Index: language/English/strings.xml =================================================================== --- language/English/strings.xml (revision 30688) +++ language/English/strings.xml (working copy) @@ -54,6 +54,33 @@ Nov Dec + N + NNE + NE + ENE + E + ESE + SE + SSE + S + SSW + SW + WSW + W + WNW + NW + NNW + VAR + North + Northeast + East + Southeast + South + Southwest + West + Northwest + Variable + View: Auto View: Auto big View: Icons @@ -367,9 +394,9 @@ Downloading thumbnail... Not available View: Big icons - Enable Library - - + Low + High + HDMI Delete album info Delete CD information @@ -383,9 +410,10 @@ No cache Remove movie from library Really remove '%s'? - - - + From %s at %i %s + From the %s at %i %s + Gust to %i %s + Removable disk Opening file Cache @@ -826,7 +854,23 @@ Grains T-Storms T-Showers + Moderate + Very High + Windy + Mist + Blowing + Moon + Waning + Waxing + Full + New + First + Last + Quarter + Crescent + Gibbous + Put display to sleep when idle @@ -2058,6 +2102,7 @@ Subtitle language Remote control sends keyboard presses - Edit + Internet connection required. File name File path @@ -2204,6 +2249,11 @@ + Configure + Disable + Enable + Add-on disabled + Library Mode QWERTY keyboard @@ -2288,5 +2338,10 @@ Path to script Enable custom script button + mile + miles + kilometer + kilometers + Flac Index: xbmc/Application.cpp =================================================================== --- xbmc/Application.cpp (revision 30688) +++ xbmc/Application.cpp (working copy) @@ -1208,6 +1208,7 @@ CreateDirectory("Q:\\plugins\\video", NULL); CreateDirectory("Q:\\plugins\\pictures", NULL); CreateDirectory("Q:\\plugins\\programs", NULL); + CreateDirectory("Q:\\plugins\\weather", NULL); CreateDirectory("Q:\\language", NULL); CreateDirectory("Q:\\visualisations", NULL); CreateDirectory("Q:\\sounds", NULL); Index: xbmc/GUISettings.cpp =================================================================== --- xbmc/GUISettings.cpp (revision 30688) +++ xbmc/GUISettings.cpp (working copy) @@ -224,11 +224,7 @@ // My Weather settings AddGroup(2, 8); AddCategory(2, "weather", 16000); - AddString(1, "weather.areacode1", 14019, "USNY0996 - New York, NY", BUTTON_CONTROL_STANDARD); - AddString(2, "weather.areacode2", 14020, "UKXX0085 - London, United Kingdom", BUTTON_CONTROL_STANDARD); - AddString(3, "weather.areacode3", 14021, "JAXX0085 - Tokyo, Japan", BUTTON_CONTROL_STANDARD); - AddSeparator(4, "weather.sep1"); - AddString(5, "weather.plugin", 23000, "", SPIN_CONTROL_TEXT, true); + AddString(5, "weather.plugin", 8, DEFAULT_WEATHER_PLUGIN, SPIN_CONTROL_TEXT, true); AddString(6, "weather.pluginsettings", 23001, "", BUTTON_CONTROL_STANDARD, true); // My Music Settings Index: xbmc/GUIWindowSettingsCategory.cpp =================================================================== --- xbmc/GUIWindowSettingsCategory.cpp (revision 30688) +++ xbmc/GUIWindowSettingsCategory.cpp (working copy) @@ -1042,16 +1042,10 @@ if (strSetting.Equals("screensaver.usedimonpause") && g_guiSettings.GetString("screensaver.mode").Equals("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(g_weatherManager.GetAreaCity(pSetting->GetData())); - } else if (strSetting.Equals("weather.plugin")) { CGUISpinControlEx *pControl = (CGUISpinControlEx *)GetControl(pSettingControl->GetID()); - if (pControl->GetCurrentLabel().Equals(g_localizeStrings.Get(13611))) + if (pControl->GetCurrentLabel().Equals(g_localizeStrings.Get(13610))) g_guiSettings.SetString("weather.plugin", ""); else g_guiSettings.SetString("weather.plugin", pControl->GetCurrentLabel()); @@ -1223,29 +1217,21 @@ void CGUIWindowSettingsCategory::OnClick(CBaseSettingControl *pSettingControl) { CStdString strSetting = pSettingControl->GetSetting()->GetSetting(); - if (strSetting.Left(16).Equals("weather.areacode")) + if (strSetting.Equals("weather.plugin")) { - 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); - g_weatherManager.ResetTimer(); - } - } - else if (strSetting.Equals("weather.plugin")) - { + g_weatherManager.Reset(); g_weatherManager.ResetTimer(); } else if (strSetting.Equals("weather.pluginsettings")) { // Create our base path CStdString basepath = "special://home/plugins/weather/" + g_guiSettings.GetString("weather.plugin"); - CGUIDialogPluginSettings::ShowAndGetInput(basepath); - // TODO: maybe have ShowAndGetInput return a bool if settings changed, then only reset weather if true. - g_weatherManager.ResetTimer(); + if (CGUIDialogPluginSettings::ShowAndGetInput(basepath)) + { + // TODO: maybe have ShowAndGetInput return a bool if settings changed, then only reset weather if true. + g_weatherManager.Reset(); + g_weatherManager.ResetTimer(); + } } else if (strSetting.Equals("lookandfeel.rssedit")) CUtil::ExecBuiltIn("RunScript("RSSEDITOR_PATH")"); @@ -3310,7 +3296,7 @@ int k=0; pControl->Clear(); // add our disable option - pControl->AddLabel(g_localizeStrings.Get(13611), j++); + pControl->AddLabel(g_localizeStrings.Get(13610), j++); CFileItemList items; if (CDirectory::GetDirectory("special://home/plugins/weather/", items, "/", false)) Index: xbmc/GUIWindowWeather.cpp =================================================================== --- xbmc/GUIWindowWeather.cpp (revision 30688) +++ xbmc/GUIWindowWeather.cpp (working copy) @@ -27,6 +27,7 @@ #include "GUIWindowManager.h" #include "Util.h" #include "lib/libPython/XBPython.h" +#include "GUIDialogOK.h" #define CONTROL_BTNREFRESH 2 #define CONTROL_SELECTLOCATION 3 @@ -54,6 +55,8 @@ #define LOCALIZED_TOKEN_LASTID 395 DWORD timeToCallPlugin = 1000; +bool forceRefresh = false; + /* FIXME'S >strings are not centered @@ -75,7 +78,7 @@ bool CGUIWindowWeather::OnAction(const CAction &action) { - if (action.id == ACTION_PREVIOUS_MENU) + if (action.id == ACTION_PREVIOUS_MENU || action.id == ACTION_PARENT_DIR) { g_windowManager.PreviousWindow(); return true; @@ -92,7 +95,8 @@ int iControl = message.GetSenderId(); if (iControl == CONTROL_BTNREFRESH) { - Refresh(); // Refresh clicked so do a complete update + forceRefresh = true; + CallPlugin(); } else if (iControl == CONTROL_SELECTLOCATION) { @@ -127,15 +131,24 @@ { UpdateLocations(); SetProperties(); - if (g_windowManager.GetActiveWindow() == WINDOW_WEATHER) - { - if (!g_guiSettings.GetString("weather.plugin").IsEmpty()) - m_pluginTimer.StartZero(); - } + if (IsActive()) + m_pluginTimer.StartZero(); else CallPlugin(); } break; + case GUI_MSG_WINDOW_INIT: + { + if (g_guiSettings.GetString("weather.plugin").IsEmpty()) + { + CGUIDialogOK::ShowAndGetInput(8,24023,20022,20022); + g_windowManager.PreviousWindow(); + return true; + } + } + break; + default: + break; } return CGUIWindow::OnMessage(message); @@ -157,7 +170,8 @@ g_windowManager.SendMessage(msg); CGUIMessage msg2(GUI_MSG_LABEL_ADD,GetID(),CONTROL_SELECTLOCATION); - for (unsigned int i = 0; i < MAX_LOCATION; i++) + unsigned int maxLocations = g_weatherManager.GetMaxLocations(); + for (unsigned int i = 0; i < maxLocations; i++) { char *szLocation = g_weatherManager.GetLocation(i); if (!szLocation) continue; @@ -195,37 +209,6 @@ SET_CONTROL_LABEL(CONTROL_BTNREFRESH, 184); //Refresh - SET_CONTROL_LABEL(WEATHER_LABEL_LOCATION, g_weatherManager.GetLocation(m_iCurWeather)); - SET_CONTROL_LABEL(CONTROL_LABELUPDATED, g_weatherManager.GetLastUpdateTime()); - - SET_CONTROL_LABEL(WEATHER_LABEL_CURRENT_COND, g_weatherManager.GetInfo(WEATHER_LABEL_CURRENT_COND)); - SET_CONTROL_LABEL(WEATHER_LABEL_CURRENT_TEMP, g_weatherManager.GetInfo(WEATHER_LABEL_CURRENT_TEMP) + g_langInfo.GetTempUnitString()); - SET_CONTROL_LABEL(WEATHER_LABEL_CURRENT_FEEL, g_weatherManager.GetInfo(WEATHER_LABEL_CURRENT_FEEL) + g_langInfo.GetTempUnitString()); - SET_CONTROL_LABEL(WEATHER_LABEL_CURRENT_UVID, g_weatherManager.GetInfo(WEATHER_LABEL_CURRENT_UVID)); - SET_CONTROL_LABEL(WEATHER_LABEL_CURRENT_WIND, g_weatherManager.GetInfo(WEATHER_LABEL_CURRENT_WIND)); - SET_CONTROL_LABEL(WEATHER_LABEL_CURRENT_DEWP, g_weatherManager.GetInfo(WEATHER_LABEL_CURRENT_DEWP) + g_langInfo.GetTempUnitString()); - SET_CONTROL_LABEL(WEATHER_LABEL_CURRENT_HUMI, g_weatherManager.GetInfo(WEATHER_LABEL_CURRENT_HUMI)); - - CGUIImage *pImage = (CGUIImage *)GetControl(WEATHER_IMAGE_CURRENT_ICON); - if (pImage) pImage->SetFileName(g_weatherManager.GetInfo(WEATHER_IMAGE_CURRENT_ICON)); - - //static labels - SET_CONTROL_LABEL(CONTROL_STATICTEMP, 401); //Temperature - SET_CONTROL_LABEL(CONTROL_STATICFEEL, 402); //Feels Like - SET_CONTROL_LABEL(CONTROL_STATICUVID, 403); //UV Index - SET_CONTROL_LABEL(CONTROL_STATICWIND, 404); //Wind - SET_CONTROL_LABEL(CONTROL_STATICDEWP, 405); //Dew Point - SET_CONTROL_LABEL(CONTROL_STATICHUMI, 406); //Humidity - - for (int i = 0; i < NUM_DAYS; i++) - { - SET_CONTROL_LABEL(CONTROL_LABELD0DAY + (i*10), g_weatherManager.m_dfForcast[i].m_szDay); - SET_CONTROL_LABEL(CONTROL_LABELD0HI + (i*10), g_weatherManager.m_dfForcast[i].m_szHigh + g_langInfo.GetTempUnitString()); - SET_CONTROL_LABEL(CONTROL_LABELD0LOW + (i*10), g_weatherManager.m_dfForcast[i].m_szLow + g_langInfo.GetTempUnitString()); - SET_CONTROL_LABEL(CONTROL_LABELD0GEN + (i*10), g_weatherManager.m_dfForcast[i].m_szOverview); - pImage = (CGUIImage *)GetControl(CONTROL_IMAGED0IMG + (i * 10)); - if (pImage) pImage->SetFileName(g_weatherManager.m_dfForcast[i].m_szIcon); - } } void CGUIWindowWeather::FrameMove() @@ -254,72 +237,45 @@ { // Current weather SetProperty("Location", g_weatherManager.GetLocation(m_iCurWeather)); - SetProperty("LocationIndex", int(m_iCurWeather + 1)); - CStdString strSetting; - strSetting.Format("weather.areacode%i", m_iCurWeather + 1); - SetProperty("AreaCode", g_weatherManager.GetAreaCode(g_guiSettings.GetString(strSetting))); - SetProperty("Updated", g_weatherManager.GetLastUpdateTime()); - SetProperty("Current.ConditionIcon", g_weatherManager.GetInfo(WEATHER_IMAGE_CURRENT_ICON)); - SetProperty("Current.Condition", g_weatherManager.GetInfo(WEATHER_LABEL_CURRENT_COND)); - SetProperty("Current.Temperature", g_weatherManager.GetInfo(WEATHER_LABEL_CURRENT_TEMP)); - SetProperty("Current.FeelsLike", g_weatherManager.GetInfo(WEATHER_LABEL_CURRENT_FEEL)); - SetProperty("Current.UVIndex", g_weatherManager.GetInfo(WEATHER_LABEL_CURRENT_UVID)); - SetProperty("Current.Wind", g_weatherManager.GetInfo(WEATHER_LABEL_CURRENT_WIND)); - SetProperty("Current.DewPoint", g_weatherManager.GetInfo(WEATHER_LABEL_CURRENT_DEWP)); - SetProperty("Current.Humidity", g_weatherManager.GetInfo(WEATHER_LABEL_CURRENT_HUMI)); - // we use the icons code number for fanart as it's the safest way - CStdString fanartcode = CUtil::GetFileName(g_weatherManager.GetInfo(WEATHER_IMAGE_CURRENT_ICON)); - CUtil::RemoveExtension(fanartcode); - SetProperty("Current.FanartCode", fanartcode); - - // Future weather - CStdString day; - for (int i = 0; i < NUM_DAYS; i++) - { - day.Format("Day%i.", i); - SetProperty(day + "Title", g_weatherManager.m_dfForcast[i].m_szDay); - SetProperty(day + "HighTemp", g_weatherManager.m_dfForcast[i].m_szHigh); - SetProperty(day + "LowTemp", g_weatherManager.m_dfForcast[i].m_szLow); - SetProperty(day + "Outlook", g_weatherManager.m_dfForcast[i].m_szOverview); - SetProperty(day + "OutlookIcon", g_weatherManager.m_dfForcast[i].m_szIcon); - fanartcode = CUtil::GetFileName(g_weatherManager.m_dfForcast[i].m_szIcon); - CUtil::RemoveExtension(fanartcode); - SetProperty(day + "FanartCode", fanartcode); - } + SetProperty("Location.Index", int(m_iCurWeather + 1)); } void CGUIWindowWeather::CallPlugin() { - if (!g_guiSettings.GetString("weather.plugin").IsEmpty()) - { - // create the full path to the plugin - CStdString plugin = "special://home/plugins/weather/" + g_guiSettings.GetString("weather.plugin") + "/default.py"; + SetProperty("Weather.IsFetched", false); - // initialize our sys.argv variables - unsigned int argc = 2; - char ** argv = new char*[argc]; - argv[0] = (char*)plugin.c_str(); + if (g_guiSettings.GetString("weather.plugin").IsEmpty()) return; - // if plugin is running we wait for another timeout only when in weather window - if (g_windowManager.GetActiveWindow() == WINDOW_WEATHER) + // create the full path to the plugin + CStdString plugin = "special://home/plugins/weather/" + g_guiSettings.GetString("weather.plugin") + "/default.py"; + + // initialize our sys.argv variables + unsigned int argc = 3; + char ** argv = new char*[argc]; + argv[0] = (char*)plugin.c_str(); + + // if plugin is running we wait for another timeout only when in weather window + if (g_windowManager.GetActiveWindow() == WINDOW_WEATHER) + { + int id = g_pythonParser.getScriptId(argv[0]); + if (id != -1 && g_pythonParser.isRunning(id)) { - int id = g_pythonParser.getScriptId(argv[0]); - if (id != -1 && g_pythonParser.isRunning(id)) - { - m_pluginTimer.StartZero(); - return; - } + m_pluginTimer.StartZero(); + return; } + } - // get the current locations area code - CStdString strSetting; - strSetting.Format("weather.areacode%i", m_iCurWeather + 1); - const CStdString &areacode = g_weatherManager.GetAreaCode(g_guiSettings.GetString(strSetting)); - argv[1] = (char*)areacode.c_str(); + // get the current locations area code + CStdString strSetting; + strSetting.Format("%i", m_iCurWeather + 1); + argv[1] = (char*)strSetting.c_str(); + argv[2] = (char*)(forceRefresh ? "1" : "0"); - // call our plugin, passing the areacode - g_pythonParser.evalFile(argv[0], argc, (const char**)argv); - CLog::Log(LOGDEBUG, "%s - Weather plugin called: %s (%s)", __FUNCTION__, argv[0], argv[1]); - } + // call our plugin, passing the areacode + g_pythonParser.evalFile(argv[0], argc, (const char**)argv); + + CLog::Log(LOGDEBUG, "%s - Weather plugin called: %s (%s)", __FUNCTION__, argv[0], argv[1]); + + forceRefresh = false; } Index: xbmc/Settings.h =================================================================== --- xbmc/Settings.h (revision 30688) +++ xbmc/Settings.h (working copy) @@ -23,6 +23,7 @@ #define PRE_SKIN_VERSION_9_10_COMPATIBILITY 1 #define DEFAULT_SKIN "Project Mayhem III" +#define DEFAULT_WEATHER_PLUGIN "Weather.com (standard)" #include "settings/VideoSettings.h" #include "GUISettings.h" Index: xbmc/utils/Weather.cpp =================================================================== --- xbmc/utils/Weather.cpp (revision 30688) +++ xbmc/utils/Weather.cpp (working copy) @@ -35,6 +35,8 @@ #include "GUIDialogSelect.h" #include "DateTime.h" #include "FileSystem/Directory.h" +#include "ScriptSettings.h" +#include "GUIDialogPluginSettings.h" using namespace std; using namespace DIRECTORY; @@ -70,7 +72,7 @@ #define PARTNER_ID "1004124588" //weather.com partner id #define PARTNER_KEY "079f24145f208494" //weather.com partner key -#define MAX_LOCATION 3 +#define MAX_LOCATION 10 #define LOCALIZED_TOKEN_FIRSTID 370 #define LOCALIZED_TOKEN_LASTID 395 #define LOCALIZED_TOKEN_FIRSTID2 1396 @@ -82,9 +84,9 @@ */ // USE THESE FOR ZIP -//#define WEATHER_BASE_PATH "Z:\\weather\\" //#define WEATHER_USE_ZIP 1 //#define WEATHER_USE_RAR 0 +//#define WEATHER_BASE_PATH "special://temp/weather/" //#define WEATHER_SOURCE_FILE "special://xbmc/media/weather.zip" // OR THESE FOR RAR @@ -97,10 +99,11 @@ void CBackgroundWeatherLoader::GetInformation() { - if (!g_network.IsAvailable()) - return; + //if (!g_network.IsAvailable()) + // return; - CWeather *callback = (CWeather *)m_callback; + //CWeather *callback = (CWeather *)m_callback; + /* // Download our weather CLog::Log(LOGINFO, "WEATHER: Downloading weather"); XFILE::CFileCurl httpUtil; @@ -128,6 +131,7 @@ } else CLog::Log(LOGERROR, "WEATHER: Weather download failed!"); + */ } CWeather::CWeather(void) : CInfoLoader("weather") @@ -668,8 +672,8 @@ } DWORD CWeather::TimeToNextRefreshInMs() -{ // 30 minutes - return 30 * 60 * 1000; +{ // 15 minutes + return 15 * 60 * 1000; } CStdString CWeather::GetAreaCity(const CStdString &codeAndCity) const @@ -694,13 +698,30 @@ { if (strlen(m_szLocation[iLocation]) == 0) { + CStdString cScriptPath = "special://home/plugins/weather/" + g_guiSettings.GetString("weather.plugin"); + CScriptSettings* settings = new CScriptSettings(); + settings->Clear(); + settings->Load(cScriptPath); CStdString setting; - setting.Format("weather.areacode%i", iLocation + 1); - strcpy(m_szLocation[iLocation], GetAreaCity(g_guiSettings.GetString(setting)).c_str()); + setting.Format("town%i", iLocation + 1); + strcpy(m_szLocation[iLocation], settings->Get(setting).c_str()); } return m_szLocation[iLocation]; } +unsigned int CWeather::GetMaxLocations() +{ + if (m_MaxLocations == -1) + { + CStdString cScriptPath = "special://home/plugins/weather/" + g_guiSettings.GetString("weather.plugin"); + CScriptSettings* settings = new CScriptSettings(); + settings->Clear(); + settings->Load(cScriptPath); + m_MaxLocations = atoi(settings->Get("maxlocations")) + 1; + } + return m_MaxLocations; +} + void CWeather::Reset() { strcpy(m_szLastUpdateTime, ""); @@ -727,6 +748,7 @@ { strcpy(m_szLocation[i], ""); } + m_MaxLocations = -1; } bool CWeather::IsFetched() Index: xbmc/utils/Weather.h =================================================================== --- xbmc/utils/Weather.h (revision 30688) +++ xbmc/utils/Weather.h (working copy) @@ -72,6 +72,7 @@ int GetArea() const { return m_iCurWeather; }; CStdString GetAreaCode(const CStdString &codeAndCity) const; CStdString GetAreaCity(const CStdString &codeAndCity) const; + unsigned int GetMaxLocations(); day_forcast m_dfForcast[NUM_DAYS]; bool m_bImagesOkay; @@ -90,7 +91,7 @@ std::map m_localizedTokens; typedef std::map::const_iterator ilocalizedTokens; - char m_szLocation[3][100]; + char m_szLocation[10][100]; // Last updated char m_szLastUpdateTime[256]; @@ -107,6 +108,8 @@ char m_szNAIcon[256]; unsigned int m_iCurWeather; + int m_MaxLocations; + }; extern CWeather g_weatherManager;