jinglecontent.cpp
/*
Copyright (c) 2008-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 "jinglecontent.h"
#include "jinglepluginfactory.h"
#include "util.h"
namespace gloox
{
namespace Jingle
{
static const char* creatorValues [] = {
"initiator",
"responder"
};
static inline Content::Creator creatorType( const std::string& type )
{
return static_cast<Content::Creator>( util::lookup( type, creatorValues ) );
}
static const char* sendersValues [] = {
"initiator",
"responder",
"both",
"none"
};
static inline Content::Senders sendersType( const std::string& type )
{
return static_cast<Content::Senders>( util::lookup( type, sendersValues ) );
}
Content::Content( const std::string& name, const PluginList& plugins, Creator creator,
Senders senders, const std::string& disposition )
: Plugin( PluginContent ), m_creator( creator ), m_disposition( disposition ),
m_name( name ), m_senders( senders )
{
m_plugins = plugins;
}
Content::Content( const Tag* tag, PluginFactory* factory )
: Plugin( PluginContent )
{
if( !tag || tag->name() != "content" )
return;
m_name = tag->findAttribute( "name" );
m_creator = static_cast<Creator>( util::lookup( tag->findAttribute( "creator" ), creatorValues ) );
m_senders = static_cast<Senders>( util::lookup( tag->findAttribute( "senders" ), sendersValues ) );
m_disposition = tag->findAttribute( "disposition" );
if( factory )
factory->addPlugins( *this, tag );
}
Content::~Content()
{
}
const std::string& Content::filterString() const
{
static const std::string filter = "jingle/content";
return filter;
}
Tag* Content::tag() const
{
if( m_creator == InvalidCreator || m_name.empty() )
return 0;
Tag* t = new Tag( "content" );
t->addAttribute( "creator", util::lookup( m_creator, creatorValues ) );
t->addAttribute( "disposition", m_disposition );
t->addAttribute( "name", m_name );
t->addAttribute( "senders", util::lookup( m_senders, sendersValues ) );
PluginList::const_iterator it = m_plugins.begin();
for( ; it != m_plugins.end(); ++it )
t->addChild( (*it)->tag() );
return t;
}
Plugin* Content::clone() const
{
return 0;
}
}
}
gloox::Jingle::Content::Creator
Creator
Definition jinglecontent.h:48
gloox::Jingle::Content::InvalidCreator
@ InvalidCreator
Definition jinglecontent.h:51
gloox::Jingle::Content::name
const std::string & name() const
Definition jinglecontent.h:107
gloox::Jingle::Content::creator
Creator creator() const
Definition jinglecontent.h:89
gloox::Jingle::Content::~Content
virtual ~Content()
Definition jinglecontent.cpp:69
gloox::Jingle::Content::clone
virtual Plugin * clone() const
Definition jinglecontent.cpp:97
gloox::Jingle::Content::filterString
virtual const std::string & filterString() const
Definition jinglecontent.cpp:73
gloox::Jingle::Content::Content
Content(const std::string &name, const PluginList &plugins, Creator creator=CInitiator, Senders senders=SBoth, const std::string &disposition="session")
Definition jinglecontent.cpp:46
gloox::Jingle::Content::senders
Senders senders() const
Definition jinglecontent.h:95
gloox::Jingle::Content::disposition
const std::string & disposition() const
Definition jinglecontent.h:101
gloox::Jingle::Content::Senders
Senders
Definition jinglecontent.h:58
gloox::Jingle::Content::tag
virtual Tag * tag() const
Definition jinglecontent.cpp:79
gloox::Jingle::PluginFactory::addPlugins
void addPlugins(Plugin &plugin, const Tag *tag)
Definition jinglepluginfactory.cpp:42
gloox::Jingle::Plugin::Plugin
Plugin(JinglePluginType type)
Definition jingleplugin.h:76
gloox::Jingle::Plugin::plugins
const PluginList & plugins() const
Definition jingleplugin.h:120
gloox::Tag
This is an abstraction of an XML element.
Definition tag.h:47
gloox::Tag::addAttribute
bool addAttribute(Attribute *attr)
Definition tag.cpp:354
gloox::Tag::addChild
void addChild(Tag *child)
Definition tag.cpp:424
gloox::Jingle
The namespace containing Jingle-related (XEP-0166 et. al.) classes.
Definition jinglecontent.cpp:22
gloox::Jingle::PluginContent
@ PluginContent
Definition jingleplugin.h:40
gloox::Jingle::PluginList
std::list< const Plugin * > PluginList
Definition jingleplugin.h:52
gloox
The namespace for the gloox library.
Definition adhoc.cpp:28