sslconn.h
Go to the documentation of this file.
1 
6 /* purple
7  *
8  * Purple is the legal property of its developers, whose names are too numerous
9  * to list here. Please refer to the COPYRIGHT file distributed with this
10  * source distribution.
11  *
12  * This program is free software; you can redistribute it and/or modify
13  * it under the terms of the GNU General Public License as published by
14  * the Free Software Foundation; either version 2 of the License, or
15  * (at your option) any later version.
16  *
17  * This program is distributed in the hope that it will be useful,
18  * but WITHOUT ANY WARRANTY; without even the implied warranty of
19  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20  * GNU General Public License for more details.
21  *
22  * You should have received a copy of the GNU General Public License
23  * along with this program; if not, write to the Free Software
24  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA
25  */
26 #ifndef _PURPLE_SSLCONN_H_
27 #define _PURPLE_SSLCONN_H_
28 
30 typedef enum
31 {
32  PURPLE_SSL_HANDSHAKE_FAILED = 1,
33  PURPLE_SSL_CONNECT_FAILED = 2,
34  PURPLE_SSL_CERTIFICATE_INVALID = 3
36 
37 #include "certificate.h"
38 #include "proxy.h"
39 
40 #define PURPLE_SSL_DEFAULT_PORT 443
41 
44 
45 typedef void (*PurpleSslInputFunction)(gpointer, PurpleSslConnection *,
47 typedef void (*PurpleSslErrorFunction)(PurpleSslConnection *, PurpleSslErrorType,
48  gpointer);
49 
51 {
53  char *host;
55  int port;
59  PurpleSslInputFunction connect_cb;
61  PurpleSslErrorFunction error_cb;
63  void *recv_cb_data;
65  PurpleSslInputFunction recv_cb;
66 
68  int fd;
71  guint inpa;
73  PurpleProxyConnectData *connect_data;
74 
76  void *private_data;
77 
80 };
81 
88 typedef struct
89 {
94  gboolean (*init)(void);
98  void (*uninit)(void);
103  void (*connectfunc)(PurpleSslConnection *gsc);
108  void (*close)(PurpleSslConnection *gsc);
117  size_t (*read)(PurpleSslConnection *gsc, void *data, size_t len);
126  size_t (*write)(PurpleSslConnection *gsc, const void *data, size_t len);
136  GList * (* get_peer_certificates)(PurpleSslConnection * gsc);
137 
138  void (*_purple_reserved2)(void);
139  void (*_purple_reserved3)(void);
140  void (*_purple_reserved4)(void);
141 } PurpleSslOps;
142 
143 #ifdef __cplusplus
144 extern "C" {
145 #endif
146 
147 /**************************************************************************/
149 /**************************************************************************/
157 gboolean purple_ssl_is_supported(void);
158 
165 const gchar * purple_ssl_strerror(PurpleSslErrorType error);
166 
184 PurpleSslConnection *purple_ssl_connect(PurpleAccount *account, const char *host,
185  int port, PurpleSslInputFunction func,
186  PurpleSslErrorFunction error_func,
187  void *data);
188 
209  int port, PurpleSslInputFunction func,
210  PurpleSslErrorFunction error_func,
211  const char *ssl_host,
212  void *data);
213 
214 #if !(defined PURPLE_DISABLE_DEPRECATED) || (defined _PURPLE_SSLCONN_C_)
215 
229  PurpleSslInputFunction func,
230  PurpleSslErrorFunction error_func,
231  void *data);
232 #endif
233 
249  PurpleSslInputFunction func,
250  PurpleSslErrorFunction error_func,
251  const char *host,
252  void *data);
253 
262 void purple_ssl_input_add(PurpleSslConnection *gsc, PurpleSslInputFunction func,
263  void *data);
264 
271 
281 size_t purple_ssl_read(PurpleSslConnection *gsc, void *buffer, size_t len);
282 
292 size_t purple_ssl_write(PurpleSslConnection *gsc, const void *buffer, size_t len);
293 
305 
308 /**************************************************************************/
310 /**************************************************************************/
319 
326 
330 void purple_ssl_init(void);
331 
335 void purple_ssl_uninit(void);
336 
339 #ifdef __cplusplus
340 }
341 #endif
342 
343 #endif /* _PURPLE_SSLCONN_H_ */