jingleplugin.h
/*
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.
*/
#ifndef JINGLEPLUGIN_H__
#define JINGLEPLUGIN_H__
#include "macros.h"
#include "util.h"
#include <string>
#include <list>
namespace gloox
{
class Tag;
namespace Jingle
{
class Plugin;
class PluginFactory;
enum JinglePluginType
{
PluginNone,
PluginContent,
PluginFileTransfer,
PluginICEUDP,
PluginReason,
PluginUser
};
typedef std::list<const Plugin*> PluginList;
class GLOOX_API Plugin
{
friend class PluginFactory;
public:
Plugin( JinglePluginType type ) : m_factory( 0 ), m_pluginType( type ) {}
virtual ~Plugin() { util::clearList( m_plugins ) ; }
void addPlugin( const Plugin* plugin ) { if( plugin ) m_plugins.push_back( plugin ); }
const Plugin* findPlugin( int type ) const
{
PluginList::const_iterator it = m_plugins.begin();
for( ; it != m_plugins.end() && (*it)->pluginType() != type; ++it ) ;
return it != m_plugins.end() ? (*it) : 0;
}
template< class T >
inline const T* findPlugin( int type ) const
{
return static_cast<const T*>( findPlugin( type ) );
}
const PluginList& plugins() const { return m_plugins; }
virtual const StringList features() const { return StringList(); }
virtual const std::string& filterString() const = 0;
virtual Tag* tag() const = 0;
virtual Plugin* newInstance( const Tag* tag ) const = 0;
virtual Plugin* clone() const = 0;
JinglePluginType pluginType() const { return m_pluginType; }
protected:
PluginList m_plugins;
PluginFactory* m_factory;
private:
void setFactory( PluginFactory* factory ) { m_factory = factory; }
JinglePluginType m_pluginType;
};
}
}
#endif // JINGLEPLUGIN_H__
gloox::Jingle::PluginFactory
A factory for which creates Plugin instances based on Tags. This is part of Jingle (XEP-0166).
Definition jinglepluginfactory.h:37
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::features
virtual const StringList features() const
Definition jingleplugin.h:127
gloox::Jingle::Plugin::findPlugin
const Plugin * findPlugin(int type) const
Definition jingleplugin.h:94
gloox::Jingle::Plugin::pluginType
JinglePluginType pluginType() const
Definition jingleplugin.h:162
gloox::Jingle::Plugin::Plugin
Plugin(JinglePluginType type)
Definition jingleplugin.h:76
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::Plugin::tag
virtual Tag * tag() const =0
gloox::Jingle::Plugin::plugins
const PluginList & plugins() const
Definition jingleplugin.h:120
gloox::Jingle::Plugin::filterString
virtual const std::string & filterString() const =0
gloox::Jingle::Plugin::~Plugin
virtual ~Plugin()
Definition jingleplugin.h:81
gloox::Jingle::Plugin::clone
virtual Plugin * clone() const =0
gloox::Jingle::Plugin::findPlugin
const T * findPlugin(int type) const
Definition jingleplugin.h:111
gloox::Tag
This is an abstraction of an XML element.
Definition tag.h:47
gloox::Jingle
The namespace containing Jingle-related (XEP-0166 et. al.) classes.
Definition jinglecontent.cpp:22
gloox::Jingle::JinglePluginType
JinglePluginType
Definition jingleplugin.h:38
gloox::Jingle::PluginICEUDP
@ PluginICEUDP
Definition jingleplugin.h:42
gloox::Jingle::PluginUser
@ PluginUser
Definition jingleplugin.h:44
gloox::Jingle::PluginContent
@ PluginContent
Definition jingleplugin.h:40
gloox::Jingle::PluginFileTransfer
@ PluginFileTransfer
Definition jingleplugin.h:41
gloox::Jingle::PluginReason
@ PluginReason
Definition jingleplugin.h:43
gloox::Jingle::PluginNone
@ PluginNone
Definition jingleplugin.h:39
gloox::Jingle::PluginList
std::list< const Plugin * > PluginList
Definition jingleplugin.h:52
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::StringList
std::list< std::string > StringList
Definition gloox.h:1251