[Spice-commits] 6 commits - SpiceXPI/src data/test.html spice-protocol

Christophe Fergau teuf at kemper.freedesktop.org
Wed Apr 4 01:17:45 PDT 2012


 SpiceXPI/src/plugin/controller.cpp |    2 
 SpiceXPI/src/plugin/plugin.cpp     |   88 ++++++++++++++-----------------------
 SpiceXPI/src/plugin/plugin.h       |    5 +-
 data/test.html                     |    1 
 spice-protocol                     |    2 
 5 files changed, 41 insertions(+), 57 deletions(-)

New commits:
commit d07338d17d0395b3df13e78472c283b0e4851c82
Author: Christophe Fergeau <cfergeau at redhat.com>
Date:   Tue Apr 3 16:35:38 2012 +0200

    Fix printf-format string
    
    Use %z modifier for ssize_t variables, and for an uint32_t variable,
    the %l modifier shouldn't be neeeded.

diff --git a/SpiceXPI/src/plugin/controller.cpp b/SpiceXPI/src/plugin/controller.cpp
index 4c6ce9f..b912c27 100644
--- a/SpiceXPI/src/plugin/controller.cpp
+++ b/SpiceXPI/src/plugin/controller.cpp
@@ -146,7 +146,7 @@ uint32_t SpiceController::Write(const void *lpBuffer, uint32_t nBytesToWrite)
 
     if (len != (ssize_t)nBytesToWrite)
     {
-        g_warning("incomplete send, bytes to write = %lu, bytes written = %d: %s",
+        g_warning("incomplete send, bytes to write = %u, bytes written = %zd: %s",
                   nBytesToWrite, len, g_strerror(errno));
     }
 
commit a4e573924e497ca4069e8f5de9506bb9580073b8
Author: Christophe Fergeau <cfergeau at redhat.com>
Date:   Tue Apr 3 16:03:08 2012 +0200

    Remove unused SendWStr()

diff --git a/SpiceXPI/src/plugin/plugin.cpp b/SpiceXPI/src/plugin/plugin.cpp
index 561015e..8acde24 100644
--- a/SpiceXPI/src/plugin/plugin.cpp
+++ b/SpiceXPI/src/plugin/plugin.cpp
@@ -572,21 +572,6 @@ void nsPluginInstance::SendStr(uint32_t id, std::string str)
     free(msg);
 }
 
-void nsPluginInstance::SendWStr(uint32_t id, const wchar_t *str)
-{
-    size_t len = wcslen(str);
-    if (!len)
-        return;
-
-    size_t size = sizeof(ControllerData) + (len + 1) * sizeof(wchar_t);
-    ControllerData *msg = static_cast<ControllerData *>(malloc(size));
-    msg->base.id = id;
-    msg->base.size = size;
-    wcscpy(reinterpret_cast<wchar_t *>(msg->data), str);
-    WriteToPipe(msg, size);
-    free(msg);
-}
-
 void nsPluginInstance::Connect()
 {
     std::string socket_file(m_tmp_dir);
diff --git a/SpiceXPI/src/plugin/plugin.h b/SpiceXPI/src/plugin/plugin.h
index b57e615..38a8c82 100644
--- a/SpiceXPI/src/plugin/plugin.h
+++ b/SpiceXPI/src/plugin/plugin.h
@@ -177,7 +177,6 @@ private:
     void SendMsg(uint32_t id);
     void SendValue(uint32_t id, uint32_t value);
     void SendStr(uint32_t id, std::string str);
-    void SendWStr(uint32_t id, const wchar_t *str);
     void SendBool(uint32_t id, bool value);
     void CallOnDisconnected(int code);
   
commit f1f61c2ed6551848a745a0bd6559e6d7d625863f
Author: Christophe Fergeau <cfergeau at redhat.com>
Date:   Tue Apr 3 16:01:24 2012 +0200

    Change SendStr to handle a std::string
    
    All callers were using std::string::c_str(), better to move this
    call to SendStr instead of doing it everywhere.

diff --git a/SpiceXPI/src/plugin/plugin.cpp b/SpiceXPI/src/plugin/plugin.cpp
index 8ba0ba6..561015e 100644
--- a/SpiceXPI/src/plugin/plugin.cpp
+++ b/SpiceXPI/src/plugin/plugin.cpp
@@ -558,16 +558,16 @@ void nsPluginInstance::SendBool(uint32_t id, bool value)
     WriteToPipe(&msg, sizeof(msg));
 }
 
-void nsPluginInstance::SendStr(uint32_t id, const char *str)
+void nsPluginInstance::SendStr(uint32_t id, std::string str)
 {
-    if (!strlen(str))
+    if (str.empty())
         return;
 
-    size_t size = sizeof(ControllerData) + strlen(str) + 1;
+    size_t size = sizeof(ControllerData) + str.size() + 1;
     ControllerData *msg = static_cast<ControllerData *>(malloc(size));
     msg->base.id = id;
     msg->base.size = size;
-    strcpy(reinterpret_cast<char *>(msg->data), str);
+    strcpy(reinterpret_cast<char *>(msg->data), str.c_str());
     WriteToPipe(msg, size);
     free(msg);
 }
@@ -683,25 +683,25 @@ void nsPluginInstance::Connect()
         }
 
         SendInit();
-        SendStr(CONTROLLER_HOST, m_host_ip.c_str());
+        SendStr(CONTROLLER_HOST, m_host_ip);
         SendValue(CONTROLLER_PORT, atoi(m_port.c_str()));
         SendValue(CONTROLLER_SPORT, atoi(m_secure_port.c_str()));
         SendValue(CONTROLLER_FULL_SCREEN,
                    (m_fullscreen == PR_TRUE ? CONTROLLER_SET_FULL_SCREEN : 0) |
                    (m_admin_console == PR_FALSE ? CONTROLLER_AUTO_DISPLAY_RES : 0));
         SendBool(CONTROLLER_ENABLE_SMARTCARD, m_smartcard);
-        SendStr(CONTROLLER_PASSWORD, m_password.c_str());
-        SendStr(CONTROLLER_TLS_CIPHERS, m_cipher_suite.c_str());
-        SendStr(CONTROLLER_SET_TITLE, m_title.c_str());
+        SendStr(CONTROLLER_PASSWORD, m_password);
+        SendStr(CONTROLLER_TLS_CIPHERS, m_cipher_suite);
+        SendStr(CONTROLLER_SET_TITLE, m_title);
         SendBool(CONTROLLER_SEND_CAD, m_send_ctrlaltdel);
         SendBool(CONTROLLER_ENABLE_USB_AUTOSHARE, m_usb_auto_share);
-        SendStr(CONTROLLER_USB_FILTER, m_usb_filter.c_str());
-        SendStr(CONTROLLER_SECURE_CHANNELS, m_ssl_channels.c_str());
-        SendStr(CONTROLLER_CA_FILE, m_trust_store_file.c_str());
-        SendStr(CONTROLLER_HOST_SUBJECT, m_host_subject.c_str());
-        SendStr(CONTROLLER_HOTKEYS, m_hot_keys.c_str());
+        SendStr(CONTROLLER_USB_FILTER, m_usb_filter);
+        SendStr(CONTROLLER_SECURE_CHANNELS, m_ssl_channels);
+        SendStr(CONTROLLER_CA_FILE, m_trust_store_file);
+        SendStr(CONTROLLER_HOST_SUBJECT, m_host_subject);
+        SendStr(CONTROLLER_HOTKEYS, m_hot_keys);
         SendValue(CONTROLLER_COLOR_DEPTH, atoi(m_color_depth.c_str()));
-        SendStr(CONTROLLER_DISABLE_EFFECTS, m_disable_effects.c_str());
+        SendStr(CONTROLLER_DISABLE_EFFECTS, m_disable_effects);
         SendMsg(CONTROLLER_CONNECT);
         SendMsg(CONTROLLER_SHOW);
 
diff --git a/SpiceXPI/src/plugin/plugin.h b/SpiceXPI/src/plugin/plugin.h
index 91f2ce6..b57e615 100644
--- a/SpiceXPI/src/plugin/plugin.h
+++ b/SpiceXPI/src/plugin/plugin.h
@@ -176,7 +176,7 @@ private:
     void SendInit();
     void SendMsg(uint32_t id);
     void SendValue(uint32_t id, uint32_t value);
-    void SendStr(uint32_t id, const char *str);
+    void SendStr(uint32_t id, std::string str);
     void SendWStr(uint32_t id, const wchar_t *str);
     void SendBool(uint32_t id, bool value);
     void CallOnDisconnected(int code);
commit ebdc7f6f5a357c36cc86cb474fb72ae628fa38d6
Author: Christophe Fergeau <cfergeau at redhat.com>
Date:   Tue Apr 3 15:58:45 2012 +0200

    Move secure channel fixup to secure channel setter
    
    The secure channel names need to be fixed for compatibility with
    older spice versions. However, it's better to do it directly when
    m_secure_channels is set rather than waiting until its first use

diff --git a/SpiceXPI/src/plugin/plugin.cpp b/SpiceXPI/src/plugin/plugin.cpp
index 1f42214..8ba0ba6 100644
--- a/SpiceXPI/src/plugin/plugin.cpp
+++ b/SpiceXPI/src/plugin/plugin.cpp
@@ -328,6 +328,20 @@ char *nsPluginInstance::GetSSLChannels() const
 void nsPluginInstance::SetSSLChannels(const char *aSSLChannels)
 {
     m_ssl_channels = aSSLChannels;
+
+    /*
+     * HACK -- remove leading s from m_SSLChannels, e.g. "main" not "smain"
+     * RHEL5 uses 'smain' and 'sinpusts
+     * RHEL6 uses 'main'  and 'inputs'
+     */
+    std::size_t found = 0;
+    while ((found = m_ssl_channels.find("smain", found)) != std::string::npos)
+        m_ssl_channels.replace(found, 5, "main");
+
+    found = 0;
+    while ((found = m_ssl_channels.find("sinputs", found)) != std::string::npos)
+        m_ssl_channels.replace(found, 7, "inputs");
+    /* HACK */
 }
 
 //* attribute string TrustStore; */
@@ -682,21 +696,6 @@ void nsPluginInstance::Connect()
         SendBool(CONTROLLER_SEND_CAD, m_send_ctrlaltdel);
         SendBool(CONTROLLER_ENABLE_USB_AUTOSHARE, m_usb_auto_share);
         SendStr(CONTROLLER_USB_FILTER, m_usb_filter.c_str());
-
-        /*
-         * HACK -- remove leading s from m_SSLChannels, e.g. "main" not "smain"
-         * RHEL5 uses 'smain' and 'sinpusts
-         * RHEL6 uses 'main'  and 'inputs'
-         */
-        std::size_t found = 0;
-        while ((found = m_ssl_channels.find("smain", found)) != std::string::npos)
-            m_ssl_channels.replace(found, 5, "main");
-
-        found = 0;
-        while ((found = m_ssl_channels.find("sinputs", found)) != std::string::npos)
-            m_ssl_channels.replace(found, 7, "inputs");
-        /* HACK */
-
         SendStr(CONTROLLER_SECURE_CHANNELS, m_ssl_channels.c_str());
         SendStr(CONTROLLER_CA_FILE, m_trust_store_file.c_str());
         SendStr(CONTROLLER_HOST_SUBJECT, m_host_subject.c_str());
commit 841606361937df552f4e130fccd2420fa71f0dda
Author: Christophe Fergeau <cfergeau at redhat.com>
Date:   Tue Apr 3 14:59:59 2012 +0200

    Set USB filter upon connection in test.html
    
    spice-xpi doesn't currently support changing properties after the
    initial connection, so set the USB filter during initial connection
    so that USB filters can be tested.

diff --git a/data/test.html b/data/test.html
index ff7743b..675d2e6 100644
--- a/data/test.html
+++ b/data/test.html
@@ -116,6 +116,7 @@ function setConnectVars()
 	if(document.getElementById("SmartcardToggled").checked == true) { embed.Smartcard = document.getElementById("Smartcard").checked; } else { embed.Smartcard = ""; }
 	if(document.getElementById("ColorDepthToggled").checked == true) { embed.ColorDepth = document.getElementById("ColorDepth").value; } else { embed.ColorDepth = ""; }
 	if(document.getElementById("DisableEffectsToggled").checked == true) { embed.DisableEffects = document.getElementById("DisableEffects").value; } else { embed.DisableEffects = ""; }
+	setUsbFilter()
 }
 
 function show()
commit ef9289a74b0bbd836349925579304fac06f2b9d0
Author: Christophe Fergeau <cfergeau at redhat.com>
Date:   Fri Mar 30 15:04:05 2012 +0200

    Handle USB-related plugin properties
    
    The Firefox plugin exposes the UsbAutoShare property and the SetUsbFilter
    method that were not wired until now. This commit propagates their value to
    the nsPluginInstance object and send them through the controller socket.

diff --git a/SpiceXPI/src/plugin/plugin.cpp b/SpiceXPI/src/plugin/plugin.cpp
index 3459869..1f42214 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_auto_share(PR_TRUE),
     m_scriptable_peer(NULL)
 {
     // create temporary directory in /tmp
@@ -231,6 +232,7 @@ NPBool nsPluginInstance::init(NPWindow *aWindow)
     m_number_of_monitors.clear();
     m_guest_host_name.clear();
     m_hot_keys.clear();
+    m_usb_filter.clear();
     m_language.clear();
     m_trust_store_file.clear();
     m_color_depth.clear();
@@ -479,17 +481,12 @@ void nsPluginInstance::SetUsbListenPort(unsigned short aUsbPort)
 /* attribute boolean UsbAutoShare; */
 PRBool nsPluginInstance::GetUsbAutoShare() const
 {
-    // this method exists due to RHEVM 2.2
-    // and should be removed some time in future,
-    // when fixed in RHEVM
-    return false;
+    return m_usb_auto_share;
 }
 
 void nsPluginInstance::SetUsbAutoShare(PRBool aUsbAutoShare)
 {
-    // this method exists due to RHEVM 2.2
-    // and should be removed some time in future,
-    // when fixed in RHEVM
+    m_usb_auto_share = aUsbAutoShare;
 }
 
 /* attribute string ColorDepth; */
@@ -683,6 +680,8 @@ void nsPluginInstance::Connect()
         SendStr(CONTROLLER_TLS_CIPHERS, m_cipher_suite.c_str());
         SendStr(CONTROLLER_SET_TITLE, m_title.c_str());
         SendBool(CONTROLLER_SEND_CAD, m_send_ctrlaltdel);
+        SendBool(CONTROLLER_ENABLE_USB_AUTOSHARE, m_usb_auto_share);
+        SendStr(CONTROLLER_USB_FILTER, m_usb_filter.c_str());
 
         /*
          * HACK -- remove leading s from m_SSLChannels, e.g. "main" not "smain"
@@ -741,9 +740,8 @@ void nsPluginInstance::SetLanguageStrings(const char *aSection, const char *aLan
 
 void nsPluginInstance::SetUsbFilter(const char *aUsbFilter)
 {
-    // this method exists due to RHEVM 2.2
-    // and should be removed some time in future,
-    // when fixed in RHEVM
+    if (aUsbFilter != NULL)
+        m_usb_filter = aUsbFilter;
 }
 
 void nsPluginInstance::CallOnDisconnected(int code)
diff --git a/SpiceXPI/src/plugin/plugin.h b/SpiceXPI/src/plugin/plugin.h
index 8b3725d..91f2ce6 100644
--- a/SpiceXPI/src/plugin/plugin.h
+++ b/SpiceXPI/src/plugin/plugin.h
@@ -208,6 +208,8 @@ private:
     std::string m_hot_keys;
     PRBool m_no_taskmgr_execution;
     PRBool m_send_ctrlaltdel;
+    std::string m_usb_filter;
+    PRBool m_usb_auto_share;
     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


More information about the Spice-commits mailing list