pidgin: c5a0fb57: Don't do IP discovery if the automatic I...

qulogic at pidgin.im qulogic at pidgin.im
Sat Sep 5 21:16:46 EDT 2009


-----------------------------------------------------------------
Revision: c5a0fb57e25619218f4386d2cbb1d8499201b4cb
Ancestor: 2f52e07f3306baa808ce3eb06c805e0d852a060b
Author: qulogic at pidgin.im
Date: 2009-09-06T00:43:33
Branch: im.pidgin.pidgin
URL: http://d.pidgin.im/viewmtn/revision/info/c5a0fb57e25619218f4386d2cbb1d8499201b4cb

Modified files:
        pidgin/gtkprefs.c

ChangeLog: 

Don't do IP discovery if the automatic IP detection pref is disabled, even
if just for display.

Fixes #4728.

-------------- next part --------------
============================================================
--- pidgin/gtkprefs.c	47b5c456269fd8a22fe46f7a7a7dd8bbb642dad6
+++ pidgin/gtkprefs.c	4fd521a4d167687d1f3049061b8bb56439b59a92
@@ -1757,6 +1757,43 @@ browser_button_clicked_cb(GtkWidget *but
 	g_error_free(err);
 }
 
+static void
+auto_ip_button_clicked_cb(GtkWidget *button, gpointer null)
+{
+	const char *ip;
+	PurpleStunNatDiscovery *stun;
+	char *auto_ip_text;
+
+	/* purple_network_get_my_ip will return the IP that was set by the user with
+	   purple_network_set_public_ip, so make a lookup for the auto-detected IP
+	   ourselves. */
+
+	if (purple_prefs_get_bool("/purple/network/auto_ip")) {
+		/* Check if STUN discovery was already done */
+		stun = purple_stun_discover(NULL);
+		if ((stun != NULL) && (stun->status == PURPLE_STUN_STATUS_DISCOVERED)) {
+			ip = stun->publicip;
+		} else {
+			/* Attempt to get the IP from a NAT device using UPnP */
+			ip = purple_upnp_get_public_ip();
+			if (ip == NULL) {
+				/* Attempt to get the IP from a NAT device using NAT-PMP */
+				ip = purple_pmp_get_public_ip();
+				if (ip == NULL) {
+					/* Just fetch the IP of the local system */
+					ip = purple_network_get_local_system_ip(-1);
+				}
+			}
+		}
+	}
+	else
+		ip = _("Disabled");
+
+	auto_ip_text = g_strdup_printf(_("Use _automatically detected IP address: %s"), ip);
+	gtk_button_set_label(GTK_BUTTON(button), auto_ip_text);
+	g_free(auto_ip_text);
+}
+
 static GtkWidget *
 network_page(void)
 {
@@ -1767,9 +1804,6 @@ network_page(void)
 	GtkWidget *proxy_button = NULL, *browser_button = NULL;
 	GtkSizeGroup *sg;
 	PurpleProxyInfo *proxy_info = NULL;
-	const char *ip;
-	PurpleStunNatDiscovery *stun;
-	char *auto_ip_text;
 
 	ret = gtk_vbox_new(FALSE, PIDGIN_HIG_CAT_SPACE);
 	gtk_container_set_border_width (GTK_CONTAINER (ret), PIDGIN_HIG_BORDER);
@@ -1800,31 +1834,12 @@ network_page(void)
 	gtk_misc_set_alignment(GTK_MISC(label), 0.0, 0.5);
 	gtk_container_add(GTK_CONTAINER(hbox), label);
 
-	/* purple_network_get_my_ip will return the IP that was set by the user with
-	   purple_network_set_public_ip, so make a lookup for the auto-detected IP
-	   ourselves. */
+	auto_ip_checkbox = pidgin_prefs_checkbox("Use _automatically detected IP address",
+	                                         "/purple/network/auto_ip", vbox);
+	g_signal_connect(G_OBJECT(auto_ip_checkbox), "clicked",
+	                 G_CALLBACK(auto_ip_button_clicked_cb), NULL);
+	auto_ip_button_clicked_cb(auto_ip_checkbox, NULL); /* Update label */
 
-	/* Check if STUN discovery was already done */
-	stun = purple_stun_discover(NULL);
-	if ((stun != NULL) && (stun->status == PURPLE_STUN_STATUS_DISCOVERED)) {
-		ip = stun->publicip;
-	} else {
-		/* Attempt to get the IP from a NAT device using UPnP */
-		ip = purple_upnp_get_public_ip();
-		if (ip == NULL) {
-			/* Attempt to get the IP from a NAT device using NAT-PMP */
-			ip = purple_pmp_get_public_ip();
-			if (ip == NULL) {
-				/* Just fetch the IP of the local system */
-				ip = purple_network_get_local_system_ip(-1);
-			}
-		}
-	}
-
-	auto_ip_text = g_strdup_printf(_("Use _automatically detected IP address: %s"), ip);
-	auto_ip_checkbox = pidgin_prefs_checkbox(auto_ip_text, "/purple/network/auto_ip", vbox);
-	g_free(auto_ip_text);
-
 	table = gtk_table_new(2, 2, FALSE);
 	gtk_container_set_border_width(GTK_CONTAINER(table), 0);
 	gtk_table_set_col_spacings(GTK_TABLE(table), 5);


More information about the Commits mailing list