/soc/2013/ashmew2/filetransferY: 06da4c4ec0ab: GSOC Soft Pencils...

Ashish Gupta ashmew2 at gmail.com
Mon Sep 16 14:31:10 EDT 2013


Changeset: 06da4c4ec0ab92e581a82aae1d67337cf7e460d8
Author:	 Ashish Gupta <ashmew2 at gmail.com>
Date:	 2013-09-17 00:00 +0530
Branch:	 filetransferX
URL: https://hg.pidgin.im/soc/2013/ashmew2/filetransferY/rev/06da4c4ec0ab

Description:

GSOC Soft Pencils Down Commit. Cleaned up some more

diffstat:

 libpurple/protocols/jabber/google/google_session.c |  167 +-------------------
 1 files changed, 13 insertions(+), 154 deletions(-)

diffs (truncated from 326 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
@@ -128,15 +128,10 @@ google_session_destroy(GoogleSession *se
 
 		purple_debug_info("google_session", "Destroying the current Google Session..\n");
 
-/*TODO REMOVE:		if(!share_session->share_agent)
-			purple_debug_info("google_session", "Agent is NULL!\n");
-		else
-			purple_debug_info("google_session", "Agent is not NULL!\n");
-*/	
-		/*Xfer section needs fixing...TODO*/
+		/*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);
-
+		*/
 		if (purple_xfer_get_status(share_session->xfer) != PURPLE_XFER_STATUS_DONE)
 			{
 				purple_debug_info("google_session", "Calling xfer_cancel_local\n");
@@ -600,22 +595,6 @@ jabber_google_relay_response_session_ini
 				g_object_set(G_OBJECT (agent), "stun-server", js->stun_ip, NULL);
 				g_object_set(G_OBJECT (agent), "stun-server-port", js->stun_port, NULL);
 			}
-/*TODO: REMOVE ME???
-			if (relay_ip) {
-				purple_debug_info("google_session", "Setting relay info on the agent..\n");
-				if (relay_udp)
-					nice_agent_set_relay_info(agent, share_session->stream_id, 1, relay_ip, relay_udp,
-								  relay_username, relay_password, NICE_RELAY_TYPE_TURN_UDP);
-				if (relay_tcp)
-					nice_agent_set_relay_info(agent, share_session->stream_id, 1, relay_ip, relay_tcp,
-								  relay_username, relay_password, NICE_RELAY_TYPE_TURN_TCP);
-				if (relay_ssltcp)
-					nice_agent_set_relay_info(agent, share_session->stream_id, 1, relay_ip, relay_ssltcp,
-								  relay_username, relay_password, NICE_RELAY_TYPE_TURN_TLS);
-			}
-
-			return;
-*/
 		}
 		else 
 			purple_debug_info("google_session", "share_agent is already initialized!..\n");		
@@ -639,9 +618,7 @@ jabber_google_relay_response_session_ini
 		if(session->session_should_die) {
 			google_session_destroy(session);
 			return;
-		}
-		
-/*		gtalk_xfer_send_candidates(session);  TODO: Possible Removal*/
+		}		
 		return;
 	}
 	/*The procedure for Share Session ends here. What follows is the process needed for Media sessions*/
@@ -973,26 +950,6 @@ google_session_handle_initiate(JabberStr
 			else
 				purple_debug_info("google_session", "Transport is NULL");
 		}
-		/**************************
-FT XML: 
-
-(23:32:45) jabber: Sending (ssl) (doondoon1234 at gmail.com/B1D48535): <iq to="ashmew2 at gmail.com/Talk.v104536A73D2" type="set" id="145" from="doondoon1234 at gmail.com/B1D48535"><session type="initiate" id="1800989809" initiator="doondoon1234 at gmail.com/B1D48535" xmlns="http://www.google.com/session"><description xmlns="http://www.google.com/session/share"><manifest><file size="1611"><name>XPLUS5.rar</name></file></manifest><protocol><http><url name="source-path">/temporary/667e854066cbd01f8cd111c35752275e/</url><url name="preview-path">/temporary/bca878ad01c248741978a105ed28d9a4/</url></http></protocol></description><transport xmlns="http://www.google.com/transport/p2p"/></session></iq>
-
-(23:32:46) jabber: Recv (ssl)(108): <iq to="doondoon1234 at gmail.com/B1D48535" id="145" type="result" from="ashmew2 at gmail.com/Talk.v104536A73D2"/>
-(23:32:46) jabber: Unhandled IQ with id 145
-
-(23:32:47) jabber: Recv (ssl)(306): <iq to="doondoon1234 at gmail.com/B1D48535" type="set" id="147" from="ashmew2 at gmail.com/Talk.v104536A73D2"><session type="transport-accept" id="1800989809" initiator="doondoon1234 at gmail.com/B1D48535" xmlns="http://www.google.com/session"><transport xmlns="http://www.google.com/transport/p2p"/></session></iq>
-
-(23:32:58) jabber: Recv (ssl)(350): <iq to="doondoon1234 at gmail.com/B1D48535" type="set" id="148" from="ashmew2 at gmail.com/Talk.v104536A73D2"><session type="accept" id="1800989809" initiator="doondoon1234 at gmail.com/B1D48535" xmlns="http://www.google.com/session"><description xmlns="http://www.google.com/session/share"><manifest/><protocol><http/></protocol></description></session></iq>
-
-(23:32:59) jabber: Recv (ssl)(309): <iq to="doondoon1234 at gmail.com/B1D48535" type="set" id="149" from="ashmew2 at gmail.com/Talk.v104536A73D2"><session type="info" id="1800989809" initiator="doondoon1234 at gmail.com/B1D48535" xmlns="http://www.google.com/session"><channel name="private-1" xmlns="http://www.google.com/session/share"/></session></iq>
-
-(23:32:59) jabber: Recv (ssl)(503): <iq to="doondoon1234 at gmail.com/B1D48535" type="set" id="150" from="ashmew2 at gmail.com/Talk.v104536A73D2"><session type="transport-info" id="1800989809" initiator="doondoon1234 at gmail.com/B1D48535" xmlns="http://www.google.com/session"><transport xmlns="http://www.google.com/transport/p2p"><candidate name="private-1" address="10.0.2.15" port="62507" preference="1" username="foQ/wQK8zax36hHz" protocol="udp" generation="0" password="ItDgj6A3q83mpfrt" type="local" network="0"/></transport></session></iq>
-
-(23:32:59) jabber: Recv (ssl)(509): <iq to="doondoon1234 at gmail.com/B1D48535" type="set" id="151" from="ashmew2 at gmail.com/Talk.v104536A73D2"><session type="transport-info" id="1800989809" initiator="doondoon1234 at gmail.com/B1D48535" xmlns="http://www.google.com/session"><transport xmlns="http://www.google.com/transport/p2p"><candidate name="private-1" address="49.248.185.192" port="53172" preference="0.9" username="rTjIPIdOe2BZchUn" protocol="udp" generation="0" password="dbuAaKuZErs5YXva" type="stun" network="0"/></transport></session></iq>
-
-(23:33:01) jabber: Recv (ssl)(238): <iq to="doondoon1234 at gmail.com/B1D48535" type="set" id="152" from="ashmew2 at gmail.com/Talk.v104536A73D2"><session type="terminate" id="1800989809" initiator="ashmew2 at gmail.com/Talk.v104536A73D2" xmlns="http://www.google.com/session"/></iq>
-		************************************/
 		/*Add the GoogleSession *session to the GList*/
 
 		purple_debug_info("google_session", "We have received a file request : XFER_RECEIVE.\n");
@@ -1015,39 +972,6 @@ FT XML:
 		share_session->xfer->data = session;
 		share_session->buffer = purple_circ_buffer_new(65536);
 		
-/*
-		purple_debug_info("google_session", "Sending a file request in return\n");
-		jabber_send_raw(js,temp,strlen(temp));
-*/
-		/*
-		result_iq = jabber_iq_new(js,JABBER_IQ_RESULT);
-		xmlnode_set_attrib(result_iq->node, "to", session->remote_jid);
-		jabber_iq_set_id(result_iq, iq_id);
-		jabber_iq_send(result_iq);
-		purple_debug_info("google_session", "\nSent result_iq.\n");
-//Sending result_iq fixes the automatic cancellation from GTalk's side and now waits for infinite time 
-
-		set_iq = jabber_iq_new(js,JABBER_IQ_SET);
-		// FIXME : Assign a unique? ID to set_iq which is not the same as result_iq 
-
-		jabber_iq_set_id(set_iq, "26");
-
-		xmlnode_set_attrib(set_iq->node, "to", session->remote_jid);
-		temp = xmlnode_new_child(set_iq->node, "session");
-		xmlnode_set_attrib(temp, "type", "transport-accept");
-		xmlnode_set_attrib(temp, "id", xmlnode_get_attrib(sess, "id"));
-		xmlnode_set_attrib(temp, "initiator", me);
-		xmlnode_set_namespace(temp, "http://www.google.com/session/share");
-		temp = xmlnode_new_child(temp, "transport");
-		xmlnode_set_namespace(temp, "http://www.google.com/transport/p2p");
-		purple_debug_info("google_session", "Our set_iq->node str : %s",xmlnode_to_str(set_iq->node, &responsetxtlen));
-		jabber_iq_send(set_iq);
-
-		  jabber_iq_set_id(result_iq, iq_id); //Needs 1to be different as compared to result_iq
-		  jabber_iq_send(set_iq);
-		  purple_debug_info("google_session", "\nSent set_iq\n");
-		*/
-		
 		result = jabber_iq_new(js,JABBER_IQ_RESULT);
 		xmlnode_set_attrib(result->node, "to", session->remote_jid);
 		jabber_iq_set_id(result, iq_id);
@@ -1268,8 +1192,7 @@ nice_candidate_from_xml(const xmlnode *c
 
 static void
 gtalk_xfer_handle_candidates(JabberStream *js, GoogleSession *session, xmlnode *sess, const char *iq_id)
-{/*<iq to="doondoon1234 at gmail.com/F0529E73" type="set" id="249" from="ashmew2 at gmail.com/Talk.v1040217A105"><session type="transport-info" id="1195983148" initiator="ashmew2 at gmail.com/Talk.v1040217A105" xmlns="http://www.google.com/session"><transport xmlns="http://www.google.com/transport/p2p"><candidate name="private-1" address="10.0.2.15" port="58919" preference="1" username="j8xIQAN/LvaC/dxb" protocol="udp" generation="0" password="eEy12J+BFBmZO0jj" type="local" network="0"/></transport></session></iq>*/
-
+{
 	GSList *candidate_list = NULL;
 	xmlnode *candidate_node, *transport_node;
 	GoogleAVSessionData *session_data = (GoogleAVSessionData*)session->session_data;
@@ -1409,7 +1332,6 @@ google_session_handle_accept(JabberStrea
 	jabber_iq_send(result);
 }
 
-/*TODO: Make me complete..*/
 static void 
 gtalk_xfer_handle_reject(JabberStream *js, GoogleSession *session, const char *iq_id)
 {	
@@ -1451,7 +1373,8 @@ google_session_handle_terminate(JabberSt
 		return;
 	}
 			
-	if(session_data->share) {	
+	if(session_data->share) {	/*TODO: Right now, we are only using local_cancel(xfer), need to use
+					  remote_cancel(xfer) as well*/
 		session->state = TERMINATED;
 		google_session_destroy(session);
 	}
@@ -1478,8 +1401,6 @@ gtalk_xfer_send_candidates(GoogleSession
 		NiceCandidate *nice_candid = (NiceCandidate *)iter->data;
 		NiceCandidateType type;
 
-		/*TODO: ADd TURN information for RELAY candidates most probably*/
-
 		iq = jabber_iq_new(session->js, JABBER_IQ_SET);
 		sess = google_session_create_xmlnode(session, "transport-info");
 		xmlnode_insert_child(iq->node, sess);
@@ -1506,21 +1427,13 @@ gtalk_xfer_send_candidates(GoogleSession
 		password = g_strdup(nice_candid->password);
 				
 		xmlnode_set_attrib(candidate, "username", username != NULL ? username : "");
-		/*	xmlnode_set_attrib(candidate, "password",
-				   password != NULL ? password : "");
-		TODO: Setting password blank for now. Let's see what happens. Remove Me.
-		*/
-//		xmlnode_set_attrib(candidate, "password", "");
-//		purple_debug_info("google_session", "Setting even more attributes now.. : \n");
 /*TODO: Fix preference*/
 		xmlnode_set_attrib(candidate, "preference", type == NICE_CANDIDATE_TYPE_HOST ? "0.000015":
 				   "0.000000");
 
 		xmlnode_set_attrib(candidate, "protocol", "udp");
-/*TODO: ADD RELAY SERVERS ASAP! Are they working now?*/
 		/*CHECK THIS : TODO Type*/
 
-//		purple_debug_info("google_session", "Setting type attrib : \n");
 		xmlnode_set_attrib(candidate, "type", 
 				   type == NICE_CANDIDATE_TYPE_HOST ? "local":
 				   type == NICE_CANDIDATE_TYPE_SERVER_REFLEXIVE ? "stun":
@@ -1687,11 +1600,6 @@ void
 gtalk_xfer_end(PurpleXfer *xfer)
 {
 
-/*TODO: Send this XML stanza in order to say that the transfer is finished. We must send this, otherwise GTalk will keep
-  thinking that the xfer is still ongoing
-  <iq to="doondoon1234 at gmail.com/24E670D3" type="set" id="102" from="ashmew2 at gmail.com/Talk.v1048DA41A6C"><session type="info" id="purple4bbd2553" initiator="doondoon1234 at gmail.com/24E670D3" xmlns="http://www.google.com/session"><complete xmlns="http://www.google.com/session/share"/></session></iq>
-
-*/
 /*The following is only for PURPLE_XFER_RECEIVE...Should add something for PURPLE_XFER_SEND ?..TODO*/		
 	GoogleSession *session = (GoogleSession *) xfer->data;
 	GoogleAVSessionData *session_data =
@@ -1699,6 +1607,7 @@ gtalk_xfer_end(PurpleXfer *xfer)
 	JabberStream *js = session->js;
 	JabberIq *iq = jabber_iq_new(js, JABBER_IQ_SET);
 	xmlnode *complete_node, *session_node;
+
 	if(purple_xfer_get_type(xfer) == PURPLE_XFER_RECEIVE) {		
 		xmlnode_set_attrib(iq->node, "to", session->remote_jid);	
 		session_node = xmlnode_new_child(iq->node, "session");
@@ -1853,7 +1762,6 @@ cb_nice_recv(NiceAgent *agent, guint str
 	}
 	else {
 		purple_debug_info("google_session", "XFER_TYPE NOT KNOWN!");
-		/*TODO: Make cancel functions for xfers otherwise infini loops and bad things happen*/
 		
 	}
 }
@@ -1975,15 +1883,6 @@ void cb_nice_component_state_changed(Nic
 	  }
 	  
 	}
-
-	/*	if( purple_xfer_get_type(share_session->xfer) == PURPLE_XFER_SEND && state == NICE_COMPONENT_STATE_READY) {
-		char *file_buf = NULL;
-
-		FILE *file_ptr = share_session->file_to_send;
-		
-		purple_debug_info("google_session", "STATE_READY for XFER_SEND! in cb_component_state_changed.");
-		}*/
-
 }
 
 void gtalk_xfer_get_next_block(GoogleXferSessionData *share_session)
@@ -2044,22 +1943,12 @@ void cb_nice_component_writable(NiceAgen
 		}
  		
 		while (1) {
-/*			purple_debug_info("google_session", "ftell gives : %ld\n", ftell(file_ptr));
-TODO REMOVE?
-			purple_debug_info("google_session", "\nBytes remaining: %llu",
-					  purple_xfer_get_bytes_remaining(xfer));
-
-			purple_debug_info("google_session","Bytes of buffer trying to send : %d\n", share_session->file_buf_current_size - 
-					  share_session->file_buf_sent);
-*/
 
 			send_ret = nice_agent_send(share_session->share_agent, share_session->stream_id, 1,
 						   share_session->file_buf_current_size - share_session->file_buf_sent, 
 						   file_buf+share_session->file_buf_sent);
 
-/*TODO:REMOVE?			purple_debug_info("google_session", "Send _ret is %d\n",send_ret);*/
-/*TODO: Replace if(else by an if?*/			
-			if(send_ret<=0){
+			if(send_ret<=0)
 				purple_debug_info("google_session", "send_ret is negative or zero or less than len...\n");
 				break;
 			}
@@ -2075,11 +1964,7 @@ TODO REMOVE?
 				purple_xfer_set_completed(xfer, 1);
 				return;
 			}
-/*TOOD REMOVE?
-			purple_debug_info("google_session", "Bytes remaining : %zu\n", purple_xfer_get_bytes_remaining(xfer));
-			purple_debug_info("google_session", "Current buf size : %d\n",share_session->file_buf_current_size);
-			purple_debug_info("google_session", "Current Bytes Sent.. : %d\n",share_session->file_buf_sent);
-*/
+
                   /*The following is equivalent to checking if send_ret is less than the no of bytes we wanted to send..*/
 			if(share_session->file_buf_current_size != share_session->file_buf_sent)
 				break;
@@ -2107,8 +1992,6 @@ gtalk_xfer_start(PurpleXfer *xfer)
 {
 	purple_debug_info("google_session", "Inside gtalk_xfer_start()\n");
 
-/*Reading the whole file into memory as it's very experimental right now, Need to fix it for Bigger Files*/
-
 	if(purple_xfer_get_type(xfer) == PURPLE_XFER_SEND) {
 		guchar *buffer = g_malloc( xfer->bytes_remaining );
 		int wrote = purple_xfer_write( xfer, buffer, xfer->bytes_remaining );
@@ -2318,9 +2201,7 @@ void
 gtalk_xfer_request_denied(PurpleXfer *xfer)
 {
 	purple_debug_info("google_session", "Request denied by user..\n");
-	gtalk_xfer_send_reject(xfer);
-	
-	/*TODO: Session should end here but Not prematurely! FIXED.?*/
+	gtalk_xfer_send_reject(xfer);	
 }
 
 gssize
@@ -2611,11 +2492,10 @@ jabber_google_session_parse(JabberStream
 			for(; iter; iter=iter->next) {
 				GoogleSession *gsession = (GoogleSession *)(iter->data);
 
-				if (!strcmp(id.id, gsession->id.id)) {
+				if (!google_session_id_equal(session, gsession)) {
 					session = gsession;
-					/*TODO: This is probably insufficient, we need to tally id.initiator as well..Oh well..For now...*/
 					break;
-					/*Found a GoogleSession*/
+					/*TODO: Ensure this works. Found a GoogleSession*/
 				}
 			}
 		}
@@ -2625,28 +2505,7 @@ jabber_google_session_parse(JabberStream
 			google_session_parse_iq(js, session, session_node, iq_id);
 			return;
 		}



More information about the Commits mailing list