summaryrefslogtreecommitdiff
path: root/sleekxmpp/plugins/google_nosave/stanza.py
diff options
context:
space:
mode:
authorLance Stout <lancestout@gmail.com>2013-01-21 01:39:08 -0800
committerLance Stout <lancestout@gmail.com>2013-01-21 01:39:08 -0800
commit4f9a95b011277ab64a137aceeb4df2e9fc0f1e25 (patch)
tree56c8c707b6bf14ae66e4e68ab2a74bf35b785990 /sleekxmpp/plugins/google_nosave/stanza.py
parent903e641457f30670af36a13b51ef0ab3e611bead (diff)
downloadslixmpp-4f9a95b011277ab64a137aceeb4df2e9fc0f1e25.tar.gz
slixmpp-4f9a95b011277ab64a137aceeb4df2e9fc0f1e25.tar.bz2
slixmpp-4f9a95b011277ab64a137aceeb4df2e9fc0f1e25.tar.xz
slixmpp-4f9a95b011277ab64a137aceeb4df2e9fc0f1e25.zip
Add plugin for Google's nosave feature.
Diffstat (limited to 'sleekxmpp/plugins/google_nosave/stanza.py')
-rw-r--r--sleekxmpp/plugins/google_nosave/stanza.py59
1 files changed, 59 insertions, 0 deletions
diff --git a/sleekxmpp/plugins/google_nosave/stanza.py b/sleekxmpp/plugins/google_nosave/stanza.py
new file mode 100644
index 00000000..d8701322
--- /dev/null
+++ b/sleekxmpp/plugins/google_nosave/stanza.py
@@ -0,0 +1,59 @@
+"""
+ SleekXMPP: The Sleek XMPP Library
+ Copyright (C) 2013 Nathanael C. Fritz, Lance J.T. Stout
+ This file is part of SleekXMPP.
+
+ See the file LICENSE for copying permission.
+"""
+
+from sleekxmpp.jid import JID
+from sleekxmpp.xmlstream import ElementBase, register_stanza_plugin
+
+
+class NoSave(ElementBase):
+ name = 'x'
+ namespace = 'google:nosave'
+ plugin_attrib = 'google_nosave'
+ interfaces = set(['value'])
+
+ def get_value(self):
+ return self._get_attr('value', '') == 'enabled'
+
+ def set_value(self, value):
+ self._set_attr('value', 'enabled' if value else 'disabled')
+
+
+class NoSaveQuery(ElementBase):
+ name = 'query'
+ namespace = 'google:nosave'
+ plugin_attrib = 'google_nosave'
+ interfaces = set()
+
+
+class Item(ElementBase):
+ name = 'item'
+ namespace = 'google:nosave'
+ plugin_attrib = 'item'
+ plugin_multi_attrib = 'items'
+ interfaces = set(['jid', 'source', 'value'])
+
+ def get_value(self):
+ return self._get_attr('value', '') == 'enabled'
+
+ def set_value(self, value):
+ self._set_attr('value', 'enabled' if value else 'disabled')
+
+ def get_jid(self):
+ return JID(self._get_attr('jid', ''))
+
+ def set_jid(self, value):
+ self._set_attr('jid', str(value))
+
+ def get_source(self):
+ return JID(self._get_attr('source', ''))
+
+ def set_source(self):
+ self._set_attr('source', str(value))
+
+
+register_stanza_plugin(NoSaveQuery, Item)