From eeaa3c65be9419ed12b6302132e9ff7337a44313 Mon Sep 17 00:00:00 2001 From: jld3103 Date: Sun, 23 Apr 2023 17:40:45 +0200 Subject: [PATCH 1/2] nextcloud: Format generated props --- packages/nextcloud/bin/generate_props.dart | 19 +- packages/nextcloud/lib/src/webdav/props.dart | 567 ++++++++++++++++--- 2 files changed, 495 insertions(+), 91 deletions(-) diff --git a/packages/nextcloud/bin/generate_props.dart b/packages/nextcloud/bin/generate_props.dart index c2ae19fc..d9b467cd 100644 --- a/packages/nextcloud/bin/generate_props.dart +++ b/packages/nextcloud/bin/generate_props.dart @@ -11,14 +11,12 @@ void main() { final type = prop[2]; final name = prop[1]; final variable = namespacePrefix + name.toLowerCase().replaceAll(RegExp('[^a-z]'), ''); - valueProps.addAll([ - "@annotation.XmlElement(name: '$name', namespace: $namespaceVariable, includeIfNull: false)", - '$type? $variable;', - ]); - findProps.addAll([ - "@annotation.XmlElement(name: '$name', namespace: $namespaceVariable, includeIfNull: false)", - 'bool? $variable;', - ]); + valueProps.add( + "@annotation.XmlElement(name: '$name', namespace: $namespaceVariable, includeIfNull: false,)\n $type? $variable;", + ); + findProps.add( + "@annotation.XmlElement(name: '$name', namespace: $namespaceVariable, includeIfNull: false,)\n bool? $variable;", + ); variables.add(variable); } File('lib/src/webdav/props.dart').writeAsStringSync( @@ -32,6 +30,7 @@ void main() { ...generateClass('WebDavPropfindProp', 'prop', 'namespaceDav', findProps, variables), ...generateClass('WebDavProp', 'prop', 'namespaceDav', valueProps, variables), ...generateClass('WebDavOcFilterRules', 'filter-rules', 'namespaceOwncloud', valueProps, variables), + '', ].join('\n'), ); } @@ -48,10 +47,10 @@ List generateClass( "@annotation.XmlRootElement(name: '$elementName', namespace: $namespace)", 'class $name with _\$${name}XmlSerializableMixin {', ' $name({', - ...variables.map((final variable) => ' this.$variable,'), + ...variables.map((final variable) => ' this.$variable,'), ' });', ' factory $name.fromXmlElement(final XmlElement element) => _\$${name}FromXmlElement(element);', - ...props.map((final prop) => ' $prop'), + ...props.map((final prop) => '\n $prop'), '}', ]; diff --git a/packages/nextcloud/lib/src/webdav/props.dart b/packages/nextcloud/lib/src/webdav/props.dart index 092f22b0..80a4f8ce 100644 --- a/packages/nextcloud/lib/src/webdav/props.dart +++ b/packages/nextcloud/lib/src/webdav/props.dart @@ -37,59 +37,194 @@ class WebDavPropfindProp with _$WebDavPropfindPropXmlSerializableMixin { this.ocmsharepermissions, }); factory WebDavPropfindProp.fromXmlElement(final XmlElement element) => _$WebDavPropfindPropFromXmlElement(element); - @annotation.XmlElement(name: 'getlastmodified', namespace: namespaceDav, includeIfNull: false) + + @annotation.XmlElement( + name: 'getlastmodified', + namespace: namespaceDav, + includeIfNull: false, + ) bool? davgetlastmodified; - @annotation.XmlElement(name: 'getetag', namespace: namespaceDav, includeIfNull: false) + + @annotation.XmlElement( + name: 'getetag', + namespace: namespaceDav, + includeIfNull: false, + ) bool? davgetetag; - @annotation.XmlElement(name: 'getcontenttype', namespace: namespaceDav, includeIfNull: false) + + @annotation.XmlElement( + name: 'getcontenttype', + namespace: namespaceDav, + includeIfNull: false, + ) bool? davgetcontenttype; - @annotation.XmlElement(name: 'getcontentlength', namespace: namespaceDav, includeIfNull: false) + + @annotation.XmlElement( + name: 'getcontentlength', + namespace: namespaceDav, + includeIfNull: false, + ) bool? davgetcontentlength; - @annotation.XmlElement(name: 'resourcetype', namespace: namespaceDav, includeIfNull: false) + + @annotation.XmlElement( + name: 'resourcetype', + namespace: namespaceDav, + includeIfNull: false, + ) bool? davresourcetype; - @annotation.XmlElement(name: 'id', namespace: namespaceOwncloud, includeIfNull: false) + + @annotation.XmlElement( + name: 'id', + namespace: namespaceOwncloud, + includeIfNull: false, + ) bool? ocid; - @annotation.XmlElement(name: 'fileid', namespace: namespaceOwncloud, includeIfNull: false) + + @annotation.XmlElement( + name: 'fileid', + namespace: namespaceOwncloud, + includeIfNull: false, + ) bool? ocfileid; - @annotation.XmlElement(name: 'favorite', namespace: namespaceOwncloud, includeIfNull: false) + + @annotation.XmlElement( + name: 'favorite', + namespace: namespaceOwncloud, + includeIfNull: false, + ) bool? ocfavorite; - @annotation.XmlElement(name: 'comments-href', namespace: namespaceOwncloud, includeIfNull: false) + + @annotation.XmlElement( + name: 'comments-href', + namespace: namespaceOwncloud, + includeIfNull: false, + ) bool? occommentshref; - @annotation.XmlElement(name: 'comments-count', namespace: namespaceOwncloud, includeIfNull: false) + + @annotation.XmlElement( + name: 'comments-count', + namespace: namespaceOwncloud, + includeIfNull: false, + ) bool? occommentscount; - @annotation.XmlElement(name: 'comments-unread', namespace: namespaceOwncloud, includeIfNull: false) + + @annotation.XmlElement( + name: 'comments-unread', + namespace: namespaceOwncloud, + includeIfNull: false, + ) bool? occommentsunread; - @annotation.XmlElement(name: 'downloadURL', namespace: namespaceOwncloud, includeIfNull: false) + + @annotation.XmlElement( + name: 'downloadURL', + namespace: namespaceOwncloud, + includeIfNull: false, + ) bool? ocdownloadurl; - @annotation.XmlElement(name: 'owner-id', namespace: namespaceOwncloud, includeIfNull: false) + + @annotation.XmlElement( + name: 'owner-id', + namespace: namespaceOwncloud, + includeIfNull: false, + ) bool? ocownerid; - @annotation.XmlElement(name: 'owner-display-name', namespace: namespaceOwncloud, includeIfNull: false) + + @annotation.XmlElement( + name: 'owner-display-name', + namespace: namespaceOwncloud, + includeIfNull: false, + ) bool? ocownerdisplayname; - @annotation.XmlElement(name: 'size', namespace: namespaceOwncloud, includeIfNull: false) + + @annotation.XmlElement( + name: 'size', + namespace: namespaceOwncloud, + includeIfNull: false, + ) bool? ocsize; - @annotation.XmlElement(name: 'permissions', namespace: namespaceOwncloud, includeIfNull: false) + + @annotation.XmlElement( + name: 'permissions', + namespace: namespaceOwncloud, + includeIfNull: false, + ) bool? ocpermissions; - @annotation.XmlElement(name: 'note', namespace: namespaceNextcloud, includeIfNull: false) + + @annotation.XmlElement( + name: 'note', + namespace: namespaceNextcloud, + includeIfNull: false, + ) bool? ncnote; - @annotation.XmlElement(name: 'data-fingerprint', namespace: namespaceNextcloud, includeIfNull: false) + + @annotation.XmlElement( + name: 'data-fingerprint', + namespace: namespaceNextcloud, + includeIfNull: false, + ) bool? ncdatafingerprint; - @annotation.XmlElement(name: 'has-preview', namespace: namespaceNextcloud, includeIfNull: false) + + @annotation.XmlElement( + name: 'has-preview', + namespace: namespaceNextcloud, + includeIfNull: false, + ) bool? nchaspreview; - @annotation.XmlElement(name: 'mount-type', namespace: namespaceNextcloud, includeIfNull: false) + + @annotation.XmlElement( + name: 'mount-type', + namespace: namespaceNextcloud, + includeIfNull: false, + ) bool? ncmounttype; - @annotation.XmlElement(name: 'is-encrypted', namespace: namespaceNextcloud, includeIfNull: false) + + @annotation.XmlElement( + name: 'is-encrypted', + namespace: namespaceNextcloud, + includeIfNull: false, + ) bool? ncisencrypted; - @annotation.XmlElement(name: 'metadata_etag', namespace: namespaceNextcloud, includeIfNull: false) + + @annotation.XmlElement( + name: 'metadata_etag', + namespace: namespaceNextcloud, + includeIfNull: false, + ) bool? ncmetadataetag; - @annotation.XmlElement(name: 'upload_time', namespace: namespaceNextcloud, includeIfNull: false) + + @annotation.XmlElement( + name: 'upload_time', + namespace: namespaceNextcloud, + includeIfNull: false, + ) bool? ncuploadtime; - @annotation.XmlElement(name: 'creation_time', namespace: namespaceNextcloud, includeIfNull: false) + + @annotation.XmlElement( + name: 'creation_time', + namespace: namespaceNextcloud, + includeIfNull: false, + ) bool? nccreationtime; - @annotation.XmlElement(name: 'rich-workspace', namespace: namespaceNextcloud, includeIfNull: false) + + @annotation.XmlElement( + name: 'rich-workspace', + namespace: namespaceNextcloud, + includeIfNull: false, + ) bool? ncrichworkspace; - @annotation.XmlElement(name: 'share-permissions', namespace: namespaceOpenCollaborationServices, includeIfNull: false) + + @annotation.XmlElement( + name: 'share-permissions', + namespace: namespaceOpenCollaborationServices, + includeIfNull: false, + ) bool? ocssharepermissions; - @annotation.XmlElement(name: 'share-permissions', namespace: namespaceOpenCloudMesh, includeIfNull: false) + + @annotation.XmlElement( + name: 'share-permissions', + namespace: namespaceOpenCloudMesh, + includeIfNull: false, + ) bool? ocmsharepermissions; } @@ -126,59 +261,194 @@ class WebDavProp with _$WebDavPropXmlSerializableMixin { this.ocmsharepermissions, }); factory WebDavProp.fromXmlElement(final XmlElement element) => _$WebDavPropFromXmlElement(element); - @annotation.XmlElement(name: 'getlastmodified', namespace: namespaceDav, includeIfNull: false) + + @annotation.XmlElement( + name: 'getlastmodified', + namespace: namespaceDav, + includeIfNull: false, + ) String? davgetlastmodified; - @annotation.XmlElement(name: 'getetag', namespace: namespaceDav, includeIfNull: false) + + @annotation.XmlElement( + name: 'getetag', + namespace: namespaceDav, + includeIfNull: false, + ) String? davgetetag; - @annotation.XmlElement(name: 'getcontenttype', namespace: namespaceDav, includeIfNull: false) + + @annotation.XmlElement( + name: 'getcontenttype', + namespace: namespaceDav, + includeIfNull: false, + ) String? davgetcontenttype; - @annotation.XmlElement(name: 'getcontentlength', namespace: namespaceDav, includeIfNull: false) + + @annotation.XmlElement( + name: 'getcontentlength', + namespace: namespaceDav, + includeIfNull: false, + ) int? davgetcontentlength; - @annotation.XmlElement(name: 'resourcetype', namespace: namespaceDav, includeIfNull: false) + + @annotation.XmlElement( + name: 'resourcetype', + namespace: namespaceDav, + includeIfNull: false, + ) WebDavResourcetype? davresourcetype; - @annotation.XmlElement(name: 'id', namespace: namespaceOwncloud, includeIfNull: false) + + @annotation.XmlElement( + name: 'id', + namespace: namespaceOwncloud, + includeIfNull: false, + ) String? ocid; - @annotation.XmlElement(name: 'fileid', namespace: namespaceOwncloud, includeIfNull: false) + + @annotation.XmlElement( + name: 'fileid', + namespace: namespaceOwncloud, + includeIfNull: false, + ) String? ocfileid; - @annotation.XmlElement(name: 'favorite', namespace: namespaceOwncloud, includeIfNull: false) + + @annotation.XmlElement( + name: 'favorite', + namespace: namespaceOwncloud, + includeIfNull: false, + ) int? ocfavorite; - @annotation.XmlElement(name: 'comments-href', namespace: namespaceOwncloud, includeIfNull: false) + + @annotation.XmlElement( + name: 'comments-href', + namespace: namespaceOwncloud, + includeIfNull: false, + ) String? occommentshref; - @annotation.XmlElement(name: 'comments-count', namespace: namespaceOwncloud, includeIfNull: false) + + @annotation.XmlElement( + name: 'comments-count', + namespace: namespaceOwncloud, + includeIfNull: false, + ) int? occommentscount; - @annotation.XmlElement(name: 'comments-unread', namespace: namespaceOwncloud, includeIfNull: false) + + @annotation.XmlElement( + name: 'comments-unread', + namespace: namespaceOwncloud, + includeIfNull: false, + ) int? occommentsunread; - @annotation.XmlElement(name: 'downloadURL', namespace: namespaceOwncloud, includeIfNull: false) + + @annotation.XmlElement( + name: 'downloadURL', + namespace: namespaceOwncloud, + includeIfNull: false, + ) String? ocdownloadurl; - @annotation.XmlElement(name: 'owner-id', namespace: namespaceOwncloud, includeIfNull: false) + + @annotation.XmlElement( + name: 'owner-id', + namespace: namespaceOwncloud, + includeIfNull: false, + ) String? ocownerid; - @annotation.XmlElement(name: 'owner-display-name', namespace: namespaceOwncloud, includeIfNull: false) + + @annotation.XmlElement( + name: 'owner-display-name', + namespace: namespaceOwncloud, + includeIfNull: false, + ) String? ocownerdisplayname; - @annotation.XmlElement(name: 'size', namespace: namespaceOwncloud, includeIfNull: false) + + @annotation.XmlElement( + name: 'size', + namespace: namespaceOwncloud, + includeIfNull: false, + ) int? ocsize; - @annotation.XmlElement(name: 'permissions', namespace: namespaceOwncloud, includeIfNull: false) + + @annotation.XmlElement( + name: 'permissions', + namespace: namespaceOwncloud, + includeIfNull: false, + ) String? ocpermissions; - @annotation.XmlElement(name: 'note', namespace: namespaceNextcloud, includeIfNull: false) + + @annotation.XmlElement( + name: 'note', + namespace: namespaceNextcloud, + includeIfNull: false, + ) String? ncnote; - @annotation.XmlElement(name: 'data-fingerprint', namespace: namespaceNextcloud, includeIfNull: false) + + @annotation.XmlElement( + name: 'data-fingerprint', + namespace: namespaceNextcloud, + includeIfNull: false, + ) String? ncdatafingerprint; - @annotation.XmlElement(name: 'has-preview', namespace: namespaceNextcloud, includeIfNull: false) + + @annotation.XmlElement( + name: 'has-preview', + namespace: namespaceNextcloud, + includeIfNull: false, + ) bool? nchaspreview; - @annotation.XmlElement(name: 'mount-type', namespace: namespaceNextcloud, includeIfNull: false) + + @annotation.XmlElement( + name: 'mount-type', + namespace: namespaceNextcloud, + includeIfNull: false, + ) String? ncmounttype; - @annotation.XmlElement(name: 'is-encrypted', namespace: namespaceNextcloud, includeIfNull: false) + + @annotation.XmlElement( + name: 'is-encrypted', + namespace: namespaceNextcloud, + includeIfNull: false, + ) int? ncisencrypted; - @annotation.XmlElement(name: 'metadata_etag', namespace: namespaceNextcloud, includeIfNull: false) + + @annotation.XmlElement( + name: 'metadata_etag', + namespace: namespaceNextcloud, + includeIfNull: false, + ) String? ncmetadataetag; - @annotation.XmlElement(name: 'upload_time', namespace: namespaceNextcloud, includeIfNull: false) + + @annotation.XmlElement( + name: 'upload_time', + namespace: namespaceNextcloud, + includeIfNull: false, + ) int? ncuploadtime; - @annotation.XmlElement(name: 'creation_time', namespace: namespaceNextcloud, includeIfNull: false) + + @annotation.XmlElement( + name: 'creation_time', + namespace: namespaceNextcloud, + includeIfNull: false, + ) int? nccreationtime; - @annotation.XmlElement(name: 'rich-workspace', namespace: namespaceNextcloud, includeIfNull: false) + + @annotation.XmlElement( + name: 'rich-workspace', + namespace: namespaceNextcloud, + includeIfNull: false, + ) String? ncrichworkspace; - @annotation.XmlElement(name: 'share-permissions', namespace: namespaceOpenCollaborationServices, includeIfNull: false) + + @annotation.XmlElement( + name: 'share-permissions', + namespace: namespaceOpenCollaborationServices, + includeIfNull: false, + ) int? ocssharepermissions; - @annotation.XmlElement(name: 'share-permissions', namespace: namespaceOpenCloudMesh, includeIfNull: false) + + @annotation.XmlElement( + name: 'share-permissions', + namespace: namespaceOpenCloudMesh, + includeIfNull: false, + ) String? ocmsharepermissions; } @@ -215,58 +485,193 @@ class WebDavOcFilterRules with _$WebDavOcFilterRulesXmlSerializableMixin { this.ocmsharepermissions, }); factory WebDavOcFilterRules.fromXmlElement(final XmlElement element) => _$WebDavOcFilterRulesFromXmlElement(element); - @annotation.XmlElement(name: 'getlastmodified', namespace: namespaceDav, includeIfNull: false) + + @annotation.XmlElement( + name: 'getlastmodified', + namespace: namespaceDav, + includeIfNull: false, + ) String? davgetlastmodified; - @annotation.XmlElement(name: 'getetag', namespace: namespaceDav, includeIfNull: false) + + @annotation.XmlElement( + name: 'getetag', + namespace: namespaceDav, + includeIfNull: false, + ) String? davgetetag; - @annotation.XmlElement(name: 'getcontenttype', namespace: namespaceDav, includeIfNull: false) + + @annotation.XmlElement( + name: 'getcontenttype', + namespace: namespaceDav, + includeIfNull: false, + ) String? davgetcontenttype; - @annotation.XmlElement(name: 'getcontentlength', namespace: namespaceDav, includeIfNull: false) + + @annotation.XmlElement( + name: 'getcontentlength', + namespace: namespaceDav, + includeIfNull: false, + ) int? davgetcontentlength; - @annotation.XmlElement(name: 'resourcetype', namespace: namespaceDav, includeIfNull: false) + + @annotation.XmlElement( + name: 'resourcetype', + namespace: namespaceDav, + includeIfNull: false, + ) WebDavResourcetype? davresourcetype; - @annotation.XmlElement(name: 'id', namespace: namespaceOwncloud, includeIfNull: false) + + @annotation.XmlElement( + name: 'id', + namespace: namespaceOwncloud, + includeIfNull: false, + ) String? ocid; - @annotation.XmlElement(name: 'fileid', namespace: namespaceOwncloud, includeIfNull: false) + + @annotation.XmlElement( + name: 'fileid', + namespace: namespaceOwncloud, + includeIfNull: false, + ) String? ocfileid; - @annotation.XmlElement(name: 'favorite', namespace: namespaceOwncloud, includeIfNull: false) + + @annotation.XmlElement( + name: 'favorite', + namespace: namespaceOwncloud, + includeIfNull: false, + ) int? ocfavorite; - @annotation.XmlElement(name: 'comments-href', namespace: namespaceOwncloud, includeIfNull: false) + + @annotation.XmlElement( + name: 'comments-href', + namespace: namespaceOwncloud, + includeIfNull: false, + ) String? occommentshref; - @annotation.XmlElement(name: 'comments-count', namespace: namespaceOwncloud, includeIfNull: false) + + @annotation.XmlElement( + name: 'comments-count', + namespace: namespaceOwncloud, + includeIfNull: false, + ) int? occommentscount; - @annotation.XmlElement(name: 'comments-unread', namespace: namespaceOwncloud, includeIfNull: false) + + @annotation.XmlElement( + name: 'comments-unread', + namespace: namespaceOwncloud, + includeIfNull: false, + ) int? occommentsunread; - @annotation.XmlElement(name: 'downloadURL', namespace: namespaceOwncloud, includeIfNull: false) + + @annotation.XmlElement( + name: 'downloadURL', + namespace: namespaceOwncloud, + includeIfNull: false, + ) String? ocdownloadurl; - @annotation.XmlElement(name: 'owner-id', namespace: namespaceOwncloud, includeIfNull: false) + + @annotation.XmlElement( + name: 'owner-id', + namespace: namespaceOwncloud, + includeIfNull: false, + ) String? ocownerid; - @annotation.XmlElement(name: 'owner-display-name', namespace: namespaceOwncloud, includeIfNull: false) + + @annotation.XmlElement( + name: 'owner-display-name', + namespace: namespaceOwncloud, + includeIfNull: false, + ) String? ocownerdisplayname; - @annotation.XmlElement(name: 'size', namespace: namespaceOwncloud, includeIfNull: false) + + @annotation.XmlElement( + name: 'size', + namespace: namespaceOwncloud, + includeIfNull: false, + ) int? ocsize; - @annotation.XmlElement(name: 'permissions', namespace: namespaceOwncloud, includeIfNull: false) + + @annotation.XmlElement( + name: 'permissions', + namespace: namespaceOwncloud, + includeIfNull: false, + ) String? ocpermissions; - @annotation.XmlElement(name: 'note', namespace: namespaceNextcloud, includeIfNull: false) + + @annotation.XmlElement( + name: 'note', + namespace: namespaceNextcloud, + includeIfNull: false, + ) String? ncnote; - @annotation.XmlElement(name: 'data-fingerprint', namespace: namespaceNextcloud, includeIfNull: false) + + @annotation.XmlElement( + name: 'data-fingerprint', + namespace: namespaceNextcloud, + includeIfNull: false, + ) String? ncdatafingerprint; - @annotation.XmlElement(name: 'has-preview', namespace: namespaceNextcloud, includeIfNull: false) + + @annotation.XmlElement( + name: 'has-preview', + namespace: namespaceNextcloud, + includeIfNull: false, + ) bool? nchaspreview; - @annotation.XmlElement(name: 'mount-type', namespace: namespaceNextcloud, includeIfNull: false) + + @annotation.XmlElement( + name: 'mount-type', + namespace: namespaceNextcloud, + includeIfNull: false, + ) String? ncmounttype; - @annotation.XmlElement(name: 'is-encrypted', namespace: namespaceNextcloud, includeIfNull: false) + + @annotation.XmlElement( + name: 'is-encrypted', + namespace: namespaceNextcloud, + includeIfNull: false, + ) int? ncisencrypted; - @annotation.XmlElement(name: 'metadata_etag', namespace: namespaceNextcloud, includeIfNull: false) + + @annotation.XmlElement( + name: 'metadata_etag', + namespace: namespaceNextcloud, + includeIfNull: false, + ) String? ncmetadataetag; - @annotation.XmlElement(name: 'upload_time', namespace: namespaceNextcloud, includeIfNull: false) + + @annotation.XmlElement( + name: 'upload_time', + namespace: namespaceNextcloud, + includeIfNull: false, + ) int? ncuploadtime; - @annotation.XmlElement(name: 'creation_time', namespace: namespaceNextcloud, includeIfNull: false) + + @annotation.XmlElement( + name: 'creation_time', + namespace: namespaceNextcloud, + includeIfNull: false, + ) int? nccreationtime; - @annotation.XmlElement(name: 'rich-workspace', namespace: namespaceNextcloud, includeIfNull: false) + + @annotation.XmlElement( + name: 'rich-workspace', + namespace: namespaceNextcloud, + includeIfNull: false, + ) String? ncrichworkspace; - @annotation.XmlElement(name: 'share-permissions', namespace: namespaceOpenCollaborationServices, includeIfNull: false) + + @annotation.XmlElement( + name: 'share-permissions', + namespace: namespaceOpenCollaborationServices, + includeIfNull: false, + ) int? ocssharepermissions; - @annotation.XmlElement(name: 'share-permissions', namespace: namespaceOpenCloudMesh, includeIfNull: false) + + @annotation.XmlElement( + name: 'share-permissions', + namespace: namespaceOpenCloudMesh, + includeIfNull: false, + ) String? ocmsharepermissions; } From 12e5c80d9efd4280f8a4858efa7fa0442a8b340c Mon Sep 17 00:00:00 2001 From: jld3103 Date: Sun, 23 Apr 2023 18:03:23 +0200 Subject: [PATCH 2/2] nextcloud: Properly set values for propfinds --- .../neon/neon_files/lib/blocs/browser.dart | 2 +- packages/nextcloud/bin/generate_props.dart | 41 +- packages/nextcloud/lib/src/webdav/props.dart | 194 ++- .../nextcloud/lib/src/webdav/props.g.dart | 1131 +++++++---------- packages/nextcloud/test/webdav.dart | 14 +- 5 files changed, 626 insertions(+), 756 deletions(-) diff --git a/packages/neon/neon_files/lib/blocs/browser.dart b/packages/neon/neon_files/lib/blocs/browser.dart index b19486bb..6f8773c6 100644 --- a/packages/neon/neon_files/lib/blocs/browser.dart +++ b/packages/neon/neon_files/lib/blocs/browser.dart @@ -46,7 +46,7 @@ class FilesBrowserBloc extends InteractiveBloc implements FilesBrowserBlocEvents files, () async => client.webdav.ls( path.value.join('/'), - prop: WebDavPropfindProp( + prop: WebDavPropfindProp.fromBools( davgetcontenttype: true, davgetetag: true, davgetlastmodified: true, diff --git a/packages/nextcloud/bin/generate_props.dart b/packages/nextcloud/bin/generate_props.dart index d9b467cd..3c577449 100644 --- a/packages/nextcloud/bin/generate_props.dart +++ b/packages/nextcloud/bin/generate_props.dart @@ -15,7 +15,7 @@ void main() { "@annotation.XmlElement(name: '$name', namespace: $namespaceVariable, includeIfNull: false,)\n $type? $variable;", ); findProps.add( - "@annotation.XmlElement(name: '$name', namespace: $namespaceVariable, includeIfNull: false,)\n bool? $variable;", + "@annotation.XmlElement(name: '$name', namespace: $namespaceVariable, includeIfNull: true, isSelfClosing: true,)\n List? $variable;", ); variables.add(variable); } @@ -27,9 +27,30 @@ void main() { "import 'package:xml_annotation/xml_annotation.dart' as annotation;", "part 'props.g.dart';", '', - ...generateClass('WebDavPropfindProp', 'prop', 'namespaceDav', findProps, variables), - ...generateClass('WebDavProp', 'prop', 'namespaceDav', valueProps, variables), - ...generateClass('WebDavOcFilterRules', 'filter-rules', 'namespaceOwncloud', valueProps, variables), + ...generateClass( + 'WebDavPropfindProp', + 'prop', + 'namespaceDav', + findProps, + variables, + isPropfind: true, + ), + ...generateClass( + 'WebDavProp', + 'prop', + 'namespaceDav', + valueProps, + variables, + isPropfind: false, + ), + ...generateClass( + 'WebDavOcFilterRules', + 'filter-rules', + 'namespaceOwncloud', + valueProps, + variables, + isPropfind: false, + ), '', ].join('\n'), ); @@ -40,8 +61,9 @@ List generateClass( final String elementName, final String namespace, final List props, - final List variables, -) => + final List variables, { + required final bool isPropfind, +}) => [ '@annotation.XmlSerializable(createMixin: true)', "@annotation.XmlRootElement(name: '$elementName', namespace: $namespace)", @@ -49,6 +71,13 @@ List generateClass( ' $name({', ...variables.map((final variable) => ' this.$variable,'), ' });', + '', + if (isPropfind) ...[ + ' $name.fromBools({', + ...variables.map((final variable) => ' final bool $variable = false,'), + ' }) : ${variables.map((final variable) => '$variable = $variable ? [null] : null').join(', ')};', + '', + ], ' factory $name.fromXmlElement(final XmlElement element) => _\$${name}FromXmlElement(element);', ...props.map((final prop) => '\n $prop'), '}', diff --git a/packages/nextcloud/lib/src/webdav/props.dart b/packages/nextcloud/lib/src/webdav/props.dart index 80a4f8ce..df63ad55 100644 --- a/packages/nextcloud/lib/src/webdav/props.dart +++ b/packages/nextcloud/lib/src/webdav/props.dart @@ -36,196 +36,280 @@ class WebDavPropfindProp with _$WebDavPropfindPropXmlSerializableMixin { this.ocssharepermissions, this.ocmsharepermissions, }); + + WebDavPropfindProp.fromBools({ + final bool davgetlastmodified = false, + final bool davgetetag = false, + final bool davgetcontenttype = false, + final bool davgetcontentlength = false, + final bool davresourcetype = false, + final bool ocid = false, + final bool ocfileid = false, + final bool ocfavorite = false, + final bool occommentshref = false, + final bool occommentscount = false, + final bool occommentsunread = false, + final bool ocdownloadurl = false, + final bool ocownerid = false, + final bool ocownerdisplayname = false, + final bool ocsize = false, + final bool ocpermissions = false, + final bool ncnote = false, + final bool ncdatafingerprint = false, + final bool nchaspreview = false, + final bool ncmounttype = false, + final bool ncisencrypted = false, + final bool ncmetadataetag = false, + final bool ncuploadtime = false, + final bool nccreationtime = false, + final bool ncrichworkspace = false, + final bool ocssharepermissions = false, + final bool ocmsharepermissions = false, + }) : davgetlastmodified = davgetlastmodified ? [null] : null, + davgetetag = davgetetag ? [null] : null, + davgetcontenttype = davgetcontenttype ? [null] : null, + davgetcontentlength = davgetcontentlength ? [null] : null, + davresourcetype = davresourcetype ? [null] : null, + ocid = ocid ? [null] : null, + ocfileid = ocfileid ? [null] : null, + ocfavorite = ocfavorite ? [null] : null, + occommentshref = occommentshref ? [null] : null, + occommentscount = occommentscount ? [null] : null, + occommentsunread = occommentsunread ? [null] : null, + ocdownloadurl = ocdownloadurl ? [null] : null, + ocownerid = ocownerid ? [null] : null, + ocownerdisplayname = ocownerdisplayname ? [null] : null, + ocsize = ocsize ? [null] : null, + ocpermissions = ocpermissions ? [null] : null, + ncnote = ncnote ? [null] : null, + ncdatafingerprint = ncdatafingerprint ? [null] : null, + nchaspreview = nchaspreview ? [null] : null, + ncmounttype = ncmounttype ? [null] : null, + ncisencrypted = ncisencrypted ? [null] : null, + ncmetadataetag = ncmetadataetag ? [null] : null, + ncuploadtime = ncuploadtime ? [null] : null, + nccreationtime = nccreationtime ? [null] : null, + ncrichworkspace = ncrichworkspace ? [null] : null, + ocssharepermissions = ocssharepermissions ? [null] : null, + ocmsharepermissions = ocmsharepermissions ? [null] : null; + factory WebDavPropfindProp.fromXmlElement(final XmlElement element) => _$WebDavPropfindPropFromXmlElement(element); @annotation.XmlElement( name: 'getlastmodified', namespace: namespaceDav, - includeIfNull: false, + includeIfNull: true, + isSelfClosing: true, ) - bool? davgetlastmodified; + List? davgetlastmodified; @annotation.XmlElement( name: 'getetag', namespace: namespaceDav, - includeIfNull: false, + includeIfNull: true, + isSelfClosing: true, ) - bool? davgetetag; + List? davgetetag; @annotation.XmlElement( name: 'getcontenttype', namespace: namespaceDav, - includeIfNull: false, + includeIfNull: true, + isSelfClosing: true, ) - bool? davgetcontenttype; + List? davgetcontenttype; @annotation.XmlElement( name: 'getcontentlength', namespace: namespaceDav, - includeIfNull: false, + includeIfNull: true, + isSelfClosing: true, ) - bool? davgetcontentlength; + List? davgetcontentlength; @annotation.XmlElement( name: 'resourcetype', namespace: namespaceDav, - includeIfNull: false, + includeIfNull: true, + isSelfClosing: true, ) - bool? davresourcetype; + List? davresourcetype; @annotation.XmlElement( name: 'id', namespace: namespaceOwncloud, - includeIfNull: false, + includeIfNull: true, + isSelfClosing: true, ) - bool? ocid; + List? ocid; @annotation.XmlElement( name: 'fileid', namespace: namespaceOwncloud, - includeIfNull: false, + includeIfNull: true, + isSelfClosing: true, ) - bool? ocfileid; + List? ocfileid; @annotation.XmlElement( name: 'favorite', namespace: namespaceOwncloud, - includeIfNull: false, + includeIfNull: true, + isSelfClosing: true, ) - bool? ocfavorite; + List? ocfavorite; @annotation.XmlElement( name: 'comments-href', namespace: namespaceOwncloud, - includeIfNull: false, + includeIfNull: true, + isSelfClosing: true, ) - bool? occommentshref; + List? occommentshref; @annotation.XmlElement( name: 'comments-count', namespace: namespaceOwncloud, - includeIfNull: false, + includeIfNull: true, + isSelfClosing: true, ) - bool? occommentscount; + List? occommentscount; @annotation.XmlElement( name: 'comments-unread', namespace: namespaceOwncloud, - includeIfNull: false, + includeIfNull: true, + isSelfClosing: true, ) - bool? occommentsunread; + List? occommentsunread; @annotation.XmlElement( name: 'downloadURL', namespace: namespaceOwncloud, - includeIfNull: false, + includeIfNull: true, + isSelfClosing: true, ) - bool? ocdownloadurl; + List? ocdownloadurl; @annotation.XmlElement( name: 'owner-id', namespace: namespaceOwncloud, - includeIfNull: false, + includeIfNull: true, + isSelfClosing: true, ) - bool? ocownerid; + List? ocownerid; @annotation.XmlElement( name: 'owner-display-name', namespace: namespaceOwncloud, - includeIfNull: false, + includeIfNull: true, + isSelfClosing: true, ) - bool? ocownerdisplayname; + List? ocownerdisplayname; @annotation.XmlElement( name: 'size', namespace: namespaceOwncloud, - includeIfNull: false, + includeIfNull: true, + isSelfClosing: true, ) - bool? ocsize; + List? ocsize; @annotation.XmlElement( name: 'permissions', namespace: namespaceOwncloud, - includeIfNull: false, + includeIfNull: true, + isSelfClosing: true, ) - bool? ocpermissions; + List? ocpermissions; @annotation.XmlElement( name: 'note', namespace: namespaceNextcloud, - includeIfNull: false, + includeIfNull: true, + isSelfClosing: true, ) - bool? ncnote; + List? ncnote; @annotation.XmlElement( name: 'data-fingerprint', namespace: namespaceNextcloud, - includeIfNull: false, + includeIfNull: true, + isSelfClosing: true, ) - bool? ncdatafingerprint; + List? ncdatafingerprint; @annotation.XmlElement( name: 'has-preview', namespace: namespaceNextcloud, - includeIfNull: false, + includeIfNull: true, + isSelfClosing: true, ) - bool? nchaspreview; + List? nchaspreview; @annotation.XmlElement( name: 'mount-type', namespace: namespaceNextcloud, - includeIfNull: false, + includeIfNull: true, + isSelfClosing: true, ) - bool? ncmounttype; + List? ncmounttype; @annotation.XmlElement( name: 'is-encrypted', namespace: namespaceNextcloud, - includeIfNull: false, + includeIfNull: true, + isSelfClosing: true, ) - bool? ncisencrypted; + List? ncisencrypted; @annotation.XmlElement( name: 'metadata_etag', namespace: namespaceNextcloud, - includeIfNull: false, + includeIfNull: true, + isSelfClosing: true, ) - bool? ncmetadataetag; + List? ncmetadataetag; @annotation.XmlElement( name: 'upload_time', namespace: namespaceNextcloud, - includeIfNull: false, + includeIfNull: true, + isSelfClosing: true, ) - bool? ncuploadtime; + List? ncuploadtime; @annotation.XmlElement( name: 'creation_time', namespace: namespaceNextcloud, - includeIfNull: false, + includeIfNull: true, + isSelfClosing: true, ) - bool? nccreationtime; + List? nccreationtime; @annotation.XmlElement( name: 'rich-workspace', namespace: namespaceNextcloud, - includeIfNull: false, + includeIfNull: true, + isSelfClosing: true, ) - bool? ncrichworkspace; + List? ncrichworkspace; @annotation.XmlElement( name: 'share-permissions', namespace: namespaceOpenCollaborationServices, - includeIfNull: false, + includeIfNull: true, + isSelfClosing: true, ) - bool? ocssharepermissions; + List? ocssharepermissions; @annotation.XmlElement( name: 'share-permissions', namespace: namespaceOpenCloudMesh, - includeIfNull: false, + includeIfNull: true, + isSelfClosing: true, ) - bool? ocmsharepermissions; + List? ocmsharepermissions; } @annotation.XmlSerializable(createMixin: true) @@ -260,6 +344,7 @@ class WebDavProp with _$WebDavPropXmlSerializableMixin { this.ocssharepermissions, this.ocmsharepermissions, }); + factory WebDavProp.fromXmlElement(final XmlElement element) => _$WebDavPropFromXmlElement(element); @annotation.XmlElement( @@ -484,6 +569,7 @@ class WebDavOcFilterRules with _$WebDavOcFilterRulesXmlSerializableMixin { this.ocssharepermissions, this.ocmsharepermissions, }); + factory WebDavOcFilterRules.fromXmlElement(final XmlElement element) => _$WebDavOcFilterRulesFromXmlElement(element); @annotation.XmlElement( diff --git a/packages/nextcloud/lib/src/webdav/props.g.dart b/packages/nextcloud/lib/src/webdav/props.g.dart index 6c8c6f31..3e842c96 100644 --- a/packages/nextcloud/lib/src/webdav/props.g.dart +++ b/packages/nextcloud/lib/src/webdav/props.g.dart @@ -9,301 +9,302 @@ part of 'props.dart'; void _$WebDavPropfindPropBuildXmlChildren(WebDavPropfindProp instance, XmlBuilder builder, {Map namespaces = const {}}) { final davgetlastmodified = instance.davgetlastmodified; - final davgetlastmodifiedSerialized = davgetlastmodified != null - ? davgetlastmodified == true - ? 'true' - : 'false' - : null; + final davgetlastmodifiedSerialized = davgetlastmodified; if (davgetlastmodifiedSerialized != null) { - builder.element('getlastmodified', namespace: 'DAV:', nest: () { - builder.text(davgetlastmodifiedSerialized); - }); + for (final value in davgetlastmodifiedSerialized) { + builder.element('getlastmodified', namespace: 'DAV:', isSelfClosing: true, nest: () { + if (value != null) { + builder.text(value); + } + }); + } } final davgetetag = instance.davgetetag; - final davgetetagSerialized = davgetetag != null - ? davgetetag == true - ? 'true' - : 'false' - : null; + final davgetetagSerialized = davgetetag; if (davgetetagSerialized != null) { - builder.element('getetag', namespace: 'DAV:', nest: () { - builder.text(davgetetagSerialized); - }); + for (final value in davgetetagSerialized) { + builder.element('getetag', namespace: 'DAV:', isSelfClosing: true, nest: () { + if (value != null) { + builder.text(value); + } + }); + } } final davgetcontenttype = instance.davgetcontenttype; - final davgetcontenttypeSerialized = davgetcontenttype != null - ? davgetcontenttype == true - ? 'true' - : 'false' - : null; + final davgetcontenttypeSerialized = davgetcontenttype; if (davgetcontenttypeSerialized != null) { - builder.element('getcontenttype', namespace: 'DAV:', nest: () { - builder.text(davgetcontenttypeSerialized); - }); + for (final value in davgetcontenttypeSerialized) { + builder.element('getcontenttype', namespace: 'DAV:', isSelfClosing: true, nest: () { + if (value != null) { + builder.text(value); + } + }); + } } final davgetcontentlength = instance.davgetcontentlength; - final davgetcontentlengthSerialized = davgetcontentlength != null - ? davgetcontentlength == true - ? 'true' - : 'false' - : null; + final davgetcontentlengthSerialized = davgetcontentlength; if (davgetcontentlengthSerialized != null) { - builder.element('getcontentlength', namespace: 'DAV:', nest: () { - builder.text(davgetcontentlengthSerialized); - }); + for (final value in davgetcontentlengthSerialized) { + builder.element('getcontentlength', namespace: 'DAV:', isSelfClosing: true, nest: () { + if (value != null) { + builder.text(value); + } + }); + } } final davresourcetype = instance.davresourcetype; - final davresourcetypeSerialized = davresourcetype != null - ? davresourcetype == true - ? 'true' - : 'false' - : null; + final davresourcetypeSerialized = davresourcetype; if (davresourcetypeSerialized != null) { - builder.element('resourcetype', namespace: 'DAV:', nest: () { - builder.text(davresourcetypeSerialized); - }); + for (final value in davresourcetypeSerialized) { + builder.element('resourcetype', namespace: 'DAV:', isSelfClosing: true, nest: () { + if (value != null) { + builder.text(value); + } + }); + } } final ocid = instance.ocid; - final ocidSerialized = ocid != null - ? ocid == true - ? 'true' - : 'false' - : null; + final ocidSerialized = ocid; if (ocidSerialized != null) { - builder.element('id', namespace: 'http://owncloud.org/ns', nest: () { - builder.text(ocidSerialized); - }); + for (final value in ocidSerialized) { + builder.element('id', namespace: 'http://owncloud.org/ns', isSelfClosing: true, nest: () { + if (value != null) { + builder.text(value); + } + }); + } } final ocfileid = instance.ocfileid; - final ocfileidSerialized = ocfileid != null - ? ocfileid == true - ? 'true' - : 'false' - : null; + final ocfileidSerialized = ocfileid; if (ocfileidSerialized != null) { - builder.element('fileid', namespace: 'http://owncloud.org/ns', nest: () { - builder.text(ocfileidSerialized); - }); + for (final value in ocfileidSerialized) { + builder.element('fileid', namespace: 'http://owncloud.org/ns', isSelfClosing: true, nest: () { + if (value != null) { + builder.text(value); + } + }); + } } final ocfavorite = instance.ocfavorite; - final ocfavoriteSerialized = ocfavorite != null - ? ocfavorite == true - ? 'true' - : 'false' - : null; + final ocfavoriteSerialized = ocfavorite; if (ocfavoriteSerialized != null) { - builder.element('favorite', namespace: 'http://owncloud.org/ns', nest: () { - builder.text(ocfavoriteSerialized); - }); + for (final value in ocfavoriteSerialized) { + builder.element('favorite', namespace: 'http://owncloud.org/ns', isSelfClosing: true, nest: () { + if (value != null) { + builder.text(value); + } + }); + } } final occommentshref = instance.occommentshref; - final occommentshrefSerialized = occommentshref != null - ? occommentshref == true - ? 'true' - : 'false' - : null; + final occommentshrefSerialized = occommentshref; if (occommentshrefSerialized != null) { - builder.element('comments-href', namespace: 'http://owncloud.org/ns', nest: () { - builder.text(occommentshrefSerialized); - }); + for (final value in occommentshrefSerialized) { + builder.element('comments-href', namespace: 'http://owncloud.org/ns', isSelfClosing: true, nest: () { + if (value != null) { + builder.text(value); + } + }); + } } final occommentscount = instance.occommentscount; - final occommentscountSerialized = occommentscount != null - ? occommentscount == true - ? 'true' - : 'false' - : null; + final occommentscountSerialized = occommentscount; if (occommentscountSerialized != null) { - builder.element('comments-count', namespace: 'http://owncloud.org/ns', nest: () { - builder.text(occommentscountSerialized); - }); + for (final value in occommentscountSerialized) { + builder.element('comments-count', namespace: 'http://owncloud.org/ns', isSelfClosing: true, nest: () { + if (value != null) { + builder.text(value); + } + }); + } } final occommentsunread = instance.occommentsunread; - final occommentsunreadSerialized = occommentsunread != null - ? occommentsunread == true - ? 'true' - : 'false' - : null; + final occommentsunreadSerialized = occommentsunread; if (occommentsunreadSerialized != null) { - builder.element('comments-unread', namespace: 'http://owncloud.org/ns', nest: () { - builder.text(occommentsunreadSerialized); - }); + for (final value in occommentsunreadSerialized) { + builder.element('comments-unread', namespace: 'http://owncloud.org/ns', isSelfClosing: true, nest: () { + if (value != null) { + builder.text(value); + } + }); + } } final ocdownloadurl = instance.ocdownloadurl; - final ocdownloadurlSerialized = ocdownloadurl != null - ? ocdownloadurl == true - ? 'true' - : 'false' - : null; + final ocdownloadurlSerialized = ocdownloadurl; if (ocdownloadurlSerialized != null) { - builder.element('downloadURL', namespace: 'http://owncloud.org/ns', nest: () { - builder.text(ocdownloadurlSerialized); - }); + for (final value in ocdownloadurlSerialized) { + builder.element('downloadURL', namespace: 'http://owncloud.org/ns', isSelfClosing: true, nest: () { + if (value != null) { + builder.text(value); + } + }); + } } final ocownerid = instance.ocownerid; - final ocowneridSerialized = ocownerid != null - ? ocownerid == true - ? 'true' - : 'false' - : null; + final ocowneridSerialized = ocownerid; if (ocowneridSerialized != null) { - builder.element('owner-id', namespace: 'http://owncloud.org/ns', nest: () { - builder.text(ocowneridSerialized); - }); + for (final value in ocowneridSerialized) { + builder.element('owner-id', namespace: 'http://owncloud.org/ns', isSelfClosing: true, nest: () { + if (value != null) { + builder.text(value); + } + }); + } } final ocownerdisplayname = instance.ocownerdisplayname; - final ocownerdisplaynameSerialized = ocownerdisplayname != null - ? ocownerdisplayname == true - ? 'true' - : 'false' - : null; + final ocownerdisplaynameSerialized = ocownerdisplayname; if (ocownerdisplaynameSerialized != null) { - builder.element('owner-display-name', namespace: 'http://owncloud.org/ns', nest: () { - builder.text(ocownerdisplaynameSerialized); - }); + for (final value in ocownerdisplaynameSerialized) { + builder.element('owner-display-name', namespace: 'http://owncloud.org/ns', isSelfClosing: true, nest: () { + if (value != null) { + builder.text(value); + } + }); + } } final ocsize = instance.ocsize; - final ocsizeSerialized = ocsize != null - ? ocsize == true - ? 'true' - : 'false' - : null; + final ocsizeSerialized = ocsize; if (ocsizeSerialized != null) { - builder.element('size', namespace: 'http://owncloud.org/ns', nest: () { - builder.text(ocsizeSerialized); - }); + for (final value in ocsizeSerialized) { + builder.element('size', namespace: 'http://owncloud.org/ns', isSelfClosing: true, nest: () { + if (value != null) { + builder.text(value); + } + }); + } } final ocpermissions = instance.ocpermissions; - final ocpermissionsSerialized = ocpermissions != null - ? ocpermissions == true - ? 'true' - : 'false' - : null; + final ocpermissionsSerialized = ocpermissions; if (ocpermissionsSerialized != null) { - builder.element('permissions', namespace: 'http://owncloud.org/ns', nest: () { - builder.text(ocpermissionsSerialized); - }); + for (final value in ocpermissionsSerialized) { + builder.element('permissions', namespace: 'http://owncloud.org/ns', isSelfClosing: true, nest: () { + if (value != null) { + builder.text(value); + } + }); + } } final ncnote = instance.ncnote; - final ncnoteSerialized = ncnote != null - ? ncnote == true - ? 'true' - : 'false' - : null; + final ncnoteSerialized = ncnote; if (ncnoteSerialized != null) { - builder.element('note', namespace: 'http://nextcloud.org/ns', nest: () { - builder.text(ncnoteSerialized); - }); + for (final value in ncnoteSerialized) { + builder.element('note', namespace: 'http://nextcloud.org/ns', isSelfClosing: true, nest: () { + if (value != null) { + builder.text(value); + } + }); + } } final ncdatafingerprint = instance.ncdatafingerprint; - final ncdatafingerprintSerialized = ncdatafingerprint != null - ? ncdatafingerprint == true - ? 'true' - : 'false' - : null; + final ncdatafingerprintSerialized = ncdatafingerprint; if (ncdatafingerprintSerialized != null) { - builder.element('data-fingerprint', namespace: 'http://nextcloud.org/ns', nest: () { - builder.text(ncdatafingerprintSerialized); - }); + for (final value in ncdatafingerprintSerialized) { + builder.element('data-fingerprint', namespace: 'http://nextcloud.org/ns', isSelfClosing: true, nest: () { + if (value != null) { + builder.text(value); + } + }); + } } final nchaspreview = instance.nchaspreview; - final nchaspreviewSerialized = nchaspreview != null - ? nchaspreview == true - ? 'true' - : 'false' - : null; + final nchaspreviewSerialized = nchaspreview; if (nchaspreviewSerialized != null) { - builder.element('has-preview', namespace: 'http://nextcloud.org/ns', nest: () { - builder.text(nchaspreviewSerialized); - }); + for (final value in nchaspreviewSerialized) { + builder.element('has-preview', namespace: 'http://nextcloud.org/ns', isSelfClosing: true, nest: () { + if (value != null) { + builder.text(value); + } + }); + } } final ncmounttype = instance.ncmounttype; - final ncmounttypeSerialized = ncmounttype != null - ? ncmounttype == true - ? 'true' - : 'false' - : null; + final ncmounttypeSerialized = ncmounttype; if (ncmounttypeSerialized != null) { - builder.element('mount-type', namespace: 'http://nextcloud.org/ns', nest: () { - builder.text(ncmounttypeSerialized); - }); + for (final value in ncmounttypeSerialized) { + builder.element('mount-type', namespace: 'http://nextcloud.org/ns', isSelfClosing: true, nest: () { + if (value != null) { + builder.text(value); + } + }); + } } final ncisencrypted = instance.ncisencrypted; - final ncisencryptedSerialized = ncisencrypted != null - ? ncisencrypted == true - ? 'true' - : 'false' - : null; + final ncisencryptedSerialized = ncisencrypted; if (ncisencryptedSerialized != null) { - builder.element('is-encrypted', namespace: 'http://nextcloud.org/ns', nest: () { - builder.text(ncisencryptedSerialized); - }); + for (final value in ncisencryptedSerialized) { + builder.element('is-encrypted', namespace: 'http://nextcloud.org/ns', isSelfClosing: true, nest: () { + if (value != null) { + builder.text(value); + } + }); + } } final ncmetadataetag = instance.ncmetadataetag; - final ncmetadataetagSerialized = ncmetadataetag != null - ? ncmetadataetag == true - ? 'true' - : 'false' - : null; + final ncmetadataetagSerialized = ncmetadataetag; if (ncmetadataetagSerialized != null) { - builder.element('metadata_etag', namespace: 'http://nextcloud.org/ns', nest: () { - builder.text(ncmetadataetagSerialized); - }); + for (final value in ncmetadataetagSerialized) { + builder.element('metadata_etag', namespace: 'http://nextcloud.org/ns', isSelfClosing: true, nest: () { + if (value != null) { + builder.text(value); + } + }); + } } final ncuploadtime = instance.ncuploadtime; - final ncuploadtimeSerialized = ncuploadtime != null - ? ncuploadtime == true - ? 'true' - : 'false' - : null; + final ncuploadtimeSerialized = ncuploadtime; if (ncuploadtimeSerialized != null) { - builder.element('upload_time', namespace: 'http://nextcloud.org/ns', nest: () { - builder.text(ncuploadtimeSerialized); - }); + for (final value in ncuploadtimeSerialized) { + builder.element('upload_time', namespace: 'http://nextcloud.org/ns', isSelfClosing: true, nest: () { + if (value != null) { + builder.text(value); + } + }); + } } final nccreationtime = instance.nccreationtime; - final nccreationtimeSerialized = nccreationtime != null - ? nccreationtime == true - ? 'true' - : 'false' - : null; + final nccreationtimeSerialized = nccreationtime; if (nccreationtimeSerialized != null) { - builder.element('creation_time', namespace: 'http://nextcloud.org/ns', nest: () { - builder.text(nccreationtimeSerialized); - }); + for (final value in nccreationtimeSerialized) { + builder.element('creation_time', namespace: 'http://nextcloud.org/ns', isSelfClosing: true, nest: () { + if (value != null) { + builder.text(value); + } + }); + } } final ncrichworkspace = instance.ncrichworkspace; - final ncrichworkspaceSerialized = ncrichworkspace != null - ? ncrichworkspace == true - ? 'true' - : 'false' - : null; + final ncrichworkspaceSerialized = ncrichworkspace; if (ncrichworkspaceSerialized != null) { - builder.element('rich-workspace', namespace: 'http://nextcloud.org/ns', nest: () { - builder.text(ncrichworkspaceSerialized); - }); + for (final value in ncrichworkspaceSerialized) { + builder.element('rich-workspace', namespace: 'http://nextcloud.org/ns', isSelfClosing: true, nest: () { + if (value != null) { + builder.text(value); + } + }); + } } final ocssharepermissions = instance.ocssharepermissions; - final ocssharepermissionsSerialized = ocssharepermissions != null - ? ocssharepermissions == true - ? 'true' - : 'false' - : null; + final ocssharepermissionsSerialized = ocssharepermissions; if (ocssharepermissionsSerialized != null) { - builder.element('share-permissions', namespace: 'http://open-collaboration-services.org/ns', nest: () { - builder.text(ocssharepermissionsSerialized); - }); + for (final value in ocssharepermissionsSerialized) { + builder.element('share-permissions', namespace: 'http://open-collaboration-services.org/ns', isSelfClosing: true, + nest: () { + if (value != null) { + builder.text(value); + } + }); + } } final ocmsharepermissions = instance.ocmsharepermissions; - final ocmsharepermissionsSerialized = ocmsharepermissions != null - ? ocmsharepermissions == true - ? 'true' - : 'false' - : null; + final ocmsharepermissionsSerialized = ocmsharepermissions; if (ocmsharepermissionsSerialized != null) { - builder.element('share-permissions', namespace: 'http://open-cloud-mesh.org/ns', nest: () { - builder.text(ocmsharepermissionsSerialized); - }); + for (final value in ocmsharepermissionsSerialized) { + builder.element('share-permissions', namespace: 'http://open-cloud-mesh.org/ns', isSelfClosing: true, nest: () { + if (value != null) { + builder.text(value); + } + }); + } } } @@ -315,225 +316,119 @@ void _$WebDavPropfindPropBuildXmlElement(WebDavPropfindProp instance, XmlBuilder } WebDavPropfindProp _$WebDavPropfindPropFromXmlElement(XmlElement element) { - final davgetlastmodified = element.getElement('getlastmodified', namespace: 'DAV:')?.getText(); - final davgetetag = element.getElement('getetag', namespace: 'DAV:')?.getText(); - final davgetcontenttype = element.getElement('getcontenttype', namespace: 'DAV:')?.getText(); - final davgetcontentlength = element.getElement('getcontentlength', namespace: 'DAV:')?.getText(); - final davresourcetype = element.getElement('resourcetype', namespace: 'DAV:')?.getText(); - final ocid = element.getElement('id', namespace: 'http://owncloud.org/ns')?.getText(); - final ocfileid = element.getElement('fileid', namespace: 'http://owncloud.org/ns')?.getText(); - final ocfavorite = element.getElement('favorite', namespace: 'http://owncloud.org/ns')?.getText(); - final occommentshref = element.getElement('comments-href', namespace: 'http://owncloud.org/ns')?.getText(); - final occommentscount = element.getElement('comments-count', namespace: 'http://owncloud.org/ns')?.getText(); - final occommentsunread = element.getElement('comments-unread', namespace: 'http://owncloud.org/ns')?.getText(); - final ocdownloadurl = element.getElement('downloadURL', namespace: 'http://owncloud.org/ns')?.getText(); - final ocownerid = element.getElement('owner-id', namespace: 'http://owncloud.org/ns')?.getText(); - final ocownerdisplayname = element.getElement('owner-display-name', namespace: 'http://owncloud.org/ns')?.getText(); - final ocsize = element.getElement('size', namespace: 'http://owncloud.org/ns')?.getText(); - final ocpermissions = element.getElement('permissions', namespace: 'http://owncloud.org/ns')?.getText(); - final ncnote = element.getElement('note', namespace: 'http://nextcloud.org/ns')?.getText(); - final ncdatafingerprint = element.getElement('data-fingerprint', namespace: 'http://nextcloud.org/ns')?.getText(); - final nchaspreview = element.getElement('has-preview', namespace: 'http://nextcloud.org/ns')?.getText(); - final ncmounttype = element.getElement('mount-type', namespace: 'http://nextcloud.org/ns')?.getText(); - final ncisencrypted = element.getElement('is-encrypted', namespace: 'http://nextcloud.org/ns')?.getText(); - final ncmetadataetag = element.getElement('metadata_etag', namespace: 'http://nextcloud.org/ns')?.getText(); - final ncuploadtime = element.getElement('upload_time', namespace: 'http://nextcloud.org/ns')?.getText(); - final nccreationtime = element.getElement('creation_time', namespace: 'http://nextcloud.org/ns')?.getText(); - final ncrichworkspace = element.getElement('rich-workspace', namespace: 'http://nextcloud.org/ns')?.getText(); - final ocssharepermissions = - element.getElement('share-permissions', namespace: 'http://open-collaboration-services.org/ns')?.getText(); - final ocmsharepermissions = - element.getElement('share-permissions', namespace: 'http://open-cloud-mesh.org/ns')?.getText(); + final davgetlastmodified = + element.getElements('getlastmodified', namespace: 'DAV:')?.map((e) => e.getText()).whereType(); + final davgetetag = element.getElements('getetag', namespace: 'DAV:')?.map((e) => e.getText()).whereType(); + final davgetcontenttype = + element.getElements('getcontenttype', namespace: 'DAV:')?.map((e) => e.getText()).whereType(); + final davgetcontentlength = + element.getElements('getcontentlength', namespace: 'DAV:')?.map((e) => e.getText()).whereType(); + final davresourcetype = + element.getElements('resourcetype', namespace: 'DAV:')?.map((e) => e.getText()).whereType(); + final ocid = + element.getElements('id', namespace: 'http://owncloud.org/ns')?.map((e) => e.getText()).whereType(); + final ocfileid = + element.getElements('fileid', namespace: 'http://owncloud.org/ns')?.map((e) => e.getText()).whereType(); + final ocfavorite = + element.getElements('favorite', namespace: 'http://owncloud.org/ns')?.map((e) => e.getText()).whereType(); + final occommentshref = element + .getElements('comments-href', namespace: 'http://owncloud.org/ns') + ?.map((e) => e.getText()) + .whereType(); + final occommentscount = element + .getElements('comments-count', namespace: 'http://owncloud.org/ns') + ?.map((e) => e.getText()) + .whereType(); + final occommentsunread = element + .getElements('comments-unread', namespace: 'http://owncloud.org/ns') + ?.map((e) => e.getText()) + .whereType(); + final ocdownloadurl = element + .getElements('downloadURL', namespace: 'http://owncloud.org/ns') + ?.map((e) => e.getText()) + .whereType(); + final ocownerid = + element.getElements('owner-id', namespace: 'http://owncloud.org/ns')?.map((e) => e.getText()).whereType(); + final ocownerdisplayname = element + .getElements('owner-display-name', namespace: 'http://owncloud.org/ns') + ?.map((e) => e.getText()) + .whereType(); + final ocsize = + element.getElements('size', namespace: 'http://owncloud.org/ns')?.map((e) => e.getText()).whereType(); + final ocpermissions = element + .getElements('permissions', namespace: 'http://owncloud.org/ns') + ?.map((e) => e.getText()) + .whereType(); + final ncnote = + element.getElements('note', namespace: 'http://nextcloud.org/ns')?.map((e) => e.getText()).whereType(); + final ncdatafingerprint = element + .getElements('data-fingerprint', namespace: 'http://nextcloud.org/ns') + ?.map((e) => e.getText()) + .whereType(); + final nchaspreview = element + .getElements('has-preview', namespace: 'http://nextcloud.org/ns') + ?.map((e) => e.getText()) + .whereType(); + final ncmounttype = element + .getElements('mount-type', namespace: 'http://nextcloud.org/ns') + ?.map((e) => e.getText()) + .whereType(); + final ncisencrypted = element + .getElements('is-encrypted', namespace: 'http://nextcloud.org/ns') + ?.map((e) => e.getText()) + .whereType(); + final ncmetadataetag = element + .getElements('metadata_etag', namespace: 'http://nextcloud.org/ns') + ?.map((e) => e.getText()) + .whereType(); + final ncuploadtime = element + .getElements('upload_time', namespace: 'http://nextcloud.org/ns') + ?.map((e) => e.getText()) + .whereType(); + final nccreationtime = element + .getElements('creation_time', namespace: 'http://nextcloud.org/ns') + ?.map((e) => e.getText()) + .whereType(); + final ncrichworkspace = element + .getElements('rich-workspace', namespace: 'http://nextcloud.org/ns') + ?.map((e) => e.getText()) + .whereType(); + final ocssharepermissions = element + .getElements('share-permissions', namespace: 'http://open-collaboration-services.org/ns') + ?.map((e) => e.getText()) + .whereType(); + final ocmsharepermissions = element + .getElements('share-permissions', namespace: 'http://open-cloud-mesh.org/ns') + ?.map((e) => e.getText()) + .whereType(); return WebDavPropfindProp( - davgetlastmodified: davgetlastmodified != null - ? davgetlastmodified == 'true' || davgetlastmodified == '1' - ? true - : davgetlastmodified == 'false' || davgetlastmodified == '0' - ? false - : throw FormatException('Invalid bool format', davgetlastmodified) - : null, - davgetetag: davgetetag != null - ? davgetetag == 'true' || davgetetag == '1' - ? true - : davgetetag == 'false' || davgetetag == '0' - ? false - : throw FormatException('Invalid bool format', davgetetag) - : null, - davgetcontenttype: davgetcontenttype != null - ? davgetcontenttype == 'true' || davgetcontenttype == '1' - ? true - : davgetcontenttype == 'false' || davgetcontenttype == '0' - ? false - : throw FormatException('Invalid bool format', davgetcontenttype) - : null, - davgetcontentlength: davgetcontentlength != null - ? davgetcontentlength == 'true' || davgetcontentlength == '1' - ? true - : davgetcontentlength == 'false' || davgetcontentlength == '0' - ? false - : throw FormatException('Invalid bool format', davgetcontentlength) - : null, - davresourcetype: davresourcetype != null - ? davresourcetype == 'true' || davresourcetype == '1' - ? true - : davresourcetype == 'false' || davresourcetype == '0' - ? false - : throw FormatException('Invalid bool format', davresourcetype) - : null, - ocid: ocid != null - ? ocid == 'true' || ocid == '1' - ? true - : ocid == 'false' || ocid == '0' - ? false - : throw FormatException('Invalid bool format', ocid) - : null, - ocfileid: ocfileid != null - ? ocfileid == 'true' || ocfileid == '1' - ? true - : ocfileid == 'false' || ocfileid == '0' - ? false - : throw FormatException('Invalid bool format', ocfileid) - : null, - ocfavorite: ocfavorite != null - ? ocfavorite == 'true' || ocfavorite == '1' - ? true - : ocfavorite == 'false' || ocfavorite == '0' - ? false - : throw FormatException('Invalid bool format', ocfavorite) - : null, - occommentshref: occommentshref != null - ? occommentshref == 'true' || occommentshref == '1' - ? true - : occommentshref == 'false' || occommentshref == '0' - ? false - : throw FormatException('Invalid bool format', occommentshref) - : null, - occommentscount: occommentscount != null - ? occommentscount == 'true' || occommentscount == '1' - ? true - : occommentscount == 'false' || occommentscount == '0' - ? false - : throw FormatException('Invalid bool format', occommentscount) - : null, - occommentsunread: occommentsunread != null - ? occommentsunread == 'true' || occommentsunread == '1' - ? true - : occommentsunread == 'false' || occommentsunread == '0' - ? false - : throw FormatException('Invalid bool format', occommentsunread) - : null, - ocdownloadurl: ocdownloadurl != null - ? ocdownloadurl == 'true' || ocdownloadurl == '1' - ? true - : ocdownloadurl == 'false' || ocdownloadurl == '0' - ? false - : throw FormatException('Invalid bool format', ocdownloadurl) - : null, - ocownerid: ocownerid != null - ? ocownerid == 'true' || ocownerid == '1' - ? true - : ocownerid == 'false' || ocownerid == '0' - ? false - : throw FormatException('Invalid bool format', ocownerid) - : null, - ocownerdisplayname: ocownerdisplayname != null - ? ocownerdisplayname == 'true' || ocownerdisplayname == '1' - ? true - : ocownerdisplayname == 'false' || ocownerdisplayname == '0' - ? false - : throw FormatException('Invalid bool format', ocownerdisplayname) - : null, - ocsize: ocsize != null - ? ocsize == 'true' || ocsize == '1' - ? true - : ocsize == 'false' || ocsize == '0' - ? false - : throw FormatException('Invalid bool format', ocsize) - : null, - ocpermissions: ocpermissions != null - ? ocpermissions == 'true' || ocpermissions == '1' - ? true - : ocpermissions == 'false' || ocpermissions == '0' - ? false - : throw FormatException('Invalid bool format', ocpermissions) - : null, - ncnote: ncnote != null - ? ncnote == 'true' || ncnote == '1' - ? true - : ncnote == 'false' || ncnote == '0' - ? false - : throw FormatException('Invalid bool format', ncnote) - : null, - ncdatafingerprint: ncdatafingerprint != null - ? ncdatafingerprint == 'true' || ncdatafingerprint == '1' - ? true - : ncdatafingerprint == 'false' || ncdatafingerprint == '0' - ? false - : throw FormatException('Invalid bool format', ncdatafingerprint) - : null, - nchaspreview: nchaspreview != null - ? nchaspreview == 'true' || nchaspreview == '1' - ? true - : nchaspreview == 'false' || nchaspreview == '0' - ? false - : throw FormatException('Invalid bool format', nchaspreview) - : null, - ncmounttype: ncmounttype != null - ? ncmounttype == 'true' || ncmounttype == '1' - ? true - : ncmounttype == 'false' || ncmounttype == '0' - ? false - : throw FormatException('Invalid bool format', ncmounttype) - : null, - ncisencrypted: ncisencrypted != null - ? ncisencrypted == 'true' || ncisencrypted == '1' - ? true - : ncisencrypted == 'false' || ncisencrypted == '0' - ? false - : throw FormatException('Invalid bool format', ncisencrypted) - : null, - ncmetadataetag: ncmetadataetag != null - ? ncmetadataetag == 'true' || ncmetadataetag == '1' - ? true - : ncmetadataetag == 'false' || ncmetadataetag == '0' - ? false - : throw FormatException('Invalid bool format', ncmetadataetag) - : null, - ncuploadtime: ncuploadtime != null - ? ncuploadtime == 'true' || ncuploadtime == '1' - ? true - : ncuploadtime == 'false' || ncuploadtime == '0' - ? false - : throw FormatException('Invalid bool format', ncuploadtime) - : null, - nccreationtime: nccreationtime != null - ? nccreationtime == 'true' || nccreationtime == '1' - ? true - : nccreationtime == 'false' || nccreationtime == '0' - ? false - : throw FormatException('Invalid bool format', nccreationtime) - : null, - ncrichworkspace: ncrichworkspace != null - ? ncrichworkspace == 'true' || ncrichworkspace == '1' - ? true - : ncrichworkspace == 'false' || ncrichworkspace == '0' - ? false - : throw FormatException('Invalid bool format', ncrichworkspace) - : null, - ocssharepermissions: ocssharepermissions != null - ? ocssharepermissions == 'true' || ocssharepermissions == '1' - ? true - : ocssharepermissions == 'false' || ocssharepermissions == '0' - ? false - : throw FormatException('Invalid bool format', ocssharepermissions) - : null, - ocmsharepermissions: ocmsharepermissions != null - ? ocmsharepermissions == 'true' || ocmsharepermissions == '1' - ? true - : ocmsharepermissions == 'false' || ocmsharepermissions == '0' - ? false - : throw FormatException('Invalid bool format', ocmsharepermissions) - : null); + davgetlastmodified: davgetlastmodified?.toList(), + davgetetag: davgetetag?.toList(), + davgetcontenttype: davgetcontenttype?.toList(), + davgetcontentlength: davgetcontentlength?.toList(), + davresourcetype: davresourcetype?.toList(), + ocid: ocid?.toList(), + ocfileid: ocfileid?.toList(), + ocfavorite: ocfavorite?.toList(), + occommentshref: occommentshref?.toList(), + occommentscount: occommentscount?.toList(), + occommentsunread: occommentsunread?.toList(), + ocdownloadurl: ocdownloadurl?.toList(), + ocownerid: ocownerid?.toList(), + ocownerdisplayname: ocownerdisplayname?.toList(), + ocsize: ocsize?.toList(), + ocpermissions: ocpermissions?.toList(), + ncnote: ncnote?.toList(), + ncdatafingerprint: ncdatafingerprint?.toList(), + nchaspreview: nchaspreview?.toList(), + ncmounttype: ncmounttype?.toList(), + ncisencrypted: ncisencrypted?.toList(), + ncmetadataetag: ncmetadataetag?.toList(), + ncuploadtime: ncuploadtime?.toList(), + nccreationtime: nccreationtime?.toList(), + ncrichworkspace: ncrichworkspace?.toList(), + ocssharepermissions: ocssharepermissions?.toList(), + ocmsharepermissions: ocmsharepermissions?.toList()); } List _$WebDavPropfindPropToXmlAttributes(WebDavPropfindProp instance, @@ -546,339 +441,199 @@ List _$WebDavPropfindPropToXmlChildren(WebDavPropfindProp instance, {Map namespaces = const {}}) { final children = []; final davgetlastmodified = instance.davgetlastmodified; - final davgetlastmodifiedSerialized = davgetlastmodified != null - ? davgetlastmodified == true - ? 'true' - : 'false' - : null; - final davgetlastmodifiedConstructed = davgetlastmodifiedSerialized != null - ? XmlElement(XmlName('getlastmodified', namespaces['DAV:']), [], [XmlText(davgetlastmodifiedSerialized)]) - : null; + final davgetlastmodifiedSerialized = davgetlastmodified; + final davgetlastmodifiedConstructed = davgetlastmodifiedSerialized + ?.map((e) => XmlElement(XmlName('getlastmodified', namespaces['DAV:']), [], e != null ? [XmlText(e)] : [], true)); if (davgetlastmodifiedConstructed != null) { - children.add(davgetlastmodifiedConstructed); + children.addAll(davgetlastmodifiedConstructed); } final davgetetag = instance.davgetetag; - final davgetetagSerialized = davgetetag != null - ? davgetetag == true - ? 'true' - : 'false' - : null; - final davgetetagConstructed = davgetetagSerialized != null - ? XmlElement(XmlName('getetag', namespaces['DAV:']), [], [XmlText(davgetetagSerialized)]) - : null; + final davgetetagSerialized = davgetetag; + final davgetetagConstructed = davgetetagSerialized + ?.map((e) => XmlElement(XmlName('getetag', namespaces['DAV:']), [], e != null ? [XmlText(e)] : [], true)); if (davgetetagConstructed != null) { - children.add(davgetetagConstructed); + children.addAll(davgetetagConstructed); } final davgetcontenttype = instance.davgetcontenttype; - final davgetcontenttypeSerialized = davgetcontenttype != null - ? davgetcontenttype == true - ? 'true' - : 'false' - : null; - final davgetcontenttypeConstructed = davgetcontenttypeSerialized != null - ? XmlElement(XmlName('getcontenttype', namespaces['DAV:']), [], [XmlText(davgetcontenttypeSerialized)]) - : null; + final davgetcontenttypeSerialized = davgetcontenttype; + final davgetcontenttypeConstructed = davgetcontenttypeSerialized + ?.map((e) => XmlElement(XmlName('getcontenttype', namespaces['DAV:']), [], e != null ? [XmlText(e)] : [], true)); if (davgetcontenttypeConstructed != null) { - children.add(davgetcontenttypeConstructed); + children.addAll(davgetcontenttypeConstructed); } final davgetcontentlength = instance.davgetcontentlength; - final davgetcontentlengthSerialized = davgetcontentlength != null - ? davgetcontentlength == true - ? 'true' - : 'false' - : null; - final davgetcontentlengthConstructed = davgetcontentlengthSerialized != null - ? XmlElement(XmlName('getcontentlength', namespaces['DAV:']), [], [XmlText(davgetcontentlengthSerialized)]) - : null; + final davgetcontentlengthSerialized = davgetcontentlength; + final davgetcontentlengthConstructed = davgetcontentlengthSerialized?.map( + (e) => XmlElement(XmlName('getcontentlength', namespaces['DAV:']), [], e != null ? [XmlText(e)] : [], true)); if (davgetcontentlengthConstructed != null) { - children.add(davgetcontentlengthConstructed); + children.addAll(davgetcontentlengthConstructed); } final davresourcetype = instance.davresourcetype; - final davresourcetypeSerialized = davresourcetype != null - ? davresourcetype == true - ? 'true' - : 'false' - : null; - final davresourcetypeConstructed = davresourcetypeSerialized != null - ? XmlElement(XmlName('resourcetype', namespaces['DAV:']), [], [XmlText(davresourcetypeSerialized)]) - : null; + final davresourcetypeSerialized = davresourcetype; + final davresourcetypeConstructed = davresourcetypeSerialized + ?.map((e) => XmlElement(XmlName('resourcetype', namespaces['DAV:']), [], e != null ? [XmlText(e)] : [], true)); if (davresourcetypeConstructed != null) { - children.add(davresourcetypeConstructed); + children.addAll(davresourcetypeConstructed); } final ocid = instance.ocid; - final ocidSerialized = ocid != null - ? ocid == true - ? 'true' - : 'false' - : null; - final ocidConstructed = ocidSerialized != null - ? XmlElement(XmlName('id', namespaces['http://owncloud.org/ns']), [], [XmlText(ocidSerialized)]) - : null; + final ocidSerialized = ocid; + final ocidConstructed = ocidSerialized?.map( + (e) => XmlElement(XmlName('id', namespaces['http://owncloud.org/ns']), [], e != null ? [XmlText(e)] : [], true)); if (ocidConstructed != null) { - children.add(ocidConstructed); + children.addAll(ocidConstructed); } final ocfileid = instance.ocfileid; - final ocfileidSerialized = ocfileid != null - ? ocfileid == true - ? 'true' - : 'false' - : null; - final ocfileidConstructed = ocfileidSerialized != null - ? XmlElement(XmlName('fileid', namespaces['http://owncloud.org/ns']), [], [XmlText(ocfileidSerialized)]) - : null; + final ocfileidSerialized = ocfileid; + final ocfileidConstructed = ocfileidSerialized?.map((e) => + XmlElement(XmlName('fileid', namespaces['http://owncloud.org/ns']), [], e != null ? [XmlText(e)] : [], true)); if (ocfileidConstructed != null) { - children.add(ocfileidConstructed); + children.addAll(ocfileidConstructed); } final ocfavorite = instance.ocfavorite; - final ocfavoriteSerialized = ocfavorite != null - ? ocfavorite == true - ? 'true' - : 'false' - : null; - final ocfavoriteConstructed = ocfavoriteSerialized != null - ? XmlElement(XmlName('favorite', namespaces['http://owncloud.org/ns']), [], [XmlText(ocfavoriteSerialized)]) - : null; + final ocfavoriteSerialized = ocfavorite; + final ocfavoriteConstructed = ocfavoriteSerialized?.map((e) => + XmlElement(XmlName('favorite', namespaces['http://owncloud.org/ns']), [], e != null ? [XmlText(e)] : [], true)); if (ocfavoriteConstructed != null) { - children.add(ocfavoriteConstructed); + children.addAll(ocfavoriteConstructed); } final occommentshref = instance.occommentshref; - final occommentshrefSerialized = occommentshref != null - ? occommentshref == true - ? 'true' - : 'false' - : null; - final occommentshrefConstructed = occommentshrefSerialized != null - ? XmlElement( - XmlName('comments-href', namespaces['http://owncloud.org/ns']), [], [XmlText(occommentshrefSerialized)]) - : null; + final occommentshrefSerialized = occommentshref; + final occommentshrefConstructed = occommentshrefSerialized?.map((e) => XmlElement( + XmlName('comments-href', namespaces['http://owncloud.org/ns']), [], e != null ? [XmlText(e)] : [], true)); if (occommentshrefConstructed != null) { - children.add(occommentshrefConstructed); + children.addAll(occommentshrefConstructed); } final occommentscount = instance.occommentscount; - final occommentscountSerialized = occommentscount != null - ? occommentscount == true - ? 'true' - : 'false' - : null; - final occommentscountConstructed = occommentscountSerialized != null - ? XmlElement( - XmlName('comments-count', namespaces['http://owncloud.org/ns']), [], [XmlText(occommentscountSerialized)]) - : null; + final occommentscountSerialized = occommentscount; + final occommentscountConstructed = occommentscountSerialized?.map((e) => XmlElement( + XmlName('comments-count', namespaces['http://owncloud.org/ns']), [], e != null ? [XmlText(e)] : [], true)); if (occommentscountConstructed != null) { - children.add(occommentscountConstructed); + children.addAll(occommentscountConstructed); } final occommentsunread = instance.occommentsunread; - final occommentsunreadSerialized = occommentsunread != null - ? occommentsunread == true - ? 'true' - : 'false' - : null; - final occommentsunreadConstructed = occommentsunreadSerialized != null - ? XmlElement( - XmlName('comments-unread', namespaces['http://owncloud.org/ns']), [], [XmlText(occommentsunreadSerialized)]) - : null; + final occommentsunreadSerialized = occommentsunread; + final occommentsunreadConstructed = occommentsunreadSerialized?.map((e) => XmlElement( + XmlName('comments-unread', namespaces['http://owncloud.org/ns']), [], e != null ? [XmlText(e)] : [], true)); if (occommentsunreadConstructed != null) { - children.add(occommentsunreadConstructed); + children.addAll(occommentsunreadConstructed); } final ocdownloadurl = instance.ocdownloadurl; - final ocdownloadurlSerialized = ocdownloadurl != null - ? ocdownloadurl == true - ? 'true' - : 'false' - : null; - final ocdownloadurlConstructed = ocdownloadurlSerialized != null - ? XmlElement(XmlName('downloadURL', namespaces['http://owncloud.org/ns']), [], [XmlText(ocdownloadurlSerialized)]) - : null; + final ocdownloadurlSerialized = ocdownloadurl; + final ocdownloadurlConstructed = ocdownloadurlSerialized?.map((e) => XmlElement( + XmlName('downloadURL', namespaces['http://owncloud.org/ns']), [], e != null ? [XmlText(e)] : [], true)); if (ocdownloadurlConstructed != null) { - children.add(ocdownloadurlConstructed); + children.addAll(ocdownloadurlConstructed); } final ocownerid = instance.ocownerid; - final ocowneridSerialized = ocownerid != null - ? ocownerid == true - ? 'true' - : 'false' - : null; - final ocowneridConstructed = ocowneridSerialized != null - ? XmlElement(XmlName('owner-id', namespaces['http://owncloud.org/ns']), [], [XmlText(ocowneridSerialized)]) - : null; + final ocowneridSerialized = ocownerid; + final ocowneridConstructed = ocowneridSerialized?.map((e) => + XmlElement(XmlName('owner-id', namespaces['http://owncloud.org/ns']), [], e != null ? [XmlText(e)] : [], true)); if (ocowneridConstructed != null) { - children.add(ocowneridConstructed); + children.addAll(ocowneridConstructed); } final ocownerdisplayname = instance.ocownerdisplayname; - final ocownerdisplaynameSerialized = ocownerdisplayname != null - ? ocownerdisplayname == true - ? 'true' - : 'false' - : null; - final ocownerdisplaynameConstructed = ocownerdisplaynameSerialized != null - ? XmlElement(XmlName('owner-display-name', namespaces['http://owncloud.org/ns']), [], - [XmlText(ocownerdisplaynameSerialized)]) - : null; + final ocownerdisplaynameSerialized = ocownerdisplayname; + final ocownerdisplaynameConstructed = ocownerdisplaynameSerialized?.map((e) => XmlElement( + XmlName('owner-display-name', namespaces['http://owncloud.org/ns']), [], e != null ? [XmlText(e)] : [], true)); if (ocownerdisplaynameConstructed != null) { - children.add(ocownerdisplaynameConstructed); + children.addAll(ocownerdisplaynameConstructed); } final ocsize = instance.ocsize; - final ocsizeSerialized = ocsize != null - ? ocsize == true - ? 'true' - : 'false' - : null; - final ocsizeConstructed = ocsizeSerialized != null - ? XmlElement(XmlName('size', namespaces['http://owncloud.org/ns']), [], [XmlText(ocsizeSerialized)]) - : null; + final ocsizeSerialized = ocsize; + final ocsizeConstructed = ocsizeSerialized?.map((e) => + XmlElement(XmlName('size', namespaces['http://owncloud.org/ns']), [], e != null ? [XmlText(e)] : [], true)); if (ocsizeConstructed != null) { - children.add(ocsizeConstructed); + children.addAll(ocsizeConstructed); } final ocpermissions = instance.ocpermissions; - final ocpermissionsSerialized = ocpermissions != null - ? ocpermissions == true - ? 'true' - : 'false' - : null; - final ocpermissionsConstructed = ocpermissionsSerialized != null - ? XmlElement(XmlName('permissions', namespaces['http://owncloud.org/ns']), [], [XmlText(ocpermissionsSerialized)]) - : null; + final ocpermissionsSerialized = ocpermissions; + final ocpermissionsConstructed = ocpermissionsSerialized?.map((e) => XmlElement( + XmlName('permissions', namespaces['http://owncloud.org/ns']), [], e != null ? [XmlText(e)] : [], true)); if (ocpermissionsConstructed != null) { - children.add(ocpermissionsConstructed); + children.addAll(ocpermissionsConstructed); } final ncnote = instance.ncnote; - final ncnoteSerialized = ncnote != null - ? ncnote == true - ? 'true' - : 'false' - : null; - final ncnoteConstructed = ncnoteSerialized != null - ? XmlElement(XmlName('note', namespaces['http://nextcloud.org/ns']), [], [XmlText(ncnoteSerialized)]) - : null; + final ncnoteSerialized = ncnote; + final ncnoteConstructed = ncnoteSerialized?.map((e) => + XmlElement(XmlName('note', namespaces['http://nextcloud.org/ns']), [], e != null ? [XmlText(e)] : [], true)); if (ncnoteConstructed != null) { - children.add(ncnoteConstructed); + children.addAll(ncnoteConstructed); } final ncdatafingerprint = instance.ncdatafingerprint; - final ncdatafingerprintSerialized = ncdatafingerprint != null - ? ncdatafingerprint == true - ? 'true' - : 'false' - : null; - final ncdatafingerprintConstructed = ncdatafingerprintSerialized != null - ? XmlElement(XmlName('data-fingerprint', namespaces['http://nextcloud.org/ns']), [], - [XmlText(ncdatafingerprintSerialized)]) - : null; + final ncdatafingerprintSerialized = ncdatafingerprint; + final ncdatafingerprintConstructed = ncdatafingerprintSerialized?.map((e) => XmlElement( + XmlName('data-fingerprint', namespaces['http://nextcloud.org/ns']), [], e != null ? [XmlText(e)] : [], true)); if (ncdatafingerprintConstructed != null) { - children.add(ncdatafingerprintConstructed); + children.addAll(ncdatafingerprintConstructed); } final nchaspreview = instance.nchaspreview; - final nchaspreviewSerialized = nchaspreview != null - ? nchaspreview == true - ? 'true' - : 'false' - : null; - final nchaspreviewConstructed = nchaspreviewSerialized != null - ? XmlElement(XmlName('has-preview', namespaces['http://nextcloud.org/ns']), [], [XmlText(nchaspreviewSerialized)]) - : null; + final nchaspreviewSerialized = nchaspreview; + final nchaspreviewConstructed = nchaspreviewSerialized?.map((e) => XmlElement( + XmlName('has-preview', namespaces['http://nextcloud.org/ns']), [], e != null ? [XmlText(e)] : [], true)); if (nchaspreviewConstructed != null) { - children.add(nchaspreviewConstructed); + children.addAll(nchaspreviewConstructed); } final ncmounttype = instance.ncmounttype; - final ncmounttypeSerialized = ncmounttype != null - ? ncmounttype == true - ? 'true' - : 'false' - : null; - final ncmounttypeConstructed = ncmounttypeSerialized != null - ? XmlElement(XmlName('mount-type', namespaces['http://nextcloud.org/ns']), [], [XmlText(ncmounttypeSerialized)]) - : null; + final ncmounttypeSerialized = ncmounttype; + final ncmounttypeConstructed = ncmounttypeSerialized?.map((e) => XmlElement( + XmlName('mount-type', namespaces['http://nextcloud.org/ns']), [], e != null ? [XmlText(e)] : [], true)); if (ncmounttypeConstructed != null) { - children.add(ncmounttypeConstructed); + children.addAll(ncmounttypeConstructed); } final ncisencrypted = instance.ncisencrypted; - final ncisencryptedSerialized = ncisencrypted != null - ? ncisencrypted == true - ? 'true' - : 'false' - : null; - final ncisencryptedConstructed = ncisencryptedSerialized != null - ? XmlElement( - XmlName('is-encrypted', namespaces['http://nextcloud.org/ns']), [], [XmlText(ncisencryptedSerialized)]) - : null; + final ncisencryptedSerialized = ncisencrypted; + final ncisencryptedConstructed = ncisencryptedSerialized?.map((e) => XmlElement( + XmlName('is-encrypted', namespaces['http://nextcloud.org/ns']), [], e != null ? [XmlText(e)] : [], true)); if (ncisencryptedConstructed != null) { - children.add(ncisencryptedConstructed); + children.addAll(ncisencryptedConstructed); } final ncmetadataetag = instance.ncmetadataetag; - final ncmetadataetagSerialized = ncmetadataetag != null - ? ncmetadataetag == true - ? 'true' - : 'false' - : null; - final ncmetadataetagConstructed = ncmetadataetagSerialized != null - ? XmlElement( - XmlName('metadata_etag', namespaces['http://nextcloud.org/ns']), [], [XmlText(ncmetadataetagSerialized)]) - : null; + final ncmetadataetagSerialized = ncmetadataetag; + final ncmetadataetagConstructed = ncmetadataetagSerialized?.map((e) => XmlElement( + XmlName('metadata_etag', namespaces['http://nextcloud.org/ns']), [], e != null ? [XmlText(e)] : [], true)); if (ncmetadataetagConstructed != null) { - children.add(ncmetadataetagConstructed); + children.addAll(ncmetadataetagConstructed); } final ncuploadtime = instance.ncuploadtime; - final ncuploadtimeSerialized = ncuploadtime != null - ? ncuploadtime == true - ? 'true' - : 'false' - : null; - final ncuploadtimeConstructed = ncuploadtimeSerialized != null - ? XmlElement(XmlName('upload_time', namespaces['http://nextcloud.org/ns']), [], [XmlText(ncuploadtimeSerialized)]) - : null; + final ncuploadtimeSerialized = ncuploadtime; + final ncuploadtimeConstructed = ncuploadtimeSerialized?.map((e) => XmlElement( + XmlName('upload_time', namespaces['http://nextcloud.org/ns']), [], e != null ? [XmlText(e)] : [], true)); if (ncuploadtimeConstructed != null) { - children.add(ncuploadtimeConstructed); + children.addAll(ncuploadtimeConstructed); } final nccreationtime = instance.nccreationtime; - final nccreationtimeSerialized = nccreationtime != null - ? nccreationtime == true - ? 'true' - : 'false' - : null; - final nccreationtimeConstructed = nccreationtimeSerialized != null - ? XmlElement( - XmlName('creation_time', namespaces['http://nextcloud.org/ns']), [], [XmlText(nccreationtimeSerialized)]) - : null; + final nccreationtimeSerialized = nccreationtime; + final nccreationtimeConstructed = nccreationtimeSerialized?.map((e) => XmlElement( + XmlName('creation_time', namespaces['http://nextcloud.org/ns']), [], e != null ? [XmlText(e)] : [], true)); if (nccreationtimeConstructed != null) { - children.add(nccreationtimeConstructed); + children.addAll(nccreationtimeConstructed); } final ncrichworkspace = instance.ncrichworkspace; - final ncrichworkspaceSerialized = ncrichworkspace != null - ? ncrichworkspace == true - ? 'true' - : 'false' - : null; - final ncrichworkspaceConstructed = ncrichworkspaceSerialized != null - ? XmlElement( - XmlName('rich-workspace', namespaces['http://nextcloud.org/ns']), [], [XmlText(ncrichworkspaceSerialized)]) - : null; + final ncrichworkspaceSerialized = ncrichworkspace; + final ncrichworkspaceConstructed = ncrichworkspaceSerialized?.map((e) => XmlElement( + XmlName('rich-workspace', namespaces['http://nextcloud.org/ns']), [], e != null ? [XmlText(e)] : [], true)); if (ncrichworkspaceConstructed != null) { - children.add(ncrichworkspaceConstructed); + children.addAll(ncrichworkspaceConstructed); } final ocssharepermissions = instance.ocssharepermissions; - final ocssharepermissionsSerialized = ocssharepermissions != null - ? ocssharepermissions == true - ? 'true' - : 'false' - : null; - final ocssharepermissionsConstructed = ocssharepermissionsSerialized != null - ? XmlElement(XmlName('share-permissions', namespaces['http://open-collaboration-services.org/ns']), [], - [XmlText(ocssharepermissionsSerialized)]) - : null; + final ocssharepermissionsSerialized = ocssharepermissions; + final ocssharepermissionsConstructed = ocssharepermissionsSerialized?.map((e) => XmlElement( + XmlName('share-permissions', namespaces['http://open-collaboration-services.org/ns']), + [], + e != null ? [XmlText(e)] : [], + true)); if (ocssharepermissionsConstructed != null) { - children.add(ocssharepermissionsConstructed); + children.addAll(ocssharepermissionsConstructed); } final ocmsharepermissions = instance.ocmsharepermissions; - final ocmsharepermissionsSerialized = ocmsharepermissions != null - ? ocmsharepermissions == true - ? 'true' - : 'false' - : null; - final ocmsharepermissionsConstructed = ocmsharepermissionsSerialized != null - ? XmlElement(XmlName('share-permissions', namespaces['http://open-cloud-mesh.org/ns']), [], - [XmlText(ocmsharepermissionsSerialized)]) - : null; + final ocmsharepermissionsSerialized = ocmsharepermissions; + final ocmsharepermissionsConstructed = ocmsharepermissionsSerialized?.map((e) => XmlElement( + XmlName('share-permissions', namespaces['http://open-cloud-mesh.org/ns']), + [], + e != null ? [XmlText(e)] : [], + true)); if (ocmsharepermissionsConstructed != null) { - children.add(ocmsharepermissionsConstructed); + children.addAll(ocmsharepermissionsConstructed); } return children; } diff --git a/packages/nextcloud/test/webdav.dart b/packages/nextcloud/test/webdav.dart index 08475131..2b6db36b 100644 --- a/packages/nextcloud/test/webdav.dart +++ b/packages/nextcloud/test/webdav.dart @@ -38,7 +38,7 @@ Future run(final DockerImage image) async { test('List directory', () async { final responses = (await client.webdav.ls( '/', - prop: WebDavPropfindProp( + prop: WebDavPropfindProp.fromBools( nchaspreview: true, davgetcontenttype: true, davgetlastmodified: true, @@ -90,7 +90,7 @@ Future run(final DockerImage image) async { final responses = (await client.webdav.ls( '/', - prop: WebDavPropfindProp( + prop: WebDavPropfindProp.fromBools( ocsize: true, ), )) @@ -121,7 +121,7 @@ Future run(final DockerImage image) async { final props = (await client.webdav.ls( '/', - prop: WebDavPropfindProp( + prop: WebDavPropfindProp.fromBools( davgetlastmodified: true, nccreationtime: true, ), @@ -210,7 +210,7 @@ Future run(final DockerImage image) async { test('Get file props', () async { final props = (await client.webdav.ls( 'Nextcloud.png', - prop: WebDavPropfindProp( + prop: WebDavPropfindProp.fromBools( davgetlastmodified: true, davgetetag: true, davgetcontenttype: true, @@ -281,7 +281,7 @@ Future run(final DockerImage image) async { final props = (await client.webdav.ls( 'test', - prop: WebDavPropfindProp( + prop: WebDavPropfindProp.fromBools( davgetcontenttype: true, davgetlastmodified: true, davresourcetype: true, @@ -315,7 +315,7 @@ Future run(final DockerImage image) async { WebDavOcFilterRules( ocfavorite: 1, ), - prop: WebDavPropfindProp( + prop: WebDavPropfindProp.fromBools( ocid: true, ocfavorite: true, ), @@ -346,7 +346,7 @@ Future run(final DockerImage image) async { final props = (await client.webdav.ls( 'test.txt', - prop: WebDavPropfindProp( + prop: WebDavPropfindProp.fromBools( ocfavorite: true, nccreationtime: true, ncuploadtime: true,