diff options
Diffstat (limited to 'poezio/bookmarks.py')
-rw-r--r-- | poezio/bookmarks.py | 45 |
1 files changed, 18 insertions, 27 deletions
diff --git a/poezio/bookmarks.py b/poezio/bookmarks.py index d95e8fd5..f62f67ce 100644 --- a/poezio/bookmarks.py +++ b/poezio/bookmarks.py @@ -246,46 +246,37 @@ class BookmarkList: if config.get('use_remote_bookmarks'): self.save_remote(xmpp, _cb) - def get_pep(self, xmpp, callback): + async def get_pep(self, xmpp): """Add the remotely stored bookmarks via pep to the list.""" + iq = await xmpp.plugin['xep_0048'].get_bookmarks(method='xep_0223') + for conf in iq['pubsub']['items']['item']['bookmarks'][ + 'conferences']: + if isinstance(conf, URL): + continue + bookm = Bookmark.parse(conf) + self.append(bookm) + return iq - def _cb(iq): - if iq['type'] == 'result': - for conf in iq['pubsub']['items']['item']['bookmarks'][ - 'conferences']: - if isinstance(conf, URL): - continue - b = Bookmark.parse(conf) - self.append(b) - if callback: - callback(iq) - - xmpp.plugin['xep_0048'].get_bookmarks(method='xep_0223', callback=_cb) - - def get_privatexml(self, xmpp, callback): + async def get_privatexml(self, xmpp): """ Fetch the remote bookmarks stored via privatexml. """ - def _cb(iq): - if iq['type'] == 'result': - for conf in iq['private']['bookmarks']['conferences']: - b = Bookmark.parse(conf) - self.append(b) - if callback: - callback(iq) - - xmpp.plugin['xep_0048'].get_bookmarks(method='xep_0049', callback=_cb) + iq = await xmpp.plugin['xep_0048'].get_bookmarks(method='xep_0049') + for conf in iq['private']['bookmarks']['conferences']: + bookm = Bookmark.parse(conf) + self.append(bookm) + return iq - def get_remote(self, xmpp, information, callback): + async def get_remote(self, xmpp, information): """Add the remotely stored bookmarks to the list.""" if xmpp.anon or not any(self.available_storage.values()): information('No remote bookmark storage available', 'Warning') return if self.preferred == 'pep': - self.get_pep(xmpp, callback=callback) + return await self.get_pep(xmpp) else: - self.get_privatexml(xmpp, callback=callback) + return await self.get_privatexml(xmpp) def get_local(self): """Add the locally stored bookmarks to the list.""" |