jinglepluginfactory.cpp
/*
Copyright (c) 2013-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 "jinglepluginfactory.h"
#include "tag.h"
#include "util.h"
namespace gloox
{
namespace Jingle
{
PluginFactory::PluginFactory()
{
}
PluginFactory::~PluginFactory()
{
util::clearList( m_plugins );
}
void PluginFactory::registerPlugin( Plugin* plugin )
{
if( !plugin )
return;
plugin->setFactory( this );
m_plugins.push_back( plugin );
}
void PluginFactory::addPlugins( Plugin& plugin, const Tag* tag )
{
if( !tag )
return;
ConstTagList::const_iterator it;
PluginList::const_iterator itp = m_plugins.begin();
for( ; itp != m_plugins.end(); ++itp )
{
const ConstTagList& match = tag->findTagList( (*itp)->filterString() );
it = match.begin();
for( ; it != match.end(); ++it )
{
Plugin* pl = (*itp)->newInstance( (*it) );
if( pl )
{
plugin.addPlugin( pl );
}
}
}
}
void PluginFactory::addPlugins( Session::Jingle& jingle, const Tag* tag )
{
if( !tag )
return;
ConstTagList::const_iterator it;
PluginList::const_iterator itp = m_plugins.begin();
for( ; itp != m_plugins.end(); ++itp )
{
const ConstTagList& match = tag->findTagList( (*itp)->filterString() );
it = match.begin();
for( ; it != match.end(); ++it )
{
Plugin* pl = (*itp)->newInstance( (*it) );
if( pl )
{
jingle.addPlugin( pl );
}
}
}
}
}
}
gloox::Jingle::PluginFactory::~PluginFactory
virtual ~PluginFactory()
Definition jinglepluginfactory.cpp:28
gloox::Jingle::PluginFactory::addPlugins
void addPlugins(Plugin &plugin, const Tag *tag)
Definition jinglepluginfactory.cpp:42
gloox::Jingle::PluginFactory::registerPlugin
void registerPlugin(Plugin *plugin)
Definition jinglepluginfactory.cpp:33
gloox::Jingle::Plugin
An abstraction of a Jingle plugin. This is part of Jingle (XEP-0166 et al.).
Definition jingleplugin.h:68
gloox::Jingle::Plugin::newInstance
virtual Plugin * newInstance(const Tag *tag) const =0
gloox::Jingle::Plugin::addPlugin
void addPlugin(const Plugin *plugin)
Definition jingleplugin.h:87
gloox::Jingle::Session::Jingle
This is an abstraction of Jingle's (XEP-0166) <jingle> element as a StanzaExtension.
Definition jinglesession.h:199
gloox::Jingle::Session::Jingle::addPlugin
void addPlugin(const Plugin *plugin)
Definition jinglesession.h:243
gloox::Tag
This is an abstraction of an XML element.
Definition tag.h:47
gloox::Tag::findTagList
ConstTagList findTagList(const std::string &expression) const
Definition tag.cpp:811
gloox::Jingle
The namespace containing Jingle-related (XEP-0166 et. al.) classes.
Definition jinglecontent.cpp:22
gloox::util::clearList
void clearList(std::list< T * > &L)
Definition util.h:152
gloox
The namespace for the gloox library.
Definition adhoc.cpp:28
gloox::ConstTagList
std::list< const Tag * > ConstTagList
Definition tag.h:36