request bookmarks via XML if server announce it supports pubsub but doesn't answer in the next 30 seconds. Fixes #5198

This commit is contained in:
Yann Leboulanger 2009-09-29 11:08:42 +02:00
parent c5b63d948d
commit 4d8454a242
1 changed files with 14 additions and 4 deletions

View File

@ -1603,6 +1603,16 @@ class Connection(ConnectionHandlers):
iq2.addChild(name='gajim', namespace='gajim:prefs') iq2.addChild(name='gajim', namespace='gajim:prefs')
self.connection.send(iq) 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): def get_bookmarks(self, storage_type=None):
'''Get Bookmarks from storage or PubSub if supported as described in '''Get Bookmarks from storage or PubSub if supported as described in
XEP 0048 XEP 0048
@ -1611,11 +1621,11 @@ class Connection(ConnectionHandlers):
return return
if self.pubsub_supported and storage_type != 'xml': if self.pubsub_supported and storage_type != 'xml':
self.send_pb_retrieve('', 'storage:bookmarks') 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: else:
iq = common.xmpp.Iq(typ='get') self._request_bookmarks_xml()
iq2 = iq.addChild(name='query', namespace=common.xmpp.NS_PRIVATE)
iq2.addChild(name='storage', namespace='storage:bookmarks')
self.connection.send(iq)
def store_bookmarks(self, storage_type=None): def store_bookmarks(self, storage_type=None):
''' Send bookmarks to the storage namespace or PubSub if supported ''' Send bookmarks to the storage namespace or PubSub if supported