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

Diff of /smsdaemon/PluginManager.cpp

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

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

Legend:
Removed from v.45  
changed lines
  Added in v.188

  ViewVC Help
Powered by ViewVC 1.1.20