/soc/2013/ashmew2/filetransferX: eed8d3a55c26: Adding relay hand...

Ashish Gupta ashmew2 at gmail.com
Thu Aug 15 17:45:09 EDT 2013


Changeset: eed8d3a55c26ec0e36c66620f6c1240e2ea5949f
Author:	 Ashish Gupta <ashmew2 at gmail.com>
Date:	 2013-08-16 01:27 +0530
Branch:	 filetransferX
URL: https://hg.pidgin.im/soc/2013/ashmew2/filetransferX/rev/eed8d3a55c26

Description:

Adding relay handling

diffstat:

 libpurple/protocols/jabber/google/google_session.c |  61 ++++++++++++++-------
 1 files changed, 40 insertions(+), 21 deletions(-)

diffs (124 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
@@ -32,13 +32,15 @@
 #ifdef USE_VV
 
 typedef struct {
-	gchar *filename;
+	gchar *filename;                            /*File Details*/
 	guint64 filesize;
 	gchar *preview_url;
 	gchar *source_url;
 	/*Needs to have a manifest Entry for Folder Sharing*/
-	GList *remote_share_candidates; /* list of PurpleMediaCandidate */
-	GList *local_share_candidates;
+	NiceAgent *share_agent; /*TODO : Assess the usefulness of share_agent and stream_id*/
+	guint stream_id;
+	GList *remote_share_candidates; /* lists of PurpleMediaCandidate OR NiceCandidates(maybe?)*/
+	GList *local_share_candidates;  
 } GoogleXferSessionData; 
 
 typedef struct {
@@ -381,7 +383,6 @@ jabber_google_session_get_params(JabberS
 	return new_params;
 }
 
-
 static void
 jabber_google_relay_response_session_initiate_cb(GoogleSession *session,
     const gchar *relay_ip, guint relay_udp, guint relay_tcp, guint relay_ssltcp,
@@ -392,12 +393,31 @@ jabber_google_relay_response_session_ini
 	JabberStream *js = session->js;
 	GoogleAVSessionData *session_data =
 		(GoogleAVSessionData *) session->session_data;
+	GoogleXferSessionData *share_session =
+		session_data->share_session;
+
+	if(session_data->share) {
+		/*TODO: Relocate? Define a new function? Only time will tell :P
+		  gtalk_relay_response_session_initiate_cb(session, relay_ip, relay_udp,
+				 relay_tcp, relay_ssltcp, relay_username, relay_password);
+		return;
+		*/
+		GoogleXferSessionData *share_session = session_data->share_session;
+		NiceAgent *agent = nice_agent_new_reliable (NULL, NICE_COMPATIBILITY_RFC5245);
+		guint stream_id;
+		purple_debug_info("google_session", "Trying to Set Relay IP : %s\n", relay_ip);
+		if(nice_agent_set_relay_info (agent, share_session->stream_id, 0, relay_ip, 80, relay_username,
+					      relay_password, NICE_RELAY_TYPE_TURN_UDP)) 
+			purple_debug_info("google_session","Setting Relay on Niceagent Failed..\n");
+		else
+			purple_debug_info("google_session","Setting Relay on Niceagent Failed..\n");
+	}
 	
 	session_data->media = purple_media_manager_create_media(
 			purple_media_manager_get(),
 			purple_connection_get_account(js->gc),
 			"fsrtpconference", session->remote_jid, TRUE);
-
+	
 	purple_media_set_prpl_data(session_data->media, session);
 
 	g_signal_connect_swapped(G_OBJECT(session_data->media),
@@ -768,29 +788,28 @@ FT XML:
 		jabber_iq_send(set_iq);
 		
 		/*
-		  jabber_iq_set_id(result_iq, iq_id); //Needs to be different as compared to result_iq
+		  jabber_iq_set_id(result_iq, iq_id); //Needs 1to be different as compared to result_iq
 		  jabber_iq_send(set_iq);
 		  purple_debug_info("google_session", "\nSent set_iq\n");
 		*/
 		/*TODO : Fix name for ResponseIq */
-
-/*		if (js->google_relay_host && js->google_relay_token) {
+		
+		if (js->google_relay_host && js->google_relay_token) {
 			jabber_google_do_relay_request(js, session,
 						       jabber_google_relay_response_session_initiate_cb);
 		} else {
 			jabber_google_relay_response_session_initiate_cb(session, NULL, 0, 0, 0,
 									 NULL, NULL);
-	}
-
-*/
-		  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);
-		  /*
+		}
+		
+		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);
@@ -1226,7 +1245,7 @@ gtalk_xfer_send_candidates(GoogleSession
 	else
 		purple_debug_info("google_session", "Gather Candidates returned TRUE\n");
 	g_main_loop_run (gloop);
-	g_main_loop_unref(gloop);
+	g_main_loop_unref(gloop); /*TODO: Check if gloop is causing a CRASH when Destroying pidgin instance*/
 	g_object_unref(agent);
 
 	return;
@@ -1475,7 +1494,7 @@ gtalk_xfer_init(PurpleXfer *xfer)
 	GoogleAVSessionData *session_data = (GoogleAVSessionData *)(session->session_data);
 	GList *iter;
 	PurpleNetworkListenData *portdata = purple_network_listen_range_family
-		(27015, 64000, AF_INET, SOCK_STREAM, gtalk_port_cb, xfer);
+	  (27015, 64000, AF_INET, SOCK_STREAM, gtalk_port_cb, 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);



More information about the Commits mailing list