--- smsdaemon/plugins/TogPlugin.cpp 2008/08/24 17:57:04 109 +++ smsdaemon/plugins/TogPlugin.cpp 2008/12/18 06:53:29 196 @@ -1,26 +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") + : Plugin("tog", "Henter tog info fra bane.dk") { - _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"); } @@ -50,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); - return; + 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; } @@ -78,7 +85,7 @@ if (code == "") { - modem.SendSms(sms.sender, "Unknown station", false); + modem.SendSms(sms.GetSender(), "Unknown station", false); return; } @@ -87,9 +94,9 @@ { infos = GetTrainInfo( code , "" ); } - catch(std::exception& e) + catch (std::exception& e) { - modem.SendSms(sms.sender, e.what(), false ); + modem.SendSms(sms.GetSender(), e.what(), false ); return; } @@ -105,7 +112,7 @@ os << train.note << "\n"; } - modem.SendSms(sms.sender, Util::str_latin2gsm(os.str()), true); + modem.SendSms(sms.GetSender(), os.str(), true);