cpw.malu.xmpp.jingle_ft: 29e9ce0d: Now it should finalize the sessions when...

malu at pidgin.im malu at pidgin.im
Wed Mar 18 15:05:29 EDT 2009


-----------------------------------------------------------------
Revision: 29e9ce0dc1408074df00e27415a072df916a0e7a
Ancestor: 8ba3eff2903b1945cd313056a069a41b19e9989d
Author: malu at pidgin.im
Date: 2009-03-18T19:02:00
Branch: im.pidgin.cpw.malu.xmpp.jingle_ft
URL: http://d.pidgin.im/viewmtn/revision/info/29e9ce0dc1408074df00e27415a072df916a0e7a

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

ChangeLog: 

Now it should finalize the sessions when the transfer is finished
It still crashes when cancelling, though...

-------------- next part --------------
============================================================
--- libpurple/protocols/jabber/jingle/file-transfer.c	b2b835c760ce8e26cbfda12323b2b793de723254
+++ libpurple/protocols/jabber/jingle/file-transfer.c	8fe4557c1f65646df1b675a8b335b76194363465
@@ -115,6 +115,11 @@ jingle_file_transfer_finalize (GObject *
 	if (priv->ibb_fp) {
 		fclose(priv->ibb_fp);
 	}
+	
+	if (priv->xfer) {
+		/* remove reference in transfer */
+		priv->xfer->data = NULL;
+	}
 }
 
 static void
@@ -166,15 +171,6 @@ static void
 }
 
 static void
-jingle_file_transfer_close_ibb_fp(JingleContent *content)
-{
-	FILE *ibb_fp = JINGLE_FT_GET_PRIVATE(JINGLE_FT(content))->ibb_fp;
-
-	if (ibb_fp)
-		fclose(ibb_fp);
-}
-
-static void
 jingle_file_transfer_cancel_remote(JingleContent *content)
 {
 	PurpleXfer *xfer = JINGLE_FT_GET_PRIVATE(JINGLE_FT(content))->xfer;
@@ -182,13 +178,13 @@ jingle_file_transfer_cancel_remote(Jingl
 	
 	purple_debug_info("jingle-ft", "cancel remote transfer\n");
 	if (xfer) {
-		jabber_iq_send(jingle_session_to_packet(
-			jingle_content_get_session(content), JINGLE_SESSION_TERMINATE));
+		jabber_iq_send(jingle_session_to_packet(session, 
+			JINGLE_SESSION_TERMINATE));
 		purple_xfer_cancel_remote(xfer);
 	}
 
-	jingle_file_transfer_close_ibb_fp(content);
 	g_object_unref(session);
+	g_object_unref(session);	/* actually close the session */
 }
 
 static void
@@ -199,13 +195,13 @@ jingle_file_transfer_cancel_local(Jingle
 	
 	purple_debug_info("jingle-ft", "cancel local trasfer\n");
 	if (xfer) {
-		jabber_iq_send(jingle_session_to_packet(
-			jingle_content_get_session(content), JINGLE_SESSION_TERMINATE));
+		jabber_iq_send(jingle_session_to_packet(session, 
+			JINGLE_SESSION_TERMINATE));
 		purple_xfer_cancel_local(xfer);
 	}
 
-	jingle_file_transfer_close_ibb_fp(content);
 	g_object_unref(session);
+	g_object_unref(session);	/* actually close the the session */
 }
 
 static void
@@ -220,7 +216,6 @@ jingle_file_transfer_success(JingleConte
 		purple_xfer_end(xfer);
 	}
 
-	jingle_file_transfer_close_ibb_fp(content);
 	g_object_unref(session);
 }
 
@@ -232,14 +227,14 @@ jingle_file_transfer_end(JingleContent *
 	
 	purple_debug_info("jingle-ft", "ending transfer\n");
 	if (xfer) {
-		jabber_iq_send(jingle_session_to_packet(jingle_content_get_session(content), 
+		jabber_iq_send(jingle_session_to_packet(session, 
 			JINGLE_SESSION_TERMINATE));
 		purple_xfer_set_completed(xfer, TRUE);
 		purple_xfer_end(xfer);
 	}
 
-	jingle_file_transfer_close_ibb_fp(content);
 	g_object_unref(session);
+	g_object_unref(session); /* actually delete it */
 }
 
 static void
@@ -326,7 +321,7 @@ jingle_file_transfer_ibb_error_callback(
 	PurpleXfer *xfer = JINGLE_FT_GET_PRIVATE(JINGLE_FT(content))->xfer;
 	JingleSession *session = jingle_content_get_session(content);
 	JabberStream *js = 
-		jingle_session_get_js(jingle_content_get_session(content));
+		jingle_session_get_js(session);
 	PurpleConnection *gc = js->gc;
 	PurpleAccount *account = purple_connection_get_account(gc);
 	gchar *who = jingle_session_get_remote_jid(session);
@@ -368,6 +363,7 @@ jingle_file_transfer_xfer_init(PurpleXfe
 				jabber_iq_send(jingle_session_to_packet(session,
 						JINGLE_SESSION_TERMINATE));
 				g_object_unref(session);
+				g_object_unref(session);
 				return;
 			}
 
@@ -381,6 +377,7 @@ jingle_file_transfer_xfer_init(PurpleXfe
 			purple_xfer_start(xfer, 0, NULL, 0);
 		}
 	}
+	g_object_unref(session);
 }
 
 static void
@@ -389,8 +386,11 @@ jingle_file_transfer_cancel_send(PurpleX
 	JingleSession *session = 
 		jingle_content_get_session((JingleContent *)xfer->data);
 	
+	purple_debug_info("jingle-ft", "jingle_file_transfer_cancel_send\n");
 	jabber_iq_send(jingle_session_to_packet(session, JINGLE_SESSION_TERMINATE));
 	g_object_unref(session);
+	g_object_unref(session);
+	g_object_unref(session);
 }
 
 static void
@@ -399,17 +399,20 @@ jingle_file_transfer_cancel_recv(PurpleX
 	JingleSession *session = 
 		jingle_content_get_session((JingleContent *)xfer->data);
 
+	purple_debug_info("jingle-ft", "jingle_file_transfer_cancel_recv\n");
 	jabber_iq_send(jingle_session_to_packet(session, JINGLE_SESSION_TERMINATE));
 	g_object_unref(session);
+	g_object_unref(session);
 }
 
 static void
 jingle_file_transfer_xfer_end(PurpleXfer *xfer)
 {
-	JingleSession *session = 
-		jingle_content_get_session((JingleContent *)xfer->data);
-
-	g_object_unref(session);
+	if (xfer->data) {
+		JingleSession *session = 
+			jingle_content_get_session((JingleContent *)xfer->data);
+		g_object_unref(session);
+	}
 }
 
 static JingleContent *
@@ -465,6 +468,7 @@ jingle_file_transfer_handle_action_inter
 					purple_debug_error("jingle-ft", 
 						"failed to open file for reading\n");
 					jingle_file_transfer_cancel_local(content);
+					break;
 				}
 			}
 			
@@ -503,6 +507,7 @@ jingle_file_transfer_handle_action_inter
 					jabber_iq_send(jingle_session_to_packet(session,
 						JINGLE_SESSION_TERMINATE));
 					g_object_unref(session);
+					g_object_unref(session);
 					g_free(who);
 					break;
 				}
@@ -536,6 +541,7 @@ jingle_file_transfer_handle_action_inter
 			}
 	
 			g_object_unref(session);
+			g_object_unref(session);
 			break;
 		}
 		case JINGLE_TRANSPORT_INFO: {
============================================================
--- libpurple/protocols/jabber/jingle/ibbs.c	8db74a4a5513f15de0f81fac442a422dbdb4e766
+++ libpurple/protocols/jabber/jingle/ibbs.c	e3b32fee9d586f0deb3a99fecc5efcfffd84bf3a
@@ -268,6 +268,8 @@ jingle_ibb_create_session(JingleIBB *ibb
 		jingle_ibb_data_recv_callback);
 	jabber_ibb_session_set_error_callback(session, jingle_ibb_error_callback);
 	JINGLE_IBB_GET_PRIVATE(ibb)->session = session;
+
+	g_object_unref(sess);
 }
 
 void 


More information about the Commits mailing list