[Telepathy-commits] [telepathy-gabble/master] MediaChannel: add ::initial-peer, non-zero only if the peer was known at create-time

Will Thompson will.thompson at collabora.co.uk
Tue Sep 23 02:27:17 PDT 2008


---
 src/media-channel.c |   45 ++++++++++++++++++++++++++++++++++++++++++---
 1 files changed, 42 insertions(+), 3 deletions(-)

diff --git a/src/media-channel.c b/src/media-channel.c
index 79d8505..e4fe2e2 100644
--- a/src/media-channel.c
+++ b/src/media-channel.c
@@ -93,6 +93,7 @@ enum
   PROP_HANDLE_TYPE,
   PROP_HANDLE,
   PROP_TARGET_ID,
+  PROP_INITIAL_PEER,
   PROP_REQUESTED,
   PROP_CONNECTION,
   PROP_CREATOR,
@@ -132,6 +133,7 @@ struct _GabbleMediaChannelPrivate
   GabbleConnection *conn;
   gchar *object_path;
   TpHandle creator;
+  TpHandle initial_peer;
 
   GabbleMediaFactory *factory;
   GabbleMediaSession *session;
@@ -400,13 +402,38 @@ gabble_media_channel_get_property (GObject    *object,
       g_value_set_static_string (value, TP_IFACE_CHANNEL_TYPE_STREAMED_MEDIA);
       break;
     case PROP_HANDLE_TYPE:
-      g_value_set_uint (value, TP_HANDLE_TYPE_NONE);
+      /* This is used to implement TargetHandleType, which is immutable.  If
+       * the peer was known at channel-creation time, this will be Contact;
+       * otherwise, it must be None even if we subsequently learn who the peer
+       * is.
+       */
+      if (priv->initial_peer != 0)
+        g_value_set_uint (value, TP_HANDLE_TYPE_CONTACT);
+      else
+        g_value_set_uint (value, TP_HANDLE_TYPE_NONE);
       break;
+    case PROP_INITIAL_PEER:
     case PROP_HANDLE:
-      g_value_set_uint (value, 0);
+      /* As above: TargetHandle is immutable, so non-0 only if the peer handle
+       * was known at creation time.
+       */
+      g_value_set_uint (value, priv->initial_peer);
       break;
     case PROP_TARGET_ID:
-      g_value_set_static_string (value, "");
+      /* As above. */
+      if (priv->initial_peer != 0)
+        {
+          TpHandleRepoIface *repo = tp_base_connection_get_handles (
+              base_conn, TP_HANDLE_TYPE_CONTACT);
+          const gchar *target_id = tp_handle_inspect (repo, priv->initial_peer);
+
+          g_value_set_string (value, target_id);
+        }
+      else
+        {
+          g_value_set_static_string (value, "");
+        }
+
       break;
     case PROP_CONNECTION:
       g_value_set_object (value, priv->conn);
@@ -498,6 +525,9 @@ gabble_media_channel_set_property (GObject     *object,
     case PROP_FACTORY:
       priv->factory = g_value_get_object (value);
       break;
+    case PROP_INITIAL_PEER:
+      priv->initial_peer = g_value_get_uint (value);
+      break;
     default:
       param_name = g_param_spec_get_name (pspec);
 
@@ -587,6 +617,15 @@ gabble_media_channel_class_init (GabbleMediaChannelClass *gabble_media_channel_c
       G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB);
   g_object_class_install_property (object_class, PROP_TARGET_ID, param_spec);
 
+  param_spec = g_param_spec_uint ("initial-peer", "Other participant",
+      "The TpHandle representing the other participant in the channel if known "
+      "at construct-time; 0 if the other participant was unknown at the time "
+      "of channel creation",
+      0, G_MAXUINT32, 0,
+      G_PARAM_CONSTRUCT_ONLY | G_PARAM_READWRITE |
+      G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB);
+  g_object_class_install_property (object_class, PROP_INITIAL_PEER, param_spec);
+
   param_spec = g_param_spec_object ("connection", "GabbleConnection object",
       "Gabble connection object that owns this media channel object.",
       GABBLE_TYPE_CONNECTION,
-- 
1.5.6.5




More information about the Telepathy-commits mailing list