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

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

  ViewVC Help
Powered by ViewVC 1.1.20