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

Diff of /smsdaemon/PluginManager.cpp

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

revision 27 by torben, Mon Jun 9 19:22:59 2008 UTC 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"  
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 17  PluginManager::~PluginManager() Line 23  PluginManager::~PluginManager()
23  }  }
24    
25    
26  void PluginManager::LoadPlugins()  void PluginManager::AddPlugin(Plugin* plugin)
27  {  {
28          Common* cmn = Common::instance();          if (plugin != 0)
29            {
30                    if (plugin->IsHelper())
31                    {
32                            _helper_plugins.push_back(plugin);
33                    }
34                    else
35                    {
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
45            {
46                    Logger::logMessage("AddPlugin() -- cannot register a null pointer");
47            }
48    }
49    
50    void PluginManager::LoadPlugins()
51    {
52          static EchoPlugin echo;          static EchoPlugin echo;
53          _plugins[ echo.GetCommand() ] = &echo;  
54                    static SpamPlugin spam;
55    
56            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                  cmn->logMessage( std::string("Loaded plugin \"") + pl->GetCommand() + "\" - " + pl->GetDescription() );                  if (pl != 0)
73                            Logger::logMessage( std::string("Loaded plugin \"") + pl->GetCommand() + "\" - " + pl->GetDescription() );
74          }          }
   
   
75  }  }
76    
77  Plugin* PluginManager::GetPlugin(const std::string& pluginname)  Plugin* PluginManager::GetPlugin(const std::string& pluginname)

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

  ViewVC Help
Powered by ViewVC 1.1.20