featureneg.cpp
/*
Copyright (c) 2007-2023 by Jakob Schröter <js@camaya.net>
This file is part of the gloox library. http://camaya.net/gloox
This software is distributed under a license. The full license
agreement can be found in the file LICENSE in this distribution.
This software may not be copied, modified, sold or distributed
other than expressed in the named license agreement.
This software is distributed without any warranty.
*/
#include "featureneg.h"
#include "dataform.h"
#include "tag.h"
namespace gloox
{
FeatureNeg::FeatureNeg( DataForm* form )
: StanzaExtension( ExtFeatureNeg ), m_form( form )
{
}
FeatureNeg::FeatureNeg( const Tag* tag )
: StanzaExtension( ExtFeatureNeg ), m_form( 0 )
{
if( !tag || tag->name() != "feature" || tag->xmlns() != XMLNS_FEATURE_NEG )
return;
const Tag* f = tag->findTag( "feature/x[@xmlns='" + XMLNS_X_DATA + "']" );
if( f )
m_form = new DataForm( f );
}
FeatureNeg::~FeatureNeg()
{
delete m_form;
}
const std::string& FeatureNeg::filterString() const
{
static const std::string filter = "/message/feature[@xmlns='" + XMLNS_FEATURE_NEG + "']"
"|/iq/feature[@xmlns='" + XMLNS_FEATURE_NEG + "']" ;
return filter;
}
Tag* FeatureNeg::tag() const
{
if( !m_form )
return 0;
Tag* t = new Tag( "feature" );
t->setXmlns( XMLNS_FEATURE_NEG );
t->addChild( m_form->tag() );
return t;
}
}
gloox::DataForm
An abstraction of a XEP-0004 Data Form.
Definition dataform.h:57
gloox::FeatureNeg::form
const DataForm * form() const
Definition featureneg.h:59
gloox::FeatureNeg::filterString
virtual const std::string & filterString() const
Definition featureneg.cpp:42
gloox::FeatureNeg::~FeatureNeg
virtual ~FeatureNeg()
Definition featureneg.cpp:37
gloox::FeatureNeg::FeatureNeg
FeatureNeg(DataForm *form)
Definition featureneg.cpp:21
gloox::FeatureNeg::tag
virtual Tag * tag() const
Definition featureneg.cpp:49
gloox::StanzaExtension::StanzaExtension
StanzaExtension(int type)
Definition stanzaextension.h:211
gloox::Tag
This is an abstraction of an XML element.
Definition tag.h:47
gloox::Tag::addChild
void addChild(Tag *child)
Definition tag.cpp:424
gloox::Tag::setXmlns
bool setXmlns(const std::string &xmlns, const std::string &prefix=EmptyString)
Definition tag.cpp:522
gloox
The namespace for the gloox library.
Definition adhoc.cpp:28
gloox::XMLNS_FEATURE_NEG
const std::string XMLNS_FEATURE_NEG
Definition gloox.cpp:33
gloox::XMLNS_X_DATA
const std::string XMLNS_X_DATA
Definition gloox.cpp:49
gloox::ExtFeatureNeg
@ ExtFeatureNeg
Definition stanzaextension.h:65