/soc/2013/ashmew2/filetransferX: a1f07e485a77: Some Progress

Ashish Gupta ashmew2 at gmail.com
Thu Aug 1 18:20:08 EDT 2013


Changeset: a1f07e485a771fd774f65da4713d39aba28a9f77
Author:	 Ashish Gupta <ashmew2 at gmail.com>
Date:	 2013-08-02 03:49 +0530
Branch:	 filetransferX
URL: https://hg.pidgin.im/soc/2013/ashmew2/filetransferX/rev/a1f07e485a77

Description:

Some Progress

diffstat:

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

diffs (119 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
@@ -639,8 +639,16 @@ google_session_handle_initiate(JabberStr
 		xmlnode *manifest,*file,*filename,*protocol,*http,*url_source_path,*url_preview_path,*transport;
 		char *filesize;
 		GoogleXferSessionData *IncomingXfer = g_new0(GoogleXferSessionData, 1);
-		JabberIq *ResponseIq;
-		gchar *me = g_strdup_printf("%s@%s/%s",session->js->user->node,session->js->user->domain,session->js->user->resource);
+		JabberIq *result_iq, *set_iq;
+		char *responsetxt;
+		int responsetxtlen;
+		xmlnode *tmp;
+		gchar *me = g_strdup_printf("%s@%s/%s",
+				session->js->user->node,
+				session->js->user->domain,
+				session->js->user->resource);
+
+		char *temp=g_strdup_printf("<iq to=\"ashmew2 at gmail.com/Talk.v10456154B74\" type=\"set\" id=\"%s\" from=\"%s\"><session type=\"initiate\" id=\"3800728781\" initiator=\"ashmew2 at gmail.com/Talk.v10456154B74\" 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>",iq_id, me);
 
 		if( description ) {
 			purple_debug_info("google_session", "\ndescription is not NULL");
@@ -688,34 +696,72 @@ google_session_handle_initiate(JabberStr
 			else
 				purple_debug_info("google_session", "\nTransport is NULL");
 		}
+		/**************************
+On receiving the FT XML, our response needs to be : 
+
+<iq to="doondoon1234 at gmail.com/AEE542E6" id="54" type="result" from="ashmew2 at gmail.com/Talk.v10456154B74"/>
+<iq to="doondoon1234 at gmail.com/AEE542E6" type="set" id="56" from="ashmew2 at gmail.com/Talk.v10456154B74">
+<session type="transport-accept" id="3800728781" initiator="ashmew2 at gmail.com/Talk.v10456154B74" xmlns="http://www.google.com/session"><transport xmlns="http://www.google.com/transport/p2p"/></session></iq>
+
+"id" attributes for both IQs are different. The second one should probably have the session node attached to it.
+After sending the set_iq, Getting a feature not implemented error, 
+
+<iq type="error" id="26" to="doondoon1234 at gmail.com/05651D75" from="ashmew2 at gmail.com/Talk.v1046D0CA26C"><session type="transport-accept" id="943620053" initiator="doondoon1234 at gmail.com/05651D75" xmlns="http://www.google.com/session/share"><transport xmlns="http://www.google.com/transport/p2p"/></session><error code="501" type="cancel"><feature-not-implemented xmlns="urn:ietf:params:xml:ns:xmpp-stanzas"/></error></iq>
+
+		************************************/
+		purple_debug_info("google_session", "We have received a file request.\n");
+		purple_debug_info("google_session", "\nme = %s. Length : %d\n",me, strlen(temp));
+		purple_debug_info("google_session", "\nParameter : iq_id = %s.\n", iq_id);
 		
-		/************Call to AcceptGoogleXfer() or something.***************
-		if( 1 ) {
-			char *own_jid = g_strdup_printf("%s@%s/%s", js->user->node, js->user->domain, js->user->resource);
-			char *sid = jabber_get_next_id(js);
-			JingleSession *XferSession = jingle_session_create(js,sid, own_jid, session->remote_jid, FALSE);
+		//jabber_send_raw(js,temp,strlen(temp));
+		//purple_debug_info("google_session","Sent to GTALK\n");
+		
+		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 */
 
-			PurpleXfer *xfer;
-			gchar *buffer;
+		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 to be different as compared to result_iq
+		  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_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"));
+		jabber_iq_send(ResponseIq2);
+		/*This should have Jingle session-accept according to XEP 0234*/
 
-			purple_debug_info("google_session", "Created Jingle Session.\n");
-			jingle_session_init(XferSession);
-
-			purple_debug_info("google_session", "init() done on XferSession.\n");
-		}
-		/****************************************************/
-		purple_debug_info("google_session", "We have received a file request.\n");
-		purple_debug_info("google_session", "<iq id : %s> and value of iq_id parameter : %s\n",xmlnode_get_attrib(sess,"id"),iq_id);
-
-		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"));
-		xmlnode_set_attrib(ResponseIq->node, "from", me);
-		purple_debug_info("google_session", "ResponseIq->id : %s\n",ResponseIq->id);
-		jabber_iq_send(ResponseIq);
-
-		purple_debug_info("google_session", "Sent ResponseIq.\n");
+		
+		//		purple_debug_info("google_session",x "Sent Both ResponseIq. Now Trying to send rest of the XML stuff.");
+		//		responsetxt = xmlnode_to_str(sess,&responsetxtlen);
+		//purple_debug_info("google_session", "\nresponsetxt : %s with len : %d\n\n",responsetxt,responsetxtlen);
+		
+				
 		return TRUE;
 	}
 	return TRUE;	



More information about the Commits mailing list