diff options
author | Christophe Fergeau <cfergeau@redhat.com> | 2012-09-27 22:57:12 +0200 |
---|---|---|
committer | Christophe Fergeau <cfergeau@redhat.com> | 2012-10-02 23:09:02 +0200 |
commit | 978a2c20dde277e8c90d24a535a5271410f8115b (patch) | |
tree | c078c10f92cd1f78d8eb9c05b51a457f27c8039c | |
parent | ec1a9c9631e0b1decd899f08a74d5d34b597c6ce (diff) |
Convert most properties to attributes
Attributes are a better replacement for the various macros that
I wrote to register properties. I didn't know about attributes ;)
-rw-r--r-- | SPICEConsoleAPI.cpp | 22 | ||||
-rw-r--r-- | SPICEConsoleAPI.h | 111 |
2 files changed, 32 insertions, 101 deletions
diff --git a/SPICEConsoleAPI.cpp b/SPICEConsoleAPI.cpp index 473554d..9529b77 100644 --- a/SPICEConsoleAPI.cpp +++ b/SPICEConsoleAPI.cpp @@ -43,28 +43,6 @@ 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 diff --git a/SPICEConsoleAPI.h b/SPICEConsoleAPI.h index 7935a3b..e184287 100644 --- a/SPICEConsoleAPI.h +++ b/SPICEConsoleAPI.h @@ -14,35 +14,6 @@ #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: @@ -63,28 +34,32 @@ 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); + registerProperty("SSLChannels", + make_property(this, + &SPICEConsoleAPI::get_SSLChannels, + &SPICEConsoleAPI::set_SSLChannels)); + + registerAttribute("hostIP", ""); + registerAttribute("port", ""); + registerAttribute("SecurePort", ""); + registerAttribute("Password", ""); + registerAttribute("CipherSuite", ""); + registerAttribute("TrustStore", ""); + registerAttribute("HostSubject", ""); + registerAttribute("fullScreen", false); + registerAttribute("Smartcard", false); + registerAttribute("AdminConsole", false); + registerAttribute("Title", ""); + registerAttribute("dynamicMenu", ""); + registerAttribute("NumberOfMonitors", ""); + registerAttribute("GuestHostName", ""); + registerAttribute("HotKey", ""); + registerAttribute("NoTaskMgrExecution", false); + registerAttribute("SendCtrlAltDelete", true); + registerAttribute("UsbListenPort", ""); + registerAttribute("UsbAutoShare", true); + registerAttribute("ColorDepth", ""); + registerAttribute("DisableEffects", ""); } /////////////////////////////////////////////////////////////////////////////// @@ -100,7 +75,11 @@ public: // Method echo FB::variant echo(const FB::variant& msg); - + + // Properties + std::string get_SSLChannels() const; + void set_SSLChannels(const std::string &aSSLChannels); + // Event helpers FB_JSAPI_EVENT(test, 0, ()); FB_JSAPI_EVENT(echo, 2, (const FB::variant&, const int)); @@ -113,33 +92,7 @@ private: 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) + std::string m_SSLChannels; }; #endif // H_SPICEConsoleAPI |