use PassphraseDialog only asynchronously. see #4147
This commit is contained in:
parent
52b8adb6be
commit
0c662cf2fd
|
@ -2553,16 +2553,19 @@ class RemoveAccountWindow:
|
||||||
gajim.connections[self.account].change_status('offline', 'offline')
|
gajim.connections[self.account].change_status('offline', 'offline')
|
||||||
if self.remove_and_unregister_radiobutton.get_active():
|
if self.remove_and_unregister_radiobutton.get_active():
|
||||||
if not gajim.connections[self.account].password:
|
if not gajim.connections[self.account].password:
|
||||||
passphrase = ''
|
def on_ok(passphrase, checked):
|
||||||
|
if passphrase == -1:
|
||||||
|
# We don't remove account cause we canceled pw window
|
||||||
|
return
|
||||||
|
gajim.connections[self.account].password = passphrase
|
||||||
|
gajim.connections[self.account].unregister_account(
|
||||||
|
self._on_remove_success)
|
||||||
|
|
||||||
w = dialogs.PassphraseDialog(
|
w = dialogs.PassphraseDialog(
|
||||||
_('Password Required'),
|
_('Password Required'),
|
||||||
_('Enter your password for account %s') % self.account,
|
_('Enter your password for account %s') % self.account,
|
||||||
_('Save password'))
|
_('Save password'), ok_handler=on_ok)
|
||||||
passphrase, save = w.run()
|
return
|
||||||
if passphrase == -1:
|
|
||||||
# We don't remove account cause we canceled pw window
|
|
||||||
return
|
|
||||||
gajim.connections[self.account].password = passphrase
|
|
||||||
gajim.connections[self.account].unregister_account(
|
gajim.connections[self.account].unregister_account(
|
||||||
self._on_remove_success)
|
self._on_remove_success)
|
||||||
else:
|
else:
|
||||||
|
@ -2572,7 +2575,7 @@ class RemoveAccountWindow:
|
||||||
dialog = dialogs.ConfirmationDialog(
|
dialog = dialogs.ConfirmationDialog(
|
||||||
_('Account "%s" is connected to the server') % self.account,
|
_('Account "%s" is connected to the server') % self.account,
|
||||||
_('If you remove it, the connection will be lost.'),
|
_('If you remove it, the connection will be lost.'),
|
||||||
on_response_ok = remove)
|
on_response_ok=remove)
|
||||||
else:
|
else:
|
||||||
remove()
|
remove()
|
||||||
|
|
||||||
|
@ -3737,4 +3740,4 @@ class ManagePEPServicesWindow:
|
||||||
window.set_title(title)
|
window.set_title(title)
|
||||||
window.show_all()
|
window.show_all()
|
||||||
|
|
||||||
# vim: se ts=3:
|
# vim: se ts=3:
|
||||||
|
|
|
@ -199,26 +199,8 @@ class EditGroupsDialog:
|
||||||
|
|
||||||
class PassphraseDialog:
|
class PassphraseDialog:
|
||||||
'''Class for Passphrase dialog'''
|
'''Class for Passphrase dialog'''
|
||||||
def run(self):
|
def __init__(self, titletext, labeltext, checkbuttontext=None,
|
||||||
'''Wait for OK button to be pressed and return passphrase/password'''
|
ok_handler=None, cancel_handler=None):
|
||||||
rep = self.window.run()
|
|
||||||
if rep == gtk.RESPONSE_OK:
|
|
||||||
passphrase = self.passphrase_entry.get_text().decode('utf-8')
|
|
||||||
else:
|
|
||||||
passphrase = -1
|
|
||||||
|
|
||||||
if self.check:
|
|
||||||
save_passphrase_checkbutton = self.xml.\
|
|
||||||
get_widget('save_passphrase_checkbutton')
|
|
||||||
checked = save_passphrase_checkbutton.get_active()
|
|
||||||
else:
|
|
||||||
checked = False
|
|
||||||
|
|
||||||
self.window.destroy()
|
|
||||||
return passphrase, checked
|
|
||||||
|
|
||||||
def __init__(self, titletext, labeltext, checkbuttontext=None, is_modal=True,
|
|
||||||
ok_handler = None, cancel_handler = None):
|
|
||||||
self.xml = gtkgui_helpers.get_glade('passphrase_dialog.glade')
|
self.xml = gtkgui_helpers.get_glade('passphrase_dialog.glade')
|
||||||
self.window = self.xml.get_widget('passphrase_dialog')
|
self.window = self.xml.get_widget('passphrase_dialog')
|
||||||
self.passphrase_entry = self.xml.get_widget('passphrase_entry')
|
self.passphrase_entry = self.xml.get_widget('passphrase_entry')
|
||||||
|
@ -229,13 +211,11 @@ class PassphraseDialog:
|
||||||
self.ok = False
|
self.ok = False
|
||||||
|
|
||||||
self.cancel_handler = cancel_handler
|
self.cancel_handler = cancel_handler
|
||||||
self.is_modal = is_modal
|
self.ok_handler = ok_handler
|
||||||
if not is_modal and ok_handler is not None:
|
okbutton = self.xml.get_widget('ok_button')
|
||||||
self.ok_handler = ok_handler
|
okbutton.connect('clicked', self.on_okbutton_clicked)
|
||||||
okbutton = self.xml.get_widget('ok_button')
|
cancelbutton = self.xml.get_widget('cancel_button')
|
||||||
okbutton.connect('clicked', self.on_okbutton_clicked)
|
cancelbutton.connect('clicked', self.on_cancelbutton_clicked)
|
||||||
cancelbutton = self.xml.get_widget('cancel_button')
|
|
||||||
cancelbutton.connect('clicked', self.on_cancelbutton_clicked)
|
|
||||||
|
|
||||||
self.xml.signal_autoconnect(self)
|
self.xml.signal_autoconnect(self)
|
||||||
self.window.show_all()
|
self.window.show_all()
|
||||||
|
@ -248,6 +228,9 @@ class PassphraseDialog:
|
||||||
checkbutton.hide()
|
checkbutton.hide()
|
||||||
|
|
||||||
def on_okbutton_clicked(self, widget):
|
def on_okbutton_clicked(self, widget):
|
||||||
|
if not self.ok_handler:
|
||||||
|
return
|
||||||
|
|
||||||
passph = self.passphrase_entry.get_text().decode('utf-8')
|
passph = self.passphrase_entry.get_text().decode('utf-8')
|
||||||
|
|
||||||
if self.check:
|
if self.check:
|
||||||
|
|
|
@ -1440,11 +1440,10 @@ class Interface:
|
||||||
# ask again
|
# ask again
|
||||||
dialogs.PassphraseDialog(_('Wrong Passphrase'),
|
dialogs.PassphraseDialog(_('Wrong Passphrase'),
|
||||||
_('Please retype your GPG passphrase or press Cancel.'),
|
_('Please retype your GPG passphrase or press Cancel.'),
|
||||||
is_modal=False, ok_handler=(_ok, count), cancel_handler=_cancel)
|
ok_handler=(_ok, count), cancel_handler=_cancel)
|
||||||
|
|
||||||
dialogs.PassphraseDialog(title, second,
|
|
||||||
is_modal=False, ok_handler=(_ok, 0), cancel_handler=_cancel)
|
|
||||||
|
|
||||||
|
dialogs.PassphraseDialog(title, second, 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))
|
||||||
|
|
|
@ -1932,7 +1932,7 @@ class RosterWindow:
|
||||||
if gajim.interface.systray_enabled:
|
if gajim.interface.systray_enabled:
|
||||||
gajim.interface.systray.change_status('connecting')
|
gajim.interface.systray.change_status('connecting')
|
||||||
|
|
||||||
def send_status(self, account, status, txt, auto = False, to = None):
|
def send_status(self, account, status, txt, auto=False, to=None):
|
||||||
child_iterA = self._get_account_iter(account, self.model)
|
child_iterA = self._get_account_iter(account, self.model)
|
||||||
if status != 'offline':
|
if status != 'offline':
|
||||||
if to is None:
|
if to is None:
|
||||||
|
@ -1950,27 +1950,39 @@ class RosterWindow:
|
||||||
text += '\n' + _('Gnome Keyring is installed but not \
|
text += '\n' + _('Gnome Keyring is installed but not \
|
||||||
correctly started (environment variable probably not \
|
correctly started (environment variable probably not \
|
||||||
correctly set)')
|
correctly set)')
|
||||||
w = dialogs.PassphraseDialog(_('Password Required'), text,
|
def on_ok(passphrase, save):
|
||||||
_('Save password'))
|
gajim.connections[account].password = passphrase
|
||||||
passphrase, save = w.run()
|
if save:
|
||||||
if passphrase == -1:
|
gajim.config.set_per('accounts', account, 'savepass', True)
|
||||||
|
passwords.save_password(account, passphrase)
|
||||||
|
keyid = gajim.config.get_per('accounts', account, 'keyid')
|
||||||
|
if keyid and not gajim.connections[account].gpg:
|
||||||
|
dialog = dialogs.WarningDialog(_('GPG is not usable'),
|
||||||
|
_('You will be connected to %s without OpenPGP.') % \
|
||||||
|
account)
|
||||||
|
self.send_status_continue(account, status, txt, auto, to)
|
||||||
|
|
||||||
|
def on_cancel():
|
||||||
if child_iterA:
|
if child_iterA:
|
||||||
self.model[child_iterA][0] = \
|
self.model[child_iterA][0] = \
|
||||||
gajim.interface.jabber_state_images['16']['offline']
|
gajim.interface.jabber_state_images['16']['offline']
|
||||||
if gajim.interface.systray_enabled:
|
if gajim.interface.systray_enabled:
|
||||||
gajim.interface.systray.change_status('offline')
|
gajim.interface.systray.change_status('offline')
|
||||||
self.update_status_combobox()
|
self.update_status_combobox()
|
||||||
return
|
|
||||||
gajim.connections[account].password = passphrase
|
w = dialogs.PassphraseDialog(_('Password Required'), text,
|
||||||
if save:
|
_('Save password'), ok_handler=on_ok,
|
||||||
gajim.config.set_per('accounts', account, 'savepass', True)
|
cancel_handler=on_cancel)
|
||||||
passwords.save_password(account, passphrase)
|
return
|
||||||
|
|
||||||
keyid = gajim.config.get_per('accounts', account, 'keyid')
|
keyid = gajim.config.get_per('accounts', account, 'keyid')
|
||||||
if keyid and not gajim.connections[account].gpg:
|
if keyid and not gajim.connections[account].gpg:
|
||||||
dialog = dialogs.WarningDialog(_('GPG is not usable'),
|
dialog = dialogs.WarningDialog(_('GPG is not usable'),
|
||||||
_('You will be connected to %s without OpenPGP.') % account)
|
_('You will be connected to %s without OpenPGP.') % account)
|
||||||
|
|
||||||
|
self.send_status_continue(account, status, txt, auto, to)
|
||||||
|
|
||||||
|
def send_status_continue(self, account, status, txt, auto, to):
|
||||||
if gajim.account_is_connected(account):
|
if gajim.account_is_connected(account):
|
||||||
if status == 'online' and gajim.interface.sleeper.getState() != \
|
if status == 'online' and gajim.interface.sleeper.getState() != \
|
||||||
common.sleepy.STATE_UNKNOWN:
|
common.sleepy.STATE_UNKNOWN:
|
||||||
|
@ -6338,4 +6350,4 @@ class RosterWindow:
|
||||||
self.setup_for_osx()
|
self.setup_for_osx()
|
||||||
|
|
||||||
|
|
||||||
# vim: se ts=3:
|
# vim: se ts=3:
|
||||||
|
|
Loading…
Reference in New Issue