Philipp Hörist pushed to branch master at gajim / gajim
Commits: ad53f214 by lovetox at 2020-03-22T09:26:37+01:00 Client: Raise notification on SASL errors
- - - - - d64b578c by lovetox at 2020-03-22T09:49:07+01:00 Client: Never allow Client.status to be 'offline'
status should be used to track our presence show value only
All code should depend on ClientState to determine if we are offline
- - - - - 29c6f0ba by lovetox at 2020-03-22T10:01:18+01:00 AccountWizard: Fix method call
- - - - -
4 changed files:
- gajim/common/cert_store.py - gajim/common/client.py - gajim/gtk/account_wizard.py - gajim/gtk/notification.py
Changes:
===================================== gajim/common/cert_store.py ===================================== @@ -61,6 +61,7 @@ class CertificateStore: return list(self._certs)
def add_certificate(self, certificate): + log.info('Add certificate to trust store') pem = certificate.props.certificate_pem path = self._get_random_path() write_file_async(path,
===================================== gajim/common/client.py ===================================== @@ -36,6 +36,7 @@ from gajim.common.helpers import get_custom_host from gajim.common.helpers import get_user_proxy from gajim.common.helpers import warn_about_plain_connection from gajim.common.helpers import get_resource +from gajim.common.i18n import _
from gajim.common.connection_handlers import ConnectionHandlers from gajim.common.connection_handlers_events import OurShowEvent @@ -70,7 +71,7 @@ class Client(ConnectionHandlers): self.roster_supported = True
self._state = ClientState.DISCONNECTED - self._status = 'offline' + self._status = 'online' self._status_message = ''
self._reconnect = True @@ -198,7 +199,7 @@ class Client(ConnectionHandlers): log.info('Disconnect %s', self._account) self._set_state(ClientState.DISCONNECTED)
- domain, error, _text = self._client.get_error() + domain, error, text = self._client.get_error() if domain == StreamError.BAD_CERTIFICATE: self._ssl_errors = self._client.peer_certificate[1] self.get_module('Chatstate').enabled = False @@ -226,6 +227,13 @@ class Client(ConnectionHandlers): app.nec.push_incoming_event(NetworkEvent( 'password-required', conn=self, on_password=_on_password))
+ app.nec.push_incoming_event( + NetworkEvent('simple-notification', + account=self._account, + type_='connection-failed', + title=_('Authentication failed'), + text=text or error)) + if self._reconnect: self._after_disconnect() self._schedule_reconnect() @@ -233,7 +241,6 @@ class Client(ConnectionHandlers): OurShowEvent(None, conn=self, show='error'))
else: - self._status = 'offline' self.get_module('Chatstate').enabled = False app.nec.push_incoming_event(OurShowEvent( None, conn=self, show='offline')) @@ -299,7 +306,8 @@ class Client(ConnectionHandlers): if not msg: msg = ''
- self._status = show + if show != 'offline': + self._status = show self._status_message = msg
if self._state.is_disconnecting:
===================================== gajim/gtk/account_wizard.py ===================================== @@ -121,7 +121,7 @@ class AccountWizard(Assistant): self._test_credentials()
elif page == 'security-warning': - if self.get_page('security-warning').is_add_to_trusted: + if self.get_page('security-warning').trust_certificate: app.cert_store.add_certificate( self.get_page('security-warning').cert) self._test_credentials(ignore_all_errors=True) @@ -141,7 +141,7 @@ class AccountWizard(Assistant): self._register_with_server()
elif page == 'security-warning': - if self.get_page('security-warning').is_add_to_trusted: + if self.get_page('security-warning').trust_certificate: app.cert_store.add_certificate( self.get_page('security-warning').cert) self._register_with_server(ignore_all_errors=True) @@ -727,7 +727,8 @@ class SecurityWarning(Page): transient_for=self.get_toplevel(), cert=self._cert)
- def is_add_to_trusted(self): + @property + def trust_certificate(self): return self._ui.trust_cert_checkbutton.get_active()
===================================== gajim/gtk/notification.py ===================================== @@ -61,6 +61,7 @@ class Notification(EventHelper):
self.register_events([ ('notification', ged.GUI2, self._nec_notification), + ('simple-notification', ged.GUI2, self._on_notification), ('our-show', ged.GUI2, self._nec_our_status), ])
@@ -114,6 +115,13 @@ class Notification(EventHelper): except Exception: pass
+ def _on_notification(self, event): + self.popup(event.type_, + None, + event.account, + title=event.title, + text=event.text) + def _on_event_removed(self, event_list): for event in event_list: if event.type_ == 'gc-invitation':
View it on GitLab: https://dev.gajim.org/gajim/gajim/-/compare/25494124cdfcb68e205a5d85cc96e847...