diff options
author | Christophe Fergeau <cfergeau@redhat.com> | 2012-10-02 23:19:01 +0200 |
---|---|---|
committer | Christophe Fergeau <cfergeau@redhat.com> | 2012-10-02 23:19:01 +0200 |
commit | 775ddeb04e750c30b9e4c489a61f46cb0f5b9fa9 (patch) | |
tree | aad5daa78f61c1bc2750abcc942ae94488ec369e | |
parent | 8b47b54c7a08612c9c0fd6fa44d9d0ed46a85d83 (diff) |
Move SPICEPluginAPI::initSocket to SpiceController
This is an OS-specific function.
-rw-r--r-- | SPICEConsoleAPI.cpp | 16 | ||||
-rw-r--r-- | SPICEConsoleAPI.h | 12 | ||||
-rw-r--r-- | controller.cpp | 28 | ||||
-rw-r--r-- | controller.h | 3 |
4 files changed, 27 insertions, 32 deletions
diff --git a/SPICEConsoleAPI.cpp b/SPICEConsoleAPI.cpp index d617568..6445923 100644 --- a/SPICEConsoleAPI.cpp +++ b/SPICEConsoleAPI.cpp @@ -75,20 +75,6 @@ SPICEConsolePtr SPICEConsoleAPI::getPlugin() // Methods - -bool SPICEConsoleAPI::initSocket(void) -{ - std::string socket_file(m_tmp_dir); - socket_file += "/spice-xpi"; - if (setenv("SPICE_XPI_SOCKET", socket_file.c_str(), 1)) - { - return false; - } - m_external_controller.SetFilename(socket_file); - - return true; -} - bool SPICEConsoleAPI::createTrustStore(void) { // create trust store filename @@ -157,7 +143,7 @@ void SPICEConsoleAPI::connect() return; } - if (!this->initSocket()) { + if (!m_external_controller.InitSocket()) { g_critical("could not initialize controller socket"); return; } diff --git a/SPICEConsoleAPI.h b/SPICEConsoleAPI.h index 09e0b4e..8ba967f 100644 --- a/SPICEConsoleAPI.h +++ b/SPICEConsoleAPI.h @@ -95,10 +95,6 @@ public: registerAttribute("UsbAutoShare", true); registerAttribute("ColorDepth", ""); registerAttribute("DisableEffects", ""); - - // create temporary directory in /tmp - char tmp_dir[] = "/tmp/spicec-XXXXXX"; - m_tmp_dir = mkdtemp(tmp_dir); } /////////////////////////////////////////////////////////////////////////////// @@ -108,11 +104,7 @@ public: /// the browser is done with it; this will almost definitely be after /// the plugin is released. /////////////////////////////////////////////////////////////////////////////// - virtual ~SPICEConsoleAPI() - { - // delete the temporary directory used for a client socket - rmdir(m_tmp_dir.c_str()); - }; + virtual ~SPICEConsoleAPI() {}; SPICEConsolePtr getPlugin(); @@ -139,7 +131,6 @@ private: std::string m_usb_filter; int m_connected_status; SpiceController m_external_controller; - std::string m_tmp_dir; std::string m_trust_store_file; /* Properties */ @@ -154,7 +145,6 @@ private: void SendMsg(uint32_t id, uint32_t value); template<typename T> void SendValue(uint32_t id, std::string attributeName); - bool initSocket(void); bool createTrustStore(void); }; diff --git a/controller.cpp b/controller.cpp index 328f03e..ada6112 100644 --- a/controller.cpp +++ b/controller.cpp @@ -63,23 +63,28 @@ SpiceController::SpiceController(): m_client_socket(-1), m_pid_controller(-1) { + // create temporary directory in /tmp + char tmp_dir[] = "/tmp/spicec-XXXXXX"; + m_tmp_dir = mkdtemp(tmp_dir); } SpiceController::SpiceController(const std::string &name): m_client_socket(-1), - m_name(name) + m_name(name), + m_pid_controller(-1) { + // create temporary directory in /tmp + char tmp_dir[] = "/tmp/spicec-XXXXXX"; + m_tmp_dir = mkdtemp(tmp_dir); } SpiceController::~SpiceController() { g_debug(G_STRFUNC); Disconnect(); -} -void SpiceController::SetFilename(const std::string &name) -{ - m_name = name; + // delete the temporary directory used for a client socket + rmdir(m_tmp_dir.c_str()); } int SpiceController::Connect() @@ -193,6 +198,19 @@ int SpiceController::TranslateRC(int nRC) } } +bool SpiceController::InitSocket(void) +{ + std::string socket_file(m_tmp_dir); + socket_file += "/spice-xpi"; + if (setenv("SPICE_XPI_SOCKET", socket_file.c_str(), 1)) + { + return false; + } + m_name = socket_file; + + return true; +} + void SpiceController::StopClient() { if (m_pid_controller > 0) diff --git a/controller.h b/controller.h index c8a96e3..46ba12d 100644 --- a/controller.h +++ b/controller.h @@ -71,7 +71,7 @@ public: SpiceController(const std::string &name); ~SpiceController(); - void SetFilename(const std::string &name); + bool InitSocket(void); bool StartClient(void); void StopClient(void); int Connect(); @@ -85,6 +85,7 @@ private: int m_client_socket; std::string m_name; pid_t m_pid_controller; + std::string m_tmp_dir; static void *ControllerWaitHelper(void *opaque); }; |