Permalink
Browse files

added: set a content_type parameter for multi-content plugins/scripts

plugins/scripts providing multiple contents can use this to see
the context they are called under and (choose to) only provide the
appropriate content
  • Loading branch information...
spiff
spiff committed Aug 8, 2012
1 parent 7a988cf commit b704b75f96823be769f9b1940c43fdd9617c7f82
Showing with 18 additions and 4 deletions.
  1. +5 −0 xbmc/addons/PluginSource.h
  2. +13 −4 xbmc/filesystem/AddonsDirectory.cpp
@@ -40,6 +40,11 @@ class CPluginSource : public CAddon
return content == UNKNOWN ? false : m_providedContent.count(content) > 0;
}
+ bool ProvidesSeveral() const
+ {
+ return m_providedContent.size() > 1;
+ }
+
static Content Translate(const CStdString &content);
private:
/*! \brief Set the provided content for this plugin
@@ -295,10 +295,19 @@ bool CAddonsDirectory::GetScriptsAndPlugins(const CStdString &content, CFileItem
for (unsigned i=0; i<addons.size(); i++)
{
- if (addons[i]->Type() == ADDON_PLUGIN)
- items.Add(FileItemFromAddon(addons[i], "plugin://", true));
- else
- items.Add(FileItemFromAddon(addons[i], "script://", false));
+ CFileItemPtr item(FileItemFromAddon(addons[i],
+ addons[i]->Type()==ADDON_PLUGIN?"plugin://":"script://",
+ addons[i]->Type() == ADDON_PLUGIN));
+ PluginPtr plugin = boost::dynamic_pointer_cast<CPluginSource>(addons[i]);
+ if (plugin->ProvidesSeveral())
+ {
+ CURL url = item->GetAsUrl();
+ CStdString opt;
+ opt.Format("?content_type=%s",content.c_str());
+ url.SetOptions(opt);
+ item->SetPath(url.Get());
+ }
+ items.Add(item);
}
items.Add(GetMoreItem(content));

0 comments on commit b704b75

Please sign in to comment.