Index: protocols/jabber/io.c
===================================================================
--- protocols/jabber/io.c	(revision cd4723c257f9f7bd8d4a46c6562f93c2aefc3dbb)
+++ protocols/jabber/io.c	(revision c2fb38096ea4e75a680e57e103d4a4986aa84c75)
@@ -118,5 +118,5 @@
 		
 		imc_error( ic, "Short write() to server" );
-		imc_logout( ic );
+		imc_logout( ic, TRUE );
 		return FALSE;
 	}
@@ -161,5 +161,5 @@
 		{
 			imc_error( ic, "XML stream error" );
-			imc_logout( ic );
+			imc_logout( ic, TRUE );
 			return FALSE;
 		}
@@ -205,5 +205,5 @@
 						imc_error( ic, "TLS is turned on for this "
 						          "account, but is not supported by this server" );
-						imc_logout( ic );
+						imc_logout( ic, FALSE );
 						return FALSE;
 					}
@@ -217,5 +217,5 @@
 			{
 				imc_error( ic, "XML stream error" );
-				imc_logout( ic );
+				imc_logout( ic, TRUE );
 				return FALSE;
 			}
@@ -228,5 +228,5 @@
 		
 		imc_error( ic, "Error while reading from server" );
-		imc_logout( ic );
+		imc_logout( ic, TRUE );
 		return FALSE;
 	}
@@ -243,5 +243,5 @@
 	{
 		imc_error( ic, "Could not connect to server" );
-		imc_logout( ic );
+		imc_logout( ic, TRUE );
 		return FALSE;
 	}
@@ -264,5 +264,5 @@
 		
 		imc_error( ic, "Could not connect to server" );
-		imc_logout( ic );
+		imc_logout( ic, TRUE );
 		return FALSE;
 	}
@@ -275,5 +275,5 @@
 static xt_status jabber_end_of_stream( struct xt_node *node, gpointer data )
 {
-	imc_logout( data );
+	imc_logout( data, TRUE );
 	return XT_ABORT;
 }
@@ -298,5 +298,5 @@
 		{
 			imc_error( ic, "Server requires TLS connections, but TLS is turned off for this account" );
-			imc_logout( ic );
+			imc_logout( ic, FALSE );
 			
 			return XT_ABORT;
@@ -328,5 +328,5 @@
 		{
 			imc_error( ic, "TLS is turned on for this account, but is not supported by this server" );
-			imc_logout( ic );
+			imc_logout( ic, FALSE );
 			
 			return XT_ABORT;
@@ -429,4 +429,5 @@
 	struct xt_node *c;
 	char *s, *type = NULL, *text = NULL;
+	int allow_reconnect = TRUE;
 	
 	for( c = node->children; c; c = c->next )
@@ -453,5 +454,5 @@
 	{
 		imc_error( ic, "Unknown stream error reported by server" );
-		imc_logout( ic );
+		imc_logout( ic, allow_reconnect );
 		return XT_ABORT;
 	}
@@ -463,5 +464,5 @@
 	{
 		imc_error( ic, "Account and resource used from a different location" );
-		ic->wants_to_die = TRUE;
+		allow_reconnect = FALSE;
 	}
 	else
@@ -470,5 +471,5 @@
 	}
 	
-	imc_logout( ic );
+	imc_logout( ic, allow_reconnect );
 	
 	return XT_ABORT;
Index: protocols/jabber/iq.c
===================================================================
--- protocols/jabber/iq.c	(revision cd4723c257f9f7bd8d4a46c6562f93c2aefc3dbb)
+++ protocols/jabber/iq.c	(revision c2fb38096ea4e75a680e57e103d4a4986aa84c75)
@@ -40,5 +40,5 @@
 	{
 		imc_error( ic, "Received IQ packet without type." );
-		imc_logout( ic );
+		imc_logout( ic, TRUE );
 		return XT_ABORT;
 	}
@@ -220,5 +220,5 @@
 	{
 		imc_log( ic, "WARNING: Received incomplete IQ packet while authenticating" );
-		imc_logout( ic );
+		imc_logout( ic, FALSE );
 		return XT_HANDLED;
 	}
@@ -259,5 +259,5 @@
 		
 		imc_error( ic, "Can't find suitable authentication method" );
-		imc_logout( ic );
+		imc_logout( ic, FALSE );
 		return XT_ABORT;
 	}
@@ -278,5 +278,5 @@
 	{
 		imc_log( ic, "WARNING: Received incomplete IQ packet while authenticating" );
-		imc_logout( ic );
+		imc_logout( ic, FALSE );
 		return XT_HANDLED;
 	}
@@ -285,5 +285,5 @@
 	{
 		imc_error( ic, "Authentication failure" );
-		imc_logout( ic );
+		imc_logout( ic, FALSE );
 		return XT_ABORT;
 	}
Index: protocols/jabber/jabber.c
===================================================================
--- protocols/jabber/jabber.c	(revision cd4723c257f9f7bd8d4a46c6562f93c2aefc3dbb)
+++ protocols/jabber/jabber.c	(revision c2fb38096ea4e75a680e57e103d4a4986aa84c75)
@@ -73,5 +73,5 @@
 	{
 		imc_error( ic, "Incomplete account name (format it like <username@jabberserver.name>)" );
-		imc_logout( ic );
+		imc_logout( ic, FALSE );
 		return;
 	}
@@ -166,5 +166,5 @@
 		imc_log( ic, "Incorrect port number, must be in the %d-%d range",
 		               JABBER_PORT_MIN, JABBER_PORT_MAX );
-		imc_logout( ic );
+		imc_logout( ic, FALSE );
 		return;
 	}
@@ -187,5 +187,5 @@
 	{
 		imc_error( ic, "Could not connect to server" );
-		imc_logout( ic );
+		imc_logout( ic, TRUE );
 	}
 }
Index: protocols/jabber/sasl.c
===================================================================
--- protocols/jabber/sasl.c	(revision cd4723c257f9f7bd8d4a46c6562f93c2aefc3dbb)
+++ protocols/jabber/sasl.c	(revision c2fb38096ea4e75a680e57e103d4a4986aa84c75)
@@ -45,5 +45,6 @@
 	if( !s || strcmp( s, XMLNS_SASL ) != 0 )
 	{
-		imc_logout( ic );
+		imc_log( ic, "Stream error while authenticating" );
+		imc_logout( ic, FALSE );
 		return XT_ABORT;
 	}
@@ -63,5 +64,5 @@
 	{
 		imc_error( ic, "No known SASL authentication schemes supported" );
-		imc_logout( ic );
+		imc_logout( ic, FALSE );
 		return XT_ABORT;
 	}
@@ -280,5 +281,5 @@
 error:
 	imc_error( ic, "Incorrect SASL challenge received" );
-	imc_logout( ic );
+	imc_logout( ic, FALSE );
 
 silent_error:
@@ -303,5 +304,6 @@
 	if( !s || strcmp( s, XMLNS_SASL ) != 0 )
 	{
-		imc_logout( ic );
+		imc_log( ic, "Stream error while authenticating" );
+		imc_logout( ic, FALSE );
 		return XT_ABORT;
 	}
@@ -315,5 +317,5 @@
 	{
 		imc_error( ic, "Authentication failure" );
-		imc_logout( ic );
+		imc_logout( ic, FALSE );
 		return XT_ABORT;
 	}
