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_0071/__init__.py | 15 +++++++ slixmpp/plugins/xep_0071/stanza.py | 81 ++++++++++++++++++++++++++++++++++++ slixmpp/plugins/xep_0071/xhtml_im.py | 30 +++++++++++++ 3 files changed, 126 insertions(+) create mode 100644 slixmpp/plugins/xep_0071/__init__.py create mode 100644 slixmpp/plugins/xep_0071/stanza.py create mode 100644 slixmpp/plugins/xep_0071/xhtml_im.py (limited to 'slixmpp/plugins/xep_0071') diff --git a/slixmpp/plugins/xep_0071/__init__.py b/slixmpp/plugins/xep_0071/__init__.py new file mode 100644 index 00000000..19275c7a --- /dev/null +++ b/slixmpp/plugins/xep_0071/__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 permissio +""" + +from slixmpp.plugins.base import register_plugin + +from slixmpp.plugins.xep_0071.stanza import XHTML_IM +from slixmpp.plugins.xep_0071.xhtml_im import XEP_0071 + + +register_plugin(XEP_0071) diff --git a/slixmpp/plugins/xep_0071/stanza.py b/slixmpp/plugins/xep_0071/stanza.py new file mode 100644 index 00000000..d997cb3a --- /dev/null +++ b/slixmpp/plugins/xep_0071/stanza.py @@ -0,0 +1,81 @@ +""" + Slixmpp: The Slick XMPP Library + Copyright (C) 2012 Nathanael C. Fritz + This file is part of Slixmpp. + + See the file LICENSE for copying permission. +""" + +from slixmpp.stanza import Message +from slixmpp.util import unicode +from slixmpp.thirdparty import OrderedDict +from slixmpp.xmlstream import ElementBase, ET, register_stanza_plugin, tostring + + +XHTML_NS = 'http://www.w3.org/1999/xhtml' + + +class XHTML_IM(ElementBase): + + namespace = 'http://jabber.org/protocol/xhtml-im' + name = 'html' + interfaces = set(['body']) + lang_interfaces = set(['body']) + plugin_attrib = name + + def set_body(self, content, lang=None): + if lang is None: + lang = self.get_lang() + self.del_body(lang) + if lang == '*': + for sublang, subcontent in content.items(): + self.set_body(subcontent, sublang) + else: + if isinstance(content, type(ET.Element('test'))): + content = unicode(ET.tostring(content)) + else: + content = unicode(content) + header = '