def _handle_GETINFO(self, arg): if arg == 'pid': yield _common.Response('D', str(_os.getpid()).encode('ascii')) elif arg == 'version': yield _common.Response('D', __version__.encode('ascii')) else: raise _error.AssuanError(message='Invalid parameter') yield _common.Response('OK')
def _handle_GETPIN(self, arg): try: self._connect() self._write(self.strings['description']) if 'key info' in self.strings: self._write('key: {}'.format(self.strings['key info'])) if 'qualitybar' in self.strings: self._write(self.strings['qualitybar']) pin = self._prompt( prompt=self.strings['prompt'], error=self.strings.get('error'), add_colon=False) finally: self._disconnect() yield _common.Response('D', pin.encode('ascii')) yield _common.Response('OK')
def _handle_SETQUALITYBAR(self, arg): """Adds a quality indicator to the GETPIN window. This indicator is updated as the passphrase is typed. The clients needs to implement an inquiry named "QUALITY" which 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. If a custom label for the quality bar is required, just add that label as an argument as percent escaped string. You will need this feature to translate the label because pinentry has no internal gettext except for stock strings from the toolkit library. If you want to show a tooltip for the quality bar, you may use C: SETQUALITYBAR_TT string 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 """ self.strings['qualitybar'] = arg yield _common.Response('OK')
def _handle_CONFIRM(self, args): assert args == '--one-button', args try: self._connect() self._write(self.strings['description']) self._write('1) '+self.strings['ok']) value = self._prompt('?') finally: self._disconnect() assert value == '1', value yield _common.Response('OK')
def _handle_CONFIRM(self, arg): try: self._connect() self._write(self.strings['description']) self._write('1) '+self.strings['ok']) self._write('2) '+self.strings['not ok']) value = self._prompt('?') finally: self._disconnect() if value == '1': yield _common.Response('OK') else: raise _error.AssuanError(message='Not confirmed')
def _handle_MESSAGE(self, arg): self._write(self.strings['description']) yield _common.Response('OK')
def _handle_SETQUALITYBAR_TT(self, arg): self.strings['qualitybar_tooltip'] = arg yield _common.Response('OK')
def _handle_SETNOTOK(self, arg): self.strings['not ok'] = arg yield _common.Response('OK')
def _handle_SETCANCEL(self, arg): self.strings['cancel'] = arg yield _common.Response('OK')
def _handle_SETTITLE(self, arg): self.strings['title'] = arg yield _common.Response('OK')
def _handle_SETERROR(self, arg): self.strings['error'] = arg yield _common.Response('OK')
def _handle_SETPROMPT(self, arg): self.strings['prompt'] = arg yield _common.Response('OK')
def _handle_SETDESC(self, arg): self.strings['description'] = arg yield _common.Response('OK')
def _handle_CLEARPASSPHRASE(self, arg): yield _common.Response('OK')
def _handle_SETKEYINFO(self, arg): self.strings['key info'] = arg yield _common.Response('OK')