2 /*******************************************************************************/
3 /* Copyright (C) 2012 Jonathan Moore Liles */
5 /* This program is free software; you can redistribute it and/or modify it */
6 /* under the terms of the GNU General Public License as published by the */
7 /* Free Software Foundation; either version 2 of the License, or (at your */
8 /* option) any later version. */
10 /* This program is distributed in the hope that it will be useful, but WITHOUT */
11 /* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or */
12 /* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for */
15 /* You should have received a copy of the GNU General Public License along */
16 /* with This program; see the file COPYING. If not,write to the Free Software */
17 /* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
18 /*******************************************************************************/
40 char *_session_manager_name;
48 ERR_INCOMPATIBLE_API = -2,
50 ERR_LAUNCH_FAILED = -4,
51 ERR_NO_SUCH_FILE = -5,
52 ERR_NO_SESSION_OPEN = -6,
53 ERR_UNSAVED_CHANGES = -7,
60 bool is_active ( void ) { return nsm_is_active; }
62 const char *session_manager_name ( void ) { return _session_manager_name; }
64 /* Client->Server methods */
65 void is_dirty ( void );
66 void is_clean ( void );
67 void progress ( float f );
68 void message( int priority, const char *msg );
69 void announce ( const char *appliction_name, const char *capabilities, const char *process_name );
71 void broadcast ( lo_message msg );
73 /* init without threading */
74 int init ( const char *nsm_url );
75 /* init with threading */
76 int init_thread ( const char *nsm_url );
78 /* call this periodically to check for new messages */
79 void check ( int timeout = 0 );
81 /* or call these to start and stop a thread (must do your own locking in handler!) */
87 /* Server->Client methods */
88 virtual int command_open ( const char *name, const char *display_name, const char *client_id, char **out_msg ) = 0;
89 virtual int command_save ( char **out_msg ) = 0;
91 virtual void command_active ( bool ) { }
93 virtual void command_session_is_loaded ( void ) { }
95 /* invoked when an unrecognized message is received. Should return 0 if you handled it, -1 otherwise. */
96 virtual int command_broadcast ( const char *, lo_message ) { return -1; }
101 static int osc_open ( const char *path, const char *types, lo_arg **argv, int argc, lo_message msg, void *user_data );
102 static int osc_save ( const char *path, const char *types, lo_arg **argv, int argc, lo_message msg, void *user_data );
103 static int osc_announce_reply ( const char *path, const char *types, lo_arg **argv, int argc, lo_message msg, void *user_data );
104 static int osc_error ( const char *path, const char *types, lo_arg **argv, int argc, lo_message msg, void *user_data );
105 static int osc_session_is_loaded ( const char *path, const char *types, lo_arg **argv, int argc, lo_message msg, void *user_data );
106 static int osc_broadcast ( const char *path, const char *types, lo_arg **argv, int argc, lo_message msg, void *user_data );