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

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

  ViewVC Help
Powered by ViewVC 1.1.20