cpw.malu.xmpp.jingle_ft: f80e7309: Add error handling for SOCKS5 negotiatio...

malu at pidgin.im malu at pidgin.im
Sat May 2 03:40:33 EDT 2009


-----------------------------------------------------------------
Revision: f80e73093f4cb3555cff59dde0664e456c3d3665
Ancestor: 21c7209f98fb12776ac84086f8c53ebc5e61d44e
Author: malu at pidgin.im
Date: 2009-05-02T07:37:23
Branch: im.pidgin.cpw.malu.xmpp.jingle_ft
URL: http://d.pidgin.im/viewmtn/revision/info/f80e73093f4cb3555cff59dde0664e456c3d3665

Modified files:
        libpurple/protocols/jabber/jingle/file-transfer.c
        libpurple/protocols/jabber/jingle/s5b.c

ChangeLog: 

Add error handling for SOCKS5 negotiation

-------------- next part --------------
============================================================
--- libpurple/protocols/jabber/jingle/file-transfer.c	ee2946e848be5a0527d8f5a10e18dda55b7320e3
+++ libpurple/protocols/jabber/jingle/file-transfer.c	7e67641d27bf17d256e617a86f83b48609a93b30
@@ -291,7 +291,21 @@ jingle_file_transfer_s5b_error_callback(
 static void
 jingle_file_transfer_s5b_error_callback(JingleContent *content)
 {
+	PurpleXfer *xfer = JINGLE_FT_GET_PRIVATE(JINGLE_FT(content))->xfer;
+	JingleSession *session = jingle_content_get_session(content);
+	JabberStream *js = 
+		jingle_session_get_js(session);
+	PurpleConnection *gc = js->gc;
+	PurpleAccount *account = purple_connection_get_account(gc);
+	gchar *who = jingle_session_get_remote_jid(session);
 	
+	purple_debug_error("jingle-ft", 
+		"an error occured during SOCKS5 file transfer\n");
+	purple_xfer_error(purple_xfer_get_type(xfer), account, who,
+		_("An error occured on the SOCKS5 transfer\n"));
+	purple_xfer_cancel_remote(xfer);
+	g_free(who);
+	g_object_unref(session);
 }
 
 /* callback functions for IBB */
============================================================
--- libpurple/protocols/jabber/jingle/s5b.c	09b0ab91e345d394f5c8f6c8f99f6311b633b24b
+++ libpurple/protocols/jabber/jingle/s5b.c	862158f04c9cecebf383d48d445efd0836900641
@@ -527,7 +527,8 @@ jingle_s5b_send_read_again_resp_cb(gpoin
 		g_free(s5b->priv->rxqueue);
 		s5b->priv->rxqueue = NULL;
 		close(source);
-		/* TODO: signal to the content that an error has occurred */
+		if (s5b->priv->error_cb && s5b->priv->error_content)
+			s5b->priv->error_cb(s5b->priv->error_content);
 		return;
 	}
 	s5b->priv->rxlen += len;
@@ -578,7 +579,9 @@ jingle_s5b_send_read_again_cb(gpointer d
 			purple_input_remove(s5b->priv->watcher);
 			s5b->priv->watcher = 0;
 			close(source);
-			/* TODO: signal the content that an error occured */
+			if (s5b->priv->error_cb && s5b->priv->error_content)
+				s5b->priv->error_cb(s5b->priv->error_content);
+			g_free(data);
 			return;
 		}
 		s5b->priv->rxqueue = 
@@ -592,7 +595,9 @@ jingle_s5b_send_read_again_cb(gpointer d
 		purple_input_remove(s5b->priv->watcher);
 		s5b->priv->watcher = 0;
 		close(source);
-		/* TODO: signal the content that an error occured */
+		if (s5b->priv->error_cb && s5b->priv->error_content)
+			s5b->priv->error_cb(s5b->priv->error_content);
+		g_free(data);
 		return;
 	} else if(s5b->priv->rxlen - 5 <  s5b->priv->rxqueue[4] + 2) {
 		purple_debug_info("jingle-s5b", "reading umpteen more bytes\n");
@@ -604,7 +609,9 @@ jingle_s5b_send_read_again_cb(gpointer d
 			purple_input_remove(s5b->priv->watcher);
 			s5b->priv->watcher = 0;
 			close(source);
-			/* TODO: signal the content that an error occured */
+			if (s5b->priv->error_cb && s5b->priv->error_content)
+				s5b->priv->error_cb(s5b->priv->error_content);
+			g_free(data);
 			return;
 		}
 		s5b->priv->rxqueue = 
@@ -635,7 +642,9 @@ jingle_s5b_send_read_again_cb(gpointer d
 		purple_debug_error("jingle-s5b", 
 			"someone connected with the wrong info!\n");
 		close(source);
-		/* TODO: signal the content that an error occured */
+		if (s5b->priv->error_cb && s5b->priv->error_content)
+			s5b->priv->error_cb(s5b->priv->error_content);
+		g_free(data);
 		g_free(hash);
 		g_free(dstaddr);
 		return;
@@ -685,13 +694,19 @@ jingle_s5b_send_read_response_cb(gpointe
 		g_free(s5b->priv->rxqueue);
 		s5b->priv->rxqueue = NULL;
 		close(source);
-		/* TODO: signal to "surrounding" content that an error has occured */
+		if (s5b->priv->error_cb && s5b->priv->error_content)
+			s5b->priv->error_cb(s5b->priv->error_content);
+		g_free(data);
 		return;
 	}
 	s5b->priv->rxlen += len;
 
-	if (s5b->priv->rxlen < s5b->priv->rxmaxlen)
+	if (s5b->priv->rxlen < s5b->priv->rxmaxlen) {
+		if (s5b->priv->error_cb && s5b->priv->error_content)
+			s5b->priv->error_cb(s5b->priv->error_content);
+		g_free(data);
 		return;
+	}
 
 	purple_input_remove(s5b->priv->watcher);
 	s5b->priv->watcher = 0;
@@ -703,7 +718,9 @@ jingle_s5b_send_read_response_cb(gpointe
 		s5b->priv->rxqueue = NULL;
 	} else {
 		close(source);
-		/* TODO: signal "surrounding" content that an error has occured */
+		if (s5b->priv->error_cb && s5b->priv->error_content)
+			s5b->priv->error_cb(s5b->priv->error_content);
+		g_free(data);
 	}
 }
 	
@@ -728,7 +745,9 @@ jingle_s5b_send_read_cb(gpointer data, g
 			purple_input_remove(s5b->priv->watcher);
 			s5b->priv->watcher = 0;
 			close(source);
-			/* TODO: signal the "surrounding" content an error has occured */
+			if (s5b->priv->error_cb && s5b->priv->error_content)
+				s5b->priv->error_cb(s5b->priv->error_content);
+			g_free(data);
 			return;
 		}
 		s5b->priv->rxqueue = 
@@ -745,7 +764,9 @@ jingle_s5b_send_read_cb(gpointer data, g
 			purple_input_remove(s5b->priv->watcher);
 			s5b->priv->watcher = 0;
 			close(source);
-			/* TODO: signal the "surrounding" content an error has occured */
+			if (s5b->priv->error_cb && s5b->priv->error_content)
+				s5b->priv->error_cb(s5b->priv->error_content);
+			g_free(data);
 			return;
 		}
 		s5b->priv->rxqueue = 
@@ -765,7 +786,9 @@ jingle_s5b_send_read_cb(gpointer data, g
 	if(s5b->priv->rxqueue[0] != 0x05) {
 		purple_debug_error("jingle-s5b", "it's not socks FIVE, giving up\n");
 		close(source);
-		/* TODO: signal to the "surrounding" content that an error has occured */
+		if (s5b->priv->error_cb && s5b->priv->error_content)
+			s5b->priv->error_cb(s5b->priv->error_content);
+		g_free(data);
 		return;
 	}
 


More information about the Commits mailing list