cpw.malu.xmpp.ibb_ft: eff30c69: Remove timeout for IBB when receiving an...

malu at pidgin.im malu at pidgin.im
Sat Dec 13 05:15:43 EST 2008


-----------------------------------------------------------------
Revision: eff30c694fd10409e06fabff4c2d9bf9da728bf0
Ancestor: 08996c0319db592ac050c74aa5ed2b8c6e6f44cf
Author: malu at pidgin.im
Date: 2008-12-13T10:13:12
Branch: im.pidgin.cpw.malu.xmpp.ibb_ft
URL: http://d.pidgin.im/viewmtn/revision/info/eff30c694fd10409e06fabff4c2d9bf9da728bf0

Modified files:
        libpurple/protocols/jabber/si.c

ChangeLog: 

Remove timeout for IBB when receiving an IBB session open from the initiator
This should prevent the timeout firing off if a transfer succeded before the
timeout is called

-------------- next part --------------
============================================================
--- libpurple/protocols/jabber/si.c	8481fa3e40ba4eb3639e0e32679e56a5cf796017
+++ libpurple/protocols/jabber/si.c	20bbf1af0e116f9ecb4b1e8cfdcc67eb68378f9e
@@ -66,6 +66,7 @@ typedef struct _JabberSIXfer {
 	int local_streamhost_fd;
 	
 	JabberIBBSession *ibb_session;
+	guint ibb_timeout_handle;
 	FILE *fp;
 } JabberSIXfer;
 
@@ -185,17 +186,27 @@ connect_timeout_cb(gpointer data)
 	return FALSE;
 }
 
+static void
+jabber_si_bytestreams_ibb_timeout_remove(JabberSIXfer *jsx)
+{
+	if (jsx->ibb_timeout_handle) {
+		purple_timeout_remove(jsx->ibb_timeout_handle);
+		jsx->ibb_timeout_handle = 0;
+	}
+}
+
 static gboolean
 jabber_si_bytestreams_ibb_timeout_cb(gpointer data)
 {
 	PurpleXfer *xfer = (PurpleXfer *) data;
 	JabberSIXfer *jsx = xfer->data;
 	
-	if (!jsx->ibb_session) {
+	if (jsx && !jsx->ibb_session) {
 		purple_debug_info("jabber", 
 			"jabber_si_bytestreams_ibb_timeout called and IBB session not set "
 			" up yet, cancel transfer");
 		purple_xfer_cancel_local(xfer);
+		jabber_si_bytestreams_ibb_timeout_remove(jsx);
 	}
 	
 	return FALSE;
@@ -237,7 +248,7 @@ static void jabber_si_bytestreams_attemp
 				jabber_si_xfer_ibb_send_init(jsx->js, xfer);
 			} else {
 				/* setup a timeout to cancel waiting for IBB open */
-				purple_timeout_add_seconds(30, 
+				jsx->ibb_timeout_handle = purple_timeout_add_seconds(30, 
 					jabber_si_bytestreams_ibb_timeout_cb, xfer);
 			}
 			/* if we are the receiver, just wait for IBB open, callback is
@@ -715,7 +726,7 @@ jabber_si_connect_proxy_cb(JabberStream 
 					&& !jsx->ibb_session) {
 					jabber_si_xfer_ibb_send_init(js, xfer);
 				} else {
-					purple_timeout_add_seconds(30,
+					jsx->ibb_timeout_handle = purple_timeout_add_seconds(30,
 						jabber_si_bytestreams_ibb_timeout_cb, xfer);
 				}
 				/* if we are receiver, just wait for IBB open stanza, callback
@@ -757,7 +768,7 @@ jabber_si_connect_proxy_cb(JabberStream 
 				if (purple_xfer_get_type(xfer) == PURPLE_XFER_SEND) {
 					jabber_si_xfer_ibb_send_init(jsx->js, xfer);
 				} else {
-					purple_timeout_add_seconds(30,
+					jsx->ibb_timeout_handle = purple_timeout_add_seconds(30,
 						jabber_si_bytestreams_ibb_timeout_cb, xfer);
 				}
 				/* if we are the receiver, we are already set up...*/
@@ -901,7 +912,7 @@ jabber_si_xfer_bytestreams_listen_cb(int
 				/* if we are the sender, init the IBB session... */
 				jabber_si_xfer_ibb_send_init(jsx->js, xfer);
 			} else {
-				purple_timeout_add_seconds(30,
+				jsx->ibb_timeout_handle = purple_timeout_add_seconds(30,
 					jabber_si_bytestreams_ibb_timeout_cb, xfer);
 			}
 			/* if we are the receiver, we should just wait... the IBB open
@@ -1050,6 +1061,8 @@ jabber_si_xfer_ibb_open_cb(JabberStream 
 			purple_xfer_end(xfer);
 			return FALSE;
 		}
+		
+		jabber_si_bytestreams_ibb_timeout_remove(jsx);
 	} else {
 		/* we got an IBB <open/> for an unknown file transfer, pass along... */
 		purple_debug_info("jabber", 
@@ -1285,7 +1298,9 @@ static void jabber_si_xfer_free(PurpleXf
 			close(jsx->local_streamhost_fd);
 		if (jsx->connect_timeout > 0)
 			purple_timeout_remove(jsx->connect_timeout);
-	
+		if (jsx->ibb_timeout_handle > 0)
+			purple_timeout_remove(jsx->ibb_timeout_handle);
+		
 		if (jsx->streamhosts) {
 			g_list_foreach(jsx->streamhosts, jabber_si_free_streamhost, NULL);
 			g_list_free(jsx->streamhosts);


More information about the Commits mailing list