/soc/2013/ashmew2/filetransferY: f55fc21844d9: Fixed width of mo...

Ashish Gupta ashmew2 at gmail.com
Sat Feb 1 07:55:20 EST 2014


Changeset: f55fc21844d9d7e65c6f9b149ae746f590235fda
Author:	 Ashish Gupta <ashmew2 at gmail.com>
Date:	 2014-02-01 18:22 +0530
Branch:	 filetransferX
URL: https://hg.pidgin.im/soc/2013/ashmew2/filetransferY/rev/f55fc21844d9

Description:

Fixed width of most lines

diffstat:

 libpurple/protocols/jabber/google/google_session.c |  189 +++++------
 libpurple/protocols/jabber/google/google_share.c   |  342 ++++++++++----------
 2 files changed, 255 insertions(+), 276 deletions(-)

diffs (truncated from 1139 to 300 lines):

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
@@ -38,8 +38,10 @@ typedef struct {
 	gboolean video;
 	GList *remote_audio_candidates; /* list of PurpleMediaCandidate */
 	GList *remote_video_candidates; /* list of PurpleMediaCandidate */
-	gboolean added_streams;		/* this indicates if the streams have been
-					   to media (ie. after getting relay credentials */
+	gboolean added_streams;		/* this indicates if the streams have 
+					 * been to media (ie. after getting
+					 * relay credentials 
+					 */
 } GoogleAVSessionData;
 
 static gboolean
@@ -52,7 +54,7 @@ google_session_id_equal(gconstpointer a,
 }
 
 void
-google_session_destroy(GoogleSession *session) /*TODO: Used for both share and VV*/
+google_session_destroy(GoogleSession *session)
 {
 	JabberStream *js = session->js;	
 	session->state = TERMINATED;			
@@ -62,30 +64,21 @@ google_session_destroy(GoogleSession *se
 		GoogleXferSessionData *share_session = session->session_data;
 		GSList *temp = NULL;
 		
-		purple_debug_info("google_session", "Destroying The current Google Session..\n");
+		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_xfer_cancel_local(share_session->xfer);
+			}
+		}
 		
-		/*Xfer section needs fixing...TODO : Remove 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_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)
-			fclose(share_session->file_to_send);
-
-		purple_debug_info("google_session", "Phase -3\n");	    
+		  fclose(share_session->file_to_send);
 
 		share_session->xfer = NULL;
 		g_free(share_session->filename);
@@ -94,24 +87,28 @@ google_session_destroy(GoogleSession *se
 		g_free(share_session->file_buf);
 		g_free(share_session->channel_name);
 
-		purple_debug_info("google_session", "Phase -2\n");
 		if(share_session->share_agent) {
-			g_signal_handlers_disconnect_by_func(G_OBJECT(share_session->share_agent),
-							     G_CALLBACK (cb_candidate_gathering_done), session);
-		
-			g_signal_handlers_disconnect_by_func(G_OBJECT(share_session->share_agent),
-							     G_CALLBACK (cb_new_selected_pair), NULL);
+			g_signal_handlers_disconnect_by_func(
+				G_OBJECT(share_session->share_agent),
+				G_CALLBACK(cb_candidate_gathering_done),
+				session);
 			
-			g_signal_handlers_disconnect_by_func(G_OBJECT(share_session->share_agent),
-							     G_CALLBACK (cb_nice_component_state_changed),
-							     session);
-		
-			g_signal_handlers_disconnect_by_func(G_OBJECT(share_session->share_agent),
-							     G_CALLBACK (cb_nice_component_writable), 
-							     share_session);      
+			g_signal_handlers_disconnect_by_func(
+				G_OBJECT(share_session->share_agent),
+				G_CALLBACK (cb_new_selected_pair), NULL);
+			
+			g_signal_handlers_disconnect_by_func(
+				G_OBJECT(share_session->share_agent),
+				G_CALLBACK (cb_nice_component_state_changed),
+				session);
+			
+			g_signal_handlers_disconnect_by_func(
+				G_OBJECT(share_session->share_agent),
+				G_CALLBACK (cb_nice_component_writable), 
+				share_session);      
 			g_object_unref(share_session->share_agent);
 		}
-
+		
 		purple_circ_buffer_destroy(share_session->buffer);
 		
 		for (temp = share_session->remote_share_candidates; temp; temp =
@@ -129,10 +126,12 @@ google_session_destroy(GoogleSession *se
 	else { /*If it is an AV session*/
 		GoogleAVSessionData *session_data = session->session_data;
 		if (session_data->remote_audio_candidates)
-			purple_media_candidate_list_free(session_data->remote_audio_candidates);
+			purple_media_candidate_list_free(
+				session_data->remote_audio_candidates);
 		
 		if (session_data->remote_video_candidates)
-			purple_media_candidate_list_free(session_data->remote_video_candidates);
+			purple_media_candidate_list_free(
+				session_data->remote_video_candidates);
 	}
 	
 	js->google_share_sessions = g_list_remove(js->google_share_sessions,session);
@@ -146,7 +145,6 @@ google_session_destroy(GoogleSession *se
 	
 	g_free(session->session_data);
 	g_free(session);
-	purple_debug_info("google_session", "Phase END of function\n");
 }
 
 xmlnode *
@@ -177,8 +175,6 @@ google_session_send_candidates(PurpleMed
 	if (!strcmp(session_id, "google-video"))
 		video = TRUE;
 
-	purple_debug_info("google_session", "Inside send_candidates()\n");
-
 	for (iter = candidates; iter; iter = iter->next) {
 		JabberIq *iq;
 		gchar *ip, *port, *username, *password;
@@ -273,9 +269,7 @@ google_session_ready(GoogleSession *sess
 		    !purple_media_accepted(media, NULL, NULL)) {
 			g_free(me);
 			return;
-		}
-		
-		purple_debug_info("google_session", "Inside google_session_ready\n");
+		}		
 
 		iq = jabber_iq_new(session->js, JABBER_IQ_SET);
 
@@ -574,8 +568,6 @@ jabber_google_session_initiate(JabberStr
 	session->js = js;
 	session->remote_jid = jid;
 	session_data = g_new0(GoogleAVSessionData, 1);
-	/*what to do? TODO*/
-/*	((GoogleAVSessionData *)session_data)->share_session = g_new0(GoogleXferSessionData, 1);*/
 	
 	session->session_data = session_data;
 
@@ -775,7 +767,8 @@ google_session_handle_initiate(JabberStr
 }
 
 static void
-google_session_handle_candidates(JabberStream  *js, GoogleSession *session, xmlnode *sess, const char *iq_id)
+google_session_handle_candidates(JabberStream  *js, GoogleSession *session, 
+				 xmlnode *sess, const char *iq_id)
 {
 	JabberIq *result;
 	GList *list = NULL, *video_list = NULL;
@@ -788,8 +781,11 @@ google_session_handle_candidates(JabberS
 	cand_parent = sess;
 
 	if(session->share) {
-		/*TODO : Optimize this block for SHARE only!. Multimedia is already handled*/
-		GoogleXferSessionData *share_session = (GoogleXferSessionData *)session->session_data;
+		/* TODO : Optimize this block for SHARE only!. 
+		 * Multimedia is being handled elsewhere
+		 */
+		GoogleXferSessionData *share_session = 
+			(GoogleXferSessionData *)session->session_data;
 		transport = xmlnode_get_child(sess, "transport");
 		cand_parent = transport;
 
@@ -806,7 +802,10 @@ google_session_handle_candidates(JabberS
 		
 			if (cname && type && address && port) {
 				PurpleMediaCandidateType candidate_type;
-				guint prio = preference ? g_ascii_strtod(preference, NULL) * 1000 : 0;
+				guint prio = 
+					preference ? 
+					g_ascii_strtod(preference, NULL) * 1000 :
+					0;
 			
 				g_snprintf(n, sizeof(n), "S%d", name++);
 			
@@ -836,7 +835,7 @@ google_session_handle_candidates(JabberS
 					     "password", xmlnode_get_attrib(cand, "password"),
 					     "priority", prio, NULL);
 			
-                                /*If it's a share session*/
+                                /*It's a share session*/
 				share_session->remote_share_candidates = 
 					g_slist_append(share_session->remote_share_candidates,
 						       info);
@@ -849,12 +848,9 @@ google_session_handle_candidates(JabberS
 		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", "Inside google_session_handle_candidiates()\nNow Returning\n\n");		
 		return;
 	}
 
-	purple_debug_info("google_session", "Inside google_session_handle_candidiates()\n");
-
 	for (cand = xmlnode_get_child(cand_parent, "candidate"); cand;
 	     cand = xmlnode_get_next_twin(cand)) {
 		PurpleMediaCandidate *info;
@@ -916,17 +912,11 @@ google_session_handle_candidates(JabberS
 								      info);
 					}
 				}
-			}
-			else {/*If it's a share session*/
-				GoogleXferSessionData * share_session  = (GoogleXferSessionData *) session->session_data;
-				share_session->remote_share_candidates = 
-					g_slist_append(share_session->remote_share_candidates,
-						       info);
-				purple_debug_info("google_session", "Added candidate to sharelist\n");
-			}
+			}		
 		}
 		else {
-			purple_debug_info("google_session", "cname && port && address && type FAILED!\n");
+			purple_debug_info("google_session",
+					  "cname && port && address && type FAILED!\n");
 		}
 	}
 
@@ -950,7 +940,8 @@ google_session_handle_candidates(JabberS
 }
 
 static void
-google_session_handle_transport_accept(JabberStream *js, GoogleSession *session, xmlnode *sess, const char *iq_id)
+google_session_handle_transport_accept(JabberStream *js, GoogleSession *session,
+				       xmlnode *sess, const char *iq_id)
 {
 	JabberIq *result_iq = jabber_iq_new(js,JABBER_IQ_RESULT);
 
@@ -961,9 +952,9 @@ google_session_handle_transport_accept(J
 }
 
 static void
-google_session_handle_transport_info(JabberStream *js, GoogleSession *session, xmlnode *sess, const char *iq_id)
+google_session_handle_transport_info(JabberStream *js, GoogleSession *session,
+				     xmlnode *sess, const char *iq_id)
 {
-/*	GoogleAVSessionData *session_data = (GoogleAVSessionData *)session->session_data; TODO : remove me?*/
 	purple_debug_info("google_session", "Inside handle_transport_info..\n");
 	
 	if(session->share)
@@ -973,7 +964,8 @@ google_session_handle_transport_info(Jab
 }
 
 static void
-google_session_handle_accept(JabberStream *js, GoogleSession *session, xmlnode *sess, const char *iq_id)
+google_session_handle_accept(JabberStream *js, GoogleSession *session,
+			     xmlnode *sess, const char *iq_id)
 {
 	xmlnode *desc_element = xmlnode_get_child(sess, "description");
 	xmlnode *codec_element = xmlnode_get_child(
@@ -1047,7 +1039,8 @@ google_session_handle_reject(JabberStrea
 }
 
 static void
-google_session_handle_terminate(JabberStream *js, GoogleSession *session, xmlnode *sess, const char *iq_id)
+google_session_handle_terminate(JabberStream *js, GoogleSession *session,
+				xmlnode *sess, const char *iq_id)
 {
 	JabberIq *result = jabber_iq_new(js, JABBER_IQ_RESULT);
 	jabber_iq_set_id(result, iq_id);
@@ -1055,19 +1048,16 @@ google_session_handle_terminate(JabberSt
 	jabber_iq_send(result);
 
 	purple_debug_info("google_session","Setting session_should_die to 1 \n");
-	session->session_should_die = 1; /*TODO: what to do?*/	       
+	session->session_should_die = 1;	       
 				
-	if(session->share) {	/*TODO: Right now, we are only using local_cancel(xfer), need to use
-				  remote_cancel(xfer) as well, Possibly fixed, but not everywhere.*/
+	if(session->share) {	
+		GoogleXferSessionData *share_session =
+			(GoogleXferSessionData *)session->session_data;
+		share_session->xfer->status = PURPLE_XFER_STATUS_CANCEL_REMOTE;	
 
-		GoogleXferSessionData *share_session = (GoogleXferSessionData *)session->session_data;



More information about the Commits mailing list