cpw.malu.xmpp.google_relay: e8462c62: Rearranged some code to remove some dupl...
malu at pidgin.im
malu at pidgin.im
Mon Sep 28 17:01:49 EDT 2009
-----------------------------------------------------------------
Revision: e8462c6249c75203a72cb2ec767d91b93009da13
Ancestor: 172ba493a74cc3f07aa44e81a0ad5a32a6d335c2
Author: malu at pidgin.im
Date: 2009-09-28T20:56:39
Branch: im.pidgin.cpw.malu.xmpp.google_relay
URL: http://d.pidgin.im/viewmtn/revision/info/e8462c6249c75203a72cb2ec767d91b93009da13
Modified files:
libpurple/protocols/jabber/jingle/jingle.c
ChangeLog:
Rearranged some code to remove some duplication.
Oh, and for some reason the three relayed candidates (udp, tcp and ssltcp port
443) are created as identical entries as the udp one, not sure why yet...
-------------- next part --------------
============================================================
--- libpurple/protocols/jabber/jingle/jingle.c 0eaca1611e928d373b3b1ba6b48fc36da2baa4c5
+++ libpurple/protocols/jabber/jingle/jingle.c 321091d6d322703af6a35a39eecebbe0b7f9e6d4
@@ -436,6 +436,30 @@ jingle_terminate_sessions(JabberStream *
}
#ifdef USE_VV
+static GValueArray *
+jingle_create_relay_info(const gchar *ip, guint port, const gchar *username,
+ const gchar *password, const gchar *relay_type, GValueArray *relay_info)
+{
+ 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, relay_type,
+ NULL);
+ purple_debug_info("jabber", "created gst_structure %" GST_PTR_FORMAT "\n",
+ turn_setup);
+ 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;
+}
+
GParameter *
jingle_get_params(JabberStream *js, const gchar *relay_ip, guint relay_udp,
guint relay_tcp, guint relay_ssltcp, const gchar *relay_username,
@@ -471,57 +495,21 @@ jingle_get_params(JabberStream *js, cons
if (relay_ip) {
GValueArray *relay_info = g_value_array_new(0);
- GValue udp_value;
- GValue tcp_value;
- GValue ssltcp_value;
if (relay_udp) {
- GstStructure *turn_setup = gst_structure_new("relay-info",
- "ip", G_TYPE_STRING, relay_ip,
- "port", G_TYPE_UINT, relay_udp,
- "username", G_TYPE_STRING, relay_username,
- "password", G_TYPE_STRING, relay_password,
- "relay-type", G_TYPE_STRING, "udp",
- NULL);
- if (turn_setup) {
- memset(&udp_value, 0, sizeof(GValue));
- g_value_init(&udp_value, GST_TYPE_STRUCTURE);
- gst_value_set_structure(&udp_value, turn_setup);
- relay_info = g_value_array_append(relay_info, &udp_value);
- gst_structure_free(turn_setup);
- }
+ relay_info =
+ jingle_create_relay_info(relay_ip, relay_udp, relay_username,
+ relay_password, "udp", relay_info);
}
if (relay_tcp) {
- GstStructure *turn_setup = gst_structure_new("relay-info",
- "ip", G_TYPE_STRING, relay_ip,
- "port", G_TYPE_UINT, relay_tcp,
- "username", G_TYPE_STRING, relay_username,
- "password", G_TYPE_STRING, relay_password,
- "relay-type", G_TYPE_STRING, "tcp",
- NULL);
- if (turn_setup) {
- memset(&tcp_value, 0, sizeof(GValue));
- g_value_init(&tcp_value, GST_TYPE_STRUCTURE);
- gst_value_set_structure(&tcp_value, turn_setup);
- relay_info = g_value_array_append(relay_info, &tcp_value);
- gst_structure_free(turn_setup);
- }
+ relay_info =
+ jingle_create_relay_info(relay_ip, relay_tcp, relay_username,
+ relay_password, "tcp", relay_info);
}
if (relay_ssltcp) {
- GstStructure *turn_setup = gst_structure_new("relay-info",
- "ip", G_TYPE_STRING, relay_ip,
- "port", G_TYPE_UINT, relay_ssltcp,
- "username", G_TYPE_STRING, relay_username,
- "password", G_TYPE_STRING, relay_password,
- "relay-type", G_TYPE_STRING, "tls",
- NULL);
- if (turn_setup) {
- memset(&ssltcp_value, 0, sizeof(GValue));
- g_value_init(&ssltcp_value, GST_TYPE_STRUCTURE);
- gst_value_set_structure(&ssltcp_value, turn_setup);
- relay_info = g_value_array_append(relay_info, &ssltcp_value);
- gst_structure_free(turn_setup);
- }
+ relay_info =
+ jingle_create_relay_info(relay_ip, relay_ssltcp, relay_username,
+ relay_password, "tls", relay_info);
}
params[next_index].name = "relay-info";
g_value_init(¶ms[next_index].value, G_TYPE_VALUE_ARRAY);
More information about the Commits
mailing list