cpw.malu.xmpp.jingle_ft: 31b57ac9: I think "tie-breaking", where the initia...
malu at pidgin.im
malu at pidgin.im
Mon Apr 6 18:45:45 EDT 2009
-----------------------------------------------------------------
Revision: 31b57ac939dc22eb4a3d54e7c03378ed10d93561
Ancestor: 16c1134da39addbe715b0c03053114e1bb769c6d
Author: malu at pidgin.im
Date: 2009-04-06T22:43:06
Branch: im.pidgin.cpw.malu.xmpp.jingle_ft
URL: http://d.pidgin.im/viewmtn/revision/info/31b57ac939dc22eb4a3d54e7c03378ed10d93561
Modified files:
libpurple/protocols/jabber/jingle/file-transfer.c
libpurple/protocols/jabber/jingle/jingle.c
libpurple/protocols/jabber/jingle/s5b.c
libpurple/protocols/jabber/jingle/s5b.h
ChangeLog:
I think "tie-breaking", where the initiator "wins" if both can connect kinda
works now. At least in when trying locally...
-------------- next part --------------
============================================================
--- libpurple/protocols/jabber/jingle/file-transfer.c cd8c06e7d02b55a1f45b88411d29529721281c8d
+++ libpurple/protocols/jabber/jingle/file-transfer.c f86a046475db3f5ecc0e97d6f17e577ba3d8c33c
@@ -673,15 +673,6 @@ jingle_file_transfer_handle_action_inter
JingleTransport *transport = jingle_transport_parse(
xmlnode_get_child(xmlcontent, "transport"));
- /* if there is a <streamhost-used/>, signal local S5B transport
- to stop connections attempts */
- /* if we are the receiver and sent a <streamhost-used/> to the
- initiator, we should give up our own listening streamhost to
- avoid ending up with two parallell streams */
- /* 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 */
-
/* we should check for "stream-host" error (in the case of S5B) and
offer a transport-replace with IBB */
@@ -689,8 +680,43 @@ jingle_file_transfer_handle_action_inter
break;
}
case JINGLE_TRANSPORT_ACCEPT: {
+ JingleSession *session = jingle_content_get_session(content);
+ JingleTransport *transport = jingle_content_get_transport(content);
+ purple_debug_info("jingle-ft",
+ "content %p\n", content);
+ purple_debug_info("jingle-ft",
+ "got transport-accept transport %p\n", transport);
+
+ 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");
+ purple_debug_info("jingle-ft", "xmltransport %p\n", xmltransport);
+
+ if (streamhost_used) {
+ 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 receiver and both parties could connect,
+ give up "ownership" */
+ 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 */
+ }
+ }
+
break;
}
case JINGLE_TRANSPORT_REPLACE: {
============================================================
--- libpurple/protocols/jabber/jingle/jingle.c 40c7fcb0814affe32eca9931c003784d7647cb48
+++ libpurple/protocols/jabber/jingle/jingle.c 56410c39672d6c0cf258cc00ad24015fc563c9da
@@ -248,15 +248,20 @@ jingle_handle_transport_accept(JingleSes
static void
jingle_handle_transport_accept(JingleSession *session, xmlnode *jingle)
{
- xmlnode *content = xmlnode_get_child(jingle, "content");
+ xmlnode *xmlcontent = xmlnode_get_child(jingle, "content");
jabber_iq_send(jingle_session_create_ack(session, jingle));
- for (; content; content = xmlnode_get_next_twin(content)) {
- const gchar *name = xmlnode_get_attrib(content, "name");
- const gchar *creator = xmlnode_get_attrib(content, "creator");
+ for (; xmlcontent; xmlcontent = xmlnode_get_next_twin(xmlcontent)) {
+ const gchar *name = xmlnode_get_attrib(xmlcontent, "name");
+ const gchar *creator = xmlnode_get_attrib(xmlcontent, "creator");
JingleContent *content = jingle_session_find_content(session, name, creator);
- jingle_content_accept_transport(content);
+ JingleTransport *pending_transport =
+ jingle_content_get_pending_transport(content);
+ if (pending_transport)
+ jingle_content_accept_transport(content);
+ jingle_content_handle_action(content, xmlcontent, JINGLE_TRANSPORT_ACCEPT);
+ g_object_unref(pending_transport);
}
}
============================================================
--- libpurple/protocols/jabber/jingle/s5b.c 6fe896a145616f754ab806402ccc0625046c2fe8
+++ libpurple/protocols/jabber/jingle/s5b.c c03d7d05ada5999be5f3d55d79f93b9c76dd0963
@@ -816,13 +816,16 @@ jingle_s5b_connect_cb(gpointer data, gin
purple_debug_info("jingle-s5b", "Successful in connecting!\n");
+ s5b->priv->connect_data = NULL;
s5b->priv->remote_fd = source;
- /* should stop trying to connect */
-
/* set the currently tried streamhost as the successfull one */
s5b->priv->successfull_remote_streamhost =
(JabberBytestreamsStreamhost *) s5b->priv->remaining_streamhosts->data;
+
+ /* should stop trying to connect */
+ jingle_s5b_stop_connection_attempts(s5b);
+
/* should send transport-info with streamhost-used */
jabber_iq_send(jingle_session_to_packet(session, JINGLE_TRANSPORT_ACCEPT));
@@ -889,3 +892,48 @@ jingle_s5b_attempt_connect(JingleSession
s5b->priv->remaining_streamhosts = s5b->priv->remote_streamhosts;
jingle_s5b_attempt_connect_internal(session, s5b);
}
+
+void
+jingle_s5b_stop_connection_attempts(JingleS5B *s5b)
+{
+ purple_debug_info("jingle-s5b", "stop connection attempts\n");
+
+ s5b->priv->remaining_streamhosts = NULL;
+
+ if (s5b->priv->connect_data) {
+ purple_proxy_connect_cancel(s5b->priv->connect_data);
+ s5b->priv->connect_data = NULL;
+ }
+}
+
+gboolean
+jingle_s5b_is_connected_to_remote(const JingleS5B *s5b)
+{
+ return s5b->priv->remote_fd;
+}
+
+void
+jingle_s5b_surrender(JingleS5B *s5b)
+{
+ purple_debug_info("jingle-s5b",
+ "in jingle_s5b_surrender, using remote streamhost\n");
+ s5b->priv->fd = s5b->priv->remote_fd;
+
+ if (s5b->priv->local_fd) {
+ close(s5b->priv->local_fd);
+ s5b->priv->local_fd = 0;
+ }
+}
+
+void
+jingle_s5b_take_command(JingleS5B *s5b)
+{
+ purple_debug_info("jingle-s5b",
+ "in jingle_s5b_take_command, using local streamhost\n");
+ s5b->priv->fd = s5b->priv->local_fd;
+
+ if (s5b->priv->remote_fd) {
+ close(s5b->priv->remote_fd);
+ s5b->priv->remote_fd = 0;
+ }
+}
\ No newline at end of file
============================================================
--- libpurple/protocols/jabber/jingle/s5b.h 4227d53b7f96d872d5d479629bc2602f0b2c89fb
+++ libpurple/protocols/jabber/jingle/s5b.h 7df0a51548ed1164677ea0450816480b7004ead8
@@ -76,6 +76,13 @@ void jingle_s5b_attempt_connect(JingleSe
void jingle_s5b_attempt_connect(JingleSession *session, JingleS5B *s5b);
+void jingle_s5b_stop_connection_attempts(JingleS5B *s5b);
+
+gboolean jingle_s5b_is_connected_to_remote(const JingleS5B *s5b);
+
+void jingle_s5b_surrender(JingleS5B *s5b);
+void jingle_s5b_take_command(JingleS5B *s5b);
+
#ifdef __cplusplus
}
#endif
More information about the Commits
mailing list