Commit b3877221 authored by Philipp Hörist's avatar Philipp Hörist Committed by Philipp Hörist
Browse files

Fix relogin after settings change

parent 1723edcb
......@@ -111,6 +111,7 @@ def features(self):
return self._client.features
def _create_client(self):
log.info('Create new nbxmpp client')
self._client = NBXMPPClient()
self.connection = self._client
self._client.set_domain(self._hostname)
......@@ -178,13 +179,14 @@ def _on_resume_successful(self, _client, _signal_name):
app.nec.push_incoming_event(
OurShowEvent(None, conn=self, show=self._status))
def disconnect(self, gracefully, reconnect):
def disconnect(self, gracefully, reconnect, destroy_client=False):
if self._state.is_disconnecting:
log.warning('Disconnect already in progress')
return
self._set_state(ClientState.DISCONNECTING)
self._reconnect = reconnect
self._destroy_client = destroy_client
log.info('Starting to disconnect %s', self._account)
self._client.disconnect(immediate=not gracefully)
......@@ -308,8 +310,9 @@ def change_status(self, show, msg, auto=False):
if self._state.is_connecting:
if show == 'offline':
self._destroy_client = True
self.disconnect(gracefully=False, reconnect=False)
self.disconnect(gracefully=False,
reconnect=False,
destroy_client=True)
return
if self._state.is_reconnect_scheduled:
......@@ -328,8 +331,9 @@ def change_status(self, show, msg, auto=False):
caps=False)
self.send_stanza(presence)
self._destroy_client = True
self.disconnect(gracefully=True, reconnect=False)
self.disconnect(gracefully=True,
reconnect=False,
destroy_client=True)
return
idle_time = None
......
......@@ -19,7 +19,6 @@
from gi.repository import Gtk
from gi.repository import Gdk
from gi.repository import GLib
from gi.repository import Pango
from gi.repository import GObject
......@@ -111,22 +110,10 @@ def _relog(self, account):
app.connections[app.ZEROCONF_ACC_NAME].update_details()
return
def login(account, show_before, status_before):
"""
Login with previous status
"""
# first make sure connection is really closed,
# 0.5 may not be enough
app.connections[account].disconnect(True)
app.interface.roster.send_status(
account, show_before, status_before)
def relog(account):
show_before = app.connections[account].status
status_before = app.connections[account].status_message
app.interface.roster.send_status(
account, 'offline', _('Be right back.'))
GLib.timeout_add(500, login, account, show_before, status_before)
def relog():
app.connections[account].disconnect(gracefully=True,
reconnect=True,
destroy_client=True)
NewConfirmationDialog(
_('Re-Login'),
......@@ -136,7 +123,7 @@ def relog(account):
text=_('_Later')),
DialogButton.make('Accept',
text=_('_Re-Login'),
callback=lambda *args: relog(account))],
callback=relog)],
transient_for=self).show()
@staticmethod
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment