From ae691d390c87365087ffd8fa41cafb19599740d2 Mon Sep 17 00:00:00 2001
From: montellese <montellese@xbmc.org>
Date: Tue, 30 Aug 2011 18:14:35 +0200
Subject: jsonrpc: consider "musiclibrary.showcompilationartists" setting in
 AudioLibrary.GetArtists (fixes #11816)

---
 xbmc/interfaces/json-rpc/AudioLibrary.cpp     | 6 +++++-
 xbmc/interfaces/json-rpc/ServiceDescription.h | 5 +++++
 xbmc/interfaces/json-rpc/methods.json         | 1 +
 xbmc/interfaces/json-rpc/types.json           | 4 ++++
 4 files changed, 15 insertions(+), 1 deletion(-)

diff --git a/xbmc/interfaces/json-rpc/AudioLibrary.cpp b/xbmc/interfaces/json-rpc/AudioLibrary.cpp
index 0b3566d3d6..97959923af 100644
--- a/xbmc/interfaces/json-rpc/AudioLibrary.cpp
+++ b/xbmc/interfaces/json-rpc/AudioLibrary.cpp
@@ -49,8 +49,12 @@ JSON_STATUS CAudioLibrary::GetArtists(const CStdString &method, ITransportLayer
     param["fields"] = CVariant(CVariant::VariantTypeArray);
   param["fields"].append("artist");
 
+  bool albumArtistsOnly = !g_guiSettings.GetBool("musiclibrary.showcompilationartists");
+  if (parameterObject["albumartistsonly"].isBoolean())
+    albumArtistsOnly = parameterObject["albumartistsonly"].asBoolean();
+
   CFileItemList items;
-  if (musicdatabase.GetArtistsNav("", items, genreID, false))
+  if (musicdatabase.GetArtistsNav("", items, genreID, albumArtistsOnly))
     HandleFileItemList("artistid", false, "artists", items, param, result);
 
   musicdatabase.Close();
diff --git a/xbmc/interfaces/json-rpc/ServiceDescription.h b/xbmc/interfaces/json-rpc/ServiceDescription.h
index cdc3ecb3c1..9701d81f21 100644
--- a/xbmc/interfaces/json-rpc/ServiceDescription.h
+++ b/xbmc/interfaces/json-rpc/ServiceDescription.h
@@ -27,6 +27,10 @@ namespace JSONRPC
   const char* const JSONRPC_SERVICE_DESCRIPTION = "JSON RPC API of XBMC";
 
   const char* const JSONRPC_SERVICE_TYPES[] = {  
+    "\"Optional.Boolean\": {"
+      "\"type\": [ \"null\", \"boolean\" ],"
+      "\"default\": null"
+    "}",
     "\"Global.Time\": {"
       "\"type\": \"object\","
       "\"properties\": {"
@@ -1647,6 +1651,7 @@ namespace JSONRPC
       "\"transport\": \"Response\","
       "\"permission\": \"ReadData\","
       "\"params\": ["
+        "{ \"name\": \"albumartistsonly\", \"$ref\": \"Optional.Boolean\", \"description\": \"Whether or not to include artists only appearing in compilations. If the parameter is not passed or is passed as null the GUI setting will be used\" },"
         "{ \"name\": \"genreid\", \"$ref\": \"Library.Id\" },"
         "{ \"name\": \"fields\", \"$ref\": \"Audio.Fields.Artist\" },"
         "{ \"name\": \"limits\", \"$ref\": \"List.Limits\" },"
diff --git a/xbmc/interfaces/json-rpc/methods.json b/xbmc/interfaces/json-rpc/methods.json
index 5494d91a39..98bfd45493 100644
--- a/xbmc/interfaces/json-rpc/methods.json
+++ b/xbmc/interfaces/json-rpc/methods.json
@@ -870,6 +870,7 @@
     "transport": "Response",
     "permission": "ReadData",
     "params": [
+      { "name": "albumartistsonly", "$ref": "Optional.Boolean", "description": "Whether or not to include artists only appearing in compilations. If the parameter is not passed or is passed as null the GUI setting will be used" },
       { "name": "genreid", "$ref": "Library.Id" },
       { "name": "fields", "$ref": "Audio.Fields.Artist" },
       { "name": "limits", "$ref": "List.Limits" },
diff --git a/xbmc/interfaces/json-rpc/types.json b/xbmc/interfaces/json-rpc/types.json
index 5b15fa55d0..e8bb04badf 100644
--- a/xbmc/interfaces/json-rpc/types.json
+++ b/xbmc/interfaces/json-rpc/types.json
@@ -1,4 +1,8 @@
 {
+  "Optional.Boolean": {
+    "type": [ "null", "boolean" ],
+    "default": null
+  },
   "Global.Time": {
     "type": "object",
     "properties": {
-- 
cgit v1.2.3