[telepathy-gabble/master] include rawudp candidate in session initiate

Senko Rasic senko.rasic at collabora.co.uk
Mon Jun 29 04:43:12 PDT 2009


---
 src/jingle-content.c          |   16 ++++++++++++++++
 src/jingle-transport-rawudp.c |   41 +++++++++++++++++++++++++++++++++++++++++
 src/jingle-transport-rawudp.h |    4 ++++
 3 files changed, 61 insertions(+), 0 deletions(-)

diff --git a/src/jingle-content.c b/src/jingle-content.c
index 1f3fd68..323f6d1 100644
--- a/src/jingle-content.c
+++ b/src/jingle-content.c
@@ -36,6 +36,10 @@
 #include "namespaces.h"
 #include "util.h"
 
+/* FIXME: need this because rawudp_produce_candidate isn't
+ * virtual method on transport ifaceyet */
+#include "jingle-transport-rawudp.h"
+
 /* signal enum */
 enum
 {
@@ -701,6 +705,18 @@ gabble_jingle_content_produce_node (GabbleJingleContent *c,
       if (trans_node_out != NULL)
         *trans_node_out = trans_node;
     }
+
+  /* FIXME: We need to special-case rawudp here to include the
+   * candidate in session initiation, until we make a generic
+   * virtual method for adding transport nodes. This adds a second <transport>
+   * node...
+   */
+  if (!tp_strdiff (priv->transport_ns, NS_JINGLE_TRANSPORT_RAWUDP))
+    {
+      jingle_transport_rawudp_produce_candidate (
+          GABBLE_JINGLE_TRANSPORT_RAWUDP(priv->transport),
+          content_node);
+    }
 }
 
 void
diff --git a/src/jingle-transport-rawudp.c b/src/jingle-transport-rawudp.c
index 4934e43..4bd6ccc 100644
--- a/src/jingle-transport-rawudp.c
+++ b/src/jingle-transport-rawudp.c
@@ -314,6 +314,47 @@ parse_candidates (GabbleJingleTransportIface *obj,
     }
 }
 
+/* FIXME: this should be turned into a generic virtual method, and be
+ * passed a param with desired jingle action (to know what to produce) */
+LmMessageNode *
+jingle_transport_rawudp_produce_candidate (GabbleJingleTransportRawUdp *transport,
+  LmMessageNode *content_node)
+{
+  GabbleJingleTransportRawUdpPrivate *priv =
+    GABBLE_JINGLE_TRANSPORT_RAWUDP_GET_PRIVATE (transport);
+  JingleCandidate *c;
+  gchar port_str[16];
+  LmMessageNode *cnode;
+  LmMessageNode *trans_node =
+      lm_message_node_add_child (content_node, "transport", NULL);
+
+  lm_message_node_set_attribute (trans_node, "xmlns", priv->transport_ns);
+
+  if (priv->local_candidates == NULL)
+    {
+      DEBUG ("panic, I don't have local candidates at the required time");
+      return trans_node;
+    }
+
+  if (priv->local_candidates->next)
+      DEBUG ("several candidates available, sending only the first one");
+
+  c = (JingleCandidate *) priv->local_candidates->data;
+  sprintf (port_str, "%d", c->port);
+
+  /* FIXME: we're missing component attrib, and have hardcoded net/gen */
+  cnode = lm_message_node_add_child (trans_node, "candidate", NULL);
+  lm_message_node_set_attributes (cnode,
+      "ip", c->address,
+      "port", port_str,
+      "id", c->username,
+      "network", "0",
+      "generation", "0",
+      NULL);
+
+  return trans_node;
+}
+
 static void
 transmit_candidates (GabbleJingleTransportRawUdp *transport, GList *candidates)
 {
diff --git a/src/jingle-transport-rawudp.h b/src/jingle-transport-rawudp.h
index 5b8b610..09edd8c 100644
--- a/src/jingle-transport-rawudp.h
+++ b/src/jingle-transport-rawudp.h
@@ -61,5 +61,9 @@ struct _GabbleJingleTransportRawUdp {
 
 void jingle_transport_rawudp_register (GabbleJingleFactory *factory);
 
+LmMessageNode *
+jingle_transport_rawudp_produce_candidate (GabbleJingleTransportRawUdp *transport,
+  LmMessageNode *content_node);
+
 #endif /* __JINGLE_TRANSPORT_RAWUDP_H__ */
 
-- 
1.5.6.5




More information about the telepathy-commits mailing list