Author: asterix
Date: 2008-07-31 08:14:48 +0200 (Thu, 31 Jul 2008)
New Revision: 10090
Modified:
trunk/src/config.py
trunk/src/dialogs.py
trunk/src/gajim.py
trunk/src/roster_window.py
Log:
use PassphraseDialog only asynchronously. see #4147
Modified: trunk/src/config.py
===================================================================
--- trunk/src/config.py 2008-07-30 19:59:24 UTC (rev 10089)
+++ trunk/src/config.py 2008-07-31 06:14:48 UTC (rev 10090)
@@ -2553,16 +2553,19 @@
gajim.connections[self.account].change_status('offline', 'offline')
if self.remove_and_unregister_radiobutton.get_active():
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(
_('Password Required'),
_('Enter your password for account %s') % self.account,
- _('Save password'))
- passphrase, save = w.run()
- if passphrase == -1:
- # We don't remove account cause we canceled pw window
- return
- gajim.connections[self.account].password = passphrase
+ _('Save password'), ok_handler=on_ok)
+ return
gajim.connections[self.account].unregister_account(
self._on_remove_success)
else:
@@ -2572,7 +2575,7 @@
dialog = dialogs.ConfirmationDialog(
_('Account "%s" is connected to the server') % self.account,
_('If you remove it, the connection will be lost.'),
- on_response_ok = remove)
+ on_response_ok=remove)
else:
remove()
@@ -3737,4 +3740,4 @@
window.set_title(title)
window.show_all()
-# vim: se ts=3:
\ No newline at end of file
+# vim: se ts=3:
Modified: trunk/src/dialogs.py
===================================================================
--- trunk/src/dialogs.py 2008-07-30 19:59:24 UTC (rev 10089)
+++ trunk/src/dialogs.py 2008-07-31 06:14:48 UTC (rev 10090)
@@ -199,26 +199,8 @@
class PassphraseDialog:
'''Class for Passphrase dialog'''
- def run(self):
- '''Wait for OK button to be pressed and return passphrase/password'''
- 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):
+ def __init__(self, titletext, labeltext, checkbuttontext=None,
+ ok_handler=None, cancel_handler=None):
self.xml = gtkgui_helpers.get_glade('passphrase_dialog.glade')
self.window = self.xml.get_widget('passphrase_dialog')
self.passphrase_entry = self.xml.get_widget('passphrase_entry')
@@ -229,13 +211,11 @@
self.ok = False
self.cancel_handler = cancel_handler
- self.is_modal = is_modal
- if not is_modal and ok_handler is not None:
- self.ok_handler = ok_handler
- okbutton = self.xml.get_widget('ok_button')
- okbutton.connect('clicked', self.on_okbutton_clicked)
- cancelbutton = self.xml.get_widget('cancel_button')
- cancelbutton.connect('clicked', self.on_cancelbutton_clicked)
+ self.ok_handler = ok_handler
+ okbutton = self.xml.get_widget('ok_button')
+ okbutton.connect('clicked', self.on_okbutton_clicked)
+ cancelbutton = self.xml.get_widget('cancel_button')
+ cancelbutton.connect('clicked', self.on_cancelbutton_clicked)
self.xml.signal_autoconnect(self)
self.window.show_all()
@@ -248,6 +228,9 @@
checkbutton.hide()
def on_okbutton_clicked(self, widget):
+ if not self.ok_handler:
+ return
+
passph = self.passphrase_entry.get_text().decode('utf-8')
if self.check:
Modified: trunk/src/gajim.py
===================================================================
--- trunk/src/gajim.py 2008-07-30 19:59:24 UTC (rev 10089)
+++ trunk/src/gajim.py 2008-07-31 06:14:48 UTC (rev 10090)
@@ -1440,12 +1440,11 @@
# ask again
dialogs.PassphraseDialog(_('Wrong Passphrase'),
_('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):
#('ROSTER_INFO', account, (jid, name, sub, ask, groups))
jid = array[0]
Modified: trunk/src/roster_window.py
===================================================================
--- trunk/src/roster_window.py 2008-07-30 19:59:24 UTC (rev 10089)
+++ trunk/src/roster_window.py 2008-07-31 06:14:48 UTC (rev 10090)
@@ -1932,7 +1932,7 @@
if gajim.interface.systray_enabled:
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)
if status != 'offline':
if to is None:
@@ -1950,27 +1950,39 @@
text += '\n' + _('Gnome Keyring is installed but not \
correctly started (environment variable probably not \
correctly set)')
- w = dialogs.PassphraseDialog(_('Password Required'), text,
- _('Save password'))
- passphrase, save = w.run()
- if passphrase == -1:
+ def on_ok(passphrase, save):
+ gajim.connections[account].password = passphrase
+ if save:
+ 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:
self.model[child_iterA][0] = \
gajim.interface.jabber_state_images['16']['offline']
if gajim.interface.systray_enabled:
gajim.interface.systray.change_status('offline')
self.update_status_combobox()
- return
- gajim.connections[account].password = passphrase
- if save:
- gajim.config.set_per('accounts', account, 'savepass', True)
- passwords.save_password(account, passphrase)
+ w = dialogs.PassphraseDialog(_('Password Required'), text,
+ _('Save password'), ok_handler=on_ok,
+ cancel_handler=on_cancel)
+ return
+
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 send_status_continue(self, account, status, txt, auto, to):
if gajim.account_is_connected(account):
if status == 'online' and gajim.interface.sleeper.getState() != \
common.sleepy.STATE_UNKNOWN:
@@ -6338,4 +6350,4 @@
self.setup_for_osx()
-# vim: se ts=3:
\ No newline at end of file
+# vim: se ts=3: