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

Diff of /smsdaemon/plugins/UrlTriggerPlugin.cpp

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 204 by torben, Thu Dec 18 06:53:29 2008 UTC revision 205 by torben, Fri Dec 19 22:29:25 2008 UTC
# Line 8  Line 8 
8  #include "Exceptions.h"  #include "Exceptions.h"
9  #include "HttpClient.h"  #include "HttpClient.h"
10  #include <sstream>  #include <sstream>
11    #include <stdexcept>
12    
13  using namespace std;  using namespace std;
14    
15  UrlTriggerPlugin::UrlTriggerPlugin(string cmd, string url)  UrlTriggerPlugin::UrlTriggerPlugin(map<string,string> args)
16                  : Plugin(cmd, string("URL Trigger:")+url ),          : Plugin("", "" )
                 command(cmd), URL(url)  
17  {  {
18    
19            _command = args["trigger"];
20            _URL = args["url"];;
21            _description = string("UrlTrigger(") + _command + ") > " + _URL;
22    
23    
24            if (_command == "" || _URL == "")
25                    throw std::runtime_error("UrlTriggerPlugin usage: plugin = urltrigger trigger=<triggerword>  url=<url>");
26    
27  }  }
28    
29  void UrlTriggerPlugin::Execute(ISmsTransceiver& modem, SMS& sms)  void UrlTriggerPlugin::Execute(ISmsTransceiver& modem, SMS& sms)
30  {  {
31          ostringstream request;          ostringstream request;
32          request << URL << "?";          request << _URL << "?";
33          request << "sender=" << sms.GetSender() << "&";          request << "sender=" << sms.GetSender() << "&";
34          request << "data=" << HttpClient::UrlEncode(sms.ExtractParameters());          request << "data=" << HttpClient::UrlEncode(sms.ExtractParameters());
35    
# Line 35  void UrlTriggerPlugin::Execute(ISmsTrans Line 44  void UrlTriggerPlugin::Execute(ISmsTrans
44          catch (httpexception& e)          catch (httpexception& e)
45          {          {
46                  reply = "Error: Could not execute command";                  reply = "Error: Could not execute command";
47                  Logger::logMessage(string("UrlTrigger failed: ") + command + ">" + e.what() );                  Logger::logMessage(string("UrlTrigger failed: ") + _command + ">" + e.what() );
48          }          }
49    
50          modem.SendSms(sms.GetSender(), reply, true);          modem.SendSms(sms.GetSender(), reply, true);

Legend:
Removed from v.204  
changed lines
  Added in v.205

  ViewVC Help
Powered by ViewVC 1.1.20