summaryrefslogtreecommitdiff
path: root/gtk2_ardour/nsmclient.h
diff options
context:
space:
mode:
authorRoy Vegard Ovesen <roy.vegard.ovesen@gmail.com>2013-03-21 21:16:48 +0100
committerRoy Vegard Ovesen <roy.vegard.ovesen@gmail.com>2013-03-31 03:59:09 +0200
commit6ef371745a1b672407cc594b7ec4cd50d721c4c2 (patch)
treeb68062cfc47216a9bd210a3576f6de329c512411 /gtk2_ardour/nsmclient.h
parent236360d8ffab9f095fcda9e09b159b2a47feb6af (diff)
non-session-manager support
Implements open, save and dirtiness. No error checking, no menu items disabling.
Diffstat (limited to 'gtk2_ardour/nsmclient.h')
-rw-r--r--gtk2_ardour/nsmclient.h112
1 files changed, 112 insertions, 0 deletions
diff --git a/gtk2_ardour/nsmclient.h b/gtk2_ardour/nsmclient.h
new file mode 100644
index 0000000000..ce55e64e3f
--- /dev/null
+++ b/gtk2_ardour/nsmclient.h
@@ -0,0 +1,112 @@
+
+/*******************************************************************************/
+/* Copyright (C) 2012 Jonathan Moore Liles */
+/* */
+/* This program is free software; you can redistribute it and/or modify it */
+/* under the terms of the GNU General Public License as published by the */
+/* Free Software Foundation; either version 2 of the License, or (at your */
+/* option) any later version. */
+/* */
+/* This program is distributed in the hope that it will be useful, but WITHOUT */
+/* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or */
+/* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for */
+/* more details. */
+/* */
+/* You should have received a copy of the GNU General Public License along */
+/* with This program; see the file COPYING. If not,write to the Free Software */
+/* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+/*******************************************************************************/
+
+#pragma once
+
+#include <lo/lo.h>
+
+namespace NSM
+{
+
+ class Client
+ {
+
+ private:
+
+ const char *nsm_url;
+
+ lo_server _server;
+ lo_server_thread _st;
+ lo_address nsm_addr;
+
+ bool nsm_is_active;
+ char *_nsm_client_id;
+ char *_session_manager_name;
+ char *_nsm_client_path;
+
+ public:
+
+ enum
+ {
+ ERR_OK = 0,
+ ERR_GENERAL = -1,
+ ERR_INCOMPATIBLE_API = -2,
+ ERR_BLACKLISTED = -3,
+ ERR_LAUNCH_FAILED = -4,
+ ERR_NO_SUCH_FILE = -5,
+ ERR_NO_SESSION_OPEN = -6,
+ ERR_UNSAVED_CHANGES = -7,
+ ERR_NOT_NOW = -8
+ };
+
+ Client ( );
+ virtual ~Client ( );
+
+ bool is_active ( void ) { return nsm_is_active; }
+
+ const char *session_manager_name ( void ) { return _session_manager_name; }
+ const char *client_id ( void ) { return _nsm_client_id; }
+ const char *client_path ( void ) { return _nsm_client_path; }
+
+ /* Client->Server methods */
+ void is_dirty ( void );
+ void is_clean ( void );
+ void progress ( float f );
+ void message( int priority, const char *msg );
+ void announce ( const char *appliction_name, const char *capabilities, const char *process_name );
+
+ void broadcast ( lo_message msg );
+
+ /* init without threading */
+ int init ( const char *nsm_url );
+ /* init with threading */
+ int init_thread ( const char *nsm_url );
+
+ /* call this periodically to check for new messages */
+ void check ( int timeout = 0 );
+
+ /* or call these to start and stop a thread (must do your own locking in handler!) */
+ void start ( void );
+ void stop ( void );
+
+ protected:
+
+ /* Server->Client methods */
+ virtual int command_open ( const char *name, const char *display_name, const char *client_id, char **out_msg ) = 0;
+ virtual int command_save ( char **out_msg ) = 0;
+
+ virtual void command_active ( bool ) { }
+
+ virtual void command_session_is_loaded ( void ) { }
+
+ /* invoked when an unrecognized message is received. Should return 0 if you handled it, -1 otherwise. */
+ virtual int command_broadcast ( const char *, lo_message ) { return -1; }
+
+ private:
+
+ /* osc handlers */
+ static int osc_open ( const char *path, const char *types, lo_arg **argv, int argc, lo_message msg, void *user_data );
+ static int osc_save ( const char *path, const char *types, lo_arg **argv, int argc, lo_message msg, void *user_data );
+ static int osc_announce_reply ( const char *path, const char *types, lo_arg **argv, int argc, lo_message msg, void *user_data );
+ static int osc_error ( const char *path, const char *types, lo_arg **argv, int argc, lo_message msg, void *user_data );
+ static int osc_session_is_loaded ( const char *path, const char *types, lo_arg **argv, int argc, lo_message msg, void *user_data );
+ static int osc_broadcast ( const char *path, const char *types, lo_arg **argv, int argc, lo_message msg, void *user_data );
+
+ };
+};