changeset 14250:1f963d406bb4

[gaim-migrate @ 16932] More sslconn improvements committer: Tailor Script <tailor@pidgin.im>
author Mark Doliner <mark@kingant.net>
date Mon, 21 Aug 2006 02:42:14 +0000
parents 9c371189d7d6
children 0fdd320a0235
files libgaim/protocols/jabber/jabber.c libgaim/protocols/novell/novell.c libgaim/sslconn.h
diffstat 3 files changed, 21 insertions(+), 17 deletions(-) [+]
line wrap: on
line diff
--- a/libgaim/protocols/jabber/jabber.c	Mon Aug 21 02:21:51 2006 +0000
+++ b/libgaim/protocols/jabber/jabber.c	Mon Aug 21 02:42:14 2006 +0000
@@ -407,13 +407,6 @@
 	GaimConnection *gc = data;
 	JabberStream *js = gc->proto_data;
 
-	if(!g_list_find(gaim_connections_get_all(), gc)) {
-		gaim_ssl_close(gsc);
-		return;
-	}
-
-	js->gsc = gsc;
-
 	if(js->state == JABBER_STREAM_CONNECTING)
 		jabber_send_raw(js, "<?xml version='1.0' ?>", -1);
 	jabber_stream_set_state(js, JABBER_STREAM_INITIALIZING);
@@ -450,6 +443,8 @@
 	GaimConnection *gc = data;
 	JabberStream *js = gc->proto_data;
 
+	js->gsc = NULL;
+
 	switch(error) {
 		case GAIM_SSL_CONNECT_FAILED:
 			gaim_connection_error(gc, _("Connection Failed"));
@@ -458,8 +453,6 @@
 			gaim_connection_error(gc, _("SSL Handshake Failed"));
 			break;
 	}
-
-	js->gsc = NULL;
 }
 
 static void tls_init(JabberStream *js)
--- a/libgaim/protocols/novell/novell.c	Mon Aug 21 02:21:51 2006 +0000
+++ b/libgaim/protocols/novell/novell.c	Mon Aug 21 02:42:14 2006 +0000
@@ -1663,8 +1663,14 @@
 novell_ssl_connect_error(GaimSslConnection * gsc,
 						 GaimSslErrorType error, gpointer data)
 {
-	gaim_connection_error((GaimConnection *)data,
-						  _("Unable to make SSL connection to server."));
+	GaimConnection *gc;
+	NMUser *user;
+
+	gc = data;
+	user = gc->proto_data;
+	user->conn->ssl_conn->data = NULL;
+
+	gaim_connection_error(gc, _("Unable to make SSL connection to server."));
 }
 
 static void
@@ -1717,7 +1723,6 @@
 		return;
 
 	conn->ssl_conn = g_new0(NMSSLConn, 1);
-	conn->ssl_conn->data = gsc;
 	conn->ssl_conn->read = (nm_ssl_read_cb) gaim_ssl_read;
 	conn->ssl_conn->write = (nm_ssl_write_cb) gaim_ssl_write;
 
@@ -2182,9 +2187,10 @@
 										1, NOVELL_CONNECT_STEPS);
 
 		user->conn->use_ssl = TRUE;
-		if (gaim_ssl_connect(user->client_data, user->conn->addr,
-							 user->conn->port, novell_ssl_connected_cb,
-							 novell_ssl_connect_error, gc) == NULL) {
+		user->conn->ssl_conn->data = gaim_ssl_connect(user->client_data,
+				user->conn->addr, user->conn->port,
+				novell_ssl_connected_cb, novell_ssl_connect_error, gc);
+		if (user->conn->ssl_conn->data == NULL) {
 			gaim_connection_error(gc, _("Error."
 										" SSL support is not installed."));
 		}
--- a/libgaim/sslconn.h	Mon Aug 21 02:21:51 2006 +0000
+++ b/libgaim/sslconn.h	Mon Aug 21 02:42:14 2006 +0000
@@ -92,13 +92,18 @@
 gboolean gaim_ssl_is_supported(void);
 
 /**
- * Makes a SSL connection to the specified host and port.
+ * Makes a SSL connection to the specified host and port.  The caller
+ * should keep track of the returned value and use it to cancel the
+ * connection, if needed.
  *
  * @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 error_func The SSL error handler function.  This function
+ *                   should NOT call gaim_ssl_close().  In the event
+ *                   of an error the GaimSslConnection will be
+ *                   destroyed for you.
  * @param data       User-defined data.
  *
  * @return The SSL connection handle.