/soc/2013/ashmew2/filetransferY: cd2ce5125706: Added Remote canc...

Ashish Gupta ashmew2 at gmail.com
Sat Dec 21 18:45:17 EST 2013


Changeset: cd2ce5125706dbcfaac7a130ad1f68d5fbe2d548
Author:	 Ashish Gupta <ashmew2 at gmail.com>
Date:	 2013-12-22 04:59 +0530
Branch:	 filetransferX
URL: https://hg.pidgin.im/soc/2013/ashmew2/filetransferY/rev/cd2ce5125706

Description:

Added Remote cancel prompt

diffstat:

 libpurple/media.h                                  |   4 -
 libpurple/protocols/jabber/google/google_session.c |  67 ++++++++++++---------
 2 files changed, 39 insertions(+), 32 deletions(-)

diffs (198 lines):

diff --git a/libpurple/media.h b/libpurple/media.h
--- a/libpurple/media.h
+++ b/libpurple/media.h
@@ -46,10 +46,6 @@ G_BEGIN_DECLS
 /** An opaque structure representing a media call. */
 typedef struct _PurpleMedia PurpleMedia;
 
-/**This struct was not here, added for GTalk FT*/
-typedef struct _PurpleMediaSession PurpleMediaSession;
-typedef struct _PurpleMediaStream PurpleMediaStream;
-
 #include "signals.h"
 #include "util.h"
 
diff --git a/libpurple/protocols/jabber/google/google_session.c b/libpurple/protocols/jabber/google/google_session.c
--- a/libpurple/protocols/jabber/google/google_session.c
+++ b/libpurple/protocols/jabber/google/google_session.c
@@ -59,8 +59,7 @@ typedef struct {
 	PurpleCircBuffer *buffer; 
 	GoogleXferChannelState channel_state;
 	gint stream_id;
-	gboolean candidates_gathered;
-	
+	gboolean candidates_gathered;	
 	gboolean file_opened;               /* Stuff for using file buffer for sending Gtalk Files.. */ 
 	FILE *file_to_send;
 	char *file_buf;
@@ -126,22 +125,24 @@ google_session_destroy(GoogleSession *se
 	if(session_data->share) {
 		GoogleXferSessionData *share_session = session_data->share_session;
 		GSList *temp = NULL;
-
-		purple_debug_info("google_session", "Destroying the current Google Session..\n");
+		
+		purple_debug_info("google_session", "Destroying The current Google Session..\n");
 
 		/*Xfer section needs fixing...TODO : Remve this block
 		purple_debug_info("google_session", "Trying to kill xfer..BEFORE?\n");
 		purple_debug_info("gs_", "status of xfer : %d",purple_xfer_get_status(share_session->xfer) == PURPLE_XFER_STATUS_STARTED);
+		TODO: Add various status changes when cancelling Xfers so that the following section can make use of it.
 		*/
-		if(share_session->xfer)
-		  if (purple_xfer_get_status(share_session->xfer) != PURPLE_XFER_STATUS_CANCEL_LOCAL &&
-		      purple_xfer_get_status(share_session->xfer) != PURPLE_XFER_STATUS_CANCEL_REMOTE &&
-		      purple_xfer_get_status(share_session->xfer) != PURPLE_XFER_STATUS_DONE)
-		    {
-		      purple_debug_info("google_session", "Calling xfer_cancel_local\n");
-		      purple_xfer_cancel_local(share_session->xfer);
-		    }
-		
+		if(share_session->xfer)	{
+
+			if(purple_xfer_get_status(share_session->xfer) == PURPLE_XFER_STATUS_CANCEL_REMOTE)
+				purple_xfer_cancel_remote(share_session->xfer);
+			else if (purple_xfer_get_status(share_session->xfer) != PURPLE_XFER_STATUS_CANCEL_LOCAL &&				 
+				 purple_xfer_get_status(share_session->xfer) != PURPLE_XFER_STATUS_DONE) {				
+				purple_debug_info("google_session", "Calling xfer_cancel_local\n");
+				purple_xfer_cancel_local(share_session->xfer);
+			}
+		}
 		purple_debug_info("google_session", "Trying to kill xfer..AFTERWARDS?\n");
 
 		if(share_session->file_to_send)
@@ -507,6 +508,8 @@ gtalk_xfer_send_terminate(PurpleXfer *xf
 	xmlnode_set_attrib(session_node, "id", session->id.id);
 	xmlnode_set_attrib(session_node, "initiator", session->id.initiator);
 	xmlnode_set_namespace(session_node, NS_GOOGLE_SESSION);        
+
+	jabber_iq_set_callback(iq, google_session_destroy, session);
 	jabber_iq_send(iq);       	
 }
 
@@ -521,7 +524,8 @@ gtalk_xfer_cancel_xfer(PurpleXfer *xfer)
 	
 	gtalk_xfer_send_terminate(xfer);	
 	session->state = TERMINATED;
-	google_session_destroy(session);
+	purple_debug_info("google_session", "Calling the google_session_destroy from gtalk_xfer_cancel_xfer() \n");
+//	google_session_destroy(session);
 }
 
 gint gtalk_xfer_init_agent(GoogleSession *session)
@@ -615,13 +619,14 @@ jabber_google_relay_response_session_ini
 							  relay_username, relay_password, NICE_RELAY_TYPE_TURN_TLS);
 		}
 
-		purple_debug_info("google_session", "Calling xfer_send_candiates()\n");
+		purple_debug_info("google_session", "Calling xfer_send_candidates()\n");
 		
 		session->relay_processing = FALSE;
 
 		if(session->session_should_die) {
-			google_session_destroy(session);
-			return;
+		  purple_debug_info("google_session","Detected session_should_die as 1.\n");
+		  google_session_destroy(session);
+		  return;
 		}		
 		return;
 	}
@@ -1019,7 +1024,10 @@ gtalk_xfer_handle_info(JabberStream  *js
 		jabber_iq_set_id(iq, iq_id);
 		xmlnode_set_attrib(iq->node, "to", session->remote_jid);
 		jabber_iq_send(iq);
-		
+		/*Maybe this call to session_destroy shouldn't occur and we should trigger the destroy when
+		  GTalk sends us the terminate message,(which ideally should be immediately following
+		  the "complete" message), but that would be depending on Google Talk for killing
+		  this session. Need to resolve this and this comment should go away ASAP. TODO*/
 		google_session_destroy(session);
 		return;
 	}
@@ -1120,7 +1128,7 @@ google_session_handle_candidates(JabberS
 			else {/*If it's a share session*/
 				session_data->share_session->remote_share_candidates = 
 					g_slist_append(session_data->share_session->remote_share_candidates,
-						      info);
+						       info);
 				purple_debug_info("google_session", "Added candidate to sharelist\n");
 			}
 		}
@@ -1343,14 +1351,15 @@ static void
 gtalk_xfer_handle_reject(JabberStream *js, GoogleSession *session, const char *iq_id)
 {	
 	GoogleAVSessionData *session_data = (GoogleAVSessionData *)session->session_data;
-	
+
 	JabberIq *result = jabber_iq_new(js, JABBER_IQ_RESULT);
 	jabber_iq_set_id(result, iq_id);
 	xmlnode_set_attrib(result->node, "to", session->remote_jid);
 	jabber_iq_send(result);
 
 	purple_debug_info("google_session", "The remote user Rejected the Xfer request..\n");
-
+	
+	session_data->share_session->xfer->status = PURPLE_XFER_STATUS_CANCEL_REMOTE;
 	session->state = TERMINATED;
 	google_session_destroy(session);
 }
@@ -1373,15 +1382,17 @@ google_session_handle_terminate(JabberSt
 	jabber_iq_set_id(result, iq_id);
 	xmlnode_set_attrib(result->node, "to", session->remote_jid);
 	jabber_iq_send(result);
-
-	session->session_should_die = 1;
+	purple_debug_info("google_session","Setting session_should_die to 1 \n");
+	session->session_should_die = 1; /*TODO: what to do?*/
 	
 	if(session->relay_processing) {
+		purple_debug_info("google_session","Relay is processing..\n");
 		return;
 	}
 			
 	if(session_data->share) {	/*TODO: Right now, we are only using local_cancel(xfer), need to use
 					  remote_cancel(xfer) as well*/
+		purple_debug_info("google_session","Setting session_state to TERMINATED..\n");
 		session->state = TERMINATED;
 		google_session_destroy(session);
 	}
@@ -1536,7 +1547,7 @@ cb_candidate_gathering_done(NiceAgent *a
 	}
 		
 	/* Time to send local candidates. */
-	while (local_candidates) {
+	if (local_candidates) {
 		NiceCandidate *candidate = (NiceCandidate *) local_candidates->data;
 		JabberIq *iq = jabber_iq_new(session->js, JABBER_IQ_SET);
 		gchar *me = g_strdup_printf("%s@%s/%s",
@@ -1626,9 +1637,9 @@ gtalk_xfer_end(PurpleXfer *xfer)
 		complete_node = xmlnode_new_child(session_node, "complete");
 		xmlnode_set_namespace(complete_node, NS_GOOGLE_SESSION_SHARE);	
 		jabber_iq_send(iq);
+
 		gtalk_xfer_send_terminate(xfer);
-
-		google_session_destroy(session);
+//		google_session_destroy(session);
 	}
 	else if(purple_xfer_get_type(xfer) == PURPLE_XFER_SEND) {
 		purple_debug_info("google_session", "XFER_SEND Ended..in gtalk_xfer_end\n");
@@ -1656,7 +1667,7 @@ gtalk_xfer_read(guchar **out_buffer, Pur
 		buffer += tmp;
 		purple_circ_buffer_mark_read(share_session->buffer, tmp);
 	}
-	purple_debug_info("google_session", "Inside gtalk_xfer_read,  returning : %ld\n",size);
+	//	purple_debug_info("google_session", "Inside gtalk_xfer_read,  returning : %ld\n",size);
 	return size;
 }
 
@@ -2475,7 +2486,7 @@ jabber_google_session_parse(JabberStream
 
 	for (; iter; iter = g_list_delete_link(iter, iter)) {
 		GoogleSession *gsession =
-				purple_media_get_prpl_data(iter->data);
+			purple_media_get_prpl_data(iter->data);
 		
 		if (google_session_id_equal(&(gsession->id), &id)) {
 			session = gsession;



More information about the Commits mailing list