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.

113 lines
3.3KB

  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. extern TLE *tle;
  33. #include "debug.h"
  34. LASH::LASH ( )
  35. {
  36. }
  37. LASH::~LASH ( )
  38. {
  39. }
  40. bool
  41. LASH::handle_save_file ( const char *path )
  42. {
  43. MESSAGE( "LASH wants us to save \"%s\"", path );
  44. char *name;
  45. asprintf( &name, "%s/project-path", path );
  46. FILE *fp;
  47. if ( ! ( fp = fopen( name, "w" ) ) )
  48. {
  49. free( name );
  50. return false;
  51. }
  52. else
  53. free( name );
  54. char project_path[ 512 ];
  55. fl_filename_absolute( project_path, sizeof( project_path ), "." );
  56. fwrite( project_path, strlen( project_path ), 1, fp );
  57. fclose( fp );
  58. return true;
  59. }
  60. bool
  61. LASH::handle_restore_file ( const char *path )
  62. {
  63. MESSAGE( "LASH wants us to load \"%s\"", path );
  64. char *name;
  65. asprintf( &name, "%s/project-path", path );
  66. FILE *fp;
  67. if ( ! ( fp = fopen( name, "r" ) ) )
  68. {
  69. free( name );
  70. return false;
  71. }
  72. else
  73. free( name );
  74. char project_path[ 512 ];
  75. fgets( project_path, sizeof( project_path ), fp );
  76. fclose( fp );
  77. return Project::open( project_path );
  78. }
  79. void
  80. LASH::handle_quit ( void )
  81. {
  82. MESSAGE( "LASH wants us to quit" );
  83. tle->quit();
  84. }