Philipp Hörist pushed to branch master at gajim / gajim
Commits: e6152d79 by lovetox at 2022-01-23T12:22:32+01:00 Interface: Handle plain-connection event in MainWindow
- - - - - aa2f660e by lovetox at 2022-01-23T12:26:47+01:00 Interface: Handle password-required event in MainWindow
- - - - - 64e7e766 by lovetox at 2022-01-23T12:32:18+01:00 Remove dead client-cert-passphrase event handling
nbxmpp does not support client certificates anymore
- - - - - e4189cbc by lovetox at 2022-01-23T12:32:29+01:00 Update pyrightconfig.json
- - - - -
5 changed files:
- gajim/common/events.py - gajim/gtk/main.py - gajim/gtk/password_dialog.py - gajim/gui_interface.py - pyrightconfig.json
Changes:
===================================== gajim/common/events.py ===================================== @@ -81,7 +81,7 @@ class PlainConnection(ApplicationEvent): @dataclass class PasswordRequired(ApplicationEvent): name: str = field(init=False, default='password-required') - conn: 'Client' + client: 'Client' on_password: Callable[..., Any]
===================================== gajim/gtk/main.py ===================================== @@ -32,6 +32,8 @@ from gajim.common import ged from gajim.common.const import Direction from gajim.common.events import ApplicationEvent +from gajim.common.events import PasswordRequired +from gajim.common.events import PlainConnection from gajim.common.events import RosterItemExchangeEvent from gajim.common.events import AllowGajimUpdateCheck from gajim.common.events import GajimUpdateAvailable @@ -130,6 +132,8 @@ def __init__(self) -> None: ('allow-gajim-update-check', ged.GUI1, self._on_allow_gajim_update), ('gajim-update-available', ged.GUI1, self._on_gajim_update_available), ('roster-item-exchange', ged.GUI1, self._on_roster_item_exchange), + ('plain-connection', ged.GUI1, self._on_plain_connection), + ('password-required', ged.GUI1, self._on_password_required), ])
self._check_for_account() @@ -206,6 +210,28 @@ def _on_roster_item_exchange(event: RosterItemExchangeEvent) -> None: exchange_list=event.exchange_items_list, jid_from=event.jid)
+ @staticmethod + def _on_plain_connection(event: PlainConnection) -> None: + ConfirmationDialog( + _('Insecure Connection'), + _('Insecure Connection'), + _('You are about to connect to the account %(account)s ' + '(%(server)s) using an insecure connection method. This means ' + 'conversations will not be encrypted. Connecting PLAIN is ' + 'strongly discouraged.') % { + 'account': event.account, + 'server': app.get_hostname_from_account(event.account)}, + [DialogButton.make('Cancel', + text=_('_Abort'), + callback=event.abort), + DialogButton.make('Remove', + text=_('_Connect Anyway'), + callback=event.connect)]).show() + + @staticmethod + def _on_password_required(event: PasswordRequired) -> None: + open_window('PasswordDialog', event=event) + def _add_actions(self) -> None: actions = [ ('add-workspace', 's', self._add_workspace),
===================================== gajim/gtk/password_dialog.py ===================================== @@ -29,7 +29,7 @@
class PasswordDialog(Gtk.ApplicationWindow): - def __init__(self, account: str, event: PasswordRequired) -> None: + def __init__(self, event: PasswordRequired) -> None: Gtk.ApplicationWindow.__init__(self) self.set_application(app.app) self.set_type_hint(Gdk.WindowTypeHint.DIALOG) @@ -42,8 +42,8 @@ def __init__(self, account: str, event: PasswordRequired) -> None: self._ui = get_builder('password_dialog.ui') self.add(self._ui.pass_box)
- self.account = account - self._client = app.get_client(account) + self.account = event.client.account + self._client = app.get_client(event.client.account) self._event = event
self.connect('key-press-event', self._on_key_press) @@ -62,53 +62,28 @@ def _process_event(self) -> None: account_name = app.settings.get_account_setting( self.account, 'name')
- if self._event.name == 'password-required': - self._ui.header.set_text(_('Password Required')) - self._ui.message_label.set_text( - _('Please enter your password for\n' - '%(jid)s\n(Account: %(account)s)') % { - 'jid': own_jid, - 'account': account_name}) - self._ui.save_pass_checkbutton.show() - self._ui.save_pass_checkbutton.set_sensitive( - not app.settings.get('use_keyring') or KEYRING_AVAILABLE) - if not KEYRING_AVAILABLE: - self._ui.keyring_hint.show() - - if self._event.name == 'client-cert-passphrase': - self._ui.header.set_text(_('Certificate Password Required')) - self._ui.message_label.set_text( - _('Please enter your certificate password for ' - '%(jid)s (%(account)s)') % { - 'jid': own_jid, - 'account': account_name}) + self._ui.header.set_text(_('Password Required')) + self._ui.message_label.set_text( + _('Please enter your password for\n' + '%(jid)s\n(Account: %(account)s)') % { + 'jid': own_jid, + 'account': account_name}) + self._ui.save_pass_checkbutton.show() + self._ui.save_pass_checkbutton.set_sensitive( + not app.settings.get('use_keyring') or KEYRING_AVAILABLE) + if not KEYRING_AVAILABLE: + self._ui.keyring_hint.show()
def _on_ok(self, _button: Gtk.Button) -> None: password = self._ui.pass_entry.get_text()
- if self._event.name == 'password-required': - app.settings.set_account_setting( - self.account, - 'savepass', - self._ui.save_pass_checkbutton.get_active()) - save_password(self.account, password) - self._event.on_password(password) - self.destroy() - - if self._event.name == 'client-cert-passphrase': - self._event.conn.on_client_cert_passphrase( - password, - self._event.con, - self._event.port, - self._event.secure_tuple) - self.destroy() + app.settings.set_account_setting( + self.account, + 'savepass', + self._ui.save_pass_checkbutton.get_active()) + save_password(self.account, password) + self._event.on_password(password) + self.destroy()
def _on_cancel(self, _button: Gtk.Button) -> None: - if self._event.name == 'client-cert-passphrase': - self._event.conn.on_client_cert_passphrase( - '', - self._event.con, - self._event.port, - self._event.secure_tuple) - self.destroy()
===================================== gajim/gui_interface.py ===================================== @@ -68,7 +68,6 @@ from gajim.common.events import FileProgress from gajim.common.events import FileError from gajim.common.events import MucAdded -from gajim.common.events import PasswordRequired from gajim.common.helpers import ask_for_status_message from gajim.common.structs import OutgoingMessage from gajim.common.i18n import _ @@ -91,7 +90,6 @@ from gajim.gui.util import get_app_window from gajim.gui.util import get_app_windows from gajim.gui.util import get_color_for_account -from gajim.gui.util import open_window from gajim.gui.types import ControlT
log = logging.getLogger('gajim.interface') @@ -144,10 +142,7 @@ def _create_core_handlers_list(self) -> None: # pylint: disable=line-too-long self.handlers = { 'iq-error-received': [self.handle_event_iq_error], - 'plain-connection': [self.handle_event_plain_connection], 'http-auth-received': [self.handle_event_http_auth], - 'password-required': [self.handle_event_password_required], - 'client-cert-passphrase': [self.handle_event_client_cert_passphrase], 'signed-in': [self.handle_event_signed_in], 'presence-received': [self.handle_event_presence], 'our-show': [self.handle_event_status], @@ -180,24 +175,6 @@ def handle_event_iq_error(event): if ctrl and ctrl.is_groupchat: ctrl.add_info_message(f'Error: {event.properties.error}')
- @staticmethod - def handle_event_plain_connection(event): - ConfirmationDialog( - _('Insecure Connection'), - _('Insecure Connection'), - _('You are about to connect to the account %(account)s ' - '(%(server)s) using an insecure connection method. This means ' - 'conversations will not be encrypted. Connecting PLAIN is ' - 'strongly discouraged.') % { - 'account': event.account, - 'server': app.get_hostname_from_account(event.account)}, - [DialogButton.make('Cancel', - text=_('_Abort'), - callback=event.abort), - DialogButton.make('Remove', - text=_('_Connect Anyway'), - callback=event.connect)]).show() - @staticmethod def handle_event_http_auth(event): # ('HTTP_AUTH', account, (method, url, transaction_id, iq_obj, msg)) @@ -230,14 +207,6 @@ def _response(answer: str) -> None: callback=_response, args=['yes'])]).show()
- @staticmethod - def handle_event_client_cert_passphrase(event): - open_window('PasswordDialog', account=event.conn.name, event=event) - - @staticmethod - def handle_event_password_required(event: PasswordRequired) -> None: - open_window('PasswordDialog', account=event.conn.name, event=event) - @staticmethod def handle_event_signed_in(event): """
===================================== pyrightconfig.json ===================================== @@ -63,6 +63,7 @@ "gajim/gtk/main_stack.py", "gajim/gtk/manage_sounds.py", "gajim/gtk/notification.py", + "gajim/gtk/password_dialog.py", "gajim/gtk/preview_audio.py", "gajim/gtk/proxies.py", "gajim/gtk/remove_account.py",
View it on GitLab: https://dev.gajim.org/gajim/gajim/-/compare/cd5c2899651383d864c2bbe463ced4ac...