From 58266232280344a18337f4c89c6898c87bfcb009 Mon Sep 17 00:00:00 2001 From: mathieui Date: Sun, 7 Dec 2014 23:37:58 +0100 Subject: Fix the autojoin of bookmarks with passwords --- src/bookmark.py | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/src/bookmark.py b/src/bookmark.py index 15a28c9d..17b12752 100644 --- a/src/bookmark.py +++ b/src/bookmark.py @@ -55,7 +55,7 @@ class Bookmark(object): self._method = value def __repr__(self): - return '<%s%s%s>' % (self.jid, ('/'+self.nick) if self.nick else '', '|autojoin' if self.autojoin else '') + return '<%s%s%s%s>' % (self.jid, ('/'+self.nick) if self.nick else '', '|autojoin' if self.autojoin else '', '|%s' % self.password if self.password else '') def stanza(self): """ @@ -81,11 +81,22 @@ class Bookmark(object): config.set_and_save('password', self.password, section=self.jid) return local + @staticmethod + def parse_from_stanza(el, method=None): + jid = el['jid'] + autojoin = el['autojoin'] + password = el['password'] + nick = el['nick'] + name = el['name'] + return Bookmark(jid, name, autojoin, nick, password, method) + @staticmethod def parse_from_element(el, method=None): """ Generate a Bookmark object from a element """ + if isinstance(el, Conference): + return Bookmark.parse_from_stanza(el, method) jid = el.get('jid') name = el.get('name') autojoin = True if el.get('autojoin', 'false').lower() in ('true', '1') else False @@ -171,7 +182,9 @@ def get_pep(xmpp, available_methods, callback): available_methods["pep"] = False else: available_methods["pep"] = True - for conf in xml_iter(iq.xml, '{storage:bookmarks}conference'): + for conf in iq['pubsub']['items']['item']['bookmarks']['conferences']: + if isinstance(conf, URL): + continue b = Bookmark.parse_from_element(conf, method='pep') if not get_by_jid(b.jid): bookmarks.append(b) @@ -188,7 +201,7 @@ def get_privatexml(xmpp, available_methods, callback): available_methods["privatexml"] = False else: available_methods["privatexml"] = True - for conf in xml_iter(iq.xml, '{storage:bookmarks}conference'): + for conf in iq['private']['bookmarks']['conferences']: b = Bookmark.parse_from_element(conf, method='privatexml') if not get_by_jid(b.jid): bookmarks.append(b) -- cgit v1.2.3