Skip to content
This repository
Browse code

Merge pull request #2366 from Tolriq/AddLimitsToFilesGetDirectory

jsonrpc: add support for limits to Files.GetDirectory
  • Loading branch information...
commit fb7811dc1e0dbb6b0ba2f3a7abd8a6d2c5cc9c8a 2 parents 9c1e763 + ff3611c
Sascha Montellese authored March 07, 2013
5  xbmc/interfaces/json-rpc/FileItemHandler.cpp
@@ -306,6 +306,11 @@ void CFileItemHandler::HandleFileItem(const char *ID, bool allowFile, const char
306 306
 
307 307
         if (!object.isMember("type"))
308 308
           object["type"] = "unknown";
  309
+
  310
+        if (item->m_bIsFolder)
  311
+          object["filetype"] = "directory";
  312
+        else 
  313
+          object["filetype"] = "file";
309 314
       }
310 315
     }
311 316
 
26  xbmc/interfaces/json-rpc/FileOperations.cpp
@@ -113,7 +113,7 @@ JSONRPC_STATUS CFileOperations::GetDirectory(const CStdString &method, ITranspor
113 113
 
114 114
   if (CDirectory::GetDirectory(strPath, items, extensions))
115 115
   {
116  
-    CFileItemList filteredDirectories, filteredFiles;
  116
+    CFileItemList filteredFiles;
117 117
     for (unsigned int i = 0; i < (unsigned int)items.Size(); i++)
118 118
     {
119 119
       if (CUtil::ExcludeFileOrFolder(items[i]->GetPath(), regexps))
@@ -131,9 +131,6 @@ JSONRPC_STATUS CFileOperations::GetDirectory(const CStdString &method, ITranspor
131 131
            media == "files" ||
132 132
            URIUtils::IsUPnP(items.GetPath()))
133 133
       {
134  
-        if (items[i]->m_bIsFolder)
135  
-          filteredDirectories.Add(items[i]);
136  
-        else 
137 134
           filteredFiles.Add(items[i]);
138 135
       }
139 136
       else
@@ -141,16 +138,10 @@ JSONRPC_STATUS CFileOperations::GetDirectory(const CStdString &method, ITranspor
141 138
         CFileItemPtr fileItem(new CFileItem());
142 139
         if (FillFileItem(items[i], fileItem, media, parameterObject))
143 140
         {
144  
-          if (items[i]->m_bIsFolder)
145  
-            filteredDirectories.Add(fileItem);
146  
-          else
147 141
             filteredFiles.Add(fileItem);
148 142
         }
149 143
         else
150 144
         {
151  
-          if (items[i]->m_bIsFolder)
152  
-            filteredDirectories.Add(items[i]);
153  
-          else
154 145
             filteredFiles.Add(items[i]);
155 146
         }
156 147
       }
@@ -176,22 +167,7 @@ JSONRPC_STATUS CFileOperations::GetDirectory(const CStdString &method, ITranspor
176 167
     if (!hasFileField)
177 168
       param["properties"].append("file");
178 169
 
179  
-    HandleFileItemList("id", true, "files", filteredDirectories, param, result);
180  
-    for (unsigned int index = 0; index < result["files"].size(); index++)
181  
-    {
182  
-      result["files"][index]["filetype"] = "directory";
183  
-    }
184  
-    int count = (int)result["limits"]["total"].asInteger();
185  
-
186 170
     HandleFileItemList("id", true, "files", filteredFiles, param, result);
187  
-    for (unsigned int index = count; index < result["files"].size(); index++)
188  
-    {
189  
-      result["files"][index]["filetype"] = "file";
190  
-    }
191  
-    count += (int)result["limits"]["total"].asInteger();
192  
-
193  
-    result["limits"]["end"] = count;
194  
-    result["limits"]["total"] = count;
195 171
 
196 172
     return OK;
197 173
   }
5  xbmc/interfaces/json-rpc/ServiceDescription.h
@@ -22,7 +22,7 @@
22 22
 namespace JSONRPC
23 23
 {
24 24
   const char* const JSONRPC_SERVICE_ID          = "http://www.xbmc.org/jsonrpc/ServiceDescription.json";
25  
-  const char* const JSONRPC_SERVICE_VERSION     = "6.0.3";
  25
+  const char* const JSONRPC_SERVICE_VERSION     = "6.1.0";
26 26
   const char* const JSONRPC_SERVICE_DESCRIPTION = "JSON-RPC API of XBMC";
27 27
 
28 28
   const char* const JSONRPC_SERVICE_TYPES[] = {  
@@ -1794,7 +1794,8 @@ namespace JSONRPC
1794 1794
         "{ \"name\": \"directory\", \"type\": \"string\", \"required\": true },"
1795 1795
         "{ \"name\": \"media\", \"$ref\": \"Files.Media\", \"default\": \"files\" },"
1796 1796
         "{ \"name\": \"properties\", \"$ref\": \"List.Fields.Files\" },"
1797  
-        "{ \"name\": \"sort\", \"$ref\": \"List.Sort\" }"
  1797
+        "{ \"name\": \"sort\", \"$ref\": \"List.Sort\" },"
  1798
+        "{ \"name\": \"limits\", \"$ref\": \"List.Limits\", \"description\": \"Limits are applied after getting the directory content thus retrieval is not faster when they are applied.\" }"
1798 1799
       "],"
1799 1800
       "\"returns\": {"
1800 1801
         "\"type\": \"object\","
3  xbmc/interfaces/json-rpc/methods.json
@@ -544,7 +544,8 @@
544 544
       { "name": "directory", "type": "string", "required": true },
545 545
       { "name": "media", "$ref": "Files.Media", "default": "files" },
546 546
       { "name": "properties", "$ref": "List.Fields.Files" },
547  
-      { "name": "sort", "$ref": "List.Sort" }
  547
+      { "name": "sort", "$ref": "List.Sort" },
  548
+      { "name": "limits", "$ref": "List.Limits", "description": "Limits are applied after getting the directory content thus retrieval is not faster when they are applied." }
548 549
     ],
549 550
     "returns": {
550 551
       "type": "object",

0 notes on commit fb7811d

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