[Spice-devel] [PATCH spice-gtk 1/2] Add agent version property

Pavel Grunt pgrunt at redhat.com
Thu Oct 23 09:29:01 PDT 2014


---
 gtk/spice-session-priv.h |  4 ++++
 gtk/spice-session.c      | 47 ++++++++++++++++++++++++++++++++++++++++++++++-
 2 files changed, 50 insertions(+), 1 deletion(-)

diff --git a/gtk/spice-session-priv.h b/gtk/spice-session-priv.h
index da43866..70cd5ce 100644
--- a/gtk/spice-session-priv.h
+++ b/gtk/spice-session-priv.h
@@ -112,6 +112,8 @@ struct _SpiceSessionPrivate {
     guint8            uuid[16];
     gchar             *name;
 
+    gchar             *agent_version;
+
     /* associated objects */
     SpiceAudio        *audio_manager;
     SpiceDesktopIntegration *desktop_integration;
@@ -173,6 +175,8 @@ guint32 spice_session_get_playback_latency(SpiceSession *session);
 void spice_session_sync_playback_latency(SpiceSession *session);
 const gchar* spice_session_get_shared_dir(SpiceSession *session);
 void spice_session_set_shared_dir(SpiceSession *session, const gchar *dir);
+const gchar* spice_session_get_agent_version(SpiceSession *session);
+void spice_session_set_agent_version(SpiceSession *session, const gchar *agent_version);
 
 G_END_DECLS
 
diff --git a/gtk/spice-session.c b/gtk/spice-session.c
index 0663380..bb2d2c3 100644
--- a/gtk/spice-session.c
+++ b/gtk/spice-session.c
@@ -112,7 +112,8 @@ enum {
     PROP_PROXY,
     PROP_SECURE_CHANNELS,
     PROP_SHARED_DIR,
-    PROP_USERNAME
+    PROP_USERNAME,
+    PROP_AGENT_VERSION,
 };
 
 /* signals */
@@ -228,6 +229,7 @@ spice_session_finalize(GObject *gobject)
     g_strfreev(s->disable_effects);
     g_strfreev(s->secure_channels);
     g_free(s->shared_dir);
+    g_free(s->agent_version);
 
     g_clear_pointer(&s->images, cache_unref);
     glz_decoder_window_destroy(s->glz_window);
@@ -512,6 +514,9 @@ static void spice_session_get_property(GObject    *gobject,
     case PROP_SHARED_DIR:
         g_value_set_string(value, spice_session_get_shared_dir(session));
         break;
+    case PROP_AGENT_VERSION:
+        g_value_set_string(value, s->agent_version);
+        break;
     default:
 	G_OBJECT_WARN_INVALID_PROPERTY_ID(gobject, prop_id, pspec);
 	break;
@@ -641,6 +646,10 @@ static void spice_session_set_property(GObject      *gobject,
     case PROP_SHARED_DIR:
         spice_session_set_shared_dir(session, g_value_get_string(value));
         break;
+    case PROP_AGENT_VERSION:
+        g_free(s->agent_version);
+        s->agent_version = g_value_dup_string(value);
+        break;
     default:
         G_OBJECT_WARN_INVALID_PROPERTY_ID(gobject, prop_id, pspec);
         break;
@@ -1219,6 +1228,20 @@ static void spice_session_class_init(SpiceSessionClass *klass)
                              G_PARAM_READWRITE |
                              G_PARAM_CONSTRUCT |
                              G_PARAM_STATIC_STRINGS));
+    /**
+     * SpiceSession:agent-version:
+     *
+     * Version string of the vd agent
+     *
+     **/
+    g_object_class_install_property
+        (gobject_class, PROP_AGENT_VERSION,
+         g_param_spec_string("agent-version",
+                             "Agent version",
+                             "Agent version",
+                             NULL,
+                             G_PARAM_READWRITE |
+                             G_PARAM_STATIC_STRINGS));
 
     g_type_class_add_private(klass, sizeof(SpiceSessionPrivate));
 }
@@ -2291,6 +2314,28 @@ void spice_session_set_shared_dir(SpiceSession *session, const gchar *dir)
     s->shared_dir = g_strdup(dir);
 }
 
+G_GNUC_INTERNAL
+const gchar* spice_session_get_agent_version(SpiceSession *session)
+{
+    SpiceSessionPrivate *s = session->priv;
+
+    g_return_val_if_fail(s != NULL, NULL);
+
+    return s->agent_version;
+}
+
+G_GNUC_INTERNAL
+void spice_session_set_agent_version(SpiceSession *session, const gchar *agent_version)
+{
+    SpiceSessionPrivate *s = session->priv;
+
+    g_return_if_fail(s != NULL);
+    g_free(s->agent_version);
+    s->agent_version = g_strdup(agent_version);
+
+    g_coroutine_object_notify(G_OBJECT(session), "agent-version");
+}
+
 /**
  * spice_session_get_proxy_uri:
  * @session: a #SpiceSession
-- 
1.9.3



More information about the Spice-devel mailing list