1 // padthv1_nsm.h 2 // 3 /**************************************************************************** 4 Copyright (C) 2012-2020, rncbc aka Rui Nuno Capela. All rights reserved. 5 6 This program is free software; you can redistribute it and/or 7 modify it under the terms of the GNU General Public License 8 as published by the Free Software Foundation; either version 2 9 of the License, or (at your option) any later version. 10 11 This program is distributed in the hope that it will be useful, 12 but WITHOUT ANY WARRANTY; without even the implied warranty of 13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 GNU General Public License for more details. 15 16 You should have received a copy of the GNU General Public License along 17 with this program; if not, write to the Free Software Foundation, Inc., 18 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 19 20 *****************************************************************************/ 21 22 #ifndef __padthv1_nsm_h 23 #define __padthv1_nsm_h 24 25 #include "padthv1_config.h" 26 27 #include <QObject> 28 29 #ifdef CONFIG_LIBLO 30 #include <lo/lo.h> 31 #endif 32 33 34 //--------------------------------------------------------------------------- 35 // padthv1_nsm - NSM OSC client agent. 36 37 class padthv1_nsm : public QObject 38 { 39 Q_OBJECT 40 41 public: 42 43 // Constructor. 44 padthv1_nsm(const QString& nsm_url, QObject *pParent = 0); 45 46 // Destructor. 47 ~padthv1_nsm(); 48 49 // Session activation accessor. 50 bool is_active() const; 51 52 // Session manager accessors. 53 const QString& manager() const; 54 const QString& capabilities() const; 55 56 // Session client accessors. 57 const QString& path_name() const; 58 const QString& display_name() const; 59 const QString& client_name() const; 60 61 // Session client methods. 62 void announce(const QString& app_name, const QString& capabilities); 63 void dirty(bool is_dirty); 64 void visible(bool is_visible); 65 void progress(float percent); 66 void message(int priority, const QString& mesg); 67 68 // Status/error codes 69 enum ReplyCode 70 { 71 ERR_OK = 0, 72 ERR_GENERAL = -1, 73 ERR_INCOMPATIBLE_API = -2, 74 ERR_BLACKLISTED = -3, 75 ERR_LAUNCH_FAILED = -4, 76 ERR_NO_SUCH_FILE = -5, 77 ERR_NO_SESSION_OPEN = -6, 78 ERR_UNSAVED_CHANGES = -7, 79 ERR_NOT_NOW = -8, 80 ERR_BAD_PROJECT = -9, 81 ERR_CREATE_FAILED = -10 82 }; 83 84 // Session client reply methods. 85 void open_reply(ReplyCode reply_code = ERR_OK); 86 void save_reply(ReplyCode reply_code = ERR_OK); 87 88 // Server methods response methods. 89 void nsm_announce_error( 90 const char *mesg); 91 92 void nsm_announce_reply( 93 const char *mesg, 94 const char *manager, 95 const char *capabilities); 96 97 void nsm_open( 98 const char *path_name, 99 const char *display_name, 100 const char *client_name); 101 102 void nsm_save(); 103 void nsm_loaded(); 104 void nsm_show(); 105 void nsm_hide(); 106 107 protected: 108 109 void reply(const QString& path, ReplyCode reply_code); 110 111 signals: 112 113 // Session client callbacks. 114 void active(bool is_active); 115 void open(); 116 void save(); 117 void loaded(); 118 void show(); 119 void hide(); 120 121 private: 122 123 // Instance variables. 124 #ifdef CONFIG_LIBLO 125 lo_address m_address; 126 lo_server_thread m_thread; 127 lo_server m_server; 128 #endif 129 bool m_active; 130 QString m_manager; 131 QString m_capabilities; 132 QString m_path_name; 133 QString m_display_name; 134 QString m_client_name; 135 }; 136 137 138 #endif // __padthv1_nsm_h 139 140 // end of padthv1_nsm.h 141