Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge pull request #2366 from Tolriq/AddLimitsToFilesGetDirectory

jsonrpc: add support for limits to Files.GetDirectory
  • Loading branch information...
commit fb7811dc1e0dbb6b0ba2f3a7abd8a6d2c5cc9c8a 2 parents 9c1e763 + ff3611c
@Montellese Montellese authored
View
5 xbmc/interfaces/json-rpc/FileItemHandler.cpp
@@ -306,6 +306,11 @@ void CFileItemHandler::HandleFileItem(const char *ID, bool allowFile, const char
if (!object.isMember("type"))
object["type"] = "unknown";
+
+ if (item->m_bIsFolder)
+ object["filetype"] = "directory";
+ else
+ object["filetype"] = "file";
}
}
View
26 xbmc/interfaces/json-rpc/FileOperations.cpp
@@ -113,7 +113,7 @@ JSONRPC_STATUS CFileOperations::GetDirectory(const CStdString &method, ITranspor
if (CDirectory::GetDirectory(strPath, items, extensions))
{
- CFileItemList filteredDirectories, filteredFiles;
+ CFileItemList filteredFiles;
for (unsigned int i = 0; i < (unsigned int)items.Size(); i++)
{
if (CUtil::ExcludeFileOrFolder(items[i]->GetPath(), regexps))
@@ -131,9 +131,6 @@ JSONRPC_STATUS CFileOperations::GetDirectory(const CStdString &method, ITranspor
media == "files" ||
URIUtils::IsUPnP(items.GetPath()))
{
- if (items[i]->m_bIsFolder)
- filteredDirectories.Add(items[i]);
- else
filteredFiles.Add(items[i]);
}
else
@@ -141,16 +138,10 @@ JSONRPC_STATUS CFileOperations::GetDirectory(const CStdString &method, ITranspor
CFileItemPtr fileItem(new CFileItem());
if (FillFileItem(items[i], fileItem, media, parameterObject))
{
- if (items[i]->m_bIsFolder)
- filteredDirectories.Add(fileItem);
- else
filteredFiles.Add(fileItem);
}
else
{
- if (items[i]->m_bIsFolder)
- filteredDirectories.Add(items[i]);
- else
filteredFiles.Add(items[i]);
}
}
@@ -176,22 +167,7 @@ JSONRPC_STATUS CFileOperations::GetDirectory(const CStdString &method, ITranspor
if (!hasFileField)
param["properties"].append("file");
- HandleFileItemList("id", true, "files", filteredDirectories, param, result);
- for (unsigned int index = 0; index < result["files"].size(); index++)
- {
- result["files"][index]["filetype"] = "directory";
- }
- int count = (int)result["limits"]["total"].asInteger();
-
HandleFileItemList("id", true, "files", filteredFiles, param, result);
- for (unsigned int index = count; index < result["files"].size(); index++)
- {
- result["files"][index]["filetype"] = "file";
- }
- count += (int)result["limits"]["total"].asInteger();
-
- result["limits"]["end"] = count;
- result["limits"]["total"] = count;
return OK;
}
View
5 xbmc/interfaces/json-rpc/ServiceDescription.h
@@ -22,7 +22,7 @@
namespace JSONRPC
{
const char* const JSONRPC_SERVICE_ID = "http://www.xbmc.org/jsonrpc/ServiceDescription.json";
- const char* const JSONRPC_SERVICE_VERSION = "6.0.3";
+ const char* const JSONRPC_SERVICE_VERSION = "6.1.0";
const char* const JSONRPC_SERVICE_DESCRIPTION = "JSON-RPC API of XBMC";
const char* const JSONRPC_SERVICE_TYPES[] = {
@@ -1794,7 +1794,8 @@ namespace JSONRPC
"{ \"name\": \"directory\", \"type\": \"string\", \"required\": true },"
"{ \"name\": \"media\", \"$ref\": \"Files.Media\", \"default\": \"files\" },"
"{ \"name\": \"properties\", \"$ref\": \"List.Fields.Files\" },"
- "{ \"name\": \"sort\", \"$ref\": \"List.Sort\" }"
+ "{ \"name\": \"sort\", \"$ref\": \"List.Sort\" },"
+ "{ \"name\": \"limits\", \"$ref\": \"List.Limits\", \"description\": \"Limits are applied after getting the directory content thus retrieval is not faster when they are applied.\" }"
"],"
"\"returns\": {"
"\"type\": \"object\","
View
3  xbmc/interfaces/json-rpc/methods.json
@@ -544,7 +544,8 @@
{ "name": "directory", "type": "string", "required": true },
{ "name": "media", "$ref": "Files.Media", "default": "files" },
{ "name": "properties", "$ref": "List.Fields.Files" },
- { "name": "sort", "$ref": "List.Sort" }
+ { "name": "sort", "$ref": "List.Sort" },
+ { "name": "limits", "$ref": "List.Limits", "description": "Limits are applied after getting the directory content thus retrieval is not faster when they are applied." }
],
"returns": {
"type": "object",
Please sign in to comment.
Something went wrong with that request. Please try again.