changeset 30444:797c03de8fa9

merge of '9b4b74ad94eb77ef347f7575823e65103cae1f85' and 'e8b7360d6e741d9d1a9c9f646663892d3c77546c'
author Marcus Lundblad <ml@update.uu.se>
date Wed, 25 Aug 2010 19:13:24 +0000
parents cae0dd35d16a (current diff) f228c946a5bc (diff)
children 4c050b6e9bd1
files ChangeLog libpurple/media/backend-fs2.c
diffstat 4 files changed, 56 insertions(+), 20 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog	Tue Aug 24 05:07:48 2010 +0000
+++ b/ChangeLog	Wed Aug 25 19:13:24 2010 +0000
@@ -3,6 +3,11 @@
 version 2.7.4 (MM/DD/YYYY):
 	General:
 	* Fix search path for Tk when compiling on Debian Squeeze. (#12465)
+	
+	libpurple:
+	* Added ability to use TURN relaying via TCP and TLS (including preference
+	  settings for these).
+
 
 	Yahoo/Yahoo JAPAN:
 	* Stop doing unnecessary lookups of certain alias information.  This
--- a/libpurple/media/backend-fs2.c	Tue Aug 24 05:07:48 2010 +0000
+++ b/libpurple/media/backend-fs2.c	Wed Aug 25 19:13:24 2010 +0000
@@ -1561,6 +1561,30 @@
 			(GSourceFunc)src_pad_added_cb_cb, stream);
 }
 
+static GValueArray *
+append_relay_info(GValueArray *relay_info, const gchar *ip, gint port,
+	const gchar *username, const gchar *password, const gchar *type)
+{
+	GValue value;
+	GstStructure *turn_setup = gst_structure_new("relay-info",
+				"ip", G_TYPE_STRING, ip, 
+				"port", G_TYPE_UINT, port,
+				"username", G_TYPE_STRING, username,
+				"password", G_TYPE_STRING, password,
+	            "relay-type", G_TYPE_STRING, type,
+				NULL);
+
+	if (turn_setup) {
+		memset(&value, 0, sizeof(GValue));
+		g_value_init(&value, GST_TYPE_STRUCTURE);
+		gst_value_set_structure(&value, turn_setup);
+		relay_info = g_value_array_append(relay_info, &value);
+		gst_structure_free(turn_setup);
+	}
+
+	return relay_info;
+}
+                        
 static gboolean
 create_stream(PurpleMediaBackendFs2 *self,
 		const gchar *sess_id, const gchar *who,
@@ -1602,31 +1626,32 @@
 
 	if (turn_ip && !strcmp("nice", transmitter)) {
 		GValueArray *relay_info = g_value_array_new(0);
-		GValue value;
-		gint turn_port = purple_prefs_get_int(
-				"/purple/network/turn_port");
+		gint port;
 		const gchar *username =	purple_prefs_get_string(
 				"/purple/network/turn_username");
 		const gchar *password = purple_prefs_get_string(
 				"/purple/network/turn_password");
-		GstStructure *turn_setup = gst_structure_new("relay-info",
-				"ip", G_TYPE_STRING, turn_ip, 
-				"port", G_TYPE_UINT, turn_port,
-				"username", G_TYPE_STRING, username,
-				"password", G_TYPE_STRING, password,
-				NULL);
 
-		if (!turn_setup) {
-			purple_debug_error("backend-fs2",
-					"Error creating relay info structure");
-			return FALSE;
+		/* UDP */
+		port = purple_prefs_get_int("/purple/network/turn_port");
+		if (port > 0) {
+			relay_info = append_relay_info(relay_info, turn_ip, port, username,
+				password, "udp");
 		}
 
-		memset(&value, 0, sizeof(GValue));
-		g_value_init(&value, GST_TYPE_STRUCTURE);
-		gst_value_set_structure(&value, turn_setup);
-		relay_info = g_value_array_append(relay_info, &value);
-		gst_structure_free(turn_setup);
+		/* TCP */
+		port = purple_prefs_get_int("/purple/network/turn_port_tcp");
+		if (port > 0) {
+			relay_info = append_relay_info(relay_info, turn_ip, port, username,
+				password, "tcp");
+		}
+
+		/* TLS */
+		port = purple_prefs_get_int("/purple/network/turn_port_tls");
+		if (port > 0) {
+			relay_info = append_relay_info(relay_info, turn_ip, port, username,
+				password, "tls");
+		}
 
 		purple_debug_info("backend-fs2",
 			"Setting relay-info on new stream\n");
--- a/libpurple/network.c	Tue Aug 24 05:07:48 2010 +0000
+++ b/libpurple/network.c	Wed Aug 25 19:13:24 2010 +0000
@@ -1140,6 +1140,8 @@
 	purple_prefs_add_string("/purple/network/stun_server", "");
 	purple_prefs_add_string("/purple/network/turn_server", "");
 	purple_prefs_add_int   ("/purple/network/turn_port", 3478);
+	purple_prefs_add_int   ("/purple/network/turn_port_tcp", 3478);
+	purple_prefs_add_int   ("/purple/network/turn_port_tls", 443);
 	purple_prefs_add_string("/purple/network/turn_username", "");
 	purple_prefs_add_string("/purple/network/turn_password", "");
 	purple_prefs_add_bool  ("/purple/network/auto_ip", TRUE);
--- a/pidgin/gtkprefs.c	Tue Aug 24 05:07:48 2010 +0000
+++ b/pidgin/gtkprefs.c	Wed Aug 25 19:13:24 2010 +0000
@@ -1809,9 +1809,13 @@
 
 	hbox = pidgin_add_widget_to_vbox(GTK_BOX(vbox), _("_TURN server:"),
 			sg, entry, TRUE, NULL);
-
-	pidgin_prefs_labeled_spin_button(hbox, _("_Port:"),
+	
+	pidgin_prefs_labeled_spin_button(hbox, _("_UDP:"),
 		"/purple/network/turn_port", 0, 65535, NULL);
+	pidgin_prefs_labeled_spin_button(hbox, _("_TCP:"),
+		"/purple/network/turn_port_tcp", 0, 65535, NULL);
+	pidgin_prefs_labeled_spin_button(hbox, _("_TLS:"),
+		"/purple/network/turn_port_tls", 0, 65535, NULL);
 	hbox = pidgin_prefs_labeled_entry(vbox, _("Use_rname:"),
 		"/purple/network/turn_username", sg);
 	pidgin_prefs_labeled_password(hbox, _("Pass_word:"),