introduced weather service interface

This commit is contained in:
louis
2015-01-13 09:01:11 +01:00
parent c59cc4e610
commit 4d8d1cc629
11 changed files with 160 additions and 3 deletions

View File

@@ -539,6 +539,19 @@ void cDisplayChannelView::DrawCustomTokens(void) {
DrawViewElement(veCustomTokens, &stringTokens, &intTokens);
}
void cDisplayChannelView::DrawCurrentWeather(void) {
if (!ViewElementImplemented(veCurrentWeather)) {
return;
}
map < string, string > stringTokens;
map < string, int > intTokens;
SetCurrentWeatherTokens(stringTokens, intTokens);
ClearViewElement(veCurrentWeather);
DrawViewElement(veCurrentWeather, &stringTokens, &intTokens);
}
void cDisplayChannelView::Action(void) {
SetInitFinished();
FadeIn();

View File

@@ -51,6 +51,7 @@ public:
void ClearChannelGroups(void);
void DisplayMessage(eMessageType Type, const char *Text);
void DrawCustomTokens(void);
void DrawCurrentWeather(void);
void DoStart(void) { Start(); };
void Flush(void) { DoFlush(); };
};

View File

@@ -1,5 +1,6 @@
#include <vdr/menu.h>
#include "../services/scraper2vdr.h"
#include "../services/weatherforecast.h"
#include "../config.h"
#include "../libcore/helpers.h"
#include "viewhelpers.h"
@@ -425,3 +426,30 @@ bool cViewHelpers::SetDate(map < string, string > &stringTokens, map < string, i
return true;
}
void cViewHelpers::SetCurrentWeatherTokens(map < string, string > &stringTokens, map < string, int > &intTokens) {
static cPlugin *pWeatherForecast = cPluginManager::GetPlugin("weatherforecast");
if (!pWeatherForecast)
return;
cServiceCurrentWeather currentWeather;
if (!pWeatherForecast->Service("GetCurrentWeather", &currentWeather)) {
return;
}
esyslog("skindesigner: service call successfull");
stringTokens.insert(pair<string,string>("timestamp", currentWeather.timeStamp));
stringTokens.insert(pair<string,string>("temperature", currentWeather.temperature));
stringTokens.insert(pair<string,string>("apparenttemperature", currentWeather.apparentTemperature));
stringTokens.insert(pair<string,string>("summary", currentWeather.summary));
stringTokens.insert(pair<string,string>("icon", currentWeather.icon));
stringTokens.insert(pair<string,string>("precipitationintensity", currentWeather.precipitationIntensity));
intTokens.insert(pair<string,int>("precipitationprobability", currentWeather.precipitationProbability));
stringTokens.insert(pair<string,string>("precipitationtype", currentWeather.precipitationType));
intTokens.insert(pair<string,int>("humidity", currentWeather.humidity));
stringTokens.insert(pair<string,string>("windspeed", currentWeather.windSpeed));
intTokens.insert(pair<string,int>("windbearing", currentWeather.windBearing));
stringTokens.insert(pair<string,string>("windbearingstring", currentWeather.windBearingString));
stringTokens.insert(pair<string,string>("visibility", currentWeather.visibility));
intTokens.insert(pair<string,int>("cloudcover", currentWeather.cloudCover));
stringTokens.insert(pair<string,string>("pressure", currentWeather.pressure));
stringTokens.insert(pair<string,string>("ozone", currentWeather.ozone));
}

View File

@@ -16,6 +16,7 @@ protected:
void SetScraperTokens(const cEvent *event, const cRecording *recording, map < string, string > &stringTokens, map < string, int > &intTokens, map < string, vector< map< string, string > > > &loopTokens);
bool SetTime(map < string, string > &stringTokens, map < string, int > &intTokens);
bool SetDate(map < string, string > &stringTokens, map < string, int > &intTokens);
void SetCurrentWeatherTokens(map < string, string > &stringTokens, map < string, int > &intTokens);
public:
cViewHelpers(void);
virtual ~cViewHelpers(void);