changeset 26098:5c3976757e50

merge of '1fa05b8b4d069723f0cba486203a2a00c3baf096' and '9fc1a9e643b3113695eaf212da6cb69b061ef832'
author Mike Ruprecht <maiku@soc.pidgin.im>
date Sat, 10 Jan 2009 01:11:29 +0000
parents 8e0ff15f835a (diff) c7ab1983df88 (current diff)
children b6457b2a8e14
files
diffstat 2 files changed, 26 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/libpurple/media.c	Sat Jan 10 00:55:35 2009 +0000
+++ b/libpurple/media.c	Sat Jan 10 01:11:29 2009 +0000
@@ -1307,6 +1307,15 @@
 	return purple_media_get_ip(stun_pref);
 }
 
+static gchar *
+purple_media_get_turn_pref_ip()
+{
+	const gchar *turn_pref =
+			purple_prefs_get_string("/purple/network/turn_server");
+	
+	return purple_media_get_ip(turn_pref);
+}
+
 static gboolean
 purple_media_add_stream_internal(PurpleMedia *media, const gchar *sess_id,
 				 const gchar *who, FsMediaType type,
@@ -1390,11 +1399,17 @@
 
 	if (!stream) {
 		GError *err = NULL;
-		gchar *stun_ip = NULL;
 		FsStream *fsstream = NULL;
 
-		if ((stun_ip = purple_media_get_stun_pref_ip())) {
-			GParameter *param = g_new0(GParameter, num_params+1);
+		gchar *stun_ip = purple_media_get_stun_pref_ip();
+		gchar *turn_ip = purple_media_get_turn_pref_ip();
+		
+		if (stun_ip || turn_ip) {
+			int new_num_params = 
+				(stun_ip != NULL && turn_ip == NULL) || 
+				(stun_ip == NULL && turn_ip != NULL) ? 
+				num_params + 1 : num_params + 2;
+			GParameter *param = g_new0(GParameter, new_num_params);
 			memcpy(param, params, sizeof(GParameter) * num_params);
 
 			param[num_params].name = "stun-ip";
@@ -1403,9 +1418,12 @@
 
 			fsstream = fs_session_new_stream(session->session,
 					participant, type_direction,
-					transmitter, num_params+1, param, &err);
+					transmitter, new_num_params, param, &err);
 			g_free(param);
-			g_free(stun_ip);
+			if (stun_ip)
+				g_free(stun_ip);
+			if (turn_ip)
+				g_free(turn_ip);
 		} else {
 			fsstream = fs_session_new_stream(session->session,
 					participant, type_direction,
--- a/pidgin/gtkprefs.c	Sat Jan 10 00:55:35 2009 +0000
+++ b/pidgin/gtkprefs.c	Sat Jan 10 01:11:29 2009 +0000
@@ -2613,7 +2613,10 @@
 	/* set a default port for TURN server */
 	/* currently there is no default port for TURN, one option is to use the
 	 same port as STUN */
+	purple_prefs_add_string("/purple/network/turn_server", "");
 	purple_prefs_add_int("/purple/network/turn_port", 3478);
+	purple_prefs_add_string("/purple/network/turn_username", "");
+	purple_prefs_add_string("/purple/network/turn_password", "");
 
 	pidgin_prefs_update_old();
 }