--- smsdaemon/PluginManager.cpp 2008/06/09 20:56:03 28 +++ smsdaemon/PluginManager.cpp 2008/11/02 20:14:20 114 @@ -5,6 +5,10 @@ #include "EchoPlugin.h" #include "SpamPlugin.h" +#include "ShellExecPlugin.h" +#include "TogPlugin.h" +#include "StatusPlugin.h" +#include "ListPlugin.h" typedef std::map::iterator MapIterator; @@ -19,25 +23,45 @@ void PluginManager::AddPlugin(Plugin* plugin) { - _plugins[ plugin->GetCommand() ] = plugin; + Common* cmn = Common::instance(); + + if (plugin != 0) + { + std::string command = plugin->GetCommand(); + + if ( _plugins[ command ] == 0) + _plugins[ command ] = plugin; + else + cmn->logMessage( std::string("AddPlugin() -- already have a plugin called ") + command); + } + else + { + cmn->logMessage("AddPlugin() -- cannot register a null pointer"); + } } void PluginManager::LoadPlugins() { Common* cmn = Common::instance(); - static EchoPlugin echo; - _plugins[ echo.GetCommand() ] = &echo; static SpamPlugin spam; - _plugins[ spam.GetCommand() ] = &spam; - + + static ShellExecPlugin wake("wake", "/home/torben/bin/wake", false, false); + static ShellExecPlugin ping("ping", "nmap -sP 192.168.10.1-255 | grep appears | awk '{print $2}'", false,true); + + static TogPlugin tog; + + static StatusPlugin status; + + static ListPlugin list; for(MapIterator it = _plugins.begin(); it != _plugins.end(); ++it) { Plugin* pl = (*it).second; - cmn->logMessage( std::string("Loaded plugin \"") + pl->GetCommand() + "\" - " + pl->GetDescription() ); + if (pl != 0) + cmn->logMessage( std::string("Loaded plugin \"") + pl->GetCommand() + "\" - " + pl->GetDescription() ); } }