[Spice-devel] [spice-xpi 7/9] Get rid of nspr use

Christophe Fergeau cfergeau at redhat.com
Thu Mar 7 07:39:33 PST 2013


The only thing from nspr we use are typedef for bool, int32_t and
definitions of TRUE/FALSE. Any decent C/C++ compiler should provide
all of these. If this proves to be an issue, the NPAPI headers
we use to build the plugin have a nptypes.h header with the needed
defines for bool/true/false and int32_t.
---
 SpiceXPI/src/plugin/nsScriptablePeer.cpp     |  4 +-
 SpiceXPI/src/plugin/nsScriptablePeerBase.cpp |  1 -
 SpiceXPI/src/plugin/plugin.cpp               | 58 ++++++++++++++--------------
 SpiceXPI/src/plugin/plugin.h                 | 41 ++++++++++----------
 4 files changed, 51 insertions(+), 53 deletions(-)

diff --git a/SpiceXPI/src/plugin/nsScriptablePeer.cpp b/SpiceXPI/src/plugin/nsScriptablePeer.cpp
index 06ee1a0..f164aa2 100644
--- a/SpiceXPI/src/plugin/nsScriptablePeer.cpp
+++ b/SpiceXPI/src/plugin/nsScriptablePeer.cpp
@@ -249,7 +249,7 @@ bool ScriptablePluginObject::SetProperty(NPIdentifier name, const NPVariant *val
 
     std::string str;
     std::stringstream ss;
-    PRBool boolean = false;
+    bool boolean = false;
     unsigned short val = -1;
 
     if (NPVARIANT_IS_STRING(*value))
@@ -372,7 +372,7 @@ bool ScriptablePluginObject::Invoke(NPIdentifier name, const NPVariant *args,
     }
     else if (name == m_id_connect_status)
     {
-        PRInt32 ret;
+        int32_t ret;
         m_plugin->ConnectedStatus(&ret);
         INT32_TO_NPVARIANT(ret, *result);
         return true;
diff --git a/SpiceXPI/src/plugin/nsScriptablePeerBase.cpp b/SpiceXPI/src/plugin/nsScriptablePeerBase.cpp
index e120958..ea18e0a 100644
--- a/SpiceXPI/src/plugin/nsScriptablePeerBase.cpp
+++ b/SpiceXPI/src/plugin/nsScriptablePeerBase.cpp
@@ -41,7 +41,6 @@
 
 #include "config.h"
 
-#include <prtypes.h>
 #include <npapi.h>
 #include <npruntime.h>
 #include "nsScriptablePeerBase.h"
diff --git a/SpiceXPI/src/plugin/plugin.cpp b/SpiceXPI/src/plugin/plugin.cpp
index 4ac556a..33765a7 100644
--- a/SpiceXPI/src/plugin/plugin.cpp
+++ b/SpiceXPI/src/plugin/plugin.cpp
@@ -182,14 +182,14 @@ nsPluginInstance::nsPluginInstance(NPP aInstance):
     m_pid_controller(-1),
     m_connected_status(-2),
     m_instance(aInstance),
-    m_initialized(PR_TRUE),
+    m_initialized(true),
     m_window(NULL),
-    m_fullscreen(PR_FALSE),
-    m_smartcard(PR_FALSE),
-    m_admin_console(PR_FALSE),
-    m_no_taskmgr_execution(PR_FALSE),
-    m_send_ctrlaltdel(PR_TRUE),
-    m_usb_auto_share(PR_TRUE),
+    m_fullscreen(false),
+    m_smartcard(false),
+    m_admin_console(false),
+    m_no_taskmgr_execution(false),
+    m_send_ctrlaltdel(true),
+    m_usb_auto_share(true),
     m_scriptable_peer(NULL)
 {
     // create temporary directory in /tmp
@@ -212,7 +212,7 @@ nsPluginInstance::~nsPluginInstance()
 
 NPBool nsPluginInstance::init(NPWindow *aWindow)
 {
-    m_initialized = PR_TRUE;
+    m_initialized = true;
 
     m_host_ip.clear();
     m_port.clear();
@@ -234,11 +234,11 @@ NPBool nsPluginInstance::init(NPWindow *aWindow)
     m_disable_effects.clear();
     m_proxy.clear();
 
-    m_fullscreen = PR_FALSE;
-    m_smartcard = PR_FALSE;
-    m_admin_console = PR_FALSE;
-    m_no_taskmgr_execution = PR_FALSE;
-    m_send_ctrlaltdel = PR_TRUE;
+    m_fullscreen = false;
+    m_smartcard = false;
+    m_admin_console = false;
+    m_no_taskmgr_execution = false;
+    m_send_ctrlaltdel = true;
 
     return m_initialized;
 }
@@ -252,7 +252,7 @@ NPError nsPluginInstance::SetWindow(NPWindow *aWindow)
 
 void nsPluginInstance::shut()
 {
-    m_initialized = PR_FALSE;
+    m_initialized = false;
 }
 
 NPBool nsPluginInstance::isInitialized()
@@ -370,23 +370,23 @@ void nsPluginInstance::SetHostSubject(const char *aHostSubject)
 }
 
 /* attribute boolean fullScreen; */
-PRBool nsPluginInstance::GetFullScreen() const
+bool nsPluginInstance::GetFullScreen() const
 {
     return m_fullscreen;
 }
 
-void nsPluginInstance::SetFullScreen(PRBool aFullScreen)
+void nsPluginInstance::SetFullScreen(bool aFullScreen)
 {
     m_fullscreen = aFullScreen;
 }
 
 /* attribute boolean Smartcard; */
-PRBool nsPluginInstance::GetSmartcard() const
+bool nsPluginInstance::GetSmartcard() const
 {
     return m_smartcard;
 }
 
-void nsPluginInstance::SetSmartcard(PRBool aSmartcard)
+void nsPluginInstance::SetSmartcard(bool aSmartcard)
 {
     m_smartcard = aSmartcard;
 }
@@ -425,12 +425,12 @@ void nsPluginInstance::SetNumberOfMonitors(const char *aNumberOfMonitors)
 }
 
 /* attribute boolean AdminConsole; */
-PRBool nsPluginInstance::GetAdminConsole() const
+bool nsPluginInstance::GetAdminConsole() const
 {
     return m_admin_console;
 }
 
-void nsPluginInstance::SetAdminConsole(PRBool aAdminConsole)
+void nsPluginInstance::SetAdminConsole(bool aAdminConsole)
 {
     m_admin_console = aAdminConsole;
 }
@@ -458,23 +458,23 @@ void nsPluginInstance::SetHotKeys(const char *aHotKeys)
 }
 
 /* attribute boolean NoTaskMgrExecution; */
-PRBool nsPluginInstance::GetNoTaskMgrExecution() const
+bool nsPluginInstance::GetNoTaskMgrExecution() const
 {
     return m_no_taskmgr_execution;
 }
 
-void nsPluginInstance::SetNoTaskMgrExecution(PRBool aNoTaskMgrExecution)
+void nsPluginInstance::SetNoTaskMgrExecution(bool aNoTaskMgrExecution)
 {
     m_no_taskmgr_execution = aNoTaskMgrExecution;
 }
 
 /* attribute boolean SendCtrlAltDelete; */
-PRBool nsPluginInstance::GetSendCtrlAltDelete() const
+bool nsPluginInstance::GetSendCtrlAltDelete() const
 {
     return m_send_ctrlaltdel;
 }
 
-void nsPluginInstance::SetSendCtrlAltDelete(PRBool aSendCtrlAltDelete)
+void nsPluginInstance::SetSendCtrlAltDelete(bool aSendCtrlAltDelete)
 {
     m_send_ctrlaltdel = aSendCtrlAltDelete;
 }
@@ -496,12 +496,12 @@ void nsPluginInstance::SetUsbListenPort(unsigned short aUsbPort)
 }
 
 /* attribute boolean UsbAutoShare; */
-PRBool nsPluginInstance::GetUsbAutoShare() const
+bool nsPluginInstance::GetUsbAutoShare() const
 {
     return m_usb_auto_share;
 }
 
-void nsPluginInstance::SetUsbAutoShare(PRBool aUsbAutoShare)
+void nsPluginInstance::SetUsbAutoShare(bool aUsbAutoShare)
 {
     m_usb_auto_share = aUsbAutoShare;
 }
@@ -708,8 +708,8 @@ void nsPluginInstance::Connect()
         if (sport > 0)
             SendValue(CONTROLLER_SPORT, sport);
         SendValue(CONTROLLER_FULL_SCREEN,
-                   (m_fullscreen == PR_TRUE ? CONTROLLER_SET_FULL_SCREEN : 0) |
-                   (m_admin_console == PR_FALSE ? CONTROLLER_AUTO_DISPLAY_RES : 0));
+                   (m_fullscreen == true ? CONTROLLER_SET_FULL_SCREEN : 0) |
+                   (m_admin_console == false ? CONTROLLER_AUTO_DISPLAY_RES : 0));
         SendBool(CONTROLLER_ENABLE_SMARTCARD, m_smartcard);
         SendStr(CONTROLLER_PASSWORD, m_password);
         SendStr(CONTROLLER_TLS_CIPHERS, m_cipher_suite);
@@ -743,7 +743,7 @@ void nsPluginInstance::Disconnect()
         kill(-m_pid_controller, SIGTERM);
 }
 
-void nsPluginInstance::ConnectedStatus(PRInt32 *retval)
+void nsPluginInstance::ConnectedStatus(int32_t *retval)
 {
     *retval = m_connected_status;
 }
diff --git a/SpiceXPI/src/plugin/plugin.h b/SpiceXPI/src/plugin/plugin.h
index b30d946..35734a8 100644
--- a/SpiceXPI/src/plugin/plugin.h
+++ b/SpiceXPI/src/plugin/plugin.h
@@ -46,7 +46,6 @@
 #include <map>
 #include <string>
 
-#include <prtypes.h>
 #include <npapi.h>
 #include <npruntime.h>
 
@@ -77,7 +76,7 @@ public:
     void Connect();
     void Disconnect();
     void Show();
-    void ConnectedStatus(PRInt32 *retval);
+    void ConnectedStatus(int32_t *retval);
     void SetLanguageStrings(const char *aSection, const char *aLanguage);
     void SetUsbFilter(const char *aUsbFilter);
     
@@ -114,12 +113,12 @@ public:
     void SetHostSubject(const char *aHostSubject);
     
     /* attribute ing FullScreen; */
-    PRBool GetFullScreen() const;
-    void SetFullScreen(PRBool aFullScreen);
+    bool GetFullScreen() const;
+    void SetFullScreen(bool aFullScreen);
 
     /* attribute ing smartcard; */
-    PRBool GetSmartcard() const;
-    void SetSmartcard(PRBool aSmartcard);
+    bool GetSmartcard() const;
+    void SetSmartcard(bool aSmartcard);
     
     /* attribute ing Port; */
     char *GetTitle() const;
@@ -134,8 +133,8 @@ public:
     void SetNumberOfMonitors(const char *aNumberOfMonitors);
     
     /* attribute ing AdminConsole; */
-    PRBool GetAdminConsole() const;
-    void SetAdminConsole(PRBool aAdminConsole);
+    bool GetAdminConsole() const;
+    void SetAdminConsole(bool aAdminConsole);
     
     /* attribute ing GuestHostName; */
     char *GetGuestHostName() const;
@@ -146,20 +145,20 @@ public:
     void SetHotKeys(const char *aHotKeys);
     
     /* attribute ing NoTaskMgrExecution; */
-    PRBool GetNoTaskMgrExecution() const;
-    void SetNoTaskMgrExecution(PRBool aNoTaskMgrExecution);
+    bool GetNoTaskMgrExecution() const;
+    void SetNoTaskMgrExecution(bool aNoTaskMgrExecution);
     
     /* attribute ing SendCtrlAltDelete; */
-    PRBool GetSendCtrlAltDelete() const;
-    void SetSendCtrlAltDelete(PRBool aSendCtrlAltDelete);
+    bool GetSendCtrlAltDelete() const;
+    void SetSendCtrlAltDelete(bool aSendCtrlAltDelete);
     
     /* attribute unsigned short UsbListenPort; */
     unsigned short GetUsbListenPort() const;
     void SetUsbListenPort(unsigned short aUsbPort);
     
     /* attribute boolean UsbAutoShare; */
-    PRBool GetUsbAutoShare() const;
-    void SetUsbAutoShare(PRBool aUsbAutoShare);
+    bool GetUsbAutoShare() const;
+    void SetUsbAutoShare(bool aUsbAutoShare);
 
     /* attribute ing color depth; */
     char *GetColorDepth() const;
@@ -187,7 +186,7 @@ private:
   
 private:
     pid_t m_pid_controller;
-    PRInt32 m_connected_status;
+    int32_t m_connected_status;
     SpiceController m_external_controller;
 
     NPP m_instance;
@@ -202,18 +201,18 @@ private:
     std::string m_ssl_channels;
     std::string m_trust_store;
     std::string m_host_subject;
-    PRBool m_fullscreen;
-    PRBool m_smartcard;
-    PRBool m_admin_console;
+    bool m_fullscreen;
+    bool m_smartcard;
+    bool m_admin_console;
     std::string m_title;
     std::string m_dynamic_menu;
     std::string m_number_of_monitors;
     std::string m_guest_host_name;
     std::string m_hot_keys;
-    PRBool m_no_taskmgr_execution;
-    PRBool m_send_ctrlaltdel;
+    bool m_no_taskmgr_execution;
+    bool m_send_ctrlaltdel;
     std::string m_usb_filter;
-    PRBool m_usb_auto_share;
+    bool m_usb_auto_share;
     std::map<std::string, std::string> m_language;
     std::string m_color_depth;
     std::string m_disable_effects;
-- 
1.8.1.4



More information about the Spice-devel mailing list