Make SILC errors disconnect the account and reduce unwanted notify dialogs.

Wed, 12 Mar 2008 01:37:15 +0000

author
Stu Tomlinson <nosnilmot@pidgin.im>
date
Wed, 12 Mar 2008 01:37:15 +0000
changeset 22600
b5aca71664d0
parent 22599
7987eb3eb3e6
child 22601
cfab23f24e50

Make SILC errors disconnect the account and reduce unwanted notify dialogs.
This might be improvable, but seems to work for me.

libpurple/protocols/silc/ops.c file | annotate | diff | comparison | revisions
--- a/libpurple/protocols/silc/ops.c	Wed Mar 12 01:35:40 2008 +0000
+++ b/libpurple/protocols/silc/ops.c	Wed Mar 12 01:37:15 2008 +0000
@@ -48,17 +48,32 @@
 void silc_say(SilcClient client, SilcClientConnection conn,
 	      SilcClientMessageType type, char *msg, ...)
 {
-	if (type == SILC_CLIENT_MESSAGE_ERROR) {
-		char tmp[256];
-		va_list va;
+	char tmp[256];
+	va_list va;
+	PurpleConnection *gc = NULL;
+	PurpleConnectionError reason = PURPLE_CONNECTION_ERROR_NETWORK_ERROR;
 
-		va_start(va, msg);
-		silc_vsnprintf(tmp, sizeof(tmp), msg, va);
-		purple_notify_error(NULL, _("Error"), _("Error occurred"), tmp);
+	va_start(va, msg);
+	silc_vsnprintf(tmp, sizeof(tmp), msg, va);
+	va_end(va);
 
-		va_end(va);
+	if (type != SILC_CLIENT_MESSAGE_ERROR) {
+		purple_debug_misc("silc", "silc_say (%d) %s\n", type, tmp);
 		return;
 	}
+
+	purple_debug_error("silc", "silc_say error: %s\n", tmp);
+
+	if (!strcmp(tmp, "Authentication failed"))
+		reason = PURPLE_CONNECTION_ERROR_AUTHENTICATION_FAILED;
+
+	if (client != NULL)
+		gc = client->application;
+
+	if (gc != NULL)
+		purple_connection_error_reason (gc, reason, tmp);
+	else
+		purple_notify_error(NULL, _("Error"), _("Error occurred"), tmp);
 }
 
 /* Processes incoming MIME message.  Can be private message or channel

mercurial