2009-03-16, 16:18
I've added checks so you don't try and run the script/plugin more than once. this may not be the best way, but i don't want to block xbmc at any time.
what i need now is a delay. say you're flipping thru the locations, i want to wait 500msec or so before the script is launched.
i'm not sure how to do this.
here is a diff and a picture of it in action.
what i need now is a delay. say you're flipping thru the locations, i want to wait 500msec or so before the script is launched.
i'm not sure how to do this.
here is a diff and a picture of it in action.
PHP Code:
Index: xbmc/GUIWindowWeather.cpp
===================================================================
--- xbmc/GUIWindowWeather.cpp (revision 18588)
+++ xbmc/GUIWindowWeather.cpp (working copy)
@@ -26,6 +26,7 @@
#include "GUISettings.h"
#include "GUIWindowManager.h"
#include "Util.h"
+#include "lib/libPython/XBPython.h"
#define CONTROL_BTNREFRESH 2
#define CONTROL_SELECTLOCATION 3
@@ -120,6 +121,7 @@
{
UpdateLocations();
SetProperties();
+ CallPlugin();
}
break;
}
@@ -242,7 +244,10 @@
void CGUIWindowWeather::SetProperties()
{
- CStdString fanartcode;
+ // we only want to clear properties if location is different
+ if (!GetProperty("Location").Equals(g_weatherManager.GetLocation(m_iCurWeather)))
+ ClearProperties();
+
// Current weather
SetProperty("Location", g_weatherManager.GetLocation(m_iCurWeather));
CStdString strSetting;
@@ -257,7 +262,8 @@
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));
- fanartcode = CUtil::GetFileName(g_weatherManager.GetInfo(WEATHER_IMAGE_CURRENT_ICON));
+ // 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);
@@ -276,3 +282,29 @@
SetProperty(day + "FanartCode", fanartcode);
}
}
+
+void CGUIWindowWeather::CallPlugin()
+{
+ if (!g_guiSettings.GetString("weather.pluginpath", false).empty())
+ {
+ CStdString strSetting;
+ strSetting.Format("weather.areacode%i", m_iCurWeather + 1);
+ const CStdString &areacode = g_weatherManager.GetAreaCode(g_guiSettings.GetString(strSetting)).c_str();
+
+ unsigned int argc = 2;
+ char ** argv = new char*[argc];
+ argv[0] = (char*)g_guiSettings.GetString("weather.pluginpath", false).c_str();
+ argv[1] = (char*)areacode.c_str();
+
+ int id = g_pythonParser.getScriptId(argv[0]);
+ if (id != -1 && g_pythonParser.isRunning(id))
+ {
+ CLog::Log(LOGDEBUG, "%s - Weather plugin cancelled: %s", __FUNCTION__, argv[0]);
+ g_pythonParser.stopScript(id);
+ }
+
+ g_pythonParser.evalFile(argv[0], argc, (const char**)argv);
+
+ CLog::Log(LOGDEBUG, "%s - Weather plugin called: %s (%s)", __FUNCTION__, argv[0], argv[1]);
+ }
+}
Index: xbmc/GUIWindowWeather.h
===================================================================
--- xbmc/GUIWindowWeather.h (revision 18588)
+++ xbmc/GUIWindowWeather.h (working copy)
@@ -38,8 +38,10 @@
void UpdateButtons();
void UpdateLocations();
void SetProperties();
+ void CallPlugin();
void Refresh();
unsigned int m_iCurWeather;
+
};