[Telepathy-commits] [telepathy-gabble/master] GabbleJingleSession: retransmit candidates if gtalk3 dialect is detected in the middle of the session
Senko Rasic
senko at phyrexia.lan
Tue Dec 2 04:34:05 PST 2008
---
src/jingle-content.c | 9 ++++++++-
src/jingle-content.h | 1 +
src/jingle-session.c | 34 ++++++++++++++++++++++++----------
src/jingle-transport-google.c | 20 +++++++++++++++-----
src/jingle-transport-iface.c | 7 ++++---
src/jingle-transport-iface.h | 4 ++--
6 files changed, 54 insertions(+), 21 deletions(-)
diff --git a/src/jingle-content.c b/src/jingle-content.c
index e5bd2fa..e7056d6 100644
--- a/src/jingle-content.c
+++ b/src/jingle-content.c
@@ -795,7 +795,14 @@ _maybe_ready (GabbleJingleContent *self)
/* if we have pending local candidates, now's the time
* to transmit them */
- gabble_jingle_transport_iface_retransmit_candidates (priv->transport);
+ gabble_jingle_transport_iface_retransmit_candidates (priv->transport, FALSE);
+}
+
+/* Used when we detect gtalk3 after we've transmitted some candidates */
+void
+gabble_jingle_content_retransmit_candidates (GabbleJingleContent *self)
+{
+ gabble_jingle_transport_iface_retransmit_candidates (self->priv->transport, TRUE);
}
/* Called by a subclass when the media is ready (e.g. we got local codecs) */
diff --git a/src/jingle-content.h b/src/jingle-content.h
index 266ec7f..86bbee3 100644
--- a/src/jingle-content.h
+++ b/src/jingle-content.h
@@ -115,6 +115,7 @@ void gabble_jingle_content_remove (GabbleJingleContent *c, gboolean signal_peer)
GList *gabble_jingle_content_get_remote_candidates (GabbleJingleContent *c);
gboolean gabble_jingle_content_change_direction (GabbleJingleContent *c,
JingleContentSenders senders);
+void gabble_jingle_content_retransmit_candidates (GabbleJingleContent *self);
#endif /* __JINGLE_CONTENT_H__ */
diff --git a/src/jingle-session.c b/src/jingle-session.c
index f110c59..e02d9cc 100644
--- a/src/jingle-session.c
+++ b/src/jingle-session.c
@@ -835,8 +835,6 @@ on_transport_info (GabbleJingleSession *sess, LmMessageNode *node,
GabbleJingleSessionPrivate *priv = GABBLE_JINGLE_SESSION_GET_PRIVATE (sess);
GabbleJingleContent *c = NULL;
- /* FIXME: we need to do dialect detection here!!! */
-
if (JINGLE_IS_GOOGLE_DIALECT (priv->dialect))
{
/* We are certain that GTalk has only one content. It's not possible
@@ -849,24 +847,40 @@ on_transport_info (GabbleJingleSession *sess, LmMessageNode *node,
g_list_free (cs);
- /* FIXME: here we need to take care if we receive <candidates>
- * and we're in gtalk4 mode, to switch to gtalk3? */
- /* GTalk4 includes "transport" subnode */
if (priv->dialect == JINGLE_DIALECT_GTALK4)
- node = lm_message_node_get_child (node, "transport");
+ {
+ /* If we think we're in gtalk4 mode and get sent this,
+ * switch to gtalk3 mode and resend our candidates */
+ if (!tp_strdiff (node->name, "candidates"))
+ {
+ priv->dialect = JINGLE_DIALECT_GTALK3;
+ gabble_jingle_content_retransmit_candidates (c);
+ }
+ else
+ {
+ node = lm_message_node_get_child (node, "transport");
+
+ if (node == NULL)
+ {
+ SET_BAD_REQ ("illegal transport-info stanza");
+ return;
+ }
+ }
+ }
}
else
{
const gchar *name;
node = lm_message_node_get_child (node, "content");
-
name = lm_message_node_get_attribute (node, "name");
-
c = g_hash_table_lookup (priv->contents, name);
- /* FIXME: report error to peer instead of assert */
- g_assert (c != NULL);
+ if (c == NULL)
+ {
+ SET_BAD_REQ ("content doesn't exist");
+ return;
+ }
/* we need transport child of content node */
node = lm_message_node_get_child (node, "transport");
diff --git a/src/jingle-transport-google.c b/src/jingle-transport-google.c
index 5c03ec1..b22ca8a 100644
--- a/src/jingle-transport-google.c
+++ b/src/jingle-transport-google.c
@@ -531,18 +531,28 @@ add_candidates (GabbleJingleTransportIface *obj, GList *new_candidates)
}
static void
-retransmit_candidates (GabbleJingleTransportIface *obj)
+retransmit_candidates (GabbleJingleTransportIface *obj, gboolean all)
{
GabbleJingleTransportGoogle *transport =
GABBLE_JINGLE_TRANSPORT_GOOGLE (obj);
GabbleJingleTransportGooglePrivate *priv =
GABBLE_JINGLE_TRANSPORT_GOOGLE_GET_PRIVATE (transport);
- /* now transmit all pending candidates */
- if (priv->pending_candidates != NULL) {
- transmit_candidates (transport, priv->pending_candidates);
+ if (all)
+ {
+ /* for gtalk3, we might have to retransmit everything */
+ transmit_candidates (transport, priv->local_candidates);
priv->pending_candidates = NULL;
- }
+ }
+ else
+ {
+ /* in case content was ready after we wanted to transmit
+ * them originally, we are called to retranmit them */
+ if (priv->pending_candidates != NULL) {
+ transmit_candidates (transport, priv->pending_candidates);
+ priv->pending_candidates = NULL;
+ }
+ }
}
static GList *
diff --git a/src/jingle-transport-iface.c b/src/jingle-transport-iface.c
index 9b53e33..7075fe2 100644
--- a/src/jingle-transport-iface.c
+++ b/src/jingle-transport-iface.c
@@ -51,13 +51,14 @@ gabble_jingle_transport_iface_add_candidates (GabbleJingleTransportIface *self,
}
void
-gabble_jingle_transport_iface_retransmit_candidates (GabbleJingleTransportIface *self)
+gabble_jingle_transport_iface_retransmit_candidates (GabbleJingleTransportIface *self,
+ gboolean all)
{
- void (*virtual_method)(GabbleJingleTransportIface *) =
+ void (*virtual_method)(GabbleJingleTransportIface *, gboolean) =
GABBLE_JINGLE_TRANSPORT_IFACE_GET_CLASS (self)->retransmit_candidates;
g_assert (virtual_method != NULL);
- virtual_method (self);
+ virtual_method (self, all);
}
GList *
diff --git a/src/jingle-transport-iface.h b/src/jingle-transport-iface.h
index 98f5036..ab3f8e7 100644
--- a/src/jingle-transport-iface.h
+++ b/src/jingle-transport-iface.h
@@ -44,7 +44,7 @@ struct _GabbleJingleTransportIfaceClass {
LmMessageNode *, GError **);
void (*add_candidates) (GabbleJingleTransportIface *,
GList *);
- void (*retransmit_candidates) (GabbleJingleTransportIface *);
+ void (*retransmit_candidates) (GabbleJingleTransportIface *, gboolean);
GList * (*get_remote_candidates) (GabbleJingleTransportIface *);
};
@@ -64,7 +64,7 @@ GType gabble_jingle_transport_iface_get_type (void);
void gabble_jingle_transport_iface_parse_candidates (GabbleJingleTransportIface *,
LmMessageNode *, GError **);
void gabble_jingle_transport_iface_add_candidates (GabbleJingleTransportIface *, GList *);
-void gabble_jingle_transport_iface_retransmit_candidates (GabbleJingleTransportIface *);
+void gabble_jingle_transport_iface_retransmit_candidates (GabbleJingleTransportIface *, gboolean);
GList *gabble_jingle_transport_iface_get_remote_candidates (GabbleJingleTransportIface *);
G_END_DECLS
--
1.5.6.5
More information about the Telepathy-commits
mailing list