[telepathy-gabble/master] Improve construct-time media channel group flags

Will Thompson will.thompson at collabora.co.uk
Thu Mar 19 08:13:09 PDT 2009


This is still not correct, hence the FIXME pending more intrusive
refactoring.
---
 src/media-channel.c                        |   32 ++++++++++++++++++++-------
 tests/twisted/constants.py                 |   14 ++++++++++++
 tests/twisted/jingle/test-incoming-call.py |   15 +++++++++++++
 3 files changed, 52 insertions(+), 9 deletions(-)

diff --git a/src/media-channel.c b/src/media-channel.c
index d5c043f..7d22b6c 100644
--- a/src/media-channel.c
+++ b/src/media-channel.c
@@ -312,9 +312,8 @@ gabble_media_channel_constructor (GType type, guint n_props,
 
   tp_intset_destroy (set);
 
-  /* Allow member adding; also, we implement the 0.17.6 properties correctly */
-  tp_group_mixin_change_flags (obj,
-      TP_CHANNEL_GROUP_FLAG_CAN_ADD | TP_CHANNEL_GROUP_FLAG_PROPERTIES, 0);
+  /* We implement the 0.17.6 properties correctly */
+  tp_group_mixin_change_flags (obj, TP_CHANNEL_GROUP_FLAG_PROPERTIES, 0);
 
   /* Set up Google relay related properties */
   jf = priv->conn->jingle_factory;
@@ -338,10 +337,12 @@ gabble_media_channel_constructor (GType type, guint n_props,
           NULL);
     }
 
-  /* act on incoming session */
   if (priv->session != NULL)
     {
-      /* make us local pending */
+      /* This is an incoming call; make us local pending and don't set any
+       * group flags (all we can do is add or remove ourselves, which is always
+       * valid per the spec)
+       */
       set = tp_intset_new ();
       tp_intset_add (set, ((TpBaseConnection *) priv->conn)->self_handle);
 
@@ -350,14 +351,27 @@ gabble_media_channel_constructor (GType type, guint n_props,
 
       tp_intset_destroy (set);
 
-      /* and update flags accordingly */
-      tp_group_mixin_change_flags (obj,
-          TP_CHANNEL_GROUP_FLAG_CAN_ADD | TP_CHANNEL_GROUP_FLAG_CAN_REMOVE, 0);
-
       /* Set up signal callbacks, emit session handler, initialize streams */
       _latch_to_session (GABBLE_MEDIA_CHANNEL (obj));
       _create_streams (GABBLE_MEDIA_CHANNEL (obj));
     }
+  else
+    {
+      /* This is an outgoing call. We'll set CanAdd here, in case the UI is
+       * using the "RequestChannel(StreamedMedia, HandleTypeNone, 0);
+       * AddMembers([h], ""); RequestStreams(h, [...])" legacy API. If the
+       * channel request came via one of the APIs where the peer is added
+       * immediately, that'll happen in media-factory.c before the channel is
+       * returned, and CanAdd will be cleared.
+       *
+       * If this channel was made with Create or Ensure, the CanAdd flag will
+       * stick around, but it shouldn't.
+       *
+       * FIXME: refactor this so we know which calling convention is in use
+       *        here, rather than poking it from media-factory.c.
+       */
+      tp_group_mixin_change_flags (obj, TP_CHANNEL_GROUP_FLAG_CAN_ADD, 0);
+    }
 
   return obj;
 }
diff --git a/tests/twisted/constants.py b/tests/twisted/constants.py
index c9c63cd..9e16267 100644
--- a/tests/twisted/constants.py
+++ b/tests/twisted/constants.py
@@ -95,6 +95,20 @@ MEDIA_STREAM_DIRECTION_SEND = 1
 MEDIA_STREAM_DIRECTION_RECEIVE = 2
 MEDIA_STREAM_DIRECTION_BIDIRECTIONAL = 3
 
+GF_CAN_ADD = 1
+GF_CAN_REMOVE = 2
+GF_CAN_RESCIND = 4
+GF_MESSAGE_ADD = 8
+GF_MESSAGE_REMOVE = 16
+GF_MESSAGE_ACCEPT = 32
+GF_MESSAGE_REJECT = 64
+GF_MESSAGE_RESCIND = 128
+GF_CHANNEL_SPECIFIC_HANDLES = 256
+GF_ONLY_ONE_GROUP = 512
+GF_HANDLE_OWNERS_NOT_AVAILABLE = 1024
+GF_PROPERTIES = 2048
+GF_MEMBERS_CHANGED_DETAILED = 4096
+
 GC_REASON_NONE = 0
 GC_REASON_OFFLINE = 1
 GC_REASON_KICKED = 2
diff --git a/tests/twisted/jingle/test-incoming-call.py b/tests/twisted/jingle/test-incoming-call.py
index 4a76c2c..760a949 100644
--- a/tests/twisted/jingle/test-incoming-call.py
+++ b/tests/twisted/jingle/test-incoming-call.py
@@ -92,6 +92,21 @@ def test(q, bus, conn, stream):
     assert channel_props['InitiatorHandle'] == remote_handle
     assert channel_props['Requested'] == False
 
+    group_props = media_chan.GetAll(cs.CHANNEL_IFACE_GROUP,
+        dbus_interface=dbus.PROPERTIES_IFACE)
+
+    assert group_props['SelfHandle'] == self_handle, \
+        (group_props['SelfHandle'], self_handle)
+
+    flags = group_props['GroupFlags']
+    assert flags & cs.GF_PROPERTIES, flags
+    # Changing members in any way other than adding or removing yourself is
+    # meaningless for incoming calls, and the flags need not be sent to change
+    # your own membership.
+    assert not flags & cs.GF_CAN_ADD, flags
+    assert not flags & cs.GF_CAN_REMOVE, flags
+    assert not flags & cs.GF_CAN_RESCIND, flags
+
     streams = media_chan.ListStreams(
             dbus_interface=cs.CHANNEL_TYPE_STREAMED_MEDIA)
     assert len(streams) == 1, streams
-- 
1.5.6.5




More information about the telepathy-commits mailing list