summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristophe Fergeau <cfergeau@redhat.com>2013-02-13 14:28:03 +0100
committerChristophe Fergeau <cfergeau@redhat.com>2013-03-14 11:10:08 +0100
commitb1d5ebb329a2c17262bbfd6bb00fbbf01f9faf5b (patch)
treeb0aa7a10b45706ee8300136f48f8d6298e42cb5a
parente7c043bbe49858e01dc95df1aa2583519ac51580 (diff)
Add SpiceController::SetupControllerPipe
Communication with the client is done differently on Windows and Linux (named pipe VS unix socket), so move this platform-specific setup to a distinct method.
-rw-r--r--SpiceXPI/src/plugin/controller-unix.cpp15
-rw-r--r--SpiceXPI/src/plugin/controller.h2
2 files changed, 13 insertions, 4 deletions
diff --git a/SpiceXPI/src/plugin/controller-unix.cpp b/SpiceXPI/src/plugin/controller-unix.cpp
index ed4e174..338f1a8 100644
--- a/SpiceXPI/src/plugin/controller-unix.cpp
+++ b/SpiceXPI/src/plugin/controller-unix.cpp
@@ -138,6 +138,16 @@ int SpiceController::Connect(const int nRetries)
return rc;
}
+void SpiceController::SetupControllerPipe(GStrv &env)
+{
+ std::string socket_file(this->m_tmp_dir);
+ socket_file += "/spice-xpi";
+
+ this->SetFilename(socket_file);
+
+ env = g_environ_setenv(env, "SPICE_XPI_SOCKET", socket_file.c_str(), TRUE);
+}
+
void SpiceController::Disconnect()
{
// close the socket
@@ -205,12 +215,9 @@ gpointer SpiceController::ClientThread(gpointer data)
gboolean spawned;
GError *error = NULL;
- std::string socket_file(fake_this->m_tmp_dir);
- socket_file += "/spice-xpi";
- fake_this->SetFilename(socket_file);
+ fake_this->SetupControllerPipe(env);
- env = g_environ_setenv(env, "SPICE_XPI_SOCKET", socket_file.c_str(), TRUE);
if (!fake_this->m_proxy.empty())
env = g_environ_setenv(env, "SPICE_PROXY", fake_this->m_proxy.c_str(), TRUE);
diff --git a/SpiceXPI/src/plugin/controller.h b/SpiceXPI/src/plugin/controller.h
index e63e121..e19187c 100644
--- a/SpiceXPI/src/plugin/controller.h
+++ b/SpiceXPI/src/plugin/controller.h
@@ -58,6 +58,7 @@
*/
#include <glib.h>
+#include <glib-object.h> /* for GStrv */
#include <string>
extern "C" {
# include <stdint.h>
@@ -87,6 +88,7 @@ public:
private:
int Connect();
void WaitForPid(GPid pid);
+ void SetupControllerPipe(GStrv &env);
static void ChildExited(GPid pid, gint status, gpointer user_data);
static gpointer ClientThread(gpointer data);