Permalink
Browse files

changed: Allow repository to have c-pluff XML files

git-svn-id: https://xbmc.svn.sourceforge.net/svnroot/xbmc/trunk@30336 568bbfeb-2a22-0410-94d2-cc84cf5bfa90
  • Loading branch information...
1 parent 9ea9065 commit 4488d3a0a8f58cd9b97fbf284be0704887282e2b jmarshallnz committed May 20, 2010
Showing with 51 additions and 16 deletions.
  1. +29 −0 xbmc/addons/AddonManager.cpp
  2. +2 −0 xbmc/addons/AddonManager.h
  3. +20 −16 xbmc/addons/Repository.cpp
View
29 xbmc/addons/AddonManager.cpp
@@ -1014,6 +1014,35 @@ CStdString CAddonMgr::GetExtValue(cp_cfg_element_t *base, const char *path)
else return CStdString();
}
+bool CAddonMgr::AddonsFromInfoXML(const TiXmlElement *root, VECADDONS &addons)
+{
+ // create a context for these addons
+ cp_status_t status;
+ cp_context_t *context = m_cpluff->create_context(&status);
+ if (!root || !context)
+ return false;
+
+ const TiXmlElement *element = root->FirstChildElement("addon");
+ while (element)
+ {
+ // dump the XML back to text (FIXME: should we add the utf8 descriptor?)
+ std::string xml;
+ xml << *element;
+ cp_status_t status;
+ cp_plugin_info_t *info = m_cpluff->load_plugin_descriptor(context, xml.c_str(), xml.size(), &status);
+ if (info)
+ {
+ AddonPtr addon = Factory(info->extensions);
+ m_cpluff->release_info(context, info);
+ // FIXME: sanity check here that the addon satisfies our requirements?
+ addons.push_back(addon);
+ }
+ element = element->NextSiblingElement("addon");
+ }
+ m_cpluff->destroy_context(context);
+ return true;
+}
+
int cp_to_clog(cp_log_severity_t lvl)
{
if( lvl == CP_LOG_DEBUG )
View
2 xbmc/addons/AddonManager.h
@@ -105,6 +105,8 @@ namespace ADDON
/* libcpluff */
CStdString GetExtValue(cp_cfg_element_t *base, const char *path);
const cp_extension_t *GetExtension(const cp_plugin_info_t *props, const char *extension);
+ bool AddonsFromInfoXML(const TiXmlElement *root, VECADDONS &addons);
+
private:
void LoadAddons(const CStdString &path,
std::map<CStdString, AddonPtr>& unresolved);
View
36 xbmc/addons/Repository.cpp
@@ -120,29 +120,33 @@ VECADDONS CRepository::Parse()
doc.LoadFile(file);
if (doc.RootElement())
{
+ CAddonMgr::Get().AddonsFromInfoXML(doc.RootElement(), result);
+ // FIXME no need for this once everything is c-pluff'd
TiXmlElement* element = doc.RootElement()->FirstChildElement("addoninfo");
while (element)
{
AddonPtr addon;
- if (CAddonMgr::AddonFromInfoXML(element,addon,m_info))
- {
- if (m_zipped)
- {
- addon->Props().path = CUtil::AddFileToFolder(m_datadir,addon->ID()+"/"+addon->ID()+"-"+addon->Version().str+".zip");
- addon->Props().icon = CUtil::AddFileToFolder(m_datadir,addon->ID()+"/icon.png");
- addon->Props().changelog = CUtil::AddFileToFolder(m_datadir,addon->ID()+"/changelog-"+addon->Version().str+".txt");
- addon->Props().fanart = CUtil::AddFileToFolder(m_datadir,addon->ID()+"/fanart.jpg");
- }
- else
- {
- addon->Props().path = CUtil::AddFileToFolder(m_datadir,addon->ID()+"/");
- addon->Props().changelog = CUtil::AddFileToFolder(m_datadir,addon->ID()+"/changelog.txt");
- addon->Props().fanart = CUtil::AddFileToFolder(m_datadir,addon->ID()+"/fanart.jpg");
- }
+ if (CAddonMgr::Get().AddonFromInfoXML(element, addon, m_info))
result.push_back(addon);
- }
element = element->NextSiblingElement("addoninfo");
}
+ for (IVECADDONS i = result.begin(); i != result.end(); ++i)
+ {
+ AddonPtr addon = *i;
+ if (m_zipped)
+ {
+ addon->Props().path = CUtil::AddFileToFolder(m_datadir,addon->ID()+"/"+addon->ID()+"-"+addon->Version().str+".zip");
+ addon->Props().icon = CUtil::AddFileToFolder(m_datadir,addon->ID()+"/icon.png");
+ addon->Props().changelog = CUtil::AddFileToFolder(m_datadir,addon->ID()+"/changelog-"+addon->Version().str+".txt");
+ addon->Props().fanart = CUtil::AddFileToFolder(m_datadir,addon->ID()+"/fanart.jpg");
+ }
+ else
+ {
+ addon->Props().path = CUtil::AddFileToFolder(m_datadir,addon->ID()+"/");
+ addon->Props().changelog = CUtil::AddFileToFolder(m_datadir,addon->ID()+"/changelog.txt");
+ addon->Props().fanart = CUtil::AddFileToFolder(m_datadir,addon->ID()+"/fanart.jpg");
+ }
+ }
}
return result;

0 comments on commit 4488d3a

Please sign in to comment.