Mon, 12 Dec 2022 23:38:47 -0600
Create PurpleAvatar to represent avatars
Testing Done:
Ran the unit tests and manually verified the docs.
Reviewed at https://reviews.imfreedom.org/r/2092/
|
20147
66f05a854eee
applied changes from 8a731bbd0197fbcc91a705c2d8f528154216defa
Richard Laager <rlaager@pidgin.im>
parents:
19859
diff
changeset
|
1 | /* purple |
| 8231 | 2 | * |
| 15884 | 3 | * Purple is the legal property of its developers, whose names are too numerous |
| 8231 | 4 | * to list here. Please refer to the COPYRIGHT file distributed with this |
| 5 | * source distribution. | |
| 6 | * | |
| 7 | * This program is free software; you can redistribute it and/or modify | |
| 8 | * it under the terms of the GNU General Public License as published by | |
| 9 | * the Free Software Foundation; either version 2 of the License, or | |
| 10 | * (at your option) any later version. | |
| 11 | * | |
| 12 | * This program is distributed in the hope that it will be useful, | |
| 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
| 15 | * GNU General Public License for more details. | |
| 16 | * | |
| 17 | * You should have received a copy of the GNU General Public License | |
| 18 | * 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
|
19 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA |
| 8231 | 20 | */ |
| 21 | ||
|
8245
c1397ca0a619
[gaim-migrate @ 8968]
Herman Bloggs <herman@bluedigits.com>
parents:
8240
diff
changeset
|
22 | #include "internal.h" |
|
40439
e9838d634d5e
Make sure that internal.h can only be included by libpurple and split out some pieces to purpleprivate.h
Gary Kramlich <grim@reaperworld.com>
parents:
40264
diff
changeset
|
23 | #include "purpleprivate.h" |
| 8231 | 24 | |
|
37450
703722d83214
Update network.c for the dns code removal
Gary Kramlich <grim@reaperworld.com>
parents:
36031
diff
changeset
|
25 | #include <gio/gio.h> |
|
703722d83214
Update network.c for the dns code removal
Gary Kramlich <grim@reaperworld.com>
parents:
36031
diff
changeset
|
26 | |
|
41682
289867067994
Clean up a bunch of stuff in internal.h
Gary Kramlich <grim@reaperworld.com>
parents:
41153
diff
changeset
|
27 | #include <fcntl.h> |
|
289867067994
Clean up a bunch of stuff in internal.h
Gary Kramlich <grim@reaperworld.com>
parents:
41153
diff
changeset
|
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> |
|
14784
3a82321f46f2
[gaim-migrate @ 17476]
Daniel Atallah <datallah@pidgin.im>
parents:
14758
diff
changeset
|
34 | #else |
|
3a82321f46f2
[gaim-migrate @ 17476]
Daniel Atallah <datallah@pidgin.im>
parents:
14758
diff
changeset
|
35 | #include <nspapi.h> |
|
13156
539a637c61dc
[gaim-migrate @ 15518]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
13131
diff
changeset
|
36 | #endif |
|
539a637c61dc
[gaim-migrate @ 15518]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
13131
diff
changeset
|
37 | |
|
539a637c61dc
[gaim-migrate @ 15518]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
13131
diff
changeset
|
38 | /* Solaris */ |
|
539a637c61dc
[gaim-migrate @ 15518]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
13131
diff
changeset
|
39 | #if defined (__SVR4) && defined (__sun) |
|
539a637c61dc
[gaim-migrate @ 15518]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
13131
diff
changeset
|
40 | #include <sys/sockio.h> |
|
539a637c61dc
[gaim-migrate @ 15518]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
13131
diff
changeset
|
41 | #endif |
|
539a637c61dc
[gaim-migrate @ 15518]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
13131
diff
changeset
|
42 | |
| 8231 | 43 | #include "debug.h" |
| 44 | #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
|
45 | #include "nat-pmp.h" |
| 8231 | 46 | #include "network.h" |
| 47 | #include "prefs.h" | |
|
11411
b74834586187
[gaim-migrate @ 13648]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
11391
diff
changeset
|
48 | #include "stun.h" |
| 8231 | 49 | |
|
37488
88afe246144e
First stab at replacing network-manager with gio, this probably breaks win32, need to test and see
Gary Kramlich <grim@reaperworld.com>
parents:
37466
diff
changeset
|
50 | static gboolean force_online = FALSE; |
|
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
|
51 | |
|
26261
ffabb135a4b6
Added support to generate relayed candidates (TURN).
Marcus Lundblad <malu@pidgin.im>
parents:
26256
diff
changeset
|
52 | /* 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
|
53 | static gchar *stun_ip = NULL; |
|
26261
ffabb135a4b6
Added support to generate relayed candidates (TURN).
Marcus Lundblad <malu@pidgin.im>
parents:
26256
diff
changeset
|
54 | 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
|
55 | |
| 8231 | 56 | void |
| 15884 | 57 | purple_network_set_public_ip(const char *ip) |
| 8231 | 58 | { |
| 59 | g_return_if_fail(ip != NULL); | |
| 60 | ||
|
8838
c23227da7b4a
[gaim-migrate @ 9604]
Mark Doliner <markdoliner@pidgin.im>
parents:
8834
diff
changeset
|
61 | /* XXX - Ensure the IP address is valid */ |
|
c23227da7b4a
[gaim-migrate @ 9604]
Mark Doliner <markdoliner@pidgin.im>
parents:
8834
diff
changeset
|
62 | |
|
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
|
63 | purple_prefs_set_string("/purple/network/public_ip", ip); |
| 8231 | 64 | } |
| 65 | ||
| 66 | const char * | |
| 15884 | 67 | purple_network_get_public_ip(void) |
| 8231 | 68 | { |
|
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
|
69 | return purple_prefs_get_string("/purple/network/public_ip"); |
| 8231 | 70 | } |
| 71 | ||
|
40110
bc2b94f2595a
Make purple_network_get_my_ip_from_gio return non-const.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
40107
diff
changeset
|
72 | static gchar * |
|
40107
6320c272e8b2
xmpp: Convert unencrypted connections to pure GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
40017
diff
changeset
|
73 | purple_network_get_local_system_ip_from_gio(GSocketConnection *sockconn) |
|
6320c272e8b2
xmpp: Convert unencrypted connections to pure GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
40017
diff
changeset
|
74 | { |
|
6320c272e8b2
xmpp: Convert unencrypted connections to pure GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
40017
diff
changeset
|
75 | GSocketAddress *addr; |
|
6320c272e8b2
xmpp: Convert unencrypted connections to pure GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
40017
diff
changeset
|
76 | GInetSocketAddress *inetsockaddr; |
|
40110
bc2b94f2595a
Make purple_network_get_my_ip_from_gio return non-const.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
40107
diff
changeset
|
77 | gchar *ip; |
|
40107
6320c272e8b2
xmpp: Convert unencrypted connections to pure GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
40017
diff
changeset
|
78 | |
|
6320c272e8b2
xmpp: Convert unencrypted connections to pure GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
40017
diff
changeset
|
79 | addr = g_socket_connection_get_local_address(sockconn, NULL); |
|
6320c272e8b2
xmpp: Convert unencrypted connections to pure GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
40017
diff
changeset
|
80 | if ((inetsockaddr = G_INET_SOCKET_ADDRESS(addr)) != NULL) { |
|
6320c272e8b2
xmpp: Convert unencrypted connections to pure GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
40017
diff
changeset
|
81 | GInetAddress *inetaddr = |
|
6320c272e8b2
xmpp: Convert unencrypted connections to pure GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
40017
diff
changeset
|
82 | g_inet_socket_address_get_address(inetsockaddr); |
|
6320c272e8b2
xmpp: Convert unencrypted connections to pure GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
40017
diff
changeset
|
83 | if (g_inet_address_get_family(inetaddr) == G_SOCKET_FAMILY_IPV4 && |
|
6320c272e8b2
xmpp: Convert unencrypted connections to pure GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
40017
diff
changeset
|
84 | !g_inet_address_get_is_loopback(inetaddr)) { |
|
40110
bc2b94f2595a
Make purple_network_get_my_ip_from_gio return non-const.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
40107
diff
changeset
|
85 | ip = g_inet_address_to_string(inetaddr); |
|
bc2b94f2595a
Make purple_network_get_my_ip_from_gio return non-const.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
40107
diff
changeset
|
86 | g_object_unref(addr); |
|
bc2b94f2595a
Make purple_network_get_my_ip_from_gio return non-const.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
40107
diff
changeset
|
87 | return ip; |
|
40107
6320c272e8b2
xmpp: Convert unencrypted connections to pure GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
40017
diff
changeset
|
88 | } |
|
6320c272e8b2
xmpp: Convert unencrypted connections to pure GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
40017
diff
changeset
|
89 | } |
|
6320c272e8b2
xmpp: Convert unencrypted connections to pure GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
40017
diff
changeset
|
90 | g_object_unref(addr); |
|
6320c272e8b2
xmpp: Convert unencrypted connections to pure GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
40017
diff
changeset
|
91 | |
|
40110
bc2b94f2595a
Make purple_network_get_my_ip_from_gio return non-const.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
40107
diff
changeset
|
92 | return g_strdup("0.0.0.0"); |
|
40107
6320c272e8b2
xmpp: Convert unencrypted connections to pure GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
40017
diff
changeset
|
93 | } |
|
6320c272e8b2
xmpp: Convert unencrypted connections to pure GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
40017
diff
changeset
|
94 | |
|
35462
901dfa763f15
Fix some gtk-doc warnings till proxy.c
Ankit Vani <a@nevitus.org>
parents:
35454
diff
changeset
|
95 | /* |
|
901dfa763f15
Fix some gtk-doc warnings till proxy.c
Ankit Vani <a@nevitus.org>
parents:
35454
diff
changeset
|
96 | * purple_network_is_ipv4: |
|
901dfa763f15
Fix some gtk-doc warnings till proxy.c
Ankit Vani <a@nevitus.org>
parents:
35454
diff
changeset
|
97 | * @hostname: The hostname to be verified. |
|
901dfa763f15
Fix some gtk-doc warnings till proxy.c
Ankit Vani <a@nevitus.org>
parents:
35454
diff
changeset
|
98 | * |
|
33894
7e3ea8475aad
Get rid of useless form of purple_network_ip_atoi
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33883
diff
changeset
|
99 | * Checks, if specified hostname is valid ipv4 address. |
|
7e3ea8475aad
Get rid of useless form of purple_network_ip_atoi
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33883
diff
changeset
|
100 | * |
|
35462
901dfa763f15
Fix some gtk-doc warnings till proxy.c
Ankit Vani <a@nevitus.org>
parents:
35454
diff
changeset
|
101 | * Returns: TRUE, if the hostname is valid. |
|
33894
7e3ea8475aad
Get rid of useless form of purple_network_ip_atoi
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33883
diff
changeset
|
102 | */ |
|
7e3ea8475aad
Get rid of useless form of purple_network_ip_atoi
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33883
diff
changeset
|
103 | static gboolean |
|
7e3ea8475aad
Get rid of useless form of purple_network_ip_atoi
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33883
diff
changeset
|
104 | purple_network_is_ipv4(const gchar *hostname) |
|
7e3ea8475aad
Get rid of useless form of purple_network_ip_atoi
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33883
diff
changeset
|
105 | { |
|
7e3ea8475aad
Get rid of useless form of purple_network_ip_atoi
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33883
diff
changeset
|
106 | g_return_val_if_fail(hostname != NULL, FALSE); |
|
7e3ea8475aad
Get rid of useless form of purple_network_ip_atoi
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33883
diff
changeset
|
107 | |
|
7e3ea8475aad
Get rid of useless form of purple_network_ip_atoi
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33883
diff
changeset
|
108 | /* We don't accept ipv6 here. */ |
|
7e3ea8475aad
Get rid of useless form of purple_network_ip_atoi
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33883
diff
changeset
|
109 | if (strchr(hostname, ':') != NULL) |
|
7e3ea8475aad
Get rid of useless form of purple_network_ip_atoi
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33883
diff
changeset
|
110 | return FALSE; |
|
7e3ea8475aad
Get rid of useless form of purple_network_ip_atoi
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33883
diff
changeset
|
111 | |
|
7e3ea8475aad
Get rid of useless form of purple_network_ip_atoi
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33883
diff
changeset
|
112 | return g_hostname_is_ip_address(hostname); |
|
7e3ea8475aad
Get rid of useless form of purple_network_ip_atoi
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33883
diff
changeset
|
113 | } |
|
7e3ea8475aad
Get rid of useless form of purple_network_ip_atoi
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33883
diff
changeset
|
114 | |
|
40663
2453bef0abe7
Cleanup local IP getters
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40659
diff
changeset
|
115 | void |
|
2453bef0abe7
Cleanup local IP getters
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40659
diff
changeset
|
116 | purple_network_discover_my_ip(void) |
| 8231 | 117 | { |
|
12686
ec3e7c4ff045
[gaim-migrate @ 15029]
Richard Laager <rlaager@pidgin.im>
parents:
11424
diff
changeset
|
118 | const char *ip = NULL; |
| 15884 | 119 | PurpleStunNatDiscovery *stun; |
|
8834
0a798e3d2b84
[gaim-migrate @ 9598]
Mark Doliner <markdoliner@pidgin.im>
parents:
8251
diff
changeset
|
120 | |
|
0a798e3d2b84
[gaim-migrate @ 9598]
Mark Doliner <markdoliner@pidgin.im>
parents:
8251
diff
changeset
|
121 | /* 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
|
122 | if (!purple_prefs_get_bool("/purple/network/auto_ip")) { |
| 15884 | 123 | ip = purple_network_get_public_ip(); |
|
15116
037b787407ba
[gaim-migrate @ 17838]
Mark Doliner <markdoliner@pidgin.im>
parents:
14959
diff
changeset
|
124 | /* Make sure the IP address entered by the user is valid */ |
|
40663
2453bef0abe7
Cleanup local IP getters
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40659
diff
changeset
|
125 | if (ip != NULL && purple_network_is_ipv4(ip)) { |
|
2453bef0abe7
Cleanup local IP getters
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40659
diff
changeset
|
126 | return; |
|
2453bef0abe7
Cleanup local IP getters
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40659
diff
changeset
|
127 | } |
|
2453bef0abe7
Cleanup local IP getters
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40659
diff
changeset
|
128 | } |
|
11424
b0f8535daa74
[gaim-migrate @ 13661]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
11411
diff
changeset
|
129 | |
|
40663
2453bef0abe7
Cleanup local IP getters
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40659
diff
changeset
|
130 | /* Check if STUN discovery was already done */ |
|
2453bef0abe7
Cleanup local IP getters
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40659
diff
changeset
|
131 | stun = purple_stun_discover(NULL); |
|
2453bef0abe7
Cleanup local IP getters
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40659
diff
changeset
|
132 | if (stun != NULL && stun->status == PURPLE_STUN_STATUS_DISCOVERED) { |
|
2453bef0abe7
Cleanup local IP getters
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40659
diff
changeset
|
133 | return; |
|
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
|
134 | } |
|
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
|
135 | |
|
40663
2453bef0abe7
Cleanup local IP getters
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40659
diff
changeset
|
136 | /* Attempt to get the IP from a NAT device using NAT-PMP */ |
|
2453bef0abe7
Cleanup local IP getters
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40659
diff
changeset
|
137 | ip = purple_pmp_get_public_ip(); |
|
2453bef0abe7
Cleanup local IP getters
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40659
diff
changeset
|
138 | if (ip != NULL) { |
|
2453bef0abe7
Cleanup local IP getters
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40659
diff
changeset
|
139 | return; |
|
2453bef0abe7
Cleanup local IP getters
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40659
diff
changeset
|
140 | } |
| 8231 | 141 | } |
| 142 | ||
|
40110
bc2b94f2595a
Make purple_network_get_my_ip_from_gio return non-const.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
40107
diff
changeset
|
143 | gchar * |
|
40107
6320c272e8b2
xmpp: Convert unencrypted connections to pure GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
40017
diff
changeset
|
144 | purple_network_get_my_ip_from_gio(GSocketConnection *sockconn) |
|
6320c272e8b2
xmpp: Convert unencrypted connections to pure GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
40017
diff
changeset
|
145 | { |
|
40110
bc2b94f2595a
Make purple_network_get_my_ip_from_gio return non-const.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
40107
diff
changeset
|
146 | const gchar *ip = NULL; |
|
40107
6320c272e8b2
xmpp: Convert unencrypted connections to pure GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
40017
diff
changeset
|
147 | PurpleStunNatDiscovery *stun; |
|
6320c272e8b2
xmpp: Convert unencrypted connections to pure GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
40017
diff
changeset
|
148 | |
|
6320c272e8b2
xmpp: Convert unencrypted connections to pure GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
40017
diff
changeset
|
149 | /* Check if the user specified an IP manually */ |
|
6320c272e8b2
xmpp: Convert unencrypted connections to pure GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
40017
diff
changeset
|
150 | if (!purple_prefs_get_bool("/purple/network/auto_ip")) { |
|
6320c272e8b2
xmpp: Convert unencrypted connections to pure GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
40017
diff
changeset
|
151 | ip = purple_network_get_public_ip(); |
|
6320c272e8b2
xmpp: Convert unencrypted connections to pure GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
40017
diff
changeset
|
152 | /* Make sure the IP address entered by the user is valid */ |
|
6320c272e8b2
xmpp: Convert unencrypted connections to pure GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
40017
diff
changeset
|
153 | if ((ip != NULL) && (purple_network_is_ipv4(ip))) { |
|
40110
bc2b94f2595a
Make purple_network_get_my_ip_from_gio return non-const.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
40107
diff
changeset
|
154 | return g_strdup(ip); |
|
40107
6320c272e8b2
xmpp: Convert unencrypted connections to pure GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
40017
diff
changeset
|
155 | } |
|
6320c272e8b2
xmpp: Convert unencrypted connections to pure GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
40017
diff
changeset
|
156 | } else { |
|
6320c272e8b2
xmpp: Convert unencrypted connections to pure GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
40017
diff
changeset
|
157 | /* Check if STUN discovery was already done */ |
|
6320c272e8b2
xmpp: Convert unencrypted connections to pure GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
40017
diff
changeset
|
158 | stun = purple_stun_discover(NULL); |
|
6320c272e8b2
xmpp: Convert unencrypted connections to pure GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
40017
diff
changeset
|
159 | if ((stun != NULL) && (stun->status == PURPLE_STUN_STATUS_DISCOVERED)) { |
|
40110
bc2b94f2595a
Make purple_network_get_my_ip_from_gio return non-const.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
40107
diff
changeset
|
160 | return g_strdup(stun->publicip); |
|
40107
6320c272e8b2
xmpp: Convert unencrypted connections to pure GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
40017
diff
changeset
|
161 | } |
|
6320c272e8b2
xmpp: Convert unencrypted connections to pure GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
40017
diff
changeset
|
162 | |
|
6320c272e8b2
xmpp: Convert unencrypted connections to pure GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
40017
diff
changeset
|
163 | /* Attempt to get the IP from a NAT device using NAT-PMP */ |
|
6320c272e8b2
xmpp: Convert unencrypted connections to pure GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
40017
diff
changeset
|
164 | ip = purple_pmp_get_public_ip(); |
|
6320c272e8b2
xmpp: Convert unencrypted connections to pure GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
40017
diff
changeset
|
165 | if (ip != NULL) { |
|
40110
bc2b94f2595a
Make purple_network_get_my_ip_from_gio return non-const.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
40107
diff
changeset
|
166 | return g_strdup(ip); |
|
40107
6320c272e8b2
xmpp: Convert unencrypted connections to pure GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
40017
diff
changeset
|
167 | } |
|
6320c272e8b2
xmpp: Convert unencrypted connections to pure GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
40017
diff
changeset
|
168 | } |
|
6320c272e8b2
xmpp: Convert unencrypted connections to pure GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
40017
diff
changeset
|
169 | |
|
6320c272e8b2
xmpp: Convert unencrypted connections to pure GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
40017
diff
changeset
|
170 | /* Just fetch the IP of the local system */ |
|
6320c272e8b2
xmpp: Convert unencrypted connections to pure GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
40017
diff
changeset
|
171 | return purple_network_get_local_system_ip_from_gio(sockconn); |
|
6320c272e8b2
xmpp: Convert unencrypted connections to pure GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
40017
diff
changeset
|
172 | } |
|
11391
d172e72988cc
[gaim-migrate @ 13620]
Adam Warrington <awarring@users.sourceforge.net>
parents:
11336
diff
changeset
|
173 | |
| 14758 | 174 | gboolean |
| 15884 | 175 | purple_network_is_available(void) |
| 14758 | 176 | { |
|
37488
88afe246144e
First stab at replacing network-manager with gio, this probably breaks win32, need to test and see
Gary Kramlich <grim@reaperworld.com>
parents:
37466
diff
changeset
|
177 | if(force_online) { |
|
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
|
178 | 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
|
179 | } |
|
24519
d4af3d043211
Improve our NetworkManager support in a couple of ways:
Richard Laager <rlaager@pidgin.im>
parents:
24044
diff
changeset
|
180 | |
|
37488
88afe246144e
First stab at replacing network-manager with gio, this probably breaks win32, need to test and see
Gary Kramlich <grim@reaperworld.com>
parents:
37466
diff
changeset
|
181 | return g_network_monitor_get_network_available(g_network_monitor_get_default()); |
| 14758 | 182 | } |
| 183 | ||
|
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
|
184 | void |
|
41840
fe350460fb1c
Remove C99-obsoleted constructs
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41828
diff
changeset
|
185 | purple_network_force_online(void) |
|
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
|
186 | { |
|
84d597b7e7c6
Add a -f/--force-online option to Pidgin which tells libpurple to claim the
Richard Laager <rlaager@pidgin.im>
parents:
24519
diff
changeset
|
187 | force_online = TRUE; |
| 14758 | 188 | } |
|
23039
c9b53691fe42
A patch from QuLogic to replace the libnm_glib calls with straight DBus
Richard Laager <rlaager@pidgin.im>
parents:
22735
diff
changeset
|
189 | |
|
c9b53691fe42
A patch from QuLogic to replace the libnm_glib calls with straight DBus
Richard Laager <rlaager@pidgin.im>
parents:
22735
diff
changeset
|
190 | static void |
|
37464
8785324c1740
Remove some async lookups that accidentally got left in from my first run at this
Gary Kramlich <grim@reaperworld.com>
parents:
37453
diff
changeset
|
191 | purple_network_ip_lookup_cb(GObject *sender, GAsyncResult *result, gpointer data) { |
|
37450
703722d83214
Update network.c for the dns code removal
Gary Kramlich <grim@reaperworld.com>
parents:
36031
diff
changeset
|
192 | GError *error = NULL; |
|
37464
8785324c1740
Remove some async lookups that accidentally got left in from my first run at this
Gary Kramlich <grim@reaperworld.com>
parents:
37453
diff
changeset
|
193 | GList *addresses = NULL; |
|
37450
703722d83214
Update network.c for the dns code removal
Gary Kramlich <grim@reaperworld.com>
parents:
36031
diff
changeset
|
194 | GInetAddress *address = NULL; |
|
37464
8785324c1740
Remove some async lookups that accidentally got left in from my first run at this
Gary Kramlich <grim@reaperworld.com>
parents:
37453
diff
changeset
|
195 | const gchar **ip_address = (const gchar **)data; |
|
23039
c9b53691fe42
A patch from QuLogic to replace the libnm_glib calls with straight DBus
Richard Laager <rlaager@pidgin.im>
parents:
22735
diff
changeset
|
196 | |
|
37517
a67be31f9c7e
Use the GResolver which was passed to g_resolver_lookup_*_async()
Mike Ruprecht <cmaiku@gmail.com>
parents:
37489
diff
changeset
|
197 | addresses = g_resolver_lookup_by_name_finish(G_RESOLVER(sender), |
|
a67be31f9c7e
Use the GResolver which was passed to g_resolver_lookup_*_async()
Mike Ruprecht <cmaiku@gmail.com>
parents:
37489
diff
changeset
|
198 | result, &error); |
|
37464
8785324c1740
Remove some async lookups that accidentally got left in from my first run at this
Gary Kramlich <grim@reaperworld.com>
parents:
37453
diff
changeset
|
199 | if(error) { |
|
37450
703722d83214
Update network.c for the dns code removal
Gary Kramlich <grim@reaperworld.com>
parents:
36031
diff
changeset
|
200 | purple_debug_info("network", "lookup of IP address failed: %s\n", error->message); |
|
23039
c9b53691fe42
A patch from QuLogic to replace the libnm_glib calls with straight DBus
Richard Laager <rlaager@pidgin.im>
parents:
22735
diff
changeset
|
201 | |
|
37450
703722d83214
Update network.c for the dns code removal
Gary Kramlich <grim@reaperworld.com>
parents:
36031
diff
changeset
|
202 | g_error_free(error); |
|
23039
c9b53691fe42
A patch from QuLogic to replace the libnm_glib calls with straight DBus
Richard Laager <rlaager@pidgin.im>
parents:
22735
diff
changeset
|
203 | |
|
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
|
204 | 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
|
205 | } |
|
26262
1ad96aa2e92a
Removed some extra tabs on blank lines
Marcus Lundblad <malu@pidgin.im>
parents:
26261
diff
changeset
|
206 | |
|
37464
8785324c1740
Remove some async lookups that accidentally got left in from my first run at this
Gary Kramlich <grim@reaperworld.com>
parents:
37453
diff
changeset
|
207 | address = G_INET_ADDRESS(addresses->data); |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
31191
diff
changeset
|
208 | |
|
37464
8785324c1740
Remove some async lookups that accidentally got left in from my first run at this
Gary Kramlich <grim@reaperworld.com>
parents:
37453
diff
changeset
|
209 | *ip_address = g_inet_address_to_string(address); |
|
26262
1ad96aa2e92a
Removed some extra tabs on blank lines
Marcus Lundblad <malu@pidgin.im>
parents:
26261
diff
changeset
|
210 | |
|
37450
703722d83214
Update network.c for the dns code removal
Gary Kramlich <grim@reaperworld.com>
parents:
36031
diff
changeset
|
211 | g_resolver_free_addresses(addresses); |
|
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
|
212 | } |
|
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
|
213 | |
|
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
|
214 | 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
|
215 | 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
|
216 | { |
|
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
|
217 | 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
|
218 | if (purple_network_is_available()) { |
|
37518
53c9ebedf2b7
Plug g_resolver_get_default() leaks
Mike Ruprecht <cmaiku@gmail.com>
parents:
37517
diff
changeset
|
219 | GResolver *resolver = g_resolver_get_default(); |
|
53c9ebedf2b7
Plug g_resolver_get_default() leaks
Mike Ruprecht <cmaiku@gmail.com>
parents:
37517
diff
changeset
|
220 | g_resolver_lookup_by_name_async(resolver, |
|
37464
8785324c1740
Remove some async lookups that accidentally got left in from my first run at this
Gary Kramlich <grim@reaperworld.com>
parents:
37453
diff
changeset
|
221 | stun_server, |
|
8785324c1740
Remove some async lookups that accidentally got left in from my first run at this
Gary Kramlich <grim@reaperworld.com>
parents:
37453
diff
changeset
|
222 | NULL, |
|
8785324c1740
Remove some async lookups that accidentally got left in from my first run at this
Gary Kramlich <grim@reaperworld.com>
parents:
37453
diff
changeset
|
223 | purple_network_ip_lookup_cb, |
|
8785324c1740
Remove some async lookups that accidentally got left in from my first run at this
Gary Kramlich <grim@reaperworld.com>
parents:
37453
diff
changeset
|
224 | &stun_ip); |
|
37518
53c9ebedf2b7
Plug g_resolver_get_default() leaks
Mike Ruprecht <cmaiku@gmail.com>
parents:
37517
diff
changeset
|
225 | g_object_unref(resolver); |
|
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
|
226 | } else { |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
31191
diff
changeset
|
227 | purple_debug_info("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
|
228 | "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
|
229 | } |
|
37426
6fd4989b77e4
The last of the NULL-checks before free()
Michael McConville <mmcco@mykolab.com>
parents:
36031
diff
changeset
|
230 | } else { |
|
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
|
231 | 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
|
232 | 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
|
233 | } |
|
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
|
234 | } |
|
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
|
235 | |
|
26261
ffabb135a4b6
Added support to generate relayed candidates (TURN).
Marcus Lundblad <malu@pidgin.im>
parents:
26256
diff
changeset
|
236 | void |
|
ffabb135a4b6
Added support to generate relayed candidates (TURN).
Marcus Lundblad <malu@pidgin.im>
parents:
26256
diff
changeset
|
237 | 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
|
238 | { |
|
ffabb135a4b6
Added support to generate relayed candidates (TURN).
Marcus Lundblad <malu@pidgin.im>
parents:
26256
diff
changeset
|
239 | if (turn_server && turn_server[0] != '\0') { |
|
ffabb135a4b6
Added support to generate relayed candidates (TURN).
Marcus Lundblad <malu@pidgin.im>
parents:
26256
diff
changeset
|
240 | if (purple_network_is_available()) { |
|
37518
53c9ebedf2b7
Plug g_resolver_get_default() leaks
Mike Ruprecht <cmaiku@gmail.com>
parents:
37517
diff
changeset
|
241 | GResolver *resolver = g_resolver_get_default(); |
|
53c9ebedf2b7
Plug g_resolver_get_default() leaks
Mike Ruprecht <cmaiku@gmail.com>
parents:
37517
diff
changeset
|
242 | g_resolver_lookup_by_name_async(resolver, |
|
37464
8785324c1740
Remove some async lookups that accidentally got left in from my first run at this
Gary Kramlich <grim@reaperworld.com>
parents:
37453
diff
changeset
|
243 | turn_server, |
|
8785324c1740
Remove some async lookups that accidentally got left in from my first run at this
Gary Kramlich <grim@reaperworld.com>
parents:
37453
diff
changeset
|
244 | NULL, |
|
8785324c1740
Remove some async lookups that accidentally got left in from my first run at this
Gary Kramlich <grim@reaperworld.com>
parents:
37453
diff
changeset
|
245 | purple_network_ip_lookup_cb, |
|
40264
d253f767f6cc
fix various memory leaks
Fabrice Bellet <fabrice@bellet.info>
parents:
40110
diff
changeset
|
246 | &turn_ip); |
|
37518
53c9ebedf2b7
Plug g_resolver_get_default() leaks
Mike Ruprecht <cmaiku@gmail.com>
parents:
37517
diff
changeset
|
247 | g_object_unref(resolver); |
|
26261
ffabb135a4b6
Added support to generate relayed candidates (TURN).
Marcus Lundblad <malu@pidgin.im>
parents:
26256
diff
changeset
|
248 | } else { |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
31191
diff
changeset
|
249 | purple_debug_info("network", |
|
26261
ffabb135a4b6
Added support to generate relayed candidates (TURN).
Marcus Lundblad <malu@pidgin.im>
parents:
26256
diff
changeset
|
250 | "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
|
251 | } |
|
37426
6fd4989b77e4
The last of the NULL-checks before free()
Michael McConville <mmcco@mykolab.com>
parents:
36031
diff
changeset
|
252 | } else { |
|
26261
ffabb135a4b6
Added support to generate relayed candidates (TURN).
Marcus Lundblad <malu@pidgin.im>
parents:
26256
diff
changeset
|
253 | g_free(turn_ip); |
|
ffabb135a4b6
Added support to generate relayed candidates (TURN).
Marcus Lundblad <malu@pidgin.im>
parents:
26256
diff
changeset
|
254 | turn_ip = NULL; |
|
ffabb135a4b6
Added support to generate relayed candidates (TURN).
Marcus Lundblad <malu@pidgin.im>
parents:
26256
diff
changeset
|
255 | } |
|
ffabb135a4b6
Added support to generate relayed candidates (TURN).
Marcus Lundblad <malu@pidgin.im>
parents:
26256
diff
changeset
|
256 | } |
|
ffabb135a4b6
Added support to generate relayed candidates (TURN).
Marcus Lundblad <malu@pidgin.im>
parents:
26256
diff
changeset
|
257 | |
|
ffabb135a4b6
Added support to generate relayed candidates (TURN).
Marcus Lundblad <malu@pidgin.im>
parents:
26256
diff
changeset
|
258 | |
|
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
|
259 | 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
|
260 | 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
|
261 | { |
|
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
|
262 | 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
|
263 | } |
|
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
|
264 | |
|
26261
ffabb135a4b6
Added support to generate relayed candidates (TURN).
Marcus Lundblad <malu@pidgin.im>
parents:
26256
diff
changeset
|
265 | const gchar * |
|
ffabb135a4b6
Added support to generate relayed candidates (TURN).
Marcus Lundblad <malu@pidgin.im>
parents:
26256
diff
changeset
|
266 | purple_network_get_turn_ip(void) |
|
ffabb135a4b6
Added support to generate relayed candidates (TURN).
Marcus Lundblad <malu@pidgin.im>
parents:
26256
diff
changeset
|
267 | { |
|
ffabb135a4b6
Added support to generate relayed candidates (TURN).
Marcus Lundblad <malu@pidgin.im>
parents:
26256
diff
changeset
|
268 | return turn_ip; |
|
ffabb135a4b6
Added support to generate relayed candidates (TURN).
Marcus Lundblad <malu@pidgin.im>
parents:
26256
diff
changeset
|
269 | } |
|
ffabb135a4b6
Added support to generate relayed candidates (TURN).
Marcus Lundblad <malu@pidgin.im>
parents:
26256
diff
changeset
|
270 | |
|
36028
fc5300cb3617
Get rid of fair amount of copy-pasta and coverity warnings
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35991
diff
changeset
|
271 | gboolean |
|
fc5300cb3617
Get rid of fair amount of copy-pasta and coverity warnings
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35991
diff
changeset
|
272 | _purple_network_set_common_socket_flags(int fd) |
|
fc5300cb3617
Get rid of fair amount of copy-pasta and coverity warnings
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35991
diff
changeset
|
273 | { |
|
fc5300cb3617
Get rid of fair amount of copy-pasta and coverity warnings
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35991
diff
changeset
|
274 | int flags; |
|
fc5300cb3617
Get rid of fair amount of copy-pasta and coverity warnings
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35991
diff
changeset
|
275 | gboolean succ = TRUE; |
|
fc5300cb3617
Get rid of fair amount of copy-pasta and coverity warnings
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35991
diff
changeset
|
276 | |
|
fc5300cb3617
Get rid of fair amount of copy-pasta and coverity warnings
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35991
diff
changeset
|
277 | g_return_val_if_fail(fd >= 0, FALSE); |
|
fc5300cb3617
Get rid of fair amount of copy-pasta and coverity warnings
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35991
diff
changeset
|
278 | |
|
fc5300cb3617
Get rid of fair amount of copy-pasta and coverity warnings
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35991
diff
changeset
|
279 | flags = fcntl(fd, F_GETFL); |
|
fc5300cb3617
Get rid of fair amount of copy-pasta and coverity warnings
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35991
diff
changeset
|
280 | |
|
fc5300cb3617
Get rid of fair amount of copy-pasta and coverity warnings
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35991
diff
changeset
|
281 | if (fcntl(fd, F_SETFL, flags | O_NONBLOCK) != 0) { |
|
fc5300cb3617
Get rid of fair amount of copy-pasta and coverity warnings
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35991
diff
changeset
|
282 | purple_debug_warning("network", |
|
fc5300cb3617
Get rid of fair amount of copy-pasta and coverity warnings
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35991
diff
changeset
|
283 | "Couldn't set O_NONBLOCK flag\n"); |
|
fc5300cb3617
Get rid of fair amount of copy-pasta and coverity warnings
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35991
diff
changeset
|
284 | succ = FALSE; |
|
fc5300cb3617
Get rid of fair amount of copy-pasta and coverity warnings
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35991
diff
changeset
|
285 | } |
|
fc5300cb3617
Get rid of fair amount of copy-pasta and coverity warnings
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35991
diff
changeset
|
286 | |
|
fc5300cb3617
Get rid of fair amount of copy-pasta and coverity warnings
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35991
diff
changeset
|
287 | #ifndef _WIN32 |
|
fc5300cb3617
Get rid of fair amount of copy-pasta and coverity warnings
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35991
diff
changeset
|
288 | if (fcntl(fd, F_SETFD, FD_CLOEXEC) != 0) { |
|
fc5300cb3617
Get rid of fair amount of copy-pasta and coverity warnings
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35991
diff
changeset
|
289 | purple_debug_warning("network", |
|
fc5300cb3617
Get rid of fair amount of copy-pasta and coverity warnings
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35991
diff
changeset
|
290 | "Couldn't set FD_CLOEXEC flag\n"); |
|
fc5300cb3617
Get rid of fair amount of copy-pasta and coverity warnings
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35991
diff
changeset
|
291 | succ = FALSE; |
|
fc5300cb3617
Get rid of fair amount of copy-pasta and coverity warnings
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35991
diff
changeset
|
292 | } |
|
fc5300cb3617
Get rid of fair amount of copy-pasta and coverity warnings
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35991
diff
changeset
|
293 | #endif |
|
fc5300cb3617
Get rid of fair amount of copy-pasta and coverity warnings
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35991
diff
changeset
|
294 | |
|
fc5300cb3617
Get rid of fair amount of copy-pasta and coverity warnings
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35991
diff
changeset
|
295 | return succ; |
|
fc5300cb3617
Get rid of fair amount of copy-pasta and coverity warnings
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35991
diff
changeset
|
296 | } |
|
fc5300cb3617
Get rid of fair amount of copy-pasta and coverity warnings
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35991
diff
changeset
|
297 | |
| 8231 | 298 | void |
| 15884 | 299 | purple_network_init(void) |
| 8231 | 300 | { |
|
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
|
301 | 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
|
302 | 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
|
303 | 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
|
304 | purple_prefs_add_int ("/purple/network/turn_port", 3478); |
|
31831
c3778a69ecee
Add support for using TCP relaying with TURN
Marcus Lundblad <malu@pidgin.im>
parents:
31680
diff
changeset
|
305 | purple_prefs_add_int ("/purple/network/turn_port_tcp", 3478); |
|
26261
ffabb135a4b6
Added support to generate relayed candidates (TURN).
Marcus Lundblad <malu@pidgin.im>
parents:
26256
diff
changeset
|
306 | 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
|
307 | 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
|
308 | 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
|
309 | 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
|
310 | 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
|
311 | 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
|
312 | 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
|
313 | purple_prefs_add_int ("/purple/network/ports_range_end", 2048); |
|
12909
dfcf4df1dcd7
[gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents:
12730
diff
changeset
|
314 | |
|
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
|
315 | purple_pmp_init(); |
|
31191
163f03d8d1d2
Cast back and forth between int and pointer instead of putting pointers
Mark Doliner <markdoliner@pidgin.im>
parents:
30792
diff
changeset
|
316 | |
|
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
|
317 | 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
|
318 | 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
|
319 | purple_network_set_turn_server( |
|
ffabb135a4b6
Added support to generate relayed candidates (TURN).
Marcus Lundblad <malu@pidgin.im>
parents:
26256
diff
changeset
|
320 | purple_prefs_get_string("/purple/network/turn_server")); |
| 8231 | 321 | } |
| 14758 | 322 | |
| 323 | void | |
| 15884 | 324 | purple_network_uninit(void) |
| 14758 | 325 | { |
|
37426
6fd4989b77e4
The last of the NULL-checks before free()
Michael McConville <mmcco@mykolab.com>
parents:
36031
diff
changeset
|
326 | g_free(stun_ip); |
|
40264
d253f767f6cc
fix various memory leaks
Fabrice Bellet <fabrice@bellet.info>
parents:
40110
diff
changeset
|
327 | g_free(turn_ip); |
| 14758 | 328 | } |