libpurple/network.h

Fri, 28 Nov 2008 06:06:35 +0000

author
Richard Laager <rlaager@pidgin.im>
date
Fri, 28 Nov 2008 06:06:35 +0000
branch
next.minor
changeset 24999
84d597b7e7c6
parent 24568
c90b00f17f7e
child 26337
ec2fc1bc9024
permissions
-rw-r--r--

Add a -f/--force-online option to Pidgin which tells libpurple to claim the
network is available, even if NetworkManager (or Windows) says it isn't.
This is useful for offline development with nullprpl. If you don't like
-f for this and would just like to keep the long option, I'm fine with that.

Also, remove a -x/--nocrash option in Pidgin that doesn't seem to do anything.

8231
347c8992c445 [gaim-migrate @ 8954]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
1 /**
347c8992c445 [gaim-migrate @ 8954]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
2 * @file network.h Network API
347c8992c445 [gaim-migrate @ 8954]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
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
347c8992c445 [gaim-migrate @ 8954]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
7 *
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15435
diff changeset
8 * Purple is the legal property of its developers, whose names are too numerous
8231
347c8992c445 [gaim-migrate @ 8954]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
9 * to list here. Please refer to the COPYRIGHT file distributed with this
347c8992c445 [gaim-migrate @ 8954]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
10 * source distribution.
347c8992c445 [gaim-migrate @ 8954]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
11 *
347c8992c445 [gaim-migrate @ 8954]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
12 * This program is free software; you can redistribute it and/or modify
347c8992c445 [gaim-migrate @ 8954]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
13 * it under the terms of the GNU General Public License as published by
347c8992c445 [gaim-migrate @ 8954]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
14 * the Free Software Foundation; either version 2 of the License, or
347c8992c445 [gaim-migrate @ 8954]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
15 * (at your option) any later version.
347c8992c445 [gaim-migrate @ 8954]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
16 *
347c8992c445 [gaim-migrate @ 8954]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
17 * This program is distributed in the hope that it will be useful,
347c8992c445 [gaim-migrate @ 8954]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
347c8992c445 [gaim-migrate @ 8954]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
347c8992c445 [gaim-migrate @ 8954]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
20 * GNU General Public License for more details.
347c8992c445 [gaim-migrate @ 8954]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
21 *
347c8992c445 [gaim-migrate @ 8954]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
22 * You should have received a copy of the GNU General Public License
347c8992c445 [gaim-migrate @ 8954]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
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: 16035
diff changeset
24 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA
8231
347c8992c445 [gaim-migrate @ 8954]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
25 */
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15435
diff changeset
26 #ifndef _PURPLE_NETWORK_H_
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15435
diff changeset
27 #define _PURPLE_NETWORK_H_
8231
347c8992c445 [gaim-migrate @ 8954]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
28
347c8992c445 [gaim-migrate @ 8954]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
29 #ifdef __cplusplus
347c8992c445 [gaim-migrate @ 8954]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
30 extern "C" {
347c8992c445 [gaim-migrate @ 8954]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
31 #endif
347c8992c445 [gaim-migrate @ 8954]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
32
347c8992c445 [gaim-migrate @ 8954]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
33 /**************************************************************************/
8834
0a798e3d2b84 [gaim-migrate @ 9598]
Mark Doliner <markdoliner@pidgin.im>
parents: 8250
diff changeset
34 /** @name Network API */
8231
347c8992c445 [gaim-migrate @ 8954]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
35 /**************************************************************************/
347c8992c445 [gaim-migrate @ 8954]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
36 /*@{*/
347c8992c445 [gaim-migrate @ 8954]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
37
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15435
diff changeset
38 typedef struct _PurpleNetworkListenData PurpleNetworkListenData;
14329
05c3cc0c1f79 [gaim-migrate @ 16949]
Mark Doliner <markdoliner@pidgin.im>
parents: 14254
diff changeset
39
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15435
diff changeset
40 typedef void (*PurpleNetworkListenCallback) (int listenfd, gpointer data);
12909
dfcf4df1dcd7 [gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents: 12730
diff changeset
41
8231
347c8992c445 [gaim-migrate @ 8954]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
42 /**
8838
c23227da7b4a [gaim-migrate @ 9604]
Mark Doliner <markdoliner@pidgin.im>
parents: 8834
diff changeset
43 * Converts a dot-decimal IP address to an array of unsigned
c23227da7b4a [gaim-migrate @ 9604]
Mark Doliner <markdoliner@pidgin.im>
parents: 8834
diff changeset
44 * chars. For example, converts 192.168.0.1 to a 4 byte
c23227da7b4a [gaim-migrate @ 9604]
Mark Doliner <markdoliner@pidgin.im>
parents: 8834
diff changeset
45 * array containing 192, 168, 0 and 1.
c23227da7b4a [gaim-migrate @ 9604]
Mark Doliner <markdoliner@pidgin.im>
parents: 8834
diff changeset
46 *
c23227da7b4a [gaim-migrate @ 9604]
Mark Doliner <markdoliner@pidgin.im>
parents: 8834
diff changeset
47 * @param ip An IP address in dot-decimal notiation.
c23227da7b4a [gaim-migrate @ 9604]
Mark Doliner <markdoliner@pidgin.im>
parents: 8834
diff changeset
48 * @return An array of 4 bytes containing an IP addresses
c23227da7b4a [gaim-migrate @ 9604]
Mark Doliner <markdoliner@pidgin.im>
parents: 8834
diff changeset
49 * equivalent to the given parameter, or NULL if
c23227da7b4a [gaim-migrate @ 9604]
Mark Doliner <markdoliner@pidgin.im>
parents: 8834
diff changeset
50 * the given IP address is invalid. This value
c23227da7b4a [gaim-migrate @ 9604]
Mark Doliner <markdoliner@pidgin.im>
parents: 8834
diff changeset
51 * is statically allocated and should not be
c23227da7b4a [gaim-migrate @ 9604]
Mark Doliner <markdoliner@pidgin.im>
parents: 8834
diff changeset
52 * freed.
c23227da7b4a [gaim-migrate @ 9604]
Mark Doliner <markdoliner@pidgin.im>
parents: 8834
diff changeset
53 */
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15435
diff changeset
54 const unsigned char *purple_network_ip_atoi(const char *ip);
8838
c23227da7b4a [gaim-migrate @ 9604]
Mark Doliner <markdoliner@pidgin.im>
parents: 8834
diff changeset
55
c23227da7b4a [gaim-migrate @ 9604]
Mark Doliner <markdoliner@pidgin.im>
parents: 8834
diff changeset
56 /**
8834
0a798e3d2b84 [gaim-migrate @ 9598]
Mark Doliner <markdoliner@pidgin.im>
parents: 8250
diff changeset
57 * Sets the IP address of the local system in preferences. This
0a798e3d2b84 [gaim-migrate @ 9598]
Mark Doliner <markdoliner@pidgin.im>
parents: 8250
diff changeset
58 * is the IP address that should be used for incoming connections
0a798e3d2b84 [gaim-migrate @ 9598]
Mark Doliner <markdoliner@pidgin.im>
parents: 8250
diff changeset
59 * (file transfer, direct IM, etc.) and should therefore be
0a798e3d2b84 [gaim-migrate @ 9598]
Mark Doliner <markdoliner@pidgin.im>
parents: 8250
diff changeset
60 * publicly accessible.
8231
347c8992c445 [gaim-migrate @ 8954]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
61 *
347c8992c445 [gaim-migrate @ 8954]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
62 * @param ip The local IP address.
347c8992c445 [gaim-migrate @ 8954]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
63 */
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15435
diff changeset
64 void purple_network_set_public_ip(const char *ip);
8231
347c8992c445 [gaim-migrate @ 8954]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
65
347c8992c445 [gaim-migrate @ 8954]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
66 /**
347c8992c445 [gaim-migrate @ 8954]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
67 * Returns the IP address of the local system set in preferences.
347c8992c445 [gaim-migrate @ 8954]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
68 *
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15435
diff changeset
69 * This returns the value set via purple_network_set_public_ip().
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15435
diff changeset
70 * You probably want to use purple_network_get_my_ip() instead.
8231
347c8992c445 [gaim-migrate @ 8954]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
71 *
347c8992c445 [gaim-migrate @ 8954]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
72 * @return The local IP address set in preferences.
347c8992c445 [gaim-migrate @ 8954]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
73 */
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15435
diff changeset
74 const char *purple_network_get_public_ip(void);
8231
347c8992c445 [gaim-migrate @ 8954]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
75
347c8992c445 [gaim-migrate @ 8954]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
76 /**
347c8992c445 [gaim-migrate @ 8954]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
77 * Returns the IP address of the local system.
347c8992c445 [gaim-migrate @ 8954]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
78 *
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15435
diff changeset
79 * You probably want to use purple_network_get_my_ip() instead.
8231
347c8992c445 [gaim-migrate @ 8954]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
80 *
347c8992c445 [gaim-migrate @ 8954]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
81 * @note The returned string is a pointer to a static buffer. If this
347c8992c445 [gaim-migrate @ 8954]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
82 * function is called twice, it may be important to make a copy
347c8992c445 [gaim-migrate @ 8954]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
83 * of the returned string.
347c8992c445 [gaim-migrate @ 8954]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
84 *
347c8992c445 [gaim-migrate @ 8954]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
85 * @param fd The fd to use to help figure out the IP, or else -1.
347c8992c445 [gaim-migrate @ 8954]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
86 * @return The local IP address.
347c8992c445 [gaim-migrate @ 8954]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
87 */
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15435
diff changeset
88 const char *purple_network_get_local_system_ip(int fd);
8231
347c8992c445 [gaim-migrate @ 8954]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
89
347c8992c445 [gaim-migrate @ 8954]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
90 /**
8834
0a798e3d2b84 [gaim-migrate @ 9598]
Mark Doliner <markdoliner@pidgin.im>
parents: 8250
diff changeset
91 * Returns the IP address that should be used anywhere a
0a798e3d2b84 [gaim-migrate @ 9598]
Mark Doliner <markdoliner@pidgin.im>
parents: 8250
diff changeset
92 * public IP addresses is needed (listening for an incoming
0a798e3d2b84 [gaim-migrate @ 9598]
Mark Doliner <markdoliner@pidgin.im>
parents: 8250
diff changeset
93 * file transfer, etc).
8231
347c8992c445 [gaim-migrate @ 8954]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
94 *
8834
0a798e3d2b84 [gaim-migrate @ 9598]
Mark Doliner <markdoliner@pidgin.im>
parents: 8250
diff changeset
95 * If the user has manually specified an IP address via
0a798e3d2b84 [gaim-migrate @ 9598]
Mark Doliner <markdoliner@pidgin.im>
parents: 8250
diff changeset
96 * preferences, then this IP is returned. Otherwise the
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15435
diff changeset
97 * IP address returned by purple_network_get_local_system_ip()
8834
0a798e3d2b84 [gaim-migrate @ 9598]
Mark Doliner <markdoliner@pidgin.im>
parents: 8250
diff changeset
98 * is returned.
8231
347c8992c445 [gaim-migrate @ 8954]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
99 *
347c8992c445 [gaim-migrate @ 8954]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
100 * @note The returned string is a pointer to a static buffer. If this
347c8992c445 [gaim-migrate @ 8954]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
101 * function is called twice, it may be important to make a copy
347c8992c445 [gaim-migrate @ 8954]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
102 * of the returned string.
347c8992c445 [gaim-migrate @ 8954]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
103 *
347c8992c445 [gaim-migrate @ 8954]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
104 * @param fd The fd to use to help figure out the IP, or -1.
347c8992c445 [gaim-migrate @ 8954]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
105 * @return The local IP address to be used.
347c8992c445 [gaim-migrate @ 8954]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
106 */
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15435
diff changeset
107 const char *purple_network_get_my_ip(int fd);
8231
347c8992c445 [gaim-migrate @ 8954]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
108
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: 20147
diff changeset
109 /**
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: 20147
diff changeset
110 * Should calls to purple_network_listen() and purple_network_listen_range()
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: 20147
diff changeset
111 * map the port externally using NAT-PMP or UPnP?
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: 20147
diff changeset
112 * The default value is 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: 20147
diff changeset
113 *
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: 20147
diff changeset
114 * @param map_external Should the open port be mapped externally?
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: 20147
diff changeset
115 * @deprecated In 3.0.0 a boolean will be added to the above functions to
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: 20147
diff changeset
116 * perform the same function.
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: 20147
diff changeset
117 * @since 2.3.0
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: 20147
diff changeset
118 */
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: 20147
diff changeset
119 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: 20147
diff changeset
120
8231
347c8992c445 [gaim-migrate @ 8954]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
121 /**
8250
e855dcce1fa0 [gaim-migrate @ 8973]
Mark Doliner <markdoliner@pidgin.im>
parents: 8248
diff changeset
122 * Attempts to open a listening port ONLY on the specified port number.
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15435
diff changeset
123 * You probably want to use purple_network_listen_range() instead of this.
8250
e855dcce1fa0 [gaim-migrate @ 8973]
Mark Doliner <markdoliner@pidgin.im>
parents: 8248
diff changeset
124 * This function is useful, for example, if you wanted to write a telnet
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15435
diff changeset
125 * server as a Purple plugin, and you HAD to listen on port 23. Why anyone
8248
47da4fbe1a17 [gaim-migrate @ 8971]
Mark Doliner <markdoliner@pidgin.im>
parents: 8246
diff changeset
126 * would want to do that is beyond me.
8231
347c8992c445 [gaim-migrate @ 8954]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
127 *
347c8992c445 [gaim-migrate @ 8954]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
128 * This opens a listening port. The caller will want to set up a watcher
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15435
diff changeset
129 * of type PURPLE_INPUT_READ on the fd returned in cb. It will probably call
12909
dfcf4df1dcd7 [gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents: 12730
diff changeset
130 * accept in the watcher callback, and then possibly remove the watcher and close
8231
347c8992c445 [gaim-migrate @ 8954]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
131 * the listening socket, and add a new watcher on the new socket accept
347c8992c445 [gaim-migrate @ 8954]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
132 * returned.
347c8992c445 [gaim-migrate @ 8954]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
133 *
8250
e855dcce1fa0 [gaim-migrate @ 8973]
Mark Doliner <markdoliner@pidgin.im>
parents: 8248
diff changeset
134 * @param port The port number to bind to. Must be greater than 0.
12730
f64fdbc34677 [gaim-migrate @ 15074]
Daniel Atallah <datallah@pidgin.im>
parents: 8915
diff changeset
135 * @param socket_type The type of socket to open for listening.
f64fdbc34677 [gaim-migrate @ 15074]
Daniel Atallah <datallah@pidgin.im>
parents: 8915
diff changeset
136 * This will be either SOCK_STREAM for TCP or SOCK_DGRAM for UDP.
12909
dfcf4df1dcd7 [gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents: 12730
diff changeset
137 * @param cb The callback to be invoked when the port to listen on is available.
dfcf4df1dcd7 [gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents: 12730
diff changeset
138 * The file descriptor of the listening socket will be specified in
dfcf4df1dcd7 [gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents: 12730
diff changeset
139 * this callback, or -1 if no socket could be established.
dfcf4df1dcd7 [gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents: 12730
diff changeset
140 * @param cb_data extra data to be returned when cb is called
8246
c83c0421149a [gaim-migrate @ 8969]
Mark Doliner <markdoliner@pidgin.im>
parents: 8240
diff changeset
141 *
14329
05c3cc0c1f79 [gaim-migrate @ 16949]
Mark Doliner <markdoliner@pidgin.im>
parents: 14254
diff changeset
142 * @return A pointer to a data structure that can be used to cancel
05c3cc0c1f79 [gaim-migrate @ 16949]
Mark Doliner <markdoliner@pidgin.im>
parents: 14254
diff changeset
143 * the pending listener, or NULL if unable to obtain a local
05c3cc0c1f79 [gaim-migrate @ 16949]
Mark Doliner <markdoliner@pidgin.im>
parents: 14254
diff changeset
144 * socket to listen on.
8231
347c8992c445 [gaim-migrate @ 8954]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
145 */
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15435
diff changeset
146 PurpleNetworkListenData *purple_network_listen(unsigned short port,
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15435
diff changeset
147 int socket_type, PurpleNetworkListenCallback cb, gpointer cb_data);
8246
c83c0421149a [gaim-migrate @ 8969]
Mark Doliner <markdoliner@pidgin.im>
parents: 8240
diff changeset
148
c83c0421149a [gaim-migrate @ 8969]
Mark Doliner <markdoliner@pidgin.im>
parents: 8240
diff changeset
149 /**
8250
e855dcce1fa0 [gaim-migrate @ 8973]
Mark Doliner <markdoliner@pidgin.im>
parents: 8248
diff changeset
150 * Opens a listening port selected from a range of ports. The range of
8248
47da4fbe1a17 [gaim-migrate @ 8971]
Mark Doliner <markdoliner@pidgin.im>
parents: 8246
diff changeset
151 * ports used is chosen in the following manner:
47da4fbe1a17 [gaim-migrate @ 8971]
Mark Doliner <markdoliner@pidgin.im>
parents: 8246
diff changeset
152 * If a range is specified in preferences, these values are used.
8250
e855dcce1fa0 [gaim-migrate @ 8973]
Mark Doliner <markdoliner@pidgin.im>
parents: 8248
diff changeset
153 * If a non-0 values are passed to the function as parameters, these
8248
47da4fbe1a17 [gaim-migrate @ 8971]
Mark Doliner <markdoliner@pidgin.im>
parents: 8246
diff changeset
154 * values are used.
13328
65543dcbaa89 [gaim-migrate @ 15697]
Mark Doliner <markdoliner@pidgin.im>
parents: 12909
diff changeset
155 * Otherwise a port is chosen at random by the operating system.
8246
c83c0421149a [gaim-migrate @ 8969]
Mark Doliner <markdoliner@pidgin.im>
parents: 8240
diff changeset
156 *
c83c0421149a [gaim-migrate @ 8969]
Mark Doliner <markdoliner@pidgin.im>
parents: 8240
diff changeset
157 * This opens a listening port. The caller will want to set up a watcher
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15435
diff changeset
158 * of type PURPLE_INPUT_READ on the fd returned in cb. It will probably call
12909
dfcf4df1dcd7 [gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents: 12730
diff changeset
159 * accept in the watcher callback, and then possibly remove the watcher and close
8246
c83c0421149a [gaim-migrate @ 8969]
Mark Doliner <markdoliner@pidgin.im>
parents: 8240
diff changeset
160 * the listening socket, and add a new watcher on the new socket accept
c83c0421149a [gaim-migrate @ 8969]
Mark Doliner <markdoliner@pidgin.im>
parents: 8240
diff changeset
161 * returned.
c83c0421149a [gaim-migrate @ 8969]
Mark Doliner <markdoliner@pidgin.im>
parents: 8240
diff changeset
162 *
8248
47da4fbe1a17 [gaim-migrate @ 8971]
Mark Doliner <markdoliner@pidgin.im>
parents: 8246
diff changeset
163 * @param start The port number to bind to, or 0 to pick a random port.
8246
c83c0421149a [gaim-migrate @ 8969]
Mark Doliner <markdoliner@pidgin.im>
parents: 8240
diff changeset
164 * Users are allowed to override this arg in prefs.
c83c0421149a [gaim-migrate @ 8969]
Mark Doliner <markdoliner@pidgin.im>
parents: 8240
diff changeset
165 * @param end The highest possible port in the range of ports to listen on,
8248
47da4fbe1a17 [gaim-migrate @ 8971]
Mark Doliner <markdoliner@pidgin.im>
parents: 8246
diff changeset
166 * or 0 to pick a random port. Users are allowed to override this
8246
c83c0421149a [gaim-migrate @ 8969]
Mark Doliner <markdoliner@pidgin.im>
parents: 8240
diff changeset
167 * arg in prefs.
12730
f64fdbc34677 [gaim-migrate @ 15074]
Daniel Atallah <datallah@pidgin.im>
parents: 8915
diff changeset
168 * @param socket_type The type of socket to open for listening.
f64fdbc34677 [gaim-migrate @ 15074]
Daniel Atallah <datallah@pidgin.im>
parents: 8915
diff changeset
169 * This will be either SOCK_STREAM for TCP or SOCK_DGRAM for UDP.
12909
dfcf4df1dcd7 [gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents: 12730
diff changeset
170 * @param cb The callback to be invoked when the port to listen on is available.
dfcf4df1dcd7 [gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents: 12730
diff changeset
171 * The file descriptor of the listening socket will be specified in
dfcf4df1dcd7 [gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents: 12730
diff changeset
172 * this callback, or -1 if no socket could be established.
dfcf4df1dcd7 [gaim-migrate @ 15262]
Daniel Atallah <datallah@pidgin.im>
parents: 12730
diff changeset
173 * @param cb_data extra data to be returned when cb is called
8250
e855dcce1fa0 [gaim-migrate @ 8973]
Mark Doliner <markdoliner@pidgin.im>
parents: 8248
diff changeset
174 *
14329
05c3cc0c1f79 [gaim-migrate @ 16949]
Mark Doliner <markdoliner@pidgin.im>
parents: 14254
diff changeset
175 * @return A pointer to a data structure that can be used to cancel
05c3cc0c1f79 [gaim-migrate @ 16949]
Mark Doliner <markdoliner@pidgin.im>
parents: 14254
diff changeset
176 * the pending listener, or NULL if unable to obtain a local
05c3cc0c1f79 [gaim-migrate @ 16949]
Mark Doliner <markdoliner@pidgin.im>
parents: 14254
diff changeset
177 * socket to listen on.
8246
c83c0421149a [gaim-migrate @ 8969]
Mark Doliner <markdoliner@pidgin.im>
parents: 8240
diff changeset
178 */
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15435
diff changeset
179 PurpleNetworkListenData *purple_network_listen_range(unsigned short start,
14329
05c3cc0c1f79 [gaim-migrate @ 16949]
Mark Doliner <markdoliner@pidgin.im>
parents: 14254
diff changeset
180 unsigned short end, int socket_type,
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15435
diff changeset
181 PurpleNetworkListenCallback cb, gpointer cb_data);
14329
05c3cc0c1f79 [gaim-migrate @ 16949]
Mark Doliner <markdoliner@pidgin.im>
parents: 14254
diff changeset
182
05c3cc0c1f79 [gaim-migrate @ 16949]
Mark Doliner <markdoliner@pidgin.im>
parents: 14254
diff changeset
183 /**
05c3cc0c1f79 [gaim-migrate @ 16949]
Mark Doliner <markdoliner@pidgin.im>
parents: 14254
diff changeset
184 * This can be used to cancel any in-progress listener connection
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15435
diff changeset
185 * by passing in the return value from either purple_network_listen()
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15435
diff changeset
186 * or purple_network_listen_range().
14329
05c3cc0c1f79 [gaim-migrate @ 16949]
Mark Doliner <markdoliner@pidgin.im>
parents: 14254
diff changeset
187 *
05c3cc0c1f79 [gaim-migrate @ 16949]
Mark Doliner <markdoliner@pidgin.im>
parents: 14254
diff changeset
188 * @param listen_data This listener attempt will be canceled and
05c3cc0c1f79 [gaim-migrate @ 16949]
Mark Doliner <markdoliner@pidgin.im>
parents: 14254
diff changeset
189 * the struct will be freed.
05c3cc0c1f79 [gaim-migrate @ 16949]
Mark Doliner <markdoliner@pidgin.im>
parents: 14254
diff changeset
190 */
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15435
diff changeset
191 void purple_network_listen_cancel(PurpleNetworkListenData *listen_data);
8231
347c8992c445 [gaim-migrate @ 8954]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
192
347c8992c445 [gaim-migrate @ 8954]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
193 /**
347c8992c445 [gaim-migrate @ 8954]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
194 * Gets a port number from a file descriptor.
347c8992c445 [gaim-migrate @ 8954]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
195 *
347c8992c445 [gaim-migrate @ 8954]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
196 * @param fd The file descriptor. This should be a tcp socket. The current
347c8992c445 [gaim-migrate @ 8954]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
197 * implementation probably dies on anything but IPv4. Perhaps this
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15435
diff changeset
198 * possible bug will inspire new and valuable contributors to Purple.
8231
347c8992c445 [gaim-migrate @ 8954]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
199 * @return The port number, in host byte order.
347c8992c445 [gaim-migrate @ 8954]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
200 */
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15435
diff changeset
201 unsigned short purple_network_get_port_from_fd(int fd);
8231
347c8992c445 [gaim-migrate @ 8954]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
202
347c8992c445 [gaim-migrate @ 8954]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
203 /**
24567
edd8e0bb750c Update the docs for purple_network_is_available(). It doesn't block.
Richard Laager <rlaager@pidgin.im>
parents: 21549
diff changeset
204 * Detects if there is an available network connection.
14758
13b9adc9efd2 [gaim-migrate @ 17448]
Sean Egan <seanegan@pidgin.im>
parents: 14329
diff changeset
205 *
24567
edd8e0bb750c Update the docs for purple_network_is_available(). It doesn't block.
Richard Laager <rlaager@pidgin.im>
parents: 21549
diff changeset
206 * @return TRUE if the network is available
14758
13b9adc9efd2 [gaim-migrate @ 17448]
Sean Egan <seanegan@pidgin.im>
parents: 14329
diff changeset
207 */
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15435
diff changeset
208 gboolean purple_network_is_available(void);
14758
13b9adc9efd2 [gaim-migrate @ 17448]
Sean Egan <seanegan@pidgin.im>
parents: 14329
diff changeset
209
13b9adc9efd2 [gaim-migrate @ 17448]
Sean Egan <seanegan@pidgin.im>
parents: 14329
diff changeset
210 /**
24999
84d597b7e7c6 Add a -f/--force-online option to Pidgin which tells libpurple to claim the
Richard Laager <rlaager@pidgin.im>
parents: 24568
diff changeset
211 * Makes purple_network_is_available() always return @c TRUE.
84d597b7e7c6 Add a -f/--force-online option to Pidgin which tells libpurple to claim the
Richard Laager <rlaager@pidgin.im>
parents: 24568
diff changeset
212 *
84d597b7e7c6 Add a -f/--force-online option to Pidgin which tells libpurple to claim the
Richard Laager <rlaager@pidgin.im>
parents: 24568
diff changeset
213 * This is what backs the --force-online command line argument in Pidgin,
84d597b7e7c6 Add a -f/--force-online option to Pidgin which tells libpurple to claim the
Richard Laager <rlaager@pidgin.im>
parents: 24568
diff changeset
214 * for example. This is useful for offline testing, especially when
84d597b7e7c6 Add a -f/--force-online option to Pidgin which tells libpurple to claim the
Richard Laager <rlaager@pidgin.im>
parents: 24568
diff changeset
215 * combined with nullprpl.
84d597b7e7c6 Add a -f/--force-online option to Pidgin which tells libpurple to claim the
Richard Laager <rlaager@pidgin.im>
parents: 24568
diff changeset
216 *
84d597b7e7c6 Add a -f/--force-online option to Pidgin which tells libpurple to claim the
Richard Laager <rlaager@pidgin.im>
parents: 24568
diff changeset
217 * @since 2.6.0
84d597b7e7c6 Add a -f/--force-online option to Pidgin which tells libpurple to claim the
Richard Laager <rlaager@pidgin.im>
parents: 24568
diff changeset
218 */
84d597b7e7c6 Add a -f/--force-online option to Pidgin which tells libpurple to claim the
Richard Laager <rlaager@pidgin.im>
parents: 24568
diff changeset
219 void purple_network_force_online(void);
84d597b7e7c6 Add a -f/--force-online option to Pidgin which tells libpurple to claim the
Richard Laager <rlaager@pidgin.im>
parents: 24568
diff changeset
220
84d597b7e7c6 Add a -f/--force-online option to Pidgin which tells libpurple to claim the
Richard Laager <rlaager@pidgin.im>
parents: 24568
diff changeset
221 /**
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: 15884
diff changeset
222 * Get the handle for the network system
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: 15884
diff changeset
223 *
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: 15884
diff changeset
224 * @return the handle to the network system
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: 15884
diff changeset
225 */
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: 15884
diff changeset
226 void *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: 15884
diff changeset
227
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: 15884
diff changeset
228 /**
8231
347c8992c445 [gaim-migrate @ 8954]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
229 * Initializes the network subsystem.
347c8992c445 [gaim-migrate @ 8954]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
230 */
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15435
diff changeset
231 void purple_network_init(void);
8231
347c8992c445 [gaim-migrate @ 8954]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
232
14758
13b9adc9efd2 [gaim-migrate @ 17448]
Sean Egan <seanegan@pidgin.im>
parents: 14329
diff changeset
233 /**
13b9adc9efd2 [gaim-migrate @ 17448]
Sean Egan <seanegan@pidgin.im>
parents: 14329
diff changeset
234 * Shuts down the network subsystem.
13b9adc9efd2 [gaim-migrate @ 17448]
Sean Egan <seanegan@pidgin.im>
parents: 14329
diff changeset
235 */
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15435
diff changeset
236 void purple_network_uninit(void);
14758
13b9adc9efd2 [gaim-migrate @ 17448]
Sean Egan <seanegan@pidgin.im>
parents: 14329
diff changeset
237
8231
347c8992c445 [gaim-migrate @ 8954]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
238 /*@}*/
347c8992c445 [gaim-migrate @ 8954]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
239
347c8992c445 [gaim-migrate @ 8954]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
240 #ifdef __cplusplus
347c8992c445 [gaim-migrate @ 8954]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
241 }
347c8992c445 [gaim-migrate @ 8954]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
242 #endif
347c8992c445 [gaim-migrate @ 8954]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
243
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15435
diff changeset
244 #endif /* _PURPLE_NETWORK_H_ */

mercurial