summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJonathon Jongsma <jjongsma@redhat.com>2015-06-17 15:03:53 -0500
committerJonathon Jongsma <jjongsma@redhat.com>2015-06-19 14:39:47 -0500
commitbac799c6e99c7a14d39e683941a9225a5a13ee4b (patch)
tree5ca8b747b9bd58a2edb711f4544e911dd7ea6fa5
parent795d499a0f0dd29c9620c078c7cd3609a8a9adf4 (diff)
downloadvirt-viewer-bac799c6e99c7a14d39e683941a9225a5a13ee4b.tar.gz
virt-viewer-bac799c6e99c7a14d39e683941a9225a5a13ee4b.tar.xz
virt-viewer-bac799c6e99c7a14d39e683941a9225a5a13ee4b.zip
Move SpiceSession setup to create_spice_session()
Most of the setup (connecting to signals, etc) for the SpiceSession was done in create_spice_session(), but some was done afterwards in virt_viewer_session_spice_new(). Consolidate all session configuration in one place. In addition to making it easier to maintain, create_spice_session() is also called in virt_viewer_session_spice_close(). which results in a spice session that is configured slightly differently than the first session created in _new(). Consolidating everything in create_spice_session() avoids that inconsistency.
-rw-r--r--src/virt-viewer-session-spice.c118
1 files changed, 60 insertions, 58 deletions
diff --git a/src/virt-viewer-session-spice.c b/src/virt-viewer-session-spice.c
index f763975..9fe5396 100644
--- a/src/virt-viewer-session-spice.c
+++ b/src/virt-viewer-session-spice.c
@@ -254,6 +254,51 @@ static void reader_removed_cb(SpiceSmartcardManager *manager G_GNUC_UNUSED,
}
}
+#define UUID_LEN 16
+static void
+uuid_changed(GObject *gobject G_GNUC_UNUSED,
+ GParamSpec *pspec G_GNUC_UNUSED,
+ VirtViewerSessionSpice *self)
+{
+ guint8* uuid = NULL;
+ VirtViewerApp* app = virt_viewer_session_get_app(VIRT_VIEWER_SESSION(self));
+
+ g_object_get(self->priv->session, "uuid", &uuid, NULL);
+ if (uuid) {
+ int i;
+ gboolean uuid_empty = TRUE;
+
+ for (i = 0; i < UUID_LEN; i++) {
+ if (uuid[i] != 0) {
+ uuid_empty = FALSE;
+ break;
+ }
+ }
+
+ if (!uuid_empty) {
+ gchar *uuid_str = spice_uuid_to_string(uuid);
+ g_object_set(app, "uuid", uuid_str, NULL);
+ g_free(uuid_str);
+ }
+ }
+
+ virt_viewer_session_spice_fullscreen_auto_conf(self);
+}
+
+static void
+name_changed(GObject *gobject G_GNUC_UNUSED,
+ GParamSpec *pspec G_GNUC_UNUSED,
+ VirtViewerSessionSpice *self)
+{
+ gchar *name = NULL;
+ VirtViewerApp *app = virt_viewer_session_get_app(VIRT_VIEWER_SESSION(self));
+
+ g_object_get(self->priv->session, "name", &name, NULL);
+
+ g_object_set(app, "guest-name", name, NULL);
+ g_free(name);
+}
+
static void
create_spice_session(VirtViewerSessionSpice *self)
{
@@ -304,6 +349,21 @@ create_spice_session(VirtViewerSessionSpice *self)
}
g_list_free(readers);
}
+
+ /* notify::uuid is guaranteed to be emitted during connection startup even
+ * if the server is too old to support sending uuid */
+ virt_viewer_signal_connect_object(self->priv->session, "notify::uuid",
+ G_CALLBACK(uuid_changed), self, 0);
+ virt_viewer_signal_connect_object(self->priv->session, "notify::name",
+ G_CALLBACK(name_changed), self, 0);
+
+ g_object_bind_property(self->priv->session, "shared-dir",
+ self, "shared-folder",
+ G_BINDING_BIDIRECTIONAL|G_BINDING_SYNC_CREATE);
+ g_object_bind_property(self->priv->session, "share-dir-ro",
+ self, "share-folder-ro",
+ G_BINDING_BIDIRECTIONAL|G_BINDING_SYNC_CREATE);
+
}
static void
@@ -941,51 +1001,6 @@ virt_viewer_session_spice_channel_destroy(G_GNUC_UNUSED SpiceSession *s,
g_signal_emit_by_name(self, "session-disconnected", error ? error->message : NULL);
}
-#define UUID_LEN 16
-static void
-uuid_changed(GObject *gobject G_GNUC_UNUSED,
- GParamSpec *pspec G_GNUC_UNUSED,
- VirtViewerSessionSpice *self)
-{
- guint8* uuid = NULL;
- VirtViewerApp* app = virt_viewer_session_get_app(VIRT_VIEWER_SESSION(self));
-
- g_object_get(self->priv->session, "uuid", &uuid, NULL);
- if (uuid) {
- int i;
- gboolean uuid_empty = TRUE;
-
- for (i = 0; i < UUID_LEN; i++) {
- if (uuid[i] != 0) {
- uuid_empty = FALSE;
- break;
- }
- }
-
- if (!uuid_empty) {
- gchar *uuid_str = spice_uuid_to_string(uuid);
- g_object_set(app, "uuid", uuid_str, NULL);
- g_free(uuid_str);
- }
- }
-
- virt_viewer_session_spice_fullscreen_auto_conf(self);
-}
-
-static void
-name_changed(GObject *gobject G_GNUC_UNUSED,
- GParamSpec *pspec G_GNUC_UNUSED,
- VirtViewerSessionSpice *self)
-{
- gchar *name = NULL;
- VirtViewerApp *app = virt_viewer_session_get_app(VIRT_VIEWER_SESSION(self));
-
- g_object_get(self->priv->session, "name", &name, NULL);
-
- g_object_set(app, "guest-name", name, NULL);
- g_free(name);
-}
-
static void
update_share_folder(VirtViewerSessionSpice *self)
{
@@ -1024,23 +1039,10 @@ virt_viewer_session_spice_new(VirtViewerApp *app, GtkWindow *main_window)
virt_viewer_signal_connect_object(app, "notify::fullscreen",
G_CALLBACK(property_notify_do_auto_conf), self, 0);
- /* notify::uuid is guaranteed to be emitted during connection startup even
- * if the server is too old to support sending uuid */
- virt_viewer_signal_connect_object(self->priv->session, "notify::uuid",
- G_CALLBACK(uuid_changed), self, 0);
- virt_viewer_signal_connect_object(self->priv->session, "notify::name",
- G_CALLBACK(name_changed), self, 0);
virt_viewer_signal_connect_object(self, "notify::share-folder",
G_CALLBACK(update_share_folder), self,
G_CONNECT_SWAPPED);
- g_object_bind_property(self->priv->session, "shared-dir",
- self, "shared-folder",
- G_BINDING_BIDIRECTIONAL|G_BINDING_SYNC_CREATE);
- g_object_bind_property(self->priv->session, "share-dir-ro",
- self, "share-folder-ro",
- G_BINDING_BIDIRECTIONAL|G_BINDING_SYNC_CREATE);
-
return VIRT_VIEWER_SESSION(self);
}