#include "guilib/GUIColorManager.h"
#include "guilib/GUITextLayout.h"
#include "addons/Skin.h"
+#include "interfaces/generic/ScriptInvocationManager.h"
#ifdef HAS_PYTHON
#include "interfaces/python/XBPython.h"
#endif
m_bPlaybackStarting = false;
m_ePlayState = PLAY_STATE_NONE;
m_skinReloading = false;
+ m_loggingIn = false;
#ifdef HAS_GLX
XInitThreads();
delete m_seekHandler;
delete m_playerController;
delete m_pInertialScrollingHandler;
-
}
bool CApplication::OnEvent(XBMC_Event& newEvent)
if (!CProfilesManager::Get().UsingLoginScreen())
{
UpdateLibraries();
-#ifdef HAS_PYTHON
- g_pythonParser.m_bLogin = true;
-#endif
+ SetLoggingIn(true);
}
m_slowTimer.StartZero();
CCrystalHD::RemoveInstance();
#endif
- g_mediaManager.Stop();
+ g_mediaManager.Stop();
- // Stop services before unloading Python
- CAddonMgr::Get().StopServices(false);
+ // Stop services before unloading Python
+ CAddonMgr::Get().StopServices(false);
+
+ // stop all remaining scripts; must be done after skin has been unloaded,
+ // not before some windows still need it when deinitializing during skin
+ // unloading
+ CScriptInvocationManager::Get().Uninitialize();
-/* Python resource freeing must be done after skin has been unloaded, not before
- some windows still need it when deinitializing during skin unloading. */
-#ifdef HAS_PYTHON
- CLog::Log(LOGNOTICE, "stop python");
- g_pythonParser.FreeResources();
-#endif
g_Windowing.DestroyRenderSystem();
g_Windowing.DestroyWindow();
g_Windowing.DestroyWindowSystem();
#ifdef HAS_PYTHON
if (item.IsPythonScript())
{ // a python script
- g_pythonParser.evalFile(item.GetPath().c_str(),ADDON::AddonPtr());
+ CScriptInvocationManager::Get().Execute(item.GetPath());
}
else
#endif
// (this can only be done after g_windowManager.Render())
CApplicationMessenger::Get().ProcessWindowMessages();
-#ifdef HAS_PYTHON
- // process any Python scripts
- g_pythonParser.Process();
-#endif
+ if (m_loggingIn)
+ {
+ m_loggingIn = false;
+
+ // autoexec.py - profile
+ CStdString strAutoExecPy = CSpecialProtocol::TranslatePath("special://profile/autoexec.py");
+
+ if (XFILE::CFile::Exists(strAutoExecPy))
+ CScriptInvocationManager::Get().Execute(strAutoExecPy);
+ else
+ CLog::Log(LOGDEBUG, "no profile autoexec.py (%s) found, skipping", strAutoExecPy.c_str());
+ }
+
+ // handle any active scripts
+ CScriptInvocationManager::Get().Process();
// process messages, even if a movie is playing
CApplicationMessenger::Get().ProcessMessages();
bool SetLanguage(const CStdString &strLanguage);
ReplayGainSettings& GetReplayGainSettings() { return m_replayGainSettings; }
+
+ void SetLoggingIn(bool loggingIn) { m_loggingIn = loggingIn; }
+
protected:
virtual bool OnSettingsSaving() const;
bool m_skinReloading; // if true we disallow LoadSkin until ReloadSkin is called
+ bool m_loggingIn;
+
#if defined(TARGET_DARWIN_IOS)
friend class CWinEventsIOS;
#endif
#include "LangInfo.h"
#include "PlayListPlayer.h"
#include "Util.h"
-#ifdef HAS_PYTHON
-#include "interfaces/python/XBPython.h"
-#endif
#include "pictures/GUIWindowSlideShow.h"
#include "interfaces/Builtins.h"
+#include "interfaces/generic/ScriptInvocationManager.h"
#include "network/Network.h"
#include "utils/log.h"
#include "utils/URIUtils.h"
break;
case TMSG_EXECUTE_SCRIPT:
-#ifdef HAS_PYTHON
- g_pythonParser.evalFile(pMsg->strParam.c_str(),ADDON::AddonPtr());
-#endif
+ CScriptInvocationManager::Get().Execute(pMsg->strParam);
break;
case TMSG_EXECUTE_BUILT_IN:
*
*/
#include "ScreenSaver.h"
+#include "interfaces/generic/ScriptInvocationManager.h"
#include "settings/DisplaySettings.h"
-#include "windowing/WindowingFactory.h"
-
-#ifdef HAS_PYTHON
-#include "interfaces/python/XBPython.h"
#include "utils/AlarmClock.h"
+#include "windowing/WindowingFactory.h"
// What sound does a python screensaver make?
-#define PYTHON_ALARM "sssssscreensaver"
+#define SCRIPT_ALARM "sssssscreensaver"
-#define PYTHON_SCRIPT_TIMEOUT 5 // seconds
-#endif
+#define SCRIPT_TIMEOUT 5 // seconds
namespace ADDON
{
bool CScreenSaver::CreateScreenSaver()
{
-#ifdef HAS_PYTHON
- if (URIUtils::HasExtension(LibPath(), ".py"))
+ if (CScriptInvocationManager::Get().HasLanguageInvoker(LibPath()))
{
// Don't allow a previously-scheduled alarm to kill our new screensaver
- g_alarmClock.Stop(PYTHON_ALARM, true);
+ g_alarmClock.Stop(SCRIPT_ALARM, true);
- if (!g_pythonParser.StopScript(LibPath()))
- g_pythonParser.evalFile(LibPath(), AddonPtr(new CScreenSaver(Props())));
+ if (!CScriptInvocationManager::Get().Stop(LibPath()))
+ CScriptInvocationManager::Get().Execute(LibPath(), AddonPtr(new CScreenSaver(Props())));
return true;
}
-#endif
// pass it the screen width,height
// and the name of the screensaver
int iWidth = g_graphicsContext.GetWidth();
#ifdef HAS_PYTHON
if (URIUtils::HasExtension(LibPath(), ".py"))
{
- g_alarmClock.Start(PYTHON_ALARM, PYTHON_SCRIPT_TIMEOUT, "StopScript(" + LibPath() + ")", true, false);
+ g_alarmClock.Start(SCRIPT_ALARM, SCRIPT_TIMEOUT, "StopScript(" + LibPath() + ")", true, false);
return;
}
#endif
*/
#include "Service.h"
#include "AddonManager.h"
+#include "interfaces/generic/ScriptInvocationManager.h"
#include "utils/log.h"
-#ifdef HAS_PYTHON
-#include "interfaces/python/XBPython.h"
-#endif
using namespace std;
{
#ifdef HAS_PYTHON
case PYTHON:
- ret = (g_pythonParser.evalFile(LibPath(), this->shared_from_this()) != -1);
+ ret = (CScriptInvocationManager::Get().Execute(LibPath(), this->shared_from_this()) != -1);
break;
#endif
{
#ifdef HAS_PYTHON
case PYTHON:
- ret = g_pythonParser.StopScript(LibPath());
+ ret = CScriptInvocationManager::Get().Stop(LibPath());
break;
#endif
#include "addons/AddonManager.h"
#include "addons/AddonInstaller.h"
#include "addons/IAddon.h"
-#ifdef HAS_PYTHON
-#include "interfaces/python/XBPython.h"
-#endif
+#include "interfaces/generic/ScriptInvocationManager.h"
#include "threads/SingleLock.h"
#include "guilib/GUIWindowManager.h"
#include "dialogs/GUIDialogProgress.h"
// setup our parameters to send the script
CStdString strHandle;
strHandle.Format("%i", handle);
- vector<CStdString> argv;
+ vector<string> argv;
argv.push_back(basePath);
argv.push_back(strHandle);
argv.push_back(options);
// run the script
CLog::Log(LOGDEBUG, "%s - calling plugin %s('%s','%s','%s')", __FUNCTION__, m_addon->Name().c_str(), argv[0].c_str(), argv[1].c_str(), argv[2].c_str());
bool success = false;
-#ifdef HAS_PYTHON
CStdString file = m_addon->LibPath();
- int id = g_pythonParser.evalFile(file, argv,m_addon);
+ int id = CScriptInvocationManager::Get().Execute(file, m_addon, argv);
if (id >= 0)
{ // wait for our script to finish
CStdString scriptName = m_addon->Name();
success = WaitOnScriptResult(file, id, scriptName, retrievingDir);
}
else
-#endif
CLog::Log(LOGERROR, "Unable to run plugin %s", m_addon->Name().c_str());
// free our handle
// setup our parameters to send the script
CStdString strHandle;
strHandle.Format("%i", -1);
- vector<CStdString> argv;
+ vector<string> argv;
argv.push_back(basePath);
argv.push_back(strHandle);
argv.push_back(options);
// run the script
-#ifdef HAS_PYTHON
CLog::Log(LOGDEBUG, "%s - calling plugin %s('%s','%s','%s')", __FUNCTION__, addon->Name().c_str(), argv[0].c_str(), argv[1].c_str(), argv[2].c_str());
- if (g_pythonParser.evalFile(addon->LibPath(), argv,addon) >= 0)
+ if (CScriptInvocationManager::Get().Execute(addon->LibPath(), addon, argv) >= 0)
return true;
else
-#endif
CLog::Log(LOGERROR, "Unable to run plugin %s", addon->Name().c_str());
return false;
}
}
// check our script is still running
-#ifdef HAS_PYTHON
- if (!g_pythonParser.isRunning(scriptId))
-#endif
+ if (!CScriptInvocationManager::Get().IsRunning(scriptId))
{ // check whether we exited normally
if (!m_fetchComplete.WaitMSec(0))
{ // python didn't return correctly
}
if (cancelled && XbmcThreads::SystemClockMillis() - startTime > timeToKillScript)
{ // cancel our script
-#ifdef HAS_PYTHON
- if (scriptId != -1 && g_pythonParser.isRunning(scriptId))
+ if (scriptId != -1 && CScriptInvocationManager::Get().IsRunning(scriptId))
{
CLog::Log(LOGDEBUG, "%s- cancelling plugin %s (id=%d)", __FUNCTION__, scriptName.c_str(), scriptId);
- g_pythonParser.stopScript(scriptId);
+ CScriptInvocationManager::Get().Stop(scriptId);
break;
}
-#endif
}
}
#include "addons/AddonInstaller.h"
#include "addons/AddonManager.h"
#include "addons/PluginSource.h"
+#include "interfaces/generic/ScriptInvocationManager.h"
#include "network/NetworkServices.h"
#include "utils/log.h"
#include "storage/MediaManager.h"
#endif
-#ifdef HAS_PYTHON
-#include "interfaces/python/XBPython.h"
-#endif
-
#if defined(TARGET_DARWIN)
#include "filesystem/SpecialProtocol.h"
#include "osx/CocoaInterface.h"
else
#endif
{
-#ifdef HAS_PYTHON
- vector<CStdString> argv = params;
+ vector<string> argv;
+ for (vector<CStdString>::const_iterator param = params.begin(); param != params.end(); ++param)
+ argv.push_back(*param);
vector<CStdString> path;
//split the path up to find the filename
if (CAddonMgr::Get().GetAddon(params[0], script))
scriptpath = script->LibPath();
- g_pythonParser.evalFile(scriptpath, argv,script);
-#endif
+ CScriptInvocationManager::Get().Execute(scriptpath, script, argv);
}
}
#if defined(TARGET_DARWIN_OSX)
#endif
else if (execute.Equals("stopscript"))
{
-#ifdef HAS_PYTHON
CStdString scriptpath(params[0]);
// Test to see if the param is an addon ID
if (CAddonMgr::Get().GetAddon(params[0], script))
scriptpath = script->LibPath();
- g_pythonParser.StopScript(scriptpath);
-#endif
+ CScriptInvocationManager::Get().Stop(scriptpath);
}
else if (execute.Equals("system.exec"))
{
#include "URIUtils.h"
#include "log.h"
#include "addons/AddonManager.h"
-#ifdef HAS_PYTHON
-#include "interfaces/python/XBPython.h"
-#endif
+#include "interfaces/generic/ScriptInvocationManager.h"
#include "CharsetConverter.h"
#include "addons/GUIDialogAddonSettings.h"
return false;
// initialize our sys.argv variables
- std::vector<CStdString> argv;
+ std::vector<std::string> argv;
argv.push_back(addon->LibPath());
CStdString strSetting;
strSetting.Format("%i", m_location);
argv.push_back(strSetting);
-#ifdef HAS_PYTHON
// Download our weather
CLog::Log(LOGINFO, "WEATHER: Downloading weather");
// call our script, passing the areacode
- if (g_pythonParser.evalFile(argv[0], argv,addon))
+ int scriptId = -1;
+ if ((scriptId = CScriptInvocationManager::Get().Execute(argv[0], addon, argv)) >= 0)
{
while (true)
{
- if (!g_pythonParser.isRunning(g_pythonParser.getScriptId(addon->LibPath().c_str())))
+ if (!CScriptInvocationManager::Get().IsRunning(scriptId))
break;
Sleep(100);
}
g_windowManager.SendThreadMessage(msg);
}
else
-#endif
CLog::Log(LOGERROR, "WEATHER: Weather download failed!");
return true;
#include "utils/FileUtils.h"
#include "guilib/GUIEditControl.h"
#include "guilib/GUIKeyboardFactory.h"
-#ifdef HAS_PYTHON
-#include "interfaces/python/XBPython.h"
-#endif
#include "interfaces/Builtins.h"
+#include "interfaces/generic/ScriptInvocationManager.h"
#include "dialogs/GUIDialogKaiToast.h"
#include "dialogs/GUIDialogMediaFilter.h"
#include "filesystem/SmartPlaylistDirectory.h"
AddonPtr addon;
if (CAddonMgr::Get().GetAddon(url.GetHostName(), addon, ADDON_SCRIPT))
{
-#ifdef HAS_PYTHON
- if (!g_pythonParser.StopScript(addon->LibPath()))
- g_pythonParser.evalFile(addon->LibPath(),addon);
-#endif
+ if (!CScriptInvocationManager::Get().Stop(addon->LibPath()))
+ CScriptInvocationManager::Get().Execute(addon->LibPath(), addon);
return true;
}
}
#include "dialogs/GUIDialogMediaSource.h"
#include "GUIPassword.h"
#include "GUIUserMessages.h"
-#ifdef HAS_PYTHON
-#include "interfaces/python/XBPython.h"
-#endif
+#include "interfaces/generic/ScriptInvocationManager.h"
#include "pictures/GUIWindowSlideShow.h"
#include "playlists/PlayListFactory.h"
#include "network/Network.h"
#ifdef HAS_PYTHON
if (pItem->IsPythonScript())
{
- g_pythonParser.evalFile(pItem->GetPath().c_str(),ADDON::AddonPtr());
+ CScriptInvocationManager::Get().Execute(pItem->GetPath());
return ;
}
#endif
#include "profiles/windows/GUIWindowSettingsProfile.h"
#include "dialogs/GUIDialogContextMenu.h"
#include "GUIPassword.h"
-#ifdef HAS_PYTHON
-#include "interfaces/python/XBPython.h"
-#endif
#ifdef HAS_JSONRPC
#include "interfaces/json-rpc/JSONRPC.h"
#endif
ADDON::CAddonMgr::Get().ReInit();
g_weatherManager.Refresh();
-#ifdef HAS_PYTHON
- g_pythonParser.m_bLogin = true;
-#endif
+ g_application.SetLoggingIn(true);
#ifdef HAS_JSONRPC
JSONRPC::CJSONRPC::Initialize();