/* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * * The contents of this file are subject to the Mozilla Public License Version * 1.1 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * http://www.mozilla.org/MPL/ * * Software distributed under the License is distributed on an "AS IS" basis, * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License * for the specific language governing rights and limitations under the * License. * * Copyright 2009-2012, Red Hat Inc. * Based on firebreath's plugin example * * Contributor(s): * Uri Lublin * Martin Stransky * Peter Hatina * * Alternatively, the contents of this file may be used under the terms of * either the GNU General Public License Version 2 or later (the "GPL"), or * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), * in which case the provisions of the GPL or the LGPL are applicable instead * of those above. If you wish to allow use of your version of this file only * under the terms of either the GPL or the LGPL, and not to allow others to * use your version of this file under the terms of the MPL, indicate your * decision by deleting the provisions above and replace them with the notice * and other provisions required by the GPL or the LGPL. If you do not delete * the provisions above, a recipient may use your version of this file under * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ #include #include #include #include "JSAPIAuto.h" #include "BrowserHost.h" #include "SPICEConsole.h" #include "controller.h" #ifndef H_SPICEConsoleAPI #define H_SPICEConsoleAPI class SPICEConsoleAPI : public FB::JSAPIAuto { public: //////////////////////////////////////////////////////////////////////////// /// @fn SPICEConsoleAPI::SPICEConsoleAPI(const SPICEConsolePtr& plugin, const FB::BrowserHostPtr host) /// /// @brief Constructor for your JSAPI object. /// You should register your methods, properties, and events /// that should be accessible to Javascript from here. /// /// @see FB::JSAPIAuto::registerMethod /// @see FB::JSAPIAuto::registerProperty /// @see FB::JSAPIAuto::registerEvent //////////////////////////////////////////////////////////////////////////// SPICEConsoleAPI(const SPICEConsolePtr& plugin, const FB::BrowserHostPtr& host) : m_plugin(plugin), m_host(host), m_connected_status(-2) { registerMethod("connect", make_method(this, &SPICEConsoleAPI::connect)); registerMethod("show", make_method(this, &SPICEConsoleAPI::show)); registerMethod("disconnect", make_method(this, &SPICEConsoleAPI::disconnect)); registerMethod("SetLanguageStrings", make_method(this, &SPICEConsoleAPI::SetLanguageStrings)); registerMethod("ConnectedStatus", make_method(this, &SPICEConsoleAPI::ConnectedStatus)); registerProperty("SSLChannels", make_property(this, &SPICEConsoleAPI::get_SSLChannels, &SPICEConsoleAPI::set_SSLChannels)); registerAttribute("hostIP", FB::variant()); registerAttribute("port", FB::variant()); registerAttribute("SecurePort", FB::variant()); registerAttribute("Password", FB::variant()); registerAttribute("CipherSuite", FB::variant()); registerAttribute("TrustStore", FB::variant()); registerAttribute("HostSubject", FB::variant()); registerAttribute("fullScreen", FB::variant()); registerAttribute("Smartcard", FB::variant()); registerAttribute("AdminConsole", FB::variant()); registerAttribute("Title", FB::variant()); registerAttribute("dynamicMenu", FB::variant()); registerAttribute("NumberOfMonitors", FB::variant()); registerAttribute("GuestHostName", FB::variant()); registerAttribute("HotKey", FB::variant()); registerAttribute("NoTaskMgrExecution", FB::variant()); registerAttribute("SendCtrlAltDelete", true); registerAttribute("UsbListenPort", FB::variant()); registerAttribute("UsbAutoShare", true); registerAttribute("ColorDepth", FB::variant()); registerAttribute("DisableEffects", FB::variant()); } /////////////////////////////////////////////////////////////////////////////// /// @fn SPICEConsoleAPI::~SPICEConsoleAPI() /// /// @brief Destructor. Remember that this object will not be released until /// the browser is done with it; this will almost definitely be after /// the plugin is released. /////////////////////////////////////////////////////////////////////////////// virtual ~SPICEConsoleAPI() {}; SPICEConsolePtr getPlugin(); // Methods void connect(); void show(); void disconnect(); void SetLanguageStrings(const std::string §ion, const std::string &lang); void SetUsbFilter(const std::string &filter); int ConnectedStatus(); // Properties std::string get_SSLChannels() const; void set_SSLChannels(const std::string &aSSLChannels); // Events FB_JSAPI_EVENT(disconnected, 1, (int)); private: SPICEConsoleWeakPtr m_plugin; FB::BrowserHostPtr m_host; std::map m_languages; std::string m_usb_filter; int m_connected_status; SpiceController m_external_controller; std::string m_trust_store_file; /* Properties */ std::string m_SSLChannels; // Controller communication void WriteToPipe(const void *data, uint32_t size); void SendInit(); void SendMsg(uint32_t id); void SendMsg(uint32_t id, const std::string &str); void SendMsg(uint32_t id, bool value); void SendMsg(uint32_t id, uint32_t value); template void SendValue(uint32_t id, std::string attributeName); bool createTrustStore(void); }; #endif // H_SPICEConsoleAPI