diff options
author | Lance Stout <lancestout@gmail.com> | 2013-01-04 03:00:43 -0800 |
---|---|---|
committer | Lance Stout <lancestout@gmail.com> | 2013-01-04 03:00:43 -0800 |
commit | 0e7486d7b49fb3f3c6e573ac972dfadc03c7ca08 (patch) | |
tree | 74f47de958471c492a7d12afe1e59729a52e3909 /sleekxmpp/plugins/xep_0048/stanza.py | |
parent | ef76f923ad885d8faa67e88d76704cbe8253b153 (diff) | |
parent | 6c0afb87b919f1f0321146323e917480851b2d63 (diff) | |
download | slixmpp-0e7486d7b49fb3f3c6e573ac972dfadc03c7ca08.tar.gz slixmpp-0e7486d7b49fb3f3c6e573ac972dfadc03c7ca08.tar.bz2 slixmpp-0e7486d7b49fb3f3c6e573ac972dfadc03c7ca08.tar.xz slixmpp-0e7486d7b49fb3f3c6e573ac972dfadc03c7ca08.zip |
Merge branch 'master' into develop
Diffstat (limited to 'sleekxmpp/plugins/xep_0048/stanza.py')
-rw-r--r-- | sleekxmpp/plugins/xep_0048/stanza.py | 65 |
1 files changed, 65 insertions, 0 deletions
diff --git a/sleekxmpp/plugins/xep_0048/stanza.py b/sleekxmpp/plugins/xep_0048/stanza.py new file mode 100644 index 00000000..2e30eb6a --- /dev/null +++ b/sleekxmpp/plugins/xep_0048/stanza.py @@ -0,0 +1,65 @@ +""" + SleekXMPP: The Sleek XMPP Library + Copyright (C) 2012 Nathanael C. Fritz, Lance J.T. Stout + This file is part of SleekXMPP. + + See the file LICENSE for copying permission. +""" + +from sleekxmpp.xmlstream import ET, ElementBase, register_stanza_plugin + + +class Bookmarks(ElementBase): + name = 'storage' + namespace = 'storage:bookmarks' + plugin_attrib = 'bookmarks' + interfaces = set() + + def add_conference(self, jid, nick, name=None, autojoin=None, password=None): + conf = Conference() + conf['jid'] = jid + conf['nick'] = nick + if name is None: + name = jid + conf['name'] = name + conf['autojoin'] = autojoin + conf['password'] = password + self.append(conf) + + def add_url(self, url, name=None): + saved_url = URL() + saved_url['url'] = url + if name is None: + name = url + saved_url['name'] = name + self.append(saved_url) + + +class Conference(ElementBase): + name = 'conference' + namespace = 'storage:bookmarks' + plugin_attrib = 'conference' + plugin_multi_attrib = 'conferences' + interfaces = set(['nick', 'password', 'autojoin', 'jid', 'name']) + sub_interfaces = set(['nick', 'password']) + + def get_autojoin(self): + value = self._get_attr('autojoin') + return value in ('1', 'true') + + def set_autojoin(self, value): + del self['autojoin'] + if value in ('1', 'true', True): + self._set_sub_text('autojoin', 'true') + + +class URL(ElementBase): + name = 'url' + namespace = 'storage:bookmarks' + plugin_attrib = 'url' + plugin_multi_attrib = 'urls' + interfaces = set(['url', 'name']) + + +register_stanza_plugin(Bookmarks, Conference, iterable=True) +register_stanza_plugin(Bookmarks, URL, iterable=True) |