Permalink
Browse files

added: CPluginSource class for all pluginsource addons

changed: fixed plugin content handling via cpluff
changed: removed generic content types from enum CONTENT_TYPE
changed: temp disable plugins from appearing in GUIDialogMediaSource
changed: moved GetExtElementDeque out of CAddonMgr class

git-svn-id: https://xbmc.svn.sourceforge.net/svnroot/xbmc/trunk@30605 568bbfeb-2a22-0410-94d2-cc84cf5bfa90
  • Loading branch information...
1 parent b7d77b4 commit 16b848acf2d52876e4b9a19cc5ea9b2e45ea9026 alcoheca committed May 27, 2010
@@ -8,5 +8,5 @@
<extension-point id="lyrics" schema="script.xsd"/>
<extension-point id="weather" schema="script.xsd"/>
<extension-point id="library" schema="script.xsd"/>
- <extension-point id="plugin" schema="script.xsd"/>
+ <extension-point id="plugin" schema="pluginsource.xsd"/>
</addon>
@@ -0,0 +1,25 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE schema PUBLIC "-//W3C//DTD XMLSCHEMA 200102//EN" "http://www.w3.org/2001/XMLSchema.dtd">
+<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
+ <xs:element name="extension">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element maxOccurs="unbounded" ref="content"/>
+ </xs:sequence>
+ <xs:attribute name="point" type="xs:string" use="required"/>
+ <xs:attribute name="id" type="simpleIdentifier"/>
+ <xs:attribute name="name" type="xs:string"/>
+ </xs:complexType>
+ </xs:element>
+ <xs:element name="content">
+ <xs:complexType>
+ <xs:attribute name="type" type="xs:string" use="required"/>
+ </xs:complexType>
+ </xs:element>
+ <xs:simpleType name="simpleIdentifier">
+ <xs:restriction base="xs:string">
+ <xs:pattern value="[^.]+"/>
+ </xs:restriction>
+ </xs:simpleType>
+</xs:schema>
+
@@ -279,12 +279,12 @@ void CGUIDialogMediaSource::OnPathBrowse(int item)
extraShares.push_back(share1);
}
// add the plugins dir as needed
- if (ADDON::CAddonMgr::Get().HasAddons(ADDON::ADDON_PLUGIN, CONTENT_AUDIO))
+ /*if (ADDON::CAddonMgr::Get().HasAddons(ADDON::ADDON_PLUGIN, CONTENT_AUDIO))
{
share1.strPath = "plugin://music/";
share1.strName = g_localizeStrings.Get(1038); // Music Plugins
extraShares.push_back(share1);
- }
+ }*/
}
else if (m_type == "video")
{ // add the music playlist location
@@ -319,12 +319,12 @@ void CGUIDialogMediaSource::OnPathBrowse(int item)
extraShares.push_back(share1);
// add the plugins dir as needed
- if (ADDON::CAddonMgr::Get().HasAddons(ADDON::ADDON_PLUGIN, CONTENT_VIDEO))
+ /*if (ADDON::CAddonMgr::Get().HasAddons(ADDON::ADDON_PLUGIN, CONTENT_VIDEO))
{
share1.strPath = "plugin://video/";
share1.strName = g_localizeStrings.Get(1037); // Video Plugins
extraShares.push_back(share1);
- }
+ }*/
}
else if (m_type == "pictures")
{
@@ -350,23 +350,23 @@ void CGUIDialogMediaSource::OnPathBrowse(int item)
extraShares.push_back(share1);
// add the plugins dir as needed
- if (ADDON::CAddonMgr::Get().HasAddons(ADDON::ADDON_PLUGIN, CONTENT_IMAGE))
+ /*if (ADDON::CAddonMgr::Get().HasAddons(ADDON::ADDON_PLUGIN, CONTENT_IMAGE))
{
share1.strPath = "plugin://pictures/";
share1.strName = g_localizeStrings.Get(1039); // Picture Plugins
extraShares.push_back(share1);
- }
+ }*/
}
else if (m_type == "programs")
{
- if (ADDON::CAddonMgr::Get().HasAddons(ADDON::ADDON_PLUGIN, CONTENT_PROGRAM))
+ /*if (ADDON::CAddonMgr::Get().HasAddons(ADDON::ADDON_PLUGIN, CONTENT_PROGRAM))
{
CMediaSource share2;
share2.strPath = "plugin://programs/";
share2.strName = g_localizeStrings.Get(1043); // Program Plugins
share2.m_ignore = true;
extraShares.push_back(share2);
- }
+ }*/
}
if (CGUIDialogFileBrowser::ShowAndGetSource(path, allowNetworkShares, extraShares.size()==0?NULL:&extraShares))
{
View
@@ -128,7 +128,7 @@ CGUIViewState* CGUIViewState::GetViewState(int windowId, const CFileItemList& it
return new CGUIViewStateGeneral(items);
}
-CGUIViewState::CGUIViewState(const CFileItemList& items, const CONTENT_TYPE& content/*=CONTENT_NONE*/) : m_items(items)
+CGUIViewState::CGUIViewState(const CFileItemList& items, const CPluginSource::Content& content/*=CONTENT_NONE*/) : m_items(items)
{
m_currentViewAsControl=0;
m_currentSortMethod=0;
@@ -344,25 +344,26 @@ VECSOURCES& CGUIViewState::GetSources()
// more consolidation could happen here for all content types
// - playlists, autoconfig network shares, whatnot
- if (m_content == CONTENT_NONE)
- return m_sources;
-
- ADDON::VECADDONS addons;
- ADDON::CAddonMgr::Get().GetAddons(ADDON::ADDON_PLUGIN, addons, m_content);
+ VECADDONS addons;
+ ADDON::CAddonMgr::Get().GetAddons(ADDON_PLUGIN, 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;
+
// format for sources's path is
// eg. pictures://UUID
- CMediaSource plugin;
+ CMediaSource source;
CURL path;
path.SetProtocol("plugin");
- path.SetHostName(addons[i]->ID());
- plugin.strPath = path.Get();
- plugin.strName = addons[i]->Name();
- plugin.m_strThumbnailImage = addons[i]->Icon(); //FIXME cache by UUID
- plugin.m_iDriveType = CMediaSource::SOURCE_TYPE_REMOTE;
- m_sources.push_back(plugin);
+ path.SetHostName(plugin->ID());
+ source.strPath = path.Get();
+ source.strName = plugin->Name();
+ source.m_strThumbnailImage = plugin->Icon(); //FIXME cache by UUID
+ source.m_iDriveType = CMediaSource::SOURCE_TYPE_REMOTE;
+ m_sources.push_back(source);
}
return m_sources;
}
View
@@ -25,7 +25,7 @@
#include "SortFileItem.h"
#include "GUIBaseContainer.h"
#include "MediaSource.h"
-#include "addons/IAddon.h"
+#include "addons/PluginSource.h"
class CViewState; // forward
class CFileItemList;
@@ -63,7 +63,7 @@ class CGUIViewState
virtual VECSOURCES& GetSources();
protected:
- CGUIViewState(const CFileItemList& items, const CONTENT_TYPE& content = CONTENT_NONE); // no direct object creation, use GetViewState()
+ CGUIViewState(const CFileItemList& items, const ADDON::CPluginSource::Content& content = ADDON::CPluginSource::UNKNOWN); // no direct object creation, use GetViewState()
virtual void SaveViewState()=0;
virtual void SaveViewToDb(const CStdString &path, int windowID, CViewState *viewState = NULL);
void LoadViewState(const CStdString &path, int windowID);
@@ -74,7 +74,7 @@ class CGUIViewState
const CFileItemList& m_items;
static VECSOURCES m_sources;
- CONTENT_TYPE m_content;
+ ADDON::CPluginSource::Content m_content;
int m_currentViewAsControl;
View
@@ -23,11 +23,12 @@
#include "GUIViewState.h"
+using namespace ADDON;
class CGUIViewStateWindowMusic : public CGUIViewState
{
public:
- CGUIViewStateWindowMusic(const CFileItemList& items) : CGUIViewState(items, CONTENT_AUDIO) {}
+ CGUIViewStateWindowMusic(const CFileItemList& items) : CGUIViewState(items, CPluginSource::AUDIO) {}
protected:
virtual int GetPlaylist();
virtual bool AutoPlayNextItem();
@@ -33,8 +33,9 @@
#include "Key.h"
using namespace XFILE;
+using namespace ADDON;
-CGUIViewStateWindowPictures::CGUIViewStateWindowPictures(const CFileItemList& items) : CGUIViewState(items, CONTENT_IMAGE)
+CGUIViewStateWindowPictures::CGUIViewStateWindowPictures(const CFileItemList& items) : CGUIViewState(items, CPluginSource::IMAGE)
{
if (items.IsVirtualDirectoryRoot())
{
@@ -32,8 +32,9 @@
#include "Key.h"
using namespace XFILE;
+using namespace ADDON;
-CGUIViewStateWindowPrograms::CGUIViewStateWindowPrograms(const CFileItemList& items) : CGUIViewState(items, CONTENT_PROGRAM)
+CGUIViewStateWindowPrograms::CGUIViewStateWindowPrograms(const CFileItemList& items) : CGUIViewState(items, CPluginSource::EXECUTABLE)
{
if (g_guiSettings.GetBool("filelists.ignorethewhensorting"))
AddSortMethod(SORT_METHOD_LABEL_IGNORE_THE, 551, LABEL_MASKS("%K", "%I", "%L", "")); // Titel, Size | Foldername, empty
View
@@ -23,11 +23,12 @@
#include "GUIViewState.h"
+using namespace ADDON;
class CGUIViewStateWindowVideo : public CGUIViewState
{
public:
- CGUIViewStateWindowVideo(const CFileItemList& items) : CGUIViewState(items, CONTENT_VIDEO) {}
+ CGUIViewStateWindowVideo(const CFileItemList& items) : CGUIViewState(items, CPluginSource::VIDEO) {}
protected:
virtual CStdString GetLockType();
View
@@ -60,11 +60,7 @@ static const ContentMapping content[] =
{"movies", CONTENT_MOVIES, 20342 },
{"tvshows", CONTENT_TVSHOWS, 20343 },
{"episodes", CONTENT_EPISODES, 20360 },
- {"musicvideos", CONTENT_MUSICVIDEOS, 20389 },
- {"audio", CONTENT_AUDIO, 0 },
- {"image", CONTENT_IMAGE, 0 },
- {"program", CONTENT_PROGRAM, 0 },
- {"video", CONTENT_VIDEO, 0 }};
+ {"musicvideos", CONTENT_MUSICVIDEOS, 20389 }};
typedef struct
{
@@ -80,7 +76,7 @@ static const TypeMapping types[] =
{"xbmc.ui.screensaver", ADDON_SCREENSAVER, 24008 },
{"xbmc.player.musicviz", ADDON_VIZ, 24010 },
{"visualization-library", ADDON_VIZ_LIBRARY, 0 },
- {"xbmc.python.plugin", ADDON_PLUGIN, 24005 },
+ {"xbmc.python.pluginsource", ADDON_PLUGIN, 24005 },
{"xbmc.python.script", ADDON_SCRIPT, 24009 },
{"xbmc.python.weather", ADDON_SCRIPT_WEATHER, 24027 },
{"xbmc.python.subtitles", ADDON_SCRIPT_SUBTITLES, 24012 },
@@ -46,6 +46,7 @@
//#ifdef HAS_SCRAPERS
#include "Scraper.h"
//#endif
+#include "PluginSource.h"
#include "Repository.h"
#include "Skin.h"
@@ -57,6 +58,8 @@ namespace ADDON
cp_log_severity_t clog_to_cp(int lvl);
void cp_fatalErrorHandler(const char *msg);
void cp_logger(cp_log_severity_t level, const char *msg, const char *apid, void *user_data);
+const std::set<CPluginSource::Content> GetPluginContent(const cp_cfg_element_t*);
+bool GetExtElementDeque(DEQUEELEMENTS &elements, cp_cfg_element_t *base, const char *path);
/**********************************************************
* CAddonMgr
@@ -79,6 +82,13 @@ AddonPtr CAddonMgr::Factory(const cp_extension_t *props)
switch (type)
{
case ADDON_PLUGIN:
+ {
+ std::set<CPluginSource::Content> provides;
+ const cp_cfg_element_t *cfg = GetExtElement(props->configuration, "provides");
+ if (cfg)
+ return AddonPtr(new CPluginSource(props->plugin, GetPluginContent(cfg)));
+ }
+ break;
case ADDON_SCRIPT:
case ADDON_SCRIPT_LIBRARY:
case ADDON_SCRIPT_LYRICS:
@@ -400,6 +410,7 @@ AddonPtr CAddonMgr::AddonFromProps(AddonProps& addonProps)
switch (addonProps.type)
{
case ADDON_PLUGIN:
+ return AddonPtr(new CPluginSource(addonProps));
case ADDON_SCRIPT:
case ADDON_SCRIPT_LIBRARY:
case ADDON_SCRIPT_LYRICS:
@@ -498,7 +509,7 @@ const cp_cfg_element_t *CAddonMgr::GetExtElement(cp_cfg_element_t *base, const c
}
/* Returns all duplicate elements from a base element */
-bool CAddonMgr::GetExtElementDeque(DEQUEELEMENTS &elements, cp_cfg_element_t *base, const char *path)
+bool GetExtElementDeque(DEQUEELEMENTS &elements, cp_cfg_element_t *base, const char *path)
{
if (!base)
return false;
@@ -669,5 +680,25 @@ void cp_logger(cp_log_severity_t level, const char *msg, const char *apid, void
CLog::Log(cp_to_clog(level), "ADDON: cpluff: '%s' reports '%s'", apid, msg);
}
+const std::set<CPluginSource::Content> GetPluginContent(const cp_cfg_element_t *types)
+{
+ std::set<CPluginSource::Content> provides;
+ DEQUEELEMENTS elements;
+ if (GetExtElementDeque(elements, (cp_cfg_element_t *)types, "content"))
+ {
+ IDEQUEELEMENTS itr = elements.begin();
+ while (itr != elements.end())
+ {
+ CPluginSource::Content type = CPluginSource::Translate(CAddonMgr::Get().GetExtValue(*itr++, "@type"));
+ if (type != CPluginSource::UNKNOWN)
+ provides.insert(type);
+ }
+ }
+ if (provides.empty())
+ CLog::Log(LOGERROR, "ADDON: Plugin did not specify any content types, will ignore");
+
+ return provides;
+}
+
} /* namespace ADDON */
@@ -137,7 +137,6 @@ namespace ADDON
/* libcpluff */
bool GetExtensions(const TYPE &type, VECADDONS &addons, const CONTENT_TYPE &content);
const cp_cfg_element_t *GetExtElement(cp_cfg_element_t *base, const char *path);
- bool GetExtElementDeque(DEQUEELEMENTS &elements, cp_cfg_element_t *base, const char *path);
cp_context_t *m_cp_context;
DllLibCPluff *m_cpluff;
View
@@ -35,10 +35,6 @@ typedef enum
CONTENT_ALBUMS,
CONTENT_ARTISTS,
CONTENT_NONE,
- CONTENT_AUDIO,
- CONTENT_IMAGE,
- CONTENT_PROGRAM,
- CONTENT_VIDEO
} CONTENT_TYPE;
namespace ADDON
@@ -68,6 +64,8 @@ namespace ADDON
typedef boost::shared_ptr<CVisualisation> VizPtr;
class CSkinInfo;
typedef boost::shared_ptr<CSkinInfo> SkinPtr;
+ class CPluginSource;
+ typedef boost::shared_ptr<CPluginSource> PluginPtr;
class CAddonMgr;
class AddonVersion;
View
@@ -3,6 +3,7 @@ INCLUDES+=-I. -I../ -I../../guilib -I../utils -I../linux
SRCS=Addon.cpp \
AddonManager.cpp \
AddonStatusHandler.cpp \
+ PluginSource.cpp \
ScreenSaver.cpp \
Scraper.cpp \
Skin.cpp \
@@ -0,0 +1,48 @@
+/*
+ * Copyright (C) 2005-2010 Team XBMC
+ * http://www.xbmc.org
+ *
+ * This Program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2, or (at your option)
+ * any later version.
+ *
+ * This Program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with XBMC; see the file COPYING. If not, write to
+ * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
+ * http://www.gnu.org/copyleft/gpl.html
+ *
+ */
+#include "PluginSource.h"
+#include "AddonManager.h"
+
+namespace ADDON
+{
+
+CPluginSource::CPluginSource(cp_plugin_info_t *props, const std::set<CPluginSource::Content> &provides)
+ : CAddon(props)
+ , m_providedContent(provides)
+{
+}
+
+CPluginSource::Content CPluginSource::Translate(const CStdString &content)
+{
+ if (content.Equals("audio"))
+ return CPluginSource::AUDIO;
+ else if (content.Equals("image"))
+ return CPluginSource::IMAGE;
+ else if (content.Equals("executable"))
+ return CPluginSource::EXECUTABLE;
+ else if (content.Equals("video"))
+ return CPluginSource::VIDEO;
+ else
+ return CPluginSource::UNKNOWN;
+}
+
+} /*namespace ADDON*/
+
Oops, something went wrong.

0 comments on commit 16b848a

Please sign in to comment.