Replace functions which called once with their bodies
[pidgin-git.git] / libpurple / proxy.h
blobcc246004bd4b5e87793909f54aa09dc4a07446b4
1 /* purple
3 * Purple is the legal property of its developers, whose names are too numerous
4 * to list here. Please refer to the COPYRIGHT file distributed with this
5 * source distribution.
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.
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.
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
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA
22 #ifndef PURPLE_PROXY_H
23 #define PURPLE_PROXY_H
24 /**
25 * SECTION:proxy
26 * @section_id: libpurple-proxy
27 * @short_description: <filename>proxy.h</filename>
28 * @title: Proxy API
31 #include <glib.h>
32 #include <gio/gio.h>
33 #include "eventloop.h"
35 /**
36 * PurpleProxyType:
37 * @PURPLE_PROXY_USE_GLOBAL: Use the global proxy information.
38 * @PURPLE_PROXY_NONE: No proxy.
39 * @PURPLE_PROXY_HTTP: HTTP proxy.
40 * @PURPLE_PROXY_SOCKS4: SOCKS 4 proxy.
41 * @PURPLE_PROXY_SOCKS5: SOCKS 5 proxy.
42 * @PURPLE_PROXY_USE_ENVVAR: Use environmental settings.
43 * @PURPLE_PROXY_TOR: Use a Tor proxy (SOCKS 5 really).
45 * A type of proxy connection.
47 typedef enum
49 PURPLE_PROXY_USE_GLOBAL = -1,
50 PURPLE_PROXY_NONE = 0,
51 PURPLE_PROXY_HTTP,
52 PURPLE_PROXY_SOCKS4,
53 PURPLE_PROXY_SOCKS5,
54 PURPLE_PROXY_USE_ENVVAR,
55 PURPLE_PROXY_TOR
57 } PurpleProxyType;
59 /**
60 * PurpleProxyInfo:
62 * Information on proxy settings.
64 typedef struct _PurpleProxyInfo PurpleProxyInfo;
66 typedef struct _PurpleProxyConnectData PurpleProxyConnectData;
68 typedef void (*PurpleProxyConnectFunction)(gpointer data, gint source, const gchar *error_message);
71 #include "account.h"
73 G_BEGIN_DECLS
75 /**************************************************************************/
76 /* Proxy structure API */
77 /**************************************************************************/
79 /**
80 * purple_proxy_info_get_type:
82 * Returns: The #GType for proxy information.
84 GType purple_proxy_info_get_type(void);
86 /**
87 * purple_proxy_info_new:
89 * Creates a proxy information structure.
91 * Returns: The proxy information structure.
93 PurpleProxyInfo *purple_proxy_info_new(void);
95 /**
96 * purple_proxy_info_destroy:
97 * @info: The proxy information structure to destroy.
99 * Destroys a proxy information structure.
101 void purple_proxy_info_destroy(PurpleProxyInfo *info);
104 * purple_proxy_info_set_proxy_type:
105 * @info: The proxy information.
106 * @type: The proxy type.
108 * Sets the type of proxy.
110 void purple_proxy_info_set_proxy_type(PurpleProxyInfo *info, PurpleProxyType type);
113 * purple_proxy_info_set_host:
114 * @info: The proxy information.
115 * @host: The host.
117 * Sets the proxy host.
119 void purple_proxy_info_set_host(PurpleProxyInfo *info, const char *host);
122 * purple_proxy_info_set_port:
123 * @info: The proxy information.
124 * @port: The port.
126 * Sets the proxy port.
128 void purple_proxy_info_set_port(PurpleProxyInfo *info, int port);
131 * purple_proxy_info_set_username:
132 * @info: The proxy information.
133 * @username: The username.
135 * Sets the proxy username.
137 void purple_proxy_info_set_username(PurpleProxyInfo *info, const char *username);
140 * purple_proxy_info_set_password:
141 * @info: The proxy information.
142 * @password: The password.
144 * Sets the proxy password.
146 void purple_proxy_info_set_password(PurpleProxyInfo *info, const char *password);
149 * purple_proxy_info_get_proxy_type:
150 * @info: The proxy information.
152 * Returns the proxy's type.
154 * Returns: The type.
156 PurpleProxyType purple_proxy_info_get_proxy_type(const PurpleProxyInfo *info);
159 * purple_proxy_info_get_host:
160 * @info: The proxy information.
162 * Returns the proxy's host.
164 * Returns: The host.
166 const char *purple_proxy_info_get_host(const PurpleProxyInfo *info);
169 * purple_proxy_info_get_port:
170 * @info: The proxy information.
172 * Returns the proxy's port.
174 * Returns: The port.
176 int purple_proxy_info_get_port(const PurpleProxyInfo *info);
179 * purple_proxy_info_get_username:
180 * @info: The proxy information.
182 * Returns the proxy's username.
184 * Returns: The username.
186 const char *purple_proxy_info_get_username(const PurpleProxyInfo *info);
189 * purple_proxy_info_get_password:
190 * @info: The proxy information.
192 * Returns the proxy's password.
194 * Returns: The password.
196 const char *purple_proxy_info_get_password(const PurpleProxyInfo *info);
198 /**************************************************************************/
199 /* Global Proxy API */
200 /**************************************************************************/
203 * purple_global_proxy_get_info:
205 * Returns purple's global proxy information.
207 * Returns: The global proxy information.
209 PurpleProxyInfo *purple_global_proxy_get_info(void);
212 * purple_global_proxy_set_info:
213 * @info: The proxy information.
215 * Set purple's global proxy information.
217 void purple_global_proxy_set_info(PurpleProxyInfo *info);
219 /**************************************************************************/
220 /* Proxy API */
221 /**************************************************************************/
224 * purple_proxy_get_handle:
226 * Returns the proxy subsystem handle.
228 * Returns: The proxy subsystem handle.
230 void *purple_proxy_get_handle(void);
233 * purple_proxy_init:
235 * Initializes the proxy subsystem.
237 void purple_proxy_init(void);
240 * purple_proxy_uninit:
242 * Uninitializes the proxy subsystem.
244 void purple_proxy_uninit(void);
247 * purple_proxy_get_setup:
248 * @account: The account for which the configuration is needed.
250 * Returns configuration of a proxy.
252 * Returns: The configuration of a proxy.
254 PurpleProxyInfo *purple_proxy_get_setup(PurpleAccount *account);
257 * purple_proxy_connect: (skip)
258 * @handle: A handle that should be associated with this
259 * connection attempt. The handle can be used
260 * to cancel the connection attempt using the
261 * purple_proxy_connect_cancel_with_handle()
262 * function.
263 * @account: The account making the connection.
264 * @host: The destination host.
265 * @port: The destination port.
266 * @connect_cb: (scope call): The function to call when the connection is
267 * established. If the connection failed then
268 * fd will be -1 and error message will be set
269 * to something descriptive (hopefully).
270 * @data: User-defined data.
272 * Makes a connection to the specified host and port. Note that this
273 * function name can be misleading--although it is called "proxy
274 * connect," it is used for establishing any outgoing TCP connection,
275 * whether through a proxy or not.
277 * Returns: NULL if there was an error, or a reference to an
278 * opaque data structure that can be used to cancel
279 * the pending connection, if needed.
281 PurpleProxyConnectData *purple_proxy_connect(void *handle,
282 PurpleAccount *account,
283 const char *host, int port,
284 PurpleProxyConnectFunction connect_cb, gpointer data);
287 * purple_proxy_connect_socks5_account: (skip)
288 * @handle: A handle that should be associated with this
289 * connection attempt. The handle can be used
290 * to cancel the connection attempt using the
291 * purple_proxy_connect_cancel_with_handle()
292 * function.
293 * @account: The account making the connection.
294 * @gpi: The PurpleProxyInfo specifying the proxy settings
295 * @host: The destination host.
296 * @port: The destination port.
297 * @connect_cb: (scope call): The function to call when the connection is
298 * established. If the connection failed then
299 * fd will be -1 and error message will be set
300 * to something descriptive (hopefully).
301 * @data: User-defined data.
303 * Makes a connection through a SOCKS5 proxy.
305 * Note that if the account that is making the connection uses a proxy, this
306 * connection to a SOCKS5 proxy will be made through the account proxy.
308 * Returns: NULL if there was an error, or a reference to an
309 * opaque data structure that can be used to cancel
310 * the pending connection, if needed.
312 PurpleProxyConnectData *purple_proxy_connect_socks5_account(void *handle,
313 PurpleAccount *account, PurpleProxyInfo *gpi,
314 const char *host, int port,
315 PurpleProxyConnectFunction connect_cb, gpointer data);
318 * purple_proxy_connect_cancel: (skip)
319 * @connect_data: The #PurpleProxyConnectData to cancel.
321 * Cancel an in-progress connection attempt. This should be called
322 * by the protocol if the user disables an account while it is still
323 * performing the initial sign on. Or when establishing a file
324 * transfer, if we attempt to connect to a remote user but they
325 * are behind a firewall then the protocol can cancel the connection
326 * attempt early rather than just letting the OS's TCP/IP stack
327 * time-out the connection.
329 void purple_proxy_connect_cancel(PurpleProxyConnectData *connect_data);
332 * purple_proxy_connect_cancel_with_handle: (skip)
333 * @handle: The handle.
335 * Closes all proxy connections registered with the specified handle.
337 void purple_proxy_connect_cancel_with_handle(void *handle);
340 * purple_proxy_get_proxy_resolver:
341 * @account: The account for which to get the proxy resolver.
342 * @error: Return location for a GError, or NULL.
344 * Returns a #GProxyResolver capable of resolving which proxy
345 * to use for this account, if any. This object can be given to a
346 * #GSocketClient for automatic proxy handling or can be used
347 * directly if desired.
349 * Returns: (transfer full): NULL if there was an error with the
350 * account's (or system) proxy settings, or a reference to
351 * a #GProxyResolver on success.
353 GProxyResolver *purple_proxy_get_proxy_resolver(PurpleAccount *account,
354 GError **error);
356 G_END_DECLS
358 #endif /* PURPLE_PROXY_H */