00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014 #include "featureneg.h"
00015 #include "dataform.h"
00016 #include "tag.h"
00017
00018 namespace gloox
00019 {
00020
00021 FeatureNeg::FeatureNeg( DataForm* form )
00022 : StanzaExtension( ExtFeatureNeg ), m_form( form )
00023 {
00024 }
00025
00026 FeatureNeg::FeatureNeg( const Tag* tag )
00027 : StanzaExtension( ExtFeatureNeg ), m_form( 0 )
00028 {
00029 if( !tag || tag->name() != "feature" || tag->xmlns() != XMLNS_FEATURE_NEG )
00030 return;
00031
00032 const Tag* f = tag->findTag( "feature/x[@xmlns='" + XMLNS_X_DATA + "']" );
00033 if( f )
00034 m_form = new DataForm( f );
00035 }
00036
00037 FeatureNeg::~FeatureNeg()
00038 {
00039 delete m_form;
00040 }
00041
00042 const std::string& FeatureNeg::filterString() const
00043 {
00044 static const std::string filter = "/message/feature[@xmlns='" + XMLNS_FEATURE_NEG + "']"
00045 "|/iq/feature[@xmlns='" + XMLNS_FEATURE_NEG + "']" ;
00046 return filter;
00047 }
00048
00049 Tag* FeatureNeg::tag() const
00050 {
00051 if( !m_form )
00052 return 0;
00053
00054 Tag* t = new Tag( "feature" );
00055 t->setXmlns( XMLNS_FEATURE_NEG );
00056 if( m_form )
00057 t->addChild( m_form->tag() );
00058 return t;
00059 }
00060
00061 }