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

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

  ViewVC Help
Powered by ViewVC 1.1.20