Mon, 02 Mar 2009 18:47:27 +0000
propagate from branch 'im.pidgin.pidgin' (head 133e5eca834c5d4adad0937da2cb93df4e9c8b30)
to branch 'im.pidgin.pidgin.vv' (head 46202497d8c3543ee9c8d91aa15cb7ff5d19e9a6)
| 8231 | 1 | /** |
| 2 | * @file network.c Network Implementation | |
| 3 | * @ingroup core | |
|
20147
66f05a854eee
applied changes from 8a731bbd0197fbcc91a705c2d8f528154216defa
Richard Laager <rlaager@pidgin.im>
parents:
19859
diff
changeset
|
4 | */ |
|
66f05a854eee
applied changes from 8a731bbd0197fbcc91a705c2d8f528154216defa
Richard Laager <rlaager@pidgin.im>
parents:
19859
diff
changeset
|
5 | |
|
66f05a854eee
applied changes from 8a731bbd0197fbcc91a705c2d8f528154216defa
Richard Laager <rlaager@pidgin.im>
parents:
19859
diff
changeset
|
6 | /* purple |
| 8231 | 7 | * |
| 15884 | 8 | * Purple is the legal property of its developers, whose names are too numerous |
| 8231 | 9 | * to list here. Please refer to the COPYRIGHT file distributed with this |
| 10 | * source distribution. | |
| 11 | * | |
| 12 | * This program is free software; you can redistribute it and/or modify | |
| 13 | * it under the terms of the GNU General Public License as published by | |
| 14 | * the Free Software Foundation; either version 2 of the License, or | |
| 15 | * (at your option) any later version. | |
| 16 | * | |
| 17 | * This program is distributed in the hope that it will be useful, | |
| 18 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 19 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
| 20 | * GNU General Public License for more details. | |
| 21 | * | |
| 22 | * You should have received a copy of the GNU General Public License | |
| 23 | * along with this program; if not, write to the Free Software | |
|
19859
71d37b57eff2
The FSF changed its address a while ago; our files were out of date.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
19832
diff
changeset
|
24 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA |
| 8231 | 25 | */ |
| 26 | ||
|
8245
c1397ca0a619
[gaim-migrate @ 8968]
Herman Bloggs <herman@bluedigits.com>
parents:
8240
diff
changeset
|
27 | #include "internal.h" |
| 8231 | 28 | |
|
13156
539a637c61dc
[gaim-migrate @ 15518]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
13131
diff
changeset
|
29 | #ifndef _WIN32 |
|
23352
9714223ca7a7
A patch from Peter O'Gorman at The Written Word, Inc. to fix various
Peter O'Gorman <pogma@thewrittenword.com>
parents:
23185
diff
changeset
|
30 | #include <arpa/nameser.h> |
| 14864 | 31 | #include <resolv.h> |
| 32 | #include <netinet/in.h> | |
|
13156
539a637c61dc
[gaim-migrate @ 15518]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
13131
diff
changeset
|
33 | #include <net/if.h> |
|
539a637c61dc
[gaim-migrate @ 15518]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
13131
diff
changeset
|
34 | #include <sys/ioctl.h> |
|
14784
3a82321f46f2
[gaim-migrate @ 17476]
Daniel Atallah <datallah@pidgin.im>
parents:
14758
diff
changeset
|
35 | #else |
|
3a82321f46f2
[gaim-migrate @ 17476]
Daniel Atallah <datallah@pidgin.im>
parents:
14758
diff
changeset
|
36 | #include <nspapi.h> |
|
13156
539a637c61dc
[gaim-migrate @ 15518]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
13131
diff
changeset
|
37 | #endif |
|
539a637c61dc
[gaim-migrate @ 15518]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
13131
diff
changeset
|
38 | |
|
539a637c61dc
[gaim-migrate @ 15518]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
13131
diff
changeset
|
39 | /* Solaris */ |
|
539a637c61dc
[gaim-migrate @ 15518]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
13131
diff
changeset
|
40 | #if defined (__SVR4) && defined (__sun) |
|
539a637c61dc
[gaim-migrate @ 15518]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
13131
diff
changeset
|
41 | #include <sys/sockio.h> |
|
539a637c61dc
[gaim-migrate @ 15518]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
13131
diff
changeset
|
42 | #endif |
|
539a637c61dc
[gaim-migrate @ 15518]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
13131
diff
changeset
|
43 | |
| 8231 | 44 | #include "debug.h" |
| 45 | #include "account.h" | |
|
16035
eb4eda79a147
The network module now registers the signal 'network-configuration-changed' and emits it when a network change is detected via libnm or the win32 network monitor. The UI could also emit this signal if it knows something network.c doesn't. UPnP and NAT-PMP respond to the signal by clearing their IP address caches; changing networks without quitting/relaunching will now lead to the new IP address being (lazily) determined. This commit also enables nat-pmp and adds nat-pmp.[h|c] to the build process; please let me know if there are any problems building, as I only have OS X test machines.
Evan Schoenberg <evands@pidgin.im>
parents:
16012
diff
changeset
|
46 | #include "nat-pmp.h" |
| 8231 | 47 | #include "network.h" |
| 48 | #include "prefs.h" | |
|
11411
b74834586187
[gaim-migrate @ 13648]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
11391
diff
changeset
|
49 | #include "stun.h" |
|
11195
d84d542a04ac
[gaim-migrate @ 13319]
Adam Warrington <awarring@users.sourceforge.net>
parents:
11033
diff
changeset
|
50 | #include "upnp.h" |
|
26256
d2673c935184
Run an asynchronous DNS lookup for the STUN server IP (to set as a property
Marcus Lundblad <malu@pidgin.im>
parents:
25326
diff
changeset
|
51 | #include "dnsquery.h" |
| 8231 | 52 | |
|
15278
7f469b5c8d7a
[gaim-migrate @ 18006]
Mark Doliner <markdoliner@pidgin.im>
parents:
15116
diff
changeset
|
53 | /* |
|
7f469b5c8d7a
[gaim-migrate @ 18006]
Mark Doliner <markdoliner@pidgin.im>
parents:
15116
diff
changeset
|
54 | * Calling sizeof(struct ifreq) isn't always correct on |
|
7f469b5c8d7a
[gaim-migrate @ 18006]
Mark Doliner <markdoliner@pidgin.im>
parents:
15116
diff
changeset
|
55 | * Mac OS X (and maybe others). |
|
7f469b5c8d7a
[gaim-migrate @ 18006]
Mark Doliner <markdoliner@pidgin.im>
parents:
15116
diff
changeset
|
56 | */ |
|
7f469b5c8d7a
[gaim-migrate @ 18006]
Mark Doliner <markdoliner@pidgin.im>
parents:
15116
diff
changeset
|
57 | #ifdef _SIZEOF_ADDR_IFREQ |
|
7f469b5c8d7a
[gaim-migrate @ 18006]
Mark Doliner <markdoliner@pidgin.im>
parents:
15116
diff
changeset
|
58 | # define HX_SIZE_OF_IFREQ(a) _SIZEOF_ADDR_IFREQ(a) |
|
7f469b5c8d7a
[gaim-migrate @ 18006]
Mark Doliner <markdoliner@pidgin.im>
parents:
15116
diff
changeset
|
59 | #else |
|
7f469b5c8d7a
[gaim-migrate @ 18006]
Mark Doliner <markdoliner@pidgin.im>
parents:
15116
diff
changeset
|
60 | # define HX_SIZE_OF_IFREQ(a) sizeof(a) |
|
7f469b5c8d7a
[gaim-migrate @ 18006]
Mark Doliner <markdoliner@pidgin.im>
parents:
15116
diff
changeset
|
61 | #endif |
|
7f469b5c8d7a
[gaim-migrate @ 18006]
Mark Doliner <markdoliner@pidgin.im>
parents:
15116
diff
changeset
|
62 | |
|
23060
db9632a9b374
Use pkg-config to detect NetworkManager. Also, fail if it isn't present,
Richard Laager <rlaager@pidgin.im>
parents:
23054
diff
changeset
|
63 | #ifdef HAVE_NETWORKMANAGER |
|
23039
c9b53691fe42
A patch from QuLogic to replace the libnm_glib calls with straight DBus
Richard Laager <rlaager@pidgin.im>
parents:
22735
diff
changeset
|
64 | #include <dbus/dbus-glib.h> |
|
23060
db9632a9b374
Use pkg-config to detect NetworkManager. Also, fail if it isn't present,
Richard Laager <rlaager@pidgin.im>
parents:
23054
diff
changeset
|
65 | #include <NetworkManager.h> |
| 14758 | 66 | |
|
23039
c9b53691fe42
A patch from QuLogic to replace the libnm_glib calls with straight DBus
Richard Laager <rlaager@pidgin.im>
parents:
22735
diff
changeset
|
67 | static DBusGConnection *nm_conn = NULL; |
|
c9b53691fe42
A patch from QuLogic to replace the libnm_glib calls with straight DBus
Richard Laager <rlaager@pidgin.im>
parents:
22735
diff
changeset
|
68 | static DBusGProxy *nm_proxy = NULL; |
|
c9b53691fe42
A patch from QuLogic to replace the libnm_glib calls with straight DBus
Richard Laager <rlaager@pidgin.im>
parents:
22735
diff
changeset
|
69 | static DBusGProxy *dbus_proxy = NULL; |
|
24519
d4af3d043211
Improve our NetworkManager support in a couple of ways:
Richard Laager <rlaager@pidgin.im>
parents:
24044
diff
changeset
|
70 | static NMState nm_state = NM_STATE_UNKNOWN; |
|
d4af3d043211
Improve our NetworkManager support in a couple of ways:
Richard Laager <rlaager@pidgin.im>
parents:
24044
diff
changeset
|
71 | static gboolean have_nm_state = FALSE; |
| 14758 | 72 | |
|
14784
3a82321f46f2
[gaim-migrate @ 17476]
Daniel Atallah <datallah@pidgin.im>
parents:
14758
diff
changeset
|
73 | #elif defined _WIN32 |
|
3a82321f46f2
[gaim-migrate @ 17476]
Daniel Atallah <datallah@pidgin.im>
parents:
14758
diff
changeset
|
74 | static int current_network_count; |
|
25326
c4f4b222dbac
Adjust the NLA code to prevent hang on exit for Windows XP and Windows Vista.
Paul Aurich <darkrain42@pidgin.im>
parents:
24519
diff
changeset
|
75 | |
|
c4f4b222dbac
Adjust the NLA code to prevent hang on exit for Windows XP and Windows Vista.
Paul Aurich <darkrain42@pidgin.im>
parents:
24519
diff
changeset
|
76 | /* Mutex for the other global vars */ |
|
c4f4b222dbac
Adjust the NLA code to prevent hang on exit for Windows XP and Windows Vista.
Paul Aurich <darkrain42@pidgin.im>
parents:
24519
diff
changeset
|
77 | static GStaticMutex mutex = G_STATIC_MUTEX_INIT; |
|
25541
1b82a0195ff5
Fix 3 different race conditions in the win32 network management functionality.
Daniel Atallah <datallah@pidgin.im>
parents:
25326
diff
changeset
|
78 | static gboolean network_initialized = FALSE; |
|
1b82a0195ff5
Fix 3 different race conditions in the win32 network management functionality.
Daniel Atallah <datallah@pidgin.im>
parents:
25326
diff
changeset
|
79 | static HANDLE network_change_handle = NULL; |
|
1b82a0195ff5
Fix 3 different race conditions in the win32 network management functionality.
Daniel Atallah <datallah@pidgin.im>
parents:
25326
diff
changeset
|
80 | static int (WSAAPI *MyWSANSPIoctl) ( |
|
1b82a0195ff5
Fix 3 different race conditions in the win32 network management functionality.
Daniel Atallah <datallah@pidgin.im>
parents:
25326
diff
changeset
|
81 | HANDLE hLookup, DWORD dwControlCode, LPVOID lpvInBuffer, |
|
1b82a0195ff5
Fix 3 different race conditions in the win32 network management functionality.
Daniel Atallah <datallah@pidgin.im>
parents:
25326
diff
changeset
|
82 | DWORD cbInBuffer, LPVOID lpvOutBuffer, DWORD cbOutBuffer, |
|
1b82a0195ff5
Fix 3 different race conditions in the win32 network management functionality.
Daniel Atallah <datallah@pidgin.im>
parents:
25326
diff
changeset
|
83 | LPDWORD lpcbBytesReturned, LPWSACOMPLETION lpCompletion) = NULL; |
| 14758 | 84 | #endif |
| 85 | ||
| 15884 | 86 | struct _PurpleNetworkListenData { |
|
12909
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12730
diff
changeset
|
87 | int listenfd; |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12730
diff
changeset
|
88 | int socket_type; |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12730
diff
changeset
|
89 | gboolean retry; |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12730
diff
changeset
|
90 | gboolean adding; |
| 15884 | 91 | PurpleNetworkListenCallback cb; |
|
12909
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12730
diff
changeset
|
92 | gpointer cb_data; |
|
15502
250802f80d94
Fix a crash when a network_listen_range process is canceled before its UPnP port mapping completes, which occurs regularly on certain routers when file transfers are initiated and then quickly finished. Much thanks to Elliott Harris and Eric Richie for their hard work with me hunting this down and fixing it.
Evan Schoenberg <evands@pidgin.im>
parents:
15435
diff
changeset
|
93 | UPnPMappingAddRemove *mapping_data; |
|
14329
05c3cc0c1f79
[gaim-migrate @ 16949]
Mark Doliner <markdoliner@pidgin.im>
parents:
14254
diff
changeset
|
94 | }; |
|
11391
d172e72988cc
[gaim-migrate @ 13620]
Adam Warrington <awarring@users.sourceforge.net>
parents:
11336
diff
changeset
|
95 | |
|
23060
db9632a9b374
Use pkg-config to detect NetworkManager. Also, fail if it isn't present,
Richard Laager <rlaager@pidgin.im>
parents:
23054
diff
changeset
|
96 | #ifdef HAVE_NETWORKMANAGER |
|
23039
c9b53691fe42
A patch from QuLogic to replace the libnm_glib calls with straight DBus
Richard Laager <rlaager@pidgin.im>
parents:
22735
diff
changeset
|
97 | static NMState nm_get_network_state(void); |
| 14758 | 98 | #endif |
| 99 | ||
|
24999
84d597b7e7c6
Add a -f/--force-online option to Pidgin which tells libpurple to claim the
Richard Laager <rlaager@pidgin.im>
parents:
24519
diff
changeset
|
100 | #if defined(HAVE_NETWORKMANAGER) || defined(_WIN32) |
|
84d597b7e7c6
Add a -f/--force-online option to Pidgin which tells libpurple to claim the
Richard Laager <rlaager@pidgin.im>
parents:
24519
diff
changeset
|
101 | static gboolean force_online; |
|
84d597b7e7c6
Add a -f/--force-online option to Pidgin which tells libpurple to claim the
Richard Laager <rlaager@pidgin.im>
parents:
24519
diff
changeset
|
102 | #endif |
|
84d597b7e7c6
Add a -f/--force-online option to Pidgin which tells libpurple to claim the
Richard Laager <rlaager@pidgin.im>
parents:
24519
diff
changeset
|
103 | |
|
26261
ffabb135a4b6
Added support to generate relayed candidates (TURN).
Marcus Lundblad <malu@pidgin.im>
parents:
26256
diff
changeset
|
104 | /* Cached IP addresses for STUN and TURN servers (set globally in prefs) */ |
|
26256
d2673c935184
Run an asynchronous DNS lookup for the STUN server IP (to set as a property
Marcus Lundblad <malu@pidgin.im>
parents:
25326
diff
changeset
|
105 | static gchar *stun_ip = NULL; |
|
26261
ffabb135a4b6
Added support to generate relayed candidates (TURN).
Marcus Lundblad <malu@pidgin.im>
parents:
26256
diff
changeset
|
106 | static gchar *turn_ip = NULL; |
|
26256
d2673c935184
Run an asynchronous DNS lookup for the STUN server IP (to set as a property
Marcus Lundblad <malu@pidgin.im>
parents:
25326
diff
changeset
|
107 | |
|
8838
c23227da7b4a
[gaim-migrate @ 9604]
Mark Doliner <markdoliner@pidgin.im>
parents:
8834
diff
changeset
|
108 | const unsigned char * |
| 15884 | 109 | purple_network_ip_atoi(const char *ip) |
|
8838
c23227da7b4a
[gaim-migrate @ 9604]
Mark Doliner <markdoliner@pidgin.im>
parents:
8834
diff
changeset
|
110 | { |
|
c23227da7b4a
[gaim-migrate @ 9604]
Mark Doliner <markdoliner@pidgin.im>
parents:
8834
diff
changeset
|
111 | static unsigned char ret[4]; |
| 8981 | 112 | gchar *delimiter = "."; |
|
8838
c23227da7b4a
[gaim-migrate @ 9604]
Mark Doliner <markdoliner@pidgin.im>
parents:
8834
diff
changeset
|
113 | gchar **split; |
|
c23227da7b4a
[gaim-migrate @ 9604]
Mark Doliner <markdoliner@pidgin.im>
parents:
8834
diff
changeset
|
114 | int i; |
|
c23227da7b4a
[gaim-migrate @ 9604]
Mark Doliner <markdoliner@pidgin.im>
parents:
8834
diff
changeset
|
115 | |
|
c23227da7b4a
[gaim-migrate @ 9604]
Mark Doliner <markdoliner@pidgin.im>
parents:
8834
diff
changeset
|
116 | g_return_val_if_fail(ip != NULL, NULL); |
|
c23227da7b4a
[gaim-migrate @ 9604]
Mark Doliner <markdoliner@pidgin.im>
parents:
8834
diff
changeset
|
117 | |
| 8981 | 118 | split = g_strsplit(ip, delimiter, 4); |
|
8838
c23227da7b4a
[gaim-migrate @ 9604]
Mark Doliner <markdoliner@pidgin.im>
parents:
8834
diff
changeset
|
119 | for (i = 0; split[i] != NULL; i++) |
|
c23227da7b4a
[gaim-migrate @ 9604]
Mark Doliner <markdoliner@pidgin.im>
parents:
8834
diff
changeset
|
120 | ret[i] = atoi(split[i]); |
|
c23227da7b4a
[gaim-migrate @ 9604]
Mark Doliner <markdoliner@pidgin.im>
parents:
8834
diff
changeset
|
121 | g_strfreev(split); |
|
c23227da7b4a
[gaim-migrate @ 9604]
Mark Doliner <markdoliner@pidgin.im>
parents:
8834
diff
changeset
|
122 | |
|
c23227da7b4a
[gaim-migrate @ 9604]
Mark Doliner <markdoliner@pidgin.im>
parents:
8834
diff
changeset
|
123 | /* i should always be 4 */ |
|
c23227da7b4a
[gaim-migrate @ 9604]
Mark Doliner <markdoliner@pidgin.im>
parents:
8834
diff
changeset
|
124 | if (i != 4) |
|
c23227da7b4a
[gaim-migrate @ 9604]
Mark Doliner <markdoliner@pidgin.im>
parents:
8834
diff
changeset
|
125 | return NULL; |
|
c23227da7b4a
[gaim-migrate @ 9604]
Mark Doliner <markdoliner@pidgin.im>
parents:
8834
diff
changeset
|
126 | |
|
c23227da7b4a
[gaim-migrate @ 9604]
Mark Doliner <markdoliner@pidgin.im>
parents:
8834
diff
changeset
|
127 | return ret; |
|
c23227da7b4a
[gaim-migrate @ 9604]
Mark Doliner <markdoliner@pidgin.im>
parents:
8834
diff
changeset
|
128 | } |
|
c23227da7b4a
[gaim-migrate @ 9604]
Mark Doliner <markdoliner@pidgin.im>
parents:
8834
diff
changeset
|
129 | |
| 8231 | 130 | void |
| 15884 | 131 | purple_network_set_public_ip(const char *ip) |
| 8231 | 132 | { |
| 133 | g_return_if_fail(ip != NULL); | |
| 134 | ||
|
8838
c23227da7b4a
[gaim-migrate @ 9604]
Mark Doliner <markdoliner@pidgin.im>
parents:
8834
diff
changeset
|
135 | /* XXX - Ensure the IP address is valid */ |
|
c23227da7b4a
[gaim-migrate @ 9604]
Mark Doliner <markdoliner@pidgin.im>
parents:
8834
diff
changeset
|
136 | |
|
16478
19107605c565
Works for me! Renames prefs: /core to /purple, /gaim/gtk to /pidgin, /gaim/gnt to /finch
Sean Egan <seanegan@pidgin.im>
parents:
16035
diff
changeset
|
137 | purple_prefs_set_string("/purple/network/public_ip", ip); |
| 8231 | 138 | } |
| 139 | ||
| 140 | const char * | |
| 15884 | 141 | purple_network_get_public_ip(void) |
| 8231 | 142 | { |
|
16478
19107605c565
Works for me! Renames prefs: /core to /purple, /gaim/gtk to /pidgin, /gaim/gnt to /finch
Sean Egan <seanegan@pidgin.im>
parents:
16035
diff
changeset
|
143 | return purple_prefs_get_string("/purple/network/public_ip"); |
| 8231 | 144 | } |
| 145 | ||
| 146 | const char * | |
| 15884 | 147 | purple_network_get_local_system_ip(int fd) |
| 8231 | 148 | { |
|
13346
a024b2b0a160
[gaim-migrate @ 15715]
Mark Doliner <markdoliner@pidgin.im>
parents:
13168
diff
changeset
|
149 | char buffer[1024]; |
|
a024b2b0a160
[gaim-migrate @ 15715]
Mark Doliner <markdoliner@pidgin.im>
parents:
13168
diff
changeset
|
150 | static char ip[16]; |
|
a024b2b0a160
[gaim-migrate @ 15715]
Mark Doliner <markdoliner@pidgin.im>
parents:
13168
diff
changeset
|
151 | char *tmp; |
|
a024b2b0a160
[gaim-migrate @ 15715]
Mark Doliner <markdoliner@pidgin.im>
parents:
13168
diff
changeset
|
152 | struct ifconf ifc; |
|
a024b2b0a160
[gaim-migrate @ 15715]
Mark Doliner <markdoliner@pidgin.im>
parents:
13168
diff
changeset
|
153 | struct ifreq *ifr; |
|
a024b2b0a160
[gaim-migrate @ 15715]
Mark Doliner <markdoliner@pidgin.im>
parents:
13168
diff
changeset
|
154 | struct sockaddr_in *sinptr; |
|
a024b2b0a160
[gaim-migrate @ 15715]
Mark Doliner <markdoliner@pidgin.im>
parents:
13168
diff
changeset
|
155 | guint32 lhost = htonl(127 * 256 * 256 * 256 + 1); |
|
a024b2b0a160
[gaim-migrate @ 15715]
Mark Doliner <markdoliner@pidgin.im>
parents:
13168
diff
changeset
|
156 | long unsigned int add; |
|
a024b2b0a160
[gaim-migrate @ 15715]
Mark Doliner <markdoliner@pidgin.im>
parents:
13168
diff
changeset
|
157 | int source = fd; |
| 8231 | 158 | |
|
13346
a024b2b0a160
[gaim-migrate @ 15715]
Mark Doliner <markdoliner@pidgin.im>
parents:
13168
diff
changeset
|
159 | if (fd < 0) |
|
a024b2b0a160
[gaim-migrate @ 15715]
Mark Doliner <markdoliner@pidgin.im>
parents:
13168
diff
changeset
|
160 | source = socket(PF_INET,SOCK_STREAM, 0); |
| 8231 | 161 | |
|
13346
a024b2b0a160
[gaim-migrate @ 15715]
Mark Doliner <markdoliner@pidgin.im>
parents:
13168
diff
changeset
|
162 | ifc.ifc_len = sizeof(buffer); |
|
a024b2b0a160
[gaim-migrate @ 15715]
Mark Doliner <markdoliner@pidgin.im>
parents:
13168
diff
changeset
|
163 | ifc.ifc_req = (struct ifreq *)buffer; |
|
a024b2b0a160
[gaim-migrate @ 15715]
Mark Doliner <markdoliner@pidgin.im>
parents:
13168
diff
changeset
|
164 | ioctl(source, SIOCGIFCONF, &ifc); |
| 8231 | 165 | |
|
13346
a024b2b0a160
[gaim-migrate @ 15715]
Mark Doliner <markdoliner@pidgin.im>
parents:
13168
diff
changeset
|
166 | if (fd < 0) |
|
a024b2b0a160
[gaim-migrate @ 15715]
Mark Doliner <markdoliner@pidgin.im>
parents:
13168
diff
changeset
|
167 | close(source); |
| 8231 | 168 | |
|
13346
a024b2b0a160
[gaim-migrate @ 15715]
Mark Doliner <markdoliner@pidgin.im>
parents:
13168
diff
changeset
|
169 | tmp = buffer; |
|
a024b2b0a160
[gaim-migrate @ 15715]
Mark Doliner <markdoliner@pidgin.im>
parents:
13168
diff
changeset
|
170 | while (tmp < buffer + ifc.ifc_len) |
|
a024b2b0a160
[gaim-migrate @ 15715]
Mark Doliner <markdoliner@pidgin.im>
parents:
13168
diff
changeset
|
171 | { |
|
a024b2b0a160
[gaim-migrate @ 15715]
Mark Doliner <markdoliner@pidgin.im>
parents:
13168
diff
changeset
|
172 | ifr = (struct ifreq *)tmp; |
|
15278
7f469b5c8d7a
[gaim-migrate @ 18006]
Mark Doliner <markdoliner@pidgin.im>
parents:
15116
diff
changeset
|
173 | tmp += HX_SIZE_OF_IFREQ(*ifr); |
| 8231 | 174 | |
|
13346
a024b2b0a160
[gaim-migrate @ 15715]
Mark Doliner <markdoliner@pidgin.im>
parents:
13168
diff
changeset
|
175 | if (ifr->ifr_addr.sa_family == AF_INET) |
|
a024b2b0a160
[gaim-migrate @ 15715]
Mark Doliner <markdoliner@pidgin.im>
parents:
13168
diff
changeset
|
176 | { |
|
a024b2b0a160
[gaim-migrate @ 15715]
Mark Doliner <markdoliner@pidgin.im>
parents:
13168
diff
changeset
|
177 | sinptr = (struct sockaddr_in *)&ifr->ifr_addr; |
|
a024b2b0a160
[gaim-migrate @ 15715]
Mark Doliner <markdoliner@pidgin.im>
parents:
13168
diff
changeset
|
178 | if (sinptr->sin_addr.s_addr != lhost) |
|
a024b2b0a160
[gaim-migrate @ 15715]
Mark Doliner <markdoliner@pidgin.im>
parents:
13168
diff
changeset
|
179 | { |
|
a024b2b0a160
[gaim-migrate @ 15715]
Mark Doliner <markdoliner@pidgin.im>
parents:
13168
diff
changeset
|
180 | add = ntohl(sinptr->sin_addr.s_addr); |
|
a024b2b0a160
[gaim-migrate @ 15715]
Mark Doliner <markdoliner@pidgin.im>
parents:
13168
diff
changeset
|
181 | g_snprintf(ip, 16, "%lu.%lu.%lu.%lu", |
|
a024b2b0a160
[gaim-migrate @ 15715]
Mark Doliner <markdoliner@pidgin.im>
parents:
13168
diff
changeset
|
182 | ((add >> 24) & 255), |
|
a024b2b0a160
[gaim-migrate @ 15715]
Mark Doliner <markdoliner@pidgin.im>
parents:
13168
diff
changeset
|
183 | ((add >> 16) & 255), |
|
a024b2b0a160
[gaim-migrate @ 15715]
Mark Doliner <markdoliner@pidgin.im>
parents:
13168
diff
changeset
|
184 | ((add >> 8) & 255), |
|
a024b2b0a160
[gaim-migrate @ 15715]
Mark Doliner <markdoliner@pidgin.im>
parents:
13168
diff
changeset
|
185 | add & 255); |
| 8231 | 186 | |
|
13346
a024b2b0a160
[gaim-migrate @ 15715]
Mark Doliner <markdoliner@pidgin.im>
parents:
13168
diff
changeset
|
187 | return ip; |
|
a024b2b0a160
[gaim-migrate @ 15715]
Mark Doliner <markdoliner@pidgin.im>
parents:
13168
diff
changeset
|
188 | } |
|
a024b2b0a160
[gaim-migrate @ 15715]
Mark Doliner <markdoliner@pidgin.im>
parents:
13168
diff
changeset
|
189 | } |
|
a024b2b0a160
[gaim-migrate @ 15715]
Mark Doliner <markdoliner@pidgin.im>
parents:
13168
diff
changeset
|
190 | } |
|
a024b2b0a160
[gaim-migrate @ 15715]
Mark Doliner <markdoliner@pidgin.im>
parents:
13168
diff
changeset
|
191 | |
|
a024b2b0a160
[gaim-migrate @ 15715]
Mark Doliner <markdoliner@pidgin.im>
parents:
13168
diff
changeset
|
192 | return "0.0.0.0"; |
| 8231 | 193 | } |
| 194 | ||
| 195 | const char * | |
| 15884 | 196 | purple_network_get_my_ip(int fd) |
| 8231 | 197 | { |
|
12686
ec3e7c4ff045
[gaim-migrate @ 15029]
Richard Laager <rlaager@pidgin.im>
parents:
11424
diff
changeset
|
198 | const char *ip = NULL; |
| 15884 | 199 | PurpleStunNatDiscovery *stun; |
|
8834
0a798e3d2b84
[gaim-migrate @ 9598]
Mark Doliner <markdoliner@pidgin.im>
parents:
8251
diff
changeset
|
200 | |
|
0a798e3d2b84
[gaim-migrate @ 9598]
Mark Doliner <markdoliner@pidgin.im>
parents:
8251
diff
changeset
|
201 | /* Check if the user specified an IP manually */ |
|
16478
19107605c565
Works for me! Renames prefs: /core to /purple, /gaim/gtk to /pidgin, /gaim/gnt to /finch
Sean Egan <seanegan@pidgin.im>
parents:
16035
diff
changeset
|
202 | if (!purple_prefs_get_bool("/purple/network/auto_ip")) { |
| 15884 | 203 | ip = purple_network_get_public_ip(); |
|
15116
037b787407ba
[gaim-migrate @ 17838]
Mark Doliner <markdoliner@pidgin.im>
parents:
14959
diff
changeset
|
204 | /* Make sure the IP address entered by the user is valid */ |
| 15884 | 205 | if ((ip != NULL) && (purple_network_ip_atoi(ip) != NULL)) |
|
8834
0a798e3d2b84
[gaim-migrate @ 9598]
Mark Doliner <markdoliner@pidgin.im>
parents:
8251
diff
changeset
|
206 | return ip; |
|
21810
0b5181178201
Allow UPnP and NAT-PMP port mapping to be disabled via a pref. This means that UPnP discovery will not occur if this new pref and the "Autodetect IP Address" pref are both unchecked. Fixes #4157.
Daniel Atallah <datallah@pidgin.im>
parents:
21549
diff
changeset
|
207 | } else { |
|
0b5181178201
Allow UPnP and NAT-PMP port mapping to be disabled via a pref. This means that UPnP discovery will not occur if this new pref and the "Autodetect IP Address" pref are both unchecked. Fixes #4157.
Daniel Atallah <datallah@pidgin.im>
parents:
21549
diff
changeset
|
208 | /* Check if STUN discovery was already done */ |
|
0b5181178201
Allow UPnP and NAT-PMP port mapping to be disabled via a pref. This means that UPnP discovery will not occur if this new pref and the "Autodetect IP Address" pref are both unchecked. Fixes #4157.
Daniel Atallah <datallah@pidgin.im>
parents:
21549
diff
changeset
|
209 | stun = purple_stun_discover(NULL); |
|
0b5181178201
Allow UPnP and NAT-PMP port mapping to be disabled via a pref. This means that UPnP discovery will not occur if this new pref and the "Autodetect IP Address" pref are both unchecked. Fixes #4157.
Daniel Atallah <datallah@pidgin.im>
parents:
21549
diff
changeset
|
210 | if ((stun != NULL) && (stun->status == PURPLE_STUN_STATUS_DISCOVERED)) |
|
0b5181178201
Allow UPnP and NAT-PMP port mapping to be disabled via a pref. This means that UPnP discovery will not occur if this new pref and the "Autodetect IP Address" pref are both unchecked. Fixes #4157.
Daniel Atallah <datallah@pidgin.im>
parents:
21549
diff
changeset
|
211 | return stun->publicip; |
|
11424
b0f8535daa74
[gaim-migrate @ 13661]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
11411
diff
changeset
|
212 | |
|
21810
0b5181178201
Allow UPnP and NAT-PMP port mapping to be disabled via a pref. This means that UPnP discovery will not occur if this new pref and the "Autodetect IP Address" pref are both unchecked. Fixes #4157.
Daniel Atallah <datallah@pidgin.im>
parents:
21549
diff
changeset
|
213 | /* Attempt to get the IP from a NAT device using UPnP */ |
|
0b5181178201
Allow UPnP and NAT-PMP port mapping to be disabled via a pref. This means that UPnP discovery will not occur if this new pref and the "Autodetect IP Address" pref are both unchecked. Fixes #4157.
Daniel Atallah <datallah@pidgin.im>
parents:
21549
diff
changeset
|
214 | ip = purple_upnp_get_public_ip(); |
|
0b5181178201
Allow UPnP and NAT-PMP port mapping to be disabled via a pref. This means that UPnP discovery will not occur if this new pref and the "Autodetect IP Address" pref are both unchecked. Fixes #4157.
Daniel Atallah <datallah@pidgin.im>
parents:
21549
diff
changeset
|
215 | if (ip != NULL) |
|
0b5181178201
Allow UPnP and NAT-PMP port mapping to be disabled via a pref. This means that UPnP discovery will not occur if this new pref and the "Autodetect IP Address" pref are both unchecked. Fixes #4157.
Daniel Atallah <datallah@pidgin.im>
parents:
21549
diff
changeset
|
216 | return ip; |
|
11195
d84d542a04ac
[gaim-migrate @ 13319]
Adam Warrington <awarring@users.sourceforge.net>
parents:
11033
diff
changeset
|
217 | |
|
21810
0b5181178201
Allow UPnP and NAT-PMP port mapping to be disabled via a pref. This means that UPnP discovery will not occur if this new pref and the "Autodetect IP Address" pref are both unchecked. Fixes #4157.
Daniel Atallah <datallah@pidgin.im>
parents:
21549
diff
changeset
|
218 | /* Attempt to get the IP from a NAT device using NAT-PMP */ |
|
0b5181178201
Allow UPnP and NAT-PMP port mapping to be disabled via a pref. This means that UPnP discovery will not occur if this new pref and the "Autodetect IP Address" pref are both unchecked. Fixes #4157.
Daniel Atallah <datallah@pidgin.im>
parents:
21549
diff
changeset
|
219 | ip = purple_pmp_get_public_ip(); |
|
0b5181178201
Allow UPnP and NAT-PMP port mapping to be disabled via a pref. This means that UPnP discovery will not occur if this new pref and the "Autodetect IP Address" pref are both unchecked. Fixes #4157.
Daniel Atallah <datallah@pidgin.im>
parents:
21549
diff
changeset
|
220 | if (ip != NULL) |
|
0b5181178201
Allow UPnP and NAT-PMP port mapping to be disabled via a pref. This means that UPnP discovery will not occur if this new pref and the "Autodetect IP Address" pref are both unchecked. Fixes #4157.
Daniel Atallah <datallah@pidgin.im>
parents:
21549
diff
changeset
|
221 | return ip; |
|
0b5181178201
Allow UPnP and NAT-PMP port mapping to be disabled via a pref. This means that UPnP discovery will not occur if this new pref and the "Autodetect IP Address" pref are both unchecked. Fixes #4157.
Daniel Atallah <datallah@pidgin.im>
parents:
21549
diff
changeset
|
222 | } |
|
15708
979f43512119
Added nat-pmp implementation and #ifdef'd out changes to network.c which would utilize it.
Evan Schoenberg <evands@pidgin.im>
parents:
15502
diff
changeset
|
223 | |
|
8834
0a798e3d2b84
[gaim-migrate @ 9598]
Mark Doliner <markdoliner@pidgin.im>
parents:
8251
diff
changeset
|
224 | /* Just fetch the IP of the local system */ |
| 15884 | 225 | return purple_network_get_local_system_ip(fd); |
| 8231 | 226 | } |
| 227 | ||
|
11391
d172e72988cc
[gaim-migrate @ 13620]
Adam Warrington <awarring@users.sourceforge.net>
parents:
11336
diff
changeset
|
228 | |
|
12909
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12730
diff
changeset
|
229 | static void |
| 15884 | 230 | purple_network_set_upnp_port_mapping_cb(gboolean success, gpointer data) |
|
12909
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12730
diff
changeset
|
231 | { |
| 15884 | 232 | PurpleNetworkListenData *listen_data; |
|
14329
05c3cc0c1f79
[gaim-migrate @ 16949]
Mark Doliner <markdoliner@pidgin.im>
parents:
14254
diff
changeset
|
233 | |
|
05c3cc0c1f79
[gaim-migrate @ 16949]
Mark Doliner <markdoliner@pidgin.im>
parents:
14254
diff
changeset
|
234 | listen_data = data; |
|
05c3cc0c1f79
[gaim-migrate @ 16949]
Mark Doliner <markdoliner@pidgin.im>
parents:
14254
diff
changeset
|
235 | /* TODO: Once we're keeping track of upnp requests... */ |
|
05c3cc0c1f79
[gaim-migrate @ 16949]
Mark Doliner <markdoliner@pidgin.im>
parents:
14254
diff
changeset
|
236 | /* listen_data->pnp_data = NULL; */ |
|
12909
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12730
diff
changeset
|
237 | |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12730
diff
changeset
|
238 | if (!success) { |
| 15884 | 239 | purple_debug_info("network", "Couldn't create UPnP mapping\n"); |
|
14329
05c3cc0c1f79
[gaim-migrate @ 16949]
Mark Doliner <markdoliner@pidgin.im>
parents:
14254
diff
changeset
|
240 | if (listen_data->retry) { |
|
05c3cc0c1f79
[gaim-migrate @ 16949]
Mark Doliner <markdoliner@pidgin.im>
parents:
14254
diff
changeset
|
241 | listen_data->retry = FALSE; |
|
05c3cc0c1f79
[gaim-migrate @ 16949]
Mark Doliner <markdoliner@pidgin.im>
parents:
14254
diff
changeset
|
242 | listen_data->adding = FALSE; |
| 15884 | 243 | listen_data->mapping_data = purple_upnp_remove_port_mapping( |
| 244 | purple_network_get_port_from_fd(listen_data->listenfd), | |
|
15502
250802f80d94
Fix a crash when a network_listen_range process is canceled before its UPnP port mapping completes, which occurs regularly on certain routers when file transfers are initiated and then quickly finished. Much thanks to Elliott Harris and Eric Richie for their hard work with me hunting this down and fixing it.
Evan Schoenberg <evands@pidgin.im>
parents:
15435
diff
changeset
|
245 | (listen_data->socket_type == SOCK_STREAM) ? "TCP" : "UDP", |
| 15884 | 246 | purple_network_set_upnp_port_mapping_cb, listen_data); |
|
12909
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12730
diff
changeset
|
247 | return; |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12730
diff
changeset
|
248 | } |
|
14329
05c3cc0c1f79
[gaim-migrate @ 16949]
Mark Doliner <markdoliner@pidgin.im>
parents:
14254
diff
changeset
|
249 | } else if (!listen_data->adding) { |
|
12909
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12730
diff
changeset
|
250 | /* We've tried successfully to remove the port mapping. |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12730
diff
changeset
|
251 | * Try to add it again */ |
|
14329
05c3cc0c1f79
[gaim-migrate @ 16949]
Mark Doliner <markdoliner@pidgin.im>
parents:
14254
diff
changeset
|
252 | listen_data->adding = TRUE; |
| 15884 | 253 | listen_data->mapping_data = purple_upnp_set_port_mapping( |
| 254 | purple_network_get_port_from_fd(listen_data->listenfd), | |
|
15502
250802f80d94
Fix a crash when a network_listen_range process is canceled before its UPnP port mapping completes, which occurs regularly on certain routers when file transfers are initiated and then quickly finished. Much thanks to Elliott Harris and Eric Richie for their hard work with me hunting this down and fixing it.
Evan Schoenberg <evands@pidgin.im>
parents:
15435
diff
changeset
|
255 | (listen_data->socket_type == SOCK_STREAM) ? "TCP" : "UDP", |
| 15884 | 256 | purple_network_set_upnp_port_mapping_cb, listen_data); |
|
12909
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12730
diff
changeset
|
257 | return; |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12730
diff
changeset
|
258 | } |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12730
diff
changeset
|
259 | |
|
14329
05c3cc0c1f79
[gaim-migrate @ 16949]
Mark Doliner <markdoliner@pidgin.im>
parents:
14254
diff
changeset
|
260 | if (listen_data->cb) |
|
05c3cc0c1f79
[gaim-migrate @ 16949]
Mark Doliner <markdoliner@pidgin.im>
parents:
14254
diff
changeset
|
261 | listen_data->cb(listen_data->listenfd, listen_data->cb_data); |
|
12909
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12730
diff
changeset
|
262 | |
| 15884 | 263 | /* Clear the UPnP mapping data, since it's complete and purple_netweork_listen_cancel() will try to cancel |
|
15502
250802f80d94
Fix a crash when a network_listen_range process is canceled before its UPnP port mapping completes, which occurs regularly on certain routers when file transfers are initiated and then quickly finished. Much thanks to Elliott Harris and Eric Richie for their hard work with me hunting this down and fixing it.
Evan Schoenberg <evands@pidgin.im>
parents:
15435
diff
changeset
|
264 | * it otherwise. */ |
|
250802f80d94
Fix a crash when a network_listen_range process is canceled before its UPnP port mapping completes, which occurs regularly on certain routers when file transfers are initiated and then quickly finished. Much thanks to Elliott Harris and Eric Richie for their hard work with me hunting this down and fixing it.
Evan Schoenberg <evands@pidgin.im>
parents:
15435
diff
changeset
|
265 | listen_data->mapping_data = NULL; |
| 15884 | 266 | purple_network_listen_cancel(listen_data); |
|
12909
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12730
diff
changeset
|
267 | } |
|
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12730
diff
changeset
|
268 | |
|
15933
913ba1d4b81c
nat-pmp is now functional with a compatible router. I'm not enabling this code yet because it hasn't been tested with a router which doesn't support nat-pmp.
Evan Schoenberg <evands@pidgin.im>
parents:
15884
diff
changeset
|
269 | static gboolean |
|
913ba1d4b81c
nat-pmp is now functional with a compatible router. I'm not enabling this code yet because it hasn't been tested with a router which doesn't support nat-pmp.
Evan Schoenberg <evands@pidgin.im>
parents:
15884
diff
changeset
|
270 | purple_network_finish_pmp_map_cb(gpointer data) |
|
913ba1d4b81c
nat-pmp is now functional with a compatible router. I'm not enabling this code yet because it hasn't been tested with a router which doesn't support nat-pmp.
Evan Schoenberg <evands@pidgin.im>
parents:
15884
diff
changeset
|
271 | { |
|
913ba1d4b81c
nat-pmp is now functional with a compatible router. I'm not enabling this code yet because it hasn't been tested with a router which doesn't support nat-pmp.
Evan Schoenberg <evands@pidgin.im>
parents:
15884
diff
changeset
|
272 | PurpleNetworkListenData *listen_data; |
|
15963
effb28723fee
Whitespace and make sure stuff is #defined to an actual value.
Mark Doliner <markdoliner@pidgin.im>
parents:
15956
diff
changeset
|
273 | |
|
15933
913ba1d4b81c
nat-pmp is now functional with a compatible router. I'm not enabling this code yet because it hasn't been tested with a router which doesn't support nat-pmp.
Evan Schoenberg <evands@pidgin.im>
parents:
15884
diff
changeset
|
274 | listen_data = data; |
|
15963
effb28723fee
Whitespace and make sure stuff is #defined to an actual value.
Mark Doliner <markdoliner@pidgin.im>
parents:
15956
diff
changeset
|
275 | |
|
15933
913ba1d4b81c
nat-pmp is now functional with a compatible router. I'm not enabling this code yet because it hasn't been tested with a router which doesn't support nat-pmp.
Evan Schoenberg <evands@pidgin.im>
parents:
15884
diff
changeset
|
276 | if (listen_data->cb) |
|
913ba1d4b81c
nat-pmp is now functional with a compatible router. I'm not enabling this code yet because it hasn't been tested with a router which doesn't support nat-pmp.
Evan Schoenberg <evands@pidgin.im>
parents:
15884
diff
changeset
|
277 | listen_data->cb(listen_data->listenfd, listen_data->cb_data); |
|
913ba1d4b81c
nat-pmp is now functional with a compatible router. I'm not enabling this code yet because it hasn't been tested with a router which doesn't support nat-pmp.
Evan Schoenberg <evands@pidgin.im>
parents:
15884
diff
changeset
|
278 | |
|
913ba1d4b81c
nat-pmp is now functional with a compatible router. I'm not enabling this code yet because it hasn't been tested with a router which doesn't support nat-pmp.
Evan Schoenberg <evands@pidgin.im>
parents:
15884
diff
changeset
|
279 | purple_network_listen_cancel(listen_data); |
|
913ba1d4b81c
nat-pmp is now functional with a compatible router. I'm not enabling this code yet because it hasn't been tested with a router which doesn't support nat-pmp.
Evan Schoenberg <evands@pidgin.im>
parents:
15884
diff
changeset
|
280 | |
|
913ba1d4b81c
nat-pmp is now functional with a compatible router. I'm not enabling this code yet because it hasn't been tested with a router which doesn't support nat-pmp.
Evan Schoenberg <evands@pidgin.im>
parents:
15884
diff
changeset
|
281 | return FALSE; |
|
913ba1d4b81c
nat-pmp is now functional with a compatible router. I'm not enabling this code yet because it hasn't been tested with a router which doesn't support nat-pmp.
Evan Schoenberg <evands@pidgin.im>
parents:
15884
diff
changeset
|
282 | } |
|
12909
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12730
diff
changeset
|
283 | |
|
21549
7436059db33b
Don't map the port used for bonjour file transfers externally. This adds a new function that will go away in 3.0.0 when we can modify purple_network_do_listen to take an additional parameter.
Daniel Atallah <datallah@pidgin.im>
parents:
21389
diff
changeset
|
284 | static gboolean listen_map_external = TRUE; |
|
7436059db33b
Don't map the port used for bonjour file transfers externally. This adds a new function that will go away in 3.0.0 when we can modify purple_network_do_listen to take an additional parameter.
Daniel Atallah <datallah@pidgin.im>
parents:
21389
diff
changeset
|
285 | void purple_network_listen_map_external(gboolean map_external) |
|
7436059db33b
Don't map the port used for bonjour file transfers externally. This adds a new function that will go away in 3.0.0 when we can modify purple_network_do_listen to take an additional parameter.
Daniel Atallah <datallah@pidgin.im>
parents:
21389
diff
changeset
|
286 | { |
|
7436059db33b
Don't map the port used for bonjour file transfers externally. This adds a new function that will go away in 3.0.0 when we can modify purple_network_do_listen to take an additional parameter.
Daniel Atallah <datallah@pidgin.im>
parents:
21389
diff
changeset
|
287 | listen_map_external = map_external; |
|
7436059db33b
Don't map the port used for bonjour file transfers externally. This adds a new function that will go away in 3.0.0 when we can modify purple_network_do_listen to take an additional parameter.
Daniel Atallah <datallah@pidgin.im>
parents:
21389
diff
changeset
|
288 | } |
|
7436059db33b
Don't map the port used for bonjour file transfers externally. This adds a new function that will go away in 3.0.0 when we can modify purple_network_do_listen to take an additional parameter.
Daniel Atallah <datallah@pidgin.im>
parents:
21389
diff
changeset
|
289 | |
| 15884 | 290 | static PurpleNetworkListenData * |
| 291 | purple_network_do_listen(unsigned short port, int socket_type, PurpleNetworkListenCallback cb, gpointer cb_data) | |
| 8231 | 292 | { |
|
9452
0e3cdb898d3e
[gaim-migrate @ 10276]
Mark Doliner <markdoliner@pidgin.im>
parents:
9449
diff
changeset
|
293 | int listenfd = -1; |
|
20239
ae122f419324
applied changes from 2762c6075c0dc52a96098c5478c5bf68cfd890a3
Luke Schierer <lschiere@pidgin.im>
parents:
20147
diff
changeset
|
294 | int flags; |
| 8231 | 295 | const int on = 1; |
| 15884 | 296 | PurpleNetworkListenData *listen_data; |
|
15708
979f43512119
Added nat-pmp implementation and #ifdef'd out changes to network.c which would utilize it.
Evan Schoenberg <evands@pidgin.im>
parents:
15502
diff
changeset
|
297 | unsigned short actual_port; |
|
13426
032ea2c9ce2d
[gaim-migrate @ 15800]
Daniel Atallah <datallah@pidgin.im>
parents:
13346
diff
changeset
|
298 | #ifdef HAVE_GETADDRINFO |
|
9449
8c5a1697bca6
[gaim-migrate @ 10273]
Mark Doliner <markdoliner@pidgin.im>
parents:
8981
diff
changeset
|
299 | int errnum; |
|
8c5a1697bca6
[gaim-migrate @ 10273]
Mark Doliner <markdoliner@pidgin.im>
parents:
8981
diff
changeset
|
300 | struct addrinfo hints, *res, *next; |
| 9456 | 301 | char serv[6]; |
| 8231 | 302 | |
|
9449
8c5a1697bca6
[gaim-migrate @ 10273]
Mark Doliner <markdoliner@pidgin.im>
parents:
8981
diff
changeset
|
303 | /* |
|
8c5a1697bca6
[gaim-migrate @ 10273]
Mark Doliner <markdoliner@pidgin.im>
parents:
8981
diff
changeset
|
304 | * Get a list of addresses on this machine. |
|
8c5a1697bca6
[gaim-migrate @ 10273]
Mark Doliner <markdoliner@pidgin.im>
parents:
8981
diff
changeset
|
305 | */ |
|
8c5a1697bca6
[gaim-migrate @ 10273]
Mark Doliner <markdoliner@pidgin.im>
parents:
8981
diff
changeset
|
306 | snprintf(serv, sizeof(serv), "%hu", port); |
| 8231 | 307 | memset(&hints, 0, sizeof(struct addrinfo)); |
| 308 | hints.ai_flags = AI_PASSIVE; | |
| 309 | hints.ai_family = AF_UNSPEC; | |
|
12730
f64fdbc34677
[gaim-migrate @ 15074]
Daniel Atallah <datallah@pidgin.im>
parents:
12728
diff
changeset
|
310 | hints.ai_socktype = socket_type; |
|
9449
8c5a1697bca6
[gaim-migrate @ 10273]
Mark Doliner <markdoliner@pidgin.im>
parents:
8981
diff
changeset
|
311 | errnum = getaddrinfo(NULL /* any IP */, serv, &hints, &res); |
|
8c5a1697bca6
[gaim-migrate @ 10273]
Mark Doliner <markdoliner@pidgin.im>
parents:
8981
diff
changeset
|
312 | if (errnum != 0) { |
|
11221
be3982550ac0
[gaim-migrate @ 13353]
Daniel Atallah <datallah@pidgin.im>
parents:
11215
diff
changeset
|
313 | #ifndef _WIN32 |
|
21977
c87889698afb
Create a purple_gai_strerror() function similar to g_str_error() which
Mark Doliner <markdoliner@pidgin.im>
parents:
21817
diff
changeset
|
314 | purple_debug_warning("network", "getaddrinfo: %s\n", purple_gai_strerror(errnum)); |
|
9449
8c5a1697bca6
[gaim-migrate @ 10273]
Mark Doliner <markdoliner@pidgin.im>
parents:
8981
diff
changeset
|
315 | if (errnum == EAI_SYSTEM) |
|
21389
e1dd8142bb87
replace most calls to strerror with calls to g_strerror. strerror will return
Nathan Walp <nwalp@pidgin.im>
parents:
20239
diff
changeset
|
316 | purple_debug_warning("network", "getaddrinfo: system error: %s\n", g_strerror(errno)); |
|
11221
be3982550ac0
[gaim-migrate @ 13353]
Daniel Atallah <datallah@pidgin.im>
parents:
11215
diff
changeset
|
317 | #else |
| 15884 | 318 | purple_debug_warning("network", "getaddrinfo: Error Code = %d\n", errnum); |
|
11221
be3982550ac0
[gaim-migrate @ 13353]
Daniel Atallah <datallah@pidgin.im>
parents:
11215
diff
changeset
|
319 | #endif |
|
14329
05c3cc0c1f79
[gaim-migrate @ 16949]
Mark Doliner <markdoliner@pidgin.im>
parents:
14254
diff
changeset
|
320 | return NULL; |
| 8231 | 321 | } |
|
9449
8c5a1697bca6
[gaim-migrate @ 10273]
Mark Doliner <markdoliner@pidgin.im>
parents:
8981
diff
changeset
|
322 | |
|
8c5a1697bca6
[gaim-migrate @ 10273]
Mark Doliner <markdoliner@pidgin.im>
parents:
8981
diff
changeset
|
323 | /* |
|
8c5a1697bca6
[gaim-migrate @ 10273]
Mark Doliner <markdoliner@pidgin.im>
parents:
8981
diff
changeset
|
324 | * Go through the list of addresses and attempt to listen on |
|
8c5a1697bca6
[gaim-migrate @ 10273]
Mark Doliner <markdoliner@pidgin.im>
parents:
8981
diff
changeset
|
325 | * one of them. |
|
8c5a1697bca6
[gaim-migrate @ 10273]
Mark Doliner <markdoliner@pidgin.im>
parents:
8981
diff
changeset
|
326 | * XXX - Try IPv6 addresses first? |
|
8c5a1697bca6
[gaim-migrate @ 10273]
Mark Doliner <markdoliner@pidgin.im>
parents:
8981
diff
changeset
|
327 | */ |
|
8c5a1697bca6
[gaim-migrate @ 10273]
Mark Doliner <markdoliner@pidgin.im>
parents:
8981
diff
changeset
|
328 | for (next = res; next != NULL; next = next->ai_next) { |
| 9455 | 329 | listenfd = socket(next->ai_family, next->ai_socktype, next->ai_protocol); |
| 8231 | 330 | if (listenfd < 0) |
| 331 | continue; | |
|
9449
8c5a1697bca6
[gaim-migrate @ 10273]
Mark Doliner <markdoliner@pidgin.im>
parents:
8981
diff
changeset
|
332 | if (setsockopt(listenfd, SOL_SOCKET, SO_REUSEADDR, &on, sizeof(on)) != 0) |
|
21389
e1dd8142bb87
replace most calls to strerror with calls to g_strerror. strerror will return
Nathan Walp <nwalp@pidgin.im>
parents:
20239
diff
changeset
|
333 | purple_debug_warning("network", "setsockopt: %s\n", g_strerror(errno)); |
| 9455 | 334 | if (bind(listenfd, next->ai_addr, next->ai_addrlen) == 0) |
| 8231 | 335 | break; /* success */ |
|
12730
f64fdbc34677
[gaim-migrate @ 15074]
Daniel Atallah <datallah@pidgin.im>
parents:
12728
diff
changeset
|
336 | /* XXX - It is unclear to me (datallah) whether we need to be |
|
f64fdbc34677
[gaim-migrate @ 15074]
Daniel Atallah <datallah@pidgin.im>
parents:
12728
diff
changeset
|
337 | using a new socket each time */ |
| 8231 | 338 | close(listenfd); |
|
9449
8c5a1697bca6
[gaim-migrate @ 10273]
Mark Doliner <markdoliner@pidgin.im>
parents:
8981
diff
changeset
|
339 | } |
| 8231 | 340 | |
|
9449
8c5a1697bca6
[gaim-migrate @ 10273]
Mark Doliner <markdoliner@pidgin.im>
parents:
8981
diff
changeset
|
341 | freeaddrinfo(res); |
| 8231 | 342 | |
|
9449
8c5a1697bca6
[gaim-migrate @ 10273]
Mark Doliner <markdoliner@pidgin.im>
parents:
8981
diff
changeset
|
343 | if (next == NULL) |
|
14329
05c3cc0c1f79
[gaim-migrate @ 16949]
Mark Doliner <markdoliner@pidgin.im>
parents:
14254
diff
changeset
|
344 | return NULL; |
| 8231 | 345 | #else |
| 346 | struct sockaddr_in sockin; | |
| 347 | ||
|
12730
f64fdbc34677
[gaim-migrate @ 15074]
Daniel Atallah <datallah@pidgin.im>
parents:
12728
diff
changeset
|
348 | if ((listenfd = socket(AF_INET, socket_type, 0)) < 0) { |
|
21389
e1dd8142bb87
replace most calls to strerror with calls to g_strerror. strerror will return
Nathan Walp <nwalp@pidgin.im>
parents:
20239
diff
changeset
|
349 | purple_debug_warning("network", "socket: %s\n", g_strerror(errno)); |
|
14329
05c3cc0c1f79
[gaim-migrate @ 16949]
Mark Doliner <markdoliner@pidgin.im>
parents:
14254
diff
changeset
|
350 | return NULL; |
| 8231 | 351 | } |
| 352 | ||
|
9449
8c5a1697bca6
[gaim-migrate @ 10273]
Mark Doliner <markdoliner@pidgin.im>
parents:
8981
diff
changeset
|
353 | if (setsockopt(listenfd, SOL_SOCKET, SO_REUSEADDR, &on, sizeof(on)) != 0) |
|
21389
e1dd8142bb87
replace most calls to strerror with calls to g_strerror. strerror will return
Nathan Walp <nwalp@pidgin.im>
parents:
20239
diff
changeset
|
354 | purple_debug_warning("network", "setsockopt: %s\n", g_strerror(errno)); |
| 8231 | 355 | |
| 356 | memset(&sockin, 0, sizeof(struct sockaddr_in)); | |
|
9449
8c5a1697bca6
[gaim-migrate @ 10273]
Mark Doliner <markdoliner@pidgin.im>
parents:
8981
diff
changeset
|
357 | sockin.sin_family = PF_INET; |
|
8251
091ca9b900c1
[gaim-migrate @ 8974]
Mark Doliner <markdoliner@pidgin.im>
parents:
8250
diff
changeset
|
358 | sockin.sin_port = htons(port); |
| 8231 | 359 | |
| 360 | if (bind(listenfd, (struct sockaddr *)&sockin, sizeof(struct sockaddr_in)) != 0) { | |
|
21389
e1dd8142bb87
replace most calls to strerror with calls to g_strerror. strerror will return
Nathan Walp <nwalp@pidgin.im>
parents:
20239
diff
changeset
|
361 | purple_debug_warning("network", "bind: %s\n", g_strerror(errno)); |
| 8231 | 362 | close(listenfd); |
|
14329
05c3cc0c1f79
[gaim-migrate @ 16949]
Mark Doliner <markdoliner@pidgin.im>
parents:
14254
diff
changeset
|
363 | return NULL; |
| 8231 | 364 | } |
| 365 | #endif | |
| 366 | ||
|
12730
f64fdbc34677
[gaim-migrate @ 15074]
Daniel Atallah <datallah@pidgin.im>
parents:
12728
diff
changeset
|
367 | if (socket_type == SOCK_STREAM && listen(listenfd, 4) != 0) { |
|
21389
e1dd8142bb87
replace most calls to strerror with calls to g_strerror. strerror will return
Nathan Walp <nwalp@pidgin.im>
parents:
20239
diff
changeset
|
368 | purple_debug_warning("network", "listen: %s\n", g_strerror(errno)); |
| 8231 | 369 | close(listenfd); |
|
14329
05c3cc0c1f79
[gaim-migrate @ 16949]
Mark Doliner <markdoliner@pidgin.im>
parents:
14254
diff
changeset
|
370 | return NULL; |
| 8231 | 371 | } |
|
20239
ae122f419324
applied changes from 2762c6075c0dc52a96098c5478c5bf68cfd890a3
Luke Schierer <lschiere@pidgin.im>
parents:
20147
diff
changeset
|
372 | flags = fcntl(listenfd, F_GETFL); |
|
ae122f419324
applied changes from 2762c6075c0dc52a96098c5478c5bf68cfd890a3
Luke Schierer <lschiere@pidgin.im>
parents:
20147
diff
changeset
|
373 | fcntl(listenfd, F_SETFL, flags | O_NONBLOCK); |
|
24044
3fd74bed3968
More leaks of fds to client processes.
Daniel Atallah <datallah@pidgin.im>
parents:
23352
diff
changeset
|
374 | #ifndef _WIN32 |
|
3fd74bed3968
More leaks of fds to client processes.
Daniel Atallah <datallah@pidgin.im>
parents:
23352
diff
changeset
|
375 | fcntl(listenfd, F_SETFD, FD_CLOEXEC); |
|
3fd74bed3968
More leaks of fds to client processes.
Daniel Atallah <datallah@pidgin.im>
parents:
23352
diff
changeset
|
376 | #endif |
| 15884 | 377 | actual_port = purple_network_get_port_from_fd(listenfd); |
|
11391
d172e72988cc
[gaim-migrate @ 13620]
Adam Warrington <awarring@users.sourceforge.net>
parents:
11336
diff
changeset
|
378 | |
| 15884 | 379 | purple_debug_info("network", "Listening on port: %hu\n", actual_port); |
|
15963
effb28723fee
Whitespace and make sure stuff is #defined to an actual value.
Mark Doliner <markdoliner@pidgin.im>
parents:
15956
diff
changeset
|
380 | |
| 15884 | 381 | listen_data = g_new0(PurpleNetworkListenData, 1); |
|
14329
05c3cc0c1f79
[gaim-migrate @ 16949]
Mark Doliner <markdoliner@pidgin.im>
parents:
14254
diff
changeset
|
382 | listen_data->listenfd = listenfd; |
|
05c3cc0c1f79
[gaim-migrate @ 16949]
Mark Doliner <markdoliner@pidgin.im>
parents:
14254
diff
changeset
|
383 | listen_data->adding = TRUE; |
|
05c3cc0c1f79
[gaim-migrate @ 16949]
Mark Doliner <markdoliner@pidgin.im>
parents:
14254
diff
changeset
|
384 | listen_data->retry = TRUE; |
|
05c3cc0c1f79
[gaim-migrate @ 16949]
Mark Doliner <markdoliner@pidgin.im>
parents:
14254
diff
changeset
|
385 | listen_data->cb = cb; |
|
05c3cc0c1f79
[gaim-migrate @ 16949]
Mark Doliner <markdoliner@pidgin.im>
parents:
14254
diff
changeset
|
386 | listen_data->cb_data = cb_data; |
|
19822
a533aa745702
Store the socket_type in the PurpleNetworkListenData correctly so that callback functions can use it correctly. Fixes #2933.
Daniel Atallah <datallah@pidgin.im>
parents:
19585
diff
changeset
|
387 | listen_data->socket_type = socket_type; |
|
11195
d84d542a04ac
[gaim-migrate @ 13319]
Adam Warrington <awarring@users.sourceforge.net>
parents:
11033
diff
changeset
|
388 | |
|
21810
0b5181178201
Allow UPnP and NAT-PMP port mapping to be disabled via a pref. This means that UPnP discovery will not occur if this new pref and the "Autodetect IP Address" pref are both unchecked. Fixes #4157.
Daniel Atallah <datallah@pidgin.im>
parents:
21549
diff
changeset
|
389 | if (!listen_map_external || !purple_prefs_get_bool("/purple/network/map_ports")) |
|
21549
7436059db33b
Don't map the port used for bonjour file transfers externally. This adds a new function that will go away in 3.0.0 when we can modify purple_network_do_listen to take an additional parameter.
Daniel Atallah <datallah@pidgin.im>
parents:
21389
diff
changeset
|
390 | { |
|
7436059db33b
Don't map the port used for bonjour file transfers externally. This adds a new function that will go away in 3.0.0 when we can modify purple_network_do_listen to take an additional parameter.
Daniel Atallah <datallah@pidgin.im>
parents:
21389
diff
changeset
|
391 | purple_debug_info("network", "Skipping external port mapping.\n"); |
|
7436059db33b
Don't map the port used for bonjour file transfers externally. This adds a new function that will go away in 3.0.0 when we can modify purple_network_do_listen to take an additional parameter.
Daniel Atallah <datallah@pidgin.im>
parents:
21389
diff
changeset
|
392 | /* The pmp_map_cb does what we want to do */ |
|
7436059db33b
Don't map the port used for bonjour file transfers externally. This adds a new function that will go away in 3.0.0 when we can modify purple_network_do_listen to take an additional parameter.
Daniel Atallah <datallah@pidgin.im>
parents:
21389
diff
changeset
|
393 | purple_timeout_add(0, purple_network_finish_pmp_map_cb, listen_data); |
|
7436059db33b
Don't map the port used for bonjour file transfers externally. This adds a new function that will go away in 3.0.0 when we can modify purple_network_do_listen to take an additional parameter.
Daniel Atallah <datallah@pidgin.im>
parents:
21389
diff
changeset
|
394 | } |
|
15708
979f43512119
Added nat-pmp implementation and #ifdef'd out changes to network.c which would utilize it.
Evan Schoenberg <evands@pidgin.im>
parents:
15502
diff
changeset
|
395 | /* Attempt a NAT-PMP Mapping, which will return immediately */ |
|
21549
7436059db33b
Don't map the port used for bonjour file transfers externally. This adds a new function that will go away in 3.0.0 when we can modify purple_network_do_listen to take an additional parameter.
Daniel Atallah <datallah@pidgin.im>
parents:
21389
diff
changeset
|
396 | else if (purple_pmp_create_map(((socket_type == SOCK_STREAM) ? PURPLE_PMP_TYPE_TCP : PURPLE_PMP_TYPE_UDP), |
|
16012
77b7fe1bfe69
purple_pmp_create_map() returns a gboolean now, not a pointer
Evan Schoenberg <evands@pidgin.im>
parents:
15963
diff
changeset
|
397 | actual_port, actual_port, PURPLE_PMP_LIFETIME)) |
|
15933
913ba1d4b81c
nat-pmp is now functional with a compatible router. I'm not enabling this code yet because it hasn't been tested with a router which doesn't support nat-pmp.
Evan Schoenberg <evands@pidgin.im>
parents:
15884
diff
changeset
|
398 | { |
|
21549
7436059db33b
Don't map the port used for bonjour file transfers externally. This adds a new function that will go away in 3.0.0 when we can modify purple_network_do_listen to take an additional parameter.
Daniel Atallah <datallah@pidgin.im>
parents:
21389
diff
changeset
|
399 | purple_debug_info("network", "Created NAT-PMP mapping on port %i\n", actual_port); |
|
15933
913ba1d4b81c
nat-pmp is now functional with a compatible router. I'm not enabling this code yet because it hasn't been tested with a router which doesn't support nat-pmp.
Evan Schoenberg <evands@pidgin.im>
parents:
15884
diff
changeset
|
400 | /* We want to return listen_data now, and on the next run loop trigger the cb and destroy listen_data */ |
|
913ba1d4b81c
nat-pmp is now functional with a compatible router. I'm not enabling this code yet because it hasn't been tested with a router which doesn't support nat-pmp.
Evan Schoenberg <evands@pidgin.im>
parents:
15884
diff
changeset
|
401 | purple_timeout_add(0, purple_network_finish_pmp_map_cb, listen_data); |
|
913ba1d4b81c
nat-pmp is now functional with a compatible router. I'm not enabling this code yet because it hasn't been tested with a router which doesn't support nat-pmp.
Evan Schoenberg <evands@pidgin.im>
parents:
15884
diff
changeset
|
402 | } |
|
913ba1d4b81c
nat-pmp is now functional with a compatible router. I'm not enabling this code yet because it hasn't been tested with a router which doesn't support nat-pmp.
Evan Schoenberg <evands@pidgin.im>
parents:
15884
diff
changeset
|
403 | else |
|
913ba1d4b81c
nat-pmp is now functional with a compatible router. I'm not enabling this code yet because it hasn't been tested with a router which doesn't support nat-pmp.
Evan Schoenberg <evands@pidgin.im>
parents:
15884
diff
changeset
|
404 | { |
|
913ba1d4b81c
nat-pmp is now functional with a compatible router. I'm not enabling this code yet because it hasn't been tested with a router which doesn't support nat-pmp.
Evan Schoenberg <evands@pidgin.im>
parents:
15884
diff
changeset
|
405 | /* Attempt a UPnP Mapping */ |
|
913ba1d4b81c
nat-pmp is now functional with a compatible router. I'm not enabling this code yet because it hasn't been tested with a router which doesn't support nat-pmp.
Evan Schoenberg <evands@pidgin.im>
parents:
15884
diff
changeset
|
406 | listen_data->mapping_data = purple_upnp_set_port_mapping( |
|
913ba1d4b81c
nat-pmp is now functional with a compatible router. I'm not enabling this code yet because it hasn't been tested with a router which doesn't support nat-pmp.
Evan Schoenberg <evands@pidgin.im>
parents:
15884
diff
changeset
|
407 | actual_port, |
|
913ba1d4b81c
nat-pmp is now functional with a compatible router. I'm not enabling this code yet because it hasn't been tested with a router which doesn't support nat-pmp.
Evan Schoenberg <evands@pidgin.im>
parents:
15884
diff
changeset
|
408 | (socket_type == SOCK_STREAM) ? "TCP" : "UDP", |
|
913ba1d4b81c
nat-pmp is now functional with a compatible router. I'm not enabling this code yet because it hasn't been tested with a router which doesn't support nat-pmp.
Evan Schoenberg <evands@pidgin.im>
parents:
15884
diff
changeset
|
409 | purple_network_set_upnp_port_mapping_cb, listen_data); |
|
913ba1d4b81c
nat-pmp is now functional with a compatible router. I'm not enabling this code yet because it hasn't been tested with a router which doesn't support nat-pmp.
Evan Schoenberg <evands@pidgin.im>
parents:
15884
diff
changeset
|
410 | } |
|
12909
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12730
diff
changeset
|
411 | |
|
14329
05c3cc0c1f79
[gaim-migrate @ 16949]
Mark Doliner <markdoliner@pidgin.im>
parents:
14254
diff
changeset
|
412 | return listen_data; |
| 8231 | 413 | } |
| 414 | ||
| 15884 | 415 | PurpleNetworkListenData * |
| 416 | purple_network_listen(unsigned short port, int socket_type, | |
| 417 | PurpleNetworkListenCallback cb, gpointer cb_data) | |
|
8246
c83c0421149a
[gaim-migrate @ 8969]
Mark Doliner <markdoliner@pidgin.im>
parents:
8245
diff
changeset
|
418 | { |
|
14329
05c3cc0c1f79
[gaim-migrate @ 16949]
Mark Doliner <markdoliner@pidgin.im>
parents:
14254
diff
changeset
|
419 | g_return_val_if_fail(port != 0, NULL); |
|
8250
e855dcce1fa0
[gaim-migrate @ 8973]
Mark Doliner <markdoliner@pidgin.im>
parents:
8248
diff
changeset
|
420 | |
| 15884 | 421 | return purple_network_do_listen(port, socket_type, cb, cb_data); |
|
8246
c83c0421149a
[gaim-migrate @ 8969]
Mark Doliner <markdoliner@pidgin.im>
parents:
8245
diff
changeset
|
422 | } |
|
c83c0421149a
[gaim-migrate @ 8969]
Mark Doliner <markdoliner@pidgin.im>
parents:
8245
diff
changeset
|
423 | |
| 15884 | 424 | PurpleNetworkListenData * |
| 425 | purple_network_listen_range(unsigned short start, unsigned short end, | |
| 426 | int socket_type, PurpleNetworkListenCallback cb, gpointer cb_data) | |
| 8231 | 427 | { |
| 15884 | 428 | PurpleNetworkListenData *ret = NULL; |
| 8231 | 429 | |
|
16478
19107605c565
Works for me! Renames prefs: /core to /purple, /gaim/gtk to /pidgin, /gaim/gnt to /finch
Sean Egan <seanegan@pidgin.im>
parents:
16035
diff
changeset
|
430 | if (purple_prefs_get_bool("/purple/network/ports_range_use")) { |
|
19107605c565
Works for me! Renames prefs: /core to /purple, /gaim/gtk to /pidgin, /gaim/gnt to /finch
Sean Egan <seanegan@pidgin.im>
parents:
16035
diff
changeset
|
431 | start = purple_prefs_get_int("/purple/network/ports_range_start"); |
|
19107605c565
Works for me! Renames prefs: /core to /purple, /gaim/gtk to /pidgin, /gaim/gnt to /finch
Sean Egan <seanegan@pidgin.im>
parents:
16035
diff
changeset
|
432 | end = purple_prefs_get_int("/purple/network/ports_range_end"); |
|
8250
e855dcce1fa0
[gaim-migrate @ 8973]
Mark Doliner <markdoliner@pidgin.im>
parents:
8248
diff
changeset
|
433 | } else { |
|
e855dcce1fa0
[gaim-migrate @ 8973]
Mark Doliner <markdoliner@pidgin.im>
parents:
8248
diff
changeset
|
434 | if (end < start) |
|
e855dcce1fa0
[gaim-migrate @ 8973]
Mark Doliner <markdoliner@pidgin.im>
parents:
8248
diff
changeset
|
435 | end = start; |
|
8239
d19f1c66720c
[gaim-migrate @ 8962]
Mark Doliner <markdoliner@pidgin.im>
parents:
8231
diff
changeset
|
436 | } |
| 8231 | 437 | |
| 438 | for (; start <= end; start++) { | |
| 15884 | 439 | ret = purple_network_do_listen(start, socket_type, cb, cb_data); |
|
14329
05c3cc0c1f79
[gaim-migrate @ 16949]
Mark Doliner <markdoliner@pidgin.im>
parents:
14254
diff
changeset
|
440 | if (ret != NULL) |
| 8231 | 441 | break; |
| 442 | } | |
| 443 | ||
| 444 | return ret; | |
| 445 | } | |
| 446 | ||
| 15884 | 447 | void purple_network_listen_cancel(PurpleNetworkListenData *listen_data) |
|
14329
05c3cc0c1f79
[gaim-migrate @ 16949]
Mark Doliner <markdoliner@pidgin.im>
parents:
14254
diff
changeset
|
448 | { |
|
15502
250802f80d94
Fix a crash when a network_listen_range process is canceled before its UPnP port mapping completes, which occurs regularly on certain routers when file transfers are initiated and then quickly finished. Much thanks to Elliott Harris and Eric Richie for their hard work with me hunting this down and fixing it.
Evan Schoenberg <evands@pidgin.im>
parents:
15435
diff
changeset
|
449 | if (listen_data->mapping_data != NULL) |
| 15884 | 450 | purple_upnp_cancel_port_mapping(listen_data->mapping_data); |
|
15502
250802f80d94
Fix a crash when a network_listen_range process is canceled before its UPnP port mapping completes, which occurs regularly on certain routers when file transfers are initiated and then quickly finished. Much thanks to Elliott Harris and Eric Richie for their hard work with me hunting this down and fixing it.
Evan Schoenberg <evands@pidgin.im>
parents:
15435
diff
changeset
|
451 | |
|
14329
05c3cc0c1f79
[gaim-migrate @ 16949]
Mark Doliner <markdoliner@pidgin.im>
parents:
14254
diff
changeset
|
452 | g_free(listen_data); |
|
05c3cc0c1f79
[gaim-migrate @ 16949]
Mark Doliner <markdoliner@pidgin.im>
parents:
14254
diff
changeset
|
453 | } |
|
05c3cc0c1f79
[gaim-migrate @ 16949]
Mark Doliner <markdoliner@pidgin.im>
parents:
14254
diff
changeset
|
454 | |
|
8834
0a798e3d2b84
[gaim-migrate @ 9598]
Mark Doliner <markdoliner@pidgin.im>
parents:
8251
diff
changeset
|
455 | unsigned short |
| 15884 | 456 | purple_network_get_port_from_fd(int fd) |
| 8231 | 457 | { |
| 458 | struct sockaddr_in addr; | |
| 459 | socklen_t len; | |
| 460 | ||
|
9449
8c5a1697bca6
[gaim-migrate @ 10273]
Mark Doliner <markdoliner@pidgin.im>
parents:
8981
diff
changeset
|
461 | g_return_val_if_fail(fd >= 0, 0); |
| 8231 | 462 | |
| 463 | len = sizeof(addr); | |
| 464 | if (getsockname(fd, (struct sockaddr *) &addr, &len) == -1) { | |
|
21389
e1dd8142bb87
replace most calls to strerror with calls to g_strerror. strerror will return
Nathan Walp <nwalp@pidgin.im>
parents:
20239
diff
changeset
|
465 | purple_debug_warning("network", "getsockname: %s\n", g_strerror(errno)); |
| 8231 | 466 | return 0; |
| 467 | } | |
| 468 | ||
| 469 | return ntohs(addr.sin_port); | |
| 470 | } | |
| 471 | ||
|
14784
3a82321f46f2
[gaim-migrate @ 17476]
Daniel Atallah <datallah@pidgin.im>
parents:
14758
diff
changeset
|
472 | #ifdef _WIN32 |
|
14853
d06b1f28a8b2
[gaim-migrate @ 17556]
Daniel Atallah <datallah@pidgin.im>
parents:
14842
diff
changeset
|
473 | #ifndef NS_NLA |
|
d06b1f28a8b2
[gaim-migrate @ 17556]
Daniel Atallah <datallah@pidgin.im>
parents:
14842
diff
changeset
|
474 | #define NS_NLA 15 |
|
d06b1f28a8b2
[gaim-migrate @ 17556]
Daniel Atallah <datallah@pidgin.im>
parents:
14842
diff
changeset
|
475 | #endif |
|
14842
fe08ba80d369
[gaim-migrate @ 17544]
Daniel Atallah <datallah@pidgin.im>
parents:
14839
diff
changeset
|
476 | static gint |
| 15884 | 477 | wpurple_get_connected_network_count(void) |
|
14784
3a82321f46f2
[gaim-migrate @ 17476]
Daniel Atallah <datallah@pidgin.im>
parents:
14758
diff
changeset
|
478 | { |
|
19585
14b519abcc26
Fix some conversion warnings about using negative values with unsigned types. There are more, but these were easy fixes. You may think that I'm changing the API, but I'm really not - it was just wrong.
Daniel Atallah <datallah@pidgin.im>
parents:
18555
diff
changeset
|
479 | gint net_cnt = 0; |
|
14784
3a82321f46f2
[gaim-migrate @ 17476]
Daniel Atallah <datallah@pidgin.im>
parents:
14758
diff
changeset
|
480 | |
|
3a82321f46f2
[gaim-migrate @ 17476]
Daniel Atallah <datallah@pidgin.im>
parents:
14758
diff
changeset
|
481 | WSAQUERYSET qs; |
|
3a82321f46f2
[gaim-migrate @ 17476]
Daniel Atallah <datallah@pidgin.im>
parents:
14758
diff
changeset
|
482 | HANDLE h; |
|
14957
1519e663dd9b
[gaim-migrate @ 17667]
Daniel Atallah <datallah@pidgin.im>
parents:
14877
diff
changeset
|
483 | gint retval; |
|
1519e663dd9b
[gaim-migrate @ 17667]
Daniel Atallah <datallah@pidgin.im>
parents:
14877
diff
changeset
|
484 | int errorid; |
|
14784
3a82321f46f2
[gaim-migrate @ 17476]
Daniel Atallah <datallah@pidgin.im>
parents:
14758
diff
changeset
|
485 | |
|
3a82321f46f2
[gaim-migrate @ 17476]
Daniel Atallah <datallah@pidgin.im>
parents:
14758
diff
changeset
|
486 | memset(&qs, 0, sizeof(WSAQUERYSET)); |
|
3a82321f46f2
[gaim-migrate @ 17476]
Daniel Atallah <datallah@pidgin.im>
parents:
14758
diff
changeset
|
487 | qs.dwSize = sizeof(WSAQUERYSET); |
|
14853
d06b1f28a8b2
[gaim-migrate @ 17556]
Daniel Atallah <datallah@pidgin.im>
parents:
14842
diff
changeset
|
488 | qs.dwNameSpace = NS_NLA; |
|
14784
3a82321f46f2
[gaim-migrate @ 17476]
Daniel Atallah <datallah@pidgin.im>
parents:
14758
diff
changeset
|
489 | |
|
3a82321f46f2
[gaim-migrate @ 17476]
Daniel Atallah <datallah@pidgin.im>
parents:
14758
diff
changeset
|
490 | retval = WSALookupServiceBegin(&qs, LUP_RETURN_ALL, &h); |
|
3a82321f46f2
[gaim-migrate @ 17476]
Daniel Atallah <datallah@pidgin.im>
parents:
14758
diff
changeset
|
491 | if (retval != ERROR_SUCCESS) { |
|
14957
1519e663dd9b
[gaim-migrate @ 17667]
Daniel Atallah <datallah@pidgin.im>
parents:
14877
diff
changeset
|
492 | gchar *msg; |
|
1519e663dd9b
[gaim-migrate @ 17667]
Daniel Atallah <datallah@pidgin.im>
parents:
14877
diff
changeset
|
493 | errorid = WSAGetLastError(); |
|
1519e663dd9b
[gaim-migrate @ 17667]
Daniel Atallah <datallah@pidgin.im>
parents:
14877
diff
changeset
|
494 | msg = g_win32_error_message(errorid); |
| 15884 | 495 | purple_debug_warning("network", "Couldn't retrieve NLA SP lookup handle. " |
|
14853
d06b1f28a8b2
[gaim-migrate @ 17556]
Daniel Atallah <datallah@pidgin.im>
parents:
14842
diff
changeset
|
496 | "NLA service is probably not running. Message: %s (%d).\n", |
|
d06b1f28a8b2
[gaim-migrate @ 17556]
Daniel Atallah <datallah@pidgin.im>
parents:
14842
diff
changeset
|
497 | msg, errorid); |
|
14784
3a82321f46f2
[gaim-migrate @ 17476]
Daniel Atallah <datallah@pidgin.im>
parents:
14758
diff
changeset
|
498 | g_free(msg); |
|
14838
40cc5f858426
[gaim-migrate @ 17540]
Daniel Atallah <datallah@pidgin.im>
parents:
14784
diff
changeset
|
499 | |
|
14842
fe08ba80d369
[gaim-migrate @ 17544]
Daniel Atallah <datallah@pidgin.im>
parents:
14839
diff
changeset
|
500 | return -1; |
|
14784
3a82321f46f2
[gaim-migrate @ 17476]
Daniel Atallah <datallah@pidgin.im>
parents:
14758
diff
changeset
|
501 | } else { |
|
14959
eb5cf3522fda
[gaim-migrate @ 17669]
Daniel Atallah <datallah@pidgin.im>
parents:
14957
diff
changeset
|
502 | char buf[4096]; |
|
14784
3a82321f46f2
[gaim-migrate @ 17476]
Daniel Atallah <datallah@pidgin.im>
parents:
14758
diff
changeset
|
503 | WSAQUERYSET *res = (LPWSAQUERYSET) buf; |
|
3a82321f46f2
[gaim-migrate @ 17476]
Daniel Atallah <datallah@pidgin.im>
parents:
14758
diff
changeset
|
504 | DWORD size = sizeof(buf); |
|
14957
1519e663dd9b
[gaim-migrate @ 17667]
Daniel Atallah <datallah@pidgin.im>
parents:
14877
diff
changeset
|
505 | while ((retval = WSALookupServiceNext(h, 0, &size, res)) == ERROR_SUCCESS) { |
|
14784
3a82321f46f2
[gaim-migrate @ 17476]
Daniel Atallah <datallah@pidgin.im>
parents:
14758
diff
changeset
|
506 | net_cnt++; |
| 15884 | 507 | purple_debug_info("network", "found network '%s'\n", |
|
14784
3a82321f46f2
[gaim-migrate @ 17476]
Daniel Atallah <datallah@pidgin.im>
parents:
14758
diff
changeset
|
508 | res->lpszServiceInstanceName ? res->lpszServiceInstanceName : "(NULL)"); |
|
3a82321f46f2
[gaim-migrate @ 17476]
Daniel Atallah <datallah@pidgin.im>
parents:
14758
diff
changeset
|
509 | size = sizeof(buf); |
|
3a82321f46f2
[gaim-migrate @ 17476]
Daniel Atallah <datallah@pidgin.im>
parents:
14758
diff
changeset
|
510 | } |
|
3a82321f46f2
[gaim-migrate @ 17476]
Daniel Atallah <datallah@pidgin.im>
parents:
14758
diff
changeset
|
511 | |
|
14957
1519e663dd9b
[gaim-migrate @ 17667]
Daniel Atallah <datallah@pidgin.im>
parents:
14877
diff
changeset
|
512 | errorid = WSAGetLastError(); |
|
1519e663dd9b
[gaim-migrate @ 17667]
Daniel Atallah <datallah@pidgin.im>
parents:
14877
diff
changeset
|
513 | if (!(errorid == WSA_E_NO_MORE || errorid == WSAENOMORE)) { |
|
1519e663dd9b
[gaim-migrate @ 17667]
Daniel Atallah <datallah@pidgin.im>
parents:
14877
diff
changeset
|
514 | gchar *msg = g_win32_error_message(errorid); |
| 15884 | 515 | purple_debug_error("network", "got unexpected NLA response %s (%d)\n", msg, errorid); |
|
14957
1519e663dd9b
[gaim-migrate @ 17667]
Daniel Atallah <datallah@pidgin.im>
parents:
14877
diff
changeset
|
516 | g_free(msg); |
|
1519e663dd9b
[gaim-migrate @ 17667]
Daniel Atallah <datallah@pidgin.im>
parents:
14877
diff
changeset
|
517 | |
|
1519e663dd9b
[gaim-migrate @ 17667]
Daniel Atallah <datallah@pidgin.im>
parents:
14877
diff
changeset
|
518 | net_cnt = -1; |
|
1519e663dd9b
[gaim-migrate @ 17667]
Daniel Atallah <datallah@pidgin.im>
parents:
14877
diff
changeset
|
519 | } |
|
1519e663dd9b
[gaim-migrate @ 17667]
Daniel Atallah <datallah@pidgin.im>
parents:
14877
diff
changeset
|
520 | |
|
1519e663dd9b
[gaim-migrate @ 17667]
Daniel Atallah <datallah@pidgin.im>
parents:
14877
diff
changeset
|
521 | retval = WSALookupServiceEnd(h); |
|
14784
3a82321f46f2
[gaim-migrate @ 17476]
Daniel Atallah <datallah@pidgin.im>
parents:
14758
diff
changeset
|
522 | } |
|
3a82321f46f2
[gaim-migrate @ 17476]
Daniel Atallah <datallah@pidgin.im>
parents:
14758
diff
changeset
|
523 | |
|
3a82321f46f2
[gaim-migrate @ 17476]
Daniel Atallah <datallah@pidgin.im>
parents:
14758
diff
changeset
|
524 | return net_cnt; |
|
3a82321f46f2
[gaim-migrate @ 17476]
Daniel Atallah <datallah@pidgin.im>
parents:
14758
diff
changeset
|
525 | |
|
3a82321f46f2
[gaim-migrate @ 17476]
Daniel Atallah <datallah@pidgin.im>
parents:
14758
diff
changeset
|
526 | } |
|
3a82321f46f2
[gaim-migrate @ 17476]
Daniel Atallah <datallah@pidgin.im>
parents:
14758
diff
changeset
|
527 | |
| 15884 | 528 | static gboolean wpurple_network_change_thread_cb(gpointer data) |
|
14784
3a82321f46f2
[gaim-migrate @ 17476]
Daniel Atallah <datallah@pidgin.im>
parents:
14758
diff
changeset
|
529 | { |
|
14842
fe08ba80d369
[gaim-migrate @ 17544]
Daniel Atallah <datallah@pidgin.im>
parents:
14839
diff
changeset
|
530 | gint new_count; |
| 15884 | 531 | PurpleConnectionUiOps *ui_ops = purple_connections_get_ui_ops(); |
|
14784
3a82321f46f2
[gaim-migrate @ 17476]
Daniel Atallah <datallah@pidgin.im>
parents:
14758
diff
changeset
|
532 | |
| 15884 | 533 | new_count = wpurple_get_connected_network_count(); |
|
14784
3a82321f46f2
[gaim-migrate @ 17476]
Daniel Atallah <datallah@pidgin.im>
parents:
14758
diff
changeset
|
534 | |
|
14842
fe08ba80d369
[gaim-migrate @ 17544]
Daniel Atallah <datallah@pidgin.im>
parents:
14839
diff
changeset
|
535 | if (new_count < 0) |
|
fe08ba80d369
[gaim-migrate @ 17544]
Daniel Atallah <datallah@pidgin.im>
parents:
14839
diff
changeset
|
536 | return FALSE; |
|
fe08ba80d369
[gaim-migrate @ 17544]
Daniel Atallah <datallah@pidgin.im>
parents:
14839
diff
changeset
|
537 | |
| 15884 | 538 | purple_debug_info("network", "Received Network Change Notification. Current network count is %d, previous count was %d.\n", new_count, current_network_count); |
|
14784
3a82321f46f2
[gaim-migrate @ 17476]
Daniel Atallah <datallah@pidgin.im>
parents:
14758
diff
changeset
|
539 | |
|
16035
eb4eda79a147
The network module now registers the signal 'network-configuration-changed' and emits it when a network change is detected via libnm or the win32 network monitor. The UI could also emit this signal if it knows something network.c doesn't. UPnP and NAT-PMP respond to the signal by clearing their IP address caches; changing networks without quitting/relaunching will now lead to the new IP address being (lazily) determined. This commit also enables nat-pmp and adds nat-pmp.[h|c] to the build process; please let me know if there are any problems building, as I only have OS X test machines.
Evan Schoenberg <evands@pidgin.im>
parents:
16012
diff
changeset
|
540 | purple_signal_emit(purple_network_get_handle(), "network-configuration-changed", NULL); |
|
eb4eda79a147
The network module now registers the signal 'network-configuration-changed' and emits it when a network change is detected via libnm or the win32 network monitor. The UI could also emit this signal if it knows something network.c doesn't. UPnP and NAT-PMP respond to the signal by clearing their IP address caches; changing networks without quitting/relaunching will now lead to the new IP address being (lazily) determined. This commit also enables nat-pmp and adds nat-pmp.[h|c] to the build process; please let me know if there are any problems building, as I only have OS X test machines.
Evan Schoenberg <evands@pidgin.im>
parents:
16012
diff
changeset
|
541 | |
|
14877
084d14fe0445
[gaim-migrate @ 17581]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
14864
diff
changeset
|
542 | if (new_count > 0 && ui_ops != NULL && ui_ops->network_connected != NULL) { |
|
14784
3a82321f46f2
[gaim-migrate @ 17476]
Daniel Atallah <datallah@pidgin.im>
parents:
14758
diff
changeset
|
543 | ui_ops->network_connected(); |
|
14877
084d14fe0445
[gaim-migrate @ 17581]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
14864
diff
changeset
|
544 | } else if (new_count == 0 && current_network_count > 0 && |
|
084d14fe0445
[gaim-migrate @ 17581]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
14864
diff
changeset
|
545 | ui_ops != NULL && ui_ops->network_disconnected != NULL) { |
|
14784
3a82321f46f2
[gaim-migrate @ 17476]
Daniel Atallah <datallah@pidgin.im>
parents:
14758
diff
changeset
|
546 | ui_ops->network_disconnected(); |
|
3a82321f46f2
[gaim-migrate @ 17476]
Daniel Atallah <datallah@pidgin.im>
parents:
14758
diff
changeset
|
547 | } |
|
3a82321f46f2
[gaim-migrate @ 17476]
Daniel Atallah <datallah@pidgin.im>
parents:
14758
diff
changeset
|
548 | |
|
3a82321f46f2
[gaim-migrate @ 17476]
Daniel Atallah <datallah@pidgin.im>
parents:
14758
diff
changeset
|
549 | current_network_count = new_count; |
|
3a82321f46f2
[gaim-migrate @ 17476]
Daniel Atallah <datallah@pidgin.im>
parents:
14758
diff
changeset
|
550 | |
|
3a82321f46f2
[gaim-migrate @ 17476]
Daniel Atallah <datallah@pidgin.im>
parents:
14758
diff
changeset
|
551 | return FALSE; |
|
3a82321f46f2
[gaim-migrate @ 17476]
Daniel Atallah <datallah@pidgin.im>
parents:
14758
diff
changeset
|
552 | } |
|
3a82321f46f2
[gaim-migrate @ 17476]
Daniel Atallah <datallah@pidgin.im>
parents:
14758
diff
changeset
|
553 | |
|
25541
1b82a0195ff5
Fix 3 different race conditions in the win32 network management functionality.
Daniel Atallah <datallah@pidgin.im>
parents:
25326
diff
changeset
|
554 | static gboolean _print_debug_msg(gpointer data) { |
|
1b82a0195ff5
Fix 3 different race conditions in the win32 network management functionality.
Daniel Atallah <datallah@pidgin.im>
parents:
25326
diff
changeset
|
555 | gchar *msg = data; |
|
1b82a0195ff5
Fix 3 different race conditions in the win32 network management functionality.
Daniel Atallah <datallah@pidgin.im>
parents:
25326
diff
changeset
|
556 | purple_debug_warning("network", msg); |
|
1b82a0195ff5
Fix 3 different race conditions in the win32 network management functionality.
Daniel Atallah <datallah@pidgin.im>
parents:
25326
diff
changeset
|
557 | g_free(msg); |
|
1b82a0195ff5
Fix 3 different race conditions in the win32 network management functionality.
Daniel Atallah <datallah@pidgin.im>
parents:
25326
diff
changeset
|
558 | return FALSE; |
|
1b82a0195ff5
Fix 3 different race conditions in the win32 network management functionality.
Daniel Atallah <datallah@pidgin.im>
parents:
25326
diff
changeset
|
559 | } |
|
1b82a0195ff5
Fix 3 different race conditions in the win32 network management functionality.
Daniel Atallah <datallah@pidgin.im>
parents:
25326
diff
changeset
|
560 | |
| 15884 | 561 | static gpointer wpurple_network_change_thread(gpointer data) |
|
14784
3a82321f46f2
[gaim-migrate @ 17476]
Daniel Atallah <datallah@pidgin.im>
parents:
14758
diff
changeset
|
562 | { |
|
3a82321f46f2
[gaim-migrate @ 17476]
Daniel Atallah <datallah@pidgin.im>
parents:
14758
diff
changeset
|
563 | WSAQUERYSET qs; |
|
25326
c4f4b222dbac
Adjust the NLA code to prevent hang on exit for Windows XP and Windows Vista.
Paul Aurich <darkrain42@pidgin.im>
parents:
24519
diff
changeset
|
564 | WSAEVENT *nla_event; |
|
25541
1b82a0195ff5
Fix 3 different race conditions in the win32 network management functionality.
Daniel Atallah <datallah@pidgin.im>
parents:
25326
diff
changeset
|
565 | time_t last_trigger = time(NULL) - 31; |
|
1b82a0195ff5
Fix 3 different race conditions in the win32 network management functionality.
Daniel Atallah <datallah@pidgin.im>
parents:
25326
diff
changeset
|
566 | char buf[4096]; |
|
1b82a0195ff5
Fix 3 different race conditions in the win32 network management functionality.
Daniel Atallah <datallah@pidgin.im>
parents:
25326
diff
changeset
|
567 | WSAQUERYSET *res = (LPWSAQUERYSET) buf; |
|
1b82a0195ff5
Fix 3 different race conditions in the win32 network management functionality.
Daniel Atallah <datallah@pidgin.im>
parents:
25326
diff
changeset
|
568 | DWORD size; |
|
14784
3a82321f46f2
[gaim-migrate @ 17476]
Daniel Atallah <datallah@pidgin.im>
parents:
14758
diff
changeset
|
569 | |
|
25326
c4f4b222dbac
Adjust the NLA code to prevent hang on exit for Windows XP and Windows Vista.
Paul Aurich <darkrain42@pidgin.im>
parents:
24519
diff
changeset
|
570 | if ((nla_event = WSACreateEvent()) == WSA_INVALID_EVENT) { |
|
c4f4b222dbac
Adjust the NLA code to prevent hang on exit for Windows XP and Windows Vista.
Paul Aurich <darkrain42@pidgin.im>
parents:
24519
diff
changeset
|
571 | int errorid = WSAGetLastError(); |
|
c4f4b222dbac
Adjust the NLA code to prevent hang on exit for Windows XP and Windows Vista.
Paul Aurich <darkrain42@pidgin.im>
parents:
24519
diff
changeset
|
572 | gchar *msg = g_win32_error_message(errorid); |
|
25541
1b82a0195ff5
Fix 3 different race conditions in the win32 network management functionality.
Daniel Atallah <datallah@pidgin.im>
parents:
25326
diff
changeset
|
573 | purple_timeout_add(0, _print_debug_msg, |
|
1b82a0195ff5
Fix 3 different race conditions in the win32 network management functionality.
Daniel Atallah <datallah@pidgin.im>
parents:
25326
diff
changeset
|
574 | g_strdup_printf("Couldn't create WSA event. " |
|
1b82a0195ff5
Fix 3 different race conditions in the win32 network management functionality.
Daniel Atallah <datallah@pidgin.im>
parents:
25326
diff
changeset
|
575 | "Message: %s (%d).\n", msg, errorid)); |
|
25326
c4f4b222dbac
Adjust the NLA code to prevent hang on exit for Windows XP and Windows Vista.
Paul Aurich <darkrain42@pidgin.im>
parents:
24519
diff
changeset
|
576 | g_free(msg); |
|
c4f4b222dbac
Adjust the NLA code to prevent hang on exit for Windows XP and Windows Vista.
Paul Aurich <darkrain42@pidgin.im>
parents:
24519
diff
changeset
|
577 | g_thread_exit(NULL); |
|
c4f4b222dbac
Adjust the NLA code to prevent hang on exit for Windows XP and Windows Vista.
Paul Aurich <darkrain42@pidgin.im>
parents:
24519
diff
changeset
|
578 | return NULL; |
|
c4f4b222dbac
Adjust the NLA code to prevent hang on exit for Windows XP and Windows Vista.
Paul Aurich <darkrain42@pidgin.im>
parents:
24519
diff
changeset
|
579 | } |
|
c4f4b222dbac
Adjust the NLA code to prevent hang on exit for Windows XP and Windows Vista.
Paul Aurich <darkrain42@pidgin.im>
parents:
24519
diff
changeset
|
580 | |
|
14784
3a82321f46f2
[gaim-migrate @ 17476]
Daniel Atallah <datallah@pidgin.im>
parents:
14758
diff
changeset
|
581 | while (TRUE) { |
|
3a82321f46f2
[gaim-migrate @ 17476]
Daniel Atallah <datallah@pidgin.im>
parents:
14758
diff
changeset
|
582 | int retval; |
|
3a82321f46f2
[gaim-migrate @ 17476]
Daniel Atallah <datallah@pidgin.im>
parents:
14758
diff
changeset
|
583 | DWORD retLen = 0; |
|
25326
c4f4b222dbac
Adjust the NLA code to prevent hang on exit for Windows XP and Windows Vista.
Paul Aurich <darkrain42@pidgin.im>
parents:
24519
diff
changeset
|
584 | WSACOMPLETION completion; |
|
c4f4b222dbac
Adjust the NLA code to prevent hang on exit for Windows XP and Windows Vista.
Paul Aurich <darkrain42@pidgin.im>
parents:
24519
diff
changeset
|
585 | WSAOVERLAPPED overlapped; |
|
c4f4b222dbac
Adjust the NLA code to prevent hang on exit for Windows XP and Windows Vista.
Paul Aurich <darkrain42@pidgin.im>
parents:
24519
diff
changeset
|
586 | |
|
c4f4b222dbac
Adjust the NLA code to prevent hang on exit for Windows XP and Windows Vista.
Paul Aurich <darkrain42@pidgin.im>
parents:
24519
diff
changeset
|
587 | g_static_mutex_lock(&mutex); |
|
c4f4b222dbac
Adjust the NLA code to prevent hang on exit for Windows XP and Windows Vista.
Paul Aurich <darkrain42@pidgin.im>
parents:
24519
diff
changeset
|
588 | if (network_initialized == FALSE) { |
|
c4f4b222dbac
Adjust the NLA code to prevent hang on exit for Windows XP and Windows Vista.
Paul Aurich <darkrain42@pidgin.im>
parents:
24519
diff
changeset
|
589 | /* purple_network_uninit has been called */ |
|
c4f4b222dbac
Adjust the NLA code to prevent hang on exit for Windows XP and Windows Vista.
Paul Aurich <darkrain42@pidgin.im>
parents:
24519
diff
changeset
|
590 | WSACloseEvent(nla_event); |
|
c4f4b222dbac
Adjust the NLA code to prevent hang on exit for Windows XP and Windows Vista.
Paul Aurich <darkrain42@pidgin.im>
parents:
24519
diff
changeset
|
591 | g_static_mutex_unlock(&mutex); |
|
c4f4b222dbac
Adjust the NLA code to prevent hang on exit for Windows XP and Windows Vista.
Paul Aurich <darkrain42@pidgin.im>
parents:
24519
diff
changeset
|
592 | g_thread_exit(NULL); |
|
c4f4b222dbac
Adjust the NLA code to prevent hang on exit for Windows XP and Windows Vista.
Paul Aurich <darkrain42@pidgin.im>
parents:
24519
diff
changeset
|
593 | return NULL; |
|
c4f4b222dbac
Adjust the NLA code to prevent hang on exit for Windows XP and Windows Vista.
Paul Aurich <darkrain42@pidgin.im>
parents:
24519
diff
changeset
|
594 | } |
|
14784
3a82321f46f2
[gaim-migrate @ 17476]
Daniel Atallah <datallah@pidgin.im>
parents:
14758
diff
changeset
|
595 | |
|
25541
1b82a0195ff5
Fix 3 different race conditions in the win32 network management functionality.
Daniel Atallah <datallah@pidgin.im>
parents:
25326
diff
changeset
|
596 | if (network_change_handle == NULL) { |
|
1b82a0195ff5
Fix 3 different race conditions in the win32 network management functionality.
Daniel Atallah <datallah@pidgin.im>
parents:
25326
diff
changeset
|
597 | memset(&qs, 0, sizeof(WSAQUERYSET)); |
|
1b82a0195ff5
Fix 3 different race conditions in the win32 network management functionality.
Daniel Atallah <datallah@pidgin.im>
parents:
25326
diff
changeset
|
598 | qs.dwSize = sizeof(WSAQUERYSET); |
|
1b82a0195ff5
Fix 3 different race conditions in the win32 network management functionality.
Daniel Atallah <datallah@pidgin.im>
parents:
25326
diff
changeset
|
599 | qs.dwNameSpace = NS_NLA; |
|
1b82a0195ff5
Fix 3 different race conditions in the win32 network management functionality.
Daniel Atallah <datallah@pidgin.im>
parents:
25326
diff
changeset
|
600 | if (WSALookupServiceBegin(&qs, 0, &network_change_handle) == SOCKET_ERROR) { |
|
1b82a0195ff5
Fix 3 different race conditions in the win32 network management functionality.
Daniel Atallah <datallah@pidgin.im>
parents:
25326
diff
changeset
|
601 | int errorid = WSAGetLastError(); |
|
1b82a0195ff5
Fix 3 different race conditions in the win32 network management functionality.
Daniel Atallah <datallah@pidgin.im>
parents:
25326
diff
changeset
|
602 | gchar *msg = g_win32_error_message(errorid); |
|
1b82a0195ff5
Fix 3 different race conditions in the win32 network management functionality.
Daniel Atallah <datallah@pidgin.im>
parents:
25326
diff
changeset
|
603 | purple_timeout_add(0, _print_debug_msg, |
|
1b82a0195ff5
Fix 3 different race conditions in the win32 network management functionality.
Daniel Atallah <datallah@pidgin.im>
parents:
25326
diff
changeset
|
604 | g_strdup_printf("Couldn't retrieve NLA SP lookup handle. " |
|
1b82a0195ff5
Fix 3 different race conditions in the win32 network management functionality.
Daniel Atallah <datallah@pidgin.im>
parents:
25326
diff
changeset
|
605 | "NLA service is probably not running. Message: %s (%d).\n", |
|
1b82a0195ff5
Fix 3 different race conditions in the win32 network management functionality.
Daniel Atallah <datallah@pidgin.im>
parents:
25326
diff
changeset
|
606 | msg, errorid)); |
|
1b82a0195ff5
Fix 3 different race conditions in the win32 network management functionality.
Daniel Atallah <datallah@pidgin.im>
parents:
25326
diff
changeset
|
607 | g_free(msg); |
|
1b82a0195ff5
Fix 3 different race conditions in the win32 network management functionality.
Daniel Atallah <datallah@pidgin.im>
parents:
25326
diff
changeset
|
608 | WSACloseEvent(nla_event); |
|
1b82a0195ff5
Fix 3 different race conditions in the win32 network management functionality.
Daniel Atallah <datallah@pidgin.im>
parents:
25326
diff
changeset
|
609 | g_static_mutex_unlock(&mutex); |
|
1b82a0195ff5
Fix 3 different race conditions in the win32 network management functionality.
Daniel Atallah <datallah@pidgin.im>
parents:
25326
diff
changeset
|
610 | g_thread_exit(NULL); |
|
1b82a0195ff5
Fix 3 different race conditions in the win32 network management functionality.
Daniel Atallah <datallah@pidgin.im>
parents:
25326
diff
changeset
|
611 | return NULL; |
|
1b82a0195ff5
Fix 3 different race conditions in the win32 network management functionality.
Daniel Atallah <datallah@pidgin.im>
parents:
25326
diff
changeset
|
612 | } |
|
14853
d06b1f28a8b2
[gaim-migrate @ 17556]
Daniel Atallah <datallah@pidgin.im>
parents:
14842
diff
changeset
|
613 | } |
|
25326
c4f4b222dbac
Adjust the NLA code to prevent hang on exit for Windows XP and Windows Vista.
Paul Aurich <darkrain42@pidgin.im>
parents:
24519
diff
changeset
|
614 | g_static_mutex_unlock(&mutex); |
|
14784
3a82321f46f2
[gaim-migrate @ 17476]
Daniel Atallah <datallah@pidgin.im>
parents:
14758
diff
changeset
|
615 | |
|
25326
c4f4b222dbac
Adjust the NLA code to prevent hang on exit for Windows XP and Windows Vista.
Paul Aurich <darkrain42@pidgin.im>
parents:
24519
diff
changeset
|
616 | memset(&completion, 0, sizeof(WSACOMPLETION)); |
|
c4f4b222dbac
Adjust the NLA code to prevent hang on exit for Windows XP and Windows Vista.
Paul Aurich <darkrain42@pidgin.im>
parents:
24519
diff
changeset
|
617 | completion.Type = NSP_NOTIFY_EVENT; |
|
c4f4b222dbac
Adjust the NLA code to prevent hang on exit for Windows XP and Windows Vista.
Paul Aurich <darkrain42@pidgin.im>
parents:
24519
diff
changeset
|
618 | overlapped.hEvent = nla_event; |
|
c4f4b222dbac
Adjust the NLA code to prevent hang on exit for Windows XP and Windows Vista.
Paul Aurich <darkrain42@pidgin.im>
parents:
24519
diff
changeset
|
619 | completion.Parameters.Event.lpOverlapped = &overlapped; |
|
c4f4b222dbac
Adjust the NLA code to prevent hang on exit for Windows XP and Windows Vista.
Paul Aurich <darkrain42@pidgin.im>
parents:
24519
diff
changeset
|
620 | |
|
c4f4b222dbac
Adjust the NLA code to prevent hang on exit for Windows XP and Windows Vista.
Paul Aurich <darkrain42@pidgin.im>
parents:
24519
diff
changeset
|
621 | if (MyWSANSPIoctl(network_change_handle, SIO_NSP_NOTIFY_CHANGE, NULL, 0, NULL, 0, &retLen, &completion) == SOCKET_ERROR) { |
|
14853
d06b1f28a8b2
[gaim-migrate @ 17556]
Daniel Atallah <datallah@pidgin.im>
parents:
14842
diff
changeset
|
622 | int errorid = WSAGetLastError(); |
|
25541
1b82a0195ff5
Fix 3 different race conditions in the win32 network management functionality.
Daniel Atallah <datallah@pidgin.im>
parents:
25326
diff
changeset
|
623 | if (errorid == WSA_INVALID_HANDLE) { |
|
1b82a0195ff5
Fix 3 different race conditions in the win32 network management functionality.
Daniel Atallah <datallah@pidgin.im>
parents:
25326
diff
changeset
|
624 | purple_timeout_add(0, _print_debug_msg, |
|
1b82a0195ff5
Fix 3 different race conditions in the win32 network management functionality.
Daniel Atallah <datallah@pidgin.im>
parents:
25326
diff
changeset
|
625 | g_strdup("Invalid NLA handle; resetting.\n")); |
|
1b82a0195ff5
Fix 3 different race conditions in the win32 network management functionality.
Daniel Atallah <datallah@pidgin.im>
parents:
25326
diff
changeset
|
626 | g_static_mutex_lock(&mutex); |
|
1b82a0195ff5
Fix 3 different race conditions in the win32 network management functionality.
Daniel Atallah <datallah@pidgin.im>
parents:
25326
diff
changeset
|
627 | retval = WSALookupServiceEnd(network_change_handle); |
|
1b82a0195ff5
Fix 3 different race conditions in the win32 network management functionality.
Daniel Atallah <datallah@pidgin.im>
parents:
25326
diff
changeset
|
628 | network_change_handle = NULL; |
|
1b82a0195ff5
Fix 3 different race conditions in the win32 network management functionality.
Daniel Atallah <datallah@pidgin.im>
parents:
25326
diff
changeset
|
629 | g_static_mutex_unlock(&mutex); |
|
1b82a0195ff5
Fix 3 different race conditions in the win32 network management functionality.
Daniel Atallah <datallah@pidgin.im>
parents:
25326
diff
changeset
|
630 | continue; |
|
25326
c4f4b222dbac
Adjust the NLA code to prevent hang on exit for Windows XP and Windows Vista.
Paul Aurich <darkrain42@pidgin.im>
parents:
24519
diff
changeset
|
631 | /* WSA_IO_PENDING indicates successful async notification will happen */ |
|
25541
1b82a0195ff5
Fix 3 different race conditions in the win32 network management functionality.
Daniel Atallah <datallah@pidgin.im>
parents:
25326
diff
changeset
|
632 | } else if (errorid != WSA_IO_PENDING) { |
|
25326
c4f4b222dbac
Adjust the NLA code to prevent hang on exit for Windows XP and Windows Vista.
Paul Aurich <darkrain42@pidgin.im>
parents:
24519
diff
changeset
|
633 | gchar *msg = g_win32_error_message(errorid); |
|
25541
1b82a0195ff5
Fix 3 different race conditions in the win32 network management functionality.
Daniel Atallah <datallah@pidgin.im>
parents:
25326
diff
changeset
|
634 | purple_timeout_add(0, _print_debug_msg, |
|
1b82a0195ff5
Fix 3 different race conditions in the win32 network management functionality.
Daniel Atallah <datallah@pidgin.im>
parents:
25326
diff
changeset
|
635 | g_strdup_printf("Unable to wait for changes. Message: %s (%d).\n", |
|
1b82a0195ff5
Fix 3 different race conditions in the win32 network management functionality.
Daniel Atallah <datallah@pidgin.im>
parents:
25326
diff
changeset
|
636 | msg, errorid)); |
|
25326
c4f4b222dbac
Adjust the NLA code to prevent hang on exit for Windows XP and Windows Vista.
Paul Aurich <darkrain42@pidgin.im>
parents:
24519
diff
changeset
|
637 | g_free(msg); |
|
c4f4b222dbac
Adjust the NLA code to prevent hang on exit for Windows XP and Windows Vista.
Paul Aurich <darkrain42@pidgin.im>
parents:
24519
diff
changeset
|
638 | } |
|
14853
d06b1f28a8b2
[gaim-migrate @ 17556]
Daniel Atallah <datallah@pidgin.im>
parents:
14842
diff
changeset
|
639 | } |
|
14784
3a82321f46f2
[gaim-migrate @ 17476]
Daniel Atallah <datallah@pidgin.im>
parents:
14758
diff
changeset
|
640 | |
|
25541
1b82a0195ff5
Fix 3 different race conditions in the win32 network management functionality.
Daniel Atallah <datallah@pidgin.im>
parents:
25326
diff
changeset
|
641 | /* Make sure at least 30 seconds have elapsed since the last |
|
1b82a0195ff5
Fix 3 different race conditions in the win32 network management functionality.
Daniel Atallah <datallah@pidgin.im>
parents:
25326
diff
changeset
|
642 | * notification so we don't peg the cpu if this keeps changing. */ |
|
1b82a0195ff5
Fix 3 different race conditions in the win32 network management functionality.
Daniel Atallah <datallah@pidgin.im>
parents:
25326
diff
changeset
|
643 | if ((time(NULL) - last_trigger) < 30) |
|
1b82a0195ff5
Fix 3 different race conditions in the win32 network management functionality.
Daniel Atallah <datallah@pidgin.im>
parents:
25326
diff
changeset
|
644 | Sleep(30000); |
|
1b82a0195ff5
Fix 3 different race conditions in the win32 network management functionality.
Daniel Atallah <datallah@pidgin.im>
parents:
25326
diff
changeset
|
645 | |
|
25326
c4f4b222dbac
Adjust the NLA code to prevent hang on exit for Windows XP and Windows Vista.
Paul Aurich <darkrain42@pidgin.im>
parents:
24519
diff
changeset
|
646 | /* This will block until NLA notifies us */ |
|
c4f4b222dbac
Adjust the NLA code to prevent hang on exit for Windows XP and Windows Vista.
Paul Aurich <darkrain42@pidgin.im>
parents:
24519
diff
changeset
|
647 | retval = WaitForSingleObjectEx(nla_event, WSA_INFINITE, TRUE); |
|
c4f4b222dbac
Adjust the NLA code to prevent hang on exit for Windows XP and Windows Vista.
Paul Aurich <darkrain42@pidgin.im>
parents:
24519
diff
changeset
|
648 | |
|
25541
1b82a0195ff5
Fix 3 different race conditions in the win32 network management functionality.
Daniel Atallah <datallah@pidgin.im>
parents:
25326
diff
changeset
|
649 | last_trigger = time(NULL); |
|
1b82a0195ff5
Fix 3 different race conditions in the win32 network management functionality.
Daniel Atallah <datallah@pidgin.im>
parents:
25326
diff
changeset
|
650 | |
|
25326
c4f4b222dbac
Adjust the NLA code to prevent hang on exit for Windows XP and Windows Vista.
Paul Aurich <darkrain42@pidgin.im>
parents:
24519
diff
changeset
|
651 | g_static_mutex_lock(&mutex); |
|
c4f4b222dbac
Adjust the NLA code to prevent hang on exit for Windows XP and Windows Vista.
Paul Aurich <darkrain42@pidgin.im>
parents:
24519
diff
changeset
|
652 | if (network_initialized == FALSE) { |
|
c4f4b222dbac
Adjust the NLA code to prevent hang on exit for Windows XP and Windows Vista.
Paul Aurich <darkrain42@pidgin.im>
parents:
24519
diff
changeset
|
653 | /* Time to die */ |
|
c4f4b222dbac
Adjust the NLA code to prevent hang on exit for Windows XP and Windows Vista.
Paul Aurich <darkrain42@pidgin.im>
parents:
24519
diff
changeset
|
654 | WSACloseEvent(nla_event); |
|
c4f4b222dbac
Adjust the NLA code to prevent hang on exit for Windows XP and Windows Vista.
Paul Aurich <darkrain42@pidgin.im>
parents:
24519
diff
changeset
|
655 | g_static_mutex_unlock(&mutex); |
|
c4f4b222dbac
Adjust the NLA code to prevent hang on exit for Windows XP and Windows Vista.
Paul Aurich <darkrain42@pidgin.im>
parents:
24519
diff
changeset
|
656 | g_thread_exit(NULL); |
|
c4f4b222dbac
Adjust the NLA code to prevent hang on exit for Windows XP and Windows Vista.
Paul Aurich <darkrain42@pidgin.im>
parents:
24519
diff
changeset
|
657 | return NULL; |
|
c4f4b222dbac
Adjust the NLA code to prevent hang on exit for Windows XP and Windows Vista.
Paul Aurich <darkrain42@pidgin.im>
parents:
24519
diff
changeset
|
658 | } |
|
c4f4b222dbac
Adjust the NLA code to prevent hang on exit for Windows XP and Windows Vista.
Paul Aurich <darkrain42@pidgin.im>
parents:
24519
diff
changeset
|
659 | |
|
25541
1b82a0195ff5
Fix 3 different race conditions in the win32 network management functionality.
Daniel Atallah <datallah@pidgin.im>
parents:
25326
diff
changeset
|
660 | size = sizeof(buf); |
|
1b82a0195ff5
Fix 3 different race conditions in the win32 network management functionality.
Daniel Atallah <datallah@pidgin.im>
parents:
25326
diff
changeset
|
661 | while ((retval = WSALookupServiceNext(network_change_handle, 0, &size, res)) == ERROR_SUCCESS) { |
|
1b82a0195ff5
Fix 3 different race conditions in the win32 network management functionality.
Daniel Atallah <datallah@pidgin.im>
parents:
25326
diff
changeset
|
662 | /*purple_timeout_add(0, _print_debug_msg, |
|
1b82a0195ff5
Fix 3 different race conditions in the win32 network management functionality.
Daniel Atallah <datallah@pidgin.im>
parents:
25326
diff
changeset
|
663 | g_strdup_printf("thread found network '%s'\n", |
|
1b82a0195ff5
Fix 3 different race conditions in the win32 network management functionality.
Daniel Atallah <datallah@pidgin.im>
parents:
25326
diff
changeset
|
664 | res->lpszServiceInstanceName ? res->lpszServiceInstanceName : "(NULL)"));*/ |
|
1b82a0195ff5
Fix 3 different race conditions in the win32 network management functionality.
Daniel Atallah <datallah@pidgin.im>
parents:
25326
diff
changeset
|
665 | size = sizeof(buf); |
|
1b82a0195ff5
Fix 3 different race conditions in the win32 network management functionality.
Daniel Atallah <datallah@pidgin.im>
parents:
25326
diff
changeset
|
666 | } |
|
1b82a0195ff5
Fix 3 different race conditions in the win32 network management functionality.
Daniel Atallah <datallah@pidgin.im>
parents:
25326
diff
changeset
|
667 | |
|
25326
c4f4b222dbac
Adjust the NLA code to prevent hang on exit for Windows XP and Windows Vista.
Paul Aurich <darkrain42@pidgin.im>
parents:
24519
diff
changeset
|
668 | WSAResetEvent(nla_event); |
|
c4f4b222dbac
Adjust the NLA code to prevent hang on exit for Windows XP and Windows Vista.
Paul Aurich <darkrain42@pidgin.im>
parents:
24519
diff
changeset
|
669 | g_static_mutex_unlock(&mutex); |
|
14784
3a82321f46f2
[gaim-migrate @ 17476]
Daniel Atallah <datallah@pidgin.im>
parents:
14758
diff
changeset
|
670 | |
|
21549
7436059db33b
Don't map the port used for bonjour file transfers externally. This adds a new function that will go away in 3.0.0 when we can modify purple_network_do_listen to take an additional parameter.
Daniel Atallah <datallah@pidgin.im>
parents:
21389
diff
changeset
|
671 | purple_timeout_add(0, wpurple_network_change_thread_cb, NULL); |
|
14784
3a82321f46f2
[gaim-migrate @ 17476]
Daniel Atallah <datallah@pidgin.im>
parents:
14758
diff
changeset
|
672 | } |
|
14853
d06b1f28a8b2
[gaim-migrate @ 17556]
Daniel Atallah <datallah@pidgin.im>
parents:
14842
diff
changeset
|
673 | |
|
d06b1f28a8b2
[gaim-migrate @ 17556]
Daniel Atallah <datallah@pidgin.im>
parents:
14842
diff
changeset
|
674 | g_thread_exit(NULL); |
|
d06b1f28a8b2
[gaim-migrate @ 17556]
Daniel Atallah <datallah@pidgin.im>
parents:
14842
diff
changeset
|
675 | return NULL; |
|
14784
3a82321f46f2
[gaim-migrate @ 17476]
Daniel Atallah <datallah@pidgin.im>
parents:
14758
diff
changeset
|
676 | } |
|
3a82321f46f2
[gaim-migrate @ 17476]
Daniel Atallah <datallah@pidgin.im>
parents:
14758
diff
changeset
|
677 | #endif |
|
3a82321f46f2
[gaim-migrate @ 17476]
Daniel Atallah <datallah@pidgin.im>
parents:
14758
diff
changeset
|
678 | |
| 14758 | 679 | gboolean |
| 15884 | 680 | purple_network_is_available(void) |
| 14758 | 681 | { |
|
23060
db9632a9b374
Use pkg-config to detect NetworkManager. Also, fail if it isn't present,
Richard Laager <rlaager@pidgin.im>
parents:
23054
diff
changeset
|
682 | #ifdef HAVE_NETWORKMANAGER |
|
24999
84d597b7e7c6
Add a -f/--force-online option to Pidgin which tells libpurple to claim the
Richard Laager <rlaager@pidgin.im>
parents:
24519
diff
changeset
|
683 | if (force_online) |
|
84d597b7e7c6
Add a -f/--force-online option to Pidgin which tells libpurple to claim the
Richard Laager <rlaager@pidgin.im>
parents:
24519
diff
changeset
|
684 | return TRUE; |
|
84d597b7e7c6
Add a -f/--force-online option to Pidgin which tells libpurple to claim the
Richard Laager <rlaager@pidgin.im>
parents:
24519
diff
changeset
|
685 | |
|
24519
d4af3d043211
Improve our NetworkManager support in a couple of ways:
Richard Laager <rlaager@pidgin.im>
parents:
24044
diff
changeset
|
686 | if (!have_nm_state) |
|
23047
f2c25bf1e0fd
Fix some whitespace as noticed by QuLogic.
Richard Laager <rlaager@pidgin.im>
parents:
23041
diff
changeset
|
687 | { |
|
24519
d4af3d043211
Improve our NetworkManager support in a couple of ways:
Richard Laager <rlaager@pidgin.im>
parents:
24044
diff
changeset
|
688 | have_nm_state = TRUE; |
|
d4af3d043211
Improve our NetworkManager support in a couple of ways:
Richard Laager <rlaager@pidgin.im>
parents:
24044
diff
changeset
|
689 | nm_state = nm_get_network_state(); |
|
d4af3d043211
Improve our NetworkManager support in a couple of ways:
Richard Laager <rlaager@pidgin.im>
parents:
24044
diff
changeset
|
690 | if (nm_state == NM_STATE_UNKNOWN) |
|
d4af3d043211
Improve our NetworkManager support in a couple of ways:
Richard Laager <rlaager@pidgin.im>
parents:
24044
diff
changeset
|
691 | purple_debug_warning("network", "NetworkManager not active. Assuming connection exists.\n"); |
|
23041
58661da65e36
Changes suggested by QuLogic to fix my broken changes to the NetworkManager
Richard Laager <rlaager@pidgin.im>
parents:
23040
diff
changeset
|
692 | } |
|
24519
d4af3d043211
Improve our NetworkManager support in a couple of ways:
Richard Laager <rlaager@pidgin.im>
parents:
24044
diff
changeset
|
693 | |
|
d4af3d043211
Improve our NetworkManager support in a couple of ways:
Richard Laager <rlaager@pidgin.im>
parents:
24044
diff
changeset
|
694 | if (nm_state == NM_STATE_UNKNOWN || nm_state == NM_STATE_CONNECTED) |
|
23040
13df421b8347
Update configure.ac to properly detect Network Manager (via NetworkManager.h instead of libnm_glib). Also, change the code so that if NetworkManager is dead, we'll assume we're connected to the network and try anyway.
Richard Laager <rlaager@pidgin.im>
parents:
23039
diff
changeset
|
695 | return TRUE; |
|
23041
58661da65e36
Changes suggested by QuLogic to fix my broken changes to the NetworkManager
Richard Laager <rlaager@pidgin.im>
parents:
23040
diff
changeset
|
696 | |
|
58661da65e36
Changes suggested by QuLogic to fix my broken changes to the NetworkManager
Richard Laager <rlaager@pidgin.im>
parents:
23040
diff
changeset
|
697 | return FALSE; |
|
58661da65e36
Changes suggested by QuLogic to fix my broken changes to the NetworkManager
Richard Laager <rlaager@pidgin.im>
parents:
23040
diff
changeset
|
698 | |
|
14839
221c60cc76e0
[gaim-migrate @ 17541]
Daniel Atallah <datallah@pidgin.im>
parents:
14838
diff
changeset
|
699 | #elif defined _WIN32 |
|
24999
84d597b7e7c6
Add a -f/--force-online option to Pidgin which tells libpurple to claim the
Richard Laager <rlaager@pidgin.im>
parents:
24519
diff
changeset
|
700 | return (current_network_count > 0 || force_online); |
|
23041
58661da65e36
Changes suggested by QuLogic to fix my broken changes to the NetworkManager
Richard Laager <rlaager@pidgin.im>
parents:
23040
diff
changeset
|
701 | #else |
|
58661da65e36
Changes suggested by QuLogic to fix my broken changes to the NetworkManager
Richard Laager <rlaager@pidgin.im>
parents:
23040
diff
changeset
|
702 | return TRUE; |
| 14758 | 703 | #endif |
| 704 | } | |
| 705 | ||
|
24999
84d597b7e7c6
Add a -f/--force-online option to Pidgin which tells libpurple to claim the
Richard Laager <rlaager@pidgin.im>
parents:
24519
diff
changeset
|
706 | void |
|
84d597b7e7c6
Add a -f/--force-online option to Pidgin which tells libpurple to claim the
Richard Laager <rlaager@pidgin.im>
parents:
24519
diff
changeset
|
707 | purple_network_force_online() |
|
84d597b7e7c6
Add a -f/--force-online option to Pidgin which tells libpurple to claim the
Richard Laager <rlaager@pidgin.im>
parents:
24519
diff
changeset
|
708 | { |
|
84d597b7e7c6
Add a -f/--force-online option to Pidgin which tells libpurple to claim the
Richard Laager <rlaager@pidgin.im>
parents:
24519
diff
changeset
|
709 | #if defined(HAVE_NETWORKMANAGER) || defined(_WIN32) |
|
84d597b7e7c6
Add a -f/--force-online option to Pidgin which tells libpurple to claim the
Richard Laager <rlaager@pidgin.im>
parents:
24519
diff
changeset
|
710 | force_online = TRUE; |
|
84d597b7e7c6
Add a -f/--force-online option to Pidgin which tells libpurple to claim the
Richard Laager <rlaager@pidgin.im>
parents:
24519
diff
changeset
|
711 | #endif |
|
84d597b7e7c6
Add a -f/--force-online option to Pidgin which tells libpurple to claim the
Richard Laager <rlaager@pidgin.im>
parents:
24519
diff
changeset
|
712 | } |
|
84d597b7e7c6
Add a -f/--force-online option to Pidgin which tells libpurple to claim the
Richard Laager <rlaager@pidgin.im>
parents:
24519
diff
changeset
|
713 | |
|
23060
db9632a9b374
Use pkg-config to detect NetworkManager. Also, fail if it isn't present,
Richard Laager <rlaager@pidgin.im>
parents:
23054
diff
changeset
|
714 | #ifdef HAVE_NETWORKMANAGER |
|
22735
a9c84e4679d8
Make some more things static
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
21977
diff
changeset
|
715 | static void |
|
23039
c9b53691fe42
A patch from QuLogic to replace the libnm_glib calls with straight DBus
Richard Laager <rlaager@pidgin.im>
parents:
22735
diff
changeset
|
716 | nm_update_state(NMState state) |
| 14758 | 717 | { |
|
24519
d4af3d043211
Improve our NetworkManager support in a couple of ways:
Richard Laager <rlaager@pidgin.im>
parents:
24044
diff
changeset
|
718 | NMState prev = nm_state; |
| 15884 | 719 | PurpleConnectionUiOps *ui_ops = purple_connections_get_ui_ops(); |
| 14758 | 720 | |
|
24519
d4af3d043211
Improve our NetworkManager support in a couple of ways:
Richard Laager <rlaager@pidgin.im>
parents:
24044
diff
changeset
|
721 | have_nm_state = TRUE; |
|
d4af3d043211
Improve our NetworkManager support in a couple of ways:
Richard Laager <rlaager@pidgin.im>
parents:
24044
diff
changeset
|
722 | nm_state = state; |
|
d4af3d043211
Improve our NetworkManager support in a couple of ways:
Richard Laager <rlaager@pidgin.im>
parents:
24044
diff
changeset
|
723 | |
|
16035
eb4eda79a147
The network module now registers the signal 'network-configuration-changed' and emits it when a network change is detected via libnm or the win32 network monitor. The UI could also emit this signal if it knows something network.c doesn't. UPnP and NAT-PMP respond to the signal by clearing their IP address caches; changing networks without quitting/relaunching will now lead to the new IP address being (lazily) determined. This commit also enables nat-pmp and adds nat-pmp.[h|c] to the build process; please let me know if there are any problems building, as I only have OS X test machines.
Evan Schoenberg <evands@pidgin.im>
parents:
16012
diff
changeset
|
724 | purple_signal_emit(purple_network_get_handle(), "network-configuration-changed", NULL); |
|
eb4eda79a147
The network module now registers the signal 'network-configuration-changed' and emits it when a network change is detected via libnm or the win32 network monitor. The UI could also emit this signal if it knows something network.c doesn't. UPnP and NAT-PMP respond to the signal by clearing their IP address caches; changing networks without quitting/relaunching will now lead to the new IP address being (lazily) determined. This commit also enables nat-pmp and adds nat-pmp.[h|c] to the build process; please let me know if there are any problems building, as I only have OS X test machines.
Evan Schoenberg <evands@pidgin.im>
parents:
16012
diff
changeset
|
725 | |
|
23039
c9b53691fe42
A patch from QuLogic to replace the libnm_glib calls with straight DBus
Richard Laager <rlaager@pidgin.im>
parents:
22735
diff
changeset
|
726 | switch(state) |
| 14758 | 727 | { |
|
23039
c9b53691fe42
A patch from QuLogic to replace the libnm_glib calls with straight DBus
Richard Laager <rlaager@pidgin.im>
parents:
22735
diff
changeset
|
728 | case NM_STATE_CONNECTED: |
|
c9b53691fe42
A patch from QuLogic to replace the libnm_glib calls with straight DBus
Richard Laager <rlaager@pidgin.im>
parents:
22735
diff
changeset
|
729 | /* Call res_init in case DNS servers have changed */ |
|
c9b53691fe42
A patch from QuLogic to replace the libnm_glib calls with straight DBus
Richard Laager <rlaager@pidgin.im>
parents:
22735
diff
changeset
|
730 | res_init(); |
|
26256
d2673c935184
Run an asynchronous DNS lookup for the STUN server IP (to set as a property
Marcus Lundblad <malu@pidgin.im>
parents:
25326
diff
changeset
|
731 | /* update STUN IP in case we it changed (theoretically we could |
|
d2673c935184
Run an asynchronous DNS lookup for the STUN server IP (to set as a property
Marcus Lundblad <malu@pidgin.im>
parents:
25326
diff
changeset
|
732 | have gone from IPv4 to IPv6, f.ex. or we were previously |
|
d2673c935184
Run an asynchronous DNS lookup for the STUN server IP (to set as a property
Marcus Lundblad <malu@pidgin.im>
parents:
25326
diff
changeset
|
733 | offline */ |
|
d2673c935184
Run an asynchronous DNS lookup for the STUN server IP (to set as a property
Marcus Lundblad <malu@pidgin.im>
parents:
25326
diff
changeset
|
734 | purple_network_set_stun_server( |
|
d2673c935184
Run an asynchronous DNS lookup for the STUN server IP (to set as a property
Marcus Lundblad <malu@pidgin.im>
parents:
25326
diff
changeset
|
735 | purple_prefs_get_string("/purple/network/stun_server")); |
|
26261
ffabb135a4b6
Added support to generate relayed candidates (TURN).
Marcus Lundblad <malu@pidgin.im>
parents:
26256
diff
changeset
|
736 | purple_network_set_turn_server( |
|
ffabb135a4b6
Added support to generate relayed candidates (TURN).
Marcus Lundblad <malu@pidgin.im>
parents:
26256
diff
changeset
|
737 | purple_prefs_get_string("/purple/network/turn_server")); |
|
26256
d2673c935184
Run an asynchronous DNS lookup for the STUN server IP (to set as a property
Marcus Lundblad <malu@pidgin.im>
parents:
25326
diff
changeset
|
738 | |
|
23039
c9b53691fe42
A patch from QuLogic to replace the libnm_glib calls with straight DBus
Richard Laager <rlaager@pidgin.im>
parents:
22735
diff
changeset
|
739 | if (ui_ops != NULL && ui_ops->network_connected != NULL) |
|
c9b53691fe42
A patch from QuLogic to replace the libnm_glib calls with straight DBus
Richard Laager <rlaager@pidgin.im>
parents:
22735
diff
changeset
|
740 | ui_ops->network_connected(); |
| 14758 | 741 | break; |
|
23039
c9b53691fe42
A patch from QuLogic to replace the libnm_glib calls with straight DBus
Richard Laager <rlaager@pidgin.im>
parents:
22735
diff
changeset
|
742 | case NM_STATE_ASLEEP: |
|
c9b53691fe42
A patch from QuLogic to replace the libnm_glib calls with straight DBus
Richard Laager <rlaager@pidgin.im>
parents:
22735
diff
changeset
|
743 | case NM_STATE_CONNECTING: |
|
c9b53691fe42
A patch from QuLogic to replace the libnm_glib calls with straight DBus
Richard Laager <rlaager@pidgin.im>
parents:
22735
diff
changeset
|
744 | case NM_STATE_DISCONNECTED: |
|
24519
d4af3d043211
Improve our NetworkManager support in a couple of ways:
Richard Laager <rlaager@pidgin.im>
parents:
24044
diff
changeset
|
745 | if (prev != NM_STATE_CONNECTED && prev != NM_STATE_UNKNOWN) |
|
23039
c9b53691fe42
A patch from QuLogic to replace the libnm_glib calls with straight DBus
Richard Laager <rlaager@pidgin.im>
parents:
22735
diff
changeset
|
746 | break; |
|
c9b53691fe42
A patch from QuLogic to replace the libnm_glib calls with straight DBus
Richard Laager <rlaager@pidgin.im>
parents:
22735
diff
changeset
|
747 | if (ui_ops != NULL && ui_ops->network_disconnected != NULL) |
|
c9b53691fe42
A patch from QuLogic to replace the libnm_glib calls with straight DBus
Richard Laager <rlaager@pidgin.im>
parents:
22735
diff
changeset
|
748 | ui_ops->network_disconnected(); |
|
c9b53691fe42
A patch from QuLogic to replace the libnm_glib calls with straight DBus
Richard Laager <rlaager@pidgin.im>
parents:
22735
diff
changeset
|
749 | break; |
|
c9b53691fe42
A patch from QuLogic to replace the libnm_glib calls with straight DBus
Richard Laager <rlaager@pidgin.im>
parents:
22735
diff
changeset
|
750 | case NM_STATE_UNKNOWN: |
|
c9b53691fe42
A patch from QuLogic to replace the libnm_glib calls with straight DBus
Richard Laager <rlaager@pidgin.im>
parents:
22735
diff
changeset
|
751 | default: |
|
c9b53691fe42
A patch from QuLogic to replace the libnm_glib calls with straight DBus
Richard Laager <rlaager@pidgin.im>
parents:
22735
diff
changeset
|
752 | break; |
| 14758 | 753 | } |
| 754 | } | |
|
23039
c9b53691fe42
A patch from QuLogic to replace the libnm_glib calls with straight DBus
Richard Laager <rlaager@pidgin.im>
parents:
22735
diff
changeset
|
755 | |
|
c9b53691fe42
A patch from QuLogic to replace the libnm_glib calls with straight DBus
Richard Laager <rlaager@pidgin.im>
parents:
22735
diff
changeset
|
756 | static void |
|
c9b53691fe42
A patch from QuLogic to replace the libnm_glib calls with straight DBus
Richard Laager <rlaager@pidgin.im>
parents:
22735
diff
changeset
|
757 | nm_state_change_cb(DBusGProxy *proxy, NMState state, gpointer user_data) |
|
c9b53691fe42
A patch from QuLogic to replace the libnm_glib calls with straight DBus
Richard Laager <rlaager@pidgin.im>
parents:
22735
diff
changeset
|
758 | { |
|
c9b53691fe42
A patch from QuLogic to replace the libnm_glib calls with straight DBus
Richard Laager <rlaager@pidgin.im>
parents:
22735
diff
changeset
|
759 | purple_debug_info("network", "Got StateChange from NetworkManager: %d.\n", state); |
|
c9b53691fe42
A patch from QuLogic to replace the libnm_glib calls with straight DBus
Richard Laager <rlaager@pidgin.im>
parents:
22735
diff
changeset
|
760 | nm_update_state(state); |
|
c9b53691fe42
A patch from QuLogic to replace the libnm_glib calls with straight DBus
Richard Laager <rlaager@pidgin.im>
parents:
22735
diff
changeset
|
761 | } |
|
c9b53691fe42
A patch from QuLogic to replace the libnm_glib calls with straight DBus
Richard Laager <rlaager@pidgin.im>
parents:
22735
diff
changeset
|
762 | |
|
c9b53691fe42
A patch from QuLogic to replace the libnm_glib calls with straight DBus
Richard Laager <rlaager@pidgin.im>
parents:
22735
diff
changeset
|
763 | static NMState |
|
c9b53691fe42
A patch from QuLogic to replace the libnm_glib calls with straight DBus
Richard Laager <rlaager@pidgin.im>
parents:
22735
diff
changeset
|
764 | nm_get_network_state(void) |
|
c9b53691fe42
A patch from QuLogic to replace the libnm_glib calls with straight DBus
Richard Laager <rlaager@pidgin.im>
parents:
22735
diff
changeset
|
765 | { |
|
c9b53691fe42
A patch from QuLogic to replace the libnm_glib calls with straight DBus
Richard Laager <rlaager@pidgin.im>
parents:
22735
diff
changeset
|
766 | GError *err = NULL; |
|
c9b53691fe42
A patch from QuLogic to replace the libnm_glib calls with straight DBus
Richard Laager <rlaager@pidgin.im>
parents:
22735
diff
changeset
|
767 | NMState state = NM_STATE_UNKNOWN; |
|
c9b53691fe42
A patch from QuLogic to replace the libnm_glib calls with straight DBus
Richard Laager <rlaager@pidgin.im>
parents:
22735
diff
changeset
|
768 | |
|
c9b53691fe42
A patch from QuLogic to replace the libnm_glib calls with straight DBus
Richard Laager <rlaager@pidgin.im>
parents:
22735
diff
changeset
|
769 | if (!nm_proxy) |
|
c9b53691fe42
A patch from QuLogic to replace the libnm_glib calls with straight DBus
Richard Laager <rlaager@pidgin.im>
parents:
22735
diff
changeset
|
770 | return NM_STATE_UNKNOWN; |
|
c9b53691fe42
A patch from QuLogic to replace the libnm_glib calls with straight DBus
Richard Laager <rlaager@pidgin.im>
parents:
22735
diff
changeset
|
771 | |
|
c9b53691fe42
A patch from QuLogic to replace the libnm_glib calls with straight DBus
Richard Laager <rlaager@pidgin.im>
parents:
22735
diff
changeset
|
772 | if (!dbus_g_proxy_call(nm_proxy, "state", &err, G_TYPE_INVALID, G_TYPE_UINT, &state, G_TYPE_INVALID)) { |
| 23185 | 773 | g_error_free(err); |
|
23039
c9b53691fe42
A patch from QuLogic to replace the libnm_glib calls with straight DBus
Richard Laager <rlaager@pidgin.im>
parents:
22735
diff
changeset
|
774 | return NM_STATE_UNKNOWN; |
|
c9b53691fe42
A patch from QuLogic to replace the libnm_glib calls with straight DBus
Richard Laager <rlaager@pidgin.im>
parents:
22735
diff
changeset
|
775 | } |
|
c9b53691fe42
A patch from QuLogic to replace the libnm_glib calls with straight DBus
Richard Laager <rlaager@pidgin.im>
parents:
22735
diff
changeset
|
776 | |
|
c9b53691fe42
A patch from QuLogic to replace the libnm_glib calls with straight DBus
Richard Laager <rlaager@pidgin.im>
parents:
22735
diff
changeset
|
777 | return state; |
|
c9b53691fe42
A patch from QuLogic to replace the libnm_glib calls with straight DBus
Richard Laager <rlaager@pidgin.im>
parents:
22735
diff
changeset
|
778 | } |
|
c9b53691fe42
A patch from QuLogic to replace the libnm_glib calls with straight DBus
Richard Laager <rlaager@pidgin.im>
parents:
22735
diff
changeset
|
779 | |
|
c9b53691fe42
A patch from QuLogic to replace the libnm_glib calls with straight DBus
Richard Laager <rlaager@pidgin.im>
parents:
22735
diff
changeset
|
780 | static void |
|
c9b53691fe42
A patch from QuLogic to replace the libnm_glib calls with straight DBus
Richard Laager <rlaager@pidgin.im>
parents:
22735
diff
changeset
|
781 | nm_dbus_name_owner_changed_cb(DBusGProxy *proxy, char *service, char *old_owner, char *new_owner, gpointer user_data) |
|
c9b53691fe42
A patch from QuLogic to replace the libnm_glib calls with straight DBus
Richard Laager <rlaager@pidgin.im>
parents:
22735
diff
changeset
|
782 | { |
|
c9b53691fe42
A patch from QuLogic to replace the libnm_glib calls with straight DBus
Richard Laager <rlaager@pidgin.im>
parents:
22735
diff
changeset
|
783 | if (g_str_equal(service, NM_DBUS_SERVICE)) { |
|
c9b53691fe42
A patch from QuLogic to replace the libnm_glib calls with straight DBus
Richard Laager <rlaager@pidgin.im>
parents:
22735
diff
changeset
|
784 | gboolean old_owner_good = old_owner && (old_owner[0] != '\0'); |
|
c9b53691fe42
A patch from QuLogic to replace the libnm_glib calls with straight DBus
Richard Laager <rlaager@pidgin.im>
parents:
22735
diff
changeset
|
785 | gboolean new_owner_good = new_owner && (new_owner[0] != '\0'); |
|
c9b53691fe42
A patch from QuLogic to replace the libnm_glib calls with straight DBus
Richard Laager <rlaager@pidgin.im>
parents:
22735
diff
changeset
|
786 | |
|
c9b53691fe42
A patch from QuLogic to replace the libnm_glib calls with straight DBus
Richard Laager <rlaager@pidgin.im>
parents:
22735
diff
changeset
|
787 | purple_debug_info("network", "Got NameOwnerChanged signal, service = '%s', old_owner = '%s', new_owner = '%s'\n", service, old_owner, new_owner); |
|
c9b53691fe42
A patch from QuLogic to replace the libnm_glib calls with straight DBus
Richard Laager <rlaager@pidgin.im>
parents:
22735
diff
changeset
|
788 | if (!old_owner_good && new_owner_good) { /* Equivalent to old ServiceCreated signal */ |
|
c9b53691fe42
A patch from QuLogic to replace the libnm_glib calls with straight DBus
Richard Laager <rlaager@pidgin.im>
parents:
22735
diff
changeset
|
789 | purple_debug_info("network", "NetworkManager has started.\n"); |
|
c9b53691fe42
A patch from QuLogic to replace the libnm_glib calls with straight DBus
Richard Laager <rlaager@pidgin.im>
parents:
22735
diff
changeset
|
790 | nm_update_state(nm_get_network_state()); |
|
c9b53691fe42
A patch from QuLogic to replace the libnm_glib calls with straight DBus
Richard Laager <rlaager@pidgin.im>
parents:
22735
diff
changeset
|
791 | } else if (old_owner_good && !new_owner_good) { /* Equivalent to old ServiceDeleted signal */ |
|
c9b53691fe42
A patch from QuLogic to replace the libnm_glib calls with straight DBus
Richard Laager <rlaager@pidgin.im>
parents:
22735
diff
changeset
|
792 | purple_debug_info("network", "NetworkManager has gone away.\n"); |
|
c9b53691fe42
A patch from QuLogic to replace the libnm_glib calls with straight DBus
Richard Laager <rlaager@pidgin.im>
parents:
22735
diff
changeset
|
793 | nm_update_state(NM_STATE_UNKNOWN); |
|
c9b53691fe42
A patch from QuLogic to replace the libnm_glib calls with straight DBus
Richard Laager <rlaager@pidgin.im>
parents:
22735
diff
changeset
|
794 | } |
|
c9b53691fe42
A patch from QuLogic to replace the libnm_glib calls with straight DBus
Richard Laager <rlaager@pidgin.im>
parents:
22735
diff
changeset
|
795 | } |
|
c9b53691fe42
A patch from QuLogic to replace the libnm_glib calls with straight DBus
Richard Laager <rlaager@pidgin.im>
parents:
22735
diff
changeset
|
796 | } |
|
c9b53691fe42
A patch from QuLogic to replace the libnm_glib calls with straight DBus
Richard Laager <rlaager@pidgin.im>
parents:
22735
diff
changeset
|
797 | |
| 14758 | 798 | #endif |
| 799 | ||
|
26256
d2673c935184
Run an asynchronous DNS lookup for the STUN server IP (to set as a property
Marcus Lundblad <malu@pidgin.im>
parents:
25326
diff
changeset
|
800 | static void |
|
26261
ffabb135a4b6
Added support to generate relayed candidates (TURN).
Marcus Lundblad <malu@pidgin.im>
parents:
26256
diff
changeset
|
801 | purple_network_ip_lookup_cb(GSList *hosts, gpointer data, |
|
26256
d2673c935184
Run an asynchronous DNS lookup for the STUN server IP (to set as a property
Marcus Lundblad <malu@pidgin.im>
parents:
25326
diff
changeset
|
802 | const char *error_message) |
|
d2673c935184
Run an asynchronous DNS lookup for the STUN server IP (to set as a property
Marcus Lundblad <malu@pidgin.im>
parents:
25326
diff
changeset
|
803 | { |
|
26261
ffabb135a4b6
Added support to generate relayed candidates (TURN).
Marcus Lundblad <malu@pidgin.im>
parents:
26256
diff
changeset
|
804 | const gchar **ip = (const gchar **) data; |
|
26262
1ad96aa2e92a
Removed some extra tabs on blank lines
Marcus Lundblad <malu@pidgin.im>
parents:
26261
diff
changeset
|
805 | |
|
26256
d2673c935184
Run an asynchronous DNS lookup for the STUN server IP (to set as a property
Marcus Lundblad <malu@pidgin.im>
parents:
25326
diff
changeset
|
806 | if (error_message) { |
|
26261
ffabb135a4b6
Added support to generate relayed candidates (TURN).
Marcus Lundblad <malu@pidgin.im>
parents:
26256
diff
changeset
|
807 | purple_debug_error("network", "lookup of IP address failed: %s\n", |
|
26256
d2673c935184
Run an asynchronous DNS lookup for the STUN server IP (to set as a property
Marcus Lundblad <malu@pidgin.im>
parents:
25326
diff
changeset
|
808 | error_message); |
|
d2673c935184
Run an asynchronous DNS lookup for the STUN server IP (to set as a property
Marcus Lundblad <malu@pidgin.im>
parents:
25326
diff
changeset
|
809 | g_slist_free(hosts); |
|
d2673c935184
Run an asynchronous DNS lookup for the STUN server IP (to set as a property
Marcus Lundblad <malu@pidgin.im>
parents:
25326
diff
changeset
|
810 | return; |
|
d2673c935184
Run an asynchronous DNS lookup for the STUN server IP (to set as a property
Marcus Lundblad <malu@pidgin.im>
parents:
25326
diff
changeset
|
811 | } |
|
26262
1ad96aa2e92a
Removed some extra tabs on blank lines
Marcus Lundblad <malu@pidgin.im>
parents:
26261
diff
changeset
|
812 | |
|
26256
d2673c935184
Run an asynchronous DNS lookup for the STUN server IP (to set as a property
Marcus Lundblad <malu@pidgin.im>
parents:
25326
diff
changeset
|
813 | if (hosts && g_slist_next(hosts)) { |
|
d2673c935184
Run an asynchronous DNS lookup for the STUN server IP (to set as a property
Marcus Lundblad <malu@pidgin.im>
parents:
25326
diff
changeset
|
814 | struct sockaddr *addr = g_slist_next(hosts)->data; |
|
d2673c935184
Run an asynchronous DNS lookup for the STUN server IP (to set as a property
Marcus Lundblad <malu@pidgin.im>
parents:
25326
diff
changeset
|
815 | char dst[INET6_ADDRSTRLEN]; |
|
d2673c935184
Run an asynchronous DNS lookup for the STUN server IP (to set as a property
Marcus Lundblad <malu@pidgin.im>
parents:
25326
diff
changeset
|
816 | |
|
d2673c935184
Run an asynchronous DNS lookup for the STUN server IP (to set as a property
Marcus Lundblad <malu@pidgin.im>
parents:
25326
diff
changeset
|
817 | if (addr->sa_family == AF_INET6) { |
|
d2673c935184
Run an asynchronous DNS lookup for the STUN server IP (to set as a property
Marcus Lundblad <malu@pidgin.im>
parents:
25326
diff
changeset
|
818 | inet_ntop(addr->sa_family, &((struct sockaddr_in6 *) addr)->sin6_addr, |
|
d2673c935184
Run an asynchronous DNS lookup for the STUN server IP (to set as a property
Marcus Lundblad <malu@pidgin.im>
parents:
25326
diff
changeset
|
819 | dst, sizeof(dst)); |
|
d2673c935184
Run an asynchronous DNS lookup for the STUN server IP (to set as a property
Marcus Lundblad <malu@pidgin.im>
parents:
25326
diff
changeset
|
820 | } else { |
|
d2673c935184
Run an asynchronous DNS lookup for the STUN server IP (to set as a property
Marcus Lundblad <malu@pidgin.im>
parents:
25326
diff
changeset
|
821 | inet_ntop(addr->sa_family, &((struct sockaddr_in *) addr)->sin_addr, |
|
d2673c935184
Run an asynchronous DNS lookup for the STUN server IP (to set as a property
Marcus Lundblad <malu@pidgin.im>
parents:
25326
diff
changeset
|
822 | dst, sizeof(dst)); |
|
d2673c935184
Run an asynchronous DNS lookup for the STUN server IP (to set as a property
Marcus Lundblad <malu@pidgin.im>
parents:
25326
diff
changeset
|
823 | } |
|
26262
1ad96aa2e92a
Removed some extra tabs on blank lines
Marcus Lundblad <malu@pidgin.im>
parents:
26261
diff
changeset
|
824 | |
|
26261
ffabb135a4b6
Added support to generate relayed candidates (TURN).
Marcus Lundblad <malu@pidgin.im>
parents:
26256
diff
changeset
|
825 | *ip = g_strdup(dst); |
|
ffabb135a4b6
Added support to generate relayed candidates (TURN).
Marcus Lundblad <malu@pidgin.im>
parents:
26256
diff
changeset
|
826 | purple_debug_info("network", "set IP address: %s\n", *ip); |
|
26256
d2673c935184
Run an asynchronous DNS lookup for the STUN server IP (to set as a property
Marcus Lundblad <malu@pidgin.im>
parents:
25326
diff
changeset
|
827 | } |
|
d2673c935184
Run an asynchronous DNS lookup for the STUN server IP (to set as a property
Marcus Lundblad <malu@pidgin.im>
parents:
25326
diff
changeset
|
828 | |
|
d2673c935184
Run an asynchronous DNS lookup for the STUN server IP (to set as a property
Marcus Lundblad <malu@pidgin.im>
parents:
25326
diff
changeset
|
829 | g_slist_free(hosts); |
|
d2673c935184
Run an asynchronous DNS lookup for the STUN server IP (to set as a property
Marcus Lundblad <malu@pidgin.im>
parents:
25326
diff
changeset
|
830 | } |
|
d2673c935184
Run an asynchronous DNS lookup for the STUN server IP (to set as a property
Marcus Lundblad <malu@pidgin.im>
parents:
25326
diff
changeset
|
831 | |
|
d2673c935184
Run an asynchronous DNS lookup for the STUN server IP (to set as a property
Marcus Lundblad <malu@pidgin.im>
parents:
25326
diff
changeset
|
832 | void |
|
d2673c935184
Run an asynchronous DNS lookup for the STUN server IP (to set as a property
Marcus Lundblad <malu@pidgin.im>
parents:
25326
diff
changeset
|
833 | purple_network_set_stun_server(const gchar *stun_server) |
|
d2673c935184
Run an asynchronous DNS lookup for the STUN server IP (to set as a property
Marcus Lundblad <malu@pidgin.im>
parents:
25326
diff
changeset
|
834 | { |
|
d2673c935184
Run an asynchronous DNS lookup for the STUN server IP (to set as a property
Marcus Lundblad <malu@pidgin.im>
parents:
25326
diff
changeset
|
835 | if (stun_server && stun_server[0] != '\0') { |
|
d2673c935184
Run an asynchronous DNS lookup for the STUN server IP (to set as a property
Marcus Lundblad <malu@pidgin.im>
parents:
25326
diff
changeset
|
836 | if (purple_network_is_available()) { |
|
d2673c935184
Run an asynchronous DNS lookup for the STUN server IP (to set as a property
Marcus Lundblad <malu@pidgin.im>
parents:
25326
diff
changeset
|
837 | purple_debug_info("network", "running DNS query for STUN server\n"); |
|
26261
ffabb135a4b6
Added support to generate relayed candidates (TURN).
Marcus Lundblad <malu@pidgin.im>
parents:
26256
diff
changeset
|
838 | purple_dnsquery_a(stun_server, 3478, purple_network_ip_lookup_cb, |
|
ffabb135a4b6
Added support to generate relayed candidates (TURN).
Marcus Lundblad <malu@pidgin.im>
parents:
26256
diff
changeset
|
839 | &stun_ip); |
|
26256
d2673c935184
Run an asynchronous DNS lookup for the STUN server IP (to set as a property
Marcus Lundblad <malu@pidgin.im>
parents:
25326
diff
changeset
|
840 | } else { |
|
d2673c935184
Run an asynchronous DNS lookup for the STUN server IP (to set as a property
Marcus Lundblad <malu@pidgin.im>
parents:
25326
diff
changeset
|
841 | purple_debug_info("network", |
|
d2673c935184
Run an asynchronous DNS lookup for the STUN server IP (to set as a property
Marcus Lundblad <malu@pidgin.im>
parents:
25326
diff
changeset
|
842 | "network is unavailable, don't try to update STUN IP"); |
|
d2673c935184
Run an asynchronous DNS lookup for the STUN server IP (to set as a property
Marcus Lundblad <malu@pidgin.im>
parents:
25326
diff
changeset
|
843 | } |
|
d2673c935184
Run an asynchronous DNS lookup for the STUN server IP (to set as a property
Marcus Lundblad <malu@pidgin.im>
parents:
25326
diff
changeset
|
844 | } else if (stun_ip) { |
|
d2673c935184
Run an asynchronous DNS lookup for the STUN server IP (to set as a property
Marcus Lundblad <malu@pidgin.im>
parents:
25326
diff
changeset
|
845 | g_free(stun_ip); |
|
d2673c935184
Run an asynchronous DNS lookup for the STUN server IP (to set as a property
Marcus Lundblad <malu@pidgin.im>
parents:
25326
diff
changeset
|
846 | stun_ip = NULL; |
|
d2673c935184
Run an asynchronous DNS lookup for the STUN server IP (to set as a property
Marcus Lundblad <malu@pidgin.im>
parents:
25326
diff
changeset
|
847 | } |
|
d2673c935184
Run an asynchronous DNS lookup for the STUN server IP (to set as a property
Marcus Lundblad <malu@pidgin.im>
parents:
25326
diff
changeset
|
848 | } |
|
d2673c935184
Run an asynchronous DNS lookup for the STUN server IP (to set as a property
Marcus Lundblad <malu@pidgin.im>
parents:
25326
diff
changeset
|
849 | |
|
26261
ffabb135a4b6
Added support to generate relayed candidates (TURN).
Marcus Lundblad <malu@pidgin.im>
parents:
26256
diff
changeset
|
850 | void |
|
ffabb135a4b6
Added support to generate relayed candidates (TURN).
Marcus Lundblad <malu@pidgin.im>
parents:
26256
diff
changeset
|
851 | purple_network_set_turn_server(const gchar *turn_server) |
|
ffabb135a4b6
Added support to generate relayed candidates (TURN).
Marcus Lundblad <malu@pidgin.im>
parents:
26256
diff
changeset
|
852 | { |
|
ffabb135a4b6
Added support to generate relayed candidates (TURN).
Marcus Lundblad <malu@pidgin.im>
parents:
26256
diff
changeset
|
853 | if (turn_server && turn_server[0] != '\0') { |
|
ffabb135a4b6
Added support to generate relayed candidates (TURN).
Marcus Lundblad <malu@pidgin.im>
parents:
26256
diff
changeset
|
854 | if (purple_network_is_available()) { |
|
ffabb135a4b6
Added support to generate relayed candidates (TURN).
Marcus Lundblad <malu@pidgin.im>
parents:
26256
diff
changeset
|
855 | purple_debug_info("network", "running DNS query for TURN server\n"); |
|
ffabb135a4b6
Added support to generate relayed candidates (TURN).
Marcus Lundblad <malu@pidgin.im>
parents:
26256
diff
changeset
|
856 | purple_dnsquery_a(turn_server, |
|
ffabb135a4b6
Added support to generate relayed candidates (TURN).
Marcus Lundblad <malu@pidgin.im>
parents:
26256
diff
changeset
|
857 | purple_prefs_get_int("/purple/network/turn_port"), |
|
ffabb135a4b6
Added support to generate relayed candidates (TURN).
Marcus Lundblad <malu@pidgin.im>
parents:
26256
diff
changeset
|
858 | purple_network_ip_lookup_cb, &turn_ip); |
|
ffabb135a4b6
Added support to generate relayed candidates (TURN).
Marcus Lundblad <malu@pidgin.im>
parents:
26256
diff
changeset
|
859 | } else { |
|
ffabb135a4b6
Added support to generate relayed candidates (TURN).
Marcus Lundblad <malu@pidgin.im>
parents:
26256
diff
changeset
|
860 | purple_debug_info("network", |
|
ffabb135a4b6
Added support to generate relayed candidates (TURN).
Marcus Lundblad <malu@pidgin.im>
parents:
26256
diff
changeset
|
861 | "network is unavailable, don't try to update TURN IP"); |
|
ffabb135a4b6
Added support to generate relayed candidates (TURN).
Marcus Lundblad <malu@pidgin.im>
parents:
26256
diff
changeset
|
862 | } |
|
ffabb135a4b6
Added support to generate relayed candidates (TURN).
Marcus Lundblad <malu@pidgin.im>
parents:
26256
diff
changeset
|
863 | } else if (turn_ip) { |
|
ffabb135a4b6
Added support to generate relayed candidates (TURN).
Marcus Lundblad <malu@pidgin.im>
parents:
26256
diff
changeset
|
864 | g_free(turn_ip); |
|
ffabb135a4b6
Added support to generate relayed candidates (TURN).
Marcus Lundblad <malu@pidgin.im>
parents:
26256
diff
changeset
|
865 | turn_ip = NULL; |
|
ffabb135a4b6
Added support to generate relayed candidates (TURN).
Marcus Lundblad <malu@pidgin.im>
parents:
26256
diff
changeset
|
866 | } |
|
ffabb135a4b6
Added support to generate relayed candidates (TURN).
Marcus Lundblad <malu@pidgin.im>
parents:
26256
diff
changeset
|
867 | } |
|
ffabb135a4b6
Added support to generate relayed candidates (TURN).
Marcus Lundblad <malu@pidgin.im>
parents:
26256
diff
changeset
|
868 | |
|
ffabb135a4b6
Added support to generate relayed candidates (TURN).
Marcus Lundblad <malu@pidgin.im>
parents:
26256
diff
changeset
|
869 | |
|
26256
d2673c935184
Run an asynchronous DNS lookup for the STUN server IP (to set as a property
Marcus Lundblad <malu@pidgin.im>
parents:
25326
diff
changeset
|
870 | const gchar * |
|
d2673c935184
Run an asynchronous DNS lookup for the STUN server IP (to set as a property
Marcus Lundblad <malu@pidgin.im>
parents:
25326
diff
changeset
|
871 | purple_network_get_stun_ip(void) |
|
d2673c935184
Run an asynchronous DNS lookup for the STUN server IP (to set as a property
Marcus Lundblad <malu@pidgin.im>
parents:
25326
diff
changeset
|
872 | { |
|
d2673c935184
Run an asynchronous DNS lookup for the STUN server IP (to set as a property
Marcus Lundblad <malu@pidgin.im>
parents:
25326
diff
changeset
|
873 | return stun_ip; |
|
d2673c935184
Run an asynchronous DNS lookup for the STUN server IP (to set as a property
Marcus Lundblad <malu@pidgin.im>
parents:
25326
diff
changeset
|
874 | } |
|
d2673c935184
Run an asynchronous DNS lookup for the STUN server IP (to set as a property
Marcus Lundblad <malu@pidgin.im>
parents:
25326
diff
changeset
|
875 | |
|
26261
ffabb135a4b6
Added support to generate relayed candidates (TURN).
Marcus Lundblad <malu@pidgin.im>
parents:
26256
diff
changeset
|
876 | const gchar * |
|
ffabb135a4b6
Added support to generate relayed candidates (TURN).
Marcus Lundblad <malu@pidgin.im>
parents:
26256
diff
changeset
|
877 | purple_network_get_turn_ip(void) |
|
ffabb135a4b6
Added support to generate relayed candidates (TURN).
Marcus Lundblad <malu@pidgin.im>
parents:
26256
diff
changeset
|
878 | { |
|
ffabb135a4b6
Added support to generate relayed candidates (TURN).
Marcus Lundblad <malu@pidgin.im>
parents:
26256
diff
changeset
|
879 | return turn_ip; |
|
ffabb135a4b6
Added support to generate relayed candidates (TURN).
Marcus Lundblad <malu@pidgin.im>
parents:
26256
diff
changeset
|
880 | } |
|
ffabb135a4b6
Added support to generate relayed candidates (TURN).
Marcus Lundblad <malu@pidgin.im>
parents:
26256
diff
changeset
|
881 | |
|
16035
eb4eda79a147
The network module now registers the signal 'network-configuration-changed' and emits it when a network change is detected via libnm or the win32 network monitor. The UI could also emit this signal if it knows something network.c doesn't. UPnP and NAT-PMP respond to the signal by clearing their IP address caches; changing networks without quitting/relaunching will now lead to the new IP address being (lazily) determined. This commit also enables nat-pmp and adds nat-pmp.[h|c] to the build process; please let me know if there are any problems building, as I only have OS X test machines.
Evan Schoenberg <evands@pidgin.im>
parents:
16012
diff
changeset
|
882 | void * |
|
eb4eda79a147
The network module now registers the signal 'network-configuration-changed' and emits it when a network change is detected via libnm or the win32 network monitor. The UI could also emit this signal if it knows something network.c doesn't. UPnP and NAT-PMP respond to the signal by clearing their IP address caches; changing networks without quitting/relaunching will now lead to the new IP address being (lazily) determined. This commit also enables nat-pmp and adds nat-pmp.[h|c] to the build process; please let me know if there are any problems building, as I only have OS X test machines.
Evan Schoenberg <evands@pidgin.im>
parents:
16012
diff
changeset
|
883 | purple_network_get_handle(void) |
|
eb4eda79a147
The network module now registers the signal 'network-configuration-changed' and emits it when a network change is detected via libnm or the win32 network monitor. The UI could also emit this signal if it knows something network.c doesn't. UPnP and NAT-PMP respond to the signal by clearing their IP address caches; changing networks without quitting/relaunching will now lead to the new IP address being (lazily) determined. This commit also enables nat-pmp and adds nat-pmp.[h|c] to the build process; please let me know if there are any problems building, as I only have OS X test machines.
Evan Schoenberg <evands@pidgin.im>
parents:
16012
diff
changeset
|
884 | { |
|
eb4eda79a147
The network module now registers the signal 'network-configuration-changed' and emits it when a network change is detected via libnm or the win32 network monitor. The UI could also emit this signal if it knows something network.c doesn't. UPnP and NAT-PMP respond to the signal by clearing their IP address caches; changing networks without quitting/relaunching will now lead to the new IP address being (lazily) determined. This commit also enables nat-pmp and adds nat-pmp.[h|c] to the build process; please let me know if there are any problems building, as I only have OS X test machines.
Evan Schoenberg <evands@pidgin.im>
parents:
16012
diff
changeset
|
885 | static int handle; |
|
19585
14b519abcc26
Fix some conversion warnings about using negative values with unsigned types. There are more, but these were easy fixes. You may think that I'm changing the API, but I'm really not - it was just wrong.
Daniel Atallah <datallah@pidgin.im>
parents:
18555
diff
changeset
|
886 | |
|
16035
eb4eda79a147
The network module now registers the signal 'network-configuration-changed' and emits it when a network change is detected via libnm or the win32 network monitor. The UI could also emit this signal if it knows something network.c doesn't. UPnP and NAT-PMP respond to the signal by clearing their IP address caches; changing networks without quitting/relaunching will now lead to the new IP address being (lazily) determined. This commit also enables nat-pmp and adds nat-pmp.[h|c] to the build process; please let me know if there are any problems building, as I only have OS X test machines.
Evan Schoenberg <evands@pidgin.im>
parents:
16012
diff
changeset
|
887 | return &handle; |
|
eb4eda79a147
The network module now registers the signal 'network-configuration-changed' and emits it when a network change is detected via libnm or the win32 network monitor. The UI could also emit this signal if it knows something network.c doesn't. UPnP and NAT-PMP respond to the signal by clearing their IP address caches; changing networks without quitting/relaunching will now lead to the new IP address being (lazily) determined. This commit also enables nat-pmp and adds nat-pmp.[h|c] to the build process; please let me know if there are any problems building, as I only have OS X test machines.
Evan Schoenberg <evands@pidgin.im>
parents:
16012
diff
changeset
|
888 | } |
|
eb4eda79a147
The network module now registers the signal 'network-configuration-changed' and emits it when a network change is detected via libnm or the win32 network monitor. The UI could also emit this signal if it knows something network.c doesn't. UPnP and NAT-PMP respond to the signal by clearing their IP address caches; changing networks without quitting/relaunching will now lead to the new IP address being (lazily) determined. This commit also enables nat-pmp and adds nat-pmp.[h|c] to the build process; please let me know if there are any problems building, as I only have OS X test machines.
Evan Schoenberg <evands@pidgin.im>
parents:
16012
diff
changeset
|
889 | |
| 8231 | 890 | void |
| 15884 | 891 | purple_network_init(void) |
| 8231 | 892 | { |
|
23060
db9632a9b374
Use pkg-config to detect NetworkManager. Also, fail if it isn't present,
Richard Laager <rlaager@pidgin.im>
parents:
23054
diff
changeset
|
893 | #ifdef HAVE_NETWORKMANAGER |
|
23039
c9b53691fe42
A patch from QuLogic to replace the libnm_glib calls with straight DBus
Richard Laager <rlaager@pidgin.im>
parents:
22735
diff
changeset
|
894 | GError *error = NULL; |
|
c9b53691fe42
A patch from QuLogic to replace the libnm_glib calls with straight DBus
Richard Laager <rlaager@pidgin.im>
parents:
22735
diff
changeset
|
895 | #endif |
|
14784
3a82321f46f2
[gaim-migrate @ 17476]
Daniel Atallah <datallah@pidgin.im>
parents:
14758
diff
changeset
|
896 | #ifdef _WIN32 |
|
3a82321f46f2
[gaim-migrate @ 17476]
Daniel Atallah <datallah@pidgin.im>
parents:
14758
diff
changeset
|
897 | GError *err = NULL; |
| 15884 | 898 | gint cnt = wpurple_get_connected_network_count(); |
|
14842
fe08ba80d369
[gaim-migrate @ 17544]
Daniel Atallah <datallah@pidgin.im>
parents:
14839
diff
changeset
|
899 | |
|
25326
c4f4b222dbac
Adjust the NLA code to prevent hang on exit for Windows XP and Windows Vista.
Paul Aurich <darkrain42@pidgin.im>
parents:
24519
diff
changeset
|
900 | network_initialized = TRUE; |
|
14842
fe08ba80d369
[gaim-migrate @ 17544]
Daniel Atallah <datallah@pidgin.im>
parents:
14839
diff
changeset
|
901 | if (cnt < 0) /* Assume there is a network */ |
|
fe08ba80d369
[gaim-migrate @ 17544]
Daniel Atallah <datallah@pidgin.im>
parents:
14839
diff
changeset
|
902 | current_network_count = 1; |
|
fe08ba80d369
[gaim-migrate @ 17544]
Daniel Atallah <datallah@pidgin.im>
parents:
14839
diff
changeset
|
903 | /* Don't listen for network changes if we can't tell anyway */ |
|
25541
1b82a0195ff5
Fix 3 different race conditions in the win32 network management functionality.
Daniel Atallah <datallah@pidgin.im>
parents:
25326
diff
changeset
|
904 | else { |
|
14842
fe08ba80d369
[gaim-migrate @ 17544]
Daniel Atallah <datallah@pidgin.im>
parents:
14839
diff
changeset
|
905 | current_network_count = cnt; |
|
25541
1b82a0195ff5
Fix 3 different race conditions in the win32 network management functionality.
Daniel Atallah <datallah@pidgin.im>
parents:
25326
diff
changeset
|
906 | if ((MyWSANSPIoctl = (void*) wpurple_find_and_loadproc("ws2_32.dll", "WSANSPIoctl"))) { |
|
1b82a0195ff5
Fix 3 different race conditions in the win32 network management functionality.
Daniel Atallah <datallah@pidgin.im>
parents:
25326
diff
changeset
|
907 | if (!g_thread_create(wpurple_network_change_thread, NULL, FALSE, &err)) |
|
1b82a0195ff5
Fix 3 different race conditions in the win32 network management functionality.
Daniel Atallah <datallah@pidgin.im>
parents:
25326
diff
changeset
|
908 | purple_debug_error("network", "Couldn't create Network Monitor thread: %s\n", err ? err->message : ""); |
|
1b82a0195ff5
Fix 3 different race conditions in the win32 network management functionality.
Daniel Atallah <datallah@pidgin.im>
parents:
25326
diff
changeset
|
909 | } |
|
14842
fe08ba80d369
[gaim-migrate @ 17544]
Daniel Atallah <datallah@pidgin.im>
parents:
14839
diff
changeset
|
910 | } |
|
14784
3a82321f46f2
[gaim-migrate @ 17476]
Daniel Atallah <datallah@pidgin.im>
parents:
14758
diff
changeset
|
911 | #endif |
|
3a82321f46f2
[gaim-migrate @ 17476]
Daniel Atallah <datallah@pidgin.im>
parents:
14758
diff
changeset
|
912 | |
|
16478
19107605c565
Works for me! Renames prefs: /core to /purple, /gaim/gtk to /pidgin, /gaim/gnt to /finch
Sean Egan <seanegan@pidgin.im>
parents:
16035
diff
changeset
|
913 | purple_prefs_add_none ("/purple/network"); |
|
26256
d2673c935184
Run an asynchronous DNS lookup for the STUN server IP (to set as a property
Marcus Lundblad <malu@pidgin.im>
parents:
25326
diff
changeset
|
914 | purple_prefs_add_string("/purple/network/stun_server", ""); |
|
26261
ffabb135a4b6
Added support to generate relayed candidates (TURN).
Marcus Lundblad <malu@pidgin.im>
parents:
26256
diff
changeset
|
915 | purple_prefs_add_string("/purple/network/turn_server", ""); |
|
ffabb135a4b6
Added support to generate relayed candidates (TURN).
Marcus Lundblad <malu@pidgin.im>
parents:
26256
diff
changeset
|
916 | purple_prefs_add_int ("/purple/network/turn_port", 3478); |
|
ffabb135a4b6
Added support to generate relayed candidates (TURN).
Marcus Lundblad <malu@pidgin.im>
parents:
26256
diff
changeset
|
917 | purple_prefs_add_string("/purple/network/turn_username", ""); |
|
ffabb135a4b6
Added support to generate relayed candidates (TURN).
Marcus Lundblad <malu@pidgin.im>
parents:
26256
diff
changeset
|
918 | purple_prefs_add_string("/purple/network/turn_password", ""); |
|
16478
19107605c565
Works for me! Renames prefs: /core to /purple, /gaim/gtk to /pidgin, /gaim/gnt to /finch
Sean Egan <seanegan@pidgin.im>
parents:
16035
diff
changeset
|
919 | purple_prefs_add_bool ("/purple/network/auto_ip", TRUE); |
|
19107605c565
Works for me! Renames prefs: /core to /purple, /gaim/gtk to /pidgin, /gaim/gnt to /finch
Sean Egan <seanegan@pidgin.im>
parents:
16035
diff
changeset
|
920 | purple_prefs_add_string("/purple/network/public_ip", ""); |
|
21810
0b5181178201
Allow UPnP and NAT-PMP port mapping to be disabled via a pref. This means that UPnP discovery will not occur if this new pref and the "Autodetect IP Address" pref are both unchecked. Fixes #4157.
Daniel Atallah <datallah@pidgin.im>
parents:
21549
diff
changeset
|
921 | purple_prefs_add_bool ("/purple/network/map_ports", TRUE); |
|
16478
19107605c565
Works for me! Renames prefs: /core to /purple, /gaim/gtk to /pidgin, /gaim/gnt to /finch
Sean Egan <seanegan@pidgin.im>
parents:
16035
diff
changeset
|
922 | purple_prefs_add_bool ("/purple/network/ports_range_use", FALSE); |
|
19107605c565
Works for me! Renames prefs: /core to /purple, /gaim/gtk to /pidgin, /gaim/gnt to /finch
Sean Egan <seanegan@pidgin.im>
parents:
16035
diff
changeset
|
923 | purple_prefs_add_int ("/purple/network/ports_range_start", 1024); |
|
19107605c565
Works for me! Renames prefs: /core to /purple, /gaim/gtk to /pidgin, /gaim/gnt to /finch
Sean Egan <seanegan@pidgin.im>
parents:
16035
diff
changeset
|
924 | purple_prefs_add_int ("/purple/network/ports_range_end", 2048); |
|
12909
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12730
diff
changeset
|
925 | |
|
21810
0b5181178201
Allow UPnP and NAT-PMP port mapping to be disabled via a pref. This means that UPnP discovery will not occur if this new pref and the "Autodetect IP Address" pref are both unchecked. Fixes #4157.
Daniel Atallah <datallah@pidgin.im>
parents:
21549
diff
changeset
|
926 | if(purple_prefs_get_bool("/purple/network/map_ports") || purple_prefs_get_bool("/purple/network/auto_ip")) |
|
0b5181178201
Allow UPnP and NAT-PMP port mapping to be disabled via a pref. This means that UPnP discovery will not occur if this new pref and the "Autodetect IP Address" pref are both unchecked. Fixes #4157.
Daniel Atallah <datallah@pidgin.im>
parents:
21549
diff
changeset
|
927 | purple_upnp_discover(NULL, NULL); |
| 14758 | 928 | |
|
23060
db9632a9b374
Use pkg-config to detect NetworkManager. Also, fail if it isn't present,
Richard Laager <rlaager@pidgin.im>
parents:
23054
diff
changeset
|
929 | #ifdef HAVE_NETWORKMANAGER |
|
23039
c9b53691fe42
A patch from QuLogic to replace the libnm_glib calls with straight DBus
Richard Laager <rlaager@pidgin.im>
parents:
22735
diff
changeset
|
930 | nm_conn = dbus_g_bus_get(DBUS_BUS_SYSTEM, &error); |
|
c9b53691fe42
A patch from QuLogic to replace the libnm_glib calls with straight DBus
Richard Laager <rlaager@pidgin.im>
parents:
22735
diff
changeset
|
931 | if (!nm_conn) { |
|
c9b53691fe42
A patch from QuLogic to replace the libnm_glib calls with straight DBus
Richard Laager <rlaager@pidgin.im>
parents:
22735
diff
changeset
|
932 | purple_debug_warning("network", "Error connecting to DBus System service: %s.\n", error->message); |
|
c9b53691fe42
A patch from QuLogic to replace the libnm_glib calls with straight DBus
Richard Laager <rlaager@pidgin.im>
parents:
22735
diff
changeset
|
933 | } else { |
|
c9b53691fe42
A patch from QuLogic to replace the libnm_glib calls with straight DBus
Richard Laager <rlaager@pidgin.im>
parents:
22735
diff
changeset
|
934 | nm_proxy = dbus_g_proxy_new_for_name(nm_conn, |
|
c9b53691fe42
A patch from QuLogic to replace the libnm_glib calls with straight DBus
Richard Laager <rlaager@pidgin.im>
parents:
22735
diff
changeset
|
935 | NM_DBUS_SERVICE, |
|
c9b53691fe42
A patch from QuLogic to replace the libnm_glib calls with straight DBus
Richard Laager <rlaager@pidgin.im>
parents:
22735
diff
changeset
|
936 | NM_DBUS_PATH, |
|
c9b53691fe42
A patch from QuLogic to replace the libnm_glib calls with straight DBus
Richard Laager <rlaager@pidgin.im>
parents:
22735
diff
changeset
|
937 | NM_DBUS_INTERFACE); |
|
23054
2dc4cdd54b28
Modify the NetworkManager support to use "StateChange" directly, instead of
Richard Laager <rlaager@pidgin.im>
parents:
23047
diff
changeset
|
938 | dbus_g_proxy_add_signal(nm_proxy, "StateChange", G_TYPE_UINT, G_TYPE_INVALID); |
|
2dc4cdd54b28
Modify the NetworkManager support to use "StateChange" directly, instead of
Richard Laager <rlaager@pidgin.im>
parents:
23047
diff
changeset
|
939 | dbus_g_proxy_connect_signal(nm_proxy, "StateChange", |
|
23039
c9b53691fe42
A patch from QuLogic to replace the libnm_glib calls with straight DBus
Richard Laager <rlaager@pidgin.im>
parents:
22735
diff
changeset
|
940 | G_CALLBACK(nm_state_change_cb), NULL, NULL); |
|
c9b53691fe42
A patch from QuLogic to replace the libnm_glib calls with straight DBus
Richard Laager <rlaager@pidgin.im>
parents:
22735
diff
changeset
|
941 | |
|
c9b53691fe42
A patch from QuLogic to replace the libnm_glib calls with straight DBus
Richard Laager <rlaager@pidgin.im>
parents:
22735
diff
changeset
|
942 | dbus_proxy = dbus_g_proxy_new_for_name(nm_conn, |
|
c9b53691fe42
A patch from QuLogic to replace the libnm_glib calls with straight DBus
Richard Laager <rlaager@pidgin.im>
parents:
22735
diff
changeset
|
943 | DBUS_SERVICE_DBUS, |
|
c9b53691fe42
A patch from QuLogic to replace the libnm_glib calls with straight DBus
Richard Laager <rlaager@pidgin.im>
parents:
22735
diff
changeset
|
944 | DBUS_PATH_DBUS, |
|
c9b53691fe42
A patch from QuLogic to replace the libnm_glib calls with straight DBus
Richard Laager <rlaager@pidgin.im>
parents:
22735
diff
changeset
|
945 | DBUS_INTERFACE_DBUS); |
|
c9b53691fe42
A patch from QuLogic to replace the libnm_glib calls with straight DBus
Richard Laager <rlaager@pidgin.im>
parents:
22735
diff
changeset
|
946 | dbus_g_proxy_add_signal(dbus_proxy, "NameOwnerChanged", G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_INVALID); |
|
c9b53691fe42
A patch from QuLogic to replace the libnm_glib calls with straight DBus
Richard Laager <rlaager@pidgin.im>
parents:
22735
diff
changeset
|
947 | dbus_g_proxy_connect_signal(dbus_proxy, "NameOwnerChanged", |
|
c9b53691fe42
A patch from QuLogic to replace the libnm_glib calls with straight DBus
Richard Laager <rlaager@pidgin.im>
parents:
22735
diff
changeset
|
948 | G_CALLBACK(nm_dbus_name_owner_changed_cb), NULL, NULL); |
|
c9b53691fe42
A patch from QuLogic to replace the libnm_glib calls with straight DBus
Richard Laager <rlaager@pidgin.im>
parents:
22735
diff
changeset
|
949 | } |
| 14758 | 950 | #endif |
|
16035
eb4eda79a147
The network module now registers the signal 'network-configuration-changed' and emits it when a network change is detected via libnm or the win32 network monitor. The UI could also emit this signal if it knows something network.c doesn't. UPnP and NAT-PMP respond to the signal by clearing their IP address caches; changing networks without quitting/relaunching will now lead to the new IP address being (lazily) determined. This commit also enables nat-pmp and adds nat-pmp.[h|c] to the build process; please let me know if there are any problems building, as I only have OS X test machines.
Evan Schoenberg <evands@pidgin.im>
parents:
16012
diff
changeset
|
951 | |
|
eb4eda79a147
The network module now registers the signal 'network-configuration-changed' and emits it when a network change is detected via libnm or the win32 network monitor. The UI could also emit this signal if it knows something network.c doesn't. UPnP and NAT-PMP respond to the signal by clearing their IP address caches; changing networks without quitting/relaunching will now lead to the new IP address being (lazily) determined. This commit also enables nat-pmp and adds nat-pmp.[h|c] to the build process; please let me know if there are any problems building, as I only have OS X test machines.
Evan Schoenberg <evands@pidgin.im>
parents:
16012
diff
changeset
|
952 | purple_signal_register(purple_network_get_handle(), "network-configuration-changed", |
|
eb4eda79a147
The network module now registers the signal 'network-configuration-changed' and emits it when a network change is detected via libnm or the win32 network monitor. The UI could also emit this signal if it knows something network.c doesn't. UPnP and NAT-PMP respond to the signal by clearing their IP address caches; changing networks without quitting/relaunching will now lead to the new IP address being (lazily) determined. This commit also enables nat-pmp and adds nat-pmp.[h|c] to the build process; please let me know if there are any problems building, as I only have OS X test machines.
Evan Schoenberg <evands@pidgin.im>
parents:
16012
diff
changeset
|
953 | purple_marshal_VOID, NULL, 0); |
|
19585
14b519abcc26
Fix some conversion warnings about using negative values with unsigned types. There are more, but these were easy fixes. You may think that I'm changing the API, but I'm really not - it was just wrong.
Daniel Atallah <datallah@pidgin.im>
parents:
18555
diff
changeset
|
954 | |
|
16035
eb4eda79a147
The network module now registers the signal 'network-configuration-changed' and emits it when a network change is detected via libnm or the win32 network monitor. The UI could also emit this signal if it knows something network.c doesn't. UPnP and NAT-PMP respond to the signal by clearing their IP address caches; changing networks without quitting/relaunching will now lead to the new IP address being (lazily) determined. This commit also enables nat-pmp and adds nat-pmp.[h|c] to the build process; please let me know if there are any problems building, as I only have OS X test machines.
Evan Schoenberg <evands@pidgin.im>
parents:
16012
diff
changeset
|
955 | purple_pmp_init(); |
|
eb4eda79a147
The network module now registers the signal 'network-configuration-changed' and emits it when a network change is detected via libnm or the win32 network monitor. The UI could also emit this signal if it knows something network.c doesn't. UPnP and NAT-PMP respond to the signal by clearing their IP address caches; changing networks without quitting/relaunching will now lead to the new IP address being (lazily) determined. This commit also enables nat-pmp and adds nat-pmp.[h|c] to the build process; please let me know if there are any problems building, as I only have OS X test machines.
Evan Schoenberg <evands@pidgin.im>
parents:
16012
diff
changeset
|
956 | purple_upnp_init(); |
|
26256
d2673c935184
Run an asynchronous DNS lookup for the STUN server IP (to set as a property
Marcus Lundblad <malu@pidgin.im>
parents:
25326
diff
changeset
|
957 | |
|
d2673c935184
Run an asynchronous DNS lookup for the STUN server IP (to set as a property
Marcus Lundblad <malu@pidgin.im>
parents:
25326
diff
changeset
|
958 | purple_network_set_stun_server( |
|
d2673c935184
Run an asynchronous DNS lookup for the STUN server IP (to set as a property
Marcus Lundblad <malu@pidgin.im>
parents:
25326
diff
changeset
|
959 | purple_prefs_get_string("/purple/network/stun_server")); |
|
26261
ffabb135a4b6
Added support to generate relayed candidates (TURN).
Marcus Lundblad <malu@pidgin.im>
parents:
26256
diff
changeset
|
960 | purple_network_set_turn_server( |
|
ffabb135a4b6
Added support to generate relayed candidates (TURN).
Marcus Lundblad <malu@pidgin.im>
parents:
26256
diff
changeset
|
961 | purple_prefs_get_string("/purple/network/turn_server")); |
| 8231 | 962 | } |
| 14758 | 963 | |
| 964 | void | |
| 15884 | 965 | purple_network_uninit(void) |
| 14758 | 966 | { |
|
23060
db9632a9b374
Use pkg-config to detect NetworkManager. Also, fail if it isn't present,
Richard Laager <rlaager@pidgin.im>
parents:
23054
diff
changeset
|
967 | #ifdef HAVE_NETWORKMANAGER |
|
23039
c9b53691fe42
A patch from QuLogic to replace the libnm_glib calls with straight DBus
Richard Laager <rlaager@pidgin.im>
parents:
22735
diff
changeset
|
968 | if (nm_proxy) { |
|
23054
2dc4cdd54b28
Modify the NetworkManager support to use "StateChange" directly, instead of
Richard Laager <rlaager@pidgin.im>
parents:
23047
diff
changeset
|
969 | dbus_g_proxy_disconnect_signal(nm_proxy, "StateChange", G_CALLBACK(nm_state_change_cb), NULL); |
|
23039
c9b53691fe42
A patch from QuLogic to replace the libnm_glib calls with straight DBus
Richard Laager <rlaager@pidgin.im>
parents:
22735
diff
changeset
|
970 | g_object_unref(G_OBJECT(nm_proxy)); |
|
c9b53691fe42
A patch from QuLogic to replace the libnm_glib calls with straight DBus
Richard Laager <rlaager@pidgin.im>
parents:
22735
diff
changeset
|
971 | } |
|
c9b53691fe42
A patch from QuLogic to replace the libnm_glib calls with straight DBus
Richard Laager <rlaager@pidgin.im>
parents:
22735
diff
changeset
|
972 | if (dbus_proxy) { |
|
c9b53691fe42
A patch from QuLogic to replace the libnm_glib calls with straight DBus
Richard Laager <rlaager@pidgin.im>
parents:
22735
diff
changeset
|
973 | dbus_g_proxy_disconnect_signal(dbus_proxy, "NameOwnerChanged", G_CALLBACK(nm_dbus_name_owner_changed_cb), NULL); |
|
c9b53691fe42
A patch from QuLogic to replace the libnm_glib calls with straight DBus
Richard Laager <rlaager@pidgin.im>
parents:
22735
diff
changeset
|
974 | g_object_unref(G_OBJECT(dbus_proxy)); |
|
c9b53691fe42
A patch from QuLogic to replace the libnm_glib calls with straight DBus
Richard Laager <rlaager@pidgin.im>
parents:
22735
diff
changeset
|
975 | } |
|
c9b53691fe42
A patch from QuLogic to replace the libnm_glib calls with straight DBus
Richard Laager <rlaager@pidgin.im>
parents:
22735
diff
changeset
|
976 | if (nm_conn) |
|
c9b53691fe42
A patch from QuLogic to replace the libnm_glib calls with straight DBus
Richard Laager <rlaager@pidgin.im>
parents:
22735
diff
changeset
|
977 | dbus_g_connection_unref(nm_conn); |
| 14758 | 978 | #endif |
|
21143
239b2f43bef5
Make purple_xfers_uninit, purple_network_uninit, and purple_plugins_uninit
Etan Reisner <deryni@pidgin.im>
parents:
20239
diff
changeset
|
979 | |
|
25326
c4f4b222dbac
Adjust the NLA code to prevent hang on exit for Windows XP and Windows Vista.
Paul Aurich <darkrain42@pidgin.im>
parents:
24519
diff
changeset
|
980 | #ifdef _WIN32 |
|
c4f4b222dbac
Adjust the NLA code to prevent hang on exit for Windows XP and Windows Vista.
Paul Aurich <darkrain42@pidgin.im>
parents:
24519
diff
changeset
|
981 | g_static_mutex_lock(&mutex); |
|
c4f4b222dbac
Adjust the NLA code to prevent hang on exit for Windows XP and Windows Vista.
Paul Aurich <darkrain42@pidgin.im>
parents:
24519
diff
changeset
|
982 | network_initialized = FALSE; |
|
c4f4b222dbac
Adjust the NLA code to prevent hang on exit for Windows XP and Windows Vista.
Paul Aurich <darkrain42@pidgin.im>
parents:
24519
diff
changeset
|
983 | if (network_change_handle != NULL) { |
|
c4f4b222dbac
Adjust the NLA code to prevent hang on exit for Windows XP and Windows Vista.
Paul Aurich <darkrain42@pidgin.im>
parents:
24519
diff
changeset
|
984 | int retval; |
|
c4f4b222dbac
Adjust the NLA code to prevent hang on exit for Windows XP and Windows Vista.
Paul Aurich <darkrain42@pidgin.im>
parents:
24519
diff
changeset
|
985 | /* Trigger the NLA thread to stop waiting for network changes. Not |
|
c4f4b222dbac
Adjust the NLA code to prevent hang on exit for Windows XP and Windows Vista.
Paul Aurich <darkrain42@pidgin.im>
parents:
24519
diff
changeset
|
986 | * doing this can cause hangs on WSACleanup. */ |
|
c4f4b222dbac
Adjust the NLA code to prevent hang on exit for Windows XP and Windows Vista.
Paul Aurich <darkrain42@pidgin.im>
parents:
24519
diff
changeset
|
987 | purple_debug_warning("network", "Terminating the NLA thread\n"); |
|
c4f4b222dbac
Adjust the NLA code to prevent hang on exit for Windows XP and Windows Vista.
Paul Aurich <darkrain42@pidgin.im>
parents:
24519
diff
changeset
|
988 | if ((retval = WSALookupServiceEnd(network_change_handle)) == SOCKET_ERROR) { |
|
c4f4b222dbac
Adjust the NLA code to prevent hang on exit for Windows XP and Windows Vista.
Paul Aurich <darkrain42@pidgin.im>
parents:
24519
diff
changeset
|
989 | int errorid = WSAGetLastError(); |
|
c4f4b222dbac
Adjust the NLA code to prevent hang on exit for Windows XP and Windows Vista.
Paul Aurich <darkrain42@pidgin.im>
parents:
24519
diff
changeset
|
990 | gchar *msg = g_win32_error_message(errorid); |
|
c4f4b222dbac
Adjust the NLA code to prevent hang on exit for Windows XP and Windows Vista.
Paul Aurich <darkrain42@pidgin.im>
parents:
24519
diff
changeset
|
991 | purple_debug_warning("network", "Unable to kill NLA thread. Message: %s (%d).\n", |
|
c4f4b222dbac
Adjust the NLA code to prevent hang on exit for Windows XP and Windows Vista.
Paul Aurich <darkrain42@pidgin.im>
parents:
24519
diff
changeset
|
992 | msg, errorid); |
|
c4f4b222dbac
Adjust the NLA code to prevent hang on exit for Windows XP and Windows Vista.
Paul Aurich <darkrain42@pidgin.im>
parents:
24519
diff
changeset
|
993 | g_free(msg); |
|
c4f4b222dbac
Adjust the NLA code to prevent hang on exit for Windows XP and Windows Vista.
Paul Aurich <darkrain42@pidgin.im>
parents:
24519
diff
changeset
|
994 | } |
|
25541
1b82a0195ff5
Fix 3 different race conditions in the win32 network management functionality.
Daniel Atallah <datallah@pidgin.im>
parents:
25326
diff
changeset
|
995 | network_change_handle = NULL; |
|
1b82a0195ff5
Fix 3 different race conditions in the win32 network management functionality.
Daniel Atallah <datallah@pidgin.im>
parents:
25326
diff
changeset
|
996 | |
|
25326
c4f4b222dbac
Adjust the NLA code to prevent hang on exit for Windows XP and Windows Vista.
Paul Aurich <darkrain42@pidgin.im>
parents:
24519
diff
changeset
|
997 | } |
|
c4f4b222dbac
Adjust the NLA code to prevent hang on exit for Windows XP and Windows Vista.
Paul Aurich <darkrain42@pidgin.im>
parents:
24519
diff
changeset
|
998 | g_static_mutex_unlock(&mutex); |
|
c4f4b222dbac
Adjust the NLA code to prevent hang on exit for Windows XP and Windows Vista.
Paul Aurich <darkrain42@pidgin.im>
parents:
24519
diff
changeset
|
999 | |
|
c4f4b222dbac
Adjust the NLA code to prevent hang on exit for Windows XP and Windows Vista.
Paul Aurich <darkrain42@pidgin.im>
parents:
24519
diff
changeset
|
1000 | #endif |
|
21143
239b2f43bef5
Make purple_xfers_uninit, purple_network_uninit, and purple_plugins_uninit
Etan Reisner <deryni@pidgin.im>
parents:
20239
diff
changeset
|
1001 | purple_signal_unregister(purple_network_get_handle(), |
|
25541
1b82a0195ff5
Fix 3 different race conditions in the win32 network management functionality.
Daniel Atallah <datallah@pidgin.im>
parents:
25326
diff
changeset
|
1002 | "network-configuration-changed"); |
|
26256
d2673c935184
Run an asynchronous DNS lookup for the STUN server IP (to set as a property
Marcus Lundblad <malu@pidgin.im>
parents:
25326
diff
changeset
|
1003 | |
|
d2673c935184
Run an asynchronous DNS lookup for the STUN server IP (to set as a property
Marcus Lundblad <malu@pidgin.im>
parents:
25326
diff
changeset
|
1004 | if (stun_ip) |
|
d2673c935184
Run an asynchronous DNS lookup for the STUN server IP (to set as a property
Marcus Lundblad <malu@pidgin.im>
parents:
25326
diff
changeset
|
1005 | g_free(stun_ip); |
| 14758 | 1006 | } |