gloox  1.0.20
xhtmlim.cpp
1 /*
2  Copyright (c) 2007-2017 by Jakob Schröter <js@camaya.net>
3  This file is part of the gloox library. http://camaya.net/gloox
4 
5  This software is distributed under a license. The full license
6  agreement can be found in the file LICENSE in this distribution.
7  This software may not be copied, modified, sold or distributed
8  other than expressed in the named license agreement.
9 
10  This software is distributed without any warranty.
11 */
12 
13 
14 #include "xhtmlim.h"
15 
16 #include "tag.h"
17 
18 namespace gloox
19 {
20 
21  XHtmlIM::XHtmlIM( const Tag* xhtml )
22  : StanzaExtension( ExtXHtmlIM ), m_xhtml( 0 )
23  {
24  if( !xhtml|| xhtml->name() != "html" || xhtml->xmlns() != XMLNS_XHTML_IM )
25  return;
26 
27  if( !xhtml->hasChild( "body", XMLNS, "http://www.w3.org/1999/xhtml" ) )
28  return;
29 
30  m_xhtml = xhtml->clone();
31  }
32 
34  {
35  delete m_xhtml;
36  }
37 
38  const std::string& XHtmlIM::filterString() const
39  {
40  static const std::string filter = "/message/html[@xmlns='" + XMLNS_XHTML_IM + "']";
41  return filter;
42  }
43 
44  Tag* XHtmlIM::tag() const
45  {
46  return m_xhtml->clone();
47  }
48 
50  {
51  XHtmlIM* x = new XHtmlIM();
52  x->m_xhtml = m_xhtml ? m_xhtml->clone() : 0;
53  return x;
54  }
55 
56 }
Tag * clone() const
Definition: tag.cpp:670
const std::string XMLNS
Definition: gloox.cpp:122
const std::string xmlns() const
Definition: tag.cpp:543
virtual StanzaExtension * clone() const
Definition: xhtmlim.cpp:49
XHtmlIM(const Tag *xhtml=0)
Definition: xhtmlim.cpp:21
const std::string & name() const
Definition: tag.h:394
bool hasChild(const std::string &name, const std::string &attr=EmptyString, const std::string &value=EmptyString) const
Definition: tag.cpp:615
virtual ~XHtmlIM()
Definition: xhtmlim.cpp:33
virtual Tag * tag() const
Definition: xhtmlim.cpp:44
The namespace for the gloox library.
Definition: adhoc.cpp:27
This is a wrapper of an XHTML-IM (XEP-0071) message body.
Definition: xhtmlim.h:34
This class abstracts a stanza extension, which is usually an XML child element in a specific namespac...
virtual const std::string & filterString() const
Definition: xhtmlim.cpp:38
const std::string XMLNS_XHTML_IM
Definition: gloox.cpp:36
This is an abstraction of an XML element.
Definition: tag.h:46