/soc/2013/ashmew2/filetransferX: 2b0b47bc4ef2: Receiving Candidates

Ashish Gupta ashmew2 at gmail.com
Sat Aug 3 00:13:21 EDT 2013


Changeset: 2b0b47bc4ef2c753d6bd20ae76f395599e94c734
Author:	 Ashish Gupta <ashmew2 at gmail.com>
Date:	 2013-08-03 09:43 +0530
Branch:	 filetransferX
URL: https://hg.pidgin.im/soc/2013/ashmew2/filetransferX/rev/2b0b47bc4ef2

Description:

Receiving Candidates

diffstat:

 libpurple/protocols/jabber/google/google_session.c |  57 +++++++++++++++------
 libpurple/protocols/jabber/iq.c                    |   4 +-
 libpurple/protocols/jabber/jabber.c                |   4 +-
 3 files changed, 44 insertions(+), 21 deletions(-)

diffs (160 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
@@ -648,7 +648,7 @@ google_session_handle_initiate(JabberStr
 				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);
+		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);
 
 		if( description ) {
 			purple_debug_info("google_session", "\ndescription is not NULL");
@@ -697,34 +697,43 @@ google_session_handle_initiate(JabberStr
 				purple_debug_info("google_session", "\nTransport is NULL");
 		}
 		/**************************
-On receiving the FT XML, our response needs to be : 
+FT XML: 
 
-<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>
+(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>
 
-"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, 
+(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
 
-<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>
+(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>
 		************************************/
 		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);
-		
-		//jabber_send_raw(js,temp,strlen(temp));
-		//purple_debug_info("google_session","Sent to GTALK\n");
-		
+
+		purple_debug_info("google_session", "\nSending a file request in return\n");
+		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 */
+//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 */
+		// 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);
@@ -754,13 +763,13 @@ After sending the set_iq, Getting a feat
 		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*/
+		//This should have Jingle session-accept according to XEP 0234
 
 		
 		//		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;
 	}
@@ -858,6 +867,16 @@ google_session_handle_candidates(JabberS
 }
 
 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);
+	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 for google_session_handle_transport_accept\n");
+}
+
+static void
 google_session_handle_accept(JabberStream *js, GoogleSession *session, xmlnode *sess, const char *iq_id)
 {
 	xmlnode *desc_element = xmlnode_get_child(sess, "description");
@@ -944,6 +963,7 @@ static void
 google_session_parse_iq(JabberStream *js, GoogleSession *session, xmlnode *sess, const char *iq_id)
 {
 	const char *type = xmlnode_get_attrib(sess, "type");
+	purple_debug_info("google_session", "\nType of IQ being parsed : %s\n",type);
 
 	if (!strcmp(type, "initiate")) {
 		google_session_handle_initiate(js, session, sess, iq_id);
@@ -955,7 +975,12 @@ google_session_parse_iq(JabberStream *js
 		google_session_handle_terminate(js, session, sess);
 	} else if (!strcmp(type, "candidates")) {
 		google_session_handle_candidates(js, session, sess, iq_id);
+	} else if (!strcmp(type, "transport-accept")) {
+		google_session_handle_transport_accept(js, session, sess, iq_id);
+	} else {
+		purple_debug_info("google_session", "In google_session_parse_iq, Unhandled IQ type");
 	}
+	
 }
 
 void
diff --git a/libpurple/protocols/jabber/iq.c b/libpurple/protocols/jabber/iq.c
--- a/libpurple/protocols/jabber/iq.c
+++ b/libpurple/protocols/jabber/iq.c
@@ -480,10 +480,10 @@ void jabber_iq_init(void)
 			jabber_roster_parse);
 	jabber_iq_register_handler("query", "jabber:iq:version",
 			jabber_iq_version_parse);
-#ifdef USE_VV
+
 	jabber_iq_register_handler("session", NS_GOOGLE_SESSION,
 		jabber_google_session_parse);
-#endif
+
 	jabber_iq_register_handler("block", NS_SIMPLE_BLOCKING, jabber_blocklist_parse_push);
 	jabber_iq_register_handler("unblock", NS_SIMPLE_BLOCKING, jabber_blocklist_parse_push);
 	jabber_iq_register_handler("time", NS_ENTITY_TIME, jabber_time_parse);
diff --git a/libpurple/protocols/jabber/jabber.c b/libpurple/protocols/jabber/jabber.c
--- a/libpurple/protocols/jabber/jabber.c
+++ b/libpurple/protocols/jabber/jabber.c
@@ -753,7 +753,7 @@ jabber_login_callback_ssl(gpointer data,
 		jabber_send_raw(js, "<?xml version='1.0' ?>", -1);
 	jabber_stream_set_state(js, JABBER_STREAM_INITIALIZING);
 	purple_ssl_input_add(gsc, jabber_recv_cb_ssl, gc);
-
+	
 	/* Tell the app that we're doing encryption */
 	jabber_stream_set_state(js, JABBER_STREAM_INITIALIZING_ENCRYPTION);
 }
@@ -1974,8 +1974,6 @@ void jabber_rem_deny(PurpleConnection *g
 void jabber_add_feature(const char *namespace, JabberFeatureEnabled cb) {
 	JabberFeature *feat;
 
-	purple_debug_info("jabber", "Inside jabber-add-feature for %s",namespace);
-
 	g_return_if_fail(namespace != NULL);
 
 	feat = g_new0(JabberFeature,1);



More information about the Commits mailing list