--- smsdaemon/PluginManager.cpp 2008/06/09 19:22:59 27 +++ smsdaemon/PluginManager.cpp 2008/12/17 23:43:26 193 @@ -1,10 +1,17 @@ #include "PluginManager.h" -#include "common.h" - -#include "EchoPlugin.h" +#include "Logger.h" +#include "plugins/EchoPlugin.h" +#include "plugins/SpamPlugin.h" +#include "plugins/ShellExecPlugin.h" +#include "plugins/TogPlugin.h" +#include "plugins/StatusPlugin.h" +#include "plugins/ListPlugin.h" +#include "plugins/HostStatusPlugin.h" +#include "plugins/WeatherPlugin.h" +#include "plugins/UrlTriggerPlugin.h" typedef std::map::iterator MapIterator; @@ -17,21 +24,57 @@ } -void PluginManager::LoadPlugins() +void PluginManager::AddPlugin(Plugin* plugin) { - Common* cmn = Common::instance(); + if (plugin != 0) + { + if (plugin->IsHelper()) + { + _helper_plugins.push_back(plugin); + } + else + { + std::string command = plugin->GetCommand(); + + if ( _plugins[ command ] == 0) + _plugins[ command ] = plugin; + else + Logger::logMessage( std::string("AddPlugin() -- already have a plugin called ") + command); + } + } + else + { + Logger::logMessage("AddPlugin() -- cannot register a null pointer"); + } +} +void PluginManager::LoadPlugins() +{ static EchoPlugin echo; - _plugins[ echo.GetCommand() ] = &echo; - + + static SpamPlugin 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; + + static HostStatusPlugin hoststatus; + + static WeatherPlugin weather; + + static UrlTriggerPlugin urltrigger("tou", "http://t-hoerup.dk/test.php"); 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) + Logger::logMessage( std::string("Loaded plugin \"") + pl->GetCommand() + "\" - " + pl->GetDescription() ); } - - } Plugin* PluginManager::GetPlugin(const std::string& pluginname)