/[projects]/smsdaemon/PluginManager.cpp
ViewVC logotype

Diff of /smsdaemon/PluginManager.cpp

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 26 by torben, Mon Jun 9 18:15:53 2008 UTC revision 101 by torben, Mon Jun 16 16:41:18 2008 UTC
# Line 3  Line 3 
3    
4  #include "common.h"  #include "common.h"
5    
6  #include "plugins/EchoPlugin.h"  #include "EchoPlugin.h"
7    #include "SpamPlugin.h"
8    #include "ShellExecPlugin.h"
9    #include "TogPlugin.h"
10    #include "StatusPlugin.h"
11    
12  typedef std::map<std::string, Plugin*>::iterator MapIterator;  typedef std::map<std::string, Plugin*>::iterator MapIterator;
13    
# Line 17  PluginManager::~PluginManager() Line 20  PluginManager::~PluginManager()
20  }  }
21    
22    
23    void PluginManager::AddPlugin(Plugin* plugin)
24    {
25            Common* cmn = Common::instance();
26    
27            if (plugin != 0)
28            {
29                    std::string command = plugin->GetCommand();
30    
31                    if ( _plugins[ command ] == 0)
32                            _plugins[ command ] = plugin;
33                    else
34                            cmn->logMessage( std::string("AddPlugin() -- already have a plugin called ") + command);
35            }
36            else
37            {
38                    cmn->logMessage("AddPlugin() -- cannot register a null pointer");
39            }
40    }
41    
42  void PluginManager::LoadPlugins()  void PluginManager::LoadPlugins()
43  {  {
44          Common* cmn = Common::instance();          Common* cmn = Common::instance();
45    
46          static EchoPlugin echo;          static EchoPlugin echo;
47          _plugins[ echo.GetCommand() ] = &echo;  
48                    static SpamPlugin spam;
49    
50            static ShellExecPlugin wake("wake", "/home/torben/bin/wake", false);
51    
52            static TogPlugin tog;
53    
54            static StatusPlugin status;
55    
56          for(MapIterator it = _plugins.begin(); it != _plugins.end(); ++it)          for(MapIterator it = _plugins.begin(); it != _plugins.end(); ++it)
57          {          {
58                  Plugin* pl = (*it).second;                  Plugin* pl = (*it).second;
59                  cmn->logMessage( std::string("Loaded plugin \"") + pl->GetCommand() + "\" - " + pl->GetDescription() );                  if (pl != 0)
60                            cmn->logMessage( std::string("Loaded plugin \"") + pl->GetCommand() + "\" - " + pl->GetDescription() );
61          }          }
   
   
62  }  }
63    
64  Plugin* PluginManager::GetPlugin(const std::string& pluginname)  Plugin* PluginManager::GetPlugin(const std::string& pluginname)

Legend:
Removed from v.26  
changed lines
  Added in v.101

  ViewVC Help
Powered by ViewVC 1.1.20