summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--SPICEConsoleAPI.cpp55
-rw-r--r--SPICEConsoleAPI.h80
2 files changed, 135 insertions, 0 deletions
diff --git a/SPICEConsoleAPI.cpp b/SPICEConsoleAPI.cpp
index 078fa7a..473554d 100644
--- a/SPICEConsoleAPI.cpp
+++ b/SPICEConsoleAPI.cpp
@@ -43,6 +43,61 @@ SPICEConsolePtr SPICEConsoleAPI::getPlugin()
return plugin;
}
+DEFINE_PROPERTY_STRING(hostIP)
+DEFINE_PROPERTY_STRING(port)
+DEFINE_PROPERTY_STRING(SecurePort)
+DEFINE_PROPERTY_STRING(Password)
+DEFINE_PROPERTY_STRING(CipherSuite)
+//DEFINE_PROPERTY_STRING(SSLChannels)
+DEFINE_PROPERTY_STRING(TrustStore)
+DEFINE_PROPERTY_STRING(HostSubject)
+DEFINE_PROPERTY_BOOL(fullScreen)
+DEFINE_PROPERTY_BOOL(Smartcard)
+DEFINE_PROPERTY_BOOL(AdminConsole)
+DEFINE_PROPERTY_STRING(Title)
+DEFINE_PROPERTY_STRING(dynamicMenu)
+DEFINE_PROPERTY_STRING(NumberOfMonitors)
+DEFINE_PROPERTY_STRING(GuestHostName)
+DEFINE_PROPERTY_STRING(HotKey)
+DEFINE_PROPERTY_BOOL(NoTaskMgrExecution)
+DEFINE_PROPERTY_BOOL(SendCtrlAltDelete)
+DEFINE_PROPERTY_STRING(UsbListenPort)
+DEFINE_PROPERTY_BOOL(UsbAutoShare)
+DEFINE_PROPERTY_STRING(ColorDepth)
+DEFINE_PROPERTY_STRING(DisableEffects)
+
+/* attribute string SSLChannels; */
+std::string SPICEConsoleAPI::get_SSLChannels() const
+{
+ return m_SSLChannels;
+}
+
+void SPICEConsoleAPI::set_SSLChannels(const std::string &aSSLChannels)
+{
+ m_SSLChannels = aSSLChannels;
+
+ /*
+ * Backward Compatibility: Begin
+ * Remove leading 's' from m_SSLChannels, e.g. "main" not "smain"
+ * RHEL5 uses 'smain' and 'sinpusts
+ * RHEL6 uses 'main' and 'inputs'
+ */
+ const char* chan_names[] = {
+ "smain", "sdisplay", "sinputs",
+ "scursor", "splayback", "srecord",
+ "susbredir", "ssmartcard", "stunnel"
+ };
+ const int nnames = sizeof(chan_names) / sizeof(chan_names[0]);
+
+ for (int i = 0; i < nnames; i++) {
+ const char *name = chan_names[i];
+ size_t found = 0;
+ while ((found = m_SSLChannels.find(name, found)) != std::string::npos)
+ m_SSLChannels.replace(found, strlen(name), name + 1);
+ }
+ /* Backward Compatibility: End */
+}
+
void SPICEConsoleAPI::testEvent()
{
fire_test();
diff --git a/SPICEConsoleAPI.h b/SPICEConsoleAPI.h
index d32c8e6..7935a3b 100644
--- a/SPICEConsoleAPI.h
+++ b/SPICEConsoleAPI.h
@@ -14,6 +14,35 @@
#ifndef H_SPICEConsoleAPI
#define H_SPICEConsoleAPI
+#define DECLARE_PROPERTY(property, type_getter, type_setter) \
+ public: \
+ type_getter get_##property() const; \
+ void set_##property(type_setter a##property); \
+ private: \
+ type_getter m_##property;
+#define DECLARE_PROPERTY_STRING(property) DECLARE_PROPERTY(property, std::string, const std::string &)
+#define DECLARE_PROPERTY_BOOL(property) DECLARE_PROPERTY(property, bool, bool)
+
+#define DEFINE_PROPERTY(property, type_getter, type_setter) \
+type_getter SPICEConsoleAPI::get_##property() const \
+{ \
+ return m_##property; \
+} \
+\
+void SPICEConsoleAPI::set_##property(type_setter a##property) \
+{ \
+ m_##property = a##property; \
+}
+#define DEFINE_PROPERTY_STRING(property) DEFINE_PROPERTY(property, std::string, const std::string &)
+#define DEFINE_PROPERTY_BOOL(property) DEFINE_PROPERTY(property, bool, bool)
+
+#define REGISTER_PROPERTY(property) do { \
+ registerProperty(#property, \
+ make_property(this, \
+ &SPICEConsoleAPI::get_##property, \
+ &SPICEConsoleAPI::set_##property)); \
+ } while (0)
+
class SPICEConsoleAPI : public FB::JSAPIAuto
{
public:
@@ -33,6 +62,29 @@ public:
{
registerMethod("echo", make_method(this, &SPICEConsoleAPI::echo));
registerMethod("testEvent", make_method(this, &SPICEConsoleAPI::testEvent));
+
+ REGISTER_PROPERTY(hostIP);
+ REGISTER_PROPERTY(port);
+ REGISTER_PROPERTY(SecurePort);
+ REGISTER_PROPERTY(Password);
+ REGISTER_PROPERTY(CipherSuite);
+ REGISTER_PROPERTY(SSLChannels);
+ REGISTER_PROPERTY(TrustStore);
+ REGISTER_PROPERTY(HostSubject);
+ REGISTER_PROPERTY(fullScreen);
+ REGISTER_PROPERTY(Smartcard);
+ REGISTER_PROPERTY(AdminConsole);
+ REGISTER_PROPERTY(Title);
+ REGISTER_PROPERTY(dynamicMenu);
+ REGISTER_PROPERTY(NumberOfMonitors);
+ REGISTER_PROPERTY(GuestHostName);
+ REGISTER_PROPERTY(HotKey);
+ REGISTER_PROPERTY(NoTaskMgrExecution);
+ REGISTER_PROPERTY(SendCtrlAltDelete);
+ REGISTER_PROPERTY(UsbListenPort);
+ REGISTER_PROPERTY(UsbAutoShare);
+ REGISTER_PROPERTY(ColorDepth);
+ REGISTER_PROPERTY(DisableEffects);
}
///////////////////////////////////////////////////////////////////////////////
@@ -60,6 +112,34 @@ private:
SPICEConsoleWeakPtr m_plugin;
FB::BrowserHostPtr m_host;
+ /* Properties */
+ std::string m_usb_filter;
+ std::map<std::string, std::string> m_language;
+
+ // must be at the end of the file as after calling DECLARE_PROPERTY,
+ // the scope is set to private:
+ DECLARE_PROPERTY_STRING(hostIP)
+ DECLARE_PROPERTY_STRING(port)
+ DECLARE_PROPERTY_STRING(SecurePort)
+ DECLARE_PROPERTY_STRING(Password)
+ DECLARE_PROPERTY_STRING(CipherSuite)
+ DECLARE_PROPERTY_STRING(SSLChannels)
+ DECLARE_PROPERTY_STRING(TrustStore)
+ DECLARE_PROPERTY_STRING(HostSubject)
+ DECLARE_PROPERTY_BOOL(fullScreen)
+ DECLARE_PROPERTY_BOOL(Smartcard)
+ DECLARE_PROPERTY_BOOL(AdminConsole)
+ DECLARE_PROPERTY_STRING(Title)
+ DECLARE_PROPERTY_STRING(dynamicMenu)
+ DECLARE_PROPERTY_STRING(NumberOfMonitors)
+ DECLARE_PROPERTY_STRING(GuestHostName)
+ DECLARE_PROPERTY_STRING(HotKey)
+ DECLARE_PROPERTY_BOOL(NoTaskMgrExecution)
+ DECLARE_PROPERTY_BOOL(SendCtrlAltDelete)
+ DECLARE_PROPERTY_STRING(UsbListenPort)
+ DECLARE_PROPERTY_BOOL(UsbAutoShare)
+ DECLARE_PROPERTY_STRING(ColorDepth)
+ DECLARE_PROPERTY_STRING(DisableEffects)
};
#endif // H_SPICEConsoleAPI