Skip to content

Commit

Permalink
[retroplayer/api] - (1004) Add "uninstalled" parameter to Addons.GetA…
Browse files Browse the repository at this point in the history
…ddons

This allows the JSON-RPC client to get (uninstalled) add-on info from remote
repos.

Example:

Addon.GetAddons({
  "method": "Addons.GetAddons",
  "params": {
    "type":    "xbmc.addon.video",
    "enabled": "uninstalled"
  }
})
  • Loading branch information
garbear committed Oct 27, 2015
1 parent 945d52e commit 9126737
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 3 deletions.
20 changes: 18 additions & 2 deletions xbmc/interfaces/json-rpc/AddonsOperations.cpp
Expand Up @@ -75,10 +75,27 @@ JSONRPC_STATUS CAddonsOperations::GetAddons(const std::string &method, ITranspor
addonTypes.push_back(addonType);

VECADDONS addons;
CAddonDatabase addondb;
for (vector<TYPE>::const_iterator typeIt = addonTypes.begin(); typeIt != addonTypes.end(); ++typeIt)
{
VECADDONS typeAddons;
if (*typeIt == ADDON_UNKNOWN)
// "uninstalled" add-ons don't make use of the enabled parameter
if (enabled.asString() == "uninstalled")
{
VECADDONS allAddons;
addondb.Open();
addondb.GetAddons(allAddons);
addondb.Close();
for (VECADDONS::const_iterator allIt = allAddons.begin(); allIt != allAddons.end(); allIt++)
{
AddonPtr allAddon = *allIt;
AddonPtr temp;
if ((*typeIt == ADDON_UNKNOWN ? true : allAddon->Type() == *typeIt) &&
!CAddonMgr::Get().GetAddon(allAddon->ID(), temp, *typeIt, false))
typeAddons.push_back(allAddon);
}
}
else if (*typeIt == ADDON_UNKNOWN)
{
if (!enabled.isBoolean())
{
Expand Down Expand Up @@ -122,7 +139,6 @@ JSONRPC_STATUS CAddonsOperations::GetAddons(const std::string &method, ITranspor
int start, end;
HandleLimits(parameterObject, result, addons.size(), start, end);

CAddonDatabase addondb;
for (int index = start; index < end; index++)
FillDetails(addons.at(index), parameterObject["properties"], result["addons"], addondb, true);

Expand Down
2 changes: 1 addition & 1 deletion xbmc/interfaces/json-rpc/schema/methods.json
Expand Up @@ -1629,7 +1629,7 @@
"params": [
{ "name": "type", "$ref": "Addon.Types" },
{ "name": "content", "$ref": "Addon.Content", "description": "Content provided by the addon. Only considered for plugins and scripts." },
{ "name": "enabled", "type": [ { "type": "boolean" }, { "type": "string", "enum": [ "all" ] } ], "default": "all" },
{ "name": "enabled", "type": [ { "type": "boolean" }, { "type": "string", "enum": [ "all", "uninstalled" ] } ], "default": "all" },
{ "name": "properties", "$ref": "Addon.Fields" },
{ "name": "limits", "$ref": "List.Limits" }
],
Expand Down

0 comments on commit 9126737

Please sign in to comment.