Add nc:metadata-photos-size to files api

This commit is contained in:
Ming Ming 2024-11-04 00:42:47 +08:00
parent b86e2ef33b
commit 987b236563
4 changed files with 20 additions and 2 deletions

View file

@ -87,6 +87,7 @@ class File with EquatableMixin {
this.metadataPhotosIfd0, this.metadataPhotosIfd0,
this.metadataPhotosExif, this.metadataPhotosExif,
this.metadataPhotosGps, this.metadataPhotosGps,
this.metadataPhotosSize,
this.customProperties, this.customProperties,
}); });
@ -112,6 +113,7 @@ class File with EquatableMixin {
metadataPhotosIfd0, metadataPhotosIfd0,
metadataPhotosExif, metadataPhotosExif,
metadataPhotosGps, metadataPhotosGps,
metadataPhotosSize,
customProperties, customProperties,
]; ];
@ -132,6 +134,7 @@ class File with EquatableMixin {
final Map<String, String>? metadataPhotosIfd0; final Map<String, String>? metadataPhotosIfd0;
final Map<String, String>? metadataPhotosExif; final Map<String, String>? metadataPhotosExif;
final Map<String, String>? metadataPhotosGps; final Map<String, String>? metadataPhotosGps;
final Map<String, String>? metadataPhotosSize;
final Map<String, String>? customProperties; final Map<String, String>? customProperties;
} }

View file

@ -30,7 +30,7 @@ extension _$FavoriteToString on Favorite {
extension _$FileToString on File { extension _$FileToString on File {
String _$toString() { String _$toString() {
// ignore: unnecessary_string_interpolations // ignore: unnecessary_string_interpolations
return "File {href: $href, ${lastModified == null ? "" : "lastModified: $lastModified, "}${etag == null ? "" : "etag: $etag, "}${contentType == null ? "" : "contentType: $contentType, "}${isCollection == null ? "" : "isCollection: $isCollection, "}${contentLength == null ? "" : "contentLength: $contentLength, "}${fileId == null ? "" : "fileId: $fileId, "}${favorite == null ? "" : "favorite: $favorite, "}${ownerId == null ? "" : "ownerId: $ownerId, "}${ownerDisplayName == null ? "" : "ownerDisplayName: $ownerDisplayName, "}${hasPreview == null ? "" : "hasPreview: $hasPreview, "}${trashbinFilename == null ? "" : "trashbinFilename: $trashbinFilename, "}${trashbinOriginalLocation == null ? "" : "trashbinOriginalLocation: $trashbinOriginalLocation, "}${trashbinDeletionTime == null ? "" : "trashbinDeletionTime: $trashbinDeletionTime, "}${metadataPhotosIfd0 == null ? "" : "metadataPhotosIfd0: $metadataPhotosIfd0, "}${metadataPhotosExif == null ? "" : "metadataPhotosExif: $metadataPhotosExif, "}${metadataPhotosGps == null ? "" : "metadataPhotosGps: $metadataPhotosGps, "}${customProperties == null ? "" : "customProperties: $customProperties"}}"; return "File {href: $href, ${lastModified == null ? "" : "lastModified: $lastModified, "}${etag == null ? "" : "etag: $etag, "}${contentType == null ? "" : "contentType: $contentType, "}${isCollection == null ? "" : "isCollection: $isCollection, "}${contentLength == null ? "" : "contentLength: $contentLength, "}${fileId == null ? "" : "fileId: $fileId, "}${favorite == null ? "" : "favorite: $favorite, "}${ownerId == null ? "" : "ownerId: $ownerId, "}${ownerDisplayName == null ? "" : "ownerDisplayName: $ownerDisplayName, "}${hasPreview == null ? "" : "hasPreview: $hasPreview, "}${trashbinFilename == null ? "" : "trashbinFilename: $trashbinFilename, "}${trashbinOriginalLocation == null ? "" : "trashbinOriginalLocation: $trashbinOriginalLocation, "}${trashbinDeletionTime == null ? "" : "trashbinDeletionTime: $trashbinDeletionTime, "}${metadataPhotosIfd0 == null ? "" : "metadataPhotosIfd0: $metadataPhotosIfd0, "}${metadataPhotosExif == null ? "" : "metadataPhotosExif: $metadataPhotosExif, "}${metadataPhotosGps == null ? "" : "metadataPhotosGps: $metadataPhotosGps, "}${metadataPhotosSize == null ? "" : "metadataPhotosSize: $metadataPhotosSize, "}${customProperties == null ? "" : "customProperties: $customProperties"}}";
} }
} }

View file

@ -36,6 +36,7 @@ class FileParser extends XmlResponseParser {
Map<String, String>? metadataPhotosIfd0; Map<String, String>? metadataPhotosIfd0;
Map<String, String>? metadataPhotosExif; Map<String, String>? metadataPhotosExif;
Map<String, String>? metadataPhotosGps; Map<String, String>? metadataPhotosGps;
Map<String, String>? metadataPhotosSize;
Map<String, String>? customProperties; Map<String, String>? customProperties;
for (final child in element.children.whereType<XmlElement>()) { for (final child in element.children.whereType<XmlElement>()) {
@ -72,6 +73,7 @@ class FileParser extends XmlResponseParser {
metadataPhotosIfd0 = propParser.metadataPhotosIfd0; metadataPhotosIfd0 = propParser.metadataPhotosIfd0;
metadataPhotosExif = propParser.metadataPhotosExif; metadataPhotosExif = propParser.metadataPhotosExif;
metadataPhotosGps = propParser.metadataPhotosGps; metadataPhotosGps = propParser.metadataPhotosGps;
metadataPhotosSize = propParser.metadataPhotosSize;
customProperties = propParser.customProperties; customProperties = propParser.customProperties;
} }
} }
@ -94,6 +96,7 @@ class FileParser extends XmlResponseParser {
metadataPhotosIfd0: metadataPhotosIfd0, metadataPhotosIfd0: metadataPhotosIfd0,
metadataPhotosExif: metadataPhotosExif, metadataPhotosExif: metadataPhotosExif,
metadataPhotosGps: metadataPhotosGps, metadataPhotosGps: metadataPhotosGps,
metadataPhotosSize: metadataPhotosSize,
customProperties: customProperties, customProperties: customProperties,
); );
} }
@ -165,6 +168,11 @@ class _PropParser {
for (final c in child.children.whereType<XmlElement>()) { for (final c in child.children.whereType<XmlElement>()) {
(_metadataPhotosGps ??= {})[c.localName] = c.innerText; (_metadataPhotosGps ??= {})[c.localName] = c.innerText;
} }
} else if (child.matchQualifiedName("metadata-photos-size",
prefix: "http://nextcloud.org/ns", namespaces: namespaces)) {
for (final c in child.children.whereType<XmlElement>()) {
(_metadataPhotosSize ??= {})[c.localName] = c.innerText;
}
} else { } else {
final key = child.name.prefix == null final key = child.name.prefix == null
? child.localName ? child.localName
@ -190,6 +198,7 @@ class _PropParser {
Map<String, String>? get metadataPhotosIfd0 => _metadataPhotosIfd0; Map<String, String>? get metadataPhotosIfd0 => _metadataPhotosIfd0;
Map<String, String>? get metadataPhotosExif => _metadataPhotosExif; Map<String, String>? get metadataPhotosExif => _metadataPhotosExif;
Map<String, String>? get metadataPhotosGps => _metadataPhotosGps; Map<String, String>? get metadataPhotosGps => _metadataPhotosGps;
Map<String, String>? get metadataPhotosSize => _metadataPhotosSize;
Map<String, String>? get customProperties => _customProperties; Map<String, String>? get customProperties => _customProperties;
final Map<String, String> namespaces; final Map<String, String> namespaces;
@ -210,6 +219,7 @@ class _PropParser {
Map<String, String>? _metadataPhotosIfd0; Map<String, String>? _metadataPhotosIfd0;
Map<String, String>? _metadataPhotosExif; Map<String, String>? _metadataPhotosExif;
Map<String, String>? _metadataPhotosGps; Map<String, String>? _metadataPhotosGps;
Map<String, String>? _metadataPhotosSize;
Map<String, String>? _customProperties; Map<String, String>? _customProperties;
} }

View file

@ -75,6 +75,7 @@ class ApiFiles {
metadataPhotosIfd0, metadataPhotosIfd0,
metadataPhotosExif, metadataPhotosExif,
metadataPhotosGps, metadataPhotosGps,
metadataPhotosSize,
Map<String, String>? customNamespaces, Map<String, String>? customNamespaces,
List<String>? customProperties, List<String>? customProperties,
}) async { }) async {
@ -102,7 +103,8 @@ class ApiFiles {
trashbinDeletionTime != null || trashbinDeletionTime != null ||
metadataPhotosIfd0 != null || metadataPhotosIfd0 != null ||
metadataPhotosExif != null || metadataPhotosExif != null ||
metadataPhotosGps != null); metadataPhotosGps != null ||
metadataPhotosSize != null);
if (!hasDavNs && !hasOcNs && !hasNcNs) { if (!hasDavNs && !hasOcNs && !hasNcNs) {
// no body // no body
return await _api.request("PROPFIND", path); return await _api.request("PROPFIND", path);
@ -190,6 +192,9 @@ class ApiFiles {
if (metadataPhotosGps != null) { if (metadataPhotosGps != null) {
builder.element("nc:metadata-photos-gps"); builder.element("nc:metadata-photos-gps");
} }
if (metadataPhotosSize != null) {
builder.element("nc:metadata-photos-size");
}
for (final p in customProperties ?? []) { for (final p in customProperties ?? []) {
builder.element(p); builder.element(p);
} }