/[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 137 by torben, Sun Dec 7 11:08:31 2008 UTC
# Line 4  Line 4 
4  #include "common.h"  #include "common.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::AddPlugin(Plugin* plugin)
26    {
27            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;
49          _plugins[ echo.GetCommand() ] = &echo;  
50                    static SpamPlugin spam;
51    
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    
71  Plugin* PluginManager::GetPlugin(const std::string& pluginname)  Plugin* PluginManager::GetPlugin(const std::string& pluginname)

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

  ViewVC Help
Powered by ViewVC 1.1.20