From 91300042495a545324757e8744355a8778162d59 Mon Sep 17 00:00:00 2001
From: Yann Leboulanger <asterix@lagaule.org>
Date: Fri, 1 Aug 2008 10:22:24 +0000
Subject: [PATCH] [avm] prevent eating up the passphrase when you fail to enter
 it 2 times, but succeed on the 3rd. see #4164

---
 src/gajim.py | 22 +++++++++++-----------
 1 file changed, 11 insertions(+), 11 deletions(-)

diff --git a/src/gajim.py b/src/gajim.py
index 1c7d7cbbca..103eb2b5af 100755
--- a/src/gajim.py
+++ b/src/gajim.py
@@ -69,7 +69,7 @@ def parseLogLevel(arg):
 		return int(arg)
 	if arg.isupper():
 		return getattr(logging, arg)
-	raise ValueError(_("%s is not a valid loglevel"), repr(arg))
+	raise ValueError(_('%s is not a valid loglevel'), repr(arg))
 
 def parseLogTarget(arg):
 	arg = arg.lower()
@@ -471,21 +471,21 @@ class PassphraseRequest:
 			self.complete(None)
 
 		def _ok(passphrase, checked, count):
-			if count < 3:
-				done = gajim.connections[account].test_gpg_passphrase(passphrase)
-			else:
-				done = True
-				passphrase = None
-
-			if done:
+			if gajim.connections[account].test_gpg_passphrase(passphrase):
+				# passphrase is good
 				self.complete(passphrase)
-			else:
+				return
+
+			if count < 3:
 				# ask again
 				dialogs.PassphraseDialog(_('Wrong Passphrase'),
 					_('Please retype your GPG passphrase or press Cancel.'),
 					ok_handler=(_ok, count + 1), cancel_handler=_cancel)
+			else:
+				# user failed 3 times, continue without GPG
+				self.complete(None)
 
-		dialogs.PassphraseDialog(title, second, ok_handler=(_ok, 0),
+		dialogs.PassphraseDialog(title, second, ok_handler=(_ok, 1),
 			cancel_handler=_cancel)
 		self.dialog_created = True
 
@@ -1378,7 +1378,7 @@ class Interface:
 		if '103' in statusCode:
 			changes.append(_('room now does not show unavailable members'))
 		if '104' in statusCode:
-			changes.append(\
+			changes.append(
 				_('A non-privacy-related room configuration change has occurred'))
 		if '170' in statusCode:
 			# Can be a presence (see chg_contact_status in groupchat_control.py)
-- 
GitLab