changeset 20123:b2c46103a5b4

Add disconnect reasons to novell.
author Will Thompson <will.thompson@collabora.co.uk>
date Mon, 01 Oct 2007 14:54:31 +0000
parents e78b4aa457a7
children 05726ea2dd89
files libpurple/protocols/novell/novell.c
diffstat 1 files changed, 32 insertions(+), 22 deletions(-) [+]
line wrap: on
line diff
--- a/libpurple/protocols/novell/novell.c	Fri Sep 21 15:02:18 2007 +0000
+++ b/libpurple/protocols/novell/novell.c	Mon Oct 01 14:54:31 2007 +0000
@@ -120,19 +120,26 @@
 		_check_for_disconnect(user, rc);
 
 	} else {
-
+		PurpleDisconnectReason reason;
 		char *err = g_strdup_printf(_("Login failed (%s)."),
 					    nm_error_to_string (ret_code));
 
-		/* Don't attempt to auto-reconnect if our password
-		 * was invalid.
-		 */
-		if (ret_code == NMERR_AUTHENTICATION_FAILED ||
-			ret_code == NMERR_CREDENTIALS_MISSING ||
-			ret_code == NMERR_PASSWORD_INVALID) {
-			gc->wants_to_die = TRUE;
+		switch (ret_code) {
+			case NMERR_AUTHENTICATION_FAILED:
+			case NMERR_CREDENTIALS_MISSING:
+			case NMERR_PASSWORD_INVALID:
+				/* Don't attempt to auto-reconnect if our
+				 * password was invalid.
+				 */
+				gc->wants_to_die = TRUE;
+				reason = PURPLE_REASON_AUTHENTICATION_FAILED;
+				break;
+			default:
+				/* FIXME: There are other reasons login could fail */
+				reason = PURPLE_REASON_NETWORK_ERROR;
 		}
-		purple_connection_error(gc, err);
+
+		purple_connection_error_reason (gc, reason, err);
 		g_free(err);
 	}
 }
@@ -1118,8 +1125,8 @@
 
 	if (_is_disconnect_error(err)) {
 
-		purple_connection_error(gc, _("Error communicating with server."
-									" Closing connection."));
+		purple_connection_error_reason (gc, PURPLE_REASON_NETWORK_ERROR,
+			_("Error communicating with server. Closing connection."));
 		return TRUE;
 
 	}
@@ -1665,7 +1672,7 @@
 	user = gc->proto_data;
 	user->conn->ssl_conn->data = NULL;
 
-	purple_connection_error(gc, _("Unable to make SSL connection to server."));
+	purple_connection_ssl_error (gc, error);
 }
 
 static void
@@ -1688,9 +1695,9 @@
 
 		if (_is_disconnect_error(rc)) {
 
-			purple_connection_error(gc,
-								  _("Error communicating with server."
-									" Closing connection."));
+			purple_connection_error_reason (gc,
+				PURPLE_REASON_NETWORK_ERROR,
+				_("Error communicating with server. Closing connection."));
 		} else {
 			purple_debug(PURPLE_DEBUG_INFO, "novell",
 					   "Error processing event or response (%d).\n", rc);
@@ -1729,7 +1736,8 @@
 		conn->connected = TRUE;
 		purple_ssl_input_add(gsc, novell_ssl_recv_cb, gc);
 	} else {
-		purple_connection_error(gc, _("Unable to connect to server."));
+		purple_connection_error_reason (gc, PURPLE_REASON_NETWORK_ERROR,
+			_("Unable to connect to server."));
 	}
 
 	purple_connection_update_progress(gc, _("Waiting for response..."),
@@ -2009,7 +2017,8 @@
 	if (gc)
 	{
 		gc->wants_to_die = TRUE; /* we don't want to reconnect in this case */
-		purple_connection_error(gc, _("You have been logged out because you"
+		purple_connection_error_reason (gc, PURPLE_REASON_NAME_IN_USE,
+									_("You have been logged out because you"
 									" logged in at another workstation."));
 	}
 }
@@ -2164,9 +2173,9 @@
 		 */
 
 		/* ...but for now just error out with a nice message. */
-		purple_connection_error(gc, _("Unable to connect to server."
-									" Please enter the address of the server"
-									" you wish to connect to."));
+		purple_connection_error_reason (gc, PURPLE_REASON_OTHER_ERROR,
+			_("Unable to connect to server. Please enter the "
+			  "address of the server you wish to connect to."));
 		return;
 	}
 
@@ -2192,8 +2201,9 @@
 													  user->conn->addr, user->conn->port,
 													  novell_ssl_connected_cb, novell_ssl_connect_error, gc);
 		if (user->conn->ssl_conn->data == NULL) {
-			purple_connection_error(gc, _("Error."
-										" SSL support is not installed."));
+			purple_connection_error_reason (gc,
+				PURPLE_REASON_ENCRYPTION_ERROR,
+				_("Error. SSL support is not installed."));
 		}
 	}
 }