From 1c895e89835c2ef4a53275cdd59e3b668a060bf3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Philipp=20H=C3=B6rist?= Date: Mon, 20 Nov 2017 18:10:51 +0100 Subject: [PATCH] Persist resource across sessions This was somehow lost once we implemented random resource strings Although its good that initally a random resource is chosen, it still should persist across sessions. This helps to kill zombie client connections on the server because most servers kill the old session once a new with the same resource connects Also dont notify the user about resource conflicts if no custom resource is set. We should not expect users to know about resources and what they are used for as long as possible. --- gajim/common/connection.py | 1 + gajim/gui_interface.py | 8 ++++++++ 2 files changed, 9 insertions(+) diff --git a/gajim/common/connection.py b/gajim/common/connection.py index eb0a0294a..dad03fd51 100644 --- a/gajim/common/connection.py +++ b/gajim/common/connection.py @@ -191,6 +191,7 @@ class CommonConnection: 'hostname': socket.gethostname(), 'rand': rand }) + app.config.set_per('accounts', self.name, 'resource', resource) return resource def dispatch(self, event, data): diff --git a/gajim/gui_interface.py b/gajim/gui_interface.py index 192e68468..458a23ac5 100644 --- a/gajim/gui_interface.py +++ b/gajim/gui_interface.py @@ -1162,10 +1162,18 @@ class Interface: account = obj.conn.name conn = obj.conn self.roster.send_status(account, 'offline', conn.status) + def on_ok(new_resource): app.config.set_per('accounts', account, 'resource', new_resource) self.roster.send_status(account, conn.old_show, conn.status) + proposed_resource = conn.server_resource + if proposed_resource.startswith('gajim.'): + # Dont notify the user about resource change if he didnt set + # a custom resource + on_ok('gajim.$rand') + return + proposed_resource += app.config.get('gc_proposed_nick_char') dlg = dialogs.ResourceConflictDialog(_('Resource Conflict'), _('You are already connected to this account with the same '