2 |
#include "ConfigFile.h" |
#include "ConfigFile.h" |
3 |
#include "Common.h" |
#include "Common.h" |
4 |
#include "Logger.h" |
#include "Logger.h" |
5 |
|
#include "AccessManager.h" |
6 |
|
|
7 |
ProxyTransceiver::ProxyTransceiver(ISmsTransceiver& realtransceiver) |
ProxyTransceiver::ProxyTransceiver(ISmsTransceiver& realtransceiver) |
8 |
: _transceiver(realtransceiver), _hasCC(false) |
: _transceiver(realtransceiver), _hasCC(false) |
9 |
{ |
{ |
10 |
Common* cmn = Common::instance(); |
Common* cmn = Common::instance(); |
11 |
_countrycode = cmn->GetConfigfile()->GetValue("smsdaemon","countrycode").StringValue(); |
_countrycode = cmn->GetConfigfile()->GetValue("smsdaemon","countrycode","").StringValue(); |
12 |
if (_countrycode != "") |
if (_countrycode != "") |
13 |
{ |
{ |
14 |
try |
try |
18 |
_hasCC = true; |
_hasCC = true; |
19 |
} |
} |
20 |
} |
} |
21 |
catch (std::exception&e) |
catch (...) |
22 |
{ |
{ |
23 |
Logger::logMessage( "Invalid country code:" + _countrycode); |
Logger::logMessage( "Invalid country code:" + _countrycode); |
24 |
} |
} |
25 |
} |
} |
26 |
|
if (_hasCC) |
27 |
|
Logger::logMessage( "Enforcing country code: " + _countrycode); |
28 |
|
else |
29 |
|
Logger::logMessage( "No countrycode enforced"); |
30 |
} |
} |
31 |
|
|
32 |
|
|
45 |
if (to.substr(0,_countrycode.size()) != _countrycode) |
if (to.substr(0,_countrycode.size()) != _countrycode) |
46 |
to.insert(0, _countrycode); |
to.insert(0, _countrycode); |
47 |
} |
} |
48 |
|
|
49 |
|
if ( AccessManager::IsBlacklisted(to)) |
50 |
|
{ |
51 |
|
Logger::logMessage( "Will not send message to blacklisted phone: " + to); |
52 |
|
return; |
53 |
|
} |
54 |
|
|
55 |
_transceiver.SendSms(to,message,allowMultipart); |
_transceiver.SendSms(to,message,allowMultipart); |
56 |
} |
} |