cpw.malu.xmpp.google_ft: e035ee1c: detect protocol v3 by the intiate action...
malu at pidgin.im
malu at pidgin.im
Tue Sep 28 17:40:47 EDT 2010
----------------------------------------------------------------------
Revision: e035ee1c2ea7afbf87941fbc23b7217e2cc1a279
Parent: 1bc068c0dd0e2106028752a034532325755e06ea
Author: malu at pidgin.im
Date: 09/28/10 17:35:15
Branch: im.pidgin.cpw.malu.xmpp.google_ft
URL: http://d.pidgin.im/viewmtn/revision/info/e035ee1c2ea7afbf87941fbc23b7217e2cc1a279
Changelog:
detect protocol v3 by the intiate action, avoids sending a transport-accept in this case... iGoogle still doesn't send us candidates, though... :(
Changes against parent 1bc068c0dd0e2106028752a034532325755e06ea
patched libpurple/protocols/jabber/google/google_session.c
patched libpurple/protocols/jabber/google/google_share.c
-------------- next part --------------
============================================================
--- libpurple/protocols/jabber/google/google_session.c 92bd6c6eddf4555e29ad5b74b21b67f9c3723876
+++ libpurple/protocols/jabber/google/google_session.c 8ca5b5acc88091ea9cbd234cd2384f4b14720d61
@@ -79,7 +79,7 @@ google_session_handle_initiate(JabberStr
} else if (purple_strequal(xmlns, NS_GOOGLE_SESSION_VIDEO)) {
google_av_handle_initiate(js, session, TRUE);
} else if (purple_strequal(xmlns, NS_GOOGLE_SESSION_SHARE)) {
- google_share_handle_initiate(js, session, desc_element);
+ google_share_handle_initiate(js, session, sess);
} else {
purple_debug_error("jabber", "Received initiate with "
"invalid namespace %s.\n", xmlns);
============================================================
--- libpurple/protocols/jabber/google/google_share.c 825dc0594dead567697a04c0e69bf7f787fb8042
+++ libpurple/protocols/jabber/google/google_share.c e52cad47bd08e3894f524b49bee48ae0613ddfad
@@ -238,7 +238,7 @@ google_share_nice_candidate_to_xml(const
xmlnode *candidate = xmlnode_new("candidate");
gchar address[NICE_ADDRESS_STRING_LEN];
gchar pref[16];
-
+
nice_address_to_string(&cand->addr, address);
xmlnode_set_attrib(candidate, "address", address);
xmlnode_set_attrib(candidate, "port",
@@ -311,9 +311,14 @@ google_share_candidate_gathering_done_cb
NiceCandidate *candidate = (NiceCandidate *) candidates->data;
JabberIq *iq = jabber_iq_new(session->js, JABBER_IQ_SET);
xmlnode *sess = google_share_create_candidate_node(session, candidate);
-
+ gchar *me = g_strdup_printf("%s@%s/%s",
+ session->js->user->node,
+ session->js->user->domain,
+ session->js->user->resource);
+
xmlnode_insert_child(iq->node, sess);
xmlnode_set_attrib(iq->node, "to", session->remote_jid);
+ xmlnode_set_attrib(iq->node, "from", me);
jabber_iq_send(iq);
nice_candidate_free(candidate);
@@ -466,9 +471,9 @@ google_share_accept_cb(JabberStream *js,
JabberIq *iq = jabber_iq_new(session->js, JABBER_IQ_SET);
xmlnode *sess = google_session_create_xmlnode(session, "info");
xmlnode *channel = xmlnode_new_child(sess, "channel");
-
+
session_data->channel_name = jabber_get_next_id(session->js);
-
+
xmlnode_set_namespace(channel, NS_GOOGLE_SESSION_SHARE);
xmlnode_set_attrib(channel, "name", session_data->channel_name);
xmlnode_set_attrib(iq->node, "to", session->remote_jid);
@@ -516,25 +521,42 @@ google_share_init(PurpleXfer *xfer)
google_share_init(PurpleXfer *xfer)
{
GoogleSession *session = (GoogleSession *) xfer->data;
+ GoogleShareSessionData *session_data =
+ (GoogleShareSessionData *) session->session_data;
gchar *me = g_strdup_printf("%s@%s/%s",
session->js->user->node,
session->js->user->domain,
session->js->user->resource);
- JabberIq *iq;
- xmlnode *sess;
- xmlnode *transport;
- /* send transport-accept
- should this only be for Google session v0.4? */
- iq = jabber_iq_new(session->js, JABBER_IQ_SET);
- sess = google_session_create_xmlnode(session, "transport-accept");
- transport = xmlnode_new_child(sess, "transport");
- xmlnode_set_namespace(transport, NS_GOOGLE_TRANSPORT_P2P);
- xmlnode_set_attrib(iq->node, "to", session->remote_jid);
- xmlnode_set_attrib(iq->node, "from", me);
- xmlnode_insert_child(iq->node, sess);
- jabber_iq_set_callback(iq, google_share_transport_accept_cb, session);
- jabber_iq_send(iq);
+ if (session_data->old_protocol) {
+ JabberIq *iq = jabber_iq_new(session->js, JABBER_IQ_SET);
+ xmlnode *sess = google_session_create_xmlnode(session, "accept");
+ xmlnode *transport = xmlnode_new_child(sess, "transport");
+
+ xmlnode_set_attrib(iq->node, "to", session->remote_jid);
+ xmlnode_set_attrib(iq->node, "from", me);
+ xmlnode_insert_child(iq->node, sess);
+ xmlnode_insert_child(sess, xmlnode_copy(session->description));
+ xmlnode_set_namespace(transport, NS_GOOGLE_TRANSPORT_P2P);
+ jabber_iq_set_callback(iq, google_share_accept_cb, session);
+ jabber_iq_send(iq);
+ } else {
+ JabberIq *iq;
+ xmlnode *sess;
+ xmlnode *transport;
+
+ /* send transport-accept
+ should this only be for Google session v0.4? */
+ iq = jabber_iq_new(session->js, JABBER_IQ_SET);
+ sess = google_session_create_xmlnode(session, "transport-accept");
+ transport = xmlnode_new_child(sess, "transport");
+ xmlnode_set_namespace(transport, NS_GOOGLE_TRANSPORT_P2P);
+ xmlnode_set_attrib(iq->node, "to", session->remote_jid);
+ xmlnode_set_attrib(iq->node, "from", me);
+ xmlnode_insert_child(iq->node, sess);
+ jabber_iq_set_callback(iq, google_share_transport_accept_cb, session);
+ jabber_iq_send(iq);
+ }
}
static void
@@ -607,16 +629,19 @@ void google_share_handle_initiate(Jabber
}
void google_share_handle_initiate(JabberStream *js, GoogleSession *session,
- const xmlnode *description)
+ const xmlnode *sess)
{
PurpleAccount *account =
purple_connection_get_account(js->gc);
GoogleShareSessionData *session_data =
g_new0(GoogleShareSessionData, 1);
+ const xmlnode *description =
+ xmlnode_get_child(sess, "description");
const xmlnode *manifest =
xmlnode_get_child(description, "manifest");
const xmlnode *file =
xmlnode_get_child(manifest, "file");
+ const xmlnode *transport = xmlnode_get_child(sess, "transport");
guint size = atoi(xmlnode_get_attrib(file, "size"));
gchar *name =
xmlnode_get_data(xmlnode_get_child(file, "name"));
@@ -635,6 +660,10 @@ void google_share_handle_initiate(Jabber
session_data->buffer = purple_circ_buffer_new(65536);
session->session_data = session_data;
session->handle_transport_info_cb = google_share_handle_transport_info;
+
+ if (transport == NULL) {
+ session_data->old_protocol = TRUE;
+ }
if (js->google_relay_host && js->google_relay_token) {
jabber_google_do_relay_request(js, session,
More information about the Commits
mailing list