gloox  1.0.28
featureneg.cpp
1 /*
2  Copyright (c) 2007-2023 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 "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 }
An abstraction of a XEP-0004 Data Form.
Definition: dataform.h:57
virtual Tag * tag() const
Definition: dataform.cpp:106
virtual const std::string & filterString() const
Definition: featureneg.cpp:42
virtual ~FeatureNeg()
Definition: featureneg.cpp:37
FeatureNeg(DataForm *form)
Definition: featureneg.cpp:21
virtual Tag * tag() const
Definition: featureneg.cpp:49
This class abstracts a stanza extension, which is usually an XML child element in a specific namespac...
This is an abstraction of an XML element.
Definition: tag.h:47
const Tag * findTag(const std::string &expression) const
Definition: tag.cpp:805
const std::string xmlns() const
Definition: tag.cpp:543
void addChild(Tag *child)
Definition: tag.cpp:424
const std::string & name() const
Definition: tag.h:394
bool setXmlns(const std::string &xmlns, const std::string &prefix=EmptyString)
Definition: tag.cpp:522
The namespace for the gloox library.
Definition: adhoc.cpp:28
const std::string XMLNS_FEATURE_NEG
Definition: gloox.cpp:33
const std::string XMLNS_X_DATA
Definition: gloox.cpp:49
@ ExtFeatureNeg