Skip to content
This repository
Browse code

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...
commit b704b75f96823be769f9b1940c43fdd9617c7f82 1 parent 7a988cf
authored August 08, 2012
5  xbmc/addons/PluginSource.h
@@ -40,6 +40,11 @@ class CPluginSource : public CAddon
40 40
     return content == UNKNOWN ? false : m_providedContent.count(content) > 0;
41 41
   }
42 42
 
  43
+  bool ProvidesSeveral() const
  44
+  {
  45
+    return m_providedContent.size() > 1;
  46
+  }
  47
+
43 48
   static Content Translate(const CStdString &content);
44 49
 private:
45 50
   /*! \brief Set the provided content for this plugin
17  xbmc/filesystem/AddonsDirectory.cpp
@@ -295,10 +295,19 @@ bool CAddonsDirectory::GetScriptsAndPlugins(const CStdString &content, CFileItem
295 295
 
296 296
   for (unsigned i=0; i<addons.size(); i++)
297 297
   {
298  
-    if (addons[i]->Type() == ADDON_PLUGIN)
299  
-      items.Add(FileItemFromAddon(addons[i], "plugin://", true));
300  
-    else
301  
-      items.Add(FileItemFromAddon(addons[i], "script://", false));
  298
+    CFileItemPtr item(FileItemFromAddon(addons[i], 
  299
+                      addons[i]->Type()==ADDON_PLUGIN?"plugin://":"script://",
  300
+                      addons[i]->Type() == ADDON_PLUGIN));
  301
+    PluginPtr plugin = boost::dynamic_pointer_cast<CPluginSource>(addons[i]);
  302
+    if (plugin->ProvidesSeveral())
  303
+    {
  304
+      CURL url = item->GetAsUrl();
  305
+      CStdString opt;
  306
+      opt.Format("?content_type=%s",content.c_str());
  307
+      url.SetOptions(opt);
  308
+      item->SetPath(url.Get());
  309
+    }
  310
+    items.Add(item);
302 311
   }
303 312
 
304 313
   items.Add(GetMoreItem(content));

0 notes on commit b704b75

Please sign in to comment.
Something went wrong with that request. Please try again.