Philipp Hörist pushed to branch gajim_1.2 at gajim / gajim
Commits: d08ebcc7 by lovetox at 2020-05-21T19:39:07+02:00 Client: Unregister handlers on cleanup()
Fixes #10083
- - - - - 3b7a4947 by lovetox at 2020-05-21T19:39:07+02:00 Fix codespell errors
- - - - - b29d2ae1 by lovetox at 2020-05-21T19:39:07+02:00 Make anonymous login work again
- - - - - bb27f66a by lovetox at 2020-05-21T19:39:37+02:00 Windows: Add some plugins to the build
- - - - -
5 changed files:
- gajim/common/client.py - gajim/data/gui/account_wizard.ui - gajim/gtk/account_wizard.py - gajim/gui_interface.py - win/_base.sh
Changes:
===================================== gajim/common/client.py ===================================== @@ -148,6 +148,11 @@ class Client(ConnectionHandlers): # his password self.password = passwords.get_password(self._account)
+ anonymous = app.config.get_per( + 'accounts', self._account, 'anonymous_auth') + if anonymous: + self._client.set_mechs(['ANONYMOUS']) + self._client.set_password(self.password) self._client.set_accepted_certificates( app.cert_store.get_certificates()) @@ -283,6 +288,7 @@ class Client(ConnectionHandlers):
if self._destroy_client: self._client.destroy() + self._client = None self._destroy_client = False self._create_client()
@@ -519,6 +525,7 @@ class Client(ConnectionHandlers):
if self._destroy_client: self._client.destroy() + self._client = None self._destroy_client = False self._create_client()
@@ -529,6 +536,13 @@ class Client(ConnectionHandlers):
def cleanup(self): self._destroyed = True + if self._client is not None: + # cleanup() is called before nbmxpp.Client has disconnected, + # when we disable the account. So we need to unregister + # handlers here. + # TODO: cleanup() should not be called before disconnect is finished + for handler in modules.get_handlers(self): + self._client.unregister_handler(handler) modules.unregister_modules(self)
def quit(self, kill_core):
===================================== gajim/data/gui/account_wizard.ui ===================================== @@ -701,7 +701,6 @@ Creating an account on one server allows you to communicate with contacts from o <object class="GtkCheckButton" id="sign_up_anonymously"> <property name="label" translatable="yes">Sign up Anonymously</property> <property name="visible">True</property> - <property name="sensitive">False</property> <property name="can_focus">True</property> <property name="receives_default">False</property> <property name="tooltip_text" translatable="yes">Note: Anonymous accounts are not possible on all servers</property>
===================================== gajim/gtk/account_wizard.py ===================================== @@ -136,17 +136,29 @@ class AccountWizard(Assistant): if self.get_page('signup').is_advanced(): self.show_page('advanced', Gtk.StackTransitionType.SLIDE_LEFT) + + elif self.get_page('signup').is_anonymous(): + self._test_anonymous_server() + else: self._register_with_server()
elif page == 'advanced': - self._register_with_server() + if self.get_page('signup').is_anonymous(): + self._test_anonymous_server() + else: + self._register_with_server()
elif page == 'security-warning': 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) + + if self.get_page('signup').is_anonymous(): + self._test_anonymous_server(ignore_all_errors=True) + + else: + self._register_with_server(ignore_all_errors=True)
elif page == 'form': self._show_progress_page(_('Creating Account...'), @@ -155,8 +167,6 @@ class AccountWizard(Assistant):
elif button_name == 'connect': if page == 'success': - # if self.get_page('success').is_update(): - # app.interface.show_vcard_when_connect.append(self.account) app.interface.enable_account(self.get_page('success').account) self.destroy()
@@ -279,6 +289,22 @@ class AccountWizard(Assistant):
self._client.connect()
+ def _test_anonymous_server(self, ignore_all_errors=False): + self._show_progress_page(_('Connecting...'), + _('Connecting to server...')) + domain = self.get_page('signup').get_server() + advanced = self.get_page('signup').is_advanced() + + self._client = self._get_base_client( + domain, + None, + Mode.ANONYMOUS_TEST, + advanced, + ignore_all_errors) + + self._client.subscribe('anonymous-supported', self._on_anonymous_supported) + self._client.connect() + def _register_with_server(self, ignore_all_errors=False): self._show_progress_page(_('Connecting...'), _('Connecting to server...')) @@ -315,12 +341,33 @@ class AccountWizard(Assistant): client.get_module('Register').request_register_form( callback=self._on_register_form)
+ def _on_anonymous_supported(self, client, _signal_name): + account = self._generate_account_name(client.domain) + proxy_name = None + if client.proxy is not None: + proxy_name = self.get_page('advanced').get_proxy() + + app.interface.create_account(account, + None, + client.domain, + client.password, + proxy_name, + client.custom_host, + anonymous=True) + self.get_page('success').set_account(account) + self.show_page('success', Gtk.StackTransitionType.SLIDE_LEFT) + def _on_disconnected(self, client, _signal_name): domain, error, text = client.get_error() if domain == StreamError.SASL: - self._show_error_page(_('Authentication failed'), - SASL_ERRORS.get(error), - text or '') + if error == 'anonymous-not-supported': + self._show_error_page(_('Anonymous login not supported'), + _('Anonymous login not supported'), + _('This server does not support anonymous')) + else: + self._show_error_page(_('Authentication failed'), + SASL_ERRORS.get(error), + text or '')
elif domain == StreamError.BAD_CERTIFICATE: self.get_page('security-warning').set_warning(
===================================== gajim/gui_interface.py ===================================== @@ -1615,17 +1615,16 @@ class Interface: custom_host, anonymous=False):
- if not account or not username or not domain: - log.error('Creating account failed: ' - 'account: %s, username: %s, domain: %s', - account, username, domain) - return + account_label = f'{username}@{domain}' + if anonymous: + username = 'anon' + account_label = f'anon@{domain}'
config = {} config['active'] = False config['name'] = username config['resource'] = 'gajim.%s' % helpers.get_random_string(8) - config['account_label'] = '%s@%s' % (username, domain) + config['account_label'] = account_label config['account_color'] = get_color_for_account( '%s@%s' % (username, domain)) config['hostname'] = domain
===================================== win/_base.sh ===================================== @@ -148,6 +148,14 @@ function install_gajim { mkdir "${PACKAGE_DIR}"/gajim/data/plugins 7z x -o"${PACKAGE_DIR}"/gajim/data/plugins "${BUILD_ROOT}"/plugin_installer.zip
+ # Install preview plugin + curl -o "${BUILD_ROOT}"/url_image_preview.zip https://ftp.gajim.org/plugins_1.2_zip/url_image_preview.zip + 7z x -o"${PACKAGE_DIR}"/gajim/data/plugins "${BUILD_ROOT}"/url_image_preview.zip + + # Install omemo plugin + curl -o "${BUILD_ROOT}"/omemo.zip https://ftp.gajim.org/plugins_1.2_zip/omemo.zip + 7z x -o"${PACKAGE_DIR}"/gajim/data/plugins "${BUILD_ROOT}"/omemo.zip + # Install language dicts curl -o "${BUILD_ROOT}"/speller_dicts.zip https://gajim.org/downloads/snap/win/build/speller_dicts.zip 7z x -o"${MINGW_ROOT}"/share "${BUILD_ROOT}"/speller_dicts.zip
View it on GitLab: https://dev.gajim.org/gajim/gajim/-/compare/c2c0828e55a2e48201e9032fcdd9c397...