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 
00042 typedef struct _PurpleSslConnection PurpleSslConnection;
00043 
00044 typedef void (*PurpleSslInputFunction)(gpointer, PurpleSslConnection *,
00045                                      PurpleInputCondition);
00046 typedef void (*PurpleSslErrorFunction)(PurpleSslConnection *, PurpleSslErrorType,
00047                                      gpointer);
00048 
00049 struct _PurpleSslConnection
00050 {
00052     char *host;
00054     int port;
00056     void *connect_cb_data;
00058     PurpleSslInputFunction connect_cb;
00060     PurpleSslErrorFunction error_cb;
00062     void *recv_cb_data;
00064     PurpleSslInputFunction recv_cb;
00065 
00067     int fd;
00070     guint inpa;
00072     PurpleProxyConnectData *connect_data;
00073 
00075     void *private_data;
00076 
00078     PurpleCertificateVerifier *verifier;
00079 };
00080 
00087 typedef struct
00088 {
00093     gboolean (*init)(void);
00097     void (*uninit)(void);
00102     void (*connectfunc)(PurpleSslConnection *gsc);
00107     void (*close)(PurpleSslConnection *gsc);
00116     size_t (*read)(PurpleSslConnection *gsc, void *data, size_t len);
00125     size_t (*write)(PurpleSslConnection *gsc, const void *data, size_t len);
00135     GList * (* get_peer_certificates)(PurpleSslConnection * gsc);
00136     
00137     void (*_purple_reserved2)(void);
00138     void (*_purple_reserved3)(void);
00139     void (*_purple_reserved4)(void);
00140 } PurpleSslOps;
00141 
00142 #ifdef __cplusplus
00143 extern "C" {
00144 #endif
00145 
00146 /**************************************************************************/
00148 /**************************************************************************/
00156 gboolean purple_ssl_is_supported(void);
00157 
00164 const gchar * purple_ssl_strerror(PurpleSslErrorType error);
00165 
00183 PurpleSslConnection *purple_ssl_connect(PurpleAccount *account, const char *host,
00184                                     int port, PurpleSslInputFunction func,
00185                                     PurpleSslErrorFunction error_func,
00186                                     void *data);
00187 
00188 #ifndef PURPLE_DISABLE_DEPRECATED
00189 
00202 PurpleSslConnection *purple_ssl_connect_fd(PurpleAccount *account, int fd,
00203                                        PurpleSslInputFunction func,
00204                                        PurpleSslErrorFunction error_func,
00205                                        void *data);
00206 #endif
00207 
00222 PurpleSslConnection *purple_ssl_connect_with_host_fd(PurpleAccount *account, int fd,
00223                                            PurpleSslInputFunction func,
00224                                            PurpleSslErrorFunction error_func,
00225                                            const char *host,
00226                                            void *data);
00227 
00236 void purple_ssl_input_add(PurpleSslConnection *gsc, PurpleSslInputFunction func,
00237                         void *data);
00238 
00244 void purple_ssl_close(PurpleSslConnection *gsc);
00245 
00255 size_t purple_ssl_read(PurpleSslConnection *gsc, void *buffer, size_t len);
00256 
00266 size_t purple_ssl_write(PurpleSslConnection *gsc, const void *buffer, size_t len);
00267 
00278 GList * purple_ssl_get_peer_certificates(PurpleSslConnection *gsc);
00279 
00282 /**************************************************************************/
00284 /**************************************************************************/
00292 void purple_ssl_set_ops(PurpleSslOps *ops);
00293 
00299 PurpleSslOps *purple_ssl_get_ops(void);
00300 
00304 void purple_ssl_init(void);
00305 
00309 void purple_ssl_uninit(void);
00310 
00313 #ifdef __cplusplus
00314 }
00315 #endif
00316 
00317 #endif /* _PURPLE_SSLCONN_H_ */

Generated on Sat Nov 8 08:07:19 2008 for pidgin by  doxygen 1.5.5