Mercurial > pidgin
comparison src/proxy.h @ 5681:46d7ad0dfa26
[gaim-migrate @ 6100]
Rewrote the proxy code. It should now work with the new prefs, and it has a
namespace and API too!
committer: Tailor Script <tailor@pidgin.im>
| author | Christian Hammond <chipx86@chipx86.com> |
|---|---|
| date | Tue, 03 Jun 2003 02:00:33 +0000 |
| parents | dfdea22a7153 |
| children | cec7988f8ee7 |
comparison
equal
deleted
inserted
replaced
| 5680:71cc0d5376c2 | 5681:46d7ad0dfa26 |
|---|---|
| 1 /** | 1 /** |
| 2 * @file proxy.h Proxy functions | 2 * @file proxy.h Proxy API |
| 3 * @ingroup core | 3 * @ingroup core |
| 4 * | 4 * |
| 5 * gaim | 5 * gaim |
| 6 * | 6 * |
| 7 * Copyright (C) 1998-1999, Mark Spencer <markster@marko.net> | 7 * Copyright (C) 1998-1999, Mark Spencer <markster@marko.net> |
| 8 * Copyright (C) 2003 Christian Hammond <chipx86@gnupdate.org> | |
| 8 * | 9 * |
| 9 * This program is free software; you can redistribute it and/or modify | 10 * This program is free software; you can redistribute it and/or modify |
| 10 * it under the terms of the GNU General Public License as published by | 11 * it under the terms of the GNU General Public License as published by |
| 11 * the Free Software Foundation; either version 2 of the License, or | 12 * the Free Software Foundation; either version 2 of the License, or |
| 12 * (at your option) any later version. | 13 * (at your option) any later version. |
| 18 * | 19 * |
| 19 * You should have received a copy of the GNU General Public License | 20 * You should have received a copy of the GNU General Public License |
| 20 * along with this program; if not, write to the Free Software | 21 * along with this program; if not, write to the Free Software |
| 21 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | 22 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
| 22 */ | 23 */ |
| 23 | 24 #ifndef _GAIM_PROXY_H_ |
| 24 /* this is the export part of the proxy.c file. it does a little | 25 #define _GAIM_PROXY_H_ |
| 25 prototype-ing stuff and redefine some net function to mask them | |
| 26 with some kind of transparent layer */ | |
| 27 | |
| 28 #ifndef _PROXY_H_ | |
| 29 #define _PROXY_H_ | |
| 30 | 26 |
| 31 #include <sys/types.h> | 27 #include <sys/types.h> |
| 32 /*this must happen before sys/socket.h or freebsd won't compile*/ | 28 /*this must happen before sys/socket.h or freebsd won't compile*/ |
| 33 | 29 |
| 34 #ifndef _WIN32 | 30 #ifndef _WIN32 |
| 35 #include <sys/socket.h> | 31 # include <sys/socket.h> |
| 36 #include <netdb.h> | 32 # include <netdb.h> |
| 37 #include <netinet/in.h> | 33 # include <netinet/in.h> |
| 38 #else | 34 #else |
| 39 #include <winsock.h> | 35 # include <winsock.h> |
| 40 #endif | 36 #endif |
| 41 | 37 |
| 42 #include <glib.h> | 38 #include <glib.h> |
| 43 | 39 |
| 44 #include "core.h" | 40 #include "core.h" |
| 45 | 41 #include "account.h" |
| 46 typedef enum { | 42 |
| 47 PROXY_USE_GLOBAL = -1, | 43 /** |
| 48 PROXY_NONE = 0, | 44 * A type of proxy connection. |
| 49 PROXY_HTTP, | 45 */ |
| 50 PROXY_SOCKS4, | 46 typedef enum |
| 51 PROXY_SOCKS5, | 47 { |
| 52 } proxytype_t; | 48 GAIM_PROXY_USE_GLOBAL = -1, /**< Use the global proxy information. */ |
| 53 | 49 GAIM_PROXY_NONE = 0, /**< No proxy. */ |
| 54 struct gaim_proxy_info { | 50 GAIM_PROXY_HTTP, /**< HTTP proxy. */ |
| 55 int proxytype; | 51 GAIM_PROXY_SOCKS4, /**< SOCKS 4 proxy. */ |
| 56 char proxyhost[128]; | 52 GAIM_PROXY_SOCKS5, /**< SOCKS 5 proxy. */ |
| 57 proxytype_t proxyport; | 53 |
| 58 char proxyuser[128]; | 54 } GaimProxyType; |
| 59 char proxypass[128]; | 55 |
| 60 }; | 56 /** |
| 61 | 57 * An input condition. |
| 62 extern struct gaim_proxy_info global_proxy_info; | 58 */ |
| 63 extern guint proxy_info_is_from_gaimrc; | 59 typedef enum |
| 64 | 60 { |
| 65 typedef enum { | 61 GAIM_INPUT_READ = 1 << 0, |
| 66 GAIM_INPUT_READ = 1 << 0, | |
| 67 GAIM_INPUT_WRITE = 1 << 1 | 62 GAIM_INPUT_WRITE = 1 << 1 |
| 63 | |
| 68 } GaimInputCondition; | 64 } GaimInputCondition; |
| 65 | |
| 66 /** | |
| 67 * Information on proxy settings. | |
| 68 */ | |
| 69 typedef struct | |
| 70 { | |
| 71 GaimProxyType type; /**< The proxy type. */ | |
| 72 | |
| 73 char *host; /**< The host. */ | |
| 74 int port; /**< The port number. */ | |
| 75 char *username; /**< The username. */ | |
| 76 char *password; /**< The password. */ | |
| 77 | |
| 78 } GaimProxyInfo; | |
| 79 | |
| 69 typedef void (*GaimInputFunction)(gpointer, gint, GaimInputCondition); | 80 typedef void (*GaimInputFunction)(gpointer, gint, GaimInputCondition); |
| 70 | 81 |
| 71 extern gint gaim_input_add(int, GaimInputCondition, GaimInputFunction, gpointer); | 82 /**************************************************************************/ |
| 72 extern void gaim_input_remove(gint); | 83 /** @name Proxy structure API */ |
| 73 | 84 /**************************************************************************/ |
| 74 extern int proxy_connect(GaimAccount *account, const char *host, int port, GaimInputFunction func, gpointer data); | 85 /*@{*/ |
| 75 | 86 |
| 76 #endif /* _PROXY_H_ */ | 87 /** |
| 88 * Creates a proxy information structure. | |
| 89 * | |
| 90 * @return The proxy information structure. | |
| 91 */ | |
| 92 GaimProxyInfo *gaim_proxy_info_new(void); | |
| 93 | |
| 94 /** | |
| 95 * Destroys a proxy information structure. | |
| 96 * | |
| 97 * @param proxy The proxy information structure to destroy. | |
| 98 */ | |
| 99 void gaim_proxy_info_destroy(GaimProxyInfo *info); | |
| 100 | |
| 101 /** | |
| 102 * Sets the type of proxy. | |
| 103 * | |
| 104 * @param proxy The proxy information. | |
| 105 * @param type The proxy type. | |
| 106 */ | |
| 107 void gaim_proxy_info_set_type(GaimProxyInfo *info, GaimProxyType type); | |
| 108 | |
| 109 /** | |
| 110 * Sets the proxy host. | |
| 111 * | |
| 112 * @param proxy The proxy information. | |
| 113 * @param host The host. | |
| 114 */ | |
| 115 void gaim_proxy_info_set_host(GaimProxyInfo *info, const char *host); | |
| 116 | |
| 117 /** | |
| 118 * Sets the proxy port. | |
| 119 * | |
| 120 * @param proxy The proxy information. | |
| 121 * @param port The port. | |
| 122 */ | |
| 123 void gaim_proxy_info_set_port(GaimProxyInfo *info, int port); | |
| 124 | |
| 125 /** | |
| 126 * Sets the proxy username. | |
| 127 * | |
| 128 * @param proxy The proxy information. | |
| 129 * @param username The username. | |
| 130 */ | |
| 131 void gaim_proxy_info_set_username(GaimProxyInfo *info, const char *username); | |
| 132 | |
| 133 /** | |
| 134 * Sets the proxy password. | |
| 135 * | |
| 136 * @param proxy The proxy information. | |
| 137 * @param password The password. | |
| 138 */ | |
| 139 void gaim_proxy_info_set_password(GaimProxyInfo *info, const char *password); | |
| 140 | |
| 141 /** | |
| 142 * Returns the proxy's type. | |
| 143 * | |
| 144 * @param The proxy information. | |
| 145 * | |
| 146 * @return The type. | |
| 147 */ | |
| 148 GaimProxyType gaim_proxy_info_get_type(const GaimProxyInfo *info); | |
| 149 | |
| 150 /** | |
| 151 * Returns the proxy's host. | |
| 152 * | |
| 153 * @param The proxy information. | |
| 154 * | |
| 155 * @return The host. | |
| 156 */ | |
| 157 const char *gaim_proxy_info_get_host(const GaimProxyInfo *info); | |
| 158 | |
| 159 /** | |
| 160 * Returns the proxy's port. | |
| 161 * | |
| 162 * @param The proxy information. | |
| 163 * | |
| 164 * @return The port. | |
| 165 */ | |
| 166 int gaim_proxy_info_get_port(const GaimProxyInfo *info); | |
| 167 | |
| 168 /** | |
| 169 * Returns the proxy's username. | |
| 170 * | |
| 171 * @param The proxy information. | |
| 172 * | |
| 173 * @return The username. | |
| 174 */ | |
| 175 const char *gaim_proxy_info_get_username(const GaimProxyInfo *info); | |
| 176 | |
| 177 /** | |
| 178 * Returns the proxy's password. | |
| 179 * | |
| 180 * @param The proxy information. | |
| 181 * | |
| 182 * @return The password. | |
| 183 */ | |
| 184 const char *gaim_proxy_info_get_password(const GaimProxyInfo *info); | |
| 185 | |
| 186 /*@}*/ | |
| 187 | |
| 188 /**************************************************************************/ | |
| 189 /** @name Global Proxy API */ | |
| 190 /**************************************************************************/ | |
| 191 /*@{*/ | |
| 192 | |
| 193 /** | |
| 194 * Sets whether or not the global proxy information is from preferences. | |
| 195 * | |
| 196 * @param from_prefs @c TRUE if the info is from preferences. | |
| 197 */ | |
| 198 void gaim_global_proxy_set_from_prefs(gboolean from_prefs); | |
| 199 | |
| 200 /** | |
| 201 * Returns gaim's global proxy information. | |
| 202 * | |
| 203 * @return The global proxy information. | |
| 204 */ | |
| 205 GaimProxyInfo *gaim_global_proxy_get_info(void); | |
| 206 | |
| 207 /** | |
| 208 * Returns whether or not the current global proxy information is from | |
| 209 * preferences. | |
| 210 * | |
| 211 * @return @c TRUE if the info is from preferences. | |
| 212 */ | |
| 213 gboolean gaim_global_proxy_is_from_prefs(void); | |
| 214 | |
| 215 /*@}*/ | |
| 216 | |
| 217 /**************************************************************************/ | |
| 218 /** @name Proxy API */ | |
| 219 /**************************************************************************/ | |
| 220 /*@{*/ | |
| 221 | |
| 222 /** | |
| 223 * Initializes the proxy subsystem. | |
| 224 */ | |
| 225 void gaim_proxy_init(void); | |
| 226 | |
| 227 /** | |
| 228 * Adds an input handler. | |
| 229 * | |
| 230 * @param source The input source. | |
| 231 * @param cond The condition type. | |
| 232 * @param func The callback function for data. | |
| 233 * @param user_data User-specified data. | |
| 234 * | |
| 235 * @return The resulting handle. | |
| 236 */ | |
| 237 gint gaim_input_add(int source, GaimInputCondition cond, | |
| 238 GaimInputFunction func, gpointer user_data); | |
| 239 | |
| 240 /** | |
| 241 * Removes an input handler. | |
| 242 * | |
| 243 * @param handle The handle of the input handler. | |
| 244 */ | |
| 245 void gaim_input_remove(gint handle); | |
| 246 | |
| 247 /** | |
| 248 * Makes a connection to the specified host and port. | |
| 249 * | |
| 250 * @param account The account making the connection. | |
| 251 * @param host The destination host. | |
| 252 * @Param port The destination port. | |
| 253 * @Param func The input handler function. | |
| 254 * @param data User-defined data. | |
| 255 * | |
| 256 * @return The socket handle. | |
| 257 */ | |
| 258 int gaim_proxy_connect(GaimAccount *account, const char *host, int port, | |
| 259 GaimInputFunction func, gpointer data); | |
| 260 | |
| 261 /*@}*/ | |
| 262 | |
| 263 #endif /* _GAIM_PROXY_H_ */ |
