/soc/2013/ashmew2/filetransferX: 23331ca7cbc3: Added gtalk_xfer_...

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


Changeset: 23331ca7cbc32425074cce2176e2d38d4c3a070c
Author:	 Ashish Gupta <ashmew2 at gmail.com>
Date:	 2013-08-07 18:20 +0530
Branch:	 filetransferX
URL: https://hg.pidgin.im/soc/2013/ashmew2/filetransferX/rev/23331ca7cbc3

Description:

Added gtalk_xfer_send_transport_accept function

diffstat:

 libpurple/protocols/jabber/google/google_session.c |  51 +++++++++++++++++++--
 libpurple/protocols/jabber/google/google_session.h |   2 +-
 2 files changed, 46 insertions(+), 7 deletions(-)

diffs (117 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
@@ -725,6 +725,7 @@ 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));
@@ -758,13 +759,16 @@ FT XML:
 		  jabber_iq_send(set_iq);
 		  purple_debug_info("google_session", "\nSent set_iq\n");
 		*/
-		
+		/*TODO : Fix name for ResponseIq */
 		  ResponseIq = jabber_iq_new(js,JABBER_IQ_RESULT);
 		  xmlnode_set_attrib(ResponseIq->node, "to", session->remote_jid);
 		  jabber_iq_set_id(ResponseIq, iq_id);
 		  purple_debug_info("google_session", "handle_initiate() : ResponseIq->id : %s\n",ResponseIq->id);
 		  jabber_iq_send(ResponseIq);
+
+		  gtalk_xfer_send_transport_accept(js, session, sess);
 		  /*
+
 		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"));
@@ -1114,7 +1118,7 @@ gtalk_get_temporary_url(void)
 	return temporary_url;
 }
 
-void gtalk_xfer_session_initiate(PurpleXfer *xfer)
+void gtalk_xfer_send_initiate(PurpleXfer *xfer)
 {
 	GoogleSession *session = xfer->data;
 	JabberStream *js = session->js;
@@ -1208,7 +1212,7 @@ gtalk_xfer_init(PurpleXfer *xfer)
 	purple_debug_info("google_session", "Inside gtalk_xfer_init() \n");
 	purple_debug_info("google_session", "We have a file now. Details of Xfer :\nwho : %s\nfilename:%s\nlocal_filename:%s\nsize:%d\nlocal_port : %d\nremote_port:%d\nremote_ip:%s\nBytes Sent:%d\nBytes Remaining:%d\n",xfer->who,xfer->filename,xfer->local_filename,xfer->size,xfer->local_port,xfer->remote_port,xfer->remote_ip,xfer->bytes_sent,xfer->bytes_remaining);
 
-	gtalk_xfer_session_initiate(xfer);
+	gtalk_xfer_send_initiate(xfer);
 /**TODO: IP.PORT etc should all be in the GoogleSession thing? I guess so.*/
 /*TODO: xfer->local_port set in the gtalk_port_cb() */
 /*TODO: xfer->remote_ip and xfer->remote_port will be set when we get a list of candidates*/
@@ -1229,13 +1233,48 @@ gtalk_xfer_init(PurpleXfer *xfer)
 	
 }
 
+void
+gtalk_xfer_send_transport_accept(JabberStream *js, GoogleSession *session, xmlnode *sess)
+{
+	JabberIq *iq;
+	xmlnode *session_node, *transport_node;
+/*TODO:  REMOVE ME gchar *me = g_strdup_printf("%s@%s/%s",
+				    js->user->node,
+				    js->user->domain,
+				    js->user->resource);
+*/	
+	purple_debug_info("google_session", "Inside google_xfer_send_transport_accept()\n");
+	iq = jabber_iq_new(js, JABBER_IQ_SET);
+	xmlnode_set_attrib(iq->node, "to", session->remote_jid);
+	
+	session_node = xmlnode_new_child(iq->node, "session");
+	transport_node = xmlnode_new_child(session_node, "transport");
+	
+	xmlnode_set_attrib(session_node, "type", "transport-accept");
+	xmlnode_set_attrib(session_node, "id", xmlnode_get_attrib(sess, "id"));
+	xmlnode_set_attrib(session_node, "initiator", session->remote_jid);
+	xmlnode_set_namespace(session_node, NS_GOOGLE_SESSION);
+
+	xmlnode_set_namespace(transport_node, NS_GOOGLE_TRANSPORT_P2P);
+
+	jabber_iq_send(iq);
+
+/*TODO: CLEAN UP: WHAT WESEND : 
+<iq type='set' id='purple154daa44' to='ashmew2 at gmail.com/Talk.v104168E5E46'>
+<session xmlns='http://www.google.com/session' type='transport-accept' id='3162060852' initiator='doondoon1234 at gmail.com/E4494551'><transport xmlns='http://www.google.com/transport/p2p'/></session></iq>
+
+WHAT WE GET : 
+  <iq to="doondoon1234 at gmail.com/1D31D21B" type="set" id="68" from="ashmew2 at gmail.com/Talk.v104168E5E46">
+<session type="transport-accept" id="3162060852" initiator="doondoon1234 at gmail.com/1D31D21B" xmlns="http://www.google.com/session"><transport xmlns="http://www.google.com/transport/p2p"/></session></iq>
+ */
+}
 
 static void 
-google_session_initiate_file_transfer(JabberStream *js, GoogleSession *session)
+google_xfer_send(JabberStream *js, GoogleSession *session)
 {
 	PurpleXfer *xfer = purple_xfer_new(purple_connection_get_account(js->gc), PURPLE_XFER_SEND, session->remote_jid);
 	xfer->data = session;
-	purple_debug_info("google_session", "inside google_session_initiate_file_transfer\n");
+	purple_debug_info("google_session", "inside google_xfer_send\n");
 
 	purple_xfer_set_init_fnc( xfer, gtalk_xfer_init );
 	purple_xfer_set_start_fnc(xfer, gtalk_xfer_start);
@@ -1281,7 +1320,7 @@ google_session_parse_iq(JabberStream *js
 		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);
-//		google_session_initiate_file_transfer(js,session);
+//		google_xfer_send(js,session);
 		purple_debug_info("google_session", "Back in parse_iq\n");
 		if(js->stun_ip)
 			purple_debug_info("google_session", "We might be able to get a stun public address now.\n");
diff --git a/libpurple/protocols/jabber/google/google_session.h b/libpurple/protocols/jabber/google/google_session.h
--- a/libpurple/protocols/jabber/google/google_session.h
+++ b/libpurple/protocols/jabber/google/google_session.h
@@ -56,5 +56,5 @@ void jabber_google_session_parse(JabberS
 void gtalk_xfer_send(PurpleConnection *gc, const char *who, const char*file);
 void gtalk_xfer_init(PurpleXfer *xfer);
 void gtalk_xfer_start(PurpleXfer *xfer);
-
+void gtalk_xfer_send_transport_accept(JabberStream *js, GoogleSession *session, xmlnode *sess);
 #endif /* PURPLE_JABBER_GOOGLE_SESSION_H_ */



More information about the Commits mailing list