/soc/2013/ashmew2/filetransferX: 3ab9bc9990a3: Shows selected ca...

Ashish Gupta ashmew2 at gmail.com
Mon Sep 9 11:25:55 EDT 2013


Changeset: 3ab9bc9990a349bc4e03c03f794bae4c15ad39cf
Author:	 Ashish Gupta <ashmew2 at gmail.com>
Date:	 2013-09-09 20:55 +0530
Branch:	 filetransferX
URL: https://hg.pidgin.im/soc/2013/ashmew2/filetransferX/rev/3ab9bc9990a3

Description:

Shows selected candidates for XFER_SEND

diffstat:

 libpurple/protocols/jabber/google/google_session.c |  60 +++++++++++++--------
 1 files changed, 37 insertions(+), 23 deletions(-)

diffs (159 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
@@ -1968,7 +1968,8 @@ cb_nice_recv(NiceAgent *agent, guint str
 				read_len = tmp - curr;
 				
 				purple_debug_info("google_session", "HTTP response header received : %s\n", curr);
-				
+				if(curr[0] == '\0')
+					purple_debug_info("google_session", "Curr is BLANK...Should exit...?", curr);
 				len -= read_len;
 				curr += read_len;
 				
@@ -2058,9 +2059,22 @@ void cb_nice_component_state_changed(Nic
 	if(purple_xfer_get_type(share_session->xfer) == PURPLE_XFER_SEND) {
 		GSList *remote_candids = nice_agent_get_remote_candidates(agent, stream_id, component_id);
 		GSList *local_candids = nice_agent_get_local_candidates(agent, stream_id, component_id);
+		NiceCandidate *rcand, *lcand;
+		gchar *temp = g_malloc(NICE_ADDRESS_STRING_LEN + 1);
+
+		nice_agent_get_selected_pair(share_session->share_agent, share_session->stream_id, 1,
+					     &lcand, &rcand);
+
+		purple_debug_info("google_session", "Selected Candidates : \n**********\n");
+		nice_address_to_string(&lcand->addr, temp);
+		purple_debug_info("google_session", "LOCAL CAND : IP: %s, Port:%u\n",temp,nice_address_get_port(&lcand->addr));
+		nice_address_to_string(&rcand->addr, temp);
+		purple_debug_info("google_session", "REMOTE CAN : IP: %s, Port:%u\n",temp,nice_address_get_port(&rcand->addr));			
+		
+		g_free(temp);
 		
 		purple_debug_info("google_session", "List of remote candidates : \n********\n");
-
+		
 		while(remote_candids) {
 			gchar *ip = g_malloc(NICE_ADDRESS_STRING_LEN + 1);
 			NiceCandidate *c = (NiceCandidate *)remote_candids->data;
@@ -2081,12 +2095,11 @@ void cb_nice_component_state_changed(Nic
 			local_candids = local_candids->next;
 		}
 		purple_debug_info("google_session", "***********\n");
-/*		g_signal_stop_emission_by_name(G_OBJECT(share_session->share_agent),"component-state-changed");*/
-
-/*TODO: Check if another way can be worked out without disconnecting the component-state-changed signal..*/
+		
+		
+		
 		if(share_session->channel_state == GTALK_XFER_CHANNEL_HTTP_OK_SENT) {
 			share_session->channel_state = GTALK_XFER_CHANNEL_HTTP_SENDING;
-			purple_debug_info("google_session", "Disconnected the component-state-changed signal..");
 			cb_nice_component_writable(share_session->share_agent, share_session->stream_id,
 						   1, share_session);
 		}
@@ -2103,9 +2116,9 @@ void cb_nice_component_state_changed(Nic
 	  gchar *request = g_strdup_printf("GET %s HTTP/1.1\r\n"
 					   "Connection: Keep-Alive\r\n"
 					   "Content-Length: 0\r\n"
-					   "Host: %s@%s/%s:0\r\n"
-					   "User-Agent: %s\r\n\r\n", url, js->user->node, js->user->domain,
-					   js->user->resource, "Pidgin 2.10.7"); 
+					   "Host: %s:0\r\n"
+					   "User-Agent: %s\r\n\r\n", url, session->remote_jid,
+					   "Google Talk"); 
 	  
 	  send_ret = nice_agent_send(share_session->share_agent, share_session->stream_id, 1,
 				     strlen(request), request);
@@ -2245,10 +2258,10 @@ void gtalk_xfer_get_next_block(GoogleXfe
 		return;
 	
 	purple_debug_info("google_session", "Making a buffer..Phase 1 Done.");
-	share_session->file_buf = malloc(65535);
+	share_session->file_buf = malloc(1200);
 	purple_debug_info("google_session", "Phase 2Done.");
 	purple_debug_info("google_session", "Phase 3Done.");
-	fread_ret = fread(share_session->file_buf, 1, 65536, share_session->file_to_send);
+	fread_ret = fread(share_session->file_buf, 1, 1200, share_session->file_to_send);
 	purple_debug_info("google_session", "Phase 4 Done.fread_ret is %d\n",fread_ret);
 	share_session->file_buf_current_size = fread_ret;
 	purple_debug_info("google_session", "Phase 5 Done.\n");
@@ -2286,13 +2299,13 @@ void cb_nice_component_writable(NiceAgen
 		gchar *request = g_strdup_printf("GET %s HTTP/1.1\r\n"
 						 "Connection: Keep-Alive\r\n"
 						 "Content-Length: 0\r\n"
-						 "Host: %s@%s/%s:0\r\n"
-						 "User-Agent: %s\r\n\r\n", url, js->user->node, js->user->domain,
-						 js->user->resource, "Pidgin 2.10.7"); 
+						 "Host: %s:0\r\n"
+						 "User-Agent: %s\r\n\r\n", url, session->remote_jid, "Google Talk"); 
 		gsize raw_len;
 		
 		send_ret = nice_agent_send(share_session->share_agent, share_session->stream_id, 1,
 					   strlen(request), request);
+		purple_debug_info("google_session", "send_ret is %d, Request is : \n%s\n",send_ret, request);	    
 		if(send_ret > 0) { /*Considering this to be successful. Maybe add a check for response?*/
 			share_session->channel_state = GTALK_XFER_CHANNEL_SENT_HTTP_GET;
 			purple_debug_info("google_session", "Request is : %s with length %d\n",request, strlen(request));
@@ -2315,13 +2328,13 @@ void cb_nice_component_writable(NiceAgen
 		purple_debug_info("google_session", "Entering the FOREVER loop..\n");
 				
 		while (1) {
-			purple_debug_info("google_session", "ftell gives : %ld\n", ftell(file_ptr));
+/*			purple_debug_info("google_session", "ftell gives : %ld\n", ftell(file_ptr));
 			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);
-			
-			/*Change the magic number 65530 to something sensible.*/
+*/
+
 			if(!file_buf)
 				purple_debug_info("purple_debug", "file_buf is NULL..\n");
 			else
@@ -2334,30 +2347,31 @@ void cb_nice_component_writable(NiceAgen
 			purple_debug_info("google_session", "Send _ret is %d\n",send_ret);
 			
 			if(send_ret<=0){
-				purple_debug_info("google_session", "send_ret is negative or zero...\n");
+				purple_debug_info("google_session", "send_ret is negative or zero or less than len...\n");
 				break;
 			}
-			else if (send_ret>0) {
+			else { //proper send_ret value
 				xfer->bytes_sent += send_ret;
 				xfer->bytes_remaining -= send_ret;
 				purple_xfer_update_progress(xfer);
 				share_session->file_buf_sent += send_ret;
 			}
-
+       		
 			if(purple_xfer_get_bytes_remaining(xfer) <= 0) {
 				purple_debug_info("google_session", "\nTransfer done!");
 				/* 
 				   Set up something here to check if CRLF CRLF is properly sent or not, 
 				   otherwise wait for writable signal again and resend:TODO
 				*/
-				nice_agent_send(share_session->share_agent, share_session->stream_id, 1,
-						strlen("\r\n\r\n"), "\r\n\r\n");
 				purple_xfer_set_completed(xfer, 1);
 				return;
 			}
 			purple_debug_info("google_session", "BYtes remaining : %llu\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 saying that 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;
 
 			if(share_session->file_buf_sent >= share_session->file_buf_current_size) {
 				free(file_buf);
@@ -2496,7 +2510,7 @@ OUR Response :
     * session xmlns='http://www.google.com/session' initiator='doondoon1234 at gmail.com/b35d7c07' id='1047464894' type='transport-info'
         * transport xmlns='http://www.google.com/transport/p2p'
             * candidate address='192.168.19.101' port='46448' username='281fPx+dTKp+JC4T' password='' preference='0.000015' protocol='udp' type='local' component='1' network='0' generation='0' name='private-1'
-            * candidate address='74.125.135.127' port='19305' username='JkrSpsOQtm6rNIHp' password='' preference='0.000000' protocol='udp' type='relay' component='1' network='0' generation='0' name='private-1'
+            * candidate address='74.125.135.127' port='19305' username='JkrSpsOQtm6rNHp' password='' preference='0.000000' protocol='udp' type='relay' component='1' network='0' generation='0' name='private-1'
             * candidate address='49.248.181.68' port='46448' username='HKmLfAkZB81f7r8x' password='' preference='0.000000' protocol='udp' type='stun' component='1' network='0' generation='0' name='private-1'
             * candidate address='74.125.135.127' port='19305' username='JkrSpsOQtm6rNIHp' password='' preference='0.000000' protocol='udp' type='relay' component='1' network='0' generation='0' name='private-1'
             * candidate address='74.125.135.127' port='443' username='JkrSpsOQtm6rNIHp' password='' preference='0.000000' protocol='udp' type='relay' component='1' network='0' generation='0' name='private-1'



More information about the Commits mailing list