/soc/2013/ashmew2/filetransferX: a9fac67abb8f: Added gtalk_xfer_...

Ashish Gupta ashmew2 at gmail.com
Fri Aug 23 03:21:22 EDT 2013


Changeset: a9fac67abb8f8af26f140f5f9b0e06228281a24b
Author:	 Ashish Gupta <ashmew2 at gmail.com>
Date:	 2013-08-21 20:55 +0530
Branch:	 filetransferX
URL: https://hg.pidgin.im/soc/2013/ashmew2/filetransferX/rev/a9fac67abb8f

Description:

Added gtalk_xfer_handle_accept

diffstat:

 libpurple/protocols/jabber/google/google_session.c |  40 ++++++++++++++++++---
 libpurple/protocols/jabber/si.c                    |   1 +
 2 files changed, 34 insertions(+), 7 deletions(-)

diffs (139 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
@@ -69,7 +69,7 @@ typedef struct {
 	NiceComponentState agent_state;
 	PurpleCircBuffer *buffer; /*Need to add something for HTTP_STATUS too */
 	GoogleXferChannelState channel_state;
-	guint stream_id;
+	gint stream_id;
 	gboolean candidates_gathered;
 	gboolean pair_selected;
 	GList *remote_share_candidates; /* lists of PurpleMediaCandidate OR NiceCandidates(maybe?)*/
@@ -455,7 +455,7 @@ jabber_google_relay_response_session_ini
 		session_data->share_session;
 	NiceCandidate *relay_candidate_udp, *relay_candidate_tcp;
 	NiceCandidate *relay_candidate_ssltcp;
-	guint stream_id = share_session->stream_id;
+	gint stream_id = share_session->stream_id;
 	NiceAgent *agent = share_session->share_agent;
 
 	if(session_data->share) {
@@ -465,9 +465,10 @@ jabber_google_relay_response_session_ini
 			/*if xfer is of type PURPLE_XFER_SEND, We've already requested it*/
 
 			stream_id = gtalk_xfer_init_agent(share_session);
+			agent = share_session->share_agent;
 
-			purple_debug_info("google_session", "share_agent is NULL in relay_cb!\n");
-			
+			purple_debug_info("google_session", "share_agent created with stream id : %d!\n", stream_id);
+
 			if(js->stun_ip) {
 				purple_debug_info("google_session", "Setting Agent's STUN..");
 				g_object_set(G_OBJECT (agent), "stun-server", js->stun_ip, NULL);
@@ -1303,6 +1304,15 @@ google_session_handle_transport_info(Jab
 }
 
 static void
+gtalk_xfer_handle_accept(JabberStream *js, GoogleSession *session, const char *iq_id)
+{
+	JabberIq *result = jabber_iq_new(js, JABBER_IQ_RESULT);
+	jabber_iq_set_id(result, iq_id);
+	xmlnode_set_attrib(result->node, "to", session->remote_jid);
+	jabber_iq_send(result);
+}
+
+static void
 google_session_handle_accept(JabberStream *js, GoogleSession *session, xmlnode *sess, const char *iq_id)
 {
 	xmlnode *desc_element = xmlnode_get_child(sess, "description");
@@ -2223,7 +2233,7 @@ gtalk_xfer_send(PurpleConnection *gc, co
 	  share_session->xfer = xfer;
 	  purple_xfer_request(xfer);
 	  js->google_share_sessions = g_list_prepend(js->google_share_sessions, session);
-	  gtalk_xfer_send_session_initiate(xfer);
+/*TODO: Put the XML Sending function gtalk_xfer_send_session_initiate in the gtalk_xfer_init. Don't add stuff here because otherwise the selection of file gets skipped*/
 	  /*TODO: Frame an XML Session initiate node, send it. Wait for the response*/
   }
 
@@ -2278,19 +2288,27 @@ void gtalk_xfer_send_session_initiate(Pu
 
 	session_node = xmlnode_new_child(iq->node, "session");
 
+	purple_debug_info("google_session", "session_init : Pass 1\n");
+
 	xmlnode_set_attrib(session_node, "type", "initiate");
 	xmlnode_set_attrib(session_node, "id", session->id.id);
 
 	xmlnode_set_attrib(session_node, "initiator", me);
 	xmlnode_set_namespace(session_node, NS_GOOGLE_SESSION);
 
+	purple_debug_info("google_session", "session_init : Pass 2\n");
+
 	description_node = xmlnode_new_child(session_node, "description");
 	xmlnode_set_namespace(description_node, NS_GOOGLE_SESSION_SHARE);
 
+	purple_debug_info("google_session", "session_init : Pass 3\n");
+
 	manifest_node = xmlnode_new_child(description_node, "manifest");
 	file_node = xmlnode_new_child(manifest_node, "file");
 	xmlnode_set_attrib(file_node, "size", g_strdup_printf("%llu",xfer->size));
 
+	purple_debug_info("google_session", "session_init : Pass 4\n");
+
 	name_node = xmlnode_new_child(file_node, "name");
 	xmlnode_insert_data(name_node,xfer->filename,strlen(xfer->filename));
 
@@ -2304,6 +2322,8 @@ void gtalk_xfer_send_session_initiate(Pu
 	xmlnode_set_attrib(url_preview_node, "name", "preview-path");
 	xmlnode_insert_data(url_preview_node, gtalk_get_temporary_url(), -1);
 
+	purple_debug_info("google_session", "session_init : Pass 5\n");
+
 	transport_node = xmlnode_new_child(session_node, "transport");
 	xmlnode_set_namespace(transport_node, NS_GOOGLE_TRANSPORT_P2P);
 	jabber_iq_send(iq);
@@ -2332,7 +2352,11 @@ gtalk_xfer_init(PurpleXfer *xfer)
 	GoogleAVSessionData *session_data = (GoogleAVSessionData *)session->session_data;
 	GoogleXferSessionData *share_session = session_data->share_session;
 	JabberStream *js = session->js;  
+
 	purple_debug_info("google_session", "Inside gtalk_xfer_init\n");
+
+	if(purple_xfer_get_type(xfer) == PURPLE_XFER_SEND)
+	  gtalk_xfer_send_session_initiate(xfer);
 }
 
 void gtalk_xfer_send_info(JabberStream *js, GoogleSession *session, xmlnode *sess)
@@ -2525,7 +2549,10 @@ google_session_parse_iq(JabberStream *js
 	if (!strcmp(type, "initiate")) {
 		google_session_handle_initiate(js, session, sess, iq_id);
 	} else if (!strcmp(type, "accept")) {
-		google_session_handle_accept(js, session, sess, iq_id);	
+		if(session_data->share)
+			gtalk_xfer_handle_accept(js, session, iq_id);
+		else
+			google_session_handle_accept(js, session, sess, iq_id);	
 	} else if (!strcmp(type, "info")) {
 		google_session_handle_info(js, session, sess, iq_id);
 	} else if (!strcmp(type, "reject")) {
@@ -2535,7 +2562,6 @@ google_session_parse_iq(JabberStream *js
 	} else if (!strcmp(type, "candidates")) {
 		google_session_handle_candidates(js, session, sess, iq_id);
 	} 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);
diff --git a/libpurple/protocols/jabber/si.c b/libpurple/protocols/jabber/si.c
--- a/libpurple/protocols/jabber/si.c
+++ b/libpurple/protocols/jabber/si.c
@@ -1665,6 +1665,7 @@ void jabber_si_xfer_send(PurpleConnectio
 
 	if(js->googletalk) {
 	  purple_debug_info("jabber", "Found Google Talk. Try to Send File Now..");
+	  /*TODO: Rename the gtalk_xfer_send function most probably ALSO, isn't file always NULL for googletalk?*/
 	  gtalk_xfer_send(gc, who, file);
 	  return;
 	}



More information about the Commits mailing list