From bbcd9c631ca6b47ad07eedc3ded9909045d6cc9e Mon Sep 17 00:00:00 2001 From: mathieui Date: Thu, 26 Jan 2012 17:21:13 +0100 Subject: Add an auto_reconnect option --- data/default_config.cfg | 4 ++++ doc/en/configure.txt | 5 +++++ src/connection.py | 2 +- 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/data/default_config.cfg b/data/default_config.cfg index 9763765b..5284579f 100644 --- a/data/default_config.cfg +++ b/data/default_config.cfg @@ -10,6 +10,10 @@ server = anon.louiz.org # the port you'll use to connect port = 5222 +# Auto-reconnects you when you get disconnected from the server +# defaults to false because it should not be necessary +auto_reconnect = false + # the resource you will use # If it's empty, your resource will be chosen (most likely randomly) by the server # It is not recommended to use a resource that is easy to guess, because it can lead diff --git a/doc/en/configure.txt b/doc/en/configure.txt index 4e93a2c5..1fca2e36 100644 --- a/doc/en/configure.txt +++ b/doc/en/configure.txt @@ -55,6 +55,11 @@ section of this documentation. It is not recommended to use a resource that is easy to guess, because it can lead to presence leak. +*auto_reconnect*:: false + + Auto-reconnects you when you get disconnected. Should not be necessary, so + the default is false. + *default_nick*:: [empty] diff --git a/src/connection.py b/src/connection.py index 352a1d5b..1079b5a6 100644 --- a/src/connection.py +++ b/src/connection.py @@ -42,7 +42,7 @@ class Connection(sleekxmpp.ClientXMPP): password = None sleekxmpp.ClientXMPP.__init__(self, jid, password, ssl=True) self.core = None - self.auto_reconnect = False + self.auto_reconnect = True if config.get('auto_reconnect', 'false').lower() in ('true', '1') else False self.auto_authorize = None self.register_plugin('xep_0030') self.register_plugin('xep_0004') -- cgit v1.2.3 From d77e79cd6bc98aa588ac7112dada67ad0df74e68 Mon Sep 17 00:00:00 2001 From: mathieui Date: Thu, 26 Jan 2012 21:23:14 +0100 Subject: Fixes #2312 (delay element in normal conversations) --- src/core.py | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/core.py b/src/core.py index 1023c748..28ccebba 100644 --- a/src/core.py +++ b/src/core.py @@ -768,20 +768,25 @@ class Core(object): """ jid = message['from'] body = xhtml.get_body_from_message_stanza(message) - conversation = self.get_tab_of_conversation_with_jid(jid, create=False) if not body: if message['type'] == 'error': self.information(self.get_error_message_from_error_stanza(message), 'Error') return conversation = self.get_tab_of_conversation_with_jid(jid, create=True) self.events.trigger('conversation_msg', message, conversation) - body = xhtml.get_body_from_message_stanza(message) if roster.get_contact_by_jid(jid.bare): remote_nick = roster.get_contact_by_jid(jid.bare).name or jid.user else: remote_nick = jid.user - conversation._text_buffer.add_message(body, nickname=remote_nick, nick_color=get_theme().COLOR_REMOTE_USER) - if conversation.remote_wants_chatstates is None: + delay_tag = message.find('{urn:xmpp:delay}delay') + if delay_tag is not None: + delayed = True + date = common.datetime_tuple(delay_tag.attrib['stamp']) + else: + delayed = False + date = None + conversation._text_buffer.add_message(body, date, nickname=remote_nick, nick_color=get_theme().COLOR_REMOTE_USER, history=delayed) + if conversation.remote_wants_chatstates is None and not delayed: if message['chat_state']: conversation.remote_wants_chatstates = True else: -- cgit v1.2.3