From 9282678d8c47e27cf2c1fcba6801a0c8a4035b2d Mon Sep 17 00:00:00 2001
From: Yann Leboulanger <asterix@lagaule.org>
Date: Wed, 11 Aug 2010 20:12:11 +0200
Subject: [PATCH] request message archiving only if server supports it.

---
 src/common/connection.py          |  1 +
 src/common/connection_handlers.py |  2 ++
 src/gui_interface.py              | 11 ++++++-----
 3 files changed, 9 insertions(+), 5 deletions(-)

diff --git a/src/common/connection.py b/src/common/connection.py
index 55593c9e35..0551b8d27e 100644
--- a/src/common/connection.py
+++ b/src/common/connection.py
@@ -153,6 +153,7 @@ class CommonConnection:
         self.privacy_rules_supported = False
         self.vcard_supported = False
         self.private_storage_supported = False
+        self.archiving_supported = False
         self.archive_pref_supported = False
 
         self.muc_jid = {} # jid of muc server for each transport type
diff --git a/src/common/connection_handlers.py b/src/common/connection_handlers.py
index 9ab7128187..f471907ccb 100644
--- a/src/common/connection_handlers.py
+++ b/src/common/connection_handlers.py
@@ -368,6 +368,8 @@ class ConnectionDisco:
                     our_jid = gajim.get_jid_from_account(self.name)
                     self.send_pb_purge(our_jid, 'storage:bookmarks')
                     self.send_pb_delete(our_jid, 'storage:bookmarks')
+            if features.__contains__(common.xmpp.NS_ARCHIVE):
+                self.archiving_supported = True
             if features.__contains__(common.xmpp.NS_ARCHIVE_AUTO):
                 self.archive_auto_supported = True
             if features.__contains__(common.xmpp.NS_ARCHIVE_MANAGE):
diff --git a/src/gui_interface.py b/src/gui_interface.py
index ac235fa0a3..856222ada0 100644
--- a/src/gui_interface.py
+++ b/src/gui_interface.py
@@ -1573,11 +1573,12 @@ class Interface:
         if gajim.connections[account].pep_supported and dbus_support.supported \
         and gajim.config.get_per('accounts', account, 'publish_location'):
             location_listener.enable()
-        # Start merging logs from server
-        gajim.connections[account].request_modifications_page(
-            gajim.config.get_per('accounts', account, 'last_archiving_time'))
-        gajim.config.set_per('accounts', account, 'last_archiving_time',
-            time.strftime('%Y-%m-%dT%H:%M:%SZ', time.gmtime()))
+        if gajim.connections[account].archiving_supported:
+            # Start merging logs from server
+            gajim.connections[account].request_modifications_page(
+                gajim.config.get_per('accounts', account, 'last_archiving_time'))
+            gajim.config.set_per('accounts', account, 'last_archiving_time',
+                time.strftime('%Y-%m-%dT%H:%M:%SZ', time.gmtime()))
 
     def handle_event_metacontacts(self, account, tags_list):
         gajim.contacts.define_metacontacts(account, tags_list)
-- 
GitLab