featureneg.cpp

00001 /*
00002   Copyright (c) 2007-2009 by Jakob Schroeter <js@camaya.net>
00003   This file is part of the gloox library. http://camaya.net/gloox
00004 
00005   This software is distributed under a license. The full license
00006   agreement can be found in the file LICENSE in this distribution.
00007   This software may not be copied, modified, sold or distributed
00008   other than expressed in the named license agreement.
00009 
00010   This software is distributed without any warranty.
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     t->addChild( m_form->tag() );
00057     return t;
00058   }
00059 
00060 }
Generated on Tue Jun 8 23:37:53 2010 for gloox by  doxygen 1.6.3