diff options
Diffstat (limited to 'src/connection.py')
-rw-r--r-- | src/connection.py | 38 |
1 files changed, 17 insertions, 21 deletions
diff --git a/src/connection.py b/src/connection.py index dc35dd94..1bbe632d 100644 --- a/src/connection.py +++ b/src/connection.py @@ -14,15 +14,15 @@ log = logging.getLogger(__name__) import getpass -import sleekxmpp -from sleekxmpp.plugins.xep_0184 import XEP_0184 +import slixmpp +from slixmpp.plugins.xep_0184 import XEP_0184 import common import fixes from common import safeJID from config import config, options -class Connection(sleekxmpp.ClientXMPP): +class Connection(slixmpp.ClientXMPP): """ Receives everything from Jabber and emits the appropriate signals @@ -47,7 +47,7 @@ class Connection(sleekxmpp.ClientXMPP): password = None jid = safeJID(jid) # TODO: use the system language - sleekxmpp.ClientXMPP.__init__(self, jid, password, + slixmpp.ClientXMPP.__init__(self, jid, password, lang=config.get('lang')) force_encryption = config.get('force_encryption') @@ -95,7 +95,6 @@ class Connection(sleekxmpp.ClientXMPP): self.register_plugin('xep_0191') self.register_plugin('xep_0199') - self.set_keepalive_values() if config.get('enable_user_tune'): self.register_plugin('xep_0118') @@ -131,14 +130,18 @@ class Connection(sleekxmpp.ClientXMPP): self.register_plugin('xep_0280') self.register_plugin('xep_0297') self.register_plugin('xep_0308') + self.init_plugins() def set_keepalive_values(self, option=None, value=None): """ - Called at startup, or triggered when one of + Called after the XMPP session has been started, or triggered when one of "connection_timeout_delay" and "connection_check_interval" options - is changed. - Unload and reload the ping plugin, with the new values. + is changed. Unload and reload the ping plugin, with the new values. """ + if not self.is_connected(): + # Happens when we change the value with /set while we are not + # connected. Do nothing in that case + return ping_interval = config.get('connection_check_interval') timeout_delay = config.get('connection_timeout_delay') if timeout_delay <= 0: @@ -156,34 +159,27 @@ class Connection(sleekxmpp.ClientXMPP): def start(self): """ Connect and process events. - - TODO: try multiple servers with anon auth. """ custom_host = config.get('custom_host') custom_port = config.get('custom_port', 5222) if custom_port == -1: custom_port = 5222 if custom_host: - res = self.connect((custom_host, custom_port), reattempt=True) + self.connect((custom_host, custom_port)) elif custom_port != 5222 and custom_port != -1: - res = self.connect((self.boundjid.host, custom_port), - reattempt=True) + self.connect((self.boundjid.host, custom_port)) else: - res = self.connect(reattempt=True) - if not res: - return False - self.process(threaded=True) - return True + self.connect() - def send_raw(self, data, now=False, reconnect=None): + def send_raw(self, data): """ Overrides XMLStream.send_raw, with an event added """ if self.core: self.core.outgoing_stanza(data) - sleekxmpp.ClientXMPP.send_raw(self, data, now, reconnect) + slixmpp.ClientXMPP.send_raw(self, data) -class MatchAll(sleekxmpp.xmlstream.matcher.base.MatcherBase): +class MatchAll(slixmpp.xmlstream.matcher.base.MatcherBase): """ Callback to retrieve all the stanzas for the XML tab """ |