Permalink
Browse files

Merge pull request #530 from cptspiff/weather

changed: always fetch weather using an add-on
  • Loading branch information...
2 parents 1f93655 + 569712f commit ada86f4c96e5fbd35b9c4d35d87b0b37517f927f Arne Morten Kvarving committed Nov 14, 2011
@@ -589,7 +589,7 @@
<onclick>ActivateWindow(Weather)</onclick>
<icon>special://skin/backgrounds/weather.jpg</icon>
<thumb>$INFO[Skin.String(Home_Custom_Back_Weather_Folder)]</thumb>
- <visible>!Skin.HasSetting(HomeMenuNoWeatherButton)</visible>
+ <visible>!Skin.HasSetting(HomeMenuNoWeatherButton)+!IsEmpty(Weather.Plugin)</visible>
</item>
<item id="4">
<label>1</label>
@@ -1,40 +0,0 @@
-<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
-<addon id="weather.xbmc.builtin"
- name="Weather.com (standard)"
- version="1.0.0"
- provider-name="Team XBMC">
- <extension point="xbmc.python.weather" library=""/>
- <extension point="xbmc.addon.metadata">
- <summary lang="br">Condições meteorológicas atuais.</summary>
- <summary lang="ca">Condicions meteorològiques actuals.</summary>
- <summary lang="en">Current weather conditions.</summary>
- <summary lang="es">Condiciones meteorológicas actuales.</summary>
- <summary lang="de">Aktuelle Wetterbedingungen</summary>
- <summary lang="fr">Conditions météorologiques en cours.</summary>
- <summary lang="hu">A jelenlegi időjárás.</summary>
- <summary lang="ko">현재 날씨</summary>
- <summary lang="nl">Huidige weersomstandigheden.</summary>
- <summary lang="pl">Aktualne warunki pogodowe.</summary>
- <summary lang="pt">Condições meteorológicas actuais.</summary>
- <summary lang="ro">Condiții meteo curente.</summary>
- <summary lang="ru">Текущие погодные условия.</summary>
- <summary lang="se">Aktuella väderförhållanden.</summary>
- <summary lang="zh">当前天气状况</summary>
- <description lang="br">Esta é a origem padrão de informação meteorológicas.[CR][CR]Ela provê as condições atuais e previsão para quatro dias.</description>
- <description lang="ca">Aquesta és la font per defecte de la informació meteorològica.[CR][CR]Proporciona les condicions meteorològiques actuals i una predicció a 4 dies.</description>
- <description lang="en">This is the default weather source.[CR][CR]It provides current weather conditions and a four day outlook.</description>
- <description lang="es">Fuente para las condiciones meteorológicas.[CR][CR]Proporciona las condiciones meteorológicas actuales y una previsión para 4 días.</description>
- <description lang="de">Standardquelle für Wetterinformationen[CR][CR]Das aktuelle Wetter sowie eine 4 tägige Vorausschau werden angezeigt</description>
- <description lang="fr">C'est la source météo par défaut.[CR][CR]Fournit les conditions climatiques en cours et les prévisions sur 4 jours.</description>
- <description lang="hu">Ez az alapértelmezett időjárás információforrás.[CR][CR]Tájékoztat a jelenlegi időjárásról, valamint négynapos előrejelzést ad.</description>
- <description lang="ko">기본 날씨 정보입니다.[CR][CR] 현재날씨와 4일치 예보를 제공합니다.</description>
- <description lang="nl">Dit is de standaardbron voor weersinformatie.[CR][CR]Het toont de huidige weersomstandigheden en de voorspellingen voor de vier volgende dagen.</description>
- <description lang="pl">Jest to domyślne źródło pogody.[CR][CR]Dostarcza aktualną pogodę oraz prognozę na cztery dni.</description>
- <description lang="pt">Fonte padrão das condições meteorológicas.[CR][CR]Providencia as condições meteorológicas actuais e previsão para quatro dias.</description>
- <description lang="ro">Sursă implicită pentru informații meteorologice.[CR][CR]Furnizează condiții meteo curente plus prognoza pe 4 zile.</description>
- <description lang="ru">Это источник информации о погоде.[CR][CR]Он предоставляет текущие погодные условия и прогноза на четыре дня.</description>
- <description lang="se">Detta är standardkällan för väder.[CR][CR]Det tillhandahåller nuvarande väderförhållanden och en fyra dagars prognos.</description>
- <description lang="zh">这是默认的天气预报信息来源。[CR][CR]它提供了当前的天气状况和未来4天的天气预报。</description>
- <platform>all</platform>
- </extension>
-</addon>
@@ -1098,7 +1098,7 @@ CStdString CGUIInfoManager::GetLabel(int info, int contextWindow)
URIUtils::RemoveExtension(strLabel);
break;
case WEATHER_PLUGIN:
- strLabel = g_guiSettings.GetString("weather.script");
+ strLabel = g_guiSettings.GetString("weather.addon");
break;
case SYSTEM_DATE:
strLabel = GetDate();
@@ -127,3 +127,6 @@
// Sent to tell window to initiate a search dialog
#define GUI_MSG_SEARCH GUI_MSG_USER + 34
+
+// Sent to the AddonSetting dialogs from addons if they updated a setting
+#define GUI_MSG_SETTING_UPDATED GUI_MSG_USER + 35
@@ -81,11 +81,23 @@ AddonPtr CAddonMgr::Factory(const cp_extension_t *props)
return AddonPtr(new CPluginSource(props));
case ADDON_SCRIPT_LIBRARY:
case ADDON_SCRIPT_LYRICS:
- case ADDON_SCRIPT_WEATHER:
case ADDON_SCRIPT_SUBTITLES:
case ADDON_SCRIPT_MODULE:
case ADDON_WEB_INTERFACE:
return AddonPtr(new CAddon(props));
+ case ADDON_SCRIPT_WEATHER:
+ {
+ // Eden (API v2.0) broke old weather add-ons
+ AddonPtr result(new CAddon(props));
+ AddonVersion ver1 = AddonVersion(GetXbmcApiVersionDependency(result));
+ AddonVersion ver2 = AddonVersion("2.0");
+ if (ver1 < ver2)
+ {
+ CLog::Log(LOGINFO,"%s: Weather add-ons for api < 2.0 unsupported (%s)",__FUNCTION__,result->ID().c_str());
+ return AddonPtr();
+ }
+ return result;
+ }
case ADDON_SERVICE:
return AddonPtr(new CService(props));
case ADDON_SCRAPER_ALBUMS:
@@ -44,6 +44,7 @@
#include "FileItem.h"
#include "settings/Settings.h"
#include "GUIInfoManager.h"
+#include "GUIUserMessages.h"
#include "dialogs/GUIDialogSelect.h"
#include "GUIWindowAddonBrowser.h"
#include "utils/log.h"
@@ -126,6 +127,17 @@ bool CGUIDialogAddonSettings::OnMessage(CGUIMessage& message)
}
return true;
}
+ case GUI_MSG_SETTING_UPDATED:
+ {
+ CStdString id = message.GetStringParam(0);
+ CStdString value = message.GetStringParam(1);
+ m_settings[id] = value;
+ int iControl = GetFocusedControl()->GetID();
+ CreateControls();
+ CGUIMessage msg(GUI_MSG_SETFOCUS,GetID(),iControl);
+ OnMessage(msg);
+ return true;
+ }
}
return CGUIDialogBoxBase::OnMessage(message);
}
@@ -1133,3 +1145,10 @@ void CGUIDialogAddonSettings::DoProcess(unsigned int currentTime, CDirtyRegionLi
((CGUIButtonControl *)control)->SetSelected(false);
}
}
+
+CStdString CGUIDialogAddonSettings::GetCurrentID() const
+{
+ if (m_addon)
+ return m_addon->ID();
+ return "";
+}
@@ -38,6 +38,7 @@ class CGUIDialogAddonSettings : public CGUIDialogBoxBase
static bool ShowAndGetInput(const ADDON::AddonPtr &addon, bool saveToDisk = true);
virtual void DoProcess(unsigned int currentTime, CDirtyRegionList &dirtyregions);
+ CStdString GetCurrentID() const;
protected:
virtual void OnInitWindow();
@@ -24,6 +24,8 @@
#include "pythreadstate.h"
#include "addons/AddonManager.h"
#include "addons/GUIDialogAddonSettings.h"
+#include "guilib/GUIWindowManager.h"
+#include "GUIUserMessages.h"
#include "utils/log.h"
namespace PYXBMC
@@ -245,8 +247,27 @@ namespace PYXBMC
AddonPtr addon(self->pAddon);
CPyThreadState pyState;
- addon->UpdateSetting(id, value);
- addon->SaveSettings();
+ bool save=true;
+ if (g_windowManager.IsWindowActive(WINDOW_DIALOG_ADDON_SETTINGS))
+ {
+ CGUIDialogAddonSettings* dialog = (CGUIDialogAddonSettings*)g_windowManager.GetWindow(WINDOW_DIALOG_ADDON_SETTINGS);
+ if (dialog->GetCurrentID() == addon->ID())
+ {
+ CGUIMessage message(GUI_MSG_SETTING_UPDATED,0,0);
+ std::vector<CStdString> params;
+ params.push_back(id);
+ params.push_back(value);
+ message.SetStringParams(params);
+ g_windowManager.SendThreadMessage(message,WINDOW_DIALOG_ADDON_SETTINGS);
+ save=false;
+ }
+ }
+ if (save)
+ {
+ addon->UpdateSetting(id, value);
+ addon->SaveSettings();
+ }
+
pyState.Restore();
Py_INCREF(Py_None);
@@ -259,12 +259,8 @@ void CGUISettings::Initialize()
AddGroup(2, 8);
CSettingsCategory* wea = AddCategory(2, "weather", 16000);
AddInt(NULL, "weather.currentlocation", 0, 1, 1, 1, 3, SPIN_CONTROL_INT_PLUS);
- AddString(wea, "weather.areacode1", 14019, "USNY0996 - New York, NY", BUTTON_CONTROL_STANDARD);
- AddString(wea, "weather.areacode2", 14020, "UKXX0085 - London, United Kingdom", BUTTON_CONTROL_STANDARD);
- AddString(wea, "weather.areacode3", 14021, "JAXX0085 - Tokyo, Japan", BUTTON_CONTROL_STANDARD);
- AddSeparator(wea, "weather.sep1");
- AddDefaultAddon(wea, "weather.script", 24027, DEFAULT_WEATHER_ADDON, ADDON_SCRIPT_WEATHER);
- AddString(wea, "weather.scriptsettings", 21417, "", BUTTON_CONTROL_STANDARD, true);
+ AddDefaultAddon(wea, "weather.addon", 24027, "", ADDON_SCRIPT_WEATHER);
+ AddString(wea, "weather.addonsettings", 21417, "", BUTTON_CONTROL_STANDARD, true);
// My Music Settings
AddGroup(3, 2);
@@ -867,12 +867,6 @@ void CGUIWindowSettingsCategory::UpdateSettings()
if (strSetting.Equals("screensaver.usedimonpause") && g_guiSettings.GetString("screensaver.mode").Equals("screensaver.xbmc.builtin.dim"))
pControl->SetEnabled(false);
}
- else if (strSetting.Left(16).Equals("weather.areacode"))
- {
- CSettingString *pSetting = (CSettingString *)GetSetting(strSetting)->GetSetting();
- CGUIButtonControl *pControl = (CGUIButtonControl *)GetControl(GetSetting(strSetting)->GetID());
- pControl->SetLabel2(CWeather::GetAreaCity(pSetting->GetData()));
- }
else if (strSetting.Equals("musicfiles.trackformat"))
{
if (m_strOldTrackFormat != g_guiSettings.GetString("musicfiles.trackformat"))
@@ -937,10 +931,10 @@ void CGUIWindowSettingsCategory::UpdateSettings()
pControl->SetEnabled(enabled);
}
}
- else if (strSetting.Equals("weather.scriptsettings"))
+ else if (strSetting.Equals("weather.addonsettings"))
{
AddonPtr addon;
- if (CAddonMgr::Get().GetAddon(g_guiSettings.GetString("weather.script"), addon, ADDON_SCRIPT_WEATHER))
+ if (CAddonMgr::Get().GetAddon(g_guiSettings.GetString("weather.addon"), addon, ADDON_SCRIPT_WEATHER))
{
CGUIControl *pControl = (CGUIControl *)GetControl(pSettingControl->GetID());
if (pControl)
@@ -983,26 +977,9 @@ void CGUIWindowSettingsCategory::UpdateRealTimeSettings()
void CGUIWindowSettingsCategory::OnClick(CBaseSettingControl *pSettingControl)
{
CStdString strSetting = pSettingControl->GetSetting()->GetSetting();
- if (strSetting.Left(16).Equals("weather.areacode"))
- {
- CStdString strSearch;
- if (CGUIDialogKeyboard::ShowAndGetInput(strSearch, g_localizeStrings.Get(14024), false))
- {
- strSearch.Replace(" ", "+");
- CStdString strResult = ((CSettingString *)pSettingControl->GetSetting())->GetData();
- if (g_weatherManager.GetSearchResults(strSearch, strResult))
- {
- ((CSettingString *)pSettingControl->GetSetting())->SetData(strResult);
- // Update the labels on the location spinner
- g_weatherManager.Reset();
- // Refresh the weather using the new location
- g_weatherManager.Refresh();
- }
- }
- }
- else if (strSetting.Equals("weather.scriptsettings"))
+ if (strSetting.Equals("weather.addonsettings"))
{
- CStdString name = g_guiSettings.GetString("weather.script");
+ CStdString name = g_guiSettings.GetString("weather.addon");
AddonPtr addon;
if (CAddonMgr::Get().GetAddon(name, addon, ADDON_SCRIPT_WEATHER))
{ // TODO: maybe have ShowAndGetInput return a bool if settings changed, then only reset weather if true.
@@ -1026,7 +1003,7 @@ void CGUIWindowSettingsCategory::OnClick(CBaseSettingControl *pSettingControl)
{ // prompt for the addon
CSettingAddon *setting = (CSettingAddon *)pSettingControl->GetSetting();
CStdString addonID = setting->GetData();
- if (CGUIWindowAddonBrowser::SelectAddonID(setting->m_type, addonID, setting->m_type == ADDON_SCREENSAVER || setting->m_type == ADDON_VIZ) == 1)
+ if (CGUIWindowAddonBrowser::SelectAddonID(setting->m_type, addonID, setting->m_type == ADDON_SCREENSAVER || setting->m_type == ADDON_VIZ || setting->m_type == ADDON_SCRIPT_WEATHER) == 1)
setting->SetData(addonID);
else
return;
@@ -29,7 +29,6 @@
#define DEFAULT_SKIN "skin.confluence"
#endif
#define DEFAULT_FANART_HEIGHT 0
-#define DEFAULT_WEATHER_ADDON "weather.xbmc.builtin"
#define DEFAULT_WEB_INTERFACE "webinterface.default"
#ifdef MID
#define DEFAULT_VSYNC VSYNC_DISABLED
Oops, something went wrong.

0 comments on commit ada86f4

Please sign in to comment.