pidgin/gtkprefs.c

changeset 40663
2453bef0abe7
parent 40655
b73d179268e1
child 40671
bdbfa6925bc9
equal deleted inserted replaced
40662:80764d18e588 40663:2453bef0abe7
27 #include <errno.h> 27 #include <errno.h>
28 #include <math.h> 28 #include <math.h>
29 29
30 #include <glib/gi18n-lib.h> 30 #include <glib/gi18n-lib.h>
31 #include <glib/gstdio.h> 31 #include <glib/gstdio.h>
32 32 #include <nice.h>
33 #include <talkatu.h> 33 #include <talkatu.h>
34 34
35 #include <purple.h> 35 #include <purple.h>
36 36
37 #include "gtkblist.h" 37 #include "gtkblist.h"
1758 auto_ip_button_clicked_cb(GtkWidget *button, gpointer null) 1758 auto_ip_button_clicked_cb(GtkWidget *button, gpointer null)
1759 { 1759 {
1760 const char *ip; 1760 const char *ip;
1761 PurpleStunNatDiscovery *stun; 1761 PurpleStunNatDiscovery *stun;
1762 char *auto_ip_text; 1762 char *auto_ip_text;
1763 1763 GList *list = NULL;
1764 /* purple_network_get_my_ip will return the IP that was set by the user with 1764
1765 purple_network_set_public_ip, so make a lookup for the auto-detected IP 1765 /* Make a lookup for the auto-detected IP ourselves. */
1766 ourselves. */
1767
1768 if (purple_prefs_get_bool("/purple/network/auto_ip")) { 1766 if (purple_prefs_get_bool("/purple/network/auto_ip")) {
1769 /* Check if STUN discovery was already done */ 1767 /* Check if STUN discovery was already done */
1770 stun = purple_stun_discover(NULL); 1768 stun = purple_stun_discover(NULL);
1771 if ((stun != NULL) && (stun->status == PURPLE_STUN_STATUS_DISCOVERED)) { 1769 if ((stun != NULL) && (stun->status == PURPLE_STUN_STATUS_DISCOVERED)) {
1772 ip = stun->publicip; 1770 ip = stun->publicip;
1775 ip = purple_upnp_get_public_ip(); 1773 ip = purple_upnp_get_public_ip();
1776 if (ip == NULL) { 1774 if (ip == NULL) {
1777 /* Attempt to get the IP from a NAT device using NAT-PMP */ 1775 /* Attempt to get the IP from a NAT device using NAT-PMP */
1778 ip = purple_pmp_get_public_ip(); 1776 ip = purple_pmp_get_public_ip();
1779 if (ip == NULL) { 1777 if (ip == NULL) {
1780 /* Just fetch the IP of the local system */ 1778 /* Just fetch the first IP of the local system */
1781 ip = purple_network_get_local_system_ip(); 1779 list = nice_interfaces_get_local_ips(FALSE);
1780 if (list) {
1781 ip = list->data;
1782 } else {
1783 ip = "0.0.0.0";
1784 }
1782 } 1785 }
1783 } 1786 }
1784 } 1787 }
1785 } 1788 } else{
1786 else
1787 ip = _("Disabled"); 1789 ip = _("Disabled");
1790 }
1788 1791
1789 auto_ip_text = g_strdup_printf(_("Use _automatically detected IP address: %s"), ip); 1792 auto_ip_text = g_strdup_printf(_("Use _automatically detected IP address: %s"), ip);
1790 gtk_button_set_label(GTK_BUTTON(button), auto_ip_text); 1793 gtk_button_set_label(GTK_BUTTON(button), auto_ip_text);
1791 g_free(auto_ip_text); 1794 g_free(auto_ip_text);
1795 g_list_free_full(list, g_free);
1792 } 1796 }
1793 1797
1794 static void 1798 static void
1795 bind_network_page(PidginPrefsWindow *win) 1799 bind_network_page(PidginPrefsWindow *win)
1796 { 1800 {

mercurial