set a content_type parameter for multi-content plugins/scripts #1265

Merged
2 commits merged into from Aug 8, 2012
Jump to file or symbol
Failed to load files and symbols.
+22 −6
Diff settings

Always

Just for now

View
@@ -35,8 +35,15 @@ class CPluginSource : public CAddon
CPluginSource(const AddonProps &props);
virtual ~CPluginSource() {}
virtual bool IsType(TYPE type) const;
- bool Provides(const Content& content) const {
- return content == UNKNOWN ? false : m_providedContent.count(content) > 0; }
+ bool Provides(const Content& content) const
+ {
+ return content == UNKNOWN ? false : m_providedContent.count(content) > 0;
+ }
+
+ bool ProvidesSeveral() const
+ {
+ return m_providedContent.size() > 1;
+ }
static Content Translate(const CStdString &content);
private:
@@ -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));