cpw.malu.xmpp.jingle_ft: c315ffd6: Actually handle transport-replace and tr...

malu at pidgin.im malu at pidgin.im
Thu May 14 14:30:24 EDT 2009


-----------------------------------------------------------------
Revision: c315ffd639385e6b4500dc3b36800b0ceae5c692
Ancestor: 17d5f3c5553eb4daf81466b63ee0017652e8e8be
Author: malu at pidgin.im
Date: 2009-05-14T18:25:10
Branch: im.pidgin.cpw.malu.xmpp.jingle_ft
URL: http://d.pidgin.im/viewmtn/revision/info/c315ffd639385e6b4500dc3b36800b0ceae5c692

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

ChangeLog: 

Actually handle transport-replace and transport-reject in jingle.c
Modified file-transfer.c accordingly

-------------- next part --------------
============================================================
--- libpurple/protocols/jabber/jingle/file-transfer.c	582f06672b6cde292b57d356641367ce0c3f1da4
+++ libpurple/protocols/jabber/jingle/file-transfer.c	33fe921eed826ef2a8ceaa5e98111bb22d029139
@@ -871,22 +871,21 @@ jingle_file_transfer_handle_action_inter
 		case JINGLE_TRANSPORT_REPLACE: {
 			JingleSession *session = jingle_content_get_session(content);
 			xmlnode *xmltransport = xmlnode_get_child(xmlcontent, "transport");
-			JingleTransport *new_transport =
-				jingle_transport_parse(xmltransport);
 			const gchar *sid = 
 				xmlnode_get_attrib(xmlnode_get_child(xmlcontent, 
 					"transport"), "sid");
 			gchar *who = jingle_session_get_remote_jid(session);
 			const PurpleXfer *xfer = JINGLE_FT(content)->priv->xfer;
 			const gchar *filename = purple_xfer_get_local_filename(xfer);
-
+			JingleTransport *new_transport = 
+				jingle_content_get_pending_transport(content);
+			
 			/* fallback to IBB etc... */
-			if (JINGLE_IS_IBB(new_transport)) {
+			if (new_transport && JINGLE_IS_IBB(new_transport)) {
 				JingleIBB *ibb = JINGLE_IBB(new_transport);
 
 				jingle_ibb_create_session(ibb, content, sid, who);
 				/* immediatly accept the new transport */
-				jingle_content_set_pending_transport(content, new_transport);
 				jingle_content_accept_transport(content);
 
 				/* open the file and setup the callbacks */
@@ -920,6 +919,7 @@ jingle_file_transfer_handle_action_inter
                     JINGLE_TRANSPORT_ACCEPT));
 			}
 
+			g_object_unref(new_transport);
 			g_free(who);
 			g_object_unref(session);
 			break;
============================================================
--- libpurple/protocols/jabber/jingle/jingle.c	56410c39672d6c0cf258cc00ad24015fc563c9da
+++ libpurple/protocols/jabber/jingle/jingle.c	0d8a9e28bdd219d9e0daeebb5b5b1aeffba5112b
@@ -255,13 +255,19 @@ jingle_handle_transport_accept(JingleSes
 	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);
-		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);
+		JingleContent *content = 
+			jingle_session_find_content(session, name, creator);
+		if (content == NULL) {
+			purple_debug_error("jingle", "Error parsing content\n");
+			/* XXX: send error */
+		} else {
+			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);
+		}
 	}
 }
 
@@ -297,8 +303,16 @@ jingle_handle_transport_reject(JingleSes
 	for (; content; content = xmlnode_get_next_twin(content)) {
 		const gchar *name = xmlnode_get_attrib(content, "name");
 		const gchar *creator = xmlnode_get_attrib(content, "creator");
-		JingleContent *content = jingle_session_find_content(session, name, creator);
-		jingle_content_remove_pending_transport(content);
+		JingleContent *parsed_content = 
+			jingle_session_find_content(session, name, creator);
+		if (parsed_content == NULL) {
+			purple_debug_error("jingle", "Error parsing content\n");
+			/* XXX: send error */
+		} else {
+			jingle_content_remove_pending_transport(parsed_content);
+			jingle_content_handle_action(parsed_content, content,
+				JINGLE_TRANSPORT_REJECT);
+		}
 	}
 }
 
@@ -314,9 +328,16 @@ jingle_handle_transport_replace(JingleSe
 		const gchar *creator = xmlnode_get_attrib(content, "creator");
 		xmlnode *xmltransport = xmlnode_get_child(content, "transport");
 		JingleTransport *transport = jingle_transport_parse(xmltransport);
-		JingleContent *content = jingle_session_find_content(session, name, creator);
-
-		jingle_content_set_pending_transport(content, transport);
+		JingleContent *parsed_content = 
+			jingle_session_find_content(session, name, creator);
+		if (parsed_content == NULL) {
+			purple_debug_error("jingle", "Error parsing content\n");
+			/* XXX: send error */
+		} else {
+			jingle_content_set_pending_transport(parsed_content, transport);
+			jingle_content_handle_action(parsed_content, content,
+				JINGLE_TRANSPORT_REPLACE);
+		}
 	}
 }
 


More information about the Commits mailing list