From: Christian H. <ch...@us...> - 2003-10-15 06:32:17
|
Update of /cvsroot/gaim/gaim/src In directory sc8-pr-cvs1:/tmp/cvs-serv25771/src Modified Files: sslconn.c sslconn.h Log Message: Added a parameter to gaim_ssl_connect() to specify an optional error callback. MSN takes advantage of it, but since I can't reproduce the errors here, I'm not positive it works. It should though! Famous last words. Index: sslconn.c =================================================================== RCS file: /cvsroot/gaim/gaim/src/sslconn.c,v retrieving revision 1.9 retrieving revision 1.10 diff -u -d -p -r1.9 -r1.10 --- sslconn.c 29 Sep 2003 20:31:20 -0000 1.9 +++ sslconn.c 15 Oct 2003 06:32:13 -0000 1.10 @@ -63,7 +63,8 @@ gaim_ssl_is_supported(void) GaimSslConnection * gaim_ssl_connect(GaimAccount *account, const char *host, int port, - GaimSslInputFunction func, void *data) + GaimSslInputFunction func, GaimSslErrorFunction error_func, + void *data) { GaimSslConnection *gsc; GaimSslOps *ops; @@ -87,10 +88,11 @@ gaim_ssl_connect(GaimAccount *account, c gsc = g_new0(GaimSslConnection, 1); - gsc->host = g_strdup(host); - gsc->port = port; - gsc->connect_cb_data = data; - gsc->connect_cb = func; + gsc->host = g_strdup(host); + gsc->port = port; + gsc->connect_cb_data = data; + gsc->connect_cb = func; + gsc->error_cb = error_func; i = gaim_proxy_connect(account, host, port, ops->connect_cb, gsc); @@ -114,7 +116,8 @@ recv_cb(gpointer data, gint source, Gaim } void -gaim_ssl_input_add(GaimSslConnection *gsc, GaimSslInputFunction func, void *data) +gaim_ssl_input_add(GaimSslConnection *gsc, GaimSslInputFunction func, + void *data) { GaimSslOps *ops; @@ -124,13 +127,15 @@ gaim_ssl_input_add(GaimSslConnection *gs ops = gaim_ssl_get_ops(); gsc->recv_cb_data = data; - gsc->recv_cb = func; + gsc->recv_cb = func; + gsc->inpa = gaim_input_add(gsc->fd, GAIM_INPUT_READ, recv_cb, gsc); } GaimSslConnection * gaim_ssl_connect_fd(GaimAccount *account, int fd, - GaimSslInputFunction func, void *data) + GaimSslInputFunction func, + GaimSslErrorFunction error_func, void *data) { GaimSslConnection *gsc; GaimSslOps *ops; @@ -152,8 +157,9 @@ gaim_ssl_connect_fd(GaimAccount *account gsc = g_new0(GaimSslConnection, 1); - gsc->connect_cb_data = data; - gsc->connect_cb = func; + gsc->connect_cb_data = data; + gsc->connect_cb = func; + gsc->error_cb = error_func; ops->connect_cb(gsc, fd, GAIM_INPUT_READ); Index: sslconn.h =================================================================== RCS file: /cvsroot/gaim/gaim/src/sslconn.h,v retrieving revision 1.7 retrieving revision 1.8 diff -u -d -p -r1.7 -r1.8 --- sslconn.h 7 Sep 2003 21:00:34 -0000 1.7 +++ sslconn.h 15 Oct 2003 06:32:13 -0000 1.8 @@ -27,10 +27,18 @@ #define GAIM_SSL_DEFAULT_PORT 443 +typedef enum +{ + GAIM_SSL_HANDSHAKE_FAILED = 1 + +} GaimSslErrorType; + typedef struct _GaimSslConnection GaimSslConnection; typedef void (*GaimSslInputFunction)(gpointer, GaimSslConnection *, GaimInputCondition); +typedef void (*GaimSslErrorFunction)(GaimSslConnection *, GaimSslErrorType, + gpointer); struct _GaimSslConnection { @@ -38,6 +46,7 @@ struct _GaimSslConnection int port; void *connect_cb_data; GaimSslInputFunction connect_cb; + GaimSslErrorFunction error_cb; void *recv_cb_data; GaimSslInputFunction recv_cb; @@ -82,19 +91,37 @@ gboolean gaim_ssl_is_supported(void); /** * Makes a SSL connection to the specified host and port. * - * @param account The account making the connection. - * @param host The destination host. - * @param port The destination port. - * @param func The SSL input handler function. - * @param data User-defined data. + * @param account The account making the connection. + * @param host The destination host. + * @param port The destination port. + * @param func The SSL input handler function. + * @param error_func The SSL error handler function. + * @param data User-defined data. * * @return The SSL connection handle. */ GaimSslConnection *gaim_ssl_connect(GaimAccount *account, const char *host, int port, GaimSslInputFunction func, + GaimSslErrorFunction error_func, void *data); /** + * Makes a SSL connection using an already open file descriptor. + * + * @param account The account making the connection. + * @param fd The file descriptor. + * @param func The SSL input handler function. + * @param error_func The SSL error handler function. + * @param data User-defined data. + * + * @return The SSL connection handle. + */ +GaimSslConnection *gaim_ssl_connect_fd(GaimAccount *account, int fd, + GaimSslInputFunction func, + GaimSslErrorFunction error_func, + void *data); + +/** * Adds an input watcher for the specified SSL connection. * * @param gsc The SSL connection handle. @@ -102,20 +129,7 @@ GaimSslConnection *gaim_ssl_connect(Gaim * @param data User-defined data. */ void gaim_ssl_input_add(GaimSslConnection *gsc, GaimSslInputFunction func, - void *data); - -/** - * Makes a SSL connection using an already open file descriptor. - * - * @param account The account making the connection. - * @param fd The file descriptor. - * @param func The SSL input handler function. - * @param data User-defined data. - * - * @return The SSL connection handle. - */ -GaimSslConnection *gaim_ssl_connect_fd(GaimAccount *account, int fd, - GaimSslInputFunction func, void *data); + void *data); /** * Closes a SSL connection. |