/soc/2013/ashmew2/filetransferX: 7520fdd018d0: Resolved warnings...

Ashish Gupta ashmew2 at gmail.com
Thu Sep 12 21:40:32 EDT 2013


Changeset: 7520fdd018d03f848f21bd7c6586730e4ba897dc
Author:	 Ashish Gupta <ashmew2 at gmail.com>
Date:	 2013-09-13 07:10 +0530
Branch:	 filetransferX
URL: https://hg.pidgin.im/soc/2013/ashmew2/filetransferX/rev/7520fdd018d0

Description:

Resolved warnings. Only unused-variable warnings remaining

diffstat:

 libpurple/protocols/jabber/google/google_session.c |  287 ++++++++------------
 1 files changed, 111 insertions(+), 176 deletions(-)

diffs (truncated from 715 to 300 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
@@ -29,7 +29,6 @@
 #include "media.h"
 #include "relay.h"
 #include <nice/agent.h>
-#include <nice/pseudotcp.h>
 
 #ifdef USE_VV
 
@@ -68,8 +67,8 @@ typedef struct {
 	char *file_buf;
 	int file_buf_current_size;
 	int file_buf_sent;
-	GList *remote_share_candidates; /* lists of NiceCandidates */
-	GList *local_share_candidates;	
+	GSList *remote_share_candidates; /* lists of NiceCandidates */
+	GSList *local_share_candidates;	
 } GoogleXferSessionData; 
 /*Thanks malu!*/
 
@@ -105,7 +104,24 @@ void cb_nice_component_writable(NiceAgen
 				gpointer user_data);
 void cb_new_selected_pair(NiceAgent *agent, guint stream_id, guint component_id,
 			  gchar *lfoundation, gchar *rfoundation, gpointer user_data);
- 
+gint gtalk_xfer_init_agent(GoogleSession *session);
+void
+gtalk_xfer_handle_info(JabberStream  *js, GoogleSession *session, xmlnode *sess, const char *iq_id);
+NiceCandidate * nice_candidate_from_xml(const xmlnode *candidate, guint stream_id);
+gchar * http_read_line(gchar *buffer, guint len);
+char* gtalk_get_temporary_url(void);
+PurpleXfer *gtalk_xfer_new(PurpleConnection *gc, const char *who);
+GoogleSession *gtalk_xfer_new_session(JabberStream *js, char *who);
+char *nice_component_state_to_str(guint state);
+void gtalk_xfer_get_next_block(GoogleXferSessionData *share_session);
+void gtalk_xfer_send_info(JabberStream *js, GoogleSession *session, xmlnode *sess);
+void gtalk_xfer_accept_cb(JabberStream *js, const gchar *from, JabberIqType type, 
+		     const gchar *id, xmlnode *sess, gpointer data);
+void gtalk_xfer_channel_cb(JabberStream *js, const gchar *from, JabberIqType type, 
+		      const gchar *id, xmlnode *sess, gpointer data);
+void gtalk_xfer_transport_accept_cb(JabberStream *js, const gchar *from, JabberIqType type, 
+				    const gchar *id, xmlnode *packet, gpointer data);
+
 static gboolean
 google_session_id_equal(gconstpointer a, gconstpointer b)
 {
@@ -521,8 +537,8 @@ jabber_google_relay_response_session_ini
 					 G_CALLBACK(cb_nice_component_writable), session);
 			g_signal_connect(G_OBJECT(agent), "component-state-changed",
 					 G_CALLBACK(cb_nice_component_state_changed), session);
-			/*Add relay candidates to our candidate list?*/
-/*		            * candidate address='49.248.181.68' port='46448' username='HKmLfAkZB81f7r8x' password='' preference='0.000000' protocol='udp' type='stun' component='1' network='0' generation='0' name='private-1'
+			Add relay candidates to our candidate list?
+		            * candidate address='49.248.181.68' port='46448' username='HKmLfAkZB81f7r8x' password='' preference='0.000000' protocol='udp' type='stun' component='1' network='0' generation='0' name='private-1'
  */
 			purple_debug_info("google_session", "share_agent is NULL in relab_cb! Not adding manually the candidates. ..\n");
 /*Set up other stuff for NiceAgent TODO*/
@@ -856,8 +872,8 @@ google_session_handle_initiate(JabberStr
 	}
 	else {
 		xmlnode *description = xmlnode_get_child(sess, "description");
-		xmlnode *manifest,*file,*filename,*protocol,*http,*url_source_path,*url_preview_path,*transport;
-		guint filesize;
+		xmlnode *manifest,*file,*filename = NULL,*protocol,*http,*url_source_path,*url_preview_path,*transport;
+		guint filesize = 0;
 		JabberIq *result_iq, *set_iq,*result;
 		char *responsetxt;
 		int responsetxtlen;
@@ -941,7 +957,9 @@ FT XML:
 		
 		share_session->xfer = purple_xfer_new(purple_connection_get_account(js->gc), PURPLE_XFER_RECEIVE,
 						     session->remote_jid);
-		purple_xfer_set_filename(share_session->xfer, xmlnode_get_data_unescaped(filename));
+		if(filename)
+			purple_xfer_set_filename(share_session->xfer, xmlnode_get_data_unescaped(filename));
+
 		purple_xfer_set_size(share_session->xfer, filesize);
 		
 		purple_xfer_set_init_fnc(share_session->xfer, gtalk_xfer_init);
@@ -980,8 +998,7 @@ FT XML:
 		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 1to be different as compared to result_iq
 		  jabber_iq_send(set_iq);
 		  purple_debug_info("google_session", "\nSent set_iq\n");
@@ -1060,14 +1077,6 @@ gtalk_xfer_handle_info(JabberStream  *js
 }
 
 static void
-gtalk_get_request_cb(PurpleUtilFetchUrlData *url_data,
-	gpointer user_data, const gchar *url_text, gsize len,
-		     const gchar *error_message)
-{	
-	purple_debug_info("google_session", "inside gtalk_get_request_cb, url_text : %s", url_text);
-}
-
-static void
 google_session_handle_candidates(JabberStream  *js, GoogleSession *session, xmlnode *sess, const char *iq_id)
 {
 	JabberIq *result;
@@ -1077,10 +1086,6 @@ google_session_handle_candidates(JabberS
 	char n[4];
 	GoogleAVSessionData *session_data =
 		(GoogleAVSessionData *) session->session_data;
-	GoogleXferSessionData* share_session = 
-		session_data->share_session;
-
-	gchar *temp_ip;
 
 	cand_parent = sess;
 	if(session_data->share) {
@@ -1100,8 +1105,6 @@ google_session_handle_candidates(JabberS
 		const gchar *preference = xmlnode_get_attrib(cand, "preference");
 		guint component_id;
 		
-		temp_ip = g_strdup(address);
-		
 		if (cname && type && address && port) {
 			PurpleMediaCandidateType candidate_type;
 			guint prio = preference ? g_ascii_strtod(preference, NULL) * 1000 : 0;
@@ -1155,7 +1158,7 @@ google_session_handle_candidates(JabberS
 			}
 			else {/*If it's a share session*/
 				session_data->share_session->remote_share_candidates = 
-					g_list_append(session_data->share_session->remote_share_candidates,
+					g_slist_append(session_data->share_session->remote_share_candidates,
 						      info);
 				purple_debug_info("google_session", "Added candidate to sharelist\n");
 			}
@@ -1230,7 +1233,6 @@ nice_candidate_from_xml(const xmlnode *c
 	const gchar *type = xmlnode_get_attrib(candidate, "type");
 	const gchar *address = xmlnode_get_attrib(candidate, "address");
 	guint port = atoi(xmlnode_get_attrib(candidate, "port"));
-	const gchar *protocol = xmlnode_get_attrib(candidate, "protocol");
 	const gchar *preference = xmlnode_get_attrib(candidate, "preference");
 	
 	if (name && type && address && port != 0) {
@@ -1271,6 +1273,7 @@ gtalk_xfer_handle_candidates(JabberStrea
 	GoogleAVSessionData *session_data = (GoogleAVSessionData*)session->session_data;
 	GoogleXferSessionData *share_session = session_data->share_session;
 	JabberIq *result;
+	transport_node = NULL;
 
 	purple_debug_info("google_session", "Inside gtalk_xfer_handle_candidates..\n");
 
@@ -1279,9 +1282,9 @@ gtalk_xfer_handle_candidates(JabberStrea
 	
 	if(sess)
 		transport_node = xmlnode_get_child(sess, "transport");
-
+	
 	if(transport_node) {
-		
+	
 		for (candidate_node = xmlnode_get_child(transport_node, "candidate");
 		     candidate_node; candidate_node = xmlnode_get_next_twin(candidate_node)) {
 			NiceCandidate *cand =
@@ -1420,7 +1423,7 @@ google_session_handle_terminate(JabberSt
 		(GoogleAVSessionData *) session->session_data;
 	/*	if(session_data->share)
 	  {
-	    TODO: Add destroy_session_stuff. Make sure to remove all the callbacks as well.
+	  TODO: Add destroy_session_stuff. Make sure to remove all the callbacks as well.
 
 	    js->google_share_sessions = g_list_remove(js->google_share_sessions,session);
 	    google_session_destroy(session);
@@ -1431,70 +1434,15 @@ google_session_handle_terminate(JabberSt
 	  purple_media_end(session_data->media, NULL, NULL);
 }
 
-static void
-gtalk_port_cb(int listenfd, gpointer data)
-{
-	PurpleXfer *xfer = data;
-	if(!xfer) {
-		purple_debug_info("google_session", "gtalk_port_cb XFER IS NULL\n");
-		return;
-	}
-	if(listenfd == -1)
-		purple_debug_info("google_session", "FATAL ERROR : listenfd is -1 !\n");
-	else
-		xfer->local_port = purple_network_get_port_from_fd(listenfd);
-	
-	purple_debug_info("google_session", "Inside gtalk_port_cb()\n, Reached ENDofFunc.Port : %d\n",xfer->local_port);
-	
-}
-
-void  pseudo_tcp_opened(PseudoTcpSocket *tcp, gpointer data)
-{
-	purple_debug_info("google_session", "Inside pseudo_tcp_opened!\n");
-}
-
-void pseudo_tcp_readable(PseudoTcpSocket *tcp, gpointer data)
-{
-	purple_debug_info("google_session", "Inside pseudo_tcp_readable\n");
-}
-
-void pseudo_tcp_writable(PseudoTcpSocket *tcp, gpointer data)
-{
-	purple_debug_info("google_session", "Inside pseudo_tcp_writable\n");
-}
-
-void pseudo_tcp_closed(PseudoTcpSocket *tcp, guint32 error, gpointer data)
-{
-	purple_debug_info("google_session", "Inside pseudo_tcp_closed\n");
-}
-
-PseudoTcpWriteResult pseudo_write_packet(PseudoTcpSocket *tcp, const gchar * buffer,
-				  guint32 len, gpointer data)
-{
-	purple_debug_info("google_session", "Inside pseudo_write_packet with buffer : %s and len = %u\n", buffer, len);
-}
-
 void
 gtalk_xfer_send_candidates(GoogleSession *session)
 {
 	
 	GoogleAVSessionData *session_data = (GoogleAVSessionData *)session->session_data;
 	GoogleXferSessionData *share_session = session_data->share_session;
-	GList *candidates = share_session->local_share_candidates;
-	GList *iter;
-	PseudoTcpCallbacks *tcp_cb = g_new0(PseudoTcpCallbacks, 1);
-	PseudoTcpSocket *tcp_socket;
-
-	/*Set up the callback struct */
-	tcp_cb->PseudoTcpOpened = pseudo_tcp_opened;
-	tcp_cb->PseudoTcpReadable = pseudo_tcp_readable;
-	tcp_cb->PseudoTcpWritable = pseudo_tcp_writable;
-	tcp_cb->PseudoTcpClosed = pseudo_tcp_closed;
-	tcp_cb->WritePacket = pseudo_write_packet;
-	/*End of callback assignment*/
-
-	tcp_socket = pseudo_tcp_socket_new(0, tcp_cb);
-	
+	GSList *candidates = share_session->local_share_candidates;
+	GSList *iter;
+
 	/*Is component ID necessary? This is a share session TODO*/
 /*				component_id = purple_media_candidate_get_component_id(
 				transport);
@@ -1509,21 +1457,11 @@ gtalk_xfer_send_candidates(GoogleSession
 	else
 		purple_debug_info("google_session","Getting local credentials SUCCESSFUL..\n");
 */	
-/*TODO: Try to add a socket to the candidate */
-	purple_debug_info("google_session", "Trying to connect the socket");
-
-	if(tcp_socket)
-		purple_debug_info("google_session", "Socket is VALID and not null\n");
-
-/*	if(pseudo_tcp_socket_connect(tcp_socket))
-		purple_debug_info("google_session", "Socket Connect returned TRUE!!\n");
-	else
-		purple_debug_info("google_session", "Socket Connect returned fALSE :'( \n");
-*/
+
 	for(iter = candidates; iter; iter = iter->next) {
 		JabberIq *iq;
 		gchar *ip = g_malloc(NICE_ADDRESS_STRING_LEN + 1);
-		gchar *pref, *port;
+		gchar *port;
 		gchar *username, *password;
 		xmlnode *sess;
 		xmlnode *candidate, *transport;
@@ -1531,7 +1469,6 @@ gtalk_xfer_send_candidates(GoogleSession
 		NiceCandidateType type;
 
 		/*TODO: ADd TURN information for RELAY candidates most probably*/
-		nice_candid->sockptr = tcp_socket;
 
 		iq = jabber_iq_new(session->js, JABBER_IQ_SET);
 		sess = google_session_create_xmlnode(session, "transport-info");
@@ -1548,7 +1485,6 @@ gtalk_xfer_send_candidates(GoogleSession
 		port = g_strdup_printf("%u",nice_address_get_port(&nice_candid->addr));
 
 		purple_debug_info("google_session", "IP and port : %s:%s\n",ip,port);
-		pref = g_strdup_printf("%u",nice_candid->priority);
 
 		type = nice_candid->type;
 //		purple_debug_info("google_session", "Setting attributes now.. : \n");
@@ -1658,7 +1594,7 @@ cb_candidate_gathering_done(NiceAgent *a
 	GoogleSession *session = (GoogleSession *)user_data;
 	GoogleAVSessionData *session_data = session->session_data;
 	GoogleXferSessionData *share_session = session_data->share_session;
-	GList *local_candidates = nice_agent_get_local_candidates(agent, stream_id, 1);
+	GSList *local_candidates = nice_agent_get_local_candidates(agent, stream_id, 1);
 	
 	purple_debug_info("google_session", "candidate gathering done!\n");
 	share_session->candidates_gathered = TRUE;
@@ -1679,8 +1615,6 @@ cb_candidate_gathering_done(NiceAgent *a
 	while (local_candidates) {
 		NiceCandidate *candidate = (NiceCandidate *) local_candidates->data;
 		JabberIq *iq = jabber_iq_new(session->js, JABBER_IQ_SET);
-		gchar address[NICE_ADDRESS_STRING_LEN];



More information about the Commits mailing list