gloox  1.0.28
jinglepluginfactory.cpp
1 /*
2  Copyright (c) 2013-2023 by Jakob Schröter <js@camaya.net>
3  This file is part of the gloox library. http://camaya.net/gloox
4 
5  This software is distributed under a license. The full license
6  agreement can be found in the file LICENSE in this distribution.
7  This software may not be copied, modified, sold or distributed
8  other than expressed in the named license agreement.
9 
10  This software is distributed without any warranty.
11 */
12 
13 
14 #include "jinglepluginfactory.h"
15 #include "tag.h"
16 #include "util.h"
17 
18 namespace gloox
19 {
20 
21  namespace Jingle
22  {
23 
24  PluginFactory::PluginFactory()
25  {
26  }
27 
29  {
30  util::clearList( m_plugins );
31  }
32 
34  {
35  if( !plugin )
36  return;
37 
38  plugin->setFactory( this );
39  m_plugins.push_back( plugin );
40  }
41 
42  void PluginFactory::addPlugins( Plugin& plugin, const Tag* tag )
43  {
44  if( !tag )
45  return;
46 
47  ConstTagList::const_iterator it;
48 
49  PluginList::const_iterator itp = m_plugins.begin();
50  for( ; itp != m_plugins.end(); ++itp )
51  {
52  const ConstTagList& match = tag->findTagList( (*itp)->filterString() );
53  it = match.begin();
54  for( ; it != match.end(); ++it )
55  {
56  Plugin* pl = (*itp)->newInstance( (*it) );
57  if( pl )
58  {
59  plugin.addPlugin( pl );
60  }
61  }
62  }
63  }
64 
65  void PluginFactory::addPlugins( Session::Jingle& jingle, const Tag* tag )
66  {
67  if( !tag )
68  return;
69 
70  ConstTagList::const_iterator it;
71 
72  PluginList::const_iterator itp = m_plugins.begin();
73  for( ; itp != m_plugins.end(); ++itp )
74  {
75  const ConstTagList& match = tag->findTagList( (*itp)->filterString() );
76  it = match.begin();
77  for( ; it != match.end(); ++it )
78  {
79  Plugin* pl = (*itp)->newInstance( (*it) );
80  if( pl )
81  {
82  jingle.addPlugin( pl );
83  }
84  }
85  }
86  }
87 
88 
89  }
90 
91 }
void addPlugins(Plugin &plugin, const Tag *tag)
void registerPlugin(Plugin *plugin)
An abstraction of a Jingle plugin. This is part of Jingle (XEP-0166 et al.)
Definition: jingleplugin.h:68
virtual Plugin * newInstance(const Tag *tag) const =0
void addPlugin(const Plugin *plugin)
Definition: jingleplugin.h:87
This is an abstraction of Jingle's (XEP-0166) <jingle> element as a StanzaExtension.
void addPlugin(const Plugin *plugin)
This is an abstraction of an XML element.
Definition: tag.h:47
ConstTagList findTagList(const std::string &expression) const
Definition: tag.cpp:811
void clearList(std::list< T * > &L)
Definition: util.h:152
The namespace for the gloox library.
Definition: adhoc.cpp:28
std::list< const Tag * > ConstTagList
Definition: tag.h:36