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 
00189 #if !(defined PURPLE_DISABLE_DEPRECATED) || (defined _PURPLE_SSLCONN_C_)
00190 
00203 PurpleSslConnection *purple_ssl_connect_fd(PurpleAccount *account, int fd,
00204                                        PurpleSslInputFunction func,
00205                                        PurpleSslErrorFunction error_func,
00206                                        void *data);
00207 #endif
00208 
00223 PurpleSslConnection *purple_ssl_connect_with_host_fd(PurpleAccount *account, int fd,
00224                                            PurpleSslInputFunction func,
00225                                            PurpleSslErrorFunction error_func,
00226                                            const char *host,
00227                                            void *data);
00228 
00237 void purple_ssl_input_add(PurpleSslConnection *gsc, PurpleSslInputFunction func,
00238                         void *data);
00239 
00245 void purple_ssl_close(PurpleSslConnection *gsc);
00246 
00256 size_t purple_ssl_read(PurpleSslConnection *gsc, void *buffer, size_t len);
00257 
00267 size_t purple_ssl_write(PurpleSslConnection *gsc, const void *buffer, size_t len);
00268 
00279 GList * purple_ssl_get_peer_certificates(PurpleSslConnection *gsc);
00280 
00283 /**************************************************************************/
00285 /**************************************************************************/
00293 void purple_ssl_set_ops(PurpleSslOps *ops);
00294 
00300 PurpleSslOps *purple_ssl_get_ops(void);
00301 
00305 void purple_ssl_init(void);
00306 
00310 void purple_ssl_uninit(void);
00311 
00314 #ifdef __cplusplus
00315 }
00316 #endif
00317 
00318 #endif /* _PURPLE_SSLCONN_H_ */