/soc/2013/ashmew2/filetransferY: 8a0c0875e834: Changed Hierarchy...

Ashish Gupta ashmew2 at gmail.com
Wed Jan 1 14:03:12 EST 2014


Changeset: 8a0c0875e8343dd2d7e634ebf85a219decd246ed
Author:	 Ashish Gupta <ashmew2 at gmail.com>
Date:	 2014-01-02 00:02 +0530
Branch:	 filetransferX
URL: https://hg.pidgin.im/soc/2013/ashmew2/filetransferY/rev/8a0c0875e834

Description:

Changed Hierarchy from Sess2AV2Xfer to Sess2Xfer

diffstat:

 libpurple/protocols/jabber/google/google_session.c |  398 ++++++++++++--------
 libpurple/protocols/jabber/google/google_session.h |    3 +
 2 files changed, 233 insertions(+), 168 deletions(-)

diffs (truncated from 799 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
@@ -72,8 +72,6 @@ typedef struct {
 typedef struct {
 	PurpleMedia *media;
 	gboolean video;
-	gboolean share;                 /*for indicating whether it's a fileXfer session*/
-	GoogleXferSessionData* share_session;
 	GList *remote_audio_candidates; /* list of PurpleMediaCandidate */
 	GList *remote_video_candidates; /* list of PurpleMediaCandidate */
 	gboolean added_streams;		/* this indicates if the streams have been
@@ -115,18 +113,14 @@ google_session_id_equal(gconstpointer a,
 	return !strcmp(c->id, d->id) && !strcmp(c->initiator, d->initiator);
 }
 
-static void
+ void
 google_session_destroy(GoogleSession *session)
 {
-	GoogleAVSessionData *session_data =
-		(GoogleAVSessionData *) session->session_data;
+	JabberStream *js = session->js;	
+	session->state = TERMINATED;			
 	
-	JabberStream *js = session->js;
-
-	session->state = TERMINATED;			
-
-	if(session_data->share) {
-		GoogleXferSessionData *share_session = session_data->share_session;
+	if(session->share) {
+		GoogleXferSessionData *share_session = session->session_data;
 		GSList *temp = NULL;
 		
 		purple_debug_info("google_session", "Destroying The current Google Session..\n");
@@ -190,30 +184,27 @@ google_session_destroy(GoogleSession *se
 			     g_slist_delete_link(temp, temp)) {
 			nice_candidate_free(temp->data);
 		}
-
-		g_free(share_session);		
+		
 		g_free(temp);		
 	}
-	else
-		purple_debug_info("google_session", "share_session is not share!");
+	else { /*If it is an AV session*/
+		GoogleAVSessionData *session_data = session->session_data;
+		if (session_data->remote_audio_candidates)
+			purple_media_candidate_list_free(session_data->remote_audio_candidates);
+		
+		if (session_data->remote_video_candidates)
+			purple_media_candidate_list_free(session_data->remote_video_candidates);
+	}
 	
-	purple_debug_info("google_session", "Phase -1\n");
-
 	js->google_share_sessions = g_list_remove(js->google_share_sessions,session);
 
 	g_free(session->id.id);
 	g_free(session->id.initiator);
 	g_free(session->remote_jid);
-		      
-	if (session_data->remote_audio_candidates)
-		purple_media_candidate_list_free(session_data->remote_audio_candidates);
-
-	if (session_data->remote_video_candidates)
-		purple_media_candidate_list_free(session_data->remote_video_candidates);
 
 	if (session->description)
 		xmlnode_free(session->description);
-
+	
 	g_free(session->session_data);
 	g_free(session);
 	purple_debug_info("google_session", "Phase END of function\n");
@@ -308,7 +299,6 @@ google_session_send_candidates(PurpleMed
 		xmlnode_set_attrib(candidate, "generation", "0");
 		xmlnode_set_attrib(candidate, "network", "0");
 		xmlnode_insert_child(sess, candidate);
-		purple_debug_info("google_session", "Candidate's IP and PORT : %s:%s",ip,port);
 		g_free(ip);
 		g_free(port);
 		g_free(username);
@@ -326,22 +316,23 @@ google_session_ready(GoogleSession *sess
 		((GoogleAVSessionData *)session->session_data)->media;
 	gboolean video =
 		((GoogleAVSessionData *)session->session_data)->video;
-	gboolean share = 
-		((GoogleAVSessionData *)session->session_data)->share;		
+
+	gboolean share = session->share;		
 
 	if (purple_media_codecs_ready(media, NULL) &&
-			purple_media_candidates_prepared(media, NULL, NULL)) {
+	    purple_media_candidates_prepared(media, NULL, NULL)) {
+
 		gchar *me = g_strdup_printf("%s@%s/%s",
-				session->js->user->node,
-				session->js->user->domain,
-				session->js->user->resource);
+					    session->js->user->node,
+					    session->js->user->domain,
+					    session->js->user->resource);
 		JabberIq *iq;
 		xmlnode *sess, *desc, *payload;
 		GList *codecs, *iter;
 		gboolean is_initiator = !strcmp(session->id.initiator, me);
-
+		
 		if (!is_initiator &&
-				!purple_media_accepted(media, NULL, NULL)) {
+		    !purple_media_accepted(media, NULL, NULL)) {
 			g_free(me);
 			return;
 		}
@@ -368,10 +359,8 @@ google_session_ready(GoogleSession *sess
 		xmlnode_insert_child(iq->node, sess);
 		desc = xmlnode_new_child(sess, "description");
 
-		if (share) {
-			xmlnode_set_namespace(desc, NS_GOOGLE_SESSION_SHARE);
-			purple_debug_info("google_session", "Set namespace to NS_GOOGLE_SESSION_SHARE");
-		}
+		if (share)
+			xmlnode_set_namespace(desc, NS_GOOGLE_SESSION_SHARE);				       
 		else if (video)
 			xmlnode_set_namespace(desc, NS_GOOGLE_SESSION_VIDEO);
 		else
@@ -558,16 +547,14 @@ gint gtalk_xfer_init_agent(GoogleSession
 {
 	gint stream_id;
 	NiceAgent *agent;
-	GoogleAVSessionData *session_data = 
-		(GoogleAVSessionData *)session->session_data;
-	GoogleXferSessionData *share_session = session_data->share_session;
-		
+	GoogleXferSessionData *share_session = (GoogleXferSessionData *)session->session_data;
+	
 	purple_debug_info("google_session", "Inside gtalk_xfer_init_agent\n");
 	if(!share_session)
-		return -1;
-
+	  return -1;
+	
 	if(share_session->share_agent)
-		return share_session->stream_id;
+	  return share_session->stream_id;
 
 	agent = share_session->share_agent;
 	
@@ -600,19 +587,19 @@ jabber_google_relay_response_session_ini
     const gchar *relay_ip, guint relay_udp, guint relay_tcp, guint relay_ssltcp,
     const gchar *relay_username, const gchar *relay_password)
 {
-	GParameter *params;
-	guint num_params;
 	JabberStream *js = session->js;
-	GoogleAVSessionData *session_data =
-		(GoogleAVSessionData *) session->session_data;
-	GoogleXferSessionData *share_session =
-		session_data->share_session;
-	gint stream_id = share_session->stream_id;
-	NiceAgent *agent = share_session->share_agent;
 	
 	purple_debug_info("google_session", "Inside jabber_google_relay_response_initiate_cb!\n");
-		
-	if(session_data->share) {
+
+	if(session->share) {		
+		GoogleXferSessionData *share_session =
+			(GoogleXferSessionData *)session->session_data;		
+		gint stream_id = share_session->stream_id;
+		NiceAgent *agent = share_session->share_agent;
+
+
+		purple_debug_info("Google_session", "Here\n\n\n\n");
+
 		if(!agent) {
 /*			if(purple_xfer_get_type(share_session->xfer) == PURPLE_XFER_RECEIVE)
 				purple_xfer_request(share_session->xfer);
@@ -652,43 +639,51 @@ jabber_google_relay_response_session_ini
 		}
 		return;
 	}
-	/*The procedure for Share Session ends here. What follows is the process needed for Media sessions*/
-
-	session_data->media = purple_media_manager_create_media(
+	else {
+		
+		GParameter *params;
+		guint num_params;
+		
+		GoogleAVSessionData *session_data =
+			(GoogleAVSessionData *) session->session_data;
+		
+		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);
+		
+		purple_media_set_prpl_data(session_data->media, session);
+		
+		g_signal_connect_swapped(G_OBJECT(session_data->media),
+					 "candidates-prepared",
+					 G_CALLBACK(google_session_ready), session);
+		g_signal_connect_swapped(G_OBJECT(session_data->media), "codecs-changed",
+					 G_CALLBACK(google_session_ready), session);
+		g_signal_connect(G_OBJECT(session_data->media), "state-changed",
+				 G_CALLBACK(google_session_state_changed_cb), session);
+		g_signal_connect(G_OBJECT(session_data->media), "stream-info",
+				 G_CALLBACK(google_session_stream_info_cb), session);
 
-	g_signal_connect_swapped(G_OBJECT(session_data->media),
-			"candidates-prepared",
-			G_CALLBACK(google_session_ready), session);
-	g_signal_connect_swapped(G_OBJECT(session_data->media), "codecs-changed",
-			G_CALLBACK(google_session_ready), session);
-	g_signal_connect(G_OBJECT(session_data->media), "state-changed",
-			G_CALLBACK(google_session_state_changed_cb), session);
-	g_signal_connect(G_OBJECT(session_data->media), "stream-info",
-			G_CALLBACK(google_session_stream_info_cb), session);
-
-	params =
-		jabber_google_session_get_params(js, relay_ip, relay_udp, relay_tcp,
-			relay_ssltcp, relay_username, relay_password, &num_params);
-
-	if (purple_media_add_stream(session_data->media, "google-voice",
-			session->remote_jid, PURPLE_MEDIA_AUDIO,
-			TRUE, "nice", num_params, params) == FALSE ||
-			(session_data->video && purple_media_add_stream(
-			session_data->media, "google-video",
-			session->remote_jid, PURPLE_MEDIA_VIDEO,
-			TRUE, "nice", num_params, params) == FALSE)) {
-		purple_media_error(session_data->media, "Error adding stream.");
-		purple_media_end(session_data->media, NULL, NULL);
-	} else {
-		session_data->added_streams = TRUE;
+		params = 
+			jabber_google_session_get_params(js, relay_ip, relay_udp, 
+							 relay_tcp, relay_ssltcp, 
+							 relay_username, relay_password, 
+							 &num_params);
+		
+		if (purple_media_add_stream(session_data->media, "google-voice",
+					    session->remote_jid, PURPLE_MEDIA_AUDIO,
+					    TRUE, "nice", num_params, params) == FALSE ||
+		    (session_data->video && purple_media_add_stream(
+			    session_data->media, "google-video",
+			    session->remote_jid, PURPLE_MEDIA_VIDEO,
+			    TRUE, "nice", num_params, params) == FALSE)) {
+			purple_media_error(session_data->media, "Error adding stream.");
+			purple_media_end(session_data->media, NULL, NULL);
+		} else 
+			session_data->added_streams = TRUE;		
+		
+		g_free(params);
 	}
-
-	g_free(params);
 }
 
 gboolean
@@ -728,7 +723,8 @@ jabber_google_session_initiate(JabberStr
 	session->js = js;
 	session->remote_jid = jid;
 	session_data = g_new0(GoogleAVSessionData, 1);
-	((GoogleAVSessionData *)session_data)->share_session = g_new0(GoogleXferSessionData, 1);
+	/*what to do? TODO*/
+/*	((GoogleAVSessionData *)session_data)->share_session = g_new0(GoogleXferSessionData, 1);*/
 	
 	session->session_data = session_data;
 
@@ -746,7 +742,7 @@ jabber_google_session_initiate(JabberStr
 	}
 
 	/* we don't actually know yet wether it succeeded... maybe this is very
-	 wrong... */
+	   wrong... */
 	return TRUE;
 }
 
@@ -863,10 +859,7 @@ static gboolean
 google_session_handle_initiate(JabberStream *js, GoogleSession *session, xmlnode *sess, const char *iq_id)
 {
 	const gchar *xmlns;
-	GoogleAVSessionData *session_data =
-		(GoogleAVSessionData *) session->session_data;
-	GoogleXferSessionData *share_session = 
-		session_data->share_session;
+	gboolean video;
 
 	purple_debug_info("google_session", "Inside google_session_handle_initiate");
 
@@ -877,21 +870,26 @@ google_session_handle_initiate(JabberStr
 	
 	session->description = xmlnode_copy(xmlnode_get_child(sess, "description"));



More information about the Commits mailing list