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

Contents of /smsdaemon/ProxyTransceiver.cpp

Parent Directory Parent Directory | Revision Log Revision Log


Revision 211 - (show annotations) (download)
Sun Dec 21 22:08:20 2008 UTC (15 years, 5 months ago) by torben
File size: 1111 byte(s)
Add a Proxy Transceiver to enforce requirements on outgoing messages

1 #include "ProxyTransceiver.h"
2 #include "ConfigFile.h"
3 #include "Common.h"
4 #include "Logger.h"
5
6 ProxyTransceiver::ProxyTransceiver(ISmsTransceiver& realtransceiver)
7 : _transceiver(realtransceiver), _hasCC(false)
8 {
9 Common* cmn = Common::instance();
10 _countrycode = cmn->GetConfigfile()->GetValue("smsdaemon","countrycode").StringValue();
11 if (_countrycode != "")
12 {
13 try
14 {
15 if (ConfigHelper::StringToInt(_countrycode) != 0)
16 {
17 _hasCC = true;
18 }
19 }
20 catch (std::exception&e)
21 {
22 Logger::logMessage( "Invalid country code:" + _countrycode);
23 }
24 }
25 }
26
27
28 void ProxyTransceiver::SendSms(std::string to, std::string message, bool allowMultipart)
29 {
30 unsigned maxLength = allowMultipart ? 900 : 160;
31
32 if (message.size() > maxLength)
33 message = message.substr(0,maxLength);
34
35 if (to.at(0) == '+') //no leading + signs
36 to.erase(0);
37
38 if (_hasCC)
39 {
40 if (to.substr(0,_countrycode.size()) != _countrycode)
41 to.insert(0, _countrycode);
42 }
43
44 _transceiver.SendSms(to,message,allowMultipart);
45 }
46
47 std::vector<SMS> ProxyTransceiver::ReadSms(bool readAll)
48 {
49 return _transceiver.ReadSms(readAll);
50 }

  ViewVC Help
Powered by ViewVC 1.1.20