--- smsdaemon/PluginManager.cpp 2008/06/09 19:22:59 27 +++ smsdaemon/PluginManager.cpp 2008/06/16 16:41:18 101 @@ -4,7 +4,10 @@ #include "common.h" #include "EchoPlugin.h" - +#include "SpamPlugin.h" +#include "ShellExecPlugin.h" +#include "TogPlugin.h" +#include "StatusPlugin.h" typedef std::map::iterator MapIterator; @@ -17,21 +20,45 @@ } +void PluginManager::AddPlugin(Plugin* 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; + + static ShellExecPlugin wake("wake", "/home/torben/bin/wake", false); + + static TogPlugin tog; + + static StatusPlugin status; 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() ); } - - } Plugin* PluginManager::GetPlugin(const std::string& pluginname)