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.

119 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. /* actual implementation of our side of the LASH protocol */
  19. /* NOTES: Since LASH doesn't provide us with the information we
  20. * need--when we need it--we just punt and only use LASH to save and
  21. * load the path to the *real* project data. */
  22. #include "LASH.H"
  23. #include "Project.H"
  24. #include "TLE.H" // all this just for quit()
  25. #include <FL/Fl.H>
  26. extern TLE *tle;
  27. #include "util/debug.h"
  28. const float lash_poll_interval = 0.2f;
  29. void
  30. LASH::timer_cb ( void *v )
  31. {
  32. ((LASH*)v)->poll();
  33. Fl::repeat_timeout( lash_poll_interval, &LASH::timer_cb, v );
  34. }
  35. LASH::LASH ( )
  36. {
  37. Fl::add_timeout( lash_poll_interval, &LASH::timer_cb, this );
  38. }
  39. LASH::~LASH ( )
  40. {
  41. Fl::remove_timeout( &LASH::timer_cb );
  42. }
  43. bool
  44. LASH::handle_save_file ( const char *path )
  45. {
  46. MESSAGE( "LASH wants us to save \"%s\"", path );
  47. char *name;
  48. asprintf( &name, "%s/project-path", path );
  49. FILE *fp;
  50. if ( ! ( fp = fopen( name, "w" ) ) )
  51. {
  52. free( name );
  53. return false;
  54. }
  55. else
  56. free( name );
  57. char project_path[ 512 ];
  58. fl_filename_absolute( project_path, sizeof( project_path ), "." );
  59. fwrite( project_path, strlen( project_path ), 1, fp );
  60. fclose( fp );
  61. return true;
  62. }
  63. bool
  64. LASH::handle_restore_file ( const char *path )
  65. {
  66. MESSAGE( "LASH wants us to load \"%s\"", path );
  67. char *name;
  68. asprintf( &name, "%s/project-path", path );
  69. FILE *fp;
  70. if ( ! ( fp = fopen( name, "r" ) ) )
  71. {
  72. free( name );
  73. return false;
  74. }
  75. else
  76. free( name );
  77. char project_path[ 512 ];
  78. fgets( project_path, sizeof( project_path ), fp );
  79. fclose( fp );
  80. return Project::open( project_path );
  81. }
  82. void
  83. LASH::handle_quit ( void )
  84. {
  85. MESSAGE( "LASH wants us to quit" );
  86. tle->quit();
  87. }