Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge pull request #2871 from Tolriq/faster_fix_filetype

jsonrpc: faster and better way to fix "filetype" property than e0ec520
  • Loading branch information...
commit 0d317329ba1898ed6a7d2cea5343632e621e0b2c 2 parents 6763ab9 + cf8a71b
Sascha Montellese Montellese authored
8 xbmc/interfaces/json-rpc/FileItemHandler.cpp
View
@@ -307,6 +307,14 @@ void CFileItemHandler::HandleFileItem(const char *ID, bool allowFile, const char
if (!object.isMember("type"))
object["type"] = "unknown";
+
+ if (fields.find("filetype") != fields.end())
+ {
+ if (item->m_bIsFolder)
+ object["filetype"] = "directory";
+ else
+ object["filetype"] = "file";
+ }
}
}
20 xbmc/interfaces/json-rpc/FileOperations.cpp
View
@@ -132,8 +132,8 @@ JSONRPC_STATUS CFileOperations::GetDirectory(const CStdString &method, ITranspor
}
// Check if the "properties" list exists
- // and make sure it contains the "file"
- // field
+ // and make sure it contains the "file" and "filetype"
+ // fields
CVariant param = parameterObject;
if (!param.isMember("properties"))
param["properties"] = CVariant(CVariant::VariantTypeArray);
@@ -150,22 +150,9 @@ JSONRPC_STATUS CFileOperations::GetDirectory(const CStdString &method, ITranspor
if (!hasFileField)
param["properties"].append("file");
+ param["properties"].append("filetype");
HandleFileItemList("id", true, "files", filteredFiles, param, result);
- for (CVariant::iterator_array item = result["files"].begin_array(); item != result["files"].end_array(); ++item)
- {
- if (!item->isMember("file"))
- continue;
-
- CFileItemPtr pItem = filteredFiles.Get((*item)["file"].asString());
- if (pItem == NULL)
- continue;
-
- if (pItem->m_bIsFolder)
- (*item)["filetype"] = "directory";
- else
- (*item)["filetype"] = "file";
- }
return OK;
}
@@ -212,6 +199,7 @@ JSONRPC_STATUS CFileOperations::GetFileDetails(const CStdString &method, ITransp
if (!hasFileField)
param["properties"].append("file");
+ param["properties"].append("filetype");
HandleFileItem("id", true, "filedetails", item, parameterObject, param["properties"], result, false);
return OK;
Please sign in to comment.
Something went wrong with that request. Please try again.