diff options
author | jmarshallnz <jmarshallnz@svn> | 2010-05-27 00:13:21 +0000 |
---|---|---|
committer | jmarshallnz <jmarshallnz@svn> | 2010-05-27 00:13:21 +0000 |
commit | 9d9704e40f9d9c5a281ee726de99b5c4e6341638 (patch) | |
tree | bf77f19f64c5403e21eb41942890110e9229e513 | |
parent | 48aa97d415d3f0687ddf7a844cd85809548e411a (diff) |
cleanup: Make <supportedcontent> and <platform> use the same xs:list style schema
git-svn-id: https://xbmc.svn.sourceforge.net/svnroot/xbmc/trunk@30597 568bbfeb-2a22-0410-94d2-cc84cf5bfa90
-rw-r--r-- | addons/xbmc.addon/metadata.xsd | 27 | ||||
-rw-r--r-- | xbmc/addons/Addon.cpp | 6 | ||||
-rw-r--r-- | xbmc/addons/AddonManager.cpp | 29 | ||||
-rw-r--r-- | xbmc/addons/AddonManager.h | 11 |
4 files changed, 52 insertions, 21 deletions
diff --git a/addons/xbmc.addon/metadata.xsd b/addons/xbmc.addon/metadata.xsd index 639f4d828b..b38d08d2d8 100644 --- a/addons/xbmc.addon/metadata.xsd +++ b/addons/xbmc.addon/metadata.xsd @@ -8,8 +8,8 @@ <xs:element name="description" type="translatedString" minOccurs="0" maxOccurs="unbounded"/> <xs:element name="disclaimer" type="translatedString" minOccurs="0"/> <xs:element name="license" type="xs:string"/> - <xs:element name="platform" type="xs:string" minOccurs="0"/> - <xs:element name="supportedcontent" type="xs:string" minOccurs="0"/> + <xs:element name="platform" type="platformList" minOccurs="0"/> + <xs:element name="supportedcontent" type="contentList" minOccurs="0"/> </xs:sequence> <xs:attribute name="point" type="xs:string" use="required"/> <xs:attribute name="id" type="simpleIdentifier"/> @@ -28,4 +28,27 @@ </xs:extension> </xs:simpleContent> </xs:complexType> + <xs:simpleType name="platformType"> + <xs:restriction base="xs:string"> + <xs:enumeration value="linux"/> + <xs:enumeration value="osx"/> + <xs:enumeration value="wingl"/> + <xs:enumeration value="windx"/> + </xs:restriction> + </xs:simpleType> + <xs:simpleType name="platformList"> + <xs:list itemType="platformType"/> + </xs:simpleType> + <xs:simpleType name="contentType"> + <xs:restriction base="xs:string"> + <xs:enumeration value="albums"/> + <xs:enumeration value="artists"/> + <xs:enumeration value="movies"/> + <xs:enumeration value="tvshows"/> + <xs:enumeration value="musicvideos"/> + </xs:restriction> + </xs:simpleType> + <xs:simpleType name="contentList"> + <xs:list itemType="contentType"/> + </xs:simpleType> </xs:schema> diff --git a/xbmc/addons/Addon.cpp b/xbmc/addons/Addon.cpp index aa095f4e7b..9cf24c81fd 100644 --- a/xbmc/addons/Addon.cpp +++ b/xbmc/addons/Addon.cpp @@ -201,16 +201,14 @@ AddonProps::AddonProps(cp_plugin_info_t *props) const cp_extension_t *metadata = CAddonMgr::Get().GetExtension(props, "xbmc.addon.metadata"); if (metadata) { - CStdString platforms = CAddonMgr::Get().GetExtValue(metadata->configuration, "platform"); summary = CAddonMgr::Get().GetTranslatedString(metadata->configuration, "summary"); description = CAddonMgr::Get().GetTranslatedString(metadata->configuration, "description"); disclaimer = CAddonMgr::Get().GetTranslatedString(metadata->configuration, "disclaimer"); license = CAddonMgr::Get().GetExtValue(metadata->configuration, "license"); - vector<CStdString> content = CAddonMgr::Get().GetExtValues(metadata->configuration,"supportedcontent"); + vector<CStdString> content; + CAddonMgr::Get().GetExtList(metadata->configuration,"supportedcontent", content); for (unsigned int i=0;i<content.size();++i) contents.insert(TranslateContent(content[i])); - //FIXME other stuff goes here - //CStdString version = CAddonMgr::Get().GetExtValue(metadata->configuration, "minversion/xbmc"); } icon = "icon.png"; fanart = CUtil::AddFileToFolder(path, "fanart.jpg"); diff --git a/xbmc/addons/AddonManager.cpp b/xbmc/addons/AddonManager.cpp index 42ce329c01..3f7863931b 100644 --- a/xbmc/addons/AddonManager.cpp +++ b/xbmc/addons/AddonManager.cpp @@ -463,13 +463,12 @@ bool CAddonMgr::PlatformSupportsAddon(const cp_plugin_info_t *plugin) const if (!plugin || !plugin->num_extensions) return false; const cp_extension_t *metadata = GetExtension(plugin, "xbmc.addon.metadata"); - if (metadata) + if (!metadata) + return false; + + vector<CStdString> platforms; + if (CAddonMgr::Get().GetExtList(metadata->configuration, "platform", platforms)) { - CStdString platformString = CAddonMgr::Get().GetExtValue(metadata->configuration, "platform"); - if (platformString.IsEmpty()) - return true; // no platform string, assume <platform>all</platform> - vector<CStdString> platforms; - StringUtils::SplitString(platformString, " ", platforms); for (unsigned int i = 0; i < platforms.size(); ++i) { if (platforms[i] == "all") @@ -485,8 +484,9 @@ bool CAddonMgr::PlatformSupportsAddon(const cp_plugin_info_t *plugin) const #endif return true; } + return false; // no <platform> works for us } - return false; + return true; // assume no <platform> is equivalent to <platform>all</platform> } const cp_cfg_element_t *CAddonMgr::GetExtElement(cp_cfg_element_t *base, const char *path) @@ -556,14 +556,15 @@ CStdString CAddonMgr::GetExtValue(cp_cfg_element_t *base, const char *path) else return CStdString(); } -vector<CStdString> CAddonMgr::GetExtValues(cp_cfg_element_t *base, const char *path) +bool CAddonMgr::GetExtList(cp_cfg_element_t *base, const char *path, vector<CStdString> &result) const { - vector<CStdString> result; - cp_cfg_element_t *parent = m_cpluff->lookup_cfg_element(base,path); - for (unsigned int i=0;parent && i<parent->num_children;++i) - result.push_back(parent->children[i].value); - - return result; + if (!base || !path) + return false; + CStdString all = m_cpluff->lookup_cfg_value(base, path); + if (all.IsEmpty()) + return false; + StringUtils::SplitString(all, " ", result); + return true; } AddonPtr CAddonMgr::GetAddonFromDescriptor(const cp_plugin_info_t *info) diff --git a/xbmc/addons/AddonManager.h b/xbmc/addons/AddonManager.h index 507a56fb3e..15e24f3d9f 100644 --- a/xbmc/addons/AddonManager.h +++ b/xbmc/addons/AddonManager.h @@ -100,7 +100,16 @@ namespace ADDON /* libcpluff */ CStdString GetExtValue(cp_cfg_element_t *base, const char *path); - std::vector<CStdString> GetExtValues(cp_cfg_element_t *base, const char *path); + + /*! \brief Retrieve a list of strings from a given configuration element + Assumes the configuration element or attribute contains a whitespace separated list of values (eg xs:list schema). + \param base the base configuration element. + \param path the path to the configuration element or attribute from the base element. + \param result [out] returned list of strings. + \return true if the configuration element is present and the list of strings is non-empty + */ + bool GetExtList(cp_cfg_element_t *base, const char *path, std::vector<CStdString> &result) const; + const cp_extension_t *GetExtension(const cp_plugin_info_t *props, const char *extension) const; /*! \brief Load the addon in the given path |