changeset 5edf059fa111 in /home/hg/repos/gajim

details:http://hg.gajim.org/gajim?cmd=changeset;node=5edf059fa111
description: request bookmarks via XML if server announce it supports pubsub 
but doesn't answer in the next 30 seconds. Fixes #5198

diffstat:

 src/common/connection.py |  18 ++++++++++++++----
 1 files changed, 14 insertions(+), 4 deletions(-)

diffs (36 lines):

diff -r fe87434867d1 -r 5edf059fa111 src/common/connection.py
--- a/src/common/connection.py  Mon Sep 28 08:20:24 2009 +0300
+++ b/src/common/connection.py  Tue Sep 29 11:08:42 2009 +0200
@@ -1603,6 +1603,16 @@
                iq2.addChild(name='gajim', namespace='gajim:prefs')
                self.connection.send(iq)
 
+       def _request_bookmarks_xml(self):
+               iq = common.xmpp.Iq(typ='get')
+               iq2 = iq.addChild(name='query', 
namespace=common.xmpp.NS_PRIVATE)
+               iq2.addChild(name='storage', namespace='storage:bookmarks')
+               self.connection.send(iq)
+
+       def _check_bookmarks_received(self):
+               if not self.bookmarks:
+                       self._request_bookmarks_xml()
+
        def get_bookmarks(self, storage_type=None):
                '''Get Bookmarks from storage or PubSub if supported as 
described in
                XEP 0048
@@ -1611,11 +1621,11 @@
                        return
                if self.pubsub_supported and storage_type != 'xml':
                        self.send_pb_retrieve('', 'storage:bookmarks')
+                       # some server (ejabberd) are so slow to answer that we 
request via XML
+                       # if we don't get answer in the next 30 seconds
+                       
gajim.idlequeue.set_alarm(self._check_bookmarks_received, 30)
                else:
-                       iq = common.xmpp.Iq(typ='get')
-                       iq2 = iq.addChild(name='query', 
namespace=common.xmpp.NS_PRIVATE)
-                       iq2.addChild(name='storage', 
namespace='storage:bookmarks')
-                       self.connection.send(iq)
+                       self._request_bookmarks_xml()
 
        def store_bookmarks(self, storage_type=None):
                ''' Send bookmarks to the storage namespace or PubSub if 
supported
_______________________________________________
Commits mailing list
[email protected]
http://lists.gajim.org/cgi-bin/listinfo/commits

Reply via email to