Browse files

added: script support to media windows. Scripts should use the same e…

…xtension format as plugins (i.e. the <provides> element) and they'll show up in media windows

git-svn-id: https://xbmc.svn.sourceforge.net/svnroot/xbmc/trunk@31143 568bbfeb-2a22-0410-94d2-cc84cf5bfa90
  • Loading branch information...
1 parent 65fde0c commit 9a8454ae662876a29a6e3a80024a6a509d7fdad1 jmarshallnz committed Jun 17, 2010
Showing with 29 additions and 1 deletion.
  1. +18 −0 xbmc/GUIMediaWindow.cpp
  2. +10 −0 xbmc/GUIViewState.cpp
  3. +1 −1 xbmc/addons/AddonManager.cpp
View
18 xbmc/GUIMediaWindow.cpp
@@ -56,6 +56,9 @@
#include "utils/FileUtils.h"
#include "GUIEditControl.h"
#include "GUIDialogKeyboard.h"
+#ifdef HAS_PYTHON
+#include "lib/libPython/XBPython.h"
+#endif
#define CONTROL_BTNVIEWASICONS 2
#define CONTROL_BTNSORTBY 3
@@ -809,6 +812,21 @@ bool CGUIMediaWindow::OnClick(int iItem)
if (pItem->m_bIsFolder)
{
+ CURL url(pItem->m_strPath);
+ if (url.GetProtocol() == "script")
+ {
+ // execute the script
+ AddonPtr addon;
+ if (CAddonMgr::Get().GetAddon(url.GetHostName(), addon))
+ {
+#ifdef HAS_PYTHON
+ if (!g_pythonParser.StopScript(addon->LibPath()))
+ g_pythonParser.evalFile(addon->LibPath());
+#endif
+ return true;
+ }
+ }
+
if ( pItem->m_bIsShareOrDrive )
{
const CStdString& strLockType=m_guiState->GetLockType();
View
10 xbmc/GUIViewState.cpp
@@ -370,6 +370,16 @@ VECSOURCES& CGUIViewState::GetSources()
m_sources.push_back(SourceFromPlugin(plugin, "plugin"));
}
+ addons.clear();
+ ADDON::CAddonMgr::Get().GetAddons(ADDON_SCRIPT, addons);
+ for (unsigned i=0; i<addons.size(); i++)
+ {
+ PluginPtr plugin = boost::dynamic_pointer_cast<CPluginSource>(addons[i]);
+ if (!plugin || !plugin->Provides(m_content))
+ continue;
+ m_sources.push_back(SourceFromPlugin(plugin, "script"));
+ }
+
return m_sources;
}
View
2 xbmc/addons/AddonManager.cpp
@@ -80,8 +80,8 @@ AddonPtr CAddonMgr::Factory(const cp_extension_t *props)
switch (type)
{
case ADDON_PLUGIN:
- return AddonPtr(new CPluginSource(props));
case ADDON_SCRIPT:
+ return AddonPtr(new CPluginSource(props));
case ADDON_SCRIPT_LIBRARY:
case ADDON_SCRIPT_LYRICS:
case ADDON_SCRIPT_WEATHER:

0 comments on commit 9a8454a

Please sign in to comment.