changeset 14249:9c371189d7d6

[gaim-migrate @ 16931] I was wrong when I said PRPLs wouldn't need to be changed to handle cancelable ssl connections. This makes MSN not crash when canceling half-way through sign on. Try it, I dare you. committer: Tailor Script <tailor@pidgin.im>
author Mark Doliner <mark@kingant.net>
date Mon, 21 Aug 2006 02:21:51 +0000
parents 4975f529d909
children 1f963d406bb4
files libgaim/protocols/msn/nexus.c
diffstat 1 files changed, 24 insertions(+), 22 deletions(-) [+]
line wrap: on
line diff
--- a/libgaim/protocols/msn/nexus.c	Mon Aug 21 02:05:55 2006 +0000
+++ b/libgaim/protocols/msn/nexus.c	Mon Aug 21 02:21:51 2006 +0000
@@ -45,6 +45,9 @@
 void
 msn_nexus_destroy(MsnNexus *nexus)
 {
+	if (nexus->gsc)
+		gaim_ssl_close(nexus->gsc);
+
 	g_free(nexus->login_host);
 
 	g_free(nexus->login_path);
@@ -99,7 +102,7 @@
 		return;
 	else if (len <= 0) {
 		gaim_input_remove(nexus->input_handler);
-		nexus->input_handler = -1;
+		nexus->input_handler = 0;
 		/* TODO: notify of the error */
 		return;
 	}
@@ -109,7 +112,7 @@
 		return;
 
 	gaim_input_remove(nexus->input_handler);
-	nexus->input_handler = -1;
+	nexus->input_handler = 0;
 
 	g_free(nexus->write_buf);
 	nexus->write_buf = NULL;
@@ -135,6 +138,8 @@
 	nexus = data;
 	g_return_if_fail(nexus != NULL);
 
+	nexus->gsc = NULL;
+
 	session = nexus->session;
 	g_return_if_fail(session != NULL);
 
@@ -153,7 +158,8 @@
 	session = nexus->session;
 	g_return_if_fail(session != NULL);
 
-	if (nexus->input_handler == -1)
+	if (nexus->input_handler == 0)
+		//TODO: Use gaim_ssl_input_add()?
 		nexus->input_handler = gaim_input_add(nexus->gsc->fd,
 			GAIM_INPUT_READ, nexus_login_written_cb, nexus);
 
@@ -164,7 +170,7 @@
 		return;
 	else if (len < 0) {
 		gaim_input_remove(nexus->input_handler);
-		nexus->input_handler = -1;
+		nexus->input_handler = 0;
 		g_free(nexus->read_buf);
 		nexus->read_buf = NULL;
 		nexus->read_len = 0;
@@ -177,7 +183,7 @@
 		return;
 
 	gaim_input_remove(nexus->input_handler);
-	nexus->input_handler = -1;
+	nexus->input_handler = 0;
 
 	gaim_ssl_close(nexus->gsc);
 	nexus->gsc = NULL;
@@ -218,9 +224,9 @@
 		g_free(nexus->login_host);
 		nexus->login_host = g_strdup(location);
 
-		gaim_ssl_connect(session->account, nexus->login_host,
-			GAIM_SSL_DEFAULT_PORT, login_connect_cb,
-			login_error_cb, nexus);
+		nexus->gsc = gaim_ssl_connect(session->account,
+				nexus->login_host, GAIM_SSL_DEFAULT_PORT,
+				login_connect_cb, login_error_cb, nexus);
 	}
 	else if (strstr(nexus->read_buf, "HTTP/1.1 401 Unauthorized") != NULL)
 	{
@@ -320,8 +326,6 @@
 	session = nexus->session;
 	g_return_if_fail(session != NULL);
 
-	nexus->gsc = gsc;
-
 	msn_session_set_login_step(session, MSN_LOGIN_STEP_GET_COOKIE);
 
 	username =
@@ -393,7 +397,8 @@
 	char *da_login;
 	char *base, *c;
 
-	if (nexus->input_handler == -1)
+	if (nexus->input_handler == 0)
+		//TODO: Use gaim_ssl_input_add()?
 		nexus->input_handler = gaim_input_add(nexus->gsc->fd,
 			GAIM_INPUT_READ, nexus_connect_written_cb, nexus);
 
@@ -404,7 +409,7 @@
 		return;
 	else if (len < 0) {
 		gaim_input_remove(nexus->input_handler);
-		nexus->input_handler = -1;
+		nexus->input_handler = 0;
 		g_free(nexus->read_buf);
 		nexus->read_buf = NULL;
 		nexus->read_len = 0;
@@ -417,7 +422,7 @@
 		return;
 
 	gaim_input_remove(nexus->input_handler);
-	nexus->input_handler = -1;
+	nexus->input_handler = 0;
 
 	base = strstr(nexus->read_buf, "PassportURLs");
 
@@ -451,12 +456,11 @@
 	nexus->read_len = 0;
 
 	gaim_ssl_close(nexus->gsc);
-	nexus->gsc = NULL;
 
 	/* Now begin the connection to the login server. */
-	gaim_ssl_connect(nexus->session->account, nexus->login_host,
-		GAIM_SSL_DEFAULT_PORT, login_connect_cb, login_error_cb,
-		nexus);
+	nexus->gsc = gaim_ssl_connect(nexus->session->account,
+			nexus->login_host, GAIM_SSL_DEFAULT_PORT,
+			login_connect_cb, login_error_cb, nexus);
 }
 
 
@@ -477,8 +481,6 @@
 	session = nexus->session;
 	g_return_if_fail(session != NULL);
 
-	nexus->gsc = gsc;
-
 	msn_session_set_login_step(session, MSN_LOGIN_STEP_AUTH);
 
 	nexus->write_buf = g_strdup("GET /rdr/pprdr.asp\r\n\r\n");
@@ -497,7 +499,7 @@
 void
 msn_nexus_connect(MsnNexus *nexus)
 {
-	gaim_ssl_connect(nexus->session->account, "nexus.passport.com",
-		GAIM_SSL_DEFAULT_PORT, nexus_connect_cb,
-		login_error_cb, nexus);
+	nexus->gsc = gaim_ssl_connect(nexus->session->account,
+			"nexus.passport.com", GAIM_SSL_DEFAULT_PORT,
+			nexus_connect_cb, login_error_cb, nexus);
 }