cpw.malu.xmpp.jingle_ft: e8a8038b: Move the s5b code for handling transport...
malu at pidgin.im
malu at pidgin.im
Wed Apr 15 16:20:57 EDT 2009
-----------------------------------------------------------------
Revision: e8a8038b50721fca98d265455ea2706b7b90f6b3
Ancestor: 11bffe7bad9187878914f03f05f34d2faa356633
Author: malu at pidgin.im
Date: 2009-04-15T20:16:46
Branch: im.pidgin.cpw.malu.xmpp.jingle_ft
URL: http://d.pidgin.im/viewmtn/revision/info/e8a8038b50721fca98d265455ea2706b7b90f6b3
Modified files:
libpurple/protocols/jabber/jingle/file-transfer.c
libpurple/protocols/jabber/jingle/s5b.c
libpurple/protocols/jabber/jingle/s5b.h
ChangeLog:
Move the s5b code for handling transport-accept from the FT content handler
to the s5b transport
-------------- next part --------------
============================================================
--- libpurple/protocols/jabber/jingle/file-transfer.c d68cea71420c402a1929ed0ae5db639fc8cdee16
+++ libpurple/protocols/jabber/jingle/file-transfer.c 444b9b613f9d1545429b7a0a89d50cc607b80055
@@ -464,6 +464,10 @@ jingle_file_transfer_xfer_init(PurpleXfe
sid = jabber_get_next_id(js);
jingle_s5b_set_sid(JINGLE_S5B(transport), sid);
g_free(sid);
+ jingle_s5b_set_connect_callback(JINGLE_S5B(transport),
+ jingle_file_transfer_s5b_connect_callback, content);
+ jingle_s5b_set_error_callback(JINGLE_S5B(transport),
+ jingle_file_transfer_s5b_error_callback, content);
/* start local listen on the S5B transport */
jingle_s5b_gather_streamhosts(session, JINGLE_S5B(transport));
}
@@ -721,39 +725,7 @@ jingle_file_transfer_handle_action_inter
if (JINGLE_IS_S5B(transport)) {
JingleS5B *s5b = JINGLE_S5B(transport);
xmlnode *xmltransport = xmlnode_get_child(xmlcontent, "transport");
- xmlnode *streamhost_used =
- xmlnode_get_child(xmltransport, "streamhost-used");
-
- if (streamhost_used) {
- const gchar *jid = xmlnode_get_attrib(streamhost_used, "jid");
- JabberStream *js = jingle_session_get_js(session);
-
- purple_debug_info("jingle-ft", "got streamhost-used\n");
- /* stop connection attempts */
- jingle_s5b_stop_connection_attempts(s5b);
-
- if (jingle_session_is_initiator(session) &&
- jingle_s5b_is_connected_to_remote(s5b)) {
- /* we are the initiator and both parties could connect,
- give up "ownership", see footnote 3 in XEP-0260 */
- jingle_s5b_surrender(s5b);
- } else {
- /* we are now the "owner" of the bytestream */
- jingle_s5b_take_command(s5b);
-
- /* also when receiving a <streamhost-used/> we need to
- check if that is not one of our local streamhosts,
- in which case it is a proxy, and we should connect to that */
- if (jid && !jingle_s5b_streamhost_is_local(js, jid)) {
- purple_debug_info("jingle-ft",
- "got transport-accept on a proxy, "
- "need to connect to the proxy\n");
- } else {
- /* start transfer */
- jingle_file_transfer_s5b_connect_callback(content);
- }
- }
- }
+ jingle_s5b_handle_transport_accept(s5b, session, xmltransport);
}
break;
============================================================
--- libpurple/protocols/jabber/jingle/s5b.c 3a82d683a8701536ab0a141d0e4913995cb4a039
+++ libpurple/protocols/jabber/jingle/s5b.c c69d747ca94e776e09eef7618e98a4b116158d1e
@@ -1114,7 +1114,7 @@ jingle_s5b_take_command(JingleS5B *s5b)
}
}
-gboolean
+static gboolean
jingle_s5b_streamhost_is_local(JabberStream *js, const gchar *jid)
{
gchar *me = g_strdup_printf("%s@%s/%s", js->user->node, js->user->domain,
@@ -1132,4 +1132,47 @@ jingle_s5b_streamhost_is_local(JabberStr
g_free(bare_jid);
return equal;
-}
\ No newline at end of file
+}
+
+void
+jingle_s5b_handle_transport_accept(JingleS5B *s5b, JingleSession *session,
+ xmlnode *transport)
+{
+ xmlnode *streamhost_used = xmlnode_get_child(transport, "streamhost-used");
+
+ if (streamhost_used) {
+ const gchar *jid = xmlnode_get_attrib(streamhost_used, "jid");
+ JabberStream *js = jingle_session_get_js(session);
+
+ purple_debug_info("jingle-ft", "got streamhost-used\n");
+ /* stop connection attempts */
+ jingle_s5b_stop_connection_attempts(s5b);
+
+ if (jingle_session_is_initiator(session) &&
+ jingle_s5b_is_connected_to_remote(s5b)) {
+ /* we are the initiator and both parties could connect,
+ give up "ownership", see footnote 3 in XEP-0260 */
+ jingle_s5b_surrender(s5b);
+ } else {
+ /* we are now the "owner" of the bytestream */
+ jingle_s5b_take_command(s5b);
+
+ /* also when receiving a <streamhost-used/> we need to
+ check if that is not one of our local streamhosts,
+ in which case it is a proxy, and we should connect to that */
+ if (jid && !jingle_s5b_streamhost_is_local(js, jid)) {
+ purple_debug_info("jingle-ft",
+ "got transport-accept on a proxy, "
+ "need to connect to the proxy\n");
+ } else {
+ /* start transfer */
+ if (s5b->priv->connect_cb && s5b->priv->connect_content) {
+ s5b->priv->connect_cb(s5b->priv->connect_content);
+ } else {
+ /* some error? */
+ }
+ }
+ }
+ }
+}
+
============================================================
--- libpurple/protocols/jabber/jingle/s5b.h 242de1cda6996605f8569a1e5dae7053239bccf0
+++ libpurple/protocols/jabber/jingle/s5b.h 26eacce679e7d8d599ef51b576469bbb4cd01e4b
@@ -96,9 +96,8 @@ void jingle_s5b_take_command(JingleS5B *
void jingle_s5b_surrender(JingleS5B *s5b);
void jingle_s5b_take_command(JingleS5B *s5b);
-/* returns true if the given JID represents a local (to this side) streamhost
- used to determine if a choosen streamhost is a proxy */
-gboolean jingle_s5b_streamhost_is_local(JabberStream *js, const gchar *jid);
+void jingle_s5b_handle_transport_accept(JingleS5B *s5b, JingleSession *session,
+ xmlnode *transport);
#ifdef __cplusplus
}
More information about the Commits
mailing list