changeset 20778:8174f6999308

Sprinkle gc->wants_to_die = TRUE liberally around connection errors that really ought to have been setting it already so that it is always set when a disconnection reason is fatal. In a couple of other places, fix the reason to be more accurate and not be fatal.
author Will Thompson <will.thompson@collabora.co.uk>
date Fri, 05 Oct 2007 18:33:27 +0000
parents c40416c4eca6
children 0f607b50279c
files libpurple/protocols/irc/irc.c libpurple/protocols/irc/parse.c libpurple/protocols/jabber/auth.c libpurple/protocols/jabber/jabber.c libpurple/protocols/jabber/parser.c libpurple/protocols/novell/novell.c libpurple/protocols/oscar/oscar.c libpurple/protocols/sametime/sametime.c libpurple/protocols/silc/silc.c
diffstat 9 files changed, 31 insertions(+), 9 deletions(-) [+]
line wrap: on
line diff
--- a/libpurple/protocols/irc/irc.c	Fri Oct 05 16:50:54 2007 +0000
+++ b/libpurple/protocols/irc/irc.c	Fri Oct 05 18:33:27 2007 +0000
@@ -297,6 +297,7 @@
 	gc->flags |= PURPLE_CONNECTION_NO_NEWLINES;
 
 	if (strpbrk(username, " \t\v\r\n") != NULL) {
+		gc->wants_to_die = TRUE;
 		purple_connection_error_reason (gc, PURPLE_REASON_INVALID_SETTINGS,
 			_("IRC nicks may not contain whitespace"));
 		return;
@@ -327,6 +328,7 @@
 					purple_account_get_int(account, "port", IRC_DEFAULT_SSL_PORT),
 					irc_login_cb_ssl, irc_ssl_connect_failure, gc);
 		} else {
+			gc->wants_to_die = TRUE;
 			purple_connection_error_reason (gc, PURPLE_REASON_ENCRYPTION_ERROR,
 				_("SSL support unavailable"));
 			return;
--- a/libpurple/protocols/irc/parse.c	Fri Oct 05 16:50:54 2007 +0000
+++ b/libpurple/protocols/irc/parse.c	Fri Oct 05 18:33:27 2007 +0000
@@ -576,11 +576,11 @@
 	} else if (!strncmp(input, "ERROR ", 6)) {
 		if (g_utf8_validate(input, -1, NULL)) {
 			char *tmp = g_strdup_printf("%s\n%s", _("Disconnected."), input);
-			purple_connection_error_reason (gc, PURPLE_REASON_OTHER_ERROR, tmp);
+			purple_connection_error_reason (gc, PURPLE_REASON_NETWORK_ERROR, tmp);
 			g_free(tmp);
 		} else
 			purple_connection_error_reason (gc,
-				PURPLE_REASON_OTHER_ERROR, _("Disconnected."));
+				PURPLE_REASON_NETWORK_ERROR, _("Disconnected."));
 		return;
 	}
 
--- a/libpurple/protocols/jabber/auth.c	Fri Oct 05 16:50:54 2007 +0000
+++ b/libpurple/protocols/jabber/auth.c	Fri Oct 05 18:33:27 2007 +0000
@@ -50,6 +50,7 @@
 					"<starttls xmlns='urn:ietf:params:xml:ns:xmpp-tls'/>", -1);
 			return TRUE;
 		} else if(xmlnode_get_child(starttls, "required")) {
+			js->gc->wants_to_die = TRUE;
 			purple_connection_error_reason (js->gc, PURPLE_REASON_ENCRYPTION_ERROR,
 				_("Server requires TLS/SSL for login.  No TLS/SSL support found."));
 			return TRUE;
@@ -114,6 +115,7 @@
 
 static void disallow_plaintext_auth(PurpleAccount *account)
 {
+	account->gc->wants_to_die = TRUE;
 	purple_connection_error_reason (account->gc, PURPLE_REASON_ENCRYPTION_ERROR,
 		_("Server requires plaintext authentication over an unencrypted stream"));
 }
@@ -542,17 +544,19 @@
 		char *msg = jabber_parse_error(js, packet);
 		xmlnode *error;
 		const char *err_code;
+		PurpleDisconnectReason reason = PURPLE_REASON_NETWORK_ERROR;
 
 		if((error = xmlnode_get_child(packet, "error")) &&
 					(err_code = xmlnode_get_attrib(error, "code")) &&
 					!strcmp(err_code, "401")) {
 			js->gc->wants_to_die = TRUE;
+			reason = PURPLE_REASON_AUTHENTICATION_FAILED;
 			/* Clear the pasword if it isn't being saved */
 			if (!purple_account_get_remember_password(js->gc->account))
 				purple_account_set_password(js->gc->account, NULL);
 		}
 
-		purple_connection_error_reason (js->gc, PURPLE_REASON_OTHER_ERROR, msg);
+		purple_connection_error_reason (js->gc, reason, msg);
 		g_free(msg);
 	}
 }
@@ -570,7 +574,7 @@
 		return;
 	} else if(!strcmp(type, "error")) {
 		char *msg = jabber_parse_error(js, packet);
-		purple_connection_error_reason (js->gc, PURPLE_REASON_AUTHENTICATION_FAILED,
+		purple_connection_error_reason (js->gc, PURPLE_REASON_NETWORK_ERROR,
 			msg);
 		g_free(msg);
 	} else if(!strcmp(type, "result")) {
@@ -977,7 +981,7 @@
 		purple_connection_error_reason (js->gc, PURPLE_REASON_NETWORK_ERROR,
 			_("Invalid response from server."));
 	} else {
-		purple_connection_error_reason (js->gc, PURPLE_REASON_AUTHENTICATION_FAILED,
+		purple_connection_error_reason (js->gc, PURPLE_REASON_NETWORK_ERROR,
 			msg);
 		g_free(msg);
 	}
--- a/libpurple/protocols/jabber/jabber.c	Fri Oct 05 16:50:54 2007 +0000
+++ b/libpurple/protocols/jabber/jabber.c	Fri Oct 05 18:33:27 2007 +0000
@@ -588,12 +588,14 @@
 	js->old_length = -1;
 
 	if(!js->user) {
+		gc->wants_to_die = TRUE;
 		purple_connection_error_reason (gc, PURPLE_REASON_INVALID_SETTINGS,
 			_("Invalid XMPP ID"));
 		return;
 	}
 	
 	if (!js->user->domain || *(js->user->domain) == '\0') {
+		gc->wants_to_die = TRUE;
 		purple_connection_error_reason (gc, PURPLE_REASON_INVALID_SETTINGS,
 			_("Invalid XMPP ID. Domain must be set."));
 		return;
@@ -625,6 +627,7 @@
 					purple_account_get_int(account, "port", 5223), jabber_login_callback_ssl,
 					jabber_ssl_connect_failure, js->gc);
 		} else {
+			js->gc->wants_to_die = TRUE;
 			purple_connection_error_reason (js->gc, PURPLE_REASON_ENCRYPTION_ERROR,
 				_("SSL support unavailable"));
 		}
@@ -1079,6 +1082,7 @@
 	js->old_length = -1;
 
 	if(!js->user) {
+		gc->wants_to_die = TRUE;
 		purple_connection_error_reason (gc, PURPLE_REASON_INVALID_SETTINGS,
 			_("Invalid XMPP ID"));
 		return;
@@ -1112,6 +1116,7 @@
 					purple_account_get_int(account, "port", 5222),
 					jabber_login_callback_ssl, jabber_ssl_connect_failure, gc);
 		} else {
+			gc->wants_to_die = TRUE;
 			purple_connection_error_reason (gc, PURPLE_REASON_ENCRYPTION_ERROR,
 				_("SSL support unavailable"));
 		}
--- a/libpurple/protocols/jabber/parser.c	Fri Oct 05 16:50:54 2007 +0000
+++ b/libpurple/protocols/jabber/parser.c	Fri Oct 05 18:33:27 2007 +0000
@@ -193,7 +193,7 @@
 		js->context = xmlCreatePushParserCtxt(&jabber_parser_libxml, js, buf, len, NULL);
 		xmlParseChunk(js->context, "", 0, 0);
 	} else if (xmlParseChunk(js->context, buf, len, 0) < 0) {
-		purple_connection_error_reason (js->gc, PURPLE_REASON_OTHER_ERROR,
+		purple_connection_error_reason (js->gc, PURPLE_REASON_NETWORK_ERROR,
 			_("XML Parse error"));
 	}
 }
--- a/libpurple/protocols/novell/novell.c	Fri Oct 05 16:50:54 2007 +0000
+++ b/libpurple/protocols/novell/novell.c	Fri Oct 05 18:33:27 2007 +0000
@@ -2178,7 +2178,8 @@
 		 */
 
 		/* ...but for now just error out with a nice message. */
-		purple_connection_error_reason (gc, PURPLE_REASON_OTHER_ERROR,
+		gc->wants_to_die = TRUE;
+		purple_connection_error_reason (gc, PURPLE_REASON_INVALID_SETTINGS,
 			_("Unable to connect to server. Please enter the "
 			  "address of the server you wish to connect to."));
 		return;
@@ -2206,6 +2207,7 @@
 													  user->conn->addr, user->conn->port,
 													  novell_ssl_connected_cb, novell_ssl_connect_error, gc);
 		if (user->conn->ssl_conn->data == NULL) {
+			gc->wants_to_die = TRUE;
 			purple_connection_error_reason (gc,
 				PURPLE_REASON_ENCRYPTION_ERROR,
 				_("Error. SSL support is not installed."));
--- a/libpurple/protocols/oscar/oscar.c	Fri Oct 05 16:50:54 2007 +0000
+++ b/libpurple/protocols/oscar/oscar.c	Fri Oct 05 18:33:27 2007 +0000
@@ -1259,7 +1259,7 @@
 		gchar *buf;
 		buf = g_strdup_printf(_("Unable to login: Could not sign on as %s because the screen name is invalid.  Screen names must be a valid email address, or start with a letter and contain only letters, numbers and spaces, or contain only numbers."), purple_account_get_username(account));
 		gc->wants_to_die = TRUE;
-		purple_connection_error_reason(gc, PURPLE_REASON_AUTHENTICATION_FAILED, buf);
+		purple_connection_error_reason(gc, PURPLE_REASON_INVALID_SETTINGS, buf);
 		g_free(buf);
 	}
 
@@ -1378,7 +1378,8 @@
 			purple_connection_error_reason(gc, PURPLE_REASON_OTHER_ERROR, _("You have been connecting and disconnecting too frequently. Wait ten minutes and try again. If you continue to try, you will need to wait even longer."));
 			break;
 		default:
-			purple_connection_error_reason(gc, PURPLE_REASON_NETWORK_ERROR, _("Authentication failed"));
+			gc->wants_to_die = TRUE;
+			purple_connection_error_reason(gc, PURPLE_REASON_AUTHENTICATION_FAILED, _("Authentication failed"));
 			break;
 		}
 		purple_debug_info("oscar", "Login Error Code 0x%04hx\n", info->errorcode);
--- a/libpurple/protocols/sametime/sametime.c	Fri Oct 05 16:50:54 2007 +0000
+++ b/libpurple/protocols/sametime/sametime.c	Fri Oct 05 18:33:27 2007 +0000
@@ -1563,12 +1563,14 @@
       case INCORRECT_LOGIN:
       case USER_UNREGISTERED:
       case GUEST_IN_USE:
+        gc->wants_to_die = TRUE;
         reason = PURPLE_REASON_AUTHENTICATION_FAILED;
         break;
 
       case ENCRYPT_MISMATCH:
       case ERR_ENCRYPT_NO_SUPPORT:
       case ERR_NO_COMMON_ENCRYPT:
+        gc->wants_to_die = TRUE;
         reason = PURPLE_REASON_ENCRYPTION_ERROR;
         break;
 
@@ -1578,6 +1580,7 @@
 
       case MULTI_SERVER_LOGIN:
       case MULTI_SERVER_LOGIN2:
+        gc->wants_to_die = TRUE;
         reason = PURPLE_REASON_NAME_IN_USE;
         break;
 
@@ -3646,6 +3649,7 @@
 
 static void prompt_host_cancel_cb(PurpleConnection *gc) {
   const char *msg = _("No Sametime Community Server specified");
+  gc->wants_to_die = TRUE;
   purple_connection_error_reason(gc, PURPLE_REASON_INVALID_SETTINGS, msg);
 }
 
--- a/libpurple/protocols/silc/silc.c	Fri Oct 05 16:50:54 2007 +0000
+++ b/libpurple/protocols/silc/silc.c	Fri Oct 05 18:33:27 2007 +0000
@@ -229,16 +229,19 @@
 		break;
 
 	case SILC_CLIENT_CONN_ERROR_KE:
+		gc->wants_to_die = TRUE;
 		purple_connection_error_reason(gc, PURPLE_REASON_ENCRYPTION_ERROR,
 		                             _("Key Exchange failed"));
 		break;
 
 	case SILC_CLIENT_CONN_ERROR_AUTH:
+		gc->wants_to_die = TRUE;
 		purple_connection_error_reason(gc, PURPLE_REASON_AUTHENTICATION_FAILED,
 		                             _("Authentication failed"));
 		break;
 
 	case SILC_CLIENT_CONN_ERROR_RESUME:
+		gc->wants_to_die = TRUE;
 		purple_connection_error_reason(gc, PURPLE_REASON_OTHER_ERROR,
 		                             _("Resuming detached session failed. "
 		                               "Press Reconnect to create new connection."));
@@ -357,6 +360,7 @@
 				(char *)purple_account_get_string(account, "private-key", prd),
 				(gc->password == NULL) ? "" : gc->password,
 				&sg->public_key, &sg->private_key)) {
+		gc->wants_to_die = TRUE;
 		purple_connection_error_reason(gc, PURPLE_REASON_OTHER_ERROR,
 		                             _("Could not load SILC key pair"));
 		gc->proto_data = NULL;