summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authormathieui <mathieui@mathieui.net>2011-11-26 23:07:31 +0100
committermathieui <mathieui@mathieui.net>2011-11-26 23:07:31 +0100
commit1d5b33166362291ccfe101b6f609e551ac03351b (patch)
tree33d5d22ce2313aa4a5621213ab13c4b4c067aa04 /src
parent2f5ecf24b7d4394901389a0ab2f2fe1fd9c37114 (diff)
downloadpoezio-1d5b33166362291ccfe101b6f609e551ac03351b.tar.gz
poezio-1d5b33166362291ccfe101b6f609e551ac03351b.tar.bz2
poezio-1d5b33166362291ccfe101b6f609e551ac03351b.tar.xz
poezio-1d5b33166362291ccfe101b6f609e551ac03351b.zip
Add get_ methods to retrieve bookmarks locally/w/pubsub/privatexml
Diffstat (limited to 'src')
-rw-r--r--src/bookmark.py55
1 files changed, 55 insertions, 0 deletions
diff --git a/src/bookmark.py b/src/bookmark.py
index 66a89830..5f1fe508 100644
--- a/src/bookmark.py
+++ b/src/bookmark.py
@@ -73,3 +73,58 @@ class Bookmark(object):
return Bookmark(jid, name, autojoin, nick, password, method)
+
+bookmarks = []
+
+def get_pep(xmpp):
+ try:
+ iq = xmpp.plugin['xep_0048'].get_bookmarks()
+ except:
+ return False
+ for conf in iq.xml.iter('{storage:bookmarks}conference'):
+ b = Bookmark.parse_from_element(conf, method='pep')
+ if not get_by_jid(b.jid):
+ bookmarks.append(b)
+ return True
+
+def get_privatexml(xmpp):
+ try:
+ iq = xmpp.plugin['xep_0048'].get_bookmarks_old()
+ except:
+ return False
+ for conf in iq.xml.iter('{storage:bookmarks}conference'):
+ b = Bookmark.parse_from_element(conf, method='privatexml')
+ if not get_by_jid(b.jid):
+ bookmarks.append(b)
+ return True
+
+def get_remote(xmpp):
+ if xmpp.anon:
+ return
+ pep, privatexml = True, True
+ for method in methods[1:]:
+ if method == 'pep':
+ pep = get_pep(xmpp)
+ else:
+ privatexml = get_privatexml(xmpp)
+ if pep and not privatexml:
+ config.set_and_save('use_bookmarks_method', 'pep')
+ elif privatexml and not pep:
+ config.set_and_save('use_bookmarks_method', 'privatexml')
+
+def get_local():
+ rooms = config.get('rooms', '')
+ if not rooms:
+ return
+ rooms = rooms.split(':')
+ for room in rooms:
+ jid = JID(room)
+ if jid.bare == '':
+ continue
+ if jid.resource != '':
+ nick = jid.resource
+ else:
+ nick = None
+ b = Bookmark(jid.bare, autojoin=True, nick=nick, method='local')
+ if not get_by_jid(b.jid):
+ bookmarks.append(b)