/[projects]/smsdaemon/plugins/ShellExecPlugin.cpp
ViewVC logotype

Annotation of /smsdaemon/plugins/ShellExecPlugin.cpp

Parent Directory Parent Directory | Revision Log Revision Log


Revision 35 - (hide annotations) (download)
Tue Jun 10 14:38:59 2008 UTC (15 years, 11 months ago) by torben
File size: 619 byte(s)
Finished PluginManager::AddPlugin() so that the plugins can register them selves.

Added a plugin for executing an external program.


1 torben 35 #include "ShellExecPlugin.h"
2     #include "GsmModem.h"
3    
4     #include "util.h"
5    
6     ShellExecPlugin::ShellExecPlugin(std::string pluginCommand, std::string exeCommand)
7     : Plugin(pluginCommand, std::string("ShellExec: ")+exeCommand ),
8     _exeCommand(exeCommand)
9     {
10     }
11    
12     void ShellExecPlugin::Execute(GsmModem& modem, SMS& sms)
13     {
14     std::string parameters = GetSmsData(sms);
15     Util::str_clean(&parameters,";");
16    
17     std::string command = _exeCommand + " " + parameters;
18     int retval = ::system( command.c_str() );
19    
20     std::string message;
21     if (retval == -1)
22     message = "Error";
23     else
24     message = "OK";
25    
26     modem.SendSms(sms.sender, message );
27     }

  ViewVC Help
Powered by ViewVC 1.1.20