Fri, 03 Dec 2004 04:02:10 +0000
[gaim-migrate @ 11505]
Hitting the enter key when you're cursor is in the alias field of the
Add Chat dialog now activates the dialogs default action.
Closes bug 1075200 and patch 1078079. Thanks to Andrew Hart for
taking a stab at this and wounding, but not killing. Killing is wrong!
committer: Mark Doliner <markdoliner@pidgin.im>
| 6703 | 1 | /** |
| 2 | * @file sslconn.h SSL API | |
| 3 | * @ingroup core | |
| 4 | * | |
| 5 | * gaim | |
| 6 | * | |
| 8046 | 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. | |
| 6703 | 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 | */ | |
|
9713
bb37562302a1
[gaim-migrate @ 10574]
Mark Doliner <markdoliner@pidgin.im>
parents:
8362
diff
changeset
|
25 | #ifndef _GAIM_SSLCONN_H_ |
|
bb37562302a1
[gaim-migrate @ 10574]
Mark Doliner <markdoliner@pidgin.im>
parents:
8362
diff
changeset
|
26 | #define _GAIM_SSLCONN_H_ |
| 6703 | 27 | |
| 28 | #include "proxy.h" | |
| 29 | ||
|
6738
aa797bcc69dd
[gaim-migrate @ 7270]
Christian Hammond <chipx86@chipx86.com>
parents:
6720
diff
changeset
|
30 | #define GAIM_SSL_DEFAULT_PORT 443 |
|
aa797bcc69dd
[gaim-migrate @ 7270]
Christian Hammond <chipx86@chipx86.com>
parents:
6720
diff
changeset
|
31 | |
|
7274
42ec5f56e32a
[gaim-migrate @ 7851]
Christian Hammond <chipx86@chipx86.com>
parents:
6783
diff
changeset
|
32 | typedef enum |
|
42ec5f56e32a
[gaim-migrate @ 7851]
Christian Hammond <chipx86@chipx86.com>
parents:
6783
diff
changeset
|
33 | { |
| 8362 | 34 | GAIM_SSL_HANDSHAKE_FAILED = 1, |
| 35 | GAIM_SSL_CONNECT_FAILED = 2 | |
|
7274
42ec5f56e32a
[gaim-migrate @ 7851]
Christian Hammond <chipx86@chipx86.com>
parents:
6783
diff
changeset
|
36 | } GaimSslErrorType; |
|
42ec5f56e32a
[gaim-migrate @ 7851]
Christian Hammond <chipx86@chipx86.com>
parents:
6783
diff
changeset
|
37 | |
|
6738
aa797bcc69dd
[gaim-migrate @ 7270]
Christian Hammond <chipx86@chipx86.com>
parents:
6720
diff
changeset
|
38 | typedef struct _GaimSslConnection GaimSslConnection; |
|
aa797bcc69dd
[gaim-migrate @ 7270]
Christian Hammond <chipx86@chipx86.com>
parents:
6720
diff
changeset
|
39 | |
|
aa797bcc69dd
[gaim-migrate @ 7270]
Christian Hammond <chipx86@chipx86.com>
parents:
6720
diff
changeset
|
40 | typedef void (*GaimSslInputFunction)(gpointer, GaimSslConnection *, |
|
aa797bcc69dd
[gaim-migrate @ 7270]
Christian Hammond <chipx86@chipx86.com>
parents:
6720
diff
changeset
|
41 | GaimInputCondition); |
|
7274
42ec5f56e32a
[gaim-migrate @ 7851]
Christian Hammond <chipx86@chipx86.com>
parents:
6783
diff
changeset
|
42 | typedef void (*GaimSslErrorFunction)(GaimSslConnection *, GaimSslErrorType, |
|
42ec5f56e32a
[gaim-migrate @ 7851]
Christian Hammond <chipx86@chipx86.com>
parents:
6783
diff
changeset
|
43 | gpointer); |
|
6738
aa797bcc69dd
[gaim-migrate @ 7270]
Christian Hammond <chipx86@chipx86.com>
parents:
6720
diff
changeset
|
44 | |
|
aa797bcc69dd
[gaim-migrate @ 7270]
Christian Hammond <chipx86@chipx86.com>
parents:
6720
diff
changeset
|
45 | struct _GaimSslConnection |
|
aa797bcc69dd
[gaim-migrate @ 7270]
Christian Hammond <chipx86@chipx86.com>
parents:
6720
diff
changeset
|
46 | { |
|
aa797bcc69dd
[gaim-migrate @ 7270]
Christian Hammond <chipx86@chipx86.com>
parents:
6720
diff
changeset
|
47 | char *host; |
|
aa797bcc69dd
[gaim-migrate @ 7270]
Christian Hammond <chipx86@chipx86.com>
parents:
6720
diff
changeset
|
48 | int port; |
| 6764 | 49 | void *connect_cb_data; |
| 50 | GaimSslInputFunction connect_cb; | |
|
7274
42ec5f56e32a
[gaim-migrate @ 7851]
Christian Hammond <chipx86@chipx86.com>
parents:
6783
diff
changeset
|
51 | GaimSslErrorFunction error_cb; |
| 6764 | 52 | void *recv_cb_data; |
| 53 | GaimSslInputFunction recv_cb; | |
|
6738
aa797bcc69dd
[gaim-migrate @ 7270]
Christian Hammond <chipx86@chipx86.com>
parents:
6720
diff
changeset
|
54 | |
|
aa797bcc69dd
[gaim-migrate @ 7270]
Christian Hammond <chipx86@chipx86.com>
parents:
6720
diff
changeset
|
55 | int fd; |
|
aa797bcc69dd
[gaim-migrate @ 7270]
Christian Hammond <chipx86@chipx86.com>
parents:
6720
diff
changeset
|
56 | int inpa; |
|
aa797bcc69dd
[gaim-migrate @ 7270]
Christian Hammond <chipx86@chipx86.com>
parents:
6720
diff
changeset
|
57 | |
|
aa797bcc69dd
[gaim-migrate @ 7270]
Christian Hammond <chipx86@chipx86.com>
parents:
6720
diff
changeset
|
58 | void *private_data; |
|
aa797bcc69dd
[gaim-migrate @ 7270]
Christian Hammond <chipx86@chipx86.com>
parents:
6720
diff
changeset
|
59 | }; |
|
aa797bcc69dd
[gaim-migrate @ 7270]
Christian Hammond <chipx86@chipx86.com>
parents:
6720
diff
changeset
|
60 | |
|
aa797bcc69dd
[gaim-migrate @ 7270]
Christian Hammond <chipx86@chipx86.com>
parents:
6720
diff
changeset
|
61 | /** |
|
aa797bcc69dd
[gaim-migrate @ 7270]
Christian Hammond <chipx86@chipx86.com>
parents:
6720
diff
changeset
|
62 | * SSL implementation operations structure. |
|
aa797bcc69dd
[gaim-migrate @ 7270]
Christian Hammond <chipx86@chipx86.com>
parents:
6720
diff
changeset
|
63 | * |
|
aa797bcc69dd
[gaim-migrate @ 7270]
Christian Hammond <chipx86@chipx86.com>
parents:
6720
diff
changeset
|
64 | * Every SSL implementation must provide one of these and register it. |
|
aa797bcc69dd
[gaim-migrate @ 7270]
Christian Hammond <chipx86@chipx86.com>
parents:
6720
diff
changeset
|
65 | */ |
|
aa797bcc69dd
[gaim-migrate @ 7270]
Christian Hammond <chipx86@chipx86.com>
parents:
6720
diff
changeset
|
66 | typedef struct |
|
aa797bcc69dd
[gaim-migrate @ 7270]
Christian Hammond <chipx86@chipx86.com>
parents:
6720
diff
changeset
|
67 | { |
|
aa797bcc69dd
[gaim-migrate @ 7270]
Christian Hammond <chipx86@chipx86.com>
parents:
6720
diff
changeset
|
68 | gboolean (*init)(void); |
|
aa797bcc69dd
[gaim-migrate @ 7270]
Christian Hammond <chipx86@chipx86.com>
parents:
6720
diff
changeset
|
69 | void (*uninit)(void); |
|
aa797bcc69dd
[gaim-migrate @ 7270]
Christian Hammond <chipx86@chipx86.com>
parents:
6720
diff
changeset
|
70 | GaimInputFunction connect_cb; |
|
aa797bcc69dd
[gaim-migrate @ 7270]
Christian Hammond <chipx86@chipx86.com>
parents:
6720
diff
changeset
|
71 | void (*close)(GaimSslConnection *gsc); |
|
aa797bcc69dd
[gaim-migrate @ 7270]
Christian Hammond <chipx86@chipx86.com>
parents:
6720
diff
changeset
|
72 | size_t (*read)(GaimSslConnection *gsc, void *data, size_t len); |
|
aa797bcc69dd
[gaim-migrate @ 7270]
Christian Hammond <chipx86@chipx86.com>
parents:
6720
diff
changeset
|
73 | size_t (*write)(GaimSslConnection *gsc, const void *data, size_t len); |
|
aa797bcc69dd
[gaim-migrate @ 7270]
Christian Hammond <chipx86@chipx86.com>
parents:
6720
diff
changeset
|
74 | |
|
aa797bcc69dd
[gaim-migrate @ 7270]
Christian Hammond <chipx86@chipx86.com>
parents:
6720
diff
changeset
|
75 | } GaimSslOps; |
|
aa797bcc69dd
[gaim-migrate @ 7270]
Christian Hammond <chipx86@chipx86.com>
parents:
6720
diff
changeset
|
76 | |
| 6703 | 77 | #ifdef __cplusplus |
| 78 | extern "C" { | |
| 79 | #endif | |
| 80 | ||
| 81 | /**************************************************************************/ | |
| 82 | /** @name SSL API */ | |
| 83 | /**************************************************************************/ | |
| 84 | /*@{*/ | |
| 85 | ||
| 86 | /** | |
| 87 | * Returns whether or not SSL is currently supported. | |
| 88 | * | |
| 89 | * @return TRUE if SSL is supported, or FALSE otherwise. | |
| 90 | */ | |
| 91 | gboolean gaim_ssl_is_supported(void); | |
| 92 | ||
| 93 | /** | |
| 94 | * Makes a SSL connection to the specified host and port. | |
| 95 | * | |
|
7274
42ec5f56e32a
[gaim-migrate @ 7851]
Christian Hammond <chipx86@chipx86.com>
parents:
6783
diff
changeset
|
96 | * @param account The account making the connection. |
|
42ec5f56e32a
[gaim-migrate @ 7851]
Christian Hammond <chipx86@chipx86.com>
parents:
6783
diff
changeset
|
97 | * @param host The destination host. |
|
42ec5f56e32a
[gaim-migrate @ 7851]
Christian Hammond <chipx86@chipx86.com>
parents:
6783
diff
changeset
|
98 | * @param port The destination port. |
|
42ec5f56e32a
[gaim-migrate @ 7851]
Christian Hammond <chipx86@chipx86.com>
parents:
6783
diff
changeset
|
99 | * @param func The SSL input handler function. |
|
42ec5f56e32a
[gaim-migrate @ 7851]
Christian Hammond <chipx86@chipx86.com>
parents:
6783
diff
changeset
|
100 | * @param error_func The SSL error handler function. |
|
42ec5f56e32a
[gaim-migrate @ 7851]
Christian Hammond <chipx86@chipx86.com>
parents:
6783
diff
changeset
|
101 | * @param data User-defined data. |
| 6703 | 102 | * |
| 103 | * @return The SSL connection handle. | |
| 104 | */ | |
| 105 | GaimSslConnection *gaim_ssl_connect(GaimAccount *account, const char *host, | |
| 106 | int port, GaimSslInputFunction func, | |
|
7274
42ec5f56e32a
[gaim-migrate @ 7851]
Christian Hammond <chipx86@chipx86.com>
parents:
6783
diff
changeset
|
107 | GaimSslErrorFunction error_func, |
| 6703 | 108 | void *data); |
| 109 | ||
| 110 | /** | |
|
7274
42ec5f56e32a
[gaim-migrate @ 7851]
Christian Hammond <chipx86@chipx86.com>
parents:
6783
diff
changeset
|
111 | * Makes a SSL connection using an already open file descriptor. |
|
42ec5f56e32a
[gaim-migrate @ 7851]
Christian Hammond <chipx86@chipx86.com>
parents:
6783
diff
changeset
|
112 | * |
|
42ec5f56e32a
[gaim-migrate @ 7851]
Christian Hammond <chipx86@chipx86.com>
parents:
6783
diff
changeset
|
113 | * @param account The account making the connection. |
|
42ec5f56e32a
[gaim-migrate @ 7851]
Christian Hammond <chipx86@chipx86.com>
parents:
6783
diff
changeset
|
114 | * @param fd The file descriptor. |
|
42ec5f56e32a
[gaim-migrate @ 7851]
Christian Hammond <chipx86@chipx86.com>
parents:
6783
diff
changeset
|
115 | * @param func The SSL input handler function. |
|
42ec5f56e32a
[gaim-migrate @ 7851]
Christian Hammond <chipx86@chipx86.com>
parents:
6783
diff
changeset
|
116 | * @param error_func The SSL error handler function. |
|
42ec5f56e32a
[gaim-migrate @ 7851]
Christian Hammond <chipx86@chipx86.com>
parents:
6783
diff
changeset
|
117 | * @param data User-defined data. |
|
42ec5f56e32a
[gaim-migrate @ 7851]
Christian Hammond <chipx86@chipx86.com>
parents:
6783
diff
changeset
|
118 | * |
|
42ec5f56e32a
[gaim-migrate @ 7851]
Christian Hammond <chipx86@chipx86.com>
parents:
6783
diff
changeset
|
119 | * @return The SSL connection handle. |
|
42ec5f56e32a
[gaim-migrate @ 7851]
Christian Hammond <chipx86@chipx86.com>
parents:
6783
diff
changeset
|
120 | */ |
|
42ec5f56e32a
[gaim-migrate @ 7851]
Christian Hammond <chipx86@chipx86.com>
parents:
6783
diff
changeset
|
121 | GaimSslConnection *gaim_ssl_connect_fd(GaimAccount *account, int fd, |
|
42ec5f56e32a
[gaim-migrate @ 7851]
Christian Hammond <chipx86@chipx86.com>
parents:
6783
diff
changeset
|
122 | GaimSslInputFunction func, |
|
42ec5f56e32a
[gaim-migrate @ 7851]
Christian Hammond <chipx86@chipx86.com>
parents:
6783
diff
changeset
|
123 | GaimSslErrorFunction error_func, |
|
42ec5f56e32a
[gaim-migrate @ 7851]
Christian Hammond <chipx86@chipx86.com>
parents:
6783
diff
changeset
|
124 | void *data); |
|
42ec5f56e32a
[gaim-migrate @ 7851]
Christian Hammond <chipx86@chipx86.com>
parents:
6783
diff
changeset
|
125 | |
|
42ec5f56e32a
[gaim-migrate @ 7851]
Christian Hammond <chipx86@chipx86.com>
parents:
6783
diff
changeset
|
126 | /** |
| 6764 | 127 | * Adds an input watcher for the specified SSL connection. |
| 128 | * | |
| 129 | * @param gsc The SSL connection handle. | |
| 130 | * @param func The callback function. | |
| 131 | * @param data User-defined data. | |
| 132 | */ | |
| 133 | void gaim_ssl_input_add(GaimSslConnection *gsc, GaimSslInputFunction func, | |
|
7274
42ec5f56e32a
[gaim-migrate @ 7851]
Christian Hammond <chipx86@chipx86.com>
parents:
6783
diff
changeset
|
134 | void *data); |
|
6762
2349053f14aa
[gaim-migrate @ 7294]
Christian Hammond <chipx86@chipx86.com>
parents:
6738
diff
changeset
|
135 | |
|
2349053f14aa
[gaim-migrate @ 7294]
Christian Hammond <chipx86@chipx86.com>
parents:
6738
diff
changeset
|
136 | /** |
| 6703 | 137 | * Closes a SSL connection. |
| 138 | * | |
| 139 | * @param gsc The SSL connection to close. | |
| 140 | */ | |
| 141 | void gaim_ssl_close(GaimSslConnection *gsc); | |
| 142 | ||
| 143 | /** | |
| 144 | * Reads data from an SSL connection. | |
| 145 | * | |
| 146 | * @param gsc The SSL connection handle. | |
| 147 | * @param buffer The destination buffer. | |
| 148 | * @param len The maximum number of bytes to read. | |
| 149 | * | |
| 150 | * @return The number of bytes read. | |
| 151 | */ | |
|
6720
cdc5348dd848
[gaim-migrate @ 7247]
Christian Hammond <chipx86@chipx86.com>
parents:
6703
diff
changeset
|
152 | size_t gaim_ssl_read(GaimSslConnection *gsc, void *buffer, size_t len); |
| 6703 | 153 | |
| 154 | /** | |
| 155 | * Writes data to an SSL connection. | |
| 156 | * | |
|
6720
cdc5348dd848
[gaim-migrate @ 7247]
Christian Hammond <chipx86@chipx86.com>
parents:
6703
diff
changeset
|
157 | * @param gsc The SSL connection handle. |
|
cdc5348dd848
[gaim-migrate @ 7247]
Christian Hammond <chipx86@chipx86.com>
parents:
6703
diff
changeset
|
158 | * @param buffer The buffer to write. |
|
cdc5348dd848
[gaim-migrate @ 7247]
Christian Hammond <chipx86@chipx86.com>
parents:
6703
diff
changeset
|
159 | * @param len The length of the data to write. |
| 6703 | 160 | * |
| 161 | * @return The number of bytes written. | |
| 162 | */ | |
|
6720
cdc5348dd848
[gaim-migrate @ 7247]
Christian Hammond <chipx86@chipx86.com>
parents:
6703
diff
changeset
|
163 | size_t gaim_ssl_write(GaimSslConnection *gsc, const void *buffer, size_t len); |
| 6703 | 164 | |
| 165 | /*@}*/ | |
| 166 | ||
| 167 | /**************************************************************************/ | |
| 168 | /** @name Subsystem API */ | |
| 169 | /**************************************************************************/ | |
| 170 | /*@{*/ | |
| 171 | ||
| 172 | /** | |
|
6738
aa797bcc69dd
[gaim-migrate @ 7270]
Christian Hammond <chipx86@chipx86.com>
parents:
6720
diff
changeset
|
173 | * Sets the current SSL operations structure. |
|
aa797bcc69dd
[gaim-migrate @ 7270]
Christian Hammond <chipx86@chipx86.com>
parents:
6720
diff
changeset
|
174 | * |
|
aa797bcc69dd
[gaim-migrate @ 7270]
Christian Hammond <chipx86@chipx86.com>
parents:
6720
diff
changeset
|
175 | * @param ops The SSL operations structure to assign. |
|
aa797bcc69dd
[gaim-migrate @ 7270]
Christian Hammond <chipx86@chipx86.com>
parents:
6720
diff
changeset
|
176 | */ |
|
aa797bcc69dd
[gaim-migrate @ 7270]
Christian Hammond <chipx86@chipx86.com>
parents:
6720
diff
changeset
|
177 | void gaim_ssl_set_ops(GaimSslOps *ops); |
|
aa797bcc69dd
[gaim-migrate @ 7270]
Christian Hammond <chipx86@chipx86.com>
parents:
6720
diff
changeset
|
178 | |
|
aa797bcc69dd
[gaim-migrate @ 7270]
Christian Hammond <chipx86@chipx86.com>
parents:
6720
diff
changeset
|
179 | /** |
|
aa797bcc69dd
[gaim-migrate @ 7270]
Christian Hammond <chipx86@chipx86.com>
parents:
6720
diff
changeset
|
180 | * Returns the current SSL operations structure. |
|
aa797bcc69dd
[gaim-migrate @ 7270]
Christian Hammond <chipx86@chipx86.com>
parents:
6720
diff
changeset
|
181 | * |
|
aa797bcc69dd
[gaim-migrate @ 7270]
Christian Hammond <chipx86@chipx86.com>
parents:
6720
diff
changeset
|
182 | * @return The SSL operations structure. |
|
aa797bcc69dd
[gaim-migrate @ 7270]
Christian Hammond <chipx86@chipx86.com>
parents:
6720
diff
changeset
|
183 | */ |
|
aa797bcc69dd
[gaim-migrate @ 7270]
Christian Hammond <chipx86@chipx86.com>
parents:
6720
diff
changeset
|
184 | GaimSslOps *gaim_ssl_get_ops(void); |
|
aa797bcc69dd
[gaim-migrate @ 7270]
Christian Hammond <chipx86@chipx86.com>
parents:
6720
diff
changeset
|
185 | |
|
aa797bcc69dd
[gaim-migrate @ 7270]
Christian Hammond <chipx86@chipx86.com>
parents:
6720
diff
changeset
|
186 | /** |
| 6703 | 187 | * Initializes the SSL subsystem. |
| 188 | */ | |
| 189 | void gaim_ssl_init(void); | |
| 190 | ||
| 191 | /** | |
| 192 | * Uninitializes the SSL subsystem. | |
| 193 | */ | |
| 194 | void gaim_ssl_uninit(void); | |
| 195 | ||
| 196 | /*@}*/ | |
| 197 | ||
| 198 | #ifdef __cplusplus | |
| 199 | } | |
| 200 | #endif | |
| 201 | ||
|
9713
bb37562302a1
[gaim-migrate @ 10574]
Mark Doliner <markdoliner@pidgin.im>
parents:
8362
diff
changeset
|
202 | #endif /* _GAIM_SSLCONN_H_ */ |