[Spice-devel] [spice-xpi 1/4] Add 'Usb" property to the browser plugin

Christophe Fergeau cfergeau at redhat.com
Tue Apr 3 06:07:02 PDT 2012


This is a boolean property that enables/disables USB redirection.
---
 SpiceXPI/src/plugin/nsISpicec.idl        |    1 +
 SpiceXPI/src/plugin/nsScriptablePeer.cpp |    7 +++++++
 SpiceXPI/src/plugin/nsScriptablePeer.h   |    1 +
 SpiceXPI/src/plugin/plugin.cpp           |   12 ++++++++++++
 SpiceXPI/src/plugin/plugin.h             |    5 +++++
 spice-protocol                           |    2 +-
 6 files changed, 27 insertions(+), 1 deletion(-)

diff --git a/SpiceXPI/src/plugin/nsISpicec.idl b/SpiceXPI/src/plugin/nsISpicec.idl
index d3d0699..bbe469f 100644
--- a/SpiceXPI/src/plugin/nsISpicec.idl
+++ b/SpiceXPI/src/plugin/nsISpicec.idl
@@ -63,6 +63,7 @@ interface nsISpicec : nsISupports {
     attribute boolean Smartcard;
     attribute string ColorDepth;
     attribute string DisableEffects;
+    attribute boolean Usb;
 
     void connect();
     void show();
diff --git a/SpiceXPI/src/plugin/nsScriptablePeer.cpp b/SpiceXPI/src/plugin/nsScriptablePeer.cpp
index caab9b7..0950670 100644
--- a/SpiceXPI/src/plugin/nsScriptablePeer.cpp
+++ b/SpiceXPI/src/plugin/nsScriptablePeer.cpp
@@ -77,6 +77,7 @@ NPIdentifier ScriptablePluginObject::m_id_guest_hostname;
 NPIdentifier ScriptablePluginObject::m_id_hotkey;
 NPIdentifier ScriptablePluginObject::m_id_no_taskmgr_execution;
 NPIdentifier ScriptablePluginObject::m_id_send_ctrlaltdel;
+NPIdentifier ScriptablePluginObject::m_id_usb_redir;
 NPIdentifier ScriptablePluginObject::m_id_usb_listen_port;
 NPIdentifier ScriptablePluginObject::m_id_usb_auto_share;
 NPIdentifier ScriptablePluginObject::m_id_color_depth;
@@ -129,6 +130,7 @@ void ScriptablePluginObject::Init()
     m_id_hotkey = NPN_GetStringIdentifier("HotKey");
     m_id_no_taskmgr_execution = NPN_GetStringIdentifier("NoTaskMgrExecution");
     m_id_send_ctrlaltdel = NPN_GetStringIdentifier("SendCtrlAltDelete");
+    m_id_usb_redir = NPN_GetStringIdentifier("Usb");
     m_id_usb_listen_port = NPN_GetStringIdentifier("UsbListenPort");
     m_id_usb_auto_share = NPN_GetStringIdentifier("UsbAutoShare");
     m_id_color_depth = NPN_GetStringIdentifier("ColorDepth");
@@ -173,6 +175,7 @@ bool ScriptablePluginObject::HasProperty(NPIdentifier name)
            name == m_id_hotkey ||
            name == m_id_no_taskmgr_execution ||
            name == m_id_send_ctrlaltdel ||
+           name == m_id_usb_redir ||
            name == m_id_usb_listen_port ||
            name == m_id_usb_auto_share ||
            name == m_id_color_depth ||
@@ -222,6 +225,8 @@ bool ScriptablePluginObject::GetProperty(NPIdentifier name, NPVariant *result)
         BOOLEAN_TO_NPVARIANT(m_plugin->GetNoTaskMgrExecution(), *result);
     else if (name == m_id_send_ctrlaltdel)
         BOOLEAN_TO_NPVARIANT(m_plugin->GetSendCtrlAltDelete(), *result);
+    else if (name == m_id_usb_redir)
+        BOOLEAN_TO_NPVARIANT(m_plugin->GetUsbRedir(), *result);
     else if (name == m_id_usb_listen_port)
         INT32_TO_NPVARIANT(m_plugin->GetUsbListenPort(), *result);
     else if (name == m_id_usb_auto_share)
@@ -302,6 +307,8 @@ bool ScriptablePluginObject::SetProperty(NPIdentifier name, const NPVariant *val
         m_plugin->SetNoTaskMgrExecution(boolean);
     else if (name == m_id_send_ctrlaltdel)
         m_plugin->SetSendCtrlAltDelete(boolean);
+    else if (name == m_id_usb_redir)
+        m_plugin->SetUsbRedir(boolean);
     else if (name == m_id_usb_listen_port)
         m_plugin->SetUsbListenPort(val);
     else if (name == m_id_usb_auto_share)
diff --git a/SpiceXPI/src/plugin/nsScriptablePeer.h b/SpiceXPI/src/plugin/nsScriptablePeer.h
index 44bd53c..0fb301e 100644
--- a/SpiceXPI/src/plugin/nsScriptablePeer.h
+++ b/SpiceXPI/src/plugin/nsScriptablePeer.h
@@ -94,6 +94,7 @@ private:
     static NPIdentifier m_id_hotkey;
     static NPIdentifier m_id_no_taskmgr_execution;
     static NPIdentifier m_id_send_ctrlaltdel;
+    static NPIdentifier m_id_usb_redir;
     static NPIdentifier m_id_usb_listen_port;
     static NPIdentifier m_id_usb_auto_share;
     static NPIdentifier m_id_color_depth;
diff --git a/SpiceXPI/src/plugin/plugin.cpp b/SpiceXPI/src/plugin/plugin.cpp
index 3459869..5e40ee2 100644
--- a/SpiceXPI/src/plugin/plugin.cpp
+++ b/SpiceXPI/src/plugin/plugin.cpp
@@ -194,6 +194,7 @@ nsPluginInstance::nsPluginInstance(NPP aInstance):
     m_admin_console(PR_FALSE),
     m_no_taskmgr_execution(PR_FALSE),
     m_send_ctrlaltdel(PR_TRUE),
+    m_usb_redir(PR_FALSE),
     m_scriptable_peer(NULL)
 {
     // create temporary directory in /tmp
@@ -460,6 +461,17 @@ void nsPluginInstance::SetSendCtrlAltDelete(PRBool aSendCtrlAltDelete)
     m_send_ctrlaltdel = aSendCtrlAltDelete;
 }
 
+/* attribute boolean UsbRedir; */
+PRBool nsPluginInstance::GetUsbRedir() const
+{
+    return m_usb_redir;
+}
+
+void nsPluginInstance::SetUsbRedir(PRBool aUsbRedir)
+{
+    m_usb_redir = aUsbRedir;
+}
+
 /* attribute unsigned short UsbListenPort; */
 unsigned short nsPluginInstance::GetUsbListenPort() const
 {
diff --git a/SpiceXPI/src/plugin/plugin.h b/SpiceXPI/src/plugin/plugin.h
index 8b3725d..7f1e259 100644
--- a/SpiceXPI/src/plugin/plugin.h
+++ b/SpiceXPI/src/plugin/plugin.h
@@ -152,6 +152,10 @@ public:
     PRBool GetSendCtrlAltDelete() const;
     void SetSendCtrlAltDelete(PRBool aSendCtrlAltDelete);
     
+    /* attribute ing usbredir; */
+    PRBool GetUsbRedir() const;
+    void SetUsbRedir(PRBool aUsbRedir);
+    
     /* attribute unsigned short UsbListenPort; */
     unsigned short GetUsbListenPort() const;
     void SetUsbListenPort(unsigned short aUsbPort);
@@ -208,6 +212,7 @@ private:
     std::string m_hot_keys;
     PRBool m_no_taskmgr_execution;
     PRBool m_send_ctrlaltdel;
+    PRBool m_usb_redir;
     std::map<std::string, std::string> m_language;
     std::string m_color_depth;
     std::string m_disable_effects;
diff --git a/spice-protocol b/spice-protocol
index 8cf92f0..2d24f61 160000
--- a/spice-protocol
+++ b/spice-protocol
@@ -1 +1 @@
-Subproject commit 8cf92f042312e50b2ff186b28356053aeac9e04c
+Subproject commit 2d24f61aae4f92746940fd1c0daf546c7a51dae8
-- 
1.7.9.3



More information about the Spice-devel mailing list