summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormathieui <mathieui@mathieui.net>2011-11-26 15:47:41 +0100
committermathieui <mathieui@mathieui.net>2011-11-26 15:47:41 +0100
commit2eaa54058921ade7702b71567d709fe589603a61 (patch)
tree210cb285786982b4ba70f218b11215a8a2cd41a8
parentbab0a143a3a6655d4dc18c7188b6be5f24b2352a (diff)
downloadpoezio-2eaa54058921ade7702b71567d709fe589603a61.tar.gz
poezio-2eaa54058921ade7702b71567d709fe589603a61.tar.bz2
poezio-2eaa54058921ade7702b71567d709fe589603a61.tar.xz
poezio-2eaa54058921ade7702b71567d709fe589603a61.zip
Add a Bookmark class
-rw-r--r--src/bookmark.py39
1 files changed, 39 insertions, 0 deletions
diff --git a/src/bookmark.py b/src/bookmark.py
new file mode 100644
index 00000000..fe926350
--- /dev/null
+++ b/src/bookmark.py
@@ -0,0 +1,39 @@
+from sleekxmpp.plugins.xep_0048 import *
+
+class Bookmark(object):
+ possible_methods = ('pep', 'privatexml', 'local')
+ def __init__(self, jid, name=None, autojoin=False, nick=None, password=None, method=None):
+ self.jid = jid
+ self.name = name or jid
+ self.autojoin = autojoin
+ self.nick = nick
+ self.password = password
+ self._method = method
+
+ @property
+ def method(self):
+ return self._method
+
+ @method.setter
+ def method(self, value):
+ if value not in self.possible_methods:
+ return
+ self._method = value
+
+ def stanza(self):
+ """
+ Generate a <conference/> stanza from the instance
+ """
+ el = Conference()
+ el['name'] = self.name
+ el['jid'] = self.jid
+ el['autojoin'] = 'true' if self.autojoin else 'false'
+ if self.nick:
+ n = Nick().xml
+ n.text = self.nick
+ el.append(n)
+ if self.password:
+ p = Password().xml
+ p.text = self.password
+ el.append(p)
+ return el