make GPG passphrase dialog nonmodal, fixes #3975
This commit is contained in:
parent
7ff17b7e1f
commit
9d98117f21
54
src/gajim.py
54
src/gajim.py
|
@ -1353,34 +1353,38 @@ class Interface:
|
||||||
gajim.connections[account].gpg_passphrase(self.gpg_passphrase[keyid])
|
gajim.connections[account].gpg_passphrase(self.gpg_passphrase[keyid])
|
||||||
callback()
|
callback()
|
||||||
return
|
return
|
||||||
if self.gpg_dialog:
|
|
||||||
# A GPG dialog is already open, retry in 0.5 second
|
|
||||||
gobject.timeout_add(500, self.handle_event_gpg_password_required,
|
|
||||||
account, array)
|
|
||||||
return
|
|
||||||
password_ok = False
|
|
||||||
count = 0
|
|
||||||
title = _('Passphrase Required')
|
title = _('Passphrase Required')
|
||||||
second = _('Enter GPG key passphrase for account %s.') % account
|
second = _('Enter GPG key passphrase for account %s.') % account
|
||||||
while not password_ok and count < 3:
|
|
||||||
count += 1
|
def _cancel():
|
||||||
self.gpg_dialog = dialogs.PassphraseDialog(title, second, '')
|
# user cancelled, continue without GPG
|
||||||
passphrase, save = self.gpg_dialog.run()
|
gajim.connections[account].gpg_passphrase(None)
|
||||||
if passphrase == -1:
|
callback()
|
||||||
# User pressed cancel
|
|
||||||
passphrase = None
|
def _ok(passphrase, checked, count):
|
||||||
password_ok = True
|
if count < 3:
|
||||||
|
count += 1
|
||||||
|
done = gajim.connections[account].test_gpg_passphrase(passphrase)
|
||||||
else:
|
else:
|
||||||
password_ok = gajim.connections[account].\
|
done = True
|
||||||
test_gpg_passphrase(passphrase)
|
passphrase = None
|
||||||
title = _('Wrong Passphrase')
|
|
||||||
second = _('Please retype your GPG passphrase or press Cancel.')
|
if done:
|
||||||
self.gpg_dialog = None
|
if passphrase is not None:
|
||||||
if passphrase is not None:
|
self.gpg_passphrase[keyid] = passphrase
|
||||||
self.gpg_passphrase[keyid] = passphrase
|
gobject.timeout_add(30000, self.forget_gpg_passphrase, keyid)
|
||||||
gobject.timeout_add(30000, self.forget_gpg_passphrase, keyid)
|
gajim.connections[account].gpg_passphrase(passphrase)
|
||||||
gajim.connections[account].gpg_passphrase(passphrase)
|
callback()
|
||||||
callback()
|
else:
|
||||||
|
# ask again
|
||||||
|
dialogs.PassphraseDialog(_('Wrong Passphrase'),
|
||||||
|
_('Please retype your GPG passphrase or press Cancel.'),
|
||||||
|
is_modal=False, ok_handler=(_ok, count), cancel_handler=_cancel)
|
||||||
|
|
||||||
|
dialogs.PassphraseDialog(title, second,
|
||||||
|
is_modal=False, ok_handler=(_ok, 0), cancel_handler=_cancel)
|
||||||
|
|
||||||
|
|
||||||
def handle_event_roster_info(self, account, array):
|
def handle_event_roster_info(self, account, array):
|
||||||
#('ROSTER_INFO', account, (jid, name, sub, ask, groups))
|
#('ROSTER_INFO', account, (jid, name, sub, ask, groups))
|
||||||
|
|
Loading…
Reference in New Issue