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

Diff of /smsdaemon/PluginManager.cpp

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

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

Legend:
Removed from v.54  
changed lines
  Added in v.184

  ViewVC Help
Powered by ViewVC 1.1.20