From 5ab77c745270d7d5c016c1dc7ef2a82533a4b16e Mon Sep 17 00:00:00 2001 From: Florent Le Coz Date: Thu, 17 Jul 2014 14:19:04 +0200 Subject: Rename to slixmpp --- slixmpp/plugins/xep_0049/__init__.py | 15 ++++++++ slixmpp/plugins/xep_0049/private_storage.py | 53 +++++++++++++++++++++++++++++ slixmpp/plugins/xep_0049/stanza.py | 17 +++++++++ 3 files changed, 85 insertions(+) create mode 100644 slixmpp/plugins/xep_0049/__init__.py create mode 100644 slixmpp/plugins/xep_0049/private_storage.py create mode 100644 slixmpp/plugins/xep_0049/stanza.py (limited to 'slixmpp/plugins/xep_0049') diff --git a/slixmpp/plugins/xep_0049/__init__.py b/slixmpp/plugins/xep_0049/__init__.py new file mode 100644 index 00000000..396be75d --- /dev/null +++ b/slixmpp/plugins/xep_0049/__init__.py @@ -0,0 +1,15 @@ +""" + Slixmpp: The Slick XMPP Library + Copyright (C) 2012 Nathanael C. Fritz, Lance J.T. Stout + This file is part of Slixmpp. + + See the file LICENSE for copying permission. +""" + +from slixmpp.plugins.base import register_plugin + +from slixmpp.plugins.xep_0049.stanza import PrivateXML +from slixmpp.plugins.xep_0049.private_storage import XEP_0049 + + +register_plugin(XEP_0049) diff --git a/slixmpp/plugins/xep_0049/private_storage.py b/slixmpp/plugins/xep_0049/private_storage.py new file mode 100644 index 00000000..99a04fe9 --- /dev/null +++ b/slixmpp/plugins/xep_0049/private_storage.py @@ -0,0 +1,53 @@ +""" + Slixmpp: The Slick XMPP Library + Copyright (C) 2012 Nathanael C. Fritz, Lance J.T. Stout + This file is part of Slixmpp. + + See the file LICENSE for copying permission. +""" + +import logging + +from slixmpp import Iq +from slixmpp.plugins import BasePlugin +from slixmpp.xmlstream.handler import Callback +from slixmpp.xmlstream.matcher import StanzaPath +from slixmpp.xmlstream import register_stanza_plugin +from slixmpp.plugins.xep_0049 import stanza, PrivateXML + + +log = logging.getLogger(__name__) + + +class XEP_0049(BasePlugin): + + name = 'xep_0049' + description = 'XEP-0049: Private XML Storage' + dependencies = set([]) + stanza = stanza + + def plugin_init(self): + register_stanza_plugin(Iq, PrivateXML) + + def register(self, stanza): + register_stanza_plugin(PrivateXML, stanza, iterable=True) + + def store(self, data, ifrom=None, block=True, timeout=None, callback=None): + iq = self.xmpp.Iq() + iq['type'] = 'set' + iq['from'] = ifrom + + if not isinstance(data, list): + data = [data] + + for elem in data: + iq['private'].append(elem) + + return iq.send(block=block, timeout=timeout, callback=callback) + + def retrieve(self, name, ifrom=None, block=True, timeout=None, callback=None): + iq = self.xmpp.Iq() + iq['type'] = 'get' + iq['from'] = ifrom + iq['private'].enable(name) + return iq.send(block=block, timeout=timeout, callback=callback) diff --git a/slixmpp/plugins/xep_0049/stanza.py b/slixmpp/plugins/xep_0049/stanza.py new file mode 100644 index 00000000..a8d425ba --- /dev/null +++ b/slixmpp/plugins/xep_0049/stanza.py @@ -0,0 +1,17 @@ +""" + Slixmpp: The Slick XMPP Library + Copyright (C) 2012 Nathanael C. Fritz, Lance J.T. Stout + This file is part of Slixmpp. + + See the file LICENSE for copying permission. +""" + +from slixmpp.xmlstream import ET, ElementBase + + +class PrivateXML(ElementBase): + + name = 'query' + namespace = 'jabber:iq:private' + plugin_attrib = 'private' + interfaces = set() -- cgit v1.2.3