gloox  1.0.1
featureneg.cpp
1 /*
2  Copyright (c) 2007-2012 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 "featureneg.h"
15 #include "dataform.h"
16 #include "tag.h"
17 
18 namespace gloox
19 {
20 
22  : StanzaExtension( ExtFeatureNeg ), m_form( form )
23  {
24  }
25 
27  : StanzaExtension( ExtFeatureNeg ), m_form( 0 )
28  {
29  if( !tag || tag->name() != "feature" || tag->xmlns() != XMLNS_FEATURE_NEG )
30  return;
31 
32  const Tag* f = tag->findTag( "feature/x[@xmlns='" + XMLNS_X_DATA + "']" );
33  if( f )
34  m_form = new DataForm( f );
35  }
36 
38  {
39  delete m_form;
40  }
41 
42  const std::string& FeatureNeg::filterString() const
43  {
44  static const std::string filter = "/message/feature[@xmlns='" + XMLNS_FEATURE_NEG + "']"
45  "|/iq/feature[@xmlns='" + XMLNS_FEATURE_NEG + "']" ;
46  return filter;
47  }
48 
50  {
51  if( !m_form )
52  return 0;
53 
54  Tag* t = new Tag( "feature" );
56  t->addChild( m_form->tag() );
57  return t;
58  }
59 
60 }