[telepathy-gabble/master] Refactor adding Jingle peer to remote-pending early
Will Thompson
will.thompson at collabora.co.uk
Thu Apr 9 10:25:57 PDT 2009
---
src/media-channel.c | 59 ++++++++++++++++++++++++++++++++++++++------------
src/media-factory.c | 25 +++++++-------------
2 files changed, 54 insertions(+), 30 deletions(-)
diff --git a/src/media-channel.c b/src/media-channel.c
index bbf96a2..fece27f 100644
--- a/src/media-channel.c
+++ b/src/media-channel.c
@@ -98,6 +98,7 @@ enum
PROP_HANDLE,
PROP_TARGET_ID,
PROP_INITIAL_PEER,
+ PROP_PEER_IN_RP,
PROP_PEER,
PROP_REQUESTED,
PROP_CONNECTION,
@@ -140,6 +141,7 @@ struct _GabbleMediaChannelPrivate
gchar *object_path;
TpHandle creator;
TpHandle initial_peer;
+ gboolean peer_in_rp;
GabbleMediaFactory *factory;
GabbleJingleSession *session;
@@ -360,20 +362,37 @@ gabble_media_channel_constructor (GType type, guint n_props,
}
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);
+ /* This is an outgoing call. */
+
+ if (priv->initial_peer != 0)
+ {
+ if (priv->peer_in_rp)
+ {
+ /* This channel was created with RequestChannel(SM, Contact, h)
+ * so the peer should start out in remote pending.
+ */
+ set = tp_intset_new_containing (priv->initial_peer);
+ tp_group_mixin_change_members (obj, "", NULL, NULL, NULL, set,
+ conn->self_handle, TP_CHANNEL_GROUP_CHANGE_REASON_INVITED);
+ tp_intset_destroy (set);
+ }
+
+ /* else this channel was created with CreateChannel or EnsureChannel,
+ * so don't.
+ */
+ }
+ else
+ {
+ /* This channel was created with RequestChannel(SM, None, 0). */
+
+ /* The peer can't be in remote pending */
+ g_assert (!priv->peer_in_rp);
+
+ /* The UI may call AddMembers([h], "") before calling
+ * RequestStreams(h, [...]).
+ */
+ tp_group_mixin_change_flags (obj, TP_CHANNEL_GROUP_FLAG_CAN_ADD, 0);
+ }
}
return obj;
@@ -552,6 +571,9 @@ gabble_media_channel_set_property (GObject *object,
}
break;
+ case PROP_PEER_IN_RP:
+ priv->peer_in_rp = g_value_get_boolean (value);
+ break;
case PROP_SESSION:
g_assert (priv->session == NULL);
priv->session = g_value_dup_object (value);
@@ -648,6 +670,15 @@ gabble_media_channel_class_init (GabbleMediaChannelClass *gabble_media_channel_c
G_PARAM_CONSTRUCT_ONLY | G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
g_object_class_install_property (object_class, PROP_INITIAL_PEER, param_spec);
+ param_spec = g_param_spec_boolean ("peer-in-rp",
+ "Peer initially in Remote Pending?",
+ "True if the channel was created with the most-deprecated "
+ "RequestChannels form, and so the peer should be in Remote Pending "
+ "before any XML has been sent.",
+ FALSE,
+ G_PARAM_CONSTRUCT_ONLY | G_PARAM_WRITABLE | G_PARAM_STATIC_STRINGS);
+ g_object_class_install_property (object_class, PROP_PEER_IN_RP, param_spec);
+
param_spec = g_param_spec_uint ("peer", "Other participant",
"The TpHandle representing the other participant in the channel if "
"currently known; 0 if this is an anonymous channel on which "
diff --git a/src/media-factory.c b/src/media-factory.c
index 8d51022..30d05b0 100644
--- a/src/media-factory.c
+++ b/src/media-factory.c
@@ -190,7 +190,7 @@ gabble_media_factory_class_init (GabbleMediaFactoryClass *gabble_media_factory_c
}
static GabbleMediaChannel *new_media_channel (GabbleMediaFactory *fac,
- GabbleJingleSession *sess, TpHandle maybe_peer);
+ GabbleJingleSession *sess, TpHandle maybe_peer, gboolean peer_in_rp);
static void media_channel_closed_cb (GabbleMediaChannel *chan,
gpointer user_data);
@@ -244,7 +244,8 @@ media_channel_closed_cb (GabbleMediaChannel *chan, gpointer user_data)
static GabbleMediaChannel *
new_media_channel (GabbleMediaFactory *fac,
GabbleJingleSession *sess,
- TpHandle maybe_peer)
+ TpHandle maybe_peer,
+ gboolean peer_in_rp)
{
GabbleMediaFactoryPrivate *priv;
TpBaseConnection *conn;
@@ -266,6 +267,7 @@ new_media_channel (GabbleMediaFactory *fac,
"object-path", object_path,
"session", sess,
"initial-peer", maybe_peer,
+ "peer-in-rp", peer_in_rp,
NULL);
DEBUG ("object path %s", object_path);
@@ -328,7 +330,7 @@ new_jingle_session_cb (GabbleJingleFactory *jf, GabbleJingleSession *sess, gpoin
if (gabble_jingle_session_get_content_type (sess) ==
GABBLE_TYPE_JINGLE_MEDIA_RTP)
{
- GabbleMediaChannel *chan = new_media_channel (self, sess, sess->peer);
+ GabbleMediaChannel *chan = new_media_channel (self, sess, sess->peer, FALSE);
tp_channel_manager_emit_new_channel (self,
TP_EXPORTABLE_CHANNEL (chan), NULL);
}
@@ -460,6 +462,8 @@ gabble_media_factory_requestotron (TpChannelManager *manager,
/* Supported modes of operation:
* - RequestChannel(None, 0):
* channel is anonymous;
+ * caller may optionally use AddMembers to add the peer to RemotePending
+ * without sending them any XML;
* caller uses RequestStreams to set the peer and start the call.
* - RequestChannel(Contact, n) where n != 0:
* channel has TargetHandle=n;
@@ -519,7 +523,7 @@ gabble_media_factory_requestotron (TpChannelManager *manager,
&error))
goto error;
- channel = new_media_channel (self, NULL, 0);
+ channel = new_media_channel (self, NULL, 0, FALSE);
break;
case TP_HANDLE_TYPE_CONTACT:
@@ -550,18 +554,7 @@ gabble_media_factory_requestotron (TpChannelManager *manager,
}
}
- channel = new_media_channel (self, NULL, handle);
-
- if (add_peer_to_remote_pending)
- {
- if (!_gabble_media_channel_add_member ((GObject *) channel, handle,
- "", &error))
- {
- gabble_media_channel_close (channel);
- goto error;
- }
- }
-
+ channel = new_media_channel (self, NULL, handle, add_peer_to_remote_pending);
break;
default:
--
1.5.6.5
More information about the telepathy-commits
mailing list