1 |
#include "TogPlugin.h" |
#include "TogPlugin.h" |
2 |
#include "GsmModem.h" |
#include "IGsmModem.h" |
3 |
|
#include "Sms.h" |
4 |
|
|
5 |
#include "TrainInfo.h" |
#include "TrainInfo.h" |
6 |
#include "util.h" |
#include "util.h" |
16 |
TogPlugin::TogPlugin() |
TogPlugin::TogPlugin() |
17 |
: Plugin("tog", "Henter tog info fra bane.dk") |
: Plugin("tog", "Henter tog info fra bane.dk") |
18 |
{ |
{ |
19 |
|
_stationInfo["ar"] = StationInfo("AR","Århus"); |
20 |
_stationInfo["la"] = StationInfo("LG","Langå"); |
_stationInfo["la"] = StationInfo("LG","Langå"); |
21 |
_stationInfo["ul"] = StationInfo("UP","Ulstrup"); |
_stationInfo["ul"] = StationInfo("UP","Ulstrup"); |
22 |
_stationInfo["bj"] = StationInfo("BJ","Bjerringbro"); |
_stationInfo["bj"] = StationInfo("BJ","Bjerringbro"); |
23 |
_stationInfo["vi"] = StationInfo("VG","Viborg"); |
_stationInfo["vi"] = StationInfo("VG","Viborg"); |
24 |
_stationInfo["hø"] = StationInfo("HØ","Højslev"); |
_stationInfo["ho"] = StationInfo("HØ","Højslev"); |
25 |
_stationInfo["sk"] = StationInfo("SK","Skive"); |
_stationInfo["sk"] = StationInfo("SK","Skive"); |
26 |
} |
} |
27 |
|
|
51 |
os << (*it).first << " - " << (*it).second.name << "\n"; |
os << (*it).first << " - " << (*it).second.name << "\n"; |
52 |
} |
} |
53 |
|
|
54 |
return Util::str_latin2gsm(os.str()); |
return os.str(); |
55 |
} |
} |
56 |
|
|
57 |
void TogPlugin::Execute(IGsmModem& modem, SMS& sms) |
void TogPlugin::Execute(IGsmModem& modem, SMS& sms) |
61 |
data = Util::str_gsm2latin(data);; |
data = Util::str_gsm2latin(data);; |
62 |
data = Util::str_tolower(data); |
data = Util::str_tolower(data); |
63 |
|
|
64 |
|
|
65 |
if (data == "") |
if (data == "") |
66 |
{ |
{ |
67 |
modem.SendSms(sms.sender, "Usage: tog <stationskode>\ntog list - liste over stationer", false); |
modem.SendSms(sms.sender, "Usage: tog <stationskode>\ntog list - liste over stationer", false); |
106 |
os << train.note << "\n"; |
os << train.note << "\n"; |
107 |
} |
} |
108 |
|
|
109 |
modem.SendSms(sms.sender, Util::str_latin2gsm(os.str()), true); |
modem.SendSms(sms.sender, os.str(), true); |
110 |
|
|
111 |
|
|
112 |
|
|