From 79a8c5ceae0cefb34d64172d95dded21872adf02 Mon Sep 17 00:00:00 2001 From: Lance Stout Date: Thu, 18 Oct 2012 21:13:08 -0700 Subject: Add proper XEP-0071 plugin. --- sleekxmpp/plugins/xep_0071/__init__.py | 15 +++++++ sleekxmpp/plugins/xep_0071/stanza.py | 73 ++++++++++++++++++++++++++++++++++ sleekxmpp/plugins/xep_0071/xhtml_im.py | 30 ++++++++++++++ 3 files changed, 118 insertions(+) create mode 100644 sleekxmpp/plugins/xep_0071/__init__.py create mode 100644 sleekxmpp/plugins/xep_0071/stanza.py create mode 100644 sleekxmpp/plugins/xep_0071/xhtml_im.py (limited to 'sleekxmpp/plugins/xep_0071') diff --git a/sleekxmpp/plugins/xep_0071/__init__.py b/sleekxmpp/plugins/xep_0071/__init__.py new file mode 100644 index 00000000..c21e9265 --- /dev/null +++ b/sleekxmpp/plugins/xep_0071/__init__.py @@ -0,0 +1,15 @@ +""" + 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 permissio +""" + +from sleekxmpp.plugins.base import register_plugin + +from sleekxmpp.plugins.xep_0071.stanza import XHTML_IM +from sleekxmpp.plugins.xep_0071.xhtml_im import XEP_0071 + + +register_plugin(XEP_0071) diff --git a/sleekxmpp/plugins/xep_0071/stanza.py b/sleekxmpp/plugins/xep_0071/stanza.py new file mode 100644 index 00000000..77957541 --- /dev/null +++ b/sleekxmpp/plugins/xep_0071/stanza.py @@ -0,0 +1,73 @@ +""" + SleekXMPP: The Sleek XMPP Library + Copyright (C) 2012 Nathanael C. Fritz + This file is part of SleekXMPP. + + See the file LICENSE for copying permission. +""" + +from sleekxmpp.stanza import Message +from sleekxmpp.thirdparty import OrderedDict +from sleekxmpp.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) + content = str(content) + header = '