Commit 5a5ab81d authored by Philipp Hörist's avatar Philipp Hörist

Adapt connection state checks

parent 13a97cf7
......@@ -137,7 +137,7 @@ def status(self, status, message):
if not app.config.get_per('accounts', connection.name,
'sync_with_global_status'):
continue
if not connection.state.is_connected:
if not connection.state.is_available:
continue
connection.change_status(status, message)
......@@ -151,7 +151,7 @@ def away(self, message):
if not app.config.get_per('accounts', connection.name,
'sync_with_global_status'):
continue
if not connection.state.is_connected:
if not connection.state.is_available:
continue
connection.change_status('away', message)
......@@ -165,7 +165,7 @@ def online(self, message):
if not app.config.get_per('accounts', connection.name,
'sync_with_global_status'):
continue
if not connection.state.is_connected:
if not connection.state.is_available:
continue
connection.change_status('online', message)
......
......@@ -442,7 +442,7 @@ def send_stanza(self, stanza):
return self._client.send_stanza(stanza)
def send_message(self, message):
if not self._state.is_connected:
if not self._state.is_available:
log.warning('Trying to send message while offline')
return
......@@ -477,7 +477,7 @@ def _send_message(self, message):
self.get_module('Message').log_message(message)
def send_messages(self, jids, message):
if not self._state.is_connected:
if not self._state.is_available:
log.warning('Trying to send message while offline')
return
......
......@@ -690,7 +690,7 @@ def get_connection_status(account):
if con.state.is_reconnect_scheduled:
return 'error'
if con.state.is_connecting:
if con.state.is_connecting or con.state.is_connected:
return 'connecting'
if con.state.is_disconnected:
......
......@@ -758,7 +758,7 @@ def _JingleFileTransfer__session_info(self, payload):
def _session_terminate(self, reason=None):
stanza, jingle = self.__make_jingle('session-terminate', reason=reason)
self.__broadcast_all(stanza, jingle, None, 'session-terminate-sent')
if self.connection.connection and self.connection.state.is_connected:
if self.connection.connection and self.connection.state.is_available:
self.connection.connection.send(stanza)
# TODO: Move to GUI?
reason, text = self.__reason_from_stanza(jingle)
......@@ -806,7 +806,7 @@ def __content_modify(self):
def __content_remove(self, content, reason=None):
assert self.state != JingleStates.ENDED
if self.connection.connection and self.connection.state.is_connected:
if self.connection.connection and self.connection.state.is_available:
stanza, jingle = self.__make_jingle('content-remove', reason=reason)
self.__append_content(jingle, content)
self.connection.connection.send(stanza)
......
......@@ -198,7 +198,7 @@ def _update_contact(self, event, properties):
if jid in app.to_be_removed[self._account]:
app.to_be_removed[self._account].remove(jid)
elif event.old_show > 1 and event.new_show == 0 and \
self._con.state.is_connected:
self._con.state.is_available:
if not jid in app.to_be_removed[self._account]:
app.to_be_removed[self._account].append(jid)
if jid in app.newly_added[self._account]:
......
......@@ -89,7 +89,7 @@ def _on_account_disconnected(self, event):
app.interface.remove_account(self.account)
def _set_remove_from_server_checkbox(self):
enabled = self._con is not None and self._con.state.is_connected
enabled = self._con is not None and self._con.state.is_available
self.get_page('remove_choice').set_remove_from_server(enabled)
@staticmethod
......
......@@ -642,5 +642,5 @@ def update_activatable(self, name, value):
activatable = False
if self.account in app.connections:
con = app.connections[self.account]
activatable = con.state.is_connected and con.register_supported
activatable = con.state.is_available and con.register_supported
self.set_activatable(activatable)
......@@ -1959,7 +1959,8 @@ def _network_status_changed(self, monitor, _param):
else:
log.info('Network connection lost')
for connection in app.connections.values():
if connection.state.is_connected:
if (connection.state.is_connected or
connection.state.is_available):
connection.disconnect(gracefully=False, reconnect=True)
def create_zeroconf_default_config(self):
......
......@@ -2501,7 +2501,7 @@ def _nec_presence_received(self, obj):
GLib.timeout_add_seconds(5, self.remove_newly_added, jid,
account)
elif obj.old_show > 1 and obj.new_show == 0 and \
obj.conn.state.is_connected:
obj.conn.state.is_available:
GLib.timeout_add_seconds(5, self.remove_to_be_removed,
jid, account)
......
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