/soc/2013/ashmew2/filetransferX: f037b2990a2c: Fixes xfer reques...

Ashish Gupta ashmew2 at gmail.com
Wed Aug 7 08:51:14 EDT 2013


Changeset: f037b2990a2cae52eb40acd4bc2d6c29e55cb518
Author:	 Ashish Gupta <ashmew2 at gmail.com>
Date:	 2013-08-07 17:27 +0530
Branch:	 filetransferX
URL: https://hg.pidgin.im/soc/2013/ashmew2/filetransferX/rev/f037b2990a2c

Description:

Fixes xfer request timeout for gtalk

diffstat:

 libpurple/protocols/jabber/google/google_session.c |  41 +++++++++++++--------
 1 files changed, 26 insertions(+), 15 deletions(-)

diffs (135 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
@@ -645,7 +645,7 @@ google_session_handle_initiate(JabberStr
 		xmlnode *description = xmlnode_get_child(sess, "description");
 		xmlnode *manifest,*file,*filename,*protocol,*http,*url_source_path,*url_preview_path,*transport;
 		char *filesize;
-		JabberIq *result_iq, *set_iq;
+		JabberIq *result_iq, *set_iq,*ResponseIq;
 		char *responsetxt;
 		int responsetxtlen;
 		xmlnode *tmp;
@@ -653,7 +653,7 @@ google_session_handle_initiate(JabberStr
 				session->js->user->node,
 				session->js->user->domain,
 				session->js->user->resource);
-
+		
 		char *temp=g_strdup_printf("<iq to=\"%s\" type=\"set\" id=\"%s\" from=\"%s\"><session type=\"initiate\" id=\"%s\" initiator=\"%s\" 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>",session->remote_jid, iq_id, me, xmlnode_get_attrib(sess, "id"), me);
 
 		
@@ -725,9 +725,10 @@ FT XML:
 		/*Add the GoogleSession *session to the GList*/
 		js->google_share_sessions = g_list_prepend(js->google_share_sessions, session);
 		purple_debug_info("google_session", "We have received a file request.\n");
-
+/*
 		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);
@@ -757,13 +758,13 @@ FT XML:
 		  jabber_iq_send(set_iq);
 		  purple_debug_info("google_session", "\nSent set_iq\n");
 		*/
-		/*
+		
 		  ResponseIq = jabber_iq_new(js,JABBER_IQ_RESULT);
 		  xmlnode_set_attrib(ResponseIq->node, "to", session->remote_jid);
-		  jabber_iq_set_id(ResponseIq, xmlnode_get_attrib(sess,"id"));
-		  purple_debug_info("google_session", "ResponseIq->id : %s\n",ResponseIq->id);
+		  jabber_iq_set_id(ResponseIq, iq_id);
+		  purple_debug_info("google_session", "handle_initiate() : ResponseIq->id : %s\n",ResponseIq->id);
 		  jabber_iq_send(ResponseIq);
-		
+		  /*
 		ResponseIq2 = jabber_iq_new(js,JABBER_IQ_SET);
 		xmlnode_set_attrib(ResponseIq2->node, "to", session->remote_jid);
 		jabber_iq_set_id(ResponseIq2, xmlnode_get_attrib(sess, "id"));
@@ -884,6 +885,7 @@ static void
 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);
+	purple_debug_info("google_session", "Inside handle_transport_accept()\n");
 	xmlnode_set_attrib(result_iq->node, "to", session->remote_jid);
 	jabber_iq_set_id(result_iq, iq_id);
 	jabber_iq_send(result_iq);
@@ -1053,14 +1055,14 @@ gtalk_xfer_send(PurpleConnection *gc, co
 	  return;
   }
   /*TODO: Start a STUN discovery here to get our external IP for sending out as a candidate to GTalk*/
-  stun_discovery = purple_stun_discover(stun_discovery_cb);
+/*  stun_discovery = purple_stun_discover(stun_discovery_cb);*/
   /*TODO: if stun_discovery is NULL, that means stun_discovery_cb will be called when discovery is done.*/
 
-  if(stun_discovery)
+/*  if(stun_discovery)
 	  purple_debug_info("google_session", "stun_discovery is NOT NULL. Public IP : %s\n",stun_discovery->publicip);
   else
 	  purple_debug_info("google_session", "stun_discovery is NULL for now..\n");
-
+*/
   if (file) {
 /*TODO: This should probably be something else*/
 	  purple_xfer_request_accepted(xfer, file);
@@ -1122,7 +1124,7 @@ void gtalk_xfer_session_initiate(PurpleX
 	JabberIq *iq;
 	xmlnode *session_node, *description_node, *file_node, *manifest_node, *transport_node;
 	xmlnode *name_node, *protocol_node, *http_node, *url_source_node, *url_preview_node;
-
+	int size;
 	gchar *me = g_strdup_printf("%s@%s/%s",
 				    js->user->node,
 				    js->user->domain,
@@ -1178,13 +1180,17 @@ void gtalk_xfer_session_initiate(PurpleX
 	protocol_node = xmlnode_new_child(description_node, "protocol");
 	http_node = xmlnode_new_child(protocol_node, "http");
 	url_source_node = xmlnode_new_child(http_node, "url");
+	xmlnode_set_attrib(url_source_node, "name", "source-path");
+	xmlnode_insert_data(url_source_node, gtalk_get_temporary_url(), -1);
 
-	xmlnode_insert_data(url_source_node, gtalk_get_temporary_url(), -1);
 	url_preview_node = xmlnode_new_child(http_node, "url");
+	xmlnode_set_attrib(url_preview_node, "name", "preview-path");
 	xmlnode_insert_data(url_preview_node, gtalk_get_temporary_url(), -1);
+
 	transport_node = xmlnode_new_child(session_node, "transport");
 	xmlnode_set_namespace(transport_node, NS_GOOGLE_TRANSPORT_P2P);
 
+	purple_debug_info("google_session", "We send this init thing : \n%s\n",xmlnode_to_str(session_node, &size));
 	js->google_share_sessions = g_list_prepend(js->google_share_sessions, session);
 	jabber_iq_send(iq);
 	
@@ -1268,8 +1274,10 @@ google_session_parse_iq(JabberStream *js
 
 			jabber_send_raw(js,buf1,strlen(buf1));
 			jabber_send_raw(js,buf2,strlen(buf2));
-
+		}
+		
 	} else if (!strcmp(type, "transport-accept")) {
+		purple_debug_info("google_session", "Inside transport-accept handle block..Calling it now..\n");
 		google_session_handle_transport_accept(js, session, sess, iq_id);
 	} else if (!strcmp(type, "transport-info")) {
 		google_session_handle_transport_info(js, session, sess, iq_id);
@@ -1285,12 +1293,15 @@ google_session_parse_iq(JabberStream *js
 			}
 			g_list_free(iplist);
 			purple_debug_info("google_session", "get_pub_ip : %s",purple_network_get_public_ip());
-
+			
 		}
 	}
+	else {
+		purple_debug_info("google_session", "No suitable IQ Parse Handler Found..\n");
+	}
 	
-	}
 }
+
 	
 void
 jabber_google_session_parse(JabberStream *js, const char *from,



More information about the Commits mailing list