From ab936239a4a1247a06f0a54ca8f2ff16348679d1 Mon Sep 17 00:00:00 2001 From: "W. Trevor King" Date: Sun, 27 May 2012 07:52:44 -0400 Subject: [PATCH] Handle SETQUALITYBAR and SETQUALITYBAR_TT in pinentry.py. If you want to see these settings in action, run something like: $ gpg --edit-key 12345678 gpg> passwd The new pinentry code no longer crashes when it gets SETQUALITYBAR commands, but it doesn't use the QUALITY inquiry to test passphrases yet. --- bin/pinentry.py | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/bin/pinentry.py b/bin/pinentry.py index 9d0e725..2b42673 100755 --- a/bin/pinentry.py +++ b/bin/pinentry.py @@ -256,7 +256,7 @@ class PinEntry (_server.AssuanServer): This indicator is updated as the passphrase is typed. The clients needs to implement an inquiry named "QUALITY" which - gets passed the current passpharse (percent-plus escaped) and + gets passed the current passphrase (percent-plus escaped) and should send back a string with a single numerical vauelue between -100 and 100. Negative values will be displayed in red. @@ -273,13 +273,27 @@ class PinEntry (_server.AssuanServer): S: OK With STRING being a percent escaped string shown as the tooltip. + + Here is a real world example of these commands in use: + + C: SETQUALITYBAR Quality%3a + S: OK + C: SETQUALITYBAR_TT The quality of the text entered above.%0aPlease ask your administrator for details about the criteria. + S: OK """ - raise NotImplementedError() + self.strings['qualitybar'] = arg + yield _common.Response('OK') + + def _handle_SETQUALITYBAR_TT(self, arg): + self.strings['qualitybar_tooltip'] = arg + yield _common.Response('OK') def _handle_GETPIN(self, arg): try: self._connect() self._write(self.strings['description']) + if 'qualitybar' in self.strings: + self._write(self.strings['qualitybar']) pin = self._prompt(self.strings['prompt'], add_colon=False) finally: self._disconnect() -- 2.26.2