Bug #128 » weather-update-2011-01-13.diff
xbmc/utils/GUIInfoManager.cpp (working copy) | ||
---|---|---|
{
|
||
case WEATHER_CONDITIONS:
|
||
strLabel = g_weatherManager.GetInfo(WEATHER_LABEL_CURRENT_COND);
|
||
strLabel = strLabel.Trim();
|
||
break;
|
||
case WEATHER_TEMPERATURE:
|
||
strLabel.Format("%s%s", g_weatherManager.GetInfo(WEATHER_LABEL_CURRENT_TEMP), g_langInfo.GetTempUnitString().c_str());
|
||
... | ... | |
strLabel = g_weatherManager.GetInfo(WEATHER_LABEL_LOCATION);
|
||
break;
|
||
case WEATHER_FANART_CODE:
|
||
strLabel = CUtil::GetFileName(g_weatherManager.GetInfo(WEATHER_IMAGE_CURRENT_ICON));
|
||
CUtil::RemoveExtension(strLabel);
|
||
strLabel = g_weatherManager.GetInfo(WEATHER_LABEL_FANART_CODE);
|
||
break;
|
||
case WEATHER_PLUGIN:
|
||
strLabel = g_guiSettings.GetString("weather.plugin");
|
||
... | ... | |
return GetMultiInfoLabel(m_multiInfo[info - MULTI_INFO_START], contextWindow);
|
||
}
|
||
else if (info == WEATHER_CONDITIONS)
|
||
{
|
||
return g_weatherManager.GetInfo(WEATHER_IMAGE_CURRENT_ICON);
|
||
}
|
||
else if (info == SYSTEM_PROFILETHUMB)
|
||
{
|
||
CStdString thumb = g_settings.m_vecProfiles[g_settings.m_iLastLoadedProfileIndex].getThumb();
|
xbmc/utils/Weather.cpp (working copy) | ||
---|---|---|
#include "GUIWindowManager.h"
|
||
#include "GUIMediaWindow.h"
|
||
#include "ScriptSettings.h"
|
||
#include "GUIDialogPluginSettings.h"
|
||
using namespace std;
|
||
... | ... | |
{
|
||
}
|
||
const char *CWeather::TranslateInfo(int info)
|
||
CStdString CWeather::TranslateInfo(int info) const
|
||
{
|
||
if (info == WEATHER_LABEL_CURRENT_COND) return m_szCurrentConditions;
|
||
else if (info == WEATHER_IMAGE_CURRENT_ICON) return m_szCurrentIcon;
|
||
else if (info == WEATHER_LABEL_CURRENT_TEMP) return m_szCurrentTemperature;
|
||
else if (info == WEATHER_LABEL_LOCATION) return m_szCurrentLocation;
|
||
CGUIWindow *window = g_windowManager.GetWindow(WINDOW_WEATHER);
|
||
if (window)
|
||
{
|
||
if (info == WEATHER_LABEL_CURRENT_COND)
|
||
return window->GetProperty("Current.Condition");
|
||
else if (info == WEATHER_IMAGE_CURRENT_ICON)
|
||
return window->GetProperty("Current.ConditionIcon");
|
||
else if (info == WEATHER_LABEL_CURRENT_TEMP)
|
||
return window->GetProperty("Current.Temperature");
|
||
else if (info == WEATHER_LABEL_LOCATION)
|
||
return window->GetProperty("Location");
|
||
else if (info == WEATHER_ISFETCHED)
|
||
return window->GetProperty("Weather.IsFetched");
|
||
else if (info == WEATHER_LABEL_FANART_CODE)
|
||
return window->GetProperty("Current.FanartCode");
|
||
}
|
||
return "";
|
||
}
|
||
... | ... | |
void CWeather::Reset()
|
||
{
|
||
strcpy(m_szLastUpdateTime, "false");
|
||
strcpy(m_szCurrentIcon,"");
|
||
strcpy(m_szCurrentConditions, "");
|
||
strcpy(m_szCurrentTemperature, "");
|
||
strcpy(m_szCurrentLocation, "");
|
||
for (int i = 0; i < MAX_LOCATION; i++)
|
||
{
|
||
strcpy(m_szLocation[i], "");
|
||
... | ... | |
{
|
||
// call GetInfo() to make sure that we actually start up
|
||
GetInfo(0);
|
||
SetInfo();
|
||
return (strcmp(m_szLastUpdateTime, "true") == 0);
|
||
return TranslateInfo(WEATHER_ISFETCHED).Equals("true");
|
||
}
|
||
void CWeather::SetInfo()
|
||
{
|
||
if (strcmp(m_szLastUpdateTime, "false") == 0 || strcmp(m_szLastUpdateTime, "") == 0)
|
||
{
|
||
CGUIWindow *window = g_windowManager.GetWindow(WINDOW_WEATHER);
|
||
if (window)
|
||
{
|
||
// set these so existing weather infolabels don't break
|
||
strcpy(m_szLastUpdateTime, ((CGUIMediaWindow*)window)->GetProperty("Weather.IsFetched").c_str());
|
||
strcpy(m_szCurrentIcon, ((CGUIMediaWindow*)window)->GetProperty("Current.ConditionIcon").c_str());
|
||
strcpy(m_szCurrentConditions, ((CGUIMediaWindow*)window)->GetProperty("Current.Condition").c_str());
|
||
strcpy(m_szCurrentTemperature, ((CGUIMediaWindow*)window)->GetProperty("Current.Condition").c_str());
|
||
strcpy(m_szCurrentLocation, ((CGUIMediaWindow*)window)->GetProperty("Location").c_str());
|
||
}
|
||
}
|
||
}
|
xbmc/utils/Weather.h (working copy) | ||
---|---|---|
*/
|
||
#include "InfoLoader.h"
|
||
#include "StdString.h"
|
||
#define WEATHER_LABEL_LOCATION 10
|
||
#define WEATHER_IMAGE_CURRENT_ICON 21
|
||
#define WEATHER_LABEL_CURRENT_COND 22
|
||
#define WEATHER_LABEL_CURRENT_TEMP 23
|
||
#define WEATHER_ISFETCHED 24
|
||
#define WEATHER_LABEL_FANART_CODE 25
|
||
class CBackgroundWeatherLoader : public CBackgroundLoader
|
||
... | ... | |
void SetArea(int iArea) { m_iCurWeather = iArea; };
|
||
unsigned int GetMaxLocations();
|
||
void SetInfo();
|
||
protected:
|
||
virtual const char *TranslateInfo(int info);
|
||
virtual CStdString TranslateInfo(int info) const;
|
||
virtual DWORD TimeToNextRefreshInMs();
|
||
char m_szLocation[10][100];
|
||
// Last updated
|
||
char m_szLastUpdateTime[256];
|
||
// Now weather
|
||
char m_szCurrentIcon[256];
|
||
char m_szCurrentConditions[256];
|
||
char m_szCurrentTemperature[10];
|
||
char m_szCurrentLocation[256];
|
||
unsigned int m_iCurWeather;
|
||
int m_MaxLocations;
|
||