diff options
author | mathieui <mathieui@mathieui.net> | 2014-12-07 23:37:58 +0100 |
---|---|---|
committer | mathieui <mathieui@mathieui.net> | 2014-12-07 23:37:58 +0100 |
commit | 58266232280344a18337f4c89c6898c87bfcb009 (patch) | |
tree | cb1bb7b5544bfa20d558691f2c0d00cd29cdeb09 | |
parent | 2e46a93215c535dcaba1282acb7424761cb6dfea (diff) | |
download | poezio-58266232280344a18337f4c89c6898c87bfcb009.tar.gz poezio-58266232280344a18337f4c89c6898c87bfcb009.tar.bz2 poezio-58266232280344a18337f4c89c6898c87bfcb009.tar.xz poezio-58266232280344a18337f4c89c6898c87bfcb009.zip |
Fix the autojoin of bookmarks with passwords
-rw-r--r-- | src/bookmark.py | 19 |
1 files 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): """ @@ -82,10 +82,21 @@ class Bookmark(object): 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 <conference/> 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) |