2010-03-26 21:32:16 +00:00
|
|
|
"""
|
|
|
|
SleekXMPP: The Sleek XMPP Library
|
|
|
|
Copyright (C) 2010 Nathanael C. Fritz
|
|
|
|
This file is part of SleekXMPP.
|
|
|
|
|
|
|
|
See the file license.txt for copying permission.
|
|
|
|
"""
|
2010-07-19 17:58:53 +00:00
|
|
|
from .. xmlstream.stanzabase import registerStanzaPlugin, ElementBase, ET
|
2009-12-15 04:37:10 +00:00
|
|
|
|
|
|
|
class HTMLIM(ElementBase):
|
|
|
|
namespace = 'http://jabber.org/protocol/xhtml-im'
|
|
|
|
name = 'html'
|
|
|
|
plugin_attrib = 'html'
|
2010-04-08 06:56:44 +00:00
|
|
|
interfaces = set(('html',))
|
2009-12-17 01:54:22 +00:00
|
|
|
plugin_attrib_map = set()
|
|
|
|
plugin_xml_map = set()
|
2009-12-15 04:37:10 +00:00
|
|
|
|
|
|
|
def setHtml(self, html):
|
2010-04-08 06:56:44 +00:00
|
|
|
if isinstance(html, str):
|
2009-12-15 04:37:10 +00:00
|
|
|
html = ET.XML(html)
|
2010-04-08 06:56:44 +00:00
|
|
|
if html.tag != '{http://www.w3.org/1999/xhtml}body':
|
2009-12-15 04:37:10 +00:00
|
|
|
body = ET.Element('{http://www.w3.org/1999/xhtml}body')
|
|
|
|
body.append(html)
|
2010-04-08 06:56:44 +00:00
|
|
|
self.xml.append(body)
|
2009-12-15 04:37:10 +00:00
|
|
|
else:
|
2010-04-08 06:56:44 +00:00
|
|
|
self.xml.append(html)
|
2009-12-15 04:37:10 +00:00
|
|
|
|
|
|
|
def getHtml(self):
|
|
|
|
html = self.xml.find('{http://www.w3.org/1999/xhtml}body')
|
|
|
|
if html is None: return ''
|
2010-04-08 06:56:44 +00:00
|
|
|
return html
|
2009-12-15 04:37:10 +00:00
|
|
|
|
|
|
|
def delHtml(self):
|
2010-05-12 20:45:36 +00:00
|
|
|
if self.parent is not None:
|
|
|
|
self.parent().xml.remove(self.xml)
|