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.

126 lines
3.6KB

  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: The LASH API, as it stands, is basically retarded. It was
  20. * designed by retards for retards. The way it handles project state
  21. * and project directories shows a deep lack of insight into how real
  22. * software works. Since LASH doesn't provide us with the information
  23. * we need--when we need it--we just punt and only use LASH to save
  24. * and load the path to the *real* project data. One of these days a
  25. * motivated individual (probably me, unfortuately) is going to spend
  26. * a cozy afternoon implementing a replacement for LASH--a load of
  27. * shit which has been in the works for God know how many years and is
  28. * still stinking up the place. */
  29. #include "LASH.H"
  30. #include "Project.H"
  31. #include "TLE.H" // all this just for quit()
  32. #include <FL/Fl.H>
  33. extern TLE *tle;
  34. #include "debug.h"
  35. const float lash_poll_interval = 0.2f;
  36. void
  37. LASH::timer_cb ( void *v )
  38. {
  39. ((LASH*)v)->poll();
  40. Fl::repeat_timeout( lash_poll_interval, &LASH::timer_cb, v );
  41. }
  42. LASH::LASH ( )
  43. {
  44. Fl::add_timeout( lash_poll_interval, &LASH::timer_cb, this );
  45. }
  46. LASH::~LASH ( )
  47. {
  48. Fl::remove_timeout( &LASH::timer_cb );
  49. }
  50. bool
  51. LASH::handle_save_file ( const char *path )
  52. {
  53. MESSAGE( "LASH wants us to save \"%s\"", path );
  54. char *name;
  55. asprintf( &name, "%s/project-path", path );
  56. FILE *fp;
  57. if ( ! ( fp = fopen( name, "w" ) ) )
  58. {
  59. free( name );
  60. return false;
  61. }
  62. else
  63. free( name );
  64. char project_path[ 512 ];
  65. fl_filename_absolute( project_path, sizeof( project_path ), "." );
  66. fwrite( project_path, strlen( project_path ), 1, fp );
  67. fclose( fp );
  68. return true;
  69. }
  70. bool
  71. LASH::handle_restore_file ( const char *path )
  72. {
  73. MESSAGE( "LASH wants us to load \"%s\"", path );
  74. char *name;
  75. asprintf( &name, "%s/project-path", path );
  76. FILE *fp;
  77. if ( ! ( fp = fopen( name, "r" ) ) )
  78. {
  79. free( name );
  80. return false;
  81. }
  82. else
  83. free( name );
  84. char project_path[ 512 ];
  85. fgets( project_path, sizeof( project_path ), fp );
  86. fclose( fp );
  87. return Project::open( project_path );
  88. }
  89. void
  90. LASH::handle_quit ( void )
  91. {
  92. MESSAGE( "LASH wants us to quit" );
  93. tle->quit();
  94. }