Mon, 13 Nov 2023 20:52:30 -0600
Fix some small doc issues
- `Return Value` is deprecated.
- `See Also` is not a valid tag, and does not appear anywhere. If placed in the
description, then it does appear, but just like a regular paragraph, so write
it like one.
- Fix a few typos.
Testing Done:
Built docs.
Reviewed at https://reviews.imfreedom.org/r/2803/
|
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 | ||
|
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
|
22 | #include "purpleprivate.h" |
| 8231 | 23 | |
|
37450
703722d83214
Update network.c for the dns code removal
Gary Kramlich <grim@reaperworld.com>
parents:
36031
diff
changeset
|
24 | #include <gio/gio.h> |
|
703722d83214
Update network.c for the dns code removal
Gary Kramlich <grim@reaperworld.com>
parents:
36031
diff
changeset
|
25 | |
|
41682
289867067994
Clean up a bunch of stuff in internal.h
Gary Kramlich <grim@reaperworld.com>
parents:
41153
diff
changeset
|
26 | #include <fcntl.h> |
|
289867067994
Clean up a bunch of stuff in internal.h
Gary Kramlich <grim@reaperworld.com>
parents:
41153
diff
changeset
|
27 | |
| 42280 | 28 | #ifdef _WIN32 |
|
42285
fc89d66998c4
Fix the windows build by adding a missing include
Gary Kramlich <grim@reaperworld.com>
parents:
42280
diff
changeset
|
29 | # include "win32/libc_interface.h" |
| 42280 | 30 | # include <nspapi.h> |
|
13156
539a637c61dc
[gaim-migrate @ 15518]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
13131
diff
changeset
|
31 | #endif |
|
539a637c61dc
[gaim-migrate @ 15518]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
13131
diff
changeset
|
32 | |
| 8231 | 33 | #include "debug.h" |
| 34 | #include "network.h" | |
| 35 | #include "prefs.h" | |
|
42344
c51d37734155
Rename account.[ch] to purpleaccount.[ch]
Gary Kramlich <grim@reaperworld.com>
parents:
42285
diff
changeset
|
36 | #include "purpleaccount.h" |
| 8231 | 37 | |
|
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
|
38 | 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
|
39 | |
| 8231 | 40 | void |
| 15884 | 41 | purple_network_set_public_ip(const char *ip) |
| 8231 | 42 | { |
| 43 | g_return_if_fail(ip != NULL); | |
| 44 | ||
|
8838
c23227da7b4a
[gaim-migrate @ 9604]
Mark Doliner <markdoliner@pidgin.im>
parents:
8834
diff
changeset
|
45 | /* XXX - Ensure the IP address is valid */ |
|
c23227da7b4a
[gaim-migrate @ 9604]
Mark Doliner <markdoliner@pidgin.im>
parents:
8834
diff
changeset
|
46 | |
|
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
|
47 | purple_prefs_set_string("/purple/network/public_ip", ip); |
| 8231 | 48 | } |
| 49 | ||
| 50 | const char * | |
| 15884 | 51 | purple_network_get_public_ip(void) |
| 8231 | 52 | { |
|
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
|
53 | return purple_prefs_get_string("/purple/network/public_ip"); |
| 8231 | 54 | } |
| 55 | ||
|
40110
bc2b94f2595a
Make purple_network_get_my_ip_from_gio return non-const.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
40107
diff
changeset
|
56 | static gchar * |
|
40107
6320c272e8b2
xmpp: Convert unencrypted connections to pure GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
40017
diff
changeset
|
57 | 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
|
58 | { |
|
6320c272e8b2
xmpp: Convert unencrypted connections to pure GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
40017
diff
changeset
|
59 | GSocketAddress *addr; |
|
6320c272e8b2
xmpp: Convert unencrypted connections to pure GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
40017
diff
changeset
|
60 | 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
|
61 | gchar *ip; |
|
40107
6320c272e8b2
xmpp: Convert unencrypted connections to pure GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
40017
diff
changeset
|
62 | |
|
6320c272e8b2
xmpp: Convert unencrypted connections to pure GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
40017
diff
changeset
|
63 | 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
|
64 | 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
|
65 | GInetAddress *inetaddr = |
|
6320c272e8b2
xmpp: Convert unencrypted connections to pure GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
40017
diff
changeset
|
66 | 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
|
67 | 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
|
68 | !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
|
69 | 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
|
70 | 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
|
71 | return ip; |
|
40107
6320c272e8b2
xmpp: Convert unencrypted connections to pure GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
40017
diff
changeset
|
72 | } |
|
6320c272e8b2
xmpp: Convert unencrypted connections to pure GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
40017
diff
changeset
|
73 | } |
|
6320c272e8b2
xmpp: Convert unencrypted connections to pure GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
40017
diff
changeset
|
74 | g_object_unref(addr); |
|
6320c272e8b2
xmpp: Convert unencrypted connections to pure GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
40017
diff
changeset
|
75 | |
|
40110
bc2b94f2595a
Make purple_network_get_my_ip_from_gio return non-const.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
40107
diff
changeset
|
76 | 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
|
77 | } |
|
6320c272e8b2
xmpp: Convert unencrypted connections to pure GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
40017
diff
changeset
|
78 | |
|
35462
901dfa763f15
Fix some gtk-doc warnings till proxy.c
Ankit Vani <a@nevitus.org>
parents:
35454
diff
changeset
|
79 | /* |
|
901dfa763f15
Fix some gtk-doc warnings till proxy.c
Ankit Vani <a@nevitus.org>
parents:
35454
diff
changeset
|
80 | * purple_network_is_ipv4: |
|
901dfa763f15
Fix some gtk-doc warnings till proxy.c
Ankit Vani <a@nevitus.org>
parents:
35454
diff
changeset
|
81 | * @hostname: The hostname to be verified. |
|
901dfa763f15
Fix some gtk-doc warnings till proxy.c
Ankit Vani <a@nevitus.org>
parents:
35454
diff
changeset
|
82 | * |
|
33894
7e3ea8475aad
Get rid of useless form of purple_network_ip_atoi
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33883
diff
changeset
|
83 | * 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
|
84 | * |
|
35462
901dfa763f15
Fix some gtk-doc warnings till proxy.c
Ankit Vani <a@nevitus.org>
parents:
35454
diff
changeset
|
85 | * 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
|
86 | */ |
|
7e3ea8475aad
Get rid of useless form of purple_network_ip_atoi
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33883
diff
changeset
|
87 | static gboolean |
|
7e3ea8475aad
Get rid of useless form of purple_network_ip_atoi
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33883
diff
changeset
|
88 | 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
|
89 | { |
|
7e3ea8475aad
Get rid of useless form of purple_network_ip_atoi
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33883
diff
changeset
|
90 | 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
|
91 | |
|
7e3ea8475aad
Get rid of useless form of purple_network_ip_atoi
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33883
diff
changeset
|
92 | /* 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
|
93 | 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
|
94 | return FALSE; |
|
7e3ea8475aad
Get rid of useless form of purple_network_ip_atoi
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33883
diff
changeset
|
95 | |
|
7e3ea8475aad
Get rid of useless form of purple_network_ip_atoi
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33883
diff
changeset
|
96 | 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
|
97 | } |
|
7e3ea8475aad
Get rid of useless form of purple_network_ip_atoi
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33883
diff
changeset
|
98 | |
|
40663
2453bef0abe7
Cleanup local IP getters
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40659
diff
changeset
|
99 | void |
|
2453bef0abe7
Cleanup local IP getters
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40659
diff
changeset
|
100 | purple_network_discover_my_ip(void) |
| 8231 | 101 | { |
|
12686
ec3e7c4ff045
[gaim-migrate @ 15029]
Richard Laager <rlaager@pidgin.im>
parents:
11424
diff
changeset
|
102 | const char *ip = NULL; |
|
8834
0a798e3d2b84
[gaim-migrate @ 9598]
Mark Doliner <markdoliner@pidgin.im>
parents:
8251
diff
changeset
|
103 | |
|
0a798e3d2b84
[gaim-migrate @ 9598]
Mark Doliner <markdoliner@pidgin.im>
parents:
8251
diff
changeset
|
104 | /* 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
|
105 | if (!purple_prefs_get_bool("/purple/network/auto_ip")) { |
| 15884 | 106 | ip = purple_network_get_public_ip(); |
|
15116
037b787407ba
[gaim-migrate @ 17838]
Mark Doliner <markdoliner@pidgin.im>
parents:
14959
diff
changeset
|
107 | /* 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
|
108 | 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
|
109 | return; |
|
2453bef0abe7
Cleanup local IP getters
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40659
diff
changeset
|
110 | } |
|
2453bef0abe7
Cleanup local IP getters
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40659
diff
changeset
|
111 | } |
| 8231 | 112 | } |
| 113 | ||
|
40110
bc2b94f2595a
Make purple_network_get_my_ip_from_gio return non-const.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
40107
diff
changeset
|
114 | gchar * |
|
40107
6320c272e8b2
xmpp: Convert unencrypted connections to pure GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
40017
diff
changeset
|
115 | 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
|
116 | { |
|
6320c272e8b2
xmpp: Convert unencrypted connections to pure GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
40017
diff
changeset
|
117 | /* 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
|
118 | if (!purple_prefs_get_bool("/purple/network/auto_ip")) { |
|
42118
97bc84c5233e
Remove our stun code
Gary Kramlich <grim@reaperworld.com>
parents:
42032
diff
changeset
|
119 | const gchar *ip = NULL; |
|
97bc84c5233e
Remove our stun code
Gary Kramlich <grim@reaperworld.com>
parents:
42032
diff
changeset
|
120 | |
|
40107
6320c272e8b2
xmpp: Convert unencrypted connections to pure GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
40017
diff
changeset
|
121 | ip = purple_network_get_public_ip(); |
|
42118
97bc84c5233e
Remove our stun code
Gary Kramlich <grim@reaperworld.com>
parents:
42032
diff
changeset
|
122 | |
|
40107
6320c272e8b2
xmpp: Convert unencrypted connections to pure GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
40017
diff
changeset
|
123 | /* 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
|
124 | 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
|
125 | return g_strdup(ip); |
|
40107
6320c272e8b2
xmpp: Convert unencrypted connections to pure GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
40017
diff
changeset
|
126 | } |
|
6320c272e8b2
xmpp: Convert unencrypted connections to pure GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
40017
diff
changeset
|
127 | } |
|
6320c272e8b2
xmpp: Convert unencrypted connections to pure GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
40017
diff
changeset
|
128 | |
|
6320c272e8b2
xmpp: Convert unencrypted connections to pure GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
40017
diff
changeset
|
129 | /* 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
|
130 | 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
|
131 | } |
|
11391
d172e72988cc
[gaim-migrate @ 13620]
Adam Warrington <awarring@users.sourceforge.net>
parents:
11336
diff
changeset
|
132 | |
| 14758 | 133 | gboolean |
| 15884 | 134 | purple_network_is_available(void) |
| 14758 | 135 | { |
|
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
|
136 | 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
|
137 | 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
|
138 | } |
|
24519
d4af3d043211
Improve our NetworkManager support in a couple of ways:
Richard Laager <rlaager@pidgin.im>
parents:
24044
diff
changeset
|
139 | |
|
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
|
140 | return g_network_monitor_get_network_available(g_network_monitor_get_default()); |
| 14758 | 141 | } |
| 142 | ||
|
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
|
143 | void |
|
41840
fe350460fb1c
Remove C99-obsoleted constructs
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41828
diff
changeset
|
144 | 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
|
145 | { |
|
84d597b7e7c6
Add a -f/--force-online option to Pidgin which tells libpurple to claim the
Richard Laager <rlaager@pidgin.im>
parents:
24519
diff
changeset
|
146 | force_online = TRUE; |
| 14758 | 147 | } |
|
23039
c9b53691fe42
A patch from QuLogic to replace the libnm_glib calls with straight DBus
Richard Laager <rlaager@pidgin.im>
parents:
22735
diff
changeset
|
148 | |
|
36028
fc5300cb3617
Get rid of fair amount of copy-pasta and coverity warnings
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35991
diff
changeset
|
149 | gboolean |
|
fc5300cb3617
Get rid of fair amount of copy-pasta and coverity warnings
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35991
diff
changeset
|
150 | _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
|
151 | { |
|
fc5300cb3617
Get rid of fair amount of copy-pasta and coverity warnings
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35991
diff
changeset
|
152 | int flags; |
|
fc5300cb3617
Get rid of fair amount of copy-pasta and coverity warnings
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35991
diff
changeset
|
153 | gboolean succ = TRUE; |
|
fc5300cb3617
Get rid of fair amount of copy-pasta and coverity warnings
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35991
diff
changeset
|
154 | |
|
fc5300cb3617
Get rid of fair amount of copy-pasta and coverity warnings
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35991
diff
changeset
|
155 | 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
|
156 | |
|
fc5300cb3617
Get rid of fair amount of copy-pasta and coverity warnings
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35991
diff
changeset
|
157 | 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
|
158 | |
|
fc5300cb3617
Get rid of fair amount of copy-pasta and coverity warnings
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35991
diff
changeset
|
159 | 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
|
160 | 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
|
161 | "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
|
162 | succ = FALSE; |
|
fc5300cb3617
Get rid of fair amount of copy-pasta and coverity warnings
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35991
diff
changeset
|
163 | } |
|
fc5300cb3617
Get rid of fair amount of copy-pasta and coverity warnings
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35991
diff
changeset
|
164 | |
|
fc5300cb3617
Get rid of fair amount of copy-pasta and coverity warnings
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35991
diff
changeset
|
165 | #ifndef _WIN32 |
|
fc5300cb3617
Get rid of fair amount of copy-pasta and coverity warnings
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35991
diff
changeset
|
166 | 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
|
167 | 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
|
168 | "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
|
169 | succ = FALSE; |
|
fc5300cb3617
Get rid of fair amount of copy-pasta and coverity warnings
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35991
diff
changeset
|
170 | } |
|
fc5300cb3617
Get rid of fair amount of copy-pasta and coverity warnings
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35991
diff
changeset
|
171 | #endif |
|
fc5300cb3617
Get rid of fair amount of copy-pasta and coverity warnings
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35991
diff
changeset
|
172 | |
|
fc5300cb3617
Get rid of fair amount of copy-pasta and coverity warnings
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35991
diff
changeset
|
173 | return succ; |
|
fc5300cb3617
Get rid of fair amount of copy-pasta and coverity warnings
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35991
diff
changeset
|
174 | } |
|
fc5300cb3617
Get rid of fair amount of copy-pasta and coverity warnings
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35991
diff
changeset
|
175 | |
| 8231 | 176 | void |
| 15884 | 177 | purple_network_init(void) |
| 8231 | 178 | { |
|
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
|
179 | purple_prefs_add_none ("/purple/network"); |
|
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
|
180 | 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
|
181 | 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
|
182 | 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
|
183 | 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
|
184 | 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
|
185 | purple_prefs_add_int ("/purple/network/ports_range_end", 2048); |
| 8231 | 186 | } |
| 14758 | 187 | |
| 188 | void | |
| 15884 | 189 | purple_network_uninit(void) |
| 14758 | 190 | { |
| 191 | } |