[Telepathy-commits] [telepathy-gabble/master] Allow adding a member to a Media channel if and only if either it has no session, or it has a session and they are the peer

Simon McVittie simon.mcvittie at collabora.co.uk
Tue Aug 19 10:51:53 PDT 2008


20080430152455-53eee-2c9f014685ab6c5d191950c4aecfa378d36632b8.gz
---
 src/gabble-media-channel.c |   25 ++++++++++++++++++++++---
 1 files changed, 22 insertions(+), 3 deletions(-)

diff --git a/src/gabble-media-channel.c b/src/gabble-media-channel.c
index 75a0b6f..f036fa3 100644
--- a/src/gabble-media-channel.c
+++ b/src/gabble-media-channel.c
@@ -1101,9 +1101,28 @@ _gabble_media_channel_add_member (GObject *obj,
 
       /* yes: invite the peer */
 
-      /* create a new session */
-      if (create_session (chan, handle, NULL, NULL, error) == NULL)
-        return FALSE;
+      if (priv->session == NULL)
+        {
+          /* create a new session */
+          if (create_session (chan, handle, NULL, NULL, error) == NULL)
+            return FALSE;
+        }
+      else
+        {
+          TpHandle peer;
+
+          g_object_get (priv->session,
+              "peer", &peer,
+              NULL);
+
+          if (peer != handle)
+            {
+              g_set_error (error, TP_ERRORS, TP_ERROR_NOT_AVAILABLE,
+                  "handle %u cannot be added: this channel's peer is %u",
+                  handle, peer);
+              return FALSE;
+            }
+        }
 
       /* make the peer remote pending */
       set = tp_intset_new ();
-- 
1.5.6.3




More information about the Telepathy-commits mailing list