[Spice-devel] [PATCH spice-gtk 1/3] channel: add read-only socket property

marcandre.lureau at redhat.com marcandre.lureau at redhat.com
Fri Aug 26 14:47:19 UTC 2016


From: Marc-André Lureau <marcandre.lureau at redhat.com>

Channel users (such as spice widget) may want to know some connection
details. Instead of exposing various connection properties, we may as
well just have a GSocket property, with a strong warning on usage.

Signed-off-by: Marc-André Lureau <marcandre.lureau at redhat.com>
---
 src/spice-channel.c | 23 +++++++++++++++++++++++
 1 file changed, 23 insertions(+)

diff --git a/src/spice-channel.c b/src/spice-channel.c
index 4e792a2..95662f3 100644
--- a/src/spice-channel.c
+++ b/src/spice-channel.c
@@ -85,6 +85,7 @@ enum {
     PROP_CHANNEL_TYPE,
     PROP_CHANNEL_ID,
     PROP_TOTAL_READ_BYTES,
+    PROP_SOCKET,
 };
 
 /* Signals */
@@ -215,6 +216,9 @@ static void spice_channel_get_property(GObject    *gobject,
     case PROP_TOTAL_READ_BYTES:
         g_value_set_ulong(value, c->total_read_bytes);
         break;
+    case PROP_SOCKET:
+        g_value_set_object(value, c->sock);
+        break;
     default:
         G_OBJECT_WARN_INVALID_PROPERTY_ID(gobject, prop_id, pspec);
         break;
@@ -317,6 +321,25 @@ static void spice_channel_class_init(SpiceChannelClass *klass)
                             G_PARAM_READABLE |
                             G_PARAM_STATIC_STRINGS));
 
+    /**
+     * SpiceChannel:socket:
+     *
+     * Get the underlying #GSocket. Note that you should not read or
+     * write any data to it directly since this will likely corrupt
+     * the channel stream.  This property is mainly useful to get some
+     * connections details.
+     *
+     * Since: 0.33
+     */
+    g_object_class_install_property
+        (gobject_class, PROP_SOCKET,
+         g_param_spec_object("socket",
+                             "Socket",
+                             "Underlying GSocket",
+                             G_TYPE_SOCKET,
+                             G_PARAM_READABLE |
+                             G_PARAM_STATIC_STRINGS));
+
     /**
      * SpiceChannel::channel-event:
      * @channel: the channel that emitted the signal
-- 
2.9.0



More information about the Spice-devel mailing list