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

Contents of /smsdaemon/PluginManager.cpp

Parent Directory Parent Directory | Revision Log Revision Log


Revision 132 - (show annotations) (download)
Sun Dec 7 00:59:05 2008 UTC (15 years, 5 months ago) by torben
File size: 1832 byte(s)
Added spooling (queing) function, with a standalone application(smsqueue) to put new messages 
into the spool dir.

1
2 #include "PluginManager.h"
3
4 #include "common.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
13 typedef std::map<std::string, Plugin*>::iterator MapIterator;
14
15 PluginManager::PluginManager()
16 {
17 }
18
19 PluginManager::~PluginManager()
20 {
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()
44 {
45 Common* cmn = Common::instance();
46
47 static EchoPlugin echo;
48
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)
61 {
62 Plugin* pl = (*it).second;
63 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)
69 {
70 return _plugins[ pluginname ];
71 }
72
73
74 std::vector<Plugin*> PluginManager::GetPluginList()
75 {
76 typedef std::map<std::string, Plugin*>::iterator MapIterator;
77 std::vector<Plugin*> plugin_list;
78
79 for (MapIterator it = _plugins.begin(); it != _plugins.end(); ++it)
80 {
81 Plugin* pl = (*it).second;
82 plugin_list.push_back(pl);
83 }
84
85
86 return plugin_list;
87 }

  ViewVC Help
Powered by ViewVC 1.1.20