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.

124 lines
3.4KB

  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 "util/debug.h"
  20. LASH_Client::LASH_Client ( )
  21. {
  22. _void = 0;
  23. }
  24. LASH_Client::~LASH_Client ( )
  25. {
  26. /* TODO: anything? */
  27. }
  28. #ifdef HAVE_LASH
  29. #include <lash/lash.h>
  30. #define _client (static_cast<lash_client_t*>(_void))
  31. bool
  32. LASH_Client::init ( const char *jack_name, const char *long_name, int *argc, char ***argv )
  33. {
  34. if ( ! ( _void = lash_init( lash_extract_args( argc, argv ), jack_name,
  35. LASH_Config_File, LASH_PROTOCOL( 2, 0 ) ) ) )
  36. return false;
  37. /* register name */
  38. lash_jack_client_name( _client, jack_name );
  39. lash_event_t *e = lash_event_new_with_type( LASH_Client_Name );
  40. lash_event_set_string( e, long_name );
  41. lash_send_event( _client, e );
  42. return true;
  43. }
  44. bool
  45. LASH_Client::enabled ( void )
  46. {
  47. return lash_enabled( _client );
  48. }
  49. /** process any queued events */
  50. void
  51. LASH_Client::poll ( void )
  52. {
  53. if ( ! _client )
  54. return;
  55. lash_event_t *e;
  56. while ( ( e = lash_get_event( _client ) ) )
  57. {
  58. const char *name = lash_event_get_string( e );
  59. switch ( lash_event_get_type( e ) )
  60. {
  61. case LASH_Save_File:
  62. handle_save_file( name );
  63. lash_send_event( _client, lash_event_new_with_type( LASH_Save_File ) );
  64. break;
  65. case LASH_Restore_File:
  66. if ( ! handle_restore_file( name ) )
  67. /* FIXME: should we tell lash that we couldn't load the song? */;
  68. lash_send_event( _client, lash_event_new_with_type( LASH_Restore_File ) );
  69. break;
  70. case LASH_Quit:
  71. handle_quit();
  72. break;
  73. default:
  74. WARNING( "unhandled LASH event" );
  75. break;
  76. }
  77. lash_event_destroy( e );
  78. }
  79. }
  80. #else
  81. bool
  82. LASH_Client::init ( const char *jack_name, const char *long_name, int *argc, char ***argv )
  83. {
  84. return true;
  85. }
  86. bool
  87. LASH_Client::enabled ( void )
  88. {
  89. return false;
  90. }
  91. void
  92. LASH_Client::poll ( void )
  93. {
  94. }
  95. #endif