14192
|
1 /**
|
|
2 * @file proxy.h Proxy API
|
|
3 * @ingroup core
|
|
4 *
|
|
5 * gaim
|
|
6 *
|
|
7 * Gaim is the legal property of its developers, whose names are too numerous
|
|
8 * to list here. Please refer to the COPYRIGHT file distributed with this
|
|
9 * source distribution.
|
|
10 *
|
|
11 * This program is free software; you can redistribute it and/or modify
|
|
12 * it under the terms of the GNU General Public License as published by
|
|
13 * the Free Software Foundation; either version 2 of the License, or
|
|
14 * (at your option) any later version.
|
|
15 *
|
|
16 * This program is distributed in the hope that it will be useful,
|
|
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
19 * GNU General Public License for more details.
|
|
20 *
|
|
21 * You should have received a copy of the GNU General Public License
|
|
22 * along with this program; if not, write to the Free Software
|
|
23 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
24 */
|
|
25 #ifndef _GAIM_PROXY_H_
|
|
26 #define _GAIM_PROXY_H_
|
|
27
|
|
28 #include <glib.h>
|
|
29 #include "eventloop.h"
|
|
30
|
|
31 /**
|
|
32 * A type of proxy connection.
|
|
33 */
|
|
34 typedef enum
|
|
35 {
|
|
36 GAIM_PROXY_USE_GLOBAL = -1, /**< Use the global proxy information. */
|
|
37 GAIM_PROXY_NONE = 0, /**< No proxy. */
|
|
38 GAIM_PROXY_HTTP, /**< HTTP proxy. */
|
|
39 GAIM_PROXY_SOCKS4, /**< SOCKS 4 proxy. */
|
|
40 GAIM_PROXY_SOCKS5, /**< SOCKS 5 proxy. */
|
|
41 GAIM_PROXY_USE_ENVVAR /**< Use environmental settings. */
|
|
42
|
|
43 } GaimProxyType;
|
|
44
|
|
45 /**
|
|
46 * Information on proxy settings.
|
|
47 */
|
|
48 typedef struct
|
|
49 {
|
|
50 GaimProxyType type; /**< The proxy type. */
|
|
51
|
|
52 char *host; /**< The host. */
|
|
53 int port; /**< The port number. */
|
|
54 char *username; /**< The username. */
|
|
55 char *password; /**< The password. */
|
|
56
|
|
57 } GaimProxyInfo;
|
|
58
|
|
59 typedef struct _GaimProxyConnectInfo GaimProxyConnectInfo;
|
|
60
|
|
61 typedef void (*GaimProxyConnectFunction)(gpointer data, gint source, const gchar *error_message);
|
|
62
|
|
63
|
|
64 #include "account.h"
|
|
65
|
|
66 #ifdef __cplusplus
|
|
67 extern "C" {
|
|
68 #endif
|
|
69
|
|
70 /**************************************************************************/
|
|
71 /** @name Proxy structure API */
|
|
72 /**************************************************************************/
|
|
73 /*@{*/
|
|
74
|
|
75 /**
|
|
76 * Creates a proxy information structure.
|
|
77 *
|
|
78 * @return The proxy information structure.
|
|
79 */
|
|
80 GaimProxyInfo *gaim_proxy_info_new(void);
|
|
81
|
|
82 /**
|
|
83 * Destroys a proxy information structure.
|
|
84 *
|
|
85 * @param info The proxy information structure to destroy.
|
|
86 */
|
|
87 void gaim_proxy_info_destroy(GaimProxyInfo *info);
|
|
88
|
|
89 /**
|
|
90 * Sets the type of proxy.
|
|
91 *
|
|
92 * @param info The proxy information.
|
|
93 * @param type The proxy type.
|
|
94 */
|
|
95 void gaim_proxy_info_set_type(GaimProxyInfo *info, GaimProxyType type);
|
|
96
|
|
97 /**
|
|
98 * Sets the proxy host.
|
|
99 *
|
|
100 * @param info The proxy information.
|
|
101 * @param host The host.
|
|
102 */
|
|
103 void gaim_proxy_info_set_host(GaimProxyInfo *info, const char *host);
|
|
104
|
|
105 /**
|
|
106 * Sets the proxy port.
|
|
107 *
|
|
108 * @param info The proxy information.
|
|
109 * @param port The port.
|
|
110 */
|
|
111 void gaim_proxy_info_set_port(GaimProxyInfo *info, int port);
|
|
112
|
|
113 /**
|
|
114 * Sets the proxy username.
|
|
115 *
|
|
116 * @param info The proxy information.
|
|
117 * @param username The username.
|
|
118 */
|
|
119 void gaim_proxy_info_set_username(GaimProxyInfo *info, const char *username);
|
|
120
|
|
121 /**
|
|
122 * Sets the proxy password.
|
|
123 *
|
|
124 * @param info The proxy information.
|
|
125 * @param password The password.
|
|
126 */
|
|
127 void gaim_proxy_info_set_password(GaimProxyInfo *info, const char *password);
|
|
128
|
|
129 /**
|
|
130 * Returns the proxy's type.
|
|
131 *
|
|
132 * @param info The proxy information.
|
|
133 *
|
|
134 * @return The type.
|
|
135 */
|
|
136 GaimProxyType gaim_proxy_info_get_type(const GaimProxyInfo *info);
|
|
137
|
|
138 /**
|
|
139 * Returns the proxy's host.
|
|
140 *
|
|
141 * @param info The proxy information.
|
|
142 *
|
|
143 * @return The host.
|
|
144 */
|
|
145 const char *gaim_proxy_info_get_host(const GaimProxyInfo *info);
|
|
146
|
|
147 /**
|
|
148 * Returns the proxy's port.
|
|
149 *
|
|
150 * @param info The proxy information.
|
|
151 *
|
|
152 * @return The port.
|
|
153 */
|
|
154 int gaim_proxy_info_get_port(const GaimProxyInfo *info);
|
|
155
|
|
156 /**
|
|
157 * Returns the proxy's username.
|
|
158 *
|
|
159 * @param info The proxy information.
|
|
160 *
|
|
161 * @return The username.
|
|
162 */
|
|
163 const char *gaim_proxy_info_get_username(const GaimProxyInfo *info);
|
|
164
|
|
165 /**
|
|
166 * Returns the proxy's password.
|
|
167 *
|
|
168 * @param info The proxy information.
|
|
169 *
|
|
170 * @return The password.
|
|
171 */
|
|
172 const char *gaim_proxy_info_get_password(const GaimProxyInfo *info);
|
|
173
|
|
174 /*@}*/
|
|
175
|
|
176 /**************************************************************************/
|
|
177 /** @name Global Proxy API */
|
|
178 /**************************************************************************/
|
|
179 /*@{*/
|
|
180
|
|
181 /**
|
|
182 * Returns gaim's global proxy information.
|
|
183 *
|
|
184 * @return The global proxy information.
|
|
185 */
|
|
186 GaimProxyInfo *gaim_global_proxy_get_info(void);
|
|
187
|
|
188 /*@}*/
|
|
189
|
|
190 /**************************************************************************/
|
|
191 /** @name Proxy API */
|
|
192 /**************************************************************************/
|
|
193 /*@{*/
|
|
194
|
|
195 /**
|
|
196 * Returns the proxy subsystem handle.
|
|
197 *
|
|
198 * @return The proxy subsystem handle.
|
|
199 */
|
|
200 void *gaim_proxy_get_handle(void);
|
|
201
|
|
202 /**
|
|
203 * Initializes the proxy subsystem.
|
|
204 */
|
|
205 void gaim_proxy_init(void);
|
|
206
|
|
207 /**
|
|
208 * Uninitializes the proxy subsystem.
|
|
209 */
|
|
210 void gaim_proxy_uninit(void);
|
|
211
|
|
212 /**
|
|
213 * Returns configuration of a proxy.
|
|
214 *
|
|
215 * @param account The account for which the configuration is needed.
|
|
216 *
|
|
217 * @return The configuration of a proxy.
|
|
218 */
|
|
219 GaimProxyInfo *gaim_proxy_get_setup(GaimAccount *account);
|
|
220
|
|
221 /**
|
|
222 * Makes a connection to the specified host and port. Note that this
|
|
223 * function name can be misleading--although it is called "proxy
|
|
224 * connect," it is used for establishing any outgoing TCP connection,
|
|
225 * whether through a proxy or not.
|
|
226 *
|
|
227 * @param account The account making the connection.
|
|
228 * @param host The destination host.
|
|
229 * @param port The destination port.
|
|
230 * @param connect_cb The function to call when the connection is
|
|
231 * established. If the connection failed then
|
|
232 * fd will be -1 and error message will be set
|
|
233 * to something descriptive (hopefully).
|
|
234 * @param data User-defined data.
|
|
235 *
|
|
236 * @return NULL if there was an error, or a reference to a data
|
|
237 * structure that can be used to cancel the pending
|
|
238 * connection, if needed.
|
|
239 */
|
|
240 GaimProxyConnectInfo *gaim_proxy_connect(GaimAccount *account,
|
|
241 const char *host, int port,
|
|
242 GaimProxyConnectFunction connect_cb, gpointer data);
|
|
243
|
|
244 /**
|
|
245 * Makes a connection through a SOCKS5 proxy.
|
|
246 *
|
|
247 * @param gpi The GaimProxyInfo specifying the proxy settings
|
|
248 * @param host The destination host.
|
|
249 * @param port The destination port.
|
|
250 * @param connect_cb The function to call when the connection is
|
|
251 * established. If the connection failed then
|
|
252 * fd will be -1 and error message will be set
|
|
253 * to something descriptive (hopefully).
|
|
254 * @param data User-defined data.
|
|
255 *
|
|
256 * @return NULL if there was an error, or a reference to a data
|
|
257 * structure that can be used to cancel the pending
|
|
258 * connection, if needed.
|
|
259 */
|
|
260 GaimProxyConnectInfo *gaim_proxy_connect_socks5(GaimProxyInfo *gpi,
|
|
261 const char *host, int port,
|
|
262 GaimProxyConnectFunction connect_cb, gpointer data);
|
|
263
|
|
264 /**
|
|
265 * Cancel an in-progress connection attempt. This should be called
|
|
266 * by the PRPL if the user disables an account while it is still
|
|
267 * performing the initial sign on. Or when establishing a file
|
|
268 * transfer, if we attempt to connect to a remote user but they
|
|
269 * are behind a firewall then the PRPL can cancel the connection
|
|
270 * attempt early rather than just letting the OS's TCP/IP stack
|
|
271 * time-out the connection.
|
|
272 */
|
|
273 void gaim_proxy_connect_cancel(GaimProxyConnectInfo *connect_info);
|
|
274
|
|
275 /*@}*/
|
|
276
|
|
277 #ifdef __cplusplus
|
|
278 }
|
|
279 #endif
|
|
280
|
|
281 #endif /* _GAIM_PROXY_H_ */
|