[textures] expose the texture cache to JSON-RPC with GetTextures/RemoveTexture
authorJonathan Marshall <jmarshall@xbmc.org>
Sat, 26 Oct 2013 07:53:26 +0000 (20:53 +1300)
committerJonathan Marshall <jmarshall@xbmc.org>
Sat, 2 Nov 2013 22:41:05 +0000 (11:41 +1300)
13 files changed:
XBMC.xcodeproj/project.pbxproj
project/VS2010Express/XBMC.vcxproj
project/VS2010Express/XBMC.vcxproj.filters
xbmc/TextureDatabase.cpp
xbmc/TextureDatabase.h
xbmc/interfaces/json-rpc/JSONRPC.cpp
xbmc/interfaces/json-rpc/JSONServiceDescription.cpp
xbmc/interfaces/json-rpc/Makefile
xbmc/interfaces/json-rpc/ServiceDescription.h
xbmc/interfaces/json-rpc/TextureOperations.cpp [new file with mode: 0644]
xbmc/interfaces/json-rpc/TextureOperations.h [new file with mode: 0644]
xbmc/interfaces/json-rpc/methods.json
xbmc/interfaces/json-rpc/types.json

index bc3261d..4b19a58 100644 (file)
                7C89674613C03B22003631FE /* InfoBool.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7C89674313C03B22003631FE /* InfoBool.cpp */; };
                7C8A14571154CB2600E5FCFA /* TextureCache.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7C8A14541154CB2600E5FCFA /* TextureCache.cpp */; };
                7C8A187D115B2A8200E5FCFA /* TextureDatabase.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7C8A187A115B2A8200E5FCFA /* TextureDatabase.cpp */; };
+               7C920CF9181669FF00DA1477 /* TextureOperations.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7C920CF7181669FF00DA1477 /* TextureOperations.cpp */; };
+               7C920CFA181669FF00DA1477 /* TextureOperations.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7C920CF7181669FF00DA1477 /* TextureOperations.cpp */; };
+               7C920CFB181669FF00DA1477 /* TextureOperations.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7C920CF7181669FF00DA1477 /* TextureOperations.cpp */; };
                7C99B6A4133D342100FC2B16 /* CircularCache.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7C99B6A2133D342100FC2B16 /* CircularCache.cpp */; };
                7C99B7951340723F00FC2B16 /* GUIDialogPlayEject.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7C99B7931340723F00FC2B16 /* GUIDialogPlayEject.cpp */; };
                7CAA20511079C8160096DE39 /* BaseRenderer.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7CAA204F1079C8160096DE39 /* BaseRenderer.cpp */; };
                7C8A14551154CB2600E5FCFA /* TextureCache.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TextureCache.h; sourceTree = "<group>"; };
                7C8A187A115B2A8200E5FCFA /* TextureDatabase.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = TextureDatabase.cpp; sourceTree = "<group>"; };
                7C8A187B115B2A8200E5FCFA /* TextureDatabase.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TextureDatabase.h; sourceTree = "<group>"; };
+               7C920CF7181669FF00DA1477 /* TextureOperations.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = TextureOperations.cpp; sourceTree = "<group>"; };
+               7C920CF8181669FF00DA1477 /* TextureOperations.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TextureOperations.h; sourceTree = "<group>"; };
                7C99B6A2133D342100FC2B16 /* CircularCache.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CircularCache.cpp; sourceTree = "<group>"; };
                7C99B6A3133D342100FC2B16 /* CircularCache.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CircularCache.h; sourceTree = "<group>"; };
                7C99B7931340723F00FC2B16 /* GUIDialogPlayEject.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = GUIDialogPlayEject.cpp; sourceTree = "<group>"; };
                                DF00492C162DAEA200A971AD /* PVROperations.h */,
                                F5AE409613415D9E0004BD79 /* SystemOperations.cpp */,
                                F5AE409713415D9E0004BD79 /* SystemOperations.h */,
+                               7C920CF7181669FF00DA1477 /* TextureOperations.cpp */,
+                               7C920CF8181669FF00DA1477 /* TextureOperations.h */,
                                F5AE409813415D9E0004BD79 /* VideoLibrary.cpp */,
                                F5AE409913415D9E0004BD79 /* VideoLibrary.h */,
                                F5AE409A13415D9E0004BD79 /* XBMCOperations.cpp */,
                                DFD882E917DD189E001516FE /* StringValidation.cpp in Sources */,
                                F500E35617F3412C004FC217 /* WinEvents.cpp in Sources */,
                                7C2612711825B6340086E04D /* DatabaseQuery.cpp in Sources */,
+                               7C920CF9181669FF00DA1477 /* TextureOperations.cpp in Sources */,
                        );
                        runOnlyForDeploymentPostprocessing = 0;
                };
                                DFD882E717DD189E001516FE /* StringValidation.cpp in Sources */,
                                F500E35817F3412C004FC217 /* WinEvents.cpp in Sources */,
                                7C2612731825B6340086E04D /* DatabaseQuery.cpp in Sources */,
+                               7C920CFB181669FF00DA1477 /* TextureOperations.cpp in Sources */,
                        );
                        runOnlyForDeploymentPostprocessing = 0;
                };
                                DFD882E817DD189E001516FE /* StringValidation.cpp in Sources */,
                                F500E35717F3412C004FC217 /* WinEvents.cpp in Sources */,
                                7C2612721825B6340086E04D /* DatabaseQuery.cpp in Sources */,
+                               7C920CFA181669FF00DA1477 /* TextureOperations.cpp in Sources */,
                        );
                        runOnlyForDeploymentPostprocessing = 0;
                };
index 9ff5c98..7cea765 100644 (file)
     <ClCompile Include="..\..\xbmc\interfaces\json-rpc\SystemOperations.cpp" />
     <ClCompile Include="..\..\xbmc\interfaces\json-rpc\VideoLibrary.cpp" />
     <ClCompile Include="..\..\xbmc\interfaces\json-rpc\XBMCOperations.cpp" />
+    <ClCompile Include="..\..\xbmc\interfaces\json-rpc\TextureOperations.cpp" />
     <ClCompile Include="..\..\xbmc\interfaces\legacy\Addon.cpp" />
     <ClCompile Include="..\..\xbmc\interfaces\legacy\AddonCallback.cpp" />
     <ClCompile Include="..\..\xbmc\interfaces\legacy\AddonClass.cpp" />
     <ClInclude Include="..\..\xbmc\interfaces\json-rpc\SystemOperations.h" />
     <ClInclude Include="..\..\xbmc\interfaces\json-rpc\VideoLibrary.h" />
     <ClInclude Include="..\..\xbmc\interfaces\json-rpc\XBMCOperations.h" />
+    <ClInclude Include="..\..\xbmc\interfaces\json-rpc\TextureOperations.h" />
     <ClInclude Include="..\..\xbmc\IProgressCallback.h" />
     <ClInclude Include="..\..\xbmc\LangInfo.h" />
     <ClInclude Include="..\..\xbmc\MediaSource.h" />
index adbb54e..98a6ca6 100644 (file)
     <ClCompile Include="..\..\xbmc\interfaces\json-rpc\XBMCOperations.cpp">
       <Filter>interfaces\json-rpc</Filter>
     </ClCompile>
+    <ClCompile Include="..\..\xbmc\interfaces\json-rpc\TextureOperations.cpp">
+      <Filter>interfaces\json-rpc</Filter>
+    </ClCompile>
     <ClCompile Include="..\..\xbmc\music\dialogs\GUIDialogMusicInfo.cpp">
       <Filter>music\dialogs</Filter>
     </ClCompile>
     <ClInclude Include="..\..\xbmc\interfaces\json-rpc\XBMCOperations.h">
       <Filter>interfaces\json-rpc</Filter>
     </ClInclude>
+    <ClInclude Include="..\..\xbmc\interfaces\json-rpc\TextureOperations.h">
+      <Filter>interfaces\json-rpc</Filter>
+    </ClInclude>
     <ClInclude Include="..\..\xbmc\music\dialogs\GUIDialogMusicInfo.h">
       <Filter>music\dialogs</Filter>
     </ClInclude>
index 7a0e469..b47dc31 100644 (file)
@@ -52,7 +52,7 @@ typedef struct
 
 static const translateField fields[] = {
   { "none",          TF_None,          CDatabaseQueryRule::TEXT_FIELD    },
-  { "id",            TF_Id,            CDatabaseQueryRule::NUMERIC_FIELD },
+  { "textureid",     TF_Id,            CDatabaseQueryRule::NUMERIC_FIELD },
   { "url",           TF_Url,           CDatabaseQueryRule::TEXT_FIELD    },
   { "cachedurl",     TF_CachedUrl,     CDatabaseQueryRule::TEXT_FIELD    },
   { "lasthashcheck", TF_LastHashCheck, CDatabaseQueryRule::TEXT_FIELD    },
@@ -100,6 +100,14 @@ CDatabaseQueryRule::FIELD_TYPE CTextureRule::GetFieldType(int field) const
   return TEXT_FIELD;
 }
 
+CStdString CTextureRule::FormatParameter(const CStdString &operatorString, const CStdString &param, const CDatabase &db, const CStdString &strType) const
+{
+  CStdString parameter(param);
+  if (m_field == TF_Url)
+    parameter = CTextureUtils::UnwrapImageURL(param);
+  return CDatabaseQueryRule::FormatParameter(operatorString, parameter, db, strType);
+}
+
 void CTextureRule::GetAvailableFields(std::vector<std::string> &fieldList)
 {
   // start at 1 to skip TF_None
@@ -312,7 +320,7 @@ bool CTextureDatabase::GetTextures(CVariant &items, const Filter &filter)
     while (!m_pDS->eof())
     {
       CVariant texture;
-      texture["id"] = m_pDS->fv(0).get_asInt();
+      texture["textureid"] = m_pDS->fv(0).get_asInt();
       texture["url"] = m_pDS->fv(1).get_asString();
       texture["cachedurl"] = m_pDS->fv(2).get_asString();
       texture["imagehash"] = m_pDS->fv(3).get_asString();
index 93317d5..75aa45c 100644 (file)
@@ -38,6 +38,7 @@ protected:
   virtual CStdString          TranslateField(int field) const;
   virtual CStdString          GetField(int field, const CStdString& type) const;
   virtual FIELD_TYPE          GetFieldType(int field) const;
+  virtual CStdString          FormatParameter(const CStdString &negate, const CStdString &oper, const CDatabase &db, const CStdString &type) const;
 };
 
 class CTextureUtils
index 6462130..6ac62b3 100644 (file)
@@ -30,6 +30,7 @@
 #include "utils/log.h"
 #include "utils/StringUtils.h"
 #include "utils/Variant.h"
+#include "TextureDatabase.h"
 
 using namespace ANNOUNCEMENT;
 using namespace JSONRPC;
@@ -84,6 +85,10 @@ void CJSONRPC::Initialize()
   CSmartPlaylist::GetAvailableFields("songs", smartplaylistList);
   CJSONServiceDescription::AddEnum("List.Filter.Fields.Songs", smartplaylistList);
 
+  smartplaylistList.clear();
+  CTextureRule::GetAvailableFields(smartplaylistList);
+  CJSONServiceDescription::AddEnum("List.Filter.Fields.Textures", smartplaylistList);
+
   unsigned int size = sizeof(JSONRPC_SERVICE_TYPES) / sizeof(char*);
 
   for (unsigned int index = 0; index < size; index++)
index da995ae..2bdc02c 100644 (file)
@@ -38,6 +38,7 @@
 #include "PVROperations.h"
 #include "ProfilesOperations.h"
 #include "FavouritesOperations.h"
+#include "TextureOperations.h"
 
 using namespace std;
 using namespace JSONRPC;
@@ -206,6 +207,10 @@ JsonRpcMethodMap CJSONServiceDescription::m_methodMaps[] = {
   { "Favourites.GetFavourites",                     CFavouritesOperations::GetFavourites },
   { "Favourites.AddFavourite",                      CFavouritesOperations::AddFavourite },
 
+// Textures operations
+  { "Textures.GetTextures",                         CTextureOperations::GetTextures },
+  { "Textures.RemoveTexture",                       CTextureOperations::RemoveTexture },
+
 // XBMC operations
   { "XBMC.GetInfoLabels",                           CXBMCOperations::GetInfoLabels },
   { "XBMC.GetInfoBooleans",                         CXBMCOperations::GetInfoBooleans }
index 398effb..a44307a 100644 (file)
@@ -13,6 +13,7 @@ SRCS=AddonsOperations.cpp \
      ProfilesOperations.cpp \
      PVROperations.cpp \
      SystemOperations.cpp \
+     TextureOperations.cpp \
      VideoLibrary.cpp \
      XBMCOperations.cpp \
 
index d373d2a..be0cd24 100644 (file)
@@ -22,7 +22,7 @@
 namespace JSONRPC
 {
   const char* const JSONRPC_SERVICE_ID          = "http://xbmc.org/jsonrpc/ServiceDescription.json";
-  const char* const JSONRPC_SERVICE_VERSION     = "6.8.0";
+  const char* const JSONRPC_SERVICE_VERSION     = "6.9.0";
   const char* const JSONRPC_SERVICE_DESCRIPTION = "JSON-RPC API of XBMC";
 
   const char* const JSONRPC_SERVICE_TYPES[] = {  
@@ -842,6 +842,33 @@ namespace JSONRPC
         "\"thumbnail\": { \"type\": \"string\" }"
       "}"
     "}",
+    "\"Textures.Details.Size\": {"
+      "\"type\": \"object\","
+      "\"properties\": {"
+        "\"size\": { \"type\": \"integer\", \"description\": \"Size of texture (1 == largest)\" },"
+        "\"width\": { \"type\": \"integer\", \"description\": \"Width of texture\" },"
+        "\"height\": { \"type\": \"integer\", \"description\": \"Height of texture\" },"
+        "\"usecount\": { \"type\": \"integer\", \"description\": \"Number of uses\" },"
+        "\"lastused\": { \"type\": \"string\", \"description\": \"Time of last use\" }"
+      "}"
+    "}",
+    "\"Textures.Fields.Texture\": {"
+      "\"extends\": \"Item.Fields.Base\","
+      "\"items\": { \"type\": \"string\","
+        "\"enum\": [ \"url\", \"cachedurl\", \"lasthashcheck\", \"imagehash\", \"sizes\" ]"
+      "}"
+    "}",
+    "\"Textures.Details.Texture\": {"
+      "\"type\": \"object\","
+      "\"properties\": {"
+        "\"textureid\": { \"$ref\": \"Library.Id\", \"required\": true },"
+        "\"url\": { \"type\": \"string\", \"description\": \"Original source URL\" },"
+        "\"cachedurl\": { \"type\": \"string\", \"description\": \"Cached URL on disk\" },"
+        "\"lasthashcheck\": { \"type\": \"string\", \"description\": \"Last time source was checked for changes\" },"
+        "\"imagehash\": { \"type\": \"string\", \"description\": \"Hash of image\" },"
+        "\"sizes\": { \"type\": \"array\", \"items\": { \"$ref\": \"Textures.Details.Size\" } }"
+      "}"
+    "}",
     "\"Profiles.Password\": {"
       "\"type\": \"object\","
       "\"properties\": {"
@@ -914,6 +941,12 @@ namespace JSONRPC
         "\"field\": { \"$ref\": \"List.Filter.Fields.Songs\", \"required\": true }"
       "}"
     "}",
+    "\"List.Filter.Rule.Textures\": {"
+      "\"extends\": \"List.Filter.Rule\","
+      "\"properties\": {"
+        "\"field\": { \"$ref\": \"List.Filter.Fields.Textures\", \"required\": true }"
+      "}"
+    "}",
     "\"List.Filter.Movies\": {"
       "\"type\": ["
         "{ \"type\": \"object\","
@@ -1061,6 +1094,27 @@ namespace JSONRPC
         "{ \"$ref\": \"List.Filter.Rule.Songs\" }"
       "]"
     "}",
+    "\"List.Filter.Textures\": {"
+      "\"type\": ["
+        "{ \"type\": \"object\","
+          "\"properties\": {"
+            "\"and\": { \"type\": \"array\","
+              "\"items\": { \"$ref\": \"List.Filter.Textures\" },"
+              "\"minItems\": 1, \"required\": true"
+            "}"
+          "}"
+        "},"
+        "{ \"type\": \"object\","
+          "\"properties\": {"
+            "\"or\": { \"type\": \"array\","
+              "\"items\": { \"$ref\": \"List.Filter.Textures\" },"
+              "\"minItems\": 1, \"required\": true"
+            "}"
+          "}"
+        "},"
+        "{ \"$ref\": \"List.Filter.Rule.Textures\" }"
+      "]"
+    "}",
     "\"List.Item.Base\": {"
       "\"extends\": [ \"Video.Details.File\", \"Audio.Details.Media\" ],"
       "\"properties\": {"
@@ -3054,6 +3108,34 @@ namespace JSONRPC
       "\"params\": [ ],"
       "\"returns\":  \"string\""
     "}",
+    "\"Textures.GetTextures\": {"
+      "\"type\": \"method\","
+      "\"description\": \"Retrieve all textures\","
+      "\"transport\": \"Response\","
+      "\"permission\": \"ReadData\","
+      "\"params\": ["
+        "{ \"name\": \"properties\", \"$ref\": \"Textures.Fields.Texture\" },"
+        "{ \"name\": \"filter\", \"$ref\": \"List.Filter.Textures\" }"
+      "],"
+      "\"returns\": {"
+        "\"type\": \"object\","
+        "\"properties\": {"
+          "\"textures\": { \"type\": \"array\", \"required\": true,"
+            "\"items\": { \"$ref\": \"Textures.Details.Texture\" }"
+          "}"
+        "}"
+      "}"
+    "}",
+    "\"Textures.RemoveTexture\": {"
+      "\"type\": \"method\","
+      "\"description\": \"Remove the specified texture\","
+      "\"transport\": \"Response\","
+      "\"permission\": \"RemoveData\","
+      "\"params\": ["
+        "{ \"name\": \"textureid\", \"$ref\": \"Library.Id\", \"required\": true, \"description\": \"Texture database identifier\" }"
+      "],"
+      "\"returns\": \"string\""
+    "}",
     "\"Profiles.GetProfiles\": {"
       "\"type\": \"method\","
       "\"description\": \"Retrieve all profiles\","
diff --git a/xbmc/interfaces/json-rpc/TextureOperations.cpp b/xbmc/interfaces/json-rpc/TextureOperations.cpp
new file mode 100644 (file)
index 0000000..ca96272
--- /dev/null
@@ -0,0 +1,103 @@
+/*
+ *      Copyright (C) 2013 Team XBMC
+ *      http://xbmc.org
+ *
+ *  This Program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2, or (at your option)
+ *  any later version.
+ *
+ *  This Program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with XBMC; see the file COPYING.  If not, see
+ *  <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#include "TextureOperations.h"
+#include "TextureDatabase.h"
+#include "TextureCache.h"
+
+using namespace JSONRPC;
+
+JSONRPC_STATUS CTextureOperations::GetTextures(const CStdString &method, ITransportLayer *transport, IClient *client, const CVariant &parameterObject, CVariant &result)
+{
+  CFileItemList listItems;
+
+  CTextureDatabase db;
+  if (!db.Open())
+    return InternalError;
+
+  CDatabase::Filter dbFilter;
+  const CVariant &filter = parameterObject["filter"];
+  if (filter.isObject())
+  {
+    CVariant xspObj(CVariant::VariantTypeObject);
+
+    if (filter.isMember("field"))
+    {
+      xspObj["and"] = CVariant(CVariant::VariantTypeArray);
+      xspObj["and"].push_back(filter);
+    }
+    else
+      xspObj = filter;
+
+    // decipher the rules
+    CDatabaseQueryRuleCombination rule;
+    if (!rule.Load(xspObj, &db))
+      return InvalidParams;
+
+    dbFilter.AppendWhere(rule.GetWhereClause(db, ""));
+  }
+
+  // fetch textures from the database
+  CVariant items = CVariant(CVariant::VariantTypeArray);
+  if (!db.GetTextures(items, dbFilter))
+    return InternalError;
+
+  // return only what was asked for, plus textureid
+  CVariant prop = parameterObject["properties"];
+  prop.push_back("textureid");
+  if (!items.empty() && prop.isArray())
+  {
+    std::set<std::string> fields;
+    CVariant &item = items[0];
+    for (CVariant::const_iterator_map field = item.begin_map(); field != item.end_map(); ++field)
+    {
+      if (std::find(prop.begin_array(), prop.end_array(), field->first) == prop.end_array())
+        fields.insert(field->first);
+    }
+    // erase these fields
+    for (CVariant::iterator_array item = items.begin_array(); item != items.end_array(); ++item)
+    {
+      for (std::set<std::string>::const_iterator i = fields.begin(); i != fields.end(); ++i)
+        item->erase(*i);
+    }
+    if (fields.find("url") == fields.end())
+    {
+      // wrap cached url to something retrieval from Files.GetFiles()
+      for (CVariant::iterator_array item = items.begin_array(); item != items.end_array(); ++item)
+      {
+        CVariant &cachedUrl = (*item)["url"];
+        cachedUrl = CTextureUtils::GetWrappedImageURL(cachedUrl.asString());
+      }
+    }
+  }
+
+  result["textures"] = items;
+  return OK;
+}
+
+JSONRPC_STATUS CTextureOperations::RemoveTexture(const CStdString &method, ITransportLayer *transport, IClient *client, const CVariant &parameterObject, CVariant &result)
+{
+  int id = (int)parameterObject["textureid"].asInteger();
+
+  if (!CTextureCache::Get().ClearCachedImage(id))
+    return InvalidParams;
+
+  return ACK;
+}
diff --git a/xbmc/interfaces/json-rpc/TextureOperations.h b/xbmc/interfaces/json-rpc/TextureOperations.h
new file mode 100644 (file)
index 0000000..4e84929
--- /dev/null
@@ -0,0 +1,33 @@
+#pragma once
+/*
+ *      Copyright (C) 2013 Team XBMC
+ *      http://xbmc.org
+ *
+ *  This Program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2, or (at your option)
+ *  any later version.
+ *
+ *  This Program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with XBMC; see the file COPYING.  If not, see
+ *  <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#include "utils/StdString.h"
+#include "JSONRPC.h"
+
+namespace JSONRPC
+{
+  class CTextureOperations
+  {
+  public:
+    static JSONRPC_STATUS GetTextures(const CStdString &method, ITransportLayer *transport, IClient *client, const CVariant &parameterObject, CVariant &result);
+    static JSONRPC_STATUS RemoveTexture(const CStdString &method, ITransportLayer *transport, IClient *client, const CVariant &parameterObject, CVariant &result);
+  };
+}
index edacf5e..d7f0e93 100644 (file)
     "params": [ ],
     "returns":  "string"
   },
+  "Textures.GetTextures": {
+    "type": "method",
+    "description": "Retrieve all textures",
+    "transport": "Response",
+    "permission": "ReadData",
+    "params": [
+      { "name": "properties", "$ref": "Textures.Fields.Texture" },
+      { "name": "filter", "$ref": "List.Filter.Textures" }
+    ],
+    "returns": {
+      "type": "object",
+      "properties": {
+        "textures": { "type": "array", "required": true,
+          "items": { "$ref": "Textures.Details.Texture" }
+        }
+      }
+    }
+  },
+  "Textures.RemoveTexture": {
+    "type": "method",
+    "description": "Remove the specified texture",
+    "transport": "Response",
+    "permission": "RemoveData",
+    "params": [
+      { "name": "textureid", "$ref": "Library.Id", "required": true, "description": "Texture database identifier" }
+    ],
+    "returns": "string"
+  },
   "Profiles.GetProfiles": {
     "type": "method",
     "description": "Retrieve all profiles",
index 72134a6..e7bf533 100644 (file)
       "thumbnail": { "type": "string" }
     }
   },
+  "Textures.Details.Size": {
+    "type": "object",
+    "properties": {
+      "size": { "type": "integer", "description": "Size of the texture (1 == largest)" },
+      "width": { "type": "integer", "description": "Width of texture" },
+      "height": { "type": "integer", "description": "Height of texture" },
+      "usecount": { "type": "integer", "description": "Number of uses" },
+      "lastused": { "type": "string", "description": "Date of last use" }
+    }
+  },
+  "Textures.Fields.Texture": {
+    "extends": "Item.Fields.Base",
+    "items": { "type": "string",
+      "enum": [ "url", "cachedurl", "lasthashcheck", "imagehash", "sizes" ]
+    }
+  },
+  "Textures.Details.Texture": {
+    "type": "object",
+    "properties": {
+      "textureid": { "$ref": "Library.Id", "required": "true" },
+      "url": { "type": "string", "description": "Original source URL" },
+      "cachedurl": { "type": "string", "description": "Cached URL on disk" },
+      "lasthashcheck": { "type": "string", "description": "Last time source was checked for changes" },
+      "imagehash": { "type": "string", "description": "Hash of image" },
+      "sizes": { "type": "array", "items": { "$ref": "Textures.Details.Size" } }
+    }
+  },
   "Profiles.Password": {
     "type": "object",
     "properties": {
       "field": { "$ref": "List.Filter.Fields.Songs", "required": true }
     }
   },
+  "List.Filter.Rule.Textures": {
+    "extends": "List.Filter.Rule",
+    "properties": {
+      "field": { "$ref": "List.Filter.Fields.Textures", "required": true }
+    }
+  },
   "List.Filter.Movies": {
     "type": [
       { "type": "object",
       { "$ref": "List.Filter.Rule.Songs" }
     ]
   },
+  "List.Filter.Textures": {
+    "type": [
+      { "type": "object",
+        "properties": {
+          "and": { "type": "array",
+            "items": { "$ref": "List.Filter.Textures" },
+            "minItems": 1, "required": true
+          }
+        }
+      },
+      { "type": "object",
+        "properties": {
+          "or": { "type": "array",
+            "items": { "$ref": "List.Filter.Textures" },
+            "minItems": 1, "required": true
+          }
+        }
+      },
+      { "$ref": "List.Filter.Rule.Textures" }
+    ]
+  },
   "List.Item.Base": {
     "extends": [ "Video.Details.File", "Audio.Details.Media" ],
     "properties": {