/soc/2013/ashmew2/filetransferX: b3c5715f7ec7: Fixed encoding is...

Ashish Gupta ashmew2 at gmail.com
Mon Sep 9 07:14:41 EDT 2013


Changeset: b3c5715f7ec7e986a2d2db0775eb72d2a05762ab
Author:	 Ashish Gupta <ashmew2 at gmail.com>
Date:	 2013-09-09 16:44 +0530
Branch:	 filetransferX
URL: https://hg.pidgin.im/soc/2013/ashmew2/filetransferX/rev/b3c5715f7ec7

Description:

Fixed encoding issue in GET Request

diffstat:

 libpurple/protocols/jabber/google/google_session.c |  56 ++++++++++++++++++---
 1 files changed, 46 insertions(+), 10 deletions(-)

diffs (82 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
@@ -35,6 +35,7 @@
 
 typedef enum {
 	GTALK_XFER_CHANNEL_INITIALIZED = 0,
+	GTALK_XFER_CHANNEL_HTTP_GET_NOT_SENT,
 	GTALK_XFER_CHANNEL_SENT_HTTP_GET,
 	GTALK_XFER_CHANNEL_HTTP_GET_RECEIVED,
 	GTALK_XFER_CHANNEL_HTTP_OK_SENT,
@@ -2097,18 +2098,26 @@ void cb_nice_component_state_changed(Nic
 	  purple_debug_info("google_session", "READY!\n");
 	  gint send_ret;
 	  JabberStream *js = session->js;
-	  gchar *url = g_strdup_printf("%s%s", share_session->source_url, share_session->filename);
+	  guchar *raw_filename = purple_strreplace(share_session->filename, " ","%20");
+	  gchar *url = g_strdup_printf("%s%s", share_session->source_url, raw_filename);
 	  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"); 
-
+					   "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"); 
+	  
 	  send_ret = nice_agent_send(share_session->share_agent, share_session->stream_id, 1,
-			  strlen(request), request);
-	  share_session->channel_state = GTALK_XFER_CHANNEL_SENT_HTTP_GET;
-	  purple_debug_info("google_session", "send_ret is %d, Request is : \n%s\n",send_ret, request);	    
+				     strlen(request), request);
+	  if(send_ret > 0) {
+		  share_session->channel_state = GTALK_XFER_CHANNEL_SENT_HTTP_GET;
+		  purple_debug_info("google_session", "send_ret is %d, Request is : \n%s\n",send_ret, request);	    
+	  }
+	  else {
+		  share_session->channel_state = GTALK_XFER_CHANNEL_HTTP_GET_NOT_SENT;
+		  purple_debug_info("google_session", "GET Request couldn't be sent..Will wait for writable now..\n");
+	  }
+	  
 	}
 
 	if( purple_xfer_get_type(share_session->xfer) == PURPLE_XFER_SEND && state == NICE_COMPONENT_STATE_READY) {
@@ -2268,6 +2277,33 @@ void cb_nice_component_writable(NiceAgen
 		purple_debug_info("google_session", "Inside _writable state!=READY..\n");
 	}
 	
+	if(share_session->channel_state == GTALK_XFER_CHANNEL_HTTP_GET_NOT_SENT) {
+		gint send_ret;
+		GoogleSession *session = (GoogleSession *)xfer->data;
+		JabberStream *js = session->js;
+		guchar *raw_filename = purple_strreplace(share_session->filename, " ","%20");
+		gchar *url = g_strdup_printf("%s%s", share_session->source_url, raw_filename);
+		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"); 
+		gsize raw_len;
+		
+		send_ret = nice_agent_send(share_session->share_agent, share_session->stream_id, 1,
+					   strlen(request), 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));
+			purple_debug_info("google_session", "send_ret is %d, SENT_HTTP_GET\n",send_ret, request);	    
+		}
+		else {
+			share_session->channel_state = GTALK_XFER_CHANNEL_HTTP_GET_NOT_SENT;
+			purple_debug_info("google_session", "GET Request couldn't be sent..Will wait for writable now..\n");
+		}	
+	}
+
 	if(share_session->channel_state == GTALK_XFER_CHANNEL_HTTP_SENDING) {
 		purple_debug_info("google_session", "Checking for file_buf is NULL or not..");
 



More information about the Commits mailing list