From 987b236563ca2b3eb0f5a069d4a33b51e1f916cd Mon Sep 17 00:00:00 2001 From: Ming Ming Date: Mon, 4 Nov 2024 00:42:47 +0800 Subject: [PATCH] Add nc:metadata-photos-size to files api --- np_api/lib/src/entity/entity.dart | 3 +++ np_api/lib/src/entity/entity.g.dart | 2 +- np_api/lib/src/entity/file_parser.dart | 10 ++++++++++ np_api/lib/src/files_api.dart | 7 ++++++- 4 files changed, 20 insertions(+), 2 deletions(-) diff --git a/np_api/lib/src/entity/entity.dart b/np_api/lib/src/entity/entity.dart index e5a18195..6682ed37 100644 --- a/np_api/lib/src/entity/entity.dart +++ b/np_api/lib/src/entity/entity.dart @@ -87,6 +87,7 @@ class File with EquatableMixin { this.metadataPhotosIfd0, this.metadataPhotosExif, this.metadataPhotosGps, + this.metadataPhotosSize, this.customProperties, }); @@ -112,6 +113,7 @@ class File with EquatableMixin { metadataPhotosIfd0, metadataPhotosExif, metadataPhotosGps, + metadataPhotosSize, customProperties, ]; @@ -132,6 +134,7 @@ class File with EquatableMixin { final Map? metadataPhotosIfd0; final Map? metadataPhotosExif; final Map? metadataPhotosGps; + final Map? metadataPhotosSize; final Map? customProperties; } diff --git a/np_api/lib/src/entity/entity.g.dart b/np_api/lib/src/entity/entity.g.dart index da142482..b7793d7a 100644 --- a/np_api/lib/src/entity/entity.g.dart +++ b/np_api/lib/src/entity/entity.g.dart @@ -30,7 +30,7 @@ extension _$FavoriteToString on Favorite { extension _$FileToString on File { String _$toString() { // 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"}}"; } } diff --git a/np_api/lib/src/entity/file_parser.dart b/np_api/lib/src/entity/file_parser.dart index 13c902dc..4bb30c2a 100644 --- a/np_api/lib/src/entity/file_parser.dart +++ b/np_api/lib/src/entity/file_parser.dart @@ -36,6 +36,7 @@ class FileParser extends XmlResponseParser { Map? metadataPhotosIfd0; Map? metadataPhotosExif; Map? metadataPhotosGps; + Map? metadataPhotosSize; Map? customProperties; for (final child in element.children.whereType()) { @@ -72,6 +73,7 @@ class FileParser extends XmlResponseParser { metadataPhotosIfd0 = propParser.metadataPhotosIfd0; metadataPhotosExif = propParser.metadataPhotosExif; metadataPhotosGps = propParser.metadataPhotosGps; + metadataPhotosSize = propParser.metadataPhotosSize; customProperties = propParser.customProperties; } } @@ -94,6 +96,7 @@ class FileParser extends XmlResponseParser { metadataPhotosIfd0: metadataPhotosIfd0, metadataPhotosExif: metadataPhotosExif, metadataPhotosGps: metadataPhotosGps, + metadataPhotosSize: metadataPhotosSize, customProperties: customProperties, ); } @@ -165,6 +168,11 @@ class _PropParser { for (final c in child.children.whereType()) { (_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()) { + (_metadataPhotosSize ??= {})[c.localName] = c.innerText; + } } else { final key = child.name.prefix == null ? child.localName @@ -190,6 +198,7 @@ class _PropParser { Map? get metadataPhotosIfd0 => _metadataPhotosIfd0; Map? get metadataPhotosExif => _metadataPhotosExif; Map? get metadataPhotosGps => _metadataPhotosGps; + Map? get metadataPhotosSize => _metadataPhotosSize; Map? get customProperties => _customProperties; final Map namespaces; @@ -210,6 +219,7 @@ class _PropParser { Map? _metadataPhotosIfd0; Map? _metadataPhotosExif; Map? _metadataPhotosGps; + Map? _metadataPhotosSize; Map? _customProperties; } diff --git a/np_api/lib/src/files_api.dart b/np_api/lib/src/files_api.dart index 1eb632ba..a647472f 100644 --- a/np_api/lib/src/files_api.dart +++ b/np_api/lib/src/files_api.dart @@ -75,6 +75,7 @@ class ApiFiles { metadataPhotosIfd0, metadataPhotosExif, metadataPhotosGps, + metadataPhotosSize, Map? customNamespaces, List? customProperties, }) async { @@ -102,7 +103,8 @@ class ApiFiles { trashbinDeletionTime != null || metadataPhotosIfd0 != null || metadataPhotosExif != null || - metadataPhotosGps != null); + metadataPhotosGps != null || + metadataPhotosSize != null); if (!hasDavNs && !hasOcNs && !hasNcNs) { // no body return await _api.request("PROPFIND", path); @@ -190,6 +192,9 @@ class ApiFiles { if (metadataPhotosGps != null) { builder.element("nc:metadata-photos-gps"); } + if (metadataPhotosSize != null) { + builder.element("nc:metadata-photos-size"); + } for (final p in customProperties ?? []) { builder.element(p); }