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

Diff of /smsdaemon/PluginManager.cpp

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

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

Legend:
Removed from v.28  
changed lines
  Added in v.137

  ViewVC Help
Powered by ViewVC 1.1.20