gloox  1.0
xhtmlim.cpp
1 /*
2  Copyright (c) 2007-2009 by Jakob Schroeter <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 0;
54  }
55 
56 }