--- smsdaemon/plugins/TogPlugin.cpp 2008/11/02 20:14:20 114 +++ smsdaemon/plugins/TogPlugin.cpp 2008/12/15 09:27:56 186 @@ -1,27 +1,34 @@ #include "TogPlugin.h" -#include "IGsmModem.h" +#include "ISmsTransceiver.h" #include "Sms.h" #include "TrainInfo.h" -#include "util.h" +#include "Util.h" #include #include -#include "common.h" +#include "Common.h" using namespace std; +StationInfo::StationInfo(std::string c, std::string n) +{ + code = Util::str_characters(c); + name = Util::str_characters(n); +} + + TogPlugin::TogPlugin() : Plugin("tog", "Henter tog info fra bane.dk") { - _stationInfo["ar"] = StationInfo("AR","Århus"); - _stationInfo["la"] = StationInfo("LG","Langå"); + _stationInfo["ar"] = StationInfo("AR","Århus"); + _stationInfo["la"] = StationInfo("LG","Langå"); _stationInfo["ul"] = StationInfo("UP","Ulstrup"); _stationInfo["bj"] = StationInfo("BJ","Bjerringbro"); _stationInfo["vi"] = StationInfo("VG","Viborg"); - _stationInfo["ho"] = StationInfo("HØ","Højslev"); + _stationInfo["ho"] = StationInfo("HØ","Højslev"); _stationInfo["sk"] = StationInfo("SK","Skive"); } @@ -51,26 +58,25 @@ os << (*it).first << " - " << (*it).second.name << "\n"; } - return Util::str_latin2gsm(os.str()); + return os.str(); } -void TogPlugin::Execute(IGsmModem& modem, SMS& sms) +void TogPlugin::Execute(ISmsTransceiver& modem, SMS& sms) { - string data = GetSmsData(sms); + string data = sms.ExtractParameters(); - data = Util::str_gsm2latin(data);; data = Util::str_tolower(data); if (data == "") { - modem.SendSms(sms.sender, "Usage: tog \ntog list - liste over stationer", false); + modem.SendSms(sms.GetSender(), "Usage: tog \ntog list - liste over stationer", false); return; } if (data == "list") { - modem.SendSms(sms.sender, CreateStationList(), true); + modem.SendSms(sms.GetSender(), CreateStationList(), true); return; } @@ -79,7 +85,7 @@ if (code == "") { - modem.SendSms(sms.sender, "Unknown station", false); + modem.SendSms(sms.GetSender(), "Unknown station", false); return; } @@ -90,7 +96,7 @@ } catch(std::exception& e) { - modem.SendSms(sms.sender, e.what(), false ); + modem.SendSms(sms.GetSender(), e.what(), false ); return; } @@ -106,7 +112,7 @@ os << train.note << "\n"; } - modem.SendSms(sms.sender, Util::str_latin2gsm(os.str()), true); + modem.SendSms(sms.GetSender(), os.str(), true);