From: W. Trevor King Date: Sun, 27 May 2012 11:52:44 +0000 (-0400) Subject: Handle SETQUALITYBAR and SETQUALITYBAR_TT in pinentry.py. X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=ab936239a4a1247a06f0a54ca8f2ff16348679d1;p=pyassuan.git 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. --- 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()