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.

135 lines
3.7KB

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