cpw.malu.xmpp.jingle_ft: 59e628a4: Wait for response on the <activated/> re..
malu at pidgin.im
malu at pidgin.im
Sun Jan 3 18:15:43 EST 2010
-----------------------------------------------------------------
Revision: 59e628a416cb654147139540302e3659c65dafd5
Ancestor: 59668003f83aa4a06fc23061aaa1f76e2d9b21a9
Author: malu at pidgin.im
Date: 2010-01-03T23:14:31
Branch: im.pidgin.cpw.malu.xmpp.jingle_ft
URL: http://d.pidgin.im/viewmtn/revision/info/59e628a416cb654147139540302e3659c65dafd5
Modified files:
libpurple/protocols/jabber/jingle/s5b.c
ChangeLog:
Wait for response on the <activated/> response before starting the stream when using a proxy.
Implement the new <proxy-error/> transport-info message to deal with situation when failing to connect to a proxy _we_ suggested (could happen when using a restrictive firewall, f.ex.)
This will probably make it into the next revision of the XEP and might need a version suffix update later on...
This code is currently untested... :)
-------------- next part --------------
============================================================
--- libpurple/protocols/jabber/jingle/s5b.c b91ef8fdd59630e523cbcc7b05a65bd8086036bb
+++ libpurple/protocols/jabber/jingle/s5b.c 7d51fa138d27683dc6c41a410ab9d4d636ec7e31
@@ -1174,6 +1174,20 @@ jingle_s5b_create_activated(JingleSessio
return activated;
}
+static JabberIq *
+jingle_s5b_create_proxy_error(JingleSession *session, JingleS5B *s5b)
+{
+ JabberIq *proxy_error =
+ jingle_session_to_packet(session, JINGLE_TRANSPORT_INFO);
+ xmlnode *jingle = xmlnode_get_child(proxy_error->node, "jingle");
+ xmlnode *content = xmlnode_get_child(jingle, "content");
+ xmlnode *transport = xmlnode_get_child(content, "transport");
+
+ xmlnode_insert_child(transport, xmlnode_new("proxy-error"));
+ /* include sid here? */
+ return proxy_error;
+}
+
static gboolean
jingle_s5b_connect_timeout_cb(gpointer data)
{
@@ -1302,37 +1316,86 @@ jingle_s5b_connect_to_candidate(JingleS5
g_free(dstjid);
}
+static void
+jingle_s5b_proxy_error_cb(JabberStream *js, const char *from,
+ JabberIqType type, const char *id, xmlnode *packet, gpointer data)
+{
+ JingleS5B *s5b = ((JingleS5BConnectData *) data)->s5b;
+
+ if (type == JABBER_IQ_RESULT) {
+ if (s5b->priv->failed_cb && s5b->priv->failed_content) {
+ s5b->priv->failed_cb(s5b->priv->failed_content);
+ }
+ } else {
+ /* error */
+ purple_debug_error("jingle-s5b",
+ "got an error response to the proxy error\n");
+ }
+
+ g_free(data);
+}
+
+static void
+jingle_s5b_send_proxy_error(gpointer data)
+{
+ JingleSession *session = ((JingleS5BConnectData *) data)->session;
+ JingleS5B *s5b = ((JingleS5BConnectData *) data)->s5b;
+ JabberIq *proxy_error = jingle_s5b_create_proxy_error(session, s5b);
+
+ jabber_iq_set_callback(proxy_error, jingle_s5b_proxy_error_cb, data);
+}
+
static gboolean
jingle_s5b_proxy_timeout_cb(gpointer data)
{
purple_debug_info("jingle-s5b", "timeout when connecting to proxy\n");
+ jingle_s5b_send_proxy_error(data);
+
return FALSE;
}
static void
-jingle_s5b_proxy_activate_cb(JabberStream *js, const char *from,
+jingle_s5b_activated_cb(JabberStream *js, const char *from,
JabberIqType type, const char *id, xmlnode *packet, gpointer data)
{
- JingleSession *session = ((JingleS5BConnectData *) data)->session;
JingleS5B *s5b = ((JingleS5BConnectData *) data)->s5b;
if (type == JABBER_IQ_RESULT) {
- /* we are connected to the proxy, let's start */
- /* send the <activated/> message to the other end */
- jabber_iq_send(jingle_s5b_create_activated(session, s5b));
if (s5b->priv->connect_cb && s5b->priv->connect_content) {
s5b->priv->connect_cb(s5b->priv->connect_content);
}
} else {
/* error */
purple_debug_error("jingle-s5b",
- "got an error response to the proxy activation request\n");
+ "got an error response from the activation request\n");
}
-
g_free(data);
}
static void
+jingle_s5b_proxy_activate_cb(JabberStream *js, const char *from,
+ JabberIqType type, const char *id, xmlnode *packet, gpointer data)
+{
+ if (type == JABBER_IQ_RESULT) {
+ /* we are connected to the proxy, let's start */
+ /* send the <activated/> message to the other end */
+ JingleSession *session = ((JingleS5BConnectData *) data)->session;
+ JingleS5B *s5b = ((JingleS5BConnectData *) data)->s5b;
+ JabberIq *activated = jingle_s5b_create_activated(session, s5b);
+
+ jabber_iq_set_callback(activated, jingle_s5b_activated_cb, data);
+ jabber_iq_send(jingle_s5b_create_activated(session, s5b));
+ } else {
+ /* error */
+ purple_debug_error("jingle-s5b",
+ "got an error response to the proxy activation request\n");
+ jingle_s5b_send_proxy_error(data);
+ }
+}
+
+
+
+static void
jingle_s5b_proxy_connect_cb(gpointer data, gint source, const gchar *error_message)
{
JabberIq *iq = NULL;
@@ -1351,7 +1414,7 @@ jingle_s5b_proxy_connect_cb(gpointer dat
if (source < 0) {
/* failed to connect */
purple_debug_error("jingle-s5b", "failed to connect to our own proxy\n");
- g_free(data);
+ jingle_s5b_send_proxy_error(data);
return;
}
@@ -1473,7 +1536,8 @@ jingle_s5b_handle_transport_info(JingleS
xmlnode *candidate_used = xmlnode_get_child(transport, "candidate-used");
xmlnode *candidate_error = xmlnode_get_child(transport, "candidate-error");
xmlnode *activated = xmlnode_get_child(transport, "activated");
-
+ xmlnode *proxy_error = xmlnode_get_child(transport, "proxy-error");
+
if (candidate_used) {
const gchar *cid = xmlnode_get_attrib(candidate_used, "cid");
JingleS5BCandidate *cand =
@@ -1564,6 +1628,10 @@ jingle_s5b_handle_transport_info(JingleS
s5b->priv->connect_cb(s5b->priv->connect_content);
}
}
+ } else if (proxy_error) {
+ if (s5b->priv->failed_cb && s5b->priv->failed_content) {
+ s5b->priv->failed_cb(s5b->priv->failed_content);
+ }
}
}
More information about the Commits
mailing list