cpw.malu.xmpp.google_ft: 9f7ee754: Candidate gathering now works (doesn't n...

malu at pidgin.im malu at pidgin.im
Thu Sep 9 16:46:13 EDT 2010


----------------------------------------------------------------------
Revision: 9f7ee754c4047247db50781455801df88edcd53d
Parent:   f44227c4eeb9eb070339d379cdd47d6df77c5fd6
Author:   malu at pidgin.im
Date:     09/09/10 16:41:15
Branch:   im.pidgin.cpw.malu.xmpp.google_ft
URL: http://d.pidgin.im/viewmtn/revision/info/9f7ee754c4047247db50781455801df88edcd53d

Changelog: 

Candidate gathering now works (doesn't not send candidates yet). Make it send session accept (might not be complete enough...)

Changes against parent f44227c4eeb9eb070339d379cdd47d6df77c5fd6

  patched  libpurple/protocols/jabber/google/google_share.c

-------------- next part --------------
============================================================
--- libpurple/protocols/jabber/google/google_share.c	6702481560bb2e336d5e34cb472ac30ec639ea84
+++ libpurple/protocols/jabber/google/google_share.c	9bfc581e0c7d9d027d81c1ac3bd89ce504d80c58
@@ -43,15 +43,38 @@ static void
 }
 
 static void
+google_share_data_received_cb(NiceAgent *agent, guint stream_id,
+	guint component_id, guint len, gchar *buf, gpointer user_data)
+{
+	GoogleSession *session = (GoogleSession *) user_data;
+
+}
+
+static void
 google_share_init(PurpleXfer *xfer)
 {
-	/* TODO: implement init here... */
+	GoogleSession *session = (GoogleSession *) xfer->data;
 	GoogleShareSessionData *session_data =
-		(GoogleShareSessionData *) ((GoogleSession *) xfer->data)->session_data;
+		(GoogleShareSessionData *) session->session_data;
+	gchar *me = g_strdup_printf("%s@%s/%s",
+				session->js->user->node,
+				session->js->user->domain,
+				session->js->user->resource);
+	JabberIq *iq = jabber_iq_new(session->js, JABBER_IQ_SET);
 
+	/* send accept */
+	xmlnode_set_attrib(iq->node, "to", session->remote_jid);
+	xmlnode_set_attrib(iq->node, "from", me);
+	xmlnode_insert_child(iq->node,
+		google_session_create_xmlnode(session, "accept"));
+	jabber_iq_send(iq);
+	
 	/* start agent */
 	nice_agent_gather_candidates(session_data->agent, session_data->stream_id);
 	/* set up signal */
+	nice_agent_attach_recv(session_data->agent, session_data->stream_id,
+	    NICE_COMPONENT_TYPE_RTP, g_main_context_default(),
+	    google_share_data_received_cb, session);
 }
 
 static void
@@ -62,7 +85,7 @@ google_share_init_agent(GoogleSession *s
 	GoogleShareSessionData *session_data =
 		(GoogleShareSessionData *) session->session_data;
 	NiceAgent *agent = nice_agent_new_reliable(g_main_context_default(),
-		NICE_COMPATIBILITY_GOOGLE);
+			                                           NICE_COMPATIBILITY_GOOGLE);
 	guint stream_id = nice_agent_add_stream(agent, 1);
 	const gchar *stun_ip = purple_network_get_stun_ip() ?
 		purple_network_get_stun_ip() : session->js->stun_ip;
@@ -74,6 +97,8 @@ google_share_init_agent(GoogleSession *s
 
 		/* set STUN server */
 		if (stun_ip) {
+			purple_debug_info("google-share", "setting stun-server: %s,"
+				"stun-server-port: %d on agent\n", stun_ip, stun_port);
 			g_object_set(G_OBJECT(agent), "stun-server", stun_ip,
 				"stun-server-port", stun_port, NULL);
 		}
@@ -81,13 +106,16 @@ google_share_init_agent(GoogleSession *s
 		/* set relays */
 		if (relay_ip) {
 			if (relay_udp)
-				nice_agent_set_relay_info(agent, stream_id, 0, relay_ip, relay_udp,
+				nice_agent_set_relay_info(agent, stream_id,
+				    NICE_COMPONENT_TYPE_RTP, relay_ip, relay_udp,
 					relay_username, relay_password, NICE_RELAY_TYPE_TURN_UDP);
 			if (relay_tcp)
-				nice_agent_set_relay_info(agent, stream_id, 0, relay_ip, relay_tcp,
+				nice_agent_set_relay_info(agent, stream_id,
+				    NICE_COMPONENT_TYPE_RTP, relay_ip, relay_tcp,
 			    	relay_username, relay_password, NICE_RELAY_TYPE_TURN_TCP);
 			if (relay_ssltcp)
-				nice_agent_set_relay_info(agent, stream_id, 0, relay_ip, relay_ssltcp,
+				nice_agent_set_relay_info(agent, stream_id,
+				    NICE_COMPONENT_TYPE_RTP, relay_ip, relay_ssltcp,
 			    	relay_username, relay_password, NICE_RELAY_TYPE_TURN_TLS);
 		}
 	}


More information about the Commits mailing list