sslconn.h

Go to the documentation of this file.
00001
00006 /* purple
00007  *
00008  * Purple is the legal property of its developers, whose names are too numerous
00009  * to list here.  Please refer to the COPYRIGHT file distributed with this
00010  * source distribution.
00011  *
00012  * This program is free software; you can redistribute it and/or modify
00013  * it under the terms of the GNU General Public License as published by
00014  * the Free Software Foundation; either version 2 of the License, or
00015  * (at your option) any later version.
00016  *
00017  * This program is distributed in the hope that it will be useful,
00018  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00019  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00020  * GNU General Public License for more details.
00021  *
00022  * You should have received a copy of the GNU General Public License
00023  * along with this program; if not, write to the Free Software
00024  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02111-1301  USA
00025  */
00026 #ifndef _PURPLE_SSLCONN_H_
00027 #define _PURPLE_SSLCONN_H_
00028 
00030 typedef enum
00031 {
00032     PURPLE_SSL_HANDSHAKE_FAILED = 1,
00033     PURPLE_SSL_CONNECT_FAILED = 2,
00034     PURPLE_SSL_CERTIFICATE_INVALID = 3
00035 } PurpleSslErrorType;
00036
00037 #include "certificate.h"
00038 #include "proxy.h"
00039
00040 #define PURPLE_SSL_DEFAULT_PORT 443
00041 
00043 typedef struct _PurpleSslConnection PurpleSslConnection;
00044
00045 typedef void (*PurpleSslInputFunction)(gpointer, PurpleSslConnection *,
00046                                      PurpleInputCondition);
00047 typedef void (*PurpleSslErrorFunction)(PurpleSslConnection *, PurpleSslErrorType,
00048                                      gpointer);
00049
00050 struct _PurpleSslConnection
00051 {
00053     char *host;
00055     int port;
00057     void *connect_cb_data;
00059     PurpleSslInputFunction connect_cb;
00061     PurpleSslErrorFunction error_cb;
00063     void *recv_cb_data;
00065     PurpleSslInputFunction recv_cb;
00066
00068     int fd;
00071     guint inpa;
00073     PurpleProxyConnectData *connect_data;
00074
00076     void *private_data;
00077
00079     PurpleCertificateVerifier *verifier;
00080 };
00081
00088 typedef struct
00089 {
00094     gboolean (*init)(void);
00098     void (*uninit)(void);
00103     void (*connectfunc)(PurpleSslConnection *gsc);
00108     void (*close)(PurpleSslConnection *gsc);
00117     size_t (*read)(PurpleSslConnection *gsc, void *data, size_t len);
00126     size_t (*write)(PurpleSslConnection *gsc, const void *data, size_t len);
00136     GList * (* get_peer_certificates)(PurpleSslConnection * gsc);
00137
00138     void (*_purple_reserved2)(void);
00139     void (*_purple_reserved3)(void);
00140     void (*_purple_reserved4)(void);
00141 } PurpleSslOps;
00142
00143 #ifdef __cplusplus
00144 extern "C" {
00145 #endif
00146 
00147 /**************************************************************************/
00149 /**************************************************************************/
00157 gboolean purple_ssl_is_supported(void);
00158
00165 const gchar * purple_ssl_strerror(PurpleSslErrorType error);
00166
00184 PurpleSslConnection *purple_ssl_connect(PurpleAccount *account, const char *host,
00185                                     int port, PurpleSslInputFunction func,
00186                                     PurpleSslErrorFunction error_func,
00187                                     void *data);
00188
00208 PurpleSslConnection *purple_ssl_connect_with_ssl_cn(PurpleAccount *account, const char *host,
00209                                     int port, PurpleSslInputFunction func,
00210                                     PurpleSslErrorFunction error_func,
00211                                     const char *ssl_host,
00212                                     void *data);
00213
00214 #if !(defined PURPLE_DISABLE_DEPRECATED) || (defined _PURPLE_SSLCONN_C_)
00215 
00228 PurpleSslConnection *purple_ssl_connect_fd(PurpleAccount *account, int fd,
00229                                        PurpleSslInputFunction func,
00230                                        PurpleSslErrorFunction error_func,
00231                                        void *data);
00232 #endif
00233 
00248 PurpleSslConnection *purple_ssl_connect_with_host_fd(PurpleAccount *account, int fd,
00249                                            PurpleSslInputFunction func,
00250                                            PurpleSslErrorFunction error_func,
00251                                            const char *host,
00252                                            void *data);
00253
00262 void purple_ssl_input_add(PurpleSslConnection *gsc, PurpleSslInputFunction func,
00263                         void *data);
00264
00270 void purple_ssl_close(PurpleSslConnection *gsc);
00271
00281 size_t purple_ssl_read(PurpleSslConnection *gsc, void *buffer, size_t len);
00282
00292 size_t purple_ssl_write(PurpleSslConnection *gsc, const void *buffer, size_t len);
00293
00304 GList * purple_ssl_get_peer_certificates(PurpleSslConnection *gsc);
00305
00308 /**************************************************************************/
00310 /**************************************************************************/
00318 void purple_ssl_set_ops(PurpleSslOps *ops);
00319
00325 PurpleSslOps *purple_ssl_get_ops(void);
00326
00330 void purple_ssl_init(void);
00331
00335 void purple_ssl_uninit(void);
00336
00339 #ifdef __cplusplus
00340 }
00341 #endif
00342 
00343 #endif /* _PURPLE_SSLCONN_H_ */
All information, including names and email addresses, entered onto this website or sent to mailing lists affiliated with this website will be public. Do not post confidential information, especially passwords!