Assists music production by grouping standalone programs into sessions. Community version of "Non Session Manager".
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

95 lines
3.1KB

  1. /*******************************************************************************/
  2. /* Copyright (C) 2008 Jonathan Moore Liles */
  3. /* */
  4. /* This program is free software; you can redistribute it and/or modify it */
  5. /* under the terms of the GNU General Public License as published by the */
  6. /* Free Software Foundation; either version 2 of the License, or (at your */
  7. /* option) any later version. */
  8. /* */
  9. /* This program is distributed in the hope that it will be useful, but WITHOUT */
  10. /* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or */
  11. /* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for */
  12. /* more details. */
  13. /* */
  14. /* You should have received a copy of the GNU General Public License along */
  15. /* with This program; see the file COPYING. If not,write to the Free Software */
  16. /* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
  17. /*******************************************************************************/
  18. #include "LASH_Client.H"
  19. #include <lash/lash.h>
  20. #define _client (static_cast<lash_client_t*>(_void))
  21. #include "debug.h"
  22. LASH_Client::LASH_Client ( )
  23. {
  24. _void = NULL;
  25. }
  26. LASH_Client::~LASH_Client ( )
  27. {
  28. /* TODO: anything? */
  29. }
  30. bool
  31. LASH_Client::init ( const char *jack_name, const char *long_name, int *argc, char ***argv )
  32. {
  33. if ( ! ( _void = lash_init( lash_extract_args( argc, argv ), jack_name,
  34. LASH_Config_File, LASH_PROTOCOL( 2, 0 ) ) ) )
  35. return false;
  36. /* register name */
  37. lash_jack_client_name( _client, jack_name );
  38. lash_event_t *e = lash_event_new_with_type( LASH_Client_Name );
  39. lash_event_set_string( e, long_name );
  40. lash_send_event( _client, e );
  41. return true;
  42. }
  43. /** process any queued events */
  44. void
  45. LASH_Client::poll ( void )
  46. {
  47. lash_event_t *e;
  48. while ( ( e = lash_get_event( _client ) ) )
  49. {
  50. const char *name = lash_event_get_string( e );
  51. switch ( lash_event_get_type( e ) )
  52. {
  53. case LASH_Save_File:
  54. {
  55. handle_save_file( name );
  56. lash_send_event( _client, lash_event_new_with_type( LASH_Save_File ) );
  57. break;
  58. }
  59. case LASH_Restore_File:
  60. {
  61. if ( ! handle_restore_file( name ) )
  62. /* FIXME: should we tell lash that we couldn't load the song? */;
  63. lash_send_event( _client, lash_event_new_with_type( LASH_Restore_File ) );
  64. break;
  65. }
  66. case LASH_Quit:
  67. handle_quit();
  68. break;
  69. default:
  70. WARNING( "unhandled LASH event" );
  71. }
  72. lash_event_destroy( e );
  73. }
  74. }