diff --git a/packages/nextcloud/bin/generate_props.dart b/packages/nextcloud/bin/generate_props.dart new file mode 100644 index 00000000..c2ae19fc --- /dev/null +++ b/packages/nextcloud/bin/generate_props.dart @@ -0,0 +1,73 @@ +import 'dart:io'; + +void main() { + final props = File('lib/src/webdav/props.csv').readAsLinesSync().map((final line) => line.split(',')); + final valueProps = []; + final findProps = []; + final variables = []; + for (final prop in props) { + final namespacePrefix = prop[0]; + final namespaceVariable = convertNamespace(namespacePrefix); + 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;', + ]); + variables.add(variable); + } + File('lib/src/webdav/props.dart').writeAsStringSync( + [ + '// ignore_for_file: public_member_api_docs', + "import 'package:nextcloud/src/webdav/webdav.dart';", + "import 'package:xml/xml.dart';", + "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), + ].join('\n'), + ); +} + +List generateClass( + final String name, + final String elementName, + final String namespace, + final List props, + final List variables, +) => + [ + '@annotation.XmlSerializable(createMixin: true)', + "@annotation.XmlRootElement(name: '$elementName', namespace: $namespace)", + 'class $name with _\$${name}XmlSerializableMixin {', + ' $name({', + ...variables.map((final variable) => ' this.$variable,'), + ' });', + ' factory $name.fromXmlElement(final XmlElement element) => _\$${name}FromXmlElement(element);', + ...props.map((final prop) => ' $prop'), + '}', + ]; + +String convertNamespace(final String namespacePrefix) { + switch (namespacePrefix) { + case 'dav': + return 'namespaceDav'; + case 'oc': + return 'namespaceOwncloud'; + case 'nc': + return 'namespaceNextcloud'; + case 'ocs': + return 'namespaceOpenCollaborationServices'; + case 'ocm': + return 'namespaceOpenCloudMesh'; + default: + throw Exception('Unknown namespace prefix "$namespacePrefix"'); + } +} diff --git a/packages/nextcloud/lib/nextcloud.dart b/packages/nextcloud/lib/nextcloud.dart index 0ac1acb6..99618c44 100644 --- a/packages/nextcloud/lib/nextcloud.dart +++ b/packages/nextcloud/lib/nextcloud.dart @@ -5,7 +5,6 @@ import 'dart:io'; import 'dart:typed_data'; import 'package:crypto/crypto.dart'; -import 'package:intl/intl.dart'; import 'package:nextcloud/nextcloud.dart'; import 'package:nextcloud/src/nextcloud.openapi.dart' as openapi; import 'package:version/version.dart'; @@ -14,6 +13,8 @@ import 'package:xml/xml.dart' as xml; export 'package:crypton/crypton.dart' show RSAKeypair, RSAPrivateKey, RSAPublicKey; export 'src/nextcloud.openapi.dart' hide NextcloudClient; +export 'src/webdav/props.dart'; +export 'src/webdav/webdav.dart'; part 'src/app_type.dart'; part 'src/client.dart'; @@ -21,4 +22,3 @@ part 'src/helpers.dart'; part 'src/version_supported.dart'; part 'src/webdav/client.dart'; part 'src/webdav/file.dart'; -part 'src/webdav/props.dart'; diff --git a/packages/nextcloud/lib/src/webdav/client.dart b/packages/nextcloud/lib/src/webdav/client.dart index 35f248fb..a48c2cee 100644 --- a/packages/nextcloud/lib/src/webdav/client.dart +++ b/packages/nextcloud/lib/src/webdav/client.dart @@ -14,18 +14,6 @@ class WebDavClient { /// Base path used on the server final String basePath; - /// XML namespaces supported by this client. - /// - /// For Nextcloud namespaces see [WebDav/Requesting properties](https://docs.nextcloud.com/server/latest/developer_manual/client_apis/WebDAV/basic.html#requesting-properties). - final Map namespaces = { - 'DAV:': 'd', - 'http://owncloud.org/ns': 'oc', - 'http://nextcloud.org/ns': 'nc', - 'http://open-collaboration-services.org/ns': 'ocs', - 'http://open-cloud-mesh.org/ns': 'ocm', - 'http://sabredav.org/ns': 's', // mostly used in error responses - }; - Future _send( final String method, final String url, @@ -65,12 +53,6 @@ class WebDavClient { return response; } - /// Registers a custom namespace for properties. - /// - /// Requires a unique [namespaceUri] and [prefix]. - void registerNamespace(final String namespaceUri, final String prefix) => - namespaces.putIfAbsent(namespaceUri, () => prefix); - String _constructPath([final String? path]) => [ rootClient.baseURL, basePath, @@ -90,25 +72,6 @@ class WebDavClient { .where((final part) => part.isNotEmpty) .join('/'); - String _buildPropsRequest(final Set props) { - final builder = xml.XmlBuilder(); - builder - ..processing('xml', 'version="1.0"') - ..element( - 'd:propfind', - nest: () { - namespaces.forEach(builder.namespace); - builder.element( - 'd:prop', - nest: () { - props.forEach(builder.element); - }, - ); - }, - ); - return builder.buildDocument().toString(); - } - /// returns the WebDAV capabilities of the server Future status() async { final response = await _send( @@ -175,18 +138,37 @@ class WebDavClient { [204], ); + Map? _generateUploadHeaders({ + required final DateTime? lastModified, + required final DateTime? created, + }) { + final headers = { + if (lastModified != null) ...{ + 'X-OC-Mtime': (lastModified.millisecondsSinceEpoch ~/ 1000).toString(), + }, + if (created != null) ...{ + 'X-OC-CTime': (created.millisecondsSinceEpoch ~/ 1000).toString(), + }, + }; + return headers.isNotEmpty ? headers : null; + } + /// upload a new file with [localData] as content to [remotePath] Future upload( final Uint8List localData, final String remotePath, { final DateTime? lastModified, + final DateTime? created, }) => _send( 'PUT', _constructPath(remotePath), [200, 201, 204], data: Stream.value(localData), - headers: lastModified != null ? {'X-OC-Mtime': (lastModified.millisecondsSinceEpoch ~/ 1000).toString()} : null, + headers: _generateUploadHeaders( + lastModified: lastModified, + created: created, + ), ); /// upload a new file with [localData] as content to [remotePath] @@ -194,13 +176,17 @@ class WebDavClient { final Stream localData, final String remotePath, { final DateTime? lastModified, + final DateTime? created, }) async => _send( 'PUT', _constructPath(remotePath), [200, 201, 204], data: localData, - headers: lastModified != null ? {'X-OC-Mtime': (lastModified.millisecondsSinceEpoch ~/ 1000).toString()} : null, + headers: _generateUploadHeaders( + lastModified: lastModified, + created: created, + ), ); /// download [remotePath] and store the response file contents to String @@ -221,100 +207,69 @@ class WebDavClient { [200], ); + Future _parseResponse(final HttpClientResponse response) async => + WebDavMultistatus.fromXmlElement(xml.XmlDocument.parse(await response.body).rootElement); + /// list the directories and files under given [remotePath]. /// - /// Optionally populates the given [props] on the returned files. - Future> ls( + /// Optionally populates the given [prop]s on the returned files. + Future ls( final String remotePath, { - final Set? props, + final WebDavPropfindProp? prop, + final int? depth, }) async { final response = await _send( 'PROPFIND', _constructPath(remotePath), [207, 301], - data: Stream.value(Uint8List.fromList(utf8.encode(_buildPropsRequest(props ?? {})))), + data: Stream.value( + Uint8List.fromList( + utf8.encode( + WebDavPropfind(prop: prop ?? WebDavPropfindProp()).toXmlElement(namespaces: namespaces).toXmlString(), + ), + ), + ), + headers: { + if (depth != null) ...{ + 'Depth': depth.toString(), + }, + }, ); if (response.statusCode == 301) { - return ls(response.headers['location']!.first); + return ls( + response.headers['location']!.first, + prop: prop, + depth: depth, + ); } - return treeFromWebDavXml( - basePath, - namespaces, - await response.body, - )..removeAt(0); + return _parseResponse(response); } - /// Runs the filter-files report with the given [propFilters] on the + /// Runs the filter-files report with the given [filterRules] on the /// [remotePath]. /// - /// Optionally populates the given [props] on the returned files. - Future> filter( + /// Optionally populates the given [prop]s on the returned files. + Future filter( final String remotePath, - final Map propFilters, { - final Set props = const {}, + final WebDavOcFilterRules filterRules, { + final WebDavPropfindProp? prop, }) async { - final builder = xml.XmlBuilder(); - builder - ..processing('xml', 'version="1.0"') - ..element( - 'oc:filter-files', - nest: () { - namespaces.forEach(builder.namespace); - builder - ..element( - 'oc:filter-rules', - nest: () { - propFilters.forEach((final key, final value) { - builder.element( - key, - nest: () { - builder.text(value); - }, - ); - }); - }, - ) - ..element( - 'd:prop', - nest: () { - props.forEach(builder.element); - }, - ); - }, - ); final response = await _send( 'REPORT', _constructPath(remotePath), [200, 207], - data: Stream.value(Uint8List.fromList(utf8.encode(builder.buildDocument().toString()))), - ); - return treeFromWebDavXml( - basePath, - namespaces, - await response.body, - ); - } - - /// Retrieves properties for the given [remotePath]. - /// - /// Populates all available properties by default, but a reduced set can be - /// specified via [props]. - Future getProps( - final String remotePath, { - final Set? props, - }) async { - final response = await _send( - 'PROPFIND', - _constructPath(remotePath), - [200, 207], - data: Stream.value(Uint8List.fromList(utf8.encode(_buildPropsRequest(props ?? {})))), - headers: {'Depth': '0'}, - ); - return fileFromWebDavXml( - basePath, - namespaces, - await response.body, + data: Stream.value( + Uint8List.fromList( + utf8.encode( + WebDavOcFilterFiles( + filterRules: filterRules, + prop: prop ?? WebDavPropfindProp(), + ).toXmlElement(namespaces: namespaces).toXmlString(), + ), + ), + ), ); + return _parseResponse(response); } /// Update (string) properties of the given [remotePath]. @@ -322,42 +277,29 @@ class WebDavClient { /// Returns true if the update was successful. Future updateProps( final String remotePath, - final Map props, + final WebDavProp prop, ) async { - final builder = xml.XmlBuilder(); - builder - ..processing('xml', 'version="1.0"') - ..element( - 'd:propertyupdate', - nest: () { - namespaces.forEach(builder.namespace); - builder.element( - 'd:set', - nest: () { - builder.element( - 'd:prop', - nest: () { - props.forEach((final key, final value) { - builder.element( - key, - nest: () { - builder.text(value); - }, - ); - }); - }, - ); - }, - ); - }, - ); final response = await _send( 'PROPPATCH', _constructPath(remotePath), [200, 207], - data: Stream.value(Uint8List.fromList(utf8.encode(builder.buildDocument().toString()))), + data: Stream.value( + Uint8List.fromList( + utf8.encode( + WebDavPropertyupdate(set: WebDavSet(prop: prop)).toXmlElement(namespaces: namespaces).toXmlString(), + ), + ), + ), ); - return checkUpdateFromWebDavXml(await response.body); + final data = await _parseResponse(response); + for (final a in data.responses) { + for (final b in a.propstats) { + if (!b.status.contains('200')) { + return false; + } + } + } + return true; } /// Move a file from [sourcePath] to [destinationPath] diff --git a/packages/nextcloud/lib/src/webdav/file.dart b/packages/nextcloud/lib/src/webdav/file.dart index 714db251..0242d65e 100644 --- a/packages/nextcloud/lib/src/webdav/file.dart +++ b/packages/nextcloud/lib/src/webdav/file.dart @@ -1,142 +1,88 @@ part of '../../nextcloud.dart'; +// ignore: public_member_api_docs +extension WebDavMultistatusFile on WebDavMultistatus { + /// Convert the [WebDavMultistatus] into a [WebDavFile] for easier handling + List toWebDavFiles(final WebDavClient client) => responses + .sublist(1) + .where((final response) => response.href != null) + .map( + (final response) => WebDavFile( + basePath: client.basePath, + response: response, + ), + ) + .toList(); +} + /// WebDavFile class class WebDavFile { /// Creates a new WebDavFile object with the given path WebDavFile({ - required this.path, - required final List props, - required final Map namespaces, - }) : _props = props, - _namespaces = namespaces; + required final String basePath, + required final WebDavResponse response, + }) : _basePath = basePath, + _response = response; - /// The path of file - final String path; + final String _basePath; + final WebDavResponse _response; - final List _props; - final Map _namespaces; + /// Get the props of the file + late final WebDavProp props = + _response.propstats.singleWhere((final propstat) => propstat.status.contains('200')).prop; - /// Gets a prop by it's qualified name. It already does namespace matching - xml.XmlElement? getProp(final String qualifiedName) { - final name = xml.XmlName.fromString(qualifiedName); - final namespaceUri = _namespaces.keys.singleWhere((final namespaceUri) => _namespaces[namespaceUri] == name.prefix); - - final matches = - _props.where((final prop) => prop.name.local == name.local && prop.namespaceUri == namespaceUri).toList(); - if (matches.isNotEmpty) { - return matches[0]; - } - return null; - } + /// The path of file + late final String path = + Uri.decodeFull(_response.href!.substring(Uri.encodeFull(_basePath).length, _response.href!.length)); /// The fileid namespaced by the instance id, globally unique - String? get id => getProp(WebDavProps.ocId.name)?.text; + late final String? id = props.ocid; /// The unique id for the file within the instance - String? get fileId => getProp(WebDavProps.ocFileId.name)?.text; - - /// Whether this is a collection resource type - bool? get isCollection { - final prop = getProp(WebDavProps.davResourceType.name); - if (prop != null) { - return prop.getElement('d:collection') != null; - } - return null; - } + late final String? fileId = props.ocfileid; /// Mime-type of the file - String? get mimeType => getProp(WebDavProps.davContentType.name)?.text; + late final String? mimeType = props.davgetcontenttype; /// ETag of the file - String? get etag => getProp(WebDavProps.davETag.name)?.text; + late final String? etag = props.davgetetag; /// File content length or folder size - int? get size { - for (final prop in [ - getProp(WebDavProps.ocSize.name), - getProp(WebDavProps.davContentLength.name), - ]) { - if (prop != null) { - return int.parse(prop.text); - } - } - return null; - } + late final int? size = props.ocsize ?? props.davgetcontentlength; /// The user id of the owner of a shared file - String? get ownerId => getProp(WebDavProps.ocOwnerId.name)?.text; + late final String? ownerId = props.ocownerid; /// The display name of the owner of a shared file - String? get ownerDisplay => getProp(WebDavProps.ocOwnerDisplayName.name)?.text; + late final String? ownerDisplay = props.ocownerdisplayname; /// Share note - String? get note => getProp(WebDavProps.ncNote.name)?.text; + late final String? note = props.ncnote; /// Last modified date of the file - DateTime? get lastModified { - final prop = getProp(WebDavProps.davLastModified.name); - if (prop != null) { - return DateFormat('E, d MMM yyyy HH:mm:ss', 'en_US').parseUtc(prop.text); + late final DateTime? lastModified = () { + if (props.davgetlastmodified != null) { + return webdavDateFormat.parseUtc(props.davgetlastmodified!); } return null; - } + }(); /// Upload date of the file - DateTime? get uploadedDate { - final prop = getProp(WebDavProps.ncUploadTime.name); - if (prop != null) { - return DateTime.fromMillisecondsSinceEpoch(int.parse(prop.text) * 1000); - } - return null; - } + late final DateTime? uploadedDate = + props.ncuploadtime != null ? DateTime.fromMillisecondsSinceEpoch(props.ncuploadtime! * 1000) : null; /// Creation date of the file as provided by uploader - DateTime? get createdDate { - final prop = getProp(WebDavProps.ncCreationTime.name); - if (prop != null) { - return DateTime.fromMillisecondsSinceEpoch(int.parse(prop.text) * 1000); - } - return null; - } - - /// List of types of shares of the file - List? get shareTypes { - final prop = getProp(WebDavProps.ocShareTypes.name); - if (prop != null) { - return prop.findElements('oc:share-type').map((final element) => int.parse(element.text)).toList(); - } - return null; - } - - /// User IDs of sharees - List? get sharees { - final prop = getProp(WebDavProps.ncShareees.name); - if (prop != null) { - return prop.findAllElements('nc:id').map((final e) => e.text).toList(); - } - return null; - } + late final DateTime? createdDate = + props.nccreationtime != null ? DateTime.fromMillisecondsSinceEpoch(props.nccreationtime! * 1000) : null; /// Whether this file is marked as favorite - bool? get favorite { - final prop = getProp(WebDavProps.ocFavorite.name); - if (prop != null) { - return prop.text == '1'; - } - return null; - } + late final bool? favorite = props.ocfavorite == null ? null : props.ocfavorite == 1; /// Whether this file has a preview image - bool? get hasPreview { - final prop = getProp(WebDavProps.ncHasPreview.name); - if (prop != null) { - return prop.text == 'true'; - } - return null; - } + late final bool? hasPreview = props.nchaspreview; /// Returns the decoded name of the file / folder without the whole path - String get name { + late final String name = () { // normalised path (remove trailing slash) final end = path.endsWith('/') ? path.length - 1 : path.length; final segments = Uri.parse(path, 0, end).pathSegments; @@ -144,101 +90,8 @@ class WebDavFile { return segments.last; } return ''; - } + }(); /// Returns if the file is a directory - bool get isDirectory => path.endsWith('/') || (isCollection ?? false); - - // coverage:ignore-start - @override - String toString() => - // ignore: lines_longer_than_80_chars - 'WebDavFile{name: $name, id: $id, isDirectory: $isDirectory, path: $path, mimeType: $mimeType, size: $size, modificationTime: $lastModified, shareTypes: $shareTypes}'; - // coverage:ignore-end -} - -/// Converts a single d:response to a [WebDavFile] -WebDavFile _fromWebDavXml( - final String basePath, - final Map namespaces, - final xml.XmlElement response, -) { - final davItemName = response.findElements('d:href').single.text; - final filePath = Uri.decodeFull(davItemName.substring(Uri.encodeFull(basePath).length, davItemName.length)); - final allProps = []; - - final propStatElements = response.findElements('d:propstat'); - for (final propStat in propStatElements) { - final status = propStat.getElement('d:status')!.text; - final props = propStat.getElement('d:prop'); - - if (!status.contains('200')) { - // Skip any props that are not returned correctly (e.g. not found) - continue; - } - for (final prop in props!.nodes.whereType()) { - if (prop.children.isNotEmpty && prop.text.isNotEmpty) { - allProps.add(prop); - } - } - } - - return WebDavFile( - path: filePath, - props: allProps, - namespaces: namespaces, - ); -} - -/// Extract a file from the webdav xml -WebDavFile fileFromWebDavXml( - final String basePath, - final Map namespaces, - final String xmlStr, -) { - final xmlDocument = xml.XmlDocument.parse(xmlStr); - return _fromWebDavXml( - basePath, - namespaces, - xmlDocument.findAllElements('d:response').single, - ); -} - -/// Extract the file tree from the webdav xml -List treeFromWebDavXml( - final String basePath, - final Map namespaces, - final String xmlStr, -) { - // Initialize a list to store the FileInfo Objects - final tree = []; - - // parse the xml using the xml.XmlDocument.parse method - final xmlDocument = xml.XmlDocument.parse(xmlStr); - - // Iterate over the response to find all folders / files and parse the information - for (final response in xmlDocument.findAllElements('d:response')) { - tree.add( - _fromWebDavXml( - basePath, - namespaces, - response, - ), - ); - } - return tree.cast(); -} - -/// Returns false if some updates have failed. -bool checkUpdateFromWebDavXml(final String xmlStr) { - final xmlDocument = xml.XmlDocument.parse(xmlStr); - final response = xmlDocument.findAllElements('d:response').single; - final propStatElements = response.findElements('d:propstat'); - for (final propStat in propStatElements) { - final status = propStat.getElement('d:status')!.text; - if (!status.contains('200')) { - return false; - } - } - return true; + late final bool isDirectory = path.endsWith('/'); } diff --git a/packages/nextcloud/lib/src/webdav/props.csv b/packages/nextcloud/lib/src/webdav/props.csv new file mode 100644 index 00000000..115c416f --- /dev/null +++ b/packages/nextcloud/lib/src/webdav/props.csv @@ -0,0 +1,26 @@ +dav,getlastmodified,String +dav,getetag,String +dav,getcontenttype,String +dav,getcontentlength,int +oc,id,String +oc,fileid,String +oc,favorite,int +oc,comments-href,String +oc,comments-count,int +oc,comments-unread,int +oc,downloadURL,String +oc,owner-id,String +oc,owner-display-name,String +oc,size,int +oc,permissions,String +nc,note,String +nc,data-fingerprint,String +nc,has-preview,bool +nc,mount-type,String +nc,is-encrypted,int +nc,metadata_etag,String +nc,upload_time,int +nc,creation_time,int +nc,rich-workspace,String +ocs,share-permissions,int +ocm,share-permissions,String diff --git a/packages/nextcloud/lib/src/webdav/props.dart b/packages/nextcloud/lib/src/webdav/props.dart index b62bc41b..3ebcf793 100644 --- a/packages/nextcloud/lib/src/webdav/props.dart +++ b/packages/nextcloud/lib/src/webdav/props.dart @@ -1,166 +1,263 @@ -part of '../../nextcloud.dart'; - -/// Mapping of all WebDAV properties. -enum WebDavProps { - /// Contains the Last-Modified header value . - davLastModified('d:getlastmodified'), - - /// Contains the ETag header value. - davETag('d:getetag'), - - /// Contains the Content-Type header value. - davContentType('d:getcontenttype'), - - /// Specifies the nature of the resource. - davResourceType('d:resourcetype'), - - /// Contains the Content-Length header. - davContentLength('d:getcontentlength'), - - /// The fileid namespaced by the instance id, globally unique - ocId('oc:id'), - - /// The unique id for the file within the instance - ocFileId('oc:fileid'), - - /// List of user specified tags. Can be modified. - ocTags('oc:tags'), - - /// Whether a resource is tagged as favorite. - /// Can be modified and reported on with list-files. - ocFavorite('oc:favorite'), - - /// List of collaborative tags. Can be reported on with list-files. - /// - /// Valid system tags are: - /// - oc:id - /// - oc:display-name - /// - oc:user-visible - /// - oc:user-assignable - /// - oc:groups - /// - oc:can-assign - ocSystemTag('oc:systemtag'), - - /// Can be reported on with list-files. - ocCircle('oc:circle'), - - /// Link to the comments for this resource. - ocCommentsHref('oc:comments-href'), - - /// Number of comments. - ocCommentsCount('oc:comments-count'), - - /// Number of unread comments. - ocCommentsUnread('oc:comments-unread'), - - /// Download URL. - ocDownloadURL('oc:downloadURL'), - - /// The user id of the owner of a shared file - ocOwnerId('oc:owner-id'), - - /// The display name of the owner of a shared file - ocOwnerDisplayName('oc:owner-display-name'), - - /// Share types of this file. - /// - /// Returns a list of share-type objects where: - /// - 0: user share - /// - 1: group share - /// - 2: usergroup share - /// - 3: public link - /// - 4: email - /// - 5: contact - /// - 6: remote (federated cloud) - /// - 7: circle - /// - 8: guest - /// - 9: remote group - /// - 10: room (talk conversation) - /// - 11: userroom - /// See also [OCS Share API](https://docs.nextcloud.com/server/19/developer_manual/client_apis/OCS/ocs-share-api.html) - ocShareTypes('oc:share-types'), - - /// List of users this file is shared with. - /// - /// Returns a list of sharee objects with: - /// - id - /// - display-name - /// - type (share type) - ncShareees('nc:sharees'), - - /// Share note. - ncNote('nc:note'), - - /// Checksums as provided during upload. - /// - /// Returns a list of checksum objects. - ocChecksums('oc:checksums'), - - /// Unlike [[davContentLength]], this property also works for folders - /// reporting the size of everything in the folder. - ocSize('oc:size'), - - /// WebDAV permissions: - /// - /// - S: shared - /// - R: shareable - /// - M: mounted - /// - G: readable - /// - D: deletable - /// - NV: updateable, renameable, moveble - /// - W: updateable (file) - /// - CK: creatable - ocPermissions('oc:permissions'), - - /// Nextcloud CRUDS permissions: - /// - /// - 1: read - /// - 2: update - /// - 4: create - /// - 8: delete - /// - 16: share - /// - 31: all - ocsSharePermissions('ocs:share-permissions'), - - /// OCM permissions: - /// - /// - share - /// - read - /// - write - ocmSharePermissions('ocm:share-permissions'), - - /// system data-fingerprint - ncDataFingerprint('nc:data-fingerprint'), - - /// Whether a preview is available. - ncHasPreview('nc:has-preview'), - - /// Mount type, e.g. global, group, user, personal, shared, shared-root, external - ncMountType('nc:mount-type'), - - /// Is this file is encrypted, 0 for false or 1 for true. - ncIsEncrypted('nc:is-encrypted'), - - // ignore: public_member_api_docs - ncMetadataETag('nc:metadata_etag'), - - /// Date this file was uploaded. - ncUploadTime('nc:upload_time'), - - /// Creation time of the file as provided during upload. - ncCreationTime('nc:creation_time'), - - // ignore: public_member_api_docs - ncRichWorkspace('nc:rich-workspace'); - - // ignore: public_member_api_docs - const WebDavProps(this.name); +// ignore_for_file: public_member_api_docs +import 'package:nextcloud/src/webdav/webdav.dart'; +import 'package:xml/xml.dart'; +import 'package:xml_annotation/xml_annotation.dart' as annotation; +part 'props.g.dart'; + +@annotation.XmlSerializable(createMixin: true) +@annotation.XmlRootElement(name: 'prop', namespace: namespaceDav) +class WebDavPropfindProp with _$WebDavPropfindPropXmlSerializableMixin { + WebDavPropfindProp({ + this.davgetlastmodified, + this.davgetetag, + this.davgetcontenttype, + this.davgetcontentlength, + this.ocid, + this.ocfileid, + this.ocfavorite, + this.occommentshref, + this.occommentscount, + this.occommentsunread, + this.ocdownloadurl, + this.ocownerid, + this.ocownerdisplayname, + this.ocsize, + this.ocpermissions, + this.ncnote, + this.ncdatafingerprint, + this.nchaspreview, + this.ncmounttype, + this.ncisencrypted, + this.ncmetadataetag, + this.ncuploadtime, + this.nccreationtime, + this.ncrichworkspace, + this.ocssharepermissions, + this.ocmsharepermissions, + }); + factory WebDavPropfindProp.fromXmlElement(final XmlElement element) => _$WebDavPropfindPropFromXmlElement(element); + @annotation.XmlElement(name: 'getlastmodified', namespace: namespaceDav, includeIfNull: false) + bool? davgetlastmodified; + @annotation.XmlElement(name: 'getetag', namespace: namespaceDav, includeIfNull: false) + bool? davgetetag; + @annotation.XmlElement(name: 'getcontenttype', namespace: namespaceDav, includeIfNull: false) + bool? davgetcontenttype; + @annotation.XmlElement(name: 'getcontentlength', namespace: namespaceDav, includeIfNull: false) + bool? davgetcontentlength; + @annotation.XmlElement(name: 'id', namespace: namespaceOwncloud, includeIfNull: false) + bool? ocid; + @annotation.XmlElement(name: 'fileid', namespace: namespaceOwncloud, includeIfNull: false) + bool? ocfileid; + @annotation.XmlElement(name: 'favorite', namespace: namespaceOwncloud, includeIfNull: false) + bool? ocfavorite; + @annotation.XmlElement(name: 'comments-href', namespace: namespaceOwncloud, includeIfNull: false) + bool? occommentshref; + @annotation.XmlElement(name: 'comments-count', namespace: namespaceOwncloud, includeIfNull: false) + bool? occommentscount; + @annotation.XmlElement(name: 'comments-unread', namespace: namespaceOwncloud, includeIfNull: false) + bool? occommentsunread; + @annotation.XmlElement(name: 'downloadURL', namespace: namespaceOwncloud, includeIfNull: false) + bool? ocdownloadurl; + @annotation.XmlElement(name: 'owner-id', namespace: namespaceOwncloud, includeIfNull: false) + bool? ocownerid; + @annotation.XmlElement(name: 'owner-display-name', namespace: namespaceOwncloud, includeIfNull: false) + bool? ocownerdisplayname; + @annotation.XmlElement(name: 'size', namespace: namespaceOwncloud, includeIfNull: false) + bool? ocsize; + @annotation.XmlElement(name: 'permissions', namespace: namespaceOwncloud, includeIfNull: false) + bool? ocpermissions; + @annotation.XmlElement(name: 'note', namespace: namespaceNextcloud, includeIfNull: false) + bool? ncnote; + @annotation.XmlElement(name: 'data-fingerprint', namespace: namespaceNextcloud, includeIfNull: false) + bool? ncdatafingerprint; + @annotation.XmlElement(name: 'has-preview', namespace: namespaceNextcloud, includeIfNull: false) + bool? nchaspreview; + @annotation.XmlElement(name: 'mount-type', namespace: namespaceNextcloud, includeIfNull: false) + bool? ncmounttype; + @annotation.XmlElement(name: 'is-encrypted', namespace: namespaceNextcloud, includeIfNull: false) + bool? ncisencrypted; + @annotation.XmlElement(name: 'metadata_etag', namespace: namespaceNextcloud, includeIfNull: false) + bool? ncmetadataetag; + @annotation.XmlElement(name: 'upload_time', namespace: namespaceNextcloud, includeIfNull: false) + bool? ncuploadtime; + @annotation.XmlElement(name: 'creation_time', namespace: namespaceNextcloud, includeIfNull: false) + bool? nccreationtime; + @annotation.XmlElement(name: 'rich-workspace', namespace: namespaceNextcloud, includeIfNull: false) + bool? ncrichworkspace; + @annotation.XmlElement(name: 'share-permissions', namespace: namespaceOpenCollaborationServices, includeIfNull: false) + bool? ocssharepermissions; + @annotation.XmlElement(name: 'share-permissions', namespace: namespaceOpenCloudMesh, includeIfNull: false) + bool? ocmsharepermissions; +} - /// Name of the prop - final String name; +@annotation.XmlSerializable(createMixin: true) +@annotation.XmlRootElement(name: 'prop', namespace: namespaceDav) +class WebDavProp with _$WebDavPropXmlSerializableMixin { + WebDavProp({ + this.davgetlastmodified, + this.davgetetag, + this.davgetcontenttype, + this.davgetcontentlength, + this.ocid, + this.ocfileid, + this.ocfavorite, + this.occommentshref, + this.occommentscount, + this.occommentsunread, + this.ocdownloadurl, + this.ocownerid, + this.ocownerdisplayname, + this.ocsize, + this.ocpermissions, + this.ncnote, + this.ncdatafingerprint, + this.nchaspreview, + this.ncmounttype, + this.ncisencrypted, + this.ncmetadataetag, + this.ncuploadtime, + this.nccreationtime, + this.ncrichworkspace, + this.ocssharepermissions, + this.ocmsharepermissions, + }); + factory WebDavProp.fromXmlElement(final XmlElement element) => _$WebDavPropFromXmlElement(element); + @annotation.XmlElement(name: 'getlastmodified', namespace: namespaceDav, includeIfNull: false) + String? davgetlastmodified; + @annotation.XmlElement(name: 'getetag', namespace: namespaceDav, includeIfNull: false) + String? davgetetag; + @annotation.XmlElement(name: 'getcontenttype', namespace: namespaceDav, includeIfNull: false) + String? davgetcontenttype; + @annotation.XmlElement(name: 'getcontentlength', namespace: namespaceDav, includeIfNull: false) + int? davgetcontentlength; + @annotation.XmlElement(name: 'id', namespace: namespaceOwncloud, includeIfNull: false) + String? ocid; + @annotation.XmlElement(name: 'fileid', namespace: namespaceOwncloud, includeIfNull: false) + String? ocfileid; + @annotation.XmlElement(name: 'favorite', namespace: namespaceOwncloud, includeIfNull: false) + int? ocfavorite; + @annotation.XmlElement(name: 'comments-href', namespace: namespaceOwncloud, includeIfNull: false) + String? occommentshref; + @annotation.XmlElement(name: 'comments-count', namespace: namespaceOwncloud, includeIfNull: false) + int? occommentscount; + @annotation.XmlElement(name: 'comments-unread', namespace: namespaceOwncloud, includeIfNull: false) + int? occommentsunread; + @annotation.XmlElement(name: 'downloadURL', namespace: namespaceOwncloud, includeIfNull: false) + String? ocdownloadurl; + @annotation.XmlElement(name: 'owner-id', namespace: namespaceOwncloud, includeIfNull: false) + String? ocownerid; + @annotation.XmlElement(name: 'owner-display-name', namespace: namespaceOwncloud, includeIfNull: false) + String? ocownerdisplayname; + @annotation.XmlElement(name: 'size', namespace: namespaceOwncloud, includeIfNull: false) + int? ocsize; + @annotation.XmlElement(name: 'permissions', namespace: namespaceOwncloud, includeIfNull: false) + String? ocpermissions; + @annotation.XmlElement(name: 'note', namespace: namespaceNextcloud, includeIfNull: false) + String? ncnote; + @annotation.XmlElement(name: 'data-fingerprint', namespace: namespaceNextcloud, includeIfNull: false) + String? ncdatafingerprint; + @annotation.XmlElement(name: 'has-preview', namespace: namespaceNextcloud, includeIfNull: false) + bool? nchaspreview; + @annotation.XmlElement(name: 'mount-type', namespace: namespaceNextcloud, includeIfNull: false) + String? ncmounttype; + @annotation.XmlElement(name: 'is-encrypted', namespace: namespaceNextcloud, includeIfNull: false) + int? ncisencrypted; + @annotation.XmlElement(name: 'metadata_etag', namespace: namespaceNextcloud, includeIfNull: false) + String? ncmetadataetag; + @annotation.XmlElement(name: 'upload_time', namespace: namespaceNextcloud, includeIfNull: false) + int? ncuploadtime; + @annotation.XmlElement(name: 'creation_time', namespace: namespaceNextcloud, includeIfNull: false) + int? nccreationtime; + @annotation.XmlElement(name: 'rich-workspace', namespace: namespaceNextcloud, includeIfNull: false) + String? ncrichworkspace; + @annotation.XmlElement(name: 'share-permissions', namespace: namespaceOpenCollaborationServices, includeIfNull: false) + int? ocssharepermissions; + @annotation.XmlElement(name: 'share-permissions', namespace: namespaceOpenCloudMesh, includeIfNull: false) + String? ocmsharepermissions; +} - // coverage:ignore-start - @override - String toString() => name; - // coverage:ignore-end +@annotation.XmlSerializable(createMixin: true) +@annotation.XmlRootElement(name: 'filter-rules', namespace: namespaceOwncloud) +class WebDavOcFilterRules with _$WebDavOcFilterRulesXmlSerializableMixin { + WebDavOcFilterRules({ + this.davgetlastmodified, + this.davgetetag, + this.davgetcontenttype, + this.davgetcontentlength, + this.ocid, + this.ocfileid, + this.ocfavorite, + this.occommentshref, + this.occommentscount, + this.occommentsunread, + this.ocdownloadurl, + this.ocownerid, + this.ocownerdisplayname, + this.ocsize, + this.ocpermissions, + this.ncnote, + this.ncdatafingerprint, + this.nchaspreview, + this.ncmounttype, + this.ncisencrypted, + this.ncmetadataetag, + this.ncuploadtime, + this.nccreationtime, + this.ncrichworkspace, + this.ocssharepermissions, + this.ocmsharepermissions, + }); + factory WebDavOcFilterRules.fromXmlElement(final XmlElement element) => _$WebDavOcFilterRulesFromXmlElement(element); + @annotation.XmlElement(name: 'getlastmodified', namespace: namespaceDav, includeIfNull: false) + String? davgetlastmodified; + @annotation.XmlElement(name: 'getetag', namespace: namespaceDav, includeIfNull: false) + String? davgetetag; + @annotation.XmlElement(name: 'getcontenttype', namespace: namespaceDav, includeIfNull: false) + String? davgetcontenttype; + @annotation.XmlElement(name: 'getcontentlength', namespace: namespaceDav, includeIfNull: false) + int? davgetcontentlength; + @annotation.XmlElement(name: 'id', namespace: namespaceOwncloud, includeIfNull: false) + String? ocid; + @annotation.XmlElement(name: 'fileid', namespace: namespaceOwncloud, includeIfNull: false) + String? ocfileid; + @annotation.XmlElement(name: 'favorite', namespace: namespaceOwncloud, includeIfNull: false) + int? ocfavorite; + @annotation.XmlElement(name: 'comments-href', namespace: namespaceOwncloud, includeIfNull: false) + String? occommentshref; + @annotation.XmlElement(name: 'comments-count', namespace: namespaceOwncloud, includeIfNull: false) + int? occommentscount; + @annotation.XmlElement(name: 'comments-unread', namespace: namespaceOwncloud, includeIfNull: false) + int? occommentsunread; + @annotation.XmlElement(name: 'downloadURL', namespace: namespaceOwncloud, includeIfNull: false) + String? ocdownloadurl; + @annotation.XmlElement(name: 'owner-id', namespace: namespaceOwncloud, includeIfNull: false) + String? ocownerid; + @annotation.XmlElement(name: 'owner-display-name', namespace: namespaceOwncloud, includeIfNull: false) + String? ocownerdisplayname; + @annotation.XmlElement(name: 'size', namespace: namespaceOwncloud, includeIfNull: false) + int? ocsize; + @annotation.XmlElement(name: 'permissions', namespace: namespaceOwncloud, includeIfNull: false) + String? ocpermissions; + @annotation.XmlElement(name: 'note', namespace: namespaceNextcloud, includeIfNull: false) + String? ncnote; + @annotation.XmlElement(name: 'data-fingerprint', namespace: namespaceNextcloud, includeIfNull: false) + String? ncdatafingerprint; + @annotation.XmlElement(name: 'has-preview', namespace: namespaceNextcloud, includeIfNull: false) + bool? nchaspreview; + @annotation.XmlElement(name: 'mount-type', namespace: namespaceNextcloud, includeIfNull: false) + String? ncmounttype; + @annotation.XmlElement(name: 'is-encrypted', namespace: namespaceNextcloud, includeIfNull: false) + int? ncisencrypted; + @annotation.XmlElement(name: 'metadata_etag', namespace: namespaceNextcloud, includeIfNull: false) + String? ncmetadataetag; + @annotation.XmlElement(name: 'upload_time', namespace: namespaceNextcloud, includeIfNull: false) + int? ncuploadtime; + @annotation.XmlElement(name: 'creation_time', namespace: namespaceNextcloud, includeIfNull: false) + int? nccreationtime; + @annotation.XmlElement(name: 'rich-workspace', namespace: namespaceNextcloud, includeIfNull: false) + String? ncrichworkspace; + @annotation.XmlElement(name: 'share-permissions', namespace: namespaceOpenCollaborationServices, includeIfNull: false) + int? ocssharepermissions; + @annotation.XmlElement(name: 'share-permissions', namespace: namespaceOpenCloudMesh, includeIfNull: false) + String? ocmsharepermissions; } diff --git a/packages/nextcloud/lib/src/webdav/props.g.dart b/packages/nextcloud/lib/src/webdav/props.g.dart new file mode 100644 index 00000000..2196bf7b --- /dev/null +++ b/packages/nextcloud/lib/src/webdav/props.g.dart @@ -0,0 +1,1915 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'props.dart'; + +// ************************************************************************** +// XmlSerializableGenerator +// ************************************************************************** + +void _$WebDavPropfindPropBuildXmlChildren(WebDavPropfindProp instance, XmlBuilder builder, + {Map namespaces = const {}}) { + final davgetlastmodified = instance.davgetlastmodified; + final davgetlastmodifiedSerialized = davgetlastmodified != null + ? davgetlastmodified == true + ? 'true' + : 'false' + : null; + if (davgetlastmodifiedSerialized != null) { + builder.element('getlastmodified', namespace: 'DAV:', nest: () { + builder.text(davgetlastmodifiedSerialized); + }); + } + final davgetetag = instance.davgetetag; + final davgetetagSerialized = davgetetag != null + ? davgetetag == true + ? 'true' + : 'false' + : null; + if (davgetetagSerialized != null) { + builder.element('getetag', namespace: 'DAV:', nest: () { + builder.text(davgetetagSerialized); + }); + } + final davgetcontenttype = instance.davgetcontenttype; + final davgetcontenttypeSerialized = davgetcontenttype != null + ? davgetcontenttype == true + ? 'true' + : 'false' + : null; + if (davgetcontenttypeSerialized != null) { + builder.element('getcontenttype', namespace: 'DAV:', nest: () { + builder.text(davgetcontenttypeSerialized); + }); + } + final davgetcontentlength = instance.davgetcontentlength; + final davgetcontentlengthSerialized = davgetcontentlength != null + ? davgetcontentlength == true + ? 'true' + : 'false' + : null; + if (davgetcontentlengthSerialized != null) { + builder.element('getcontentlength', namespace: 'DAV:', nest: () { + builder.text(davgetcontentlengthSerialized); + }); + } + final ocid = instance.ocid; + final ocidSerialized = ocid != null + ? ocid == true + ? 'true' + : 'false' + : null; + if (ocidSerialized != null) { + builder.element('id', namespace: 'http://owncloud.org/ns', nest: () { + builder.text(ocidSerialized); + }); + } + final ocfileid = instance.ocfileid; + final ocfileidSerialized = ocfileid != null + ? ocfileid == true + ? 'true' + : 'false' + : null; + if (ocfileidSerialized != null) { + builder.element('fileid', namespace: 'http://owncloud.org/ns', nest: () { + builder.text(ocfileidSerialized); + }); + } + final ocfavorite = instance.ocfavorite; + final ocfavoriteSerialized = ocfavorite != null + ? ocfavorite == true + ? 'true' + : 'false' + : null; + if (ocfavoriteSerialized != null) { + builder.element('favorite', namespace: 'http://owncloud.org/ns', nest: () { + builder.text(ocfavoriteSerialized); + }); + } + final occommentshref = instance.occommentshref; + final occommentshrefSerialized = occommentshref != null + ? occommentshref == true + ? 'true' + : 'false' + : null; + if (occommentshrefSerialized != null) { + builder.element('comments-href', namespace: 'http://owncloud.org/ns', nest: () { + builder.text(occommentshrefSerialized); + }); + } + final occommentscount = instance.occommentscount; + final occommentscountSerialized = occommentscount != null + ? occommentscount == true + ? 'true' + : 'false' + : null; + if (occommentscountSerialized != null) { + builder.element('comments-count', namespace: 'http://owncloud.org/ns', nest: () { + builder.text(occommentscountSerialized); + }); + } + final occommentsunread = instance.occommentsunread; + final occommentsunreadSerialized = occommentsunread != null + ? occommentsunread == true + ? 'true' + : 'false' + : null; + if (occommentsunreadSerialized != null) { + builder.element('comments-unread', namespace: 'http://owncloud.org/ns', nest: () { + builder.text(occommentsunreadSerialized); + }); + } + final ocdownloadurl = instance.ocdownloadurl; + final ocdownloadurlSerialized = ocdownloadurl != null + ? ocdownloadurl == true + ? 'true' + : 'false' + : null; + if (ocdownloadurlSerialized != null) { + builder.element('downloadURL', namespace: 'http://owncloud.org/ns', nest: () { + builder.text(ocdownloadurlSerialized); + }); + } + final ocownerid = instance.ocownerid; + final ocowneridSerialized = ocownerid != null + ? ocownerid == true + ? 'true' + : 'false' + : null; + if (ocowneridSerialized != null) { + builder.element('owner-id', namespace: 'http://owncloud.org/ns', nest: () { + builder.text(ocowneridSerialized); + }); + } + final ocownerdisplayname = instance.ocownerdisplayname; + final ocownerdisplaynameSerialized = ocownerdisplayname != null + ? ocownerdisplayname == true + ? 'true' + : 'false' + : null; + if (ocownerdisplaynameSerialized != null) { + builder.element('owner-display-name', namespace: 'http://owncloud.org/ns', nest: () { + builder.text(ocownerdisplaynameSerialized); + }); + } + final ocsize = instance.ocsize; + final ocsizeSerialized = ocsize != null + ? ocsize == true + ? 'true' + : 'false' + : null; + if (ocsizeSerialized != null) { + builder.element('size', namespace: 'http://owncloud.org/ns', nest: () { + builder.text(ocsizeSerialized); + }); + } + final ocpermissions = instance.ocpermissions; + final ocpermissionsSerialized = ocpermissions != null + ? ocpermissions == true + ? 'true' + : 'false' + : null; + if (ocpermissionsSerialized != null) { + builder.element('permissions', namespace: 'http://owncloud.org/ns', nest: () { + builder.text(ocpermissionsSerialized); + }); + } + final ncnote = instance.ncnote; + final ncnoteSerialized = ncnote != null + ? ncnote == true + ? 'true' + : 'false' + : null; + if (ncnoteSerialized != null) { + builder.element('note', namespace: 'http://nextcloud.org/ns', nest: () { + builder.text(ncnoteSerialized); + }); + } + final ncdatafingerprint = instance.ncdatafingerprint; + final ncdatafingerprintSerialized = ncdatafingerprint != null + ? ncdatafingerprint == true + ? 'true' + : 'false' + : null; + if (ncdatafingerprintSerialized != null) { + builder.element('data-fingerprint', namespace: 'http://nextcloud.org/ns', nest: () { + builder.text(ncdatafingerprintSerialized); + }); + } + final nchaspreview = instance.nchaspreview; + final nchaspreviewSerialized = nchaspreview != null + ? nchaspreview == true + ? 'true' + : 'false' + : null; + if (nchaspreviewSerialized != null) { + builder.element('has-preview', namespace: 'http://nextcloud.org/ns', nest: () { + builder.text(nchaspreviewSerialized); + }); + } + final ncmounttype = instance.ncmounttype; + final ncmounttypeSerialized = ncmounttype != null + ? ncmounttype == true + ? 'true' + : 'false' + : null; + if (ncmounttypeSerialized != null) { + builder.element('mount-type', namespace: 'http://nextcloud.org/ns', nest: () { + builder.text(ncmounttypeSerialized); + }); + } + final ncisencrypted = instance.ncisencrypted; + final ncisencryptedSerialized = ncisencrypted != null + ? ncisencrypted == true + ? 'true' + : 'false' + : null; + if (ncisencryptedSerialized != null) { + builder.element('is-encrypted', namespace: 'http://nextcloud.org/ns', nest: () { + builder.text(ncisencryptedSerialized); + }); + } + final ncmetadataetag = instance.ncmetadataetag; + final ncmetadataetagSerialized = ncmetadataetag != null + ? ncmetadataetag == true + ? 'true' + : 'false' + : null; + if (ncmetadataetagSerialized != null) { + builder.element('metadata_etag', namespace: 'http://nextcloud.org/ns', nest: () { + builder.text(ncmetadataetagSerialized); + }); + } + final ncuploadtime = instance.ncuploadtime; + final ncuploadtimeSerialized = ncuploadtime != null + ? ncuploadtime == true + ? 'true' + : 'false' + : null; + if (ncuploadtimeSerialized != null) { + builder.element('upload_time', namespace: 'http://nextcloud.org/ns', nest: () { + builder.text(ncuploadtimeSerialized); + }); + } + final nccreationtime = instance.nccreationtime; + final nccreationtimeSerialized = nccreationtime != null + ? nccreationtime == true + ? 'true' + : 'false' + : null; + if (nccreationtimeSerialized != null) { + builder.element('creation_time', namespace: 'http://nextcloud.org/ns', nest: () { + builder.text(nccreationtimeSerialized); + }); + } + final ncrichworkspace = instance.ncrichworkspace; + final ncrichworkspaceSerialized = ncrichworkspace != null + ? ncrichworkspace == true + ? 'true' + : 'false' + : null; + if (ncrichworkspaceSerialized != null) { + builder.element('rich-workspace', namespace: 'http://nextcloud.org/ns', nest: () { + builder.text(ncrichworkspaceSerialized); + }); + } + final ocssharepermissions = instance.ocssharepermissions; + final ocssharepermissionsSerialized = ocssharepermissions != null + ? ocssharepermissions == true + ? 'true' + : 'false' + : null; + if (ocssharepermissionsSerialized != null) { + builder.element('share-permissions', namespace: 'http://open-collaboration-services.org/ns', nest: () { + builder.text(ocssharepermissionsSerialized); + }); + } + final ocmsharepermissions = instance.ocmsharepermissions; + final ocmsharepermissionsSerialized = ocmsharepermissions != null + ? ocmsharepermissions == true + ? 'true' + : 'false' + : null; + if (ocmsharepermissionsSerialized != null) { + builder.element('share-permissions', namespace: 'http://open-cloud-mesh.org/ns', nest: () { + builder.text(ocmsharepermissionsSerialized); + }); + } +} + +void _$WebDavPropfindPropBuildXmlElement(WebDavPropfindProp instance, XmlBuilder builder, + {Map namespaces = const {}}) { + builder.element('prop', namespace: 'DAV:', namespaces: namespaces, nest: () { + instance.buildXmlChildren(builder, namespaces: namespaces); + }); +} + +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 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(); + 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, + 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); +} + +List _$WebDavPropfindPropToXmlAttributes(WebDavPropfindProp instance, + {Map namespaces = const {}}) { + final attributes = []; + return attributes; +} + +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; + if (davgetlastmodifiedConstructed != null) { + children.add(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; + if (davgetetagConstructed != null) { + children.add(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; + if (davgetcontenttypeConstructed != null) { + children.add(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; + if (davgetcontentlengthConstructed != null) { + children.add(davgetcontentlengthConstructed); + } + 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; + if (ocidConstructed != null) { + children.add(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; + if (ocfileidConstructed != null) { + children.add(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; + if (ocfavoriteConstructed != null) { + children.add(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; + if (occommentshrefConstructed != null) { + children.add(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; + if (occommentscountConstructed != null) { + children.add(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; + if (occommentsunreadConstructed != null) { + children.add(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; + if (ocdownloadurlConstructed != null) { + children.add(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; + if (ocowneridConstructed != null) { + children.add(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; + if (ocownerdisplaynameConstructed != null) { + children.add(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; + if (ocsizeConstructed != null) { + children.add(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; + if (ocpermissionsConstructed != null) { + children.add(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; + if (ncnoteConstructed != null) { + children.add(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; + if (ncdatafingerprintConstructed != null) { + children.add(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; + if (nchaspreviewConstructed != null) { + children.add(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; + if (ncmounttypeConstructed != null) { + children.add(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; + if (ncisencryptedConstructed != null) { + children.add(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; + if (ncmetadataetagConstructed != null) { + children.add(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; + if (ncuploadtimeConstructed != null) { + children.add(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; + if (nccreationtimeConstructed != null) { + children.add(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; + if (ncrichworkspaceConstructed != null) { + children.add(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; + if (ocssharepermissionsConstructed != null) { + children.add(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; + if (ocmsharepermissionsConstructed != null) { + children.add(ocmsharepermissionsConstructed); + } + return children; +} + +XmlElement _$WebDavPropfindPropToXmlElement(WebDavPropfindProp instance, {Map namespaces = const {}}) { + return XmlElement( + XmlName('prop', namespaces['DAV:']), + [...namespaces.toXmlAttributes(), ...instance.toXmlAttributes(namespaces: namespaces)], + instance.toXmlChildren(namespaces: namespaces)); +} + +mixin _$WebDavPropfindPropXmlSerializableMixin { + void buildXmlChildren(XmlBuilder builder, {Map namespaces = const {}}) => + _$WebDavPropfindPropBuildXmlChildren(this as WebDavPropfindProp, builder, namespaces: namespaces); + + void buildXmlElement(XmlBuilder builder, {Map namespaces = const {}}) => + _$WebDavPropfindPropBuildXmlElement(this as WebDavPropfindProp, builder, namespaces: namespaces); + + List toXmlAttributes({Map namespaces = const {}}) => + _$WebDavPropfindPropToXmlAttributes(this as WebDavPropfindProp, namespaces: namespaces); + + List toXmlChildren({Map namespaces = const {}}) => + _$WebDavPropfindPropToXmlChildren(this as WebDavPropfindProp, namespaces: namespaces); + + XmlElement toXmlElement({Map namespaces = const {}}) => + _$WebDavPropfindPropToXmlElement(this as WebDavPropfindProp, namespaces: namespaces); +} + +void _$WebDavPropBuildXmlChildren(WebDavProp instance, XmlBuilder builder, + {Map namespaces = const {}}) { + final davgetlastmodified = instance.davgetlastmodified; + final davgetlastmodifiedSerialized = davgetlastmodified; + if (davgetlastmodifiedSerialized != null) { + builder.element('getlastmodified', namespace: 'DAV:', nest: () { + builder.text(davgetlastmodifiedSerialized); + }); + } + final davgetetag = instance.davgetetag; + final davgetetagSerialized = davgetetag; + if (davgetetagSerialized != null) { + builder.element('getetag', namespace: 'DAV:', nest: () { + builder.text(davgetetagSerialized); + }); + } + final davgetcontenttype = instance.davgetcontenttype; + final davgetcontenttypeSerialized = davgetcontenttype; + if (davgetcontenttypeSerialized != null) { + builder.element('getcontenttype', namespace: 'DAV:', nest: () { + builder.text(davgetcontenttypeSerialized); + }); + } + final davgetcontentlength = instance.davgetcontentlength; + final davgetcontentlengthSerialized = davgetcontentlength?.toString(); + if (davgetcontentlengthSerialized != null) { + builder.element('getcontentlength', namespace: 'DAV:', nest: () { + builder.text(davgetcontentlengthSerialized); + }); + } + final ocid = instance.ocid; + final ocidSerialized = ocid; + if (ocidSerialized != null) { + builder.element('id', namespace: 'http://owncloud.org/ns', nest: () { + builder.text(ocidSerialized); + }); + } + final ocfileid = instance.ocfileid; + final ocfileidSerialized = ocfileid; + if (ocfileidSerialized != null) { + builder.element('fileid', namespace: 'http://owncloud.org/ns', nest: () { + builder.text(ocfileidSerialized); + }); + } + final ocfavorite = instance.ocfavorite; + final ocfavoriteSerialized = ocfavorite?.toString(); + if (ocfavoriteSerialized != null) { + builder.element('favorite', namespace: 'http://owncloud.org/ns', nest: () { + builder.text(ocfavoriteSerialized); + }); + } + final occommentshref = instance.occommentshref; + final occommentshrefSerialized = occommentshref; + if (occommentshrefSerialized != null) { + builder.element('comments-href', namespace: 'http://owncloud.org/ns', nest: () { + builder.text(occommentshrefSerialized); + }); + } + final occommentscount = instance.occommentscount; + final occommentscountSerialized = occommentscount?.toString(); + if (occommentscountSerialized != null) { + builder.element('comments-count', namespace: 'http://owncloud.org/ns', nest: () { + builder.text(occommentscountSerialized); + }); + } + final occommentsunread = instance.occommentsunread; + final occommentsunreadSerialized = occommentsunread?.toString(); + if (occommentsunreadSerialized != null) { + builder.element('comments-unread', namespace: 'http://owncloud.org/ns', nest: () { + builder.text(occommentsunreadSerialized); + }); + } + final ocdownloadurl = instance.ocdownloadurl; + final ocdownloadurlSerialized = ocdownloadurl; + if (ocdownloadurlSerialized != null) { + builder.element('downloadURL', namespace: 'http://owncloud.org/ns', nest: () { + builder.text(ocdownloadurlSerialized); + }); + } + final ocownerid = instance.ocownerid; + final ocowneridSerialized = ocownerid; + if (ocowneridSerialized != null) { + builder.element('owner-id', namespace: 'http://owncloud.org/ns', nest: () { + builder.text(ocowneridSerialized); + }); + } + final ocownerdisplayname = instance.ocownerdisplayname; + final ocownerdisplaynameSerialized = ocownerdisplayname; + if (ocownerdisplaynameSerialized != null) { + builder.element('owner-display-name', namespace: 'http://owncloud.org/ns', nest: () { + builder.text(ocownerdisplaynameSerialized); + }); + } + final ocsize = instance.ocsize; + final ocsizeSerialized = ocsize?.toString(); + if (ocsizeSerialized != null) { + builder.element('size', namespace: 'http://owncloud.org/ns', nest: () { + builder.text(ocsizeSerialized); + }); + } + final ocpermissions = instance.ocpermissions; + final ocpermissionsSerialized = ocpermissions; + if (ocpermissionsSerialized != null) { + builder.element('permissions', namespace: 'http://owncloud.org/ns', nest: () { + builder.text(ocpermissionsSerialized); + }); + } + final ncnote = instance.ncnote; + final ncnoteSerialized = ncnote; + if (ncnoteSerialized != null) { + builder.element('note', namespace: 'http://nextcloud.org/ns', nest: () { + builder.text(ncnoteSerialized); + }); + } + final ncdatafingerprint = instance.ncdatafingerprint; + final ncdatafingerprintSerialized = ncdatafingerprint; + if (ncdatafingerprintSerialized != null) { + builder.element('data-fingerprint', namespace: 'http://nextcloud.org/ns', nest: () { + builder.text(ncdatafingerprintSerialized); + }); + } + final nchaspreview = instance.nchaspreview; + final nchaspreviewSerialized = nchaspreview != null + ? nchaspreview == true + ? 'true' + : 'false' + : null; + if (nchaspreviewSerialized != null) { + builder.element('has-preview', namespace: 'http://nextcloud.org/ns', nest: () { + builder.text(nchaspreviewSerialized); + }); + } + final ncmounttype = instance.ncmounttype; + final ncmounttypeSerialized = ncmounttype; + if (ncmounttypeSerialized != null) { + builder.element('mount-type', namespace: 'http://nextcloud.org/ns', nest: () { + builder.text(ncmounttypeSerialized); + }); + } + final ncisencrypted = instance.ncisencrypted; + final ncisencryptedSerialized = ncisencrypted?.toString(); + if (ncisencryptedSerialized != null) { + builder.element('is-encrypted', namespace: 'http://nextcloud.org/ns', nest: () { + builder.text(ncisencryptedSerialized); + }); + } + final ncmetadataetag = instance.ncmetadataetag; + final ncmetadataetagSerialized = ncmetadataetag; + if (ncmetadataetagSerialized != null) { + builder.element('metadata_etag', namespace: 'http://nextcloud.org/ns', nest: () { + builder.text(ncmetadataetagSerialized); + }); + } + final ncuploadtime = instance.ncuploadtime; + final ncuploadtimeSerialized = ncuploadtime?.toString(); + if (ncuploadtimeSerialized != null) { + builder.element('upload_time', namespace: 'http://nextcloud.org/ns', nest: () { + builder.text(ncuploadtimeSerialized); + }); + } + final nccreationtime = instance.nccreationtime; + final nccreationtimeSerialized = nccreationtime?.toString(); + if (nccreationtimeSerialized != null) { + builder.element('creation_time', namespace: 'http://nextcloud.org/ns', nest: () { + builder.text(nccreationtimeSerialized); + }); + } + final ncrichworkspace = instance.ncrichworkspace; + final ncrichworkspaceSerialized = ncrichworkspace; + if (ncrichworkspaceSerialized != null) { + builder.element('rich-workspace', namespace: 'http://nextcloud.org/ns', nest: () { + builder.text(ncrichworkspaceSerialized); + }); + } + final ocssharepermissions = instance.ocssharepermissions; + final ocssharepermissionsSerialized = ocssharepermissions?.toString(); + if (ocssharepermissionsSerialized != null) { + builder.element('share-permissions', namespace: 'http://open-collaboration-services.org/ns', nest: () { + builder.text(ocssharepermissionsSerialized); + }); + } + final ocmsharepermissions = instance.ocmsharepermissions; + final ocmsharepermissionsSerialized = ocmsharepermissions; + if (ocmsharepermissionsSerialized != null) { + builder.element('share-permissions', namespace: 'http://open-cloud-mesh.org/ns', nest: () { + builder.text(ocmsharepermissionsSerialized); + }); + } +} + +void _$WebDavPropBuildXmlElement(WebDavProp instance, XmlBuilder builder, {Map namespaces = const {}}) { + builder.element('prop', namespace: 'DAV:', namespaces: namespaces, nest: () { + instance.buildXmlChildren(builder, namespaces: namespaces); + }); +} + +WebDavProp _$WebDavPropFromXmlElement(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 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(); + return WebDavProp( + davgetlastmodified: davgetlastmodified, + davgetetag: davgetetag, + davgetcontenttype: davgetcontenttype, + davgetcontentlength: davgetcontentlength != null ? int.parse(davgetcontentlength) : null, + ocid: ocid, + ocfileid: ocfileid, + ocfavorite: ocfavorite != null ? int.parse(ocfavorite) : null, + occommentshref: occommentshref, + occommentscount: occommentscount != null ? int.parse(occommentscount) : null, + occommentsunread: occommentsunread != null ? int.parse(occommentsunread) : null, + ocdownloadurl: ocdownloadurl, + ocownerid: ocownerid, + ocownerdisplayname: ocownerdisplayname, + ocsize: ocsize != null ? int.parse(ocsize) : null, + ocpermissions: ocpermissions, + ncnote: ncnote, + ncdatafingerprint: ncdatafingerprint, + nchaspreview: nchaspreview != null + ? nchaspreview == 'true' || nchaspreview == '1' + ? true + : nchaspreview == 'false' || nchaspreview == '0' + ? false + : throw FormatException('Invalid bool format', nchaspreview) + : null, + ncmounttype: ncmounttype, + ncisencrypted: ncisencrypted != null ? int.parse(ncisencrypted) : null, + ncmetadataetag: ncmetadataetag, + ncuploadtime: ncuploadtime != null ? int.parse(ncuploadtime) : null, + nccreationtime: nccreationtime != null ? int.parse(nccreationtime) : null, + ncrichworkspace: ncrichworkspace, + ocssharepermissions: ocssharepermissions != null ? int.parse(ocssharepermissions) : null, + ocmsharepermissions: ocmsharepermissions); +} + +List _$WebDavPropToXmlAttributes(WebDavProp instance, {Map namespaces = const {}}) { + final attributes = []; + return attributes; +} + +List _$WebDavPropToXmlChildren(WebDavProp instance, {Map namespaces = const {}}) { + final children = []; + final davgetlastmodified = instance.davgetlastmodified; + final davgetlastmodifiedSerialized = davgetlastmodified; + final davgetlastmodifiedConstructed = davgetlastmodifiedSerialized != null + ? XmlElement(XmlName('getlastmodified', namespaces['DAV:']), [], [XmlText(davgetlastmodifiedSerialized)]) + : null; + if (davgetlastmodifiedConstructed != null) { + children.add(davgetlastmodifiedConstructed); + } + final davgetetag = instance.davgetetag; + final davgetetagSerialized = davgetetag; + final davgetetagConstructed = davgetetagSerialized != null + ? XmlElement(XmlName('getetag', namespaces['DAV:']), [], [XmlText(davgetetagSerialized)]) + : null; + if (davgetetagConstructed != null) { + children.add(davgetetagConstructed); + } + final davgetcontenttype = instance.davgetcontenttype; + final davgetcontenttypeSerialized = davgetcontenttype; + final davgetcontenttypeConstructed = davgetcontenttypeSerialized != null + ? XmlElement(XmlName('getcontenttype', namespaces['DAV:']), [], [XmlText(davgetcontenttypeSerialized)]) + : null; + if (davgetcontenttypeConstructed != null) { + children.add(davgetcontenttypeConstructed); + } + final davgetcontentlength = instance.davgetcontentlength; + final davgetcontentlengthSerialized = davgetcontentlength?.toString(); + final davgetcontentlengthConstructed = davgetcontentlengthSerialized != null + ? XmlElement(XmlName('getcontentlength', namespaces['DAV:']), [], [XmlText(davgetcontentlengthSerialized)]) + : null; + if (davgetcontentlengthConstructed != null) { + children.add(davgetcontentlengthConstructed); + } + final ocid = instance.ocid; + final ocidSerialized = ocid; + final ocidConstructed = ocidSerialized != null + ? XmlElement(XmlName('id', namespaces['http://owncloud.org/ns']), [], [XmlText(ocidSerialized)]) + : null; + if (ocidConstructed != null) { + children.add(ocidConstructed); + } + final ocfileid = instance.ocfileid; + final ocfileidSerialized = ocfileid; + final ocfileidConstructed = ocfileidSerialized != null + ? XmlElement(XmlName('fileid', namespaces['http://owncloud.org/ns']), [], [XmlText(ocfileidSerialized)]) + : null; + if (ocfileidConstructed != null) { + children.add(ocfileidConstructed); + } + final ocfavorite = instance.ocfavorite; + final ocfavoriteSerialized = ocfavorite?.toString(); + final ocfavoriteConstructed = ocfavoriteSerialized != null + ? XmlElement(XmlName('favorite', namespaces['http://owncloud.org/ns']), [], [XmlText(ocfavoriteSerialized)]) + : null; + if (ocfavoriteConstructed != null) { + children.add(ocfavoriteConstructed); + } + final occommentshref = instance.occommentshref; + final occommentshrefSerialized = occommentshref; + final occommentshrefConstructed = occommentshrefSerialized != null + ? XmlElement( + XmlName('comments-href', namespaces['http://owncloud.org/ns']), [], [XmlText(occommentshrefSerialized)]) + : null; + if (occommentshrefConstructed != null) { + children.add(occommentshrefConstructed); + } + final occommentscount = instance.occommentscount; + final occommentscountSerialized = occommentscount?.toString(); + final occommentscountConstructed = occommentscountSerialized != null + ? XmlElement( + XmlName('comments-count', namespaces['http://owncloud.org/ns']), [], [XmlText(occommentscountSerialized)]) + : null; + if (occommentscountConstructed != null) { + children.add(occommentscountConstructed); + } + final occommentsunread = instance.occommentsunread; + final occommentsunreadSerialized = occommentsunread?.toString(); + final occommentsunreadConstructed = occommentsunreadSerialized != null + ? XmlElement( + XmlName('comments-unread', namespaces['http://owncloud.org/ns']), [], [XmlText(occommentsunreadSerialized)]) + : null; + if (occommentsunreadConstructed != null) { + children.add(occommentsunreadConstructed); + } + final ocdownloadurl = instance.ocdownloadurl; + final ocdownloadurlSerialized = ocdownloadurl; + final ocdownloadurlConstructed = ocdownloadurlSerialized != null + ? XmlElement(XmlName('downloadURL', namespaces['http://owncloud.org/ns']), [], [XmlText(ocdownloadurlSerialized)]) + : null; + if (ocdownloadurlConstructed != null) { + children.add(ocdownloadurlConstructed); + } + final ocownerid = instance.ocownerid; + final ocowneridSerialized = ocownerid; + final ocowneridConstructed = ocowneridSerialized != null + ? XmlElement(XmlName('owner-id', namespaces['http://owncloud.org/ns']), [], [XmlText(ocowneridSerialized)]) + : null; + if (ocowneridConstructed != null) { + children.add(ocowneridConstructed); + } + final ocownerdisplayname = instance.ocownerdisplayname; + final ocownerdisplaynameSerialized = ocownerdisplayname; + final ocownerdisplaynameConstructed = ocownerdisplaynameSerialized != null + ? XmlElement(XmlName('owner-display-name', namespaces['http://owncloud.org/ns']), [], + [XmlText(ocownerdisplaynameSerialized)]) + : null; + if (ocownerdisplaynameConstructed != null) { + children.add(ocownerdisplaynameConstructed); + } + final ocsize = instance.ocsize; + final ocsizeSerialized = ocsize?.toString(); + final ocsizeConstructed = ocsizeSerialized != null + ? XmlElement(XmlName('size', namespaces['http://owncloud.org/ns']), [], [XmlText(ocsizeSerialized)]) + : null; + if (ocsizeConstructed != null) { + children.add(ocsizeConstructed); + } + final ocpermissions = instance.ocpermissions; + final ocpermissionsSerialized = ocpermissions; + final ocpermissionsConstructed = ocpermissionsSerialized != null + ? XmlElement(XmlName('permissions', namespaces['http://owncloud.org/ns']), [], [XmlText(ocpermissionsSerialized)]) + : null; + if (ocpermissionsConstructed != null) { + children.add(ocpermissionsConstructed); + } + final ncnote = instance.ncnote; + final ncnoteSerialized = ncnote; + final ncnoteConstructed = ncnoteSerialized != null + ? XmlElement(XmlName('note', namespaces['http://nextcloud.org/ns']), [], [XmlText(ncnoteSerialized)]) + : null; + if (ncnoteConstructed != null) { + children.add(ncnoteConstructed); + } + final ncdatafingerprint = instance.ncdatafingerprint; + final ncdatafingerprintSerialized = ncdatafingerprint; + final ncdatafingerprintConstructed = ncdatafingerprintSerialized != null + ? XmlElement(XmlName('data-fingerprint', namespaces['http://nextcloud.org/ns']), [], + [XmlText(ncdatafingerprintSerialized)]) + : null; + if (ncdatafingerprintConstructed != null) { + children.add(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; + if (nchaspreviewConstructed != null) { + children.add(nchaspreviewConstructed); + } + final ncmounttype = instance.ncmounttype; + final ncmounttypeSerialized = ncmounttype; + final ncmounttypeConstructed = ncmounttypeSerialized != null + ? XmlElement(XmlName('mount-type', namespaces['http://nextcloud.org/ns']), [], [XmlText(ncmounttypeSerialized)]) + : null; + if (ncmounttypeConstructed != null) { + children.add(ncmounttypeConstructed); + } + final ncisencrypted = instance.ncisencrypted; + final ncisencryptedSerialized = ncisencrypted?.toString(); + final ncisencryptedConstructed = ncisencryptedSerialized != null + ? XmlElement( + XmlName('is-encrypted', namespaces['http://nextcloud.org/ns']), [], [XmlText(ncisencryptedSerialized)]) + : null; + if (ncisencryptedConstructed != null) { + children.add(ncisencryptedConstructed); + } + final ncmetadataetag = instance.ncmetadataetag; + final ncmetadataetagSerialized = ncmetadataetag; + final ncmetadataetagConstructed = ncmetadataetagSerialized != null + ? XmlElement( + XmlName('metadata_etag', namespaces['http://nextcloud.org/ns']), [], [XmlText(ncmetadataetagSerialized)]) + : null; + if (ncmetadataetagConstructed != null) { + children.add(ncmetadataetagConstructed); + } + final ncuploadtime = instance.ncuploadtime; + final ncuploadtimeSerialized = ncuploadtime?.toString(); + final ncuploadtimeConstructed = ncuploadtimeSerialized != null + ? XmlElement(XmlName('upload_time', namespaces['http://nextcloud.org/ns']), [], [XmlText(ncuploadtimeSerialized)]) + : null; + if (ncuploadtimeConstructed != null) { + children.add(ncuploadtimeConstructed); + } + final nccreationtime = instance.nccreationtime; + final nccreationtimeSerialized = nccreationtime?.toString(); + final nccreationtimeConstructed = nccreationtimeSerialized != null + ? XmlElement( + XmlName('creation_time', namespaces['http://nextcloud.org/ns']), [], [XmlText(nccreationtimeSerialized)]) + : null; + if (nccreationtimeConstructed != null) { + children.add(nccreationtimeConstructed); + } + final ncrichworkspace = instance.ncrichworkspace; + final ncrichworkspaceSerialized = ncrichworkspace; + final ncrichworkspaceConstructed = ncrichworkspaceSerialized != null + ? XmlElement( + XmlName('rich-workspace', namespaces['http://nextcloud.org/ns']), [], [XmlText(ncrichworkspaceSerialized)]) + : null; + if (ncrichworkspaceConstructed != null) { + children.add(ncrichworkspaceConstructed); + } + final ocssharepermissions = instance.ocssharepermissions; + final ocssharepermissionsSerialized = ocssharepermissions?.toString(); + final ocssharepermissionsConstructed = ocssharepermissionsSerialized != null + ? XmlElement(XmlName('share-permissions', namespaces['http://open-collaboration-services.org/ns']), [], + [XmlText(ocssharepermissionsSerialized)]) + : null; + if (ocssharepermissionsConstructed != null) { + children.add(ocssharepermissionsConstructed); + } + final ocmsharepermissions = instance.ocmsharepermissions; + final ocmsharepermissionsSerialized = ocmsharepermissions; + final ocmsharepermissionsConstructed = ocmsharepermissionsSerialized != null + ? XmlElement(XmlName('share-permissions', namespaces['http://open-cloud-mesh.org/ns']), [], + [XmlText(ocmsharepermissionsSerialized)]) + : null; + if (ocmsharepermissionsConstructed != null) { + children.add(ocmsharepermissionsConstructed); + } + return children; +} + +XmlElement _$WebDavPropToXmlElement(WebDavProp instance, {Map namespaces = const {}}) { + return XmlElement( + XmlName('prop', namespaces['DAV:']), + [...namespaces.toXmlAttributes(), ...instance.toXmlAttributes(namespaces: namespaces)], + instance.toXmlChildren(namespaces: namespaces)); +} + +mixin _$WebDavPropXmlSerializableMixin { + void buildXmlChildren(XmlBuilder builder, {Map namespaces = const {}}) => + _$WebDavPropBuildXmlChildren(this as WebDavProp, builder, namespaces: namespaces); + + void buildXmlElement(XmlBuilder builder, {Map namespaces = const {}}) => + _$WebDavPropBuildXmlElement(this as WebDavProp, builder, namespaces: namespaces); + + List toXmlAttributes({Map namespaces = const {}}) => + _$WebDavPropToXmlAttributes(this as WebDavProp, namespaces: namespaces); + + List toXmlChildren({Map namespaces = const {}}) => + _$WebDavPropToXmlChildren(this as WebDavProp, namespaces: namespaces); + + XmlElement toXmlElement({Map namespaces = const {}}) => + _$WebDavPropToXmlElement(this as WebDavProp, namespaces: namespaces); +} + +void _$WebDavOcFilterRulesBuildXmlChildren(WebDavOcFilterRules instance, XmlBuilder builder, + {Map namespaces = const {}}) { + final davgetlastmodified = instance.davgetlastmodified; + final davgetlastmodifiedSerialized = davgetlastmodified; + if (davgetlastmodifiedSerialized != null) { + builder.element('getlastmodified', namespace: 'DAV:', nest: () { + builder.text(davgetlastmodifiedSerialized); + }); + } + final davgetetag = instance.davgetetag; + final davgetetagSerialized = davgetetag; + if (davgetetagSerialized != null) { + builder.element('getetag', namespace: 'DAV:', nest: () { + builder.text(davgetetagSerialized); + }); + } + final davgetcontenttype = instance.davgetcontenttype; + final davgetcontenttypeSerialized = davgetcontenttype; + if (davgetcontenttypeSerialized != null) { + builder.element('getcontenttype', namespace: 'DAV:', nest: () { + builder.text(davgetcontenttypeSerialized); + }); + } + final davgetcontentlength = instance.davgetcontentlength; + final davgetcontentlengthSerialized = davgetcontentlength?.toString(); + if (davgetcontentlengthSerialized != null) { + builder.element('getcontentlength', namespace: 'DAV:', nest: () { + builder.text(davgetcontentlengthSerialized); + }); + } + final ocid = instance.ocid; + final ocidSerialized = ocid; + if (ocidSerialized != null) { + builder.element('id', namespace: 'http://owncloud.org/ns', nest: () { + builder.text(ocidSerialized); + }); + } + final ocfileid = instance.ocfileid; + final ocfileidSerialized = ocfileid; + if (ocfileidSerialized != null) { + builder.element('fileid', namespace: 'http://owncloud.org/ns', nest: () { + builder.text(ocfileidSerialized); + }); + } + final ocfavorite = instance.ocfavorite; + final ocfavoriteSerialized = ocfavorite?.toString(); + if (ocfavoriteSerialized != null) { + builder.element('favorite', namespace: 'http://owncloud.org/ns', nest: () { + builder.text(ocfavoriteSerialized); + }); + } + final occommentshref = instance.occommentshref; + final occommentshrefSerialized = occommentshref; + if (occommentshrefSerialized != null) { + builder.element('comments-href', namespace: 'http://owncloud.org/ns', nest: () { + builder.text(occommentshrefSerialized); + }); + } + final occommentscount = instance.occommentscount; + final occommentscountSerialized = occommentscount?.toString(); + if (occommentscountSerialized != null) { + builder.element('comments-count', namespace: 'http://owncloud.org/ns', nest: () { + builder.text(occommentscountSerialized); + }); + } + final occommentsunread = instance.occommentsunread; + final occommentsunreadSerialized = occommentsunread?.toString(); + if (occommentsunreadSerialized != null) { + builder.element('comments-unread', namespace: 'http://owncloud.org/ns', nest: () { + builder.text(occommentsunreadSerialized); + }); + } + final ocdownloadurl = instance.ocdownloadurl; + final ocdownloadurlSerialized = ocdownloadurl; + if (ocdownloadurlSerialized != null) { + builder.element('downloadURL', namespace: 'http://owncloud.org/ns', nest: () { + builder.text(ocdownloadurlSerialized); + }); + } + final ocownerid = instance.ocownerid; + final ocowneridSerialized = ocownerid; + if (ocowneridSerialized != null) { + builder.element('owner-id', namespace: 'http://owncloud.org/ns', nest: () { + builder.text(ocowneridSerialized); + }); + } + final ocownerdisplayname = instance.ocownerdisplayname; + final ocownerdisplaynameSerialized = ocownerdisplayname; + if (ocownerdisplaynameSerialized != null) { + builder.element('owner-display-name', namespace: 'http://owncloud.org/ns', nest: () { + builder.text(ocownerdisplaynameSerialized); + }); + } + final ocsize = instance.ocsize; + final ocsizeSerialized = ocsize?.toString(); + if (ocsizeSerialized != null) { + builder.element('size', namespace: 'http://owncloud.org/ns', nest: () { + builder.text(ocsizeSerialized); + }); + } + final ocpermissions = instance.ocpermissions; + final ocpermissionsSerialized = ocpermissions; + if (ocpermissionsSerialized != null) { + builder.element('permissions', namespace: 'http://owncloud.org/ns', nest: () { + builder.text(ocpermissionsSerialized); + }); + } + final ncnote = instance.ncnote; + final ncnoteSerialized = ncnote; + if (ncnoteSerialized != null) { + builder.element('note', namespace: 'http://nextcloud.org/ns', nest: () { + builder.text(ncnoteSerialized); + }); + } + final ncdatafingerprint = instance.ncdatafingerprint; + final ncdatafingerprintSerialized = ncdatafingerprint; + if (ncdatafingerprintSerialized != null) { + builder.element('data-fingerprint', namespace: 'http://nextcloud.org/ns', nest: () { + builder.text(ncdatafingerprintSerialized); + }); + } + final nchaspreview = instance.nchaspreview; + final nchaspreviewSerialized = nchaspreview != null + ? nchaspreview == true + ? 'true' + : 'false' + : null; + if (nchaspreviewSerialized != null) { + builder.element('has-preview', namespace: 'http://nextcloud.org/ns', nest: () { + builder.text(nchaspreviewSerialized); + }); + } + final ncmounttype = instance.ncmounttype; + final ncmounttypeSerialized = ncmounttype; + if (ncmounttypeSerialized != null) { + builder.element('mount-type', namespace: 'http://nextcloud.org/ns', nest: () { + builder.text(ncmounttypeSerialized); + }); + } + final ncisencrypted = instance.ncisencrypted; + final ncisencryptedSerialized = ncisencrypted?.toString(); + if (ncisencryptedSerialized != null) { + builder.element('is-encrypted', namespace: 'http://nextcloud.org/ns', nest: () { + builder.text(ncisencryptedSerialized); + }); + } + final ncmetadataetag = instance.ncmetadataetag; + final ncmetadataetagSerialized = ncmetadataetag; + if (ncmetadataetagSerialized != null) { + builder.element('metadata_etag', namespace: 'http://nextcloud.org/ns', nest: () { + builder.text(ncmetadataetagSerialized); + }); + } + final ncuploadtime = instance.ncuploadtime; + final ncuploadtimeSerialized = ncuploadtime?.toString(); + if (ncuploadtimeSerialized != null) { + builder.element('upload_time', namespace: 'http://nextcloud.org/ns', nest: () { + builder.text(ncuploadtimeSerialized); + }); + } + final nccreationtime = instance.nccreationtime; + final nccreationtimeSerialized = nccreationtime?.toString(); + if (nccreationtimeSerialized != null) { + builder.element('creation_time', namespace: 'http://nextcloud.org/ns', nest: () { + builder.text(nccreationtimeSerialized); + }); + } + final ncrichworkspace = instance.ncrichworkspace; + final ncrichworkspaceSerialized = ncrichworkspace; + if (ncrichworkspaceSerialized != null) { + builder.element('rich-workspace', namespace: 'http://nextcloud.org/ns', nest: () { + builder.text(ncrichworkspaceSerialized); + }); + } + final ocssharepermissions = instance.ocssharepermissions; + final ocssharepermissionsSerialized = ocssharepermissions?.toString(); + if (ocssharepermissionsSerialized != null) { + builder.element('share-permissions', namespace: 'http://open-collaboration-services.org/ns', nest: () { + builder.text(ocssharepermissionsSerialized); + }); + } + final ocmsharepermissions = instance.ocmsharepermissions; + final ocmsharepermissionsSerialized = ocmsharepermissions; + if (ocmsharepermissionsSerialized != null) { + builder.element('share-permissions', namespace: 'http://open-cloud-mesh.org/ns', nest: () { + builder.text(ocmsharepermissionsSerialized); + }); + } +} + +void _$WebDavOcFilterRulesBuildXmlElement(WebDavOcFilterRules instance, XmlBuilder builder, + {Map namespaces = const {}}) { + builder.element('filter-rules', namespace: 'http://owncloud.org/ns', namespaces: namespaces, nest: () { + instance.buildXmlChildren(builder, namespaces: namespaces); + }); +} + +WebDavOcFilterRules _$WebDavOcFilterRulesFromXmlElement(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 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(); + return WebDavOcFilterRules( + davgetlastmodified: davgetlastmodified, + davgetetag: davgetetag, + davgetcontenttype: davgetcontenttype, + davgetcontentlength: davgetcontentlength != null ? int.parse(davgetcontentlength) : null, + ocid: ocid, + ocfileid: ocfileid, + ocfavorite: ocfavorite != null ? int.parse(ocfavorite) : null, + occommentshref: occommentshref, + occommentscount: occommentscount != null ? int.parse(occommentscount) : null, + occommentsunread: occommentsunread != null ? int.parse(occommentsunread) : null, + ocdownloadurl: ocdownloadurl, + ocownerid: ocownerid, + ocownerdisplayname: ocownerdisplayname, + ocsize: ocsize != null ? int.parse(ocsize) : null, + ocpermissions: ocpermissions, + ncnote: ncnote, + ncdatafingerprint: ncdatafingerprint, + nchaspreview: nchaspreview != null + ? nchaspreview == 'true' || nchaspreview == '1' + ? true + : nchaspreview == 'false' || nchaspreview == '0' + ? false + : throw FormatException('Invalid bool format', nchaspreview) + : null, + ncmounttype: ncmounttype, + ncisencrypted: ncisencrypted != null ? int.parse(ncisencrypted) : null, + ncmetadataetag: ncmetadataetag, + ncuploadtime: ncuploadtime != null ? int.parse(ncuploadtime) : null, + nccreationtime: nccreationtime != null ? int.parse(nccreationtime) : null, + ncrichworkspace: ncrichworkspace, + ocssharepermissions: ocssharepermissions != null ? int.parse(ocssharepermissions) : null, + ocmsharepermissions: ocmsharepermissions); +} + +List _$WebDavOcFilterRulesToXmlAttributes(WebDavOcFilterRules instance, + {Map namespaces = const {}}) { + final attributes = []; + return attributes; +} + +List _$WebDavOcFilterRulesToXmlChildren(WebDavOcFilterRules instance, + {Map namespaces = const {}}) { + final children = []; + final davgetlastmodified = instance.davgetlastmodified; + final davgetlastmodifiedSerialized = davgetlastmodified; + final davgetlastmodifiedConstructed = davgetlastmodifiedSerialized != null + ? XmlElement(XmlName('getlastmodified', namespaces['DAV:']), [], [XmlText(davgetlastmodifiedSerialized)]) + : null; + if (davgetlastmodifiedConstructed != null) { + children.add(davgetlastmodifiedConstructed); + } + final davgetetag = instance.davgetetag; + final davgetetagSerialized = davgetetag; + final davgetetagConstructed = davgetetagSerialized != null + ? XmlElement(XmlName('getetag', namespaces['DAV:']), [], [XmlText(davgetetagSerialized)]) + : null; + if (davgetetagConstructed != null) { + children.add(davgetetagConstructed); + } + final davgetcontenttype = instance.davgetcontenttype; + final davgetcontenttypeSerialized = davgetcontenttype; + final davgetcontenttypeConstructed = davgetcontenttypeSerialized != null + ? XmlElement(XmlName('getcontenttype', namespaces['DAV:']), [], [XmlText(davgetcontenttypeSerialized)]) + : null; + if (davgetcontenttypeConstructed != null) { + children.add(davgetcontenttypeConstructed); + } + final davgetcontentlength = instance.davgetcontentlength; + final davgetcontentlengthSerialized = davgetcontentlength?.toString(); + final davgetcontentlengthConstructed = davgetcontentlengthSerialized != null + ? XmlElement(XmlName('getcontentlength', namespaces['DAV:']), [], [XmlText(davgetcontentlengthSerialized)]) + : null; + if (davgetcontentlengthConstructed != null) { + children.add(davgetcontentlengthConstructed); + } + final ocid = instance.ocid; + final ocidSerialized = ocid; + final ocidConstructed = ocidSerialized != null + ? XmlElement(XmlName('id', namespaces['http://owncloud.org/ns']), [], [XmlText(ocidSerialized)]) + : null; + if (ocidConstructed != null) { + children.add(ocidConstructed); + } + final ocfileid = instance.ocfileid; + final ocfileidSerialized = ocfileid; + final ocfileidConstructed = ocfileidSerialized != null + ? XmlElement(XmlName('fileid', namespaces['http://owncloud.org/ns']), [], [XmlText(ocfileidSerialized)]) + : null; + if (ocfileidConstructed != null) { + children.add(ocfileidConstructed); + } + final ocfavorite = instance.ocfavorite; + final ocfavoriteSerialized = ocfavorite?.toString(); + final ocfavoriteConstructed = ocfavoriteSerialized != null + ? XmlElement(XmlName('favorite', namespaces['http://owncloud.org/ns']), [], [XmlText(ocfavoriteSerialized)]) + : null; + if (ocfavoriteConstructed != null) { + children.add(ocfavoriteConstructed); + } + final occommentshref = instance.occommentshref; + final occommentshrefSerialized = occommentshref; + final occommentshrefConstructed = occommentshrefSerialized != null + ? XmlElement( + XmlName('comments-href', namespaces['http://owncloud.org/ns']), [], [XmlText(occommentshrefSerialized)]) + : null; + if (occommentshrefConstructed != null) { + children.add(occommentshrefConstructed); + } + final occommentscount = instance.occommentscount; + final occommentscountSerialized = occommentscount?.toString(); + final occommentscountConstructed = occommentscountSerialized != null + ? XmlElement( + XmlName('comments-count', namespaces['http://owncloud.org/ns']), [], [XmlText(occommentscountSerialized)]) + : null; + if (occommentscountConstructed != null) { + children.add(occommentscountConstructed); + } + final occommentsunread = instance.occommentsunread; + final occommentsunreadSerialized = occommentsunread?.toString(); + final occommentsunreadConstructed = occommentsunreadSerialized != null + ? XmlElement( + XmlName('comments-unread', namespaces['http://owncloud.org/ns']), [], [XmlText(occommentsunreadSerialized)]) + : null; + if (occommentsunreadConstructed != null) { + children.add(occommentsunreadConstructed); + } + final ocdownloadurl = instance.ocdownloadurl; + final ocdownloadurlSerialized = ocdownloadurl; + final ocdownloadurlConstructed = ocdownloadurlSerialized != null + ? XmlElement(XmlName('downloadURL', namespaces['http://owncloud.org/ns']), [], [XmlText(ocdownloadurlSerialized)]) + : null; + if (ocdownloadurlConstructed != null) { + children.add(ocdownloadurlConstructed); + } + final ocownerid = instance.ocownerid; + final ocowneridSerialized = ocownerid; + final ocowneridConstructed = ocowneridSerialized != null + ? XmlElement(XmlName('owner-id', namespaces['http://owncloud.org/ns']), [], [XmlText(ocowneridSerialized)]) + : null; + if (ocowneridConstructed != null) { + children.add(ocowneridConstructed); + } + final ocownerdisplayname = instance.ocownerdisplayname; + final ocownerdisplaynameSerialized = ocownerdisplayname; + final ocownerdisplaynameConstructed = ocownerdisplaynameSerialized != null + ? XmlElement(XmlName('owner-display-name', namespaces['http://owncloud.org/ns']), [], + [XmlText(ocownerdisplaynameSerialized)]) + : null; + if (ocownerdisplaynameConstructed != null) { + children.add(ocownerdisplaynameConstructed); + } + final ocsize = instance.ocsize; + final ocsizeSerialized = ocsize?.toString(); + final ocsizeConstructed = ocsizeSerialized != null + ? XmlElement(XmlName('size', namespaces['http://owncloud.org/ns']), [], [XmlText(ocsizeSerialized)]) + : null; + if (ocsizeConstructed != null) { + children.add(ocsizeConstructed); + } + final ocpermissions = instance.ocpermissions; + final ocpermissionsSerialized = ocpermissions; + final ocpermissionsConstructed = ocpermissionsSerialized != null + ? XmlElement(XmlName('permissions', namespaces['http://owncloud.org/ns']), [], [XmlText(ocpermissionsSerialized)]) + : null; + if (ocpermissionsConstructed != null) { + children.add(ocpermissionsConstructed); + } + final ncnote = instance.ncnote; + final ncnoteSerialized = ncnote; + final ncnoteConstructed = ncnoteSerialized != null + ? XmlElement(XmlName('note', namespaces['http://nextcloud.org/ns']), [], [XmlText(ncnoteSerialized)]) + : null; + if (ncnoteConstructed != null) { + children.add(ncnoteConstructed); + } + final ncdatafingerprint = instance.ncdatafingerprint; + final ncdatafingerprintSerialized = ncdatafingerprint; + final ncdatafingerprintConstructed = ncdatafingerprintSerialized != null + ? XmlElement(XmlName('data-fingerprint', namespaces['http://nextcloud.org/ns']), [], + [XmlText(ncdatafingerprintSerialized)]) + : null; + if (ncdatafingerprintConstructed != null) { + children.add(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; + if (nchaspreviewConstructed != null) { + children.add(nchaspreviewConstructed); + } + final ncmounttype = instance.ncmounttype; + final ncmounttypeSerialized = ncmounttype; + final ncmounttypeConstructed = ncmounttypeSerialized != null + ? XmlElement(XmlName('mount-type', namespaces['http://nextcloud.org/ns']), [], [XmlText(ncmounttypeSerialized)]) + : null; + if (ncmounttypeConstructed != null) { + children.add(ncmounttypeConstructed); + } + final ncisencrypted = instance.ncisencrypted; + final ncisencryptedSerialized = ncisencrypted?.toString(); + final ncisencryptedConstructed = ncisencryptedSerialized != null + ? XmlElement( + XmlName('is-encrypted', namespaces['http://nextcloud.org/ns']), [], [XmlText(ncisencryptedSerialized)]) + : null; + if (ncisencryptedConstructed != null) { + children.add(ncisencryptedConstructed); + } + final ncmetadataetag = instance.ncmetadataetag; + final ncmetadataetagSerialized = ncmetadataetag; + final ncmetadataetagConstructed = ncmetadataetagSerialized != null + ? XmlElement( + XmlName('metadata_etag', namespaces['http://nextcloud.org/ns']), [], [XmlText(ncmetadataetagSerialized)]) + : null; + if (ncmetadataetagConstructed != null) { + children.add(ncmetadataetagConstructed); + } + final ncuploadtime = instance.ncuploadtime; + final ncuploadtimeSerialized = ncuploadtime?.toString(); + final ncuploadtimeConstructed = ncuploadtimeSerialized != null + ? XmlElement(XmlName('upload_time', namespaces['http://nextcloud.org/ns']), [], [XmlText(ncuploadtimeSerialized)]) + : null; + if (ncuploadtimeConstructed != null) { + children.add(ncuploadtimeConstructed); + } + final nccreationtime = instance.nccreationtime; + final nccreationtimeSerialized = nccreationtime?.toString(); + final nccreationtimeConstructed = nccreationtimeSerialized != null + ? XmlElement( + XmlName('creation_time', namespaces['http://nextcloud.org/ns']), [], [XmlText(nccreationtimeSerialized)]) + : null; + if (nccreationtimeConstructed != null) { + children.add(nccreationtimeConstructed); + } + final ncrichworkspace = instance.ncrichworkspace; + final ncrichworkspaceSerialized = ncrichworkspace; + final ncrichworkspaceConstructed = ncrichworkspaceSerialized != null + ? XmlElement( + XmlName('rich-workspace', namespaces['http://nextcloud.org/ns']), [], [XmlText(ncrichworkspaceSerialized)]) + : null; + if (ncrichworkspaceConstructed != null) { + children.add(ncrichworkspaceConstructed); + } + final ocssharepermissions = instance.ocssharepermissions; + final ocssharepermissionsSerialized = ocssharepermissions?.toString(); + final ocssharepermissionsConstructed = ocssharepermissionsSerialized != null + ? XmlElement(XmlName('share-permissions', namespaces['http://open-collaboration-services.org/ns']), [], + [XmlText(ocssharepermissionsSerialized)]) + : null; + if (ocssharepermissionsConstructed != null) { + children.add(ocssharepermissionsConstructed); + } + final ocmsharepermissions = instance.ocmsharepermissions; + final ocmsharepermissionsSerialized = ocmsharepermissions; + final ocmsharepermissionsConstructed = ocmsharepermissionsSerialized != null + ? XmlElement(XmlName('share-permissions', namespaces['http://open-cloud-mesh.org/ns']), [], + [XmlText(ocmsharepermissionsSerialized)]) + : null; + if (ocmsharepermissionsConstructed != null) { + children.add(ocmsharepermissionsConstructed); + } + return children; +} + +XmlElement _$WebDavOcFilterRulesToXmlElement(WebDavOcFilterRules instance, + {Map namespaces = const {}}) { + return XmlElement( + XmlName('filter-rules', namespaces['http://owncloud.org/ns']), + [...namespaces.toXmlAttributes(), ...instance.toXmlAttributes(namespaces: namespaces)], + instance.toXmlChildren(namespaces: namespaces)); +} + +mixin _$WebDavOcFilterRulesXmlSerializableMixin { + void buildXmlChildren(XmlBuilder builder, {Map namespaces = const {}}) => + _$WebDavOcFilterRulesBuildXmlChildren(this as WebDavOcFilterRules, builder, namespaces: namespaces); + + void buildXmlElement(XmlBuilder builder, {Map namespaces = const {}}) => + _$WebDavOcFilterRulesBuildXmlElement(this as WebDavOcFilterRules, builder, namespaces: namespaces); + + List toXmlAttributes({Map namespaces = const {}}) => + _$WebDavOcFilterRulesToXmlAttributes(this as WebDavOcFilterRules, namespaces: namespaces); + + List toXmlChildren({Map namespaces = const {}}) => + _$WebDavOcFilterRulesToXmlChildren(this as WebDavOcFilterRules, namespaces: namespaces); + + XmlElement toXmlElement({Map namespaces = const {}}) => + _$WebDavOcFilterRulesToXmlElement(this as WebDavOcFilterRules, namespaces: namespaces); +} diff --git a/packages/nextcloud/lib/src/webdav/webdav.dart b/packages/nextcloud/lib/src/webdav/webdav.dart new file mode 100644 index 00000000..924eed0d --- /dev/null +++ b/packages/nextcloud/lib/src/webdav/webdav.dart @@ -0,0 +1,137 @@ +// ignore_for_file: public_member_api_docs + +import 'package:intl/intl.dart'; +import 'package:nextcloud/src/webdav/props.dart'; +import 'package:xml/xml.dart'; +import 'package:xml_annotation/xml_annotation.dart' as annotation; + +part 'webdav.g.dart'; + +/// Format used in WebDAV +final webdavDateFormat = DateFormat('E, d MMM yyyy HH:mm:ss', 'en_US'); + +const namespaceDav = 'DAV:'; +const namespaceOwncloud = 'http://owncloud.org/ns'; +const namespaceNextcloud = 'http://nextcloud.org/ns'; +const namespaceOpenCollaborationServices = 'http://open-collaboration-services.org/ns'; +const namespaceOpenCloudMesh = 'http://open-cloud-mesh.org/ns'; + +final Map namespaces = { + namespaceDav: 'd', + namespaceOwncloud: 'oc', + namespaceNextcloud: 'nc', + namespaceOpenCollaborationServices: 'ocs', + namespaceOpenCloudMesh: 'ocm', +}; + +@annotation.XmlSerializable(createMixin: true) +@annotation.XmlRootElement(name: 'multistatus', namespace: namespaceDav) +class WebDavMultistatus with _$WebDavMultistatusXmlSerializableMixin { + WebDavMultistatus({ + required this.responses, + }); + + factory WebDavMultistatus.fromXmlElement(final XmlElement element) => _$WebDavMultistatusFromXmlElement(element); + + @annotation.XmlElement(name: 'response', namespace: namespaceDav) + final List responses; +} + +@annotation.XmlSerializable(createMixin: true) +@annotation.XmlRootElement(name: 'response', namespace: namespaceDav) +class WebDavResponse with _$WebDavResponseXmlSerializableMixin { + WebDavResponse({ + required this.href, + required this.propstats, + }); + + factory WebDavResponse.fromXmlElement(final XmlElement element) => _$WebDavResponseFromXmlElement(element); + + @annotation.XmlElement(name: 'href', namespace: namespaceDav) + final String? href; + + @annotation.XmlElement(name: 'propstat', namespace: namespaceDav) + final List propstats; +} + +@annotation.XmlSerializable(createMixin: true) +@annotation.XmlRootElement(name: 'propstat', namespace: namespaceDav) +class WebDavPropstat with _$WebDavPropstatXmlSerializableMixin { + WebDavPropstat({ + required this.status, + required this.prop, + }); + + factory WebDavPropstat.fromXmlElement(final XmlElement element) => _$WebDavPropstatFromXmlElement(element); + + @annotation.XmlElement(name: 'status', namespace: namespaceDav) + final String status; + + @annotation.XmlElement(name: 'prop', namespace: namespaceDav) + final WebDavProp prop; +} + +@annotation.XmlSerializable(createMixin: true) +@annotation.XmlRootElement(name: 'propertyupdate', namespace: namespaceDav) +class WebDavPropertyupdate with _$WebDavPropertyupdateXmlSerializableMixin { + WebDavPropertyupdate({ + required this.set, + }); + + factory WebDavPropertyupdate.fromXmlElement(final XmlElement element) => + _$WebDavPropertyupdateFromXmlElement(element); + + @annotation.XmlElement(name: 'set', namespace: namespaceDav) + final WebDavSet set; +} + +@annotation.XmlSerializable(createMixin: true) +@annotation.XmlRootElement(name: 'propertyupdate', namespace: namespaceDav) +class WebDavSet with _$WebDavSetXmlSerializableMixin { + WebDavSet({ + required this.prop, + }); + + factory WebDavSet.fromXmlElement(final XmlElement element) => _$WebDavSetFromXmlElement(element); + + @annotation.XmlElement(name: 'prop', namespace: namespaceDav) + final WebDavProp prop; +} + +@annotation.XmlSerializable(createMixin: true) +@annotation.XmlRootElement(name: 'propfind', namespace: namespaceDav) +class WebDavPropfind with _$WebDavPropfindXmlSerializableMixin { + WebDavPropfind({ + required this.prop, + }); + + factory WebDavPropfind.fromXmlElement(final XmlElement element) => _$WebDavPropfindFromXmlElement(element); + + @annotation.XmlElement(name: 'prop', namespace: namespaceDav) + final WebDavPropfindProp prop; +} + +@annotation.XmlSerializable(createMixin: true) +@annotation.XmlRootElement(name: 'filter-files', namespace: namespaceOwncloud) +class WebDavOcFilterFiles with _$WebDavOcFilterFilesXmlSerializableMixin { + WebDavOcFilterFiles({ + required this.filterRules, + required this.prop, + }); + + factory WebDavOcFilterFiles.fromXmlElement(final XmlElement element) => _$WebDavOcFilterFilesFromXmlElement(element); + + @annotation.XmlElement(name: 'filter-rules', namespace: namespaceOwncloud) + final WebDavOcFilterRules filterRules; + + @annotation.XmlElement(name: 'prop', namespace: namespaceDav) + final WebDavPropfindProp prop; +} + +// TODO: d:resourcetype +// TODO: oc:checksum +// TODO: oc:tags +// TODO: oc:systemtag +// TODO: oc:circle +// TODO: oc:share-types +// TODO: nc:sharees diff --git a/packages/nextcloud/lib/src/webdav/webdav.g.dart b/packages/nextcloud/lib/src/webdav/webdav.g.dart new file mode 100644 index 00000000..46b12110 --- /dev/null +++ b/packages/nextcloud/lib/src/webdav/webdav.g.dart @@ -0,0 +1,477 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'webdav.dart'; + +// ************************************************************************** +// XmlSerializableGenerator +// ************************************************************************** + +void _$WebDavMultistatusBuildXmlChildren(WebDavMultistatus instance, XmlBuilder builder, + {Map namespaces = const {}}) { + final responses = instance.responses; + final responsesSerialized = responses; + for (final value in responsesSerialized) { + builder.element('response', namespace: 'DAV:', nest: () { + value.buildXmlChildren(builder, namespaces: namespaces); + }); + } +} + +void _$WebDavMultistatusBuildXmlElement(WebDavMultistatus instance, XmlBuilder builder, + {Map namespaces = const {}}) { + builder.element('multistatus', namespace: 'DAV:', namespaces: namespaces, nest: () { + instance.buildXmlChildren(builder, namespaces: namespaces); + }); +} + +WebDavMultistatus _$WebDavMultistatusFromXmlElement(XmlElement element) { + final responses = element.getElements('response', namespace: 'DAV:')!; + return WebDavMultistatus(responses: responses.map((e) => WebDavResponse.fromXmlElement(e)).toList()); +} + +List _$WebDavMultistatusToXmlAttributes(WebDavMultistatus instance, + {Map namespaces = const {}}) { + final attributes = []; + return attributes; +} + +List _$WebDavMultistatusToXmlChildren(WebDavMultistatus instance, + {Map namespaces = const {}}) { + final children = []; + final responses = instance.responses; + final responsesSerialized = responses; + final responsesConstructed = responsesSerialized.map((e) => XmlElement(XmlName('response', namespaces['DAV:']), + e.toXmlAttributes(namespaces: namespaces), e.toXmlChildren(namespaces: namespaces))); + children.addAll(responsesConstructed); + return children; +} + +XmlElement _$WebDavMultistatusToXmlElement(WebDavMultistatus instance, {Map namespaces = const {}}) { + return XmlElement( + XmlName('multistatus', namespaces['DAV:']), + [...namespaces.toXmlAttributes(), ...instance.toXmlAttributes(namespaces: namespaces)], + instance.toXmlChildren(namespaces: namespaces)); +} + +mixin _$WebDavMultistatusXmlSerializableMixin { + void buildXmlChildren(XmlBuilder builder, {Map namespaces = const {}}) => + _$WebDavMultistatusBuildXmlChildren(this as WebDavMultistatus, builder, namespaces: namespaces); + + void buildXmlElement(XmlBuilder builder, {Map namespaces = const {}}) => + _$WebDavMultistatusBuildXmlElement(this as WebDavMultistatus, builder, namespaces: namespaces); + + List toXmlAttributes({Map namespaces = const {}}) => + _$WebDavMultistatusToXmlAttributes(this as WebDavMultistatus, namespaces: namespaces); + + List toXmlChildren({Map namespaces = const {}}) => + _$WebDavMultistatusToXmlChildren(this as WebDavMultistatus, namespaces: namespaces); + + XmlElement toXmlElement({Map namespaces = const {}}) => + _$WebDavMultistatusToXmlElement(this as WebDavMultistatus, namespaces: namespaces); +} + +void _$WebDavResponseBuildXmlChildren(WebDavResponse instance, XmlBuilder builder, + {Map namespaces = const {}}) { + final href = instance.href; + final hrefSerialized = href; + builder.element('href', namespace: 'DAV:', nest: () { + if (hrefSerialized != null) { + builder.text(hrefSerialized); + } + }); + final propstats = instance.propstats; + final propstatsSerialized = propstats; + for (final value in propstatsSerialized) { + builder.element('propstat', namespace: 'DAV:', nest: () { + value.buildXmlChildren(builder, namespaces: namespaces); + }); + } +} + +void _$WebDavResponseBuildXmlElement(WebDavResponse instance, XmlBuilder builder, + {Map namespaces = const {}}) { + builder.element('response', namespace: 'DAV:', namespaces: namespaces, nest: () { + instance.buildXmlChildren(builder, namespaces: namespaces); + }); +} + +WebDavResponse _$WebDavResponseFromXmlElement(XmlElement element) { + final href = element.getElement('href', namespace: 'DAV:')?.getText(); + final propstats = element.getElements('propstat', namespace: 'DAV:')!; + return WebDavResponse(href: href, propstats: propstats.map((e) => WebDavPropstat.fromXmlElement(e)).toList()); +} + +List _$WebDavResponseToXmlAttributes(WebDavResponse instance, + {Map namespaces = const {}}) { + final attributes = []; + return attributes; +} + +List _$WebDavResponseToXmlChildren(WebDavResponse instance, {Map namespaces = const {}}) { + final children = []; + final href = instance.href; + final hrefSerialized = href; + final hrefConstructed = + XmlElement(XmlName('href', namespaces['DAV:']), [], hrefSerialized != null ? [XmlText(hrefSerialized)] : []); + children.add(hrefConstructed); + final propstats = instance.propstats; + final propstatsSerialized = propstats; + final propstatsConstructed = propstatsSerialized.map((e) => XmlElement(XmlName('propstat', namespaces['DAV:']), + e.toXmlAttributes(namespaces: namespaces), e.toXmlChildren(namespaces: namespaces))); + children.addAll(propstatsConstructed); + return children; +} + +XmlElement _$WebDavResponseToXmlElement(WebDavResponse instance, {Map namespaces = const {}}) { + return XmlElement( + XmlName('response', namespaces['DAV:']), + [...namespaces.toXmlAttributes(), ...instance.toXmlAttributes(namespaces: namespaces)], + instance.toXmlChildren(namespaces: namespaces)); +} + +mixin _$WebDavResponseXmlSerializableMixin { + void buildXmlChildren(XmlBuilder builder, {Map namespaces = const {}}) => + _$WebDavResponseBuildXmlChildren(this as WebDavResponse, builder, namespaces: namespaces); + + void buildXmlElement(XmlBuilder builder, {Map namespaces = const {}}) => + _$WebDavResponseBuildXmlElement(this as WebDavResponse, builder, namespaces: namespaces); + + List toXmlAttributes({Map namespaces = const {}}) => + _$WebDavResponseToXmlAttributes(this as WebDavResponse, namespaces: namespaces); + + List toXmlChildren({Map namespaces = const {}}) => + _$WebDavResponseToXmlChildren(this as WebDavResponse, namespaces: namespaces); + + XmlElement toXmlElement({Map namespaces = const {}}) => + _$WebDavResponseToXmlElement(this as WebDavResponse, namespaces: namespaces); +} + +void _$WebDavPropstatBuildXmlChildren(WebDavPropstat instance, XmlBuilder builder, + {Map namespaces = const {}}) { + final status = instance.status; + final statusSerialized = status; + builder.element('status', namespace: 'DAV:', nest: () { + builder.text(statusSerialized); + }); + final prop = instance.prop; + final propSerialized = prop; + builder.element('prop', namespace: 'DAV:', nest: () { + propSerialized.buildXmlChildren(builder, namespaces: namespaces); + }); +} + +void _$WebDavPropstatBuildXmlElement(WebDavPropstat instance, XmlBuilder builder, + {Map namespaces = const {}}) { + builder.element('propstat', namespace: 'DAV:', namespaces: namespaces, nest: () { + instance.buildXmlChildren(builder, namespaces: namespaces); + }); +} + +WebDavPropstat _$WebDavPropstatFromXmlElement(XmlElement element) { + final status = element.getElement('status', namespace: 'DAV:')!.getText()!; + final prop = element.getElement('prop', namespace: 'DAV:')!; + return WebDavPropstat(status: status, prop: WebDavProp.fromXmlElement(prop)); +} + +List _$WebDavPropstatToXmlAttributes(WebDavPropstat instance, + {Map namespaces = const {}}) { + final attributes = []; + return attributes; +} + +List _$WebDavPropstatToXmlChildren(WebDavPropstat instance, {Map namespaces = const {}}) { + final children = []; + final status = instance.status; + final statusSerialized = status; + final statusConstructed = XmlElement(XmlName('status', namespaces['DAV:']), [], [XmlText(statusSerialized)]); + children.add(statusConstructed); + final prop = instance.prop; + final propSerialized = prop; + final propConstructed = XmlElement(XmlName('prop', namespaces['DAV:']), + propSerialized.toXmlAttributes(namespaces: namespaces), propSerialized.toXmlChildren(namespaces: namespaces)); + children.add(propConstructed); + return children; +} + +XmlElement _$WebDavPropstatToXmlElement(WebDavPropstat instance, {Map namespaces = const {}}) { + return XmlElement( + XmlName('propstat', namespaces['DAV:']), + [...namespaces.toXmlAttributes(), ...instance.toXmlAttributes(namespaces: namespaces)], + instance.toXmlChildren(namespaces: namespaces)); +} + +mixin _$WebDavPropstatXmlSerializableMixin { + void buildXmlChildren(XmlBuilder builder, {Map namespaces = const {}}) => + _$WebDavPropstatBuildXmlChildren(this as WebDavPropstat, builder, namespaces: namespaces); + + void buildXmlElement(XmlBuilder builder, {Map namespaces = const {}}) => + _$WebDavPropstatBuildXmlElement(this as WebDavPropstat, builder, namespaces: namespaces); + + List toXmlAttributes({Map namespaces = const {}}) => + _$WebDavPropstatToXmlAttributes(this as WebDavPropstat, namespaces: namespaces); + + List toXmlChildren({Map namespaces = const {}}) => + _$WebDavPropstatToXmlChildren(this as WebDavPropstat, namespaces: namespaces); + + XmlElement toXmlElement({Map namespaces = const {}}) => + _$WebDavPropstatToXmlElement(this as WebDavPropstat, namespaces: namespaces); +} + +void _$WebDavPropertyupdateBuildXmlChildren(WebDavPropertyupdate instance, XmlBuilder builder, + {Map namespaces = const {}}) { + final set = instance.set; + final setSerialized = set; + builder.element('set', namespace: 'DAV:', nest: () { + setSerialized.buildXmlChildren(builder, namespaces: namespaces); + }); +} + +void _$WebDavPropertyupdateBuildXmlElement(WebDavPropertyupdate instance, XmlBuilder builder, + {Map namespaces = const {}}) { + builder.element('propertyupdate', namespace: 'DAV:', namespaces: namespaces, nest: () { + instance.buildXmlChildren(builder, namespaces: namespaces); + }); +} + +WebDavPropertyupdate _$WebDavPropertyupdateFromXmlElement(XmlElement element) { + final set = element.getElement('set', namespace: 'DAV:')!; + return WebDavPropertyupdate(set: WebDavSet.fromXmlElement(set)); +} + +List _$WebDavPropertyupdateToXmlAttributes(WebDavPropertyupdate instance, + {Map namespaces = const {}}) { + final attributes = []; + return attributes; +} + +List _$WebDavPropertyupdateToXmlChildren(WebDavPropertyupdate instance, + {Map namespaces = const {}}) { + final children = []; + final set = instance.set; + final setSerialized = set; + final setConstructed = XmlElement(XmlName('set', namespaces['DAV:']), + setSerialized.toXmlAttributes(namespaces: namespaces), setSerialized.toXmlChildren(namespaces: namespaces)); + children.add(setConstructed); + return children; +} + +XmlElement _$WebDavPropertyupdateToXmlElement(WebDavPropertyupdate instance, + {Map namespaces = const {}}) { + return XmlElement( + XmlName('propertyupdate', namespaces['DAV:']), + [...namespaces.toXmlAttributes(), ...instance.toXmlAttributes(namespaces: namespaces)], + instance.toXmlChildren(namespaces: namespaces)); +} + +mixin _$WebDavPropertyupdateXmlSerializableMixin { + void buildXmlChildren(XmlBuilder builder, {Map namespaces = const {}}) => + _$WebDavPropertyupdateBuildXmlChildren(this as WebDavPropertyupdate, builder, namespaces: namespaces); + + void buildXmlElement(XmlBuilder builder, {Map namespaces = const {}}) => + _$WebDavPropertyupdateBuildXmlElement(this as WebDavPropertyupdate, builder, namespaces: namespaces); + + List toXmlAttributes({Map namespaces = const {}}) => + _$WebDavPropertyupdateToXmlAttributes(this as WebDavPropertyupdate, namespaces: namespaces); + + List toXmlChildren({Map namespaces = const {}}) => + _$WebDavPropertyupdateToXmlChildren(this as WebDavPropertyupdate, namespaces: namespaces); + + XmlElement toXmlElement({Map namespaces = const {}}) => + _$WebDavPropertyupdateToXmlElement(this as WebDavPropertyupdate, namespaces: namespaces); +} + +void _$WebDavSetBuildXmlChildren(WebDavSet instance, XmlBuilder builder, {Map namespaces = const {}}) { + final prop = instance.prop; + final propSerialized = prop; + builder.element('prop', namespace: 'DAV:', nest: () { + propSerialized.buildXmlChildren(builder, namespaces: namespaces); + }); +} + +void _$WebDavSetBuildXmlElement(WebDavSet instance, XmlBuilder builder, {Map namespaces = const {}}) { + builder.element('propertyupdate', namespace: 'DAV:', namespaces: namespaces, nest: () { + instance.buildXmlChildren(builder, namespaces: namespaces); + }); +} + +WebDavSet _$WebDavSetFromXmlElement(XmlElement element) { + final prop = element.getElement('prop', namespace: 'DAV:')!; + return WebDavSet(prop: WebDavProp.fromXmlElement(prop)); +} + +List _$WebDavSetToXmlAttributes(WebDavSet instance, {Map namespaces = const {}}) { + final attributes = []; + return attributes; +} + +List _$WebDavSetToXmlChildren(WebDavSet instance, {Map namespaces = const {}}) { + final children = []; + final prop = instance.prop; + final propSerialized = prop; + final propConstructed = XmlElement(XmlName('prop', namespaces['DAV:']), + propSerialized.toXmlAttributes(namespaces: namespaces), propSerialized.toXmlChildren(namespaces: namespaces)); + children.add(propConstructed); + return children; +} + +XmlElement _$WebDavSetToXmlElement(WebDavSet instance, {Map namespaces = const {}}) { + return XmlElement( + XmlName('propertyupdate', namespaces['DAV:']), + [...namespaces.toXmlAttributes(), ...instance.toXmlAttributes(namespaces: namespaces)], + instance.toXmlChildren(namespaces: namespaces)); +} + +mixin _$WebDavSetXmlSerializableMixin { + void buildXmlChildren(XmlBuilder builder, {Map namespaces = const {}}) => + _$WebDavSetBuildXmlChildren(this as WebDavSet, builder, namespaces: namespaces); + + void buildXmlElement(XmlBuilder builder, {Map namespaces = const {}}) => + _$WebDavSetBuildXmlElement(this as WebDavSet, builder, namespaces: namespaces); + + List toXmlAttributes({Map namespaces = const {}}) => + _$WebDavSetToXmlAttributes(this as WebDavSet, namespaces: namespaces); + + List toXmlChildren({Map namespaces = const {}}) => + _$WebDavSetToXmlChildren(this as WebDavSet, namespaces: namespaces); + + XmlElement toXmlElement({Map namespaces = const {}}) => + _$WebDavSetToXmlElement(this as WebDavSet, namespaces: namespaces); +} + +void _$WebDavPropfindBuildXmlChildren(WebDavPropfind instance, XmlBuilder builder, + {Map namespaces = const {}}) { + final prop = instance.prop; + final propSerialized = prop; + builder.element('prop', namespace: 'DAV:', nest: () { + propSerialized.buildXmlChildren(builder, namespaces: namespaces); + }); +} + +void _$WebDavPropfindBuildXmlElement(WebDavPropfind instance, XmlBuilder builder, + {Map namespaces = const {}}) { + builder.element('propfind', namespace: 'DAV:', namespaces: namespaces, nest: () { + instance.buildXmlChildren(builder, namespaces: namespaces); + }); +} + +WebDavPropfind _$WebDavPropfindFromXmlElement(XmlElement element) { + final prop = element.getElement('prop', namespace: 'DAV:')!; + return WebDavPropfind(prop: WebDavPropfindProp.fromXmlElement(prop)); +} + +List _$WebDavPropfindToXmlAttributes(WebDavPropfind instance, + {Map namespaces = const {}}) { + final attributes = []; + return attributes; +} + +List _$WebDavPropfindToXmlChildren(WebDavPropfind instance, {Map namespaces = const {}}) { + final children = []; + final prop = instance.prop; + final propSerialized = prop; + final propConstructed = XmlElement(XmlName('prop', namespaces['DAV:']), + propSerialized.toXmlAttributes(namespaces: namespaces), propSerialized.toXmlChildren(namespaces: namespaces)); + children.add(propConstructed); + return children; +} + +XmlElement _$WebDavPropfindToXmlElement(WebDavPropfind instance, {Map namespaces = const {}}) { + return XmlElement( + XmlName('propfind', namespaces['DAV:']), + [...namespaces.toXmlAttributes(), ...instance.toXmlAttributes(namespaces: namespaces)], + instance.toXmlChildren(namespaces: namespaces)); +} + +mixin _$WebDavPropfindXmlSerializableMixin { + void buildXmlChildren(XmlBuilder builder, {Map namespaces = const {}}) => + _$WebDavPropfindBuildXmlChildren(this as WebDavPropfind, builder, namespaces: namespaces); + + void buildXmlElement(XmlBuilder builder, {Map namespaces = const {}}) => + _$WebDavPropfindBuildXmlElement(this as WebDavPropfind, builder, namespaces: namespaces); + + List toXmlAttributes({Map namespaces = const {}}) => + _$WebDavPropfindToXmlAttributes(this as WebDavPropfind, namespaces: namespaces); + + List toXmlChildren({Map namespaces = const {}}) => + _$WebDavPropfindToXmlChildren(this as WebDavPropfind, namespaces: namespaces); + + XmlElement toXmlElement({Map namespaces = const {}}) => + _$WebDavPropfindToXmlElement(this as WebDavPropfind, namespaces: namespaces); +} + +void _$WebDavOcFilterFilesBuildXmlChildren(WebDavOcFilterFiles instance, XmlBuilder builder, + {Map namespaces = const {}}) { + final filterRules = instance.filterRules; + final filterRulesSerialized = filterRules; + builder.element('filter-rules', namespace: 'http://owncloud.org/ns', nest: () { + filterRulesSerialized.buildXmlChildren(builder, namespaces: namespaces); + }); + final prop = instance.prop; + final propSerialized = prop; + builder.element('prop', namespace: 'DAV:', nest: () { + propSerialized.buildXmlChildren(builder, namespaces: namespaces); + }); +} + +void _$WebDavOcFilterFilesBuildXmlElement(WebDavOcFilterFiles instance, XmlBuilder builder, + {Map namespaces = const {}}) { + builder.element('filter-files', namespace: 'http://owncloud.org/ns', namespaces: namespaces, nest: () { + instance.buildXmlChildren(builder, namespaces: namespaces); + }); +} + +WebDavOcFilterFiles _$WebDavOcFilterFilesFromXmlElement(XmlElement element) { + final filterRules = element.getElement('filter-rules', namespace: 'http://owncloud.org/ns')!; + final prop = element.getElement('prop', namespace: 'DAV:')!; + return WebDavOcFilterFiles( + filterRules: WebDavOcFilterRules.fromXmlElement(filterRules), prop: WebDavPropfindProp.fromXmlElement(prop)); +} + +List _$WebDavOcFilterFilesToXmlAttributes(WebDavOcFilterFiles instance, + {Map namespaces = const {}}) { + final attributes = []; + return attributes; +} + +List _$WebDavOcFilterFilesToXmlChildren(WebDavOcFilterFiles instance, + {Map namespaces = const {}}) { + final children = []; + final filterRules = instance.filterRules; + final filterRulesSerialized = filterRules; + final filterRulesConstructed = XmlElement( + XmlName('filter-rules', namespaces['http://owncloud.org/ns']), + filterRulesSerialized.toXmlAttributes(namespaces: namespaces), + filterRulesSerialized.toXmlChildren(namespaces: namespaces)); + children.add(filterRulesConstructed); + final prop = instance.prop; + final propSerialized = prop; + final propConstructed = XmlElement(XmlName('prop', namespaces['DAV:']), + propSerialized.toXmlAttributes(namespaces: namespaces), propSerialized.toXmlChildren(namespaces: namespaces)); + children.add(propConstructed); + return children; +} + +XmlElement _$WebDavOcFilterFilesToXmlElement(WebDavOcFilterFiles instance, + {Map namespaces = const {}}) { + return XmlElement( + XmlName('filter-files', namespaces['http://owncloud.org/ns']), + [...namespaces.toXmlAttributes(), ...instance.toXmlAttributes(namespaces: namespaces)], + instance.toXmlChildren(namespaces: namespaces)); +} + +mixin _$WebDavOcFilterFilesXmlSerializableMixin { + void buildXmlChildren(XmlBuilder builder, {Map namespaces = const {}}) => + _$WebDavOcFilterFilesBuildXmlChildren(this as WebDavOcFilterFiles, builder, namespaces: namespaces); + + void buildXmlElement(XmlBuilder builder, {Map namespaces = const {}}) => + _$WebDavOcFilterFilesBuildXmlElement(this as WebDavOcFilterFiles, builder, namespaces: namespaces); + + List toXmlAttributes({Map namespaces = const {}}) => + _$WebDavOcFilterFilesToXmlAttributes(this as WebDavOcFilterFiles, namespaces: namespaces); + + List toXmlChildren({Map namespaces = const {}}) => + _$WebDavOcFilterFilesToXmlChildren(this as WebDavOcFilterFiles, namespaces: namespaces); + + XmlElement toXmlElement({Map namespaces = const {}}) => + _$WebDavOcFilterFilesToXmlElement(this as WebDavOcFilterFiles, namespaces: namespaces); +} diff --git a/packages/nextcloud/pubspec.yaml b/packages/nextcloud/pubspec.yaml index 0d546526..51837c8f 100644 --- a/packages/nextcloud/pubspec.yaml +++ b/packages/nextcloud/pubspec.yaml @@ -12,6 +12,7 @@ dependencies: json_annotation: ^4.7.0 version: ^3.0.2 xml: ^6.1.0 + xml_annotation: ^2.2.0 dev_dependencies: build_runner: ^2.2.1 @@ -25,3 +26,4 @@ dev_dependencies: ref: 0b2ee0d process_run: ^0.12.5+2 test: ^1.16.0 + xml_serializable: ^2.2.2 diff --git a/packages/nextcloud/test/webdav.dart b/packages/nextcloud/test/webdav.dart index 6403b501..9645708e 100644 --- a/packages/nextcloud/test/webdav.dart +++ b/packages/nextcloud/test/webdav.dart @@ -36,21 +36,23 @@ Future run(final DockerImage image) async { }); test('List directory', () async { - final files = await client.webdav.ls( + final responses = (await client.webdav.ls( '/', - props: { - WebDavProps.ncHasPreview.name, - WebDavProps.davContentType.name, - WebDavProps.davLastModified.name, - WebDavProps.ocSize.name, - }, - ); - expect(files, hasLength(8)); - final file = files.singleWhere((final f) => f.name == 'Nextcloud.png'); - expect(file.hasPreview, isTrue); - expect(file.mimeType, 'image/png'); - expect(file.lastModified!.isBefore(DateTime.now()), isTrue); - expect(file.size, 50598); + prop: WebDavPropfindProp( + nchaspreview: true, + davgetcontenttype: true, + davgetlastmodified: true, + ocsize: true, + ), + )) + .responses; + expect(responses, hasLength(9)); + final props = + responses.singleWhere((final response) => response.href!.endsWith('/Nextcloud.png')).propstats.first.prop; + expect(props.nchaspreview, isTrue); + expect(props.davgetcontenttype, 'image/png'); + expect(webdavDateFormat.parseUtc(props.davgetlastmodified!).isBefore(DateTime.now()), isTrue); + expect(props.ocsize, 50598); }); test('Create directory', () async { @@ -62,9 +64,9 @@ Future run(final DockerImage image) async { final response = await client.webdav.mkdirs('test/bla'); expect(response!.statusCode, equals(201)); - final files = await client.webdav.ls('/test'); - expect(files, hasLength(1)); - expect(files[0].path, '/test/bla/'); + final responses = (await client.webdav.ls('/test')).responses; + expect(responses, hasLength(2)); + expect(responses[1].href, endsWith('/test/bla/')); }); test('Upload files', () async { @@ -77,38 +79,57 @@ Future run(final DockerImage image) async { response = await client.webdav.upload(txtBytes, 'test.txt'); expect(response.statusCode, equals(201)); - final files = await client.webdav.ls( + final responses = (await client.webdav.ls( '/', - props: { - WebDavProps.ocSize.name, - }, + prop: WebDavPropfindProp( + ocsize: true, + ), + )) + .responses; + expect(responses, hasLength(11)); + expect( + responses.singleWhere((final response) => response.href!.endsWith('/test.png')).propstats.first.prop.ocsize, + pngBytes.lengthInBytes, + ); + expect( + responses.singleWhere((final response) => response.href!.endsWith('/test.txt')).propstats.first.prop.ocsize, + txtBytes.lengthInBytes, ); - expect(files, hasLength(10)); - final pngFile = files.singleWhere((final f) => f.name == 'test.png'); - final txtFile = files.singleWhere((final f) => f.name == 'test.txt'); - expect(pngFile.size, pngBytes.lengthInBytes); - expect(txtFile.size, txtBytes.lengthInBytes); }); - test('Upload file with modified time', () async { + test('Upload file', () async { final lastModified = DateTime.fromMillisecondsSinceEpoch(DateTime.now().millisecondsSinceEpoch ~/ 1000 * 1000); + final created = lastModified.subtract(const Duration(hours: 1)); final txtBytes = File('test/files/test.txt').readAsBytesSync(); final response = await client.webdav.upload( txtBytes, 'test.txt', lastModified: lastModified, + created: created, ); expect(response.statusCode, equals(201)); - final files = await client.webdav.ls( + final props = (await client.webdav.ls( '/', - props: { - WebDavProps.davLastModified.name, - }, + prop: WebDavPropfindProp( + davgetlastmodified: true, + nccreationtime: true, + ), + )) + .responses + .singleWhere((final response) => response.href!.endsWith('/test.txt')) + .propstats + .first + .prop; + expect( + webdavDateFormat.parseUtc(props.davgetlastmodified!).millisecondsSinceEpoch, + lastModified.millisecondsSinceEpoch, + ); + expect( + DateTime.fromMillisecondsSinceEpoch(props.nccreationtime! * 1000).millisecondsSinceEpoch, + created.millisecondsSinceEpoch, ); - final txtFile = files.singleWhere((final f) => f.name == 'test.txt'); - expect(txtFile.lastModified!.millisecondsSinceEpoch, lastModified.millisecondsSinceEpoch); }); test('Copy file', () async { @@ -117,9 +138,9 @@ Future run(final DockerImage image) async { 'test.png', ); expect(response.statusCode, 201); - final files = await client.webdav.ls('/'); - expect(files.where((final f) => f.name == 'Nextcloud.png'), hasLength(1)); - expect(files.where((final f) => f.name == 'test.png'), hasLength(1)); + final responses = (await client.webdav.ls('/')).responses; + expect(responses.where((final response) => response.href!.endsWith('/Nextcloud.png')), hasLength(1)); + expect(responses.where((final response) => response.href!.endsWith('/test.png')), hasLength(1)); }); test('Copy file (overwrite fail)', () async { @@ -150,9 +171,9 @@ Future run(final DockerImage image) async { 'test.png', ); expect(response.statusCode, 201); - final files = await client.webdav.ls('/'); - expect(files.where((final f) => f.name == 'Nextcloud.png'), hasLength(0)); - expect(files.where((final f) => f.name == 'test.png'), hasLength(1)); + final responses = (await client.webdav.ls('/')).responses; + expect(responses.where((final response) => response.href!.endsWith('/Nextcloud.png')), hasLength(0)); + expect(responses.where((final response) => response.href!.endsWith('/test.png')), hasLength(1)); }); test('Move file (overwrite fail)', () async { @@ -178,19 +199,69 @@ Future run(final DockerImage image) async { }); test('Get file props', () async { - final file = await client.webdav.getProps( + final props = (await client.webdav.ls( 'Nextcloud.png', - props: { - WebDavProps.ncHasPreview.name, - WebDavProps.davContentType.name, - WebDavProps.davLastModified.name, - WebDavProps.ocSize.name, - }, - ); - expect(file.hasPreview, isTrue); - expect(file.mimeType, 'image/png'); - expect(file.lastModified!.isBefore(DateTime.now()), isTrue); - expect(file.size, 50598); + prop: WebDavPropfindProp( + davgetlastmodified: true, + davgetetag: true, + davgetcontenttype: true, + davgetcontentlength: true, + ocid: true, + ocfileid: true, + ocfavorite: true, + occommentshref: true, + occommentscount: true, + occommentsunread: true, + ocdownloadurl: true, + ocownerid: true, + ocownerdisplayname: true, + ocsize: true, + ocpermissions: true, + ncnote: true, + ncdatafingerprint: true, + nchaspreview: true, + ncmounttype: true, + ncisencrypted: true, + ncmetadataetag: true, + ncuploadtime: true, + nccreationtime: true, + ncrichworkspace: true, + ocssharepermissions: true, + ocmsharepermissions: true, + ), + depth: 0, + )) + .responses + .single + .propstats + .first + .prop; + expect(webdavDateFormat.parseUtc(props.davgetlastmodified!).isBefore(DateTime.now()), isTrue); + expect(props.davgetetag, isNotEmpty); + expect(props.davgetcontenttype, 'image/png'); + expect(props.davgetcontentlength, 50598); + expect(props.ocid, isNotEmpty); + expect(props.ocfileid, isNotEmpty); + expect(props.ocfavorite, 0); + expect(props.occommentshref, isNotEmpty); + expect(props.occommentscount, 0); + expect(props.occommentsunread, 0); + expect(props.ocdownloadurl, isNull); + expect(props.ocownerid, 'user1'); + expect(props.ocownerdisplayname, 'User One'); + expect(props.ocsize, 50598); + expect(props.ocpermissions, 'RGDNVW'); + expect(props.ncnote, isNull); + expect(props.ncdatafingerprint, isNull); + expect(props.nchaspreview, isTrue); + expect(props.ncmounttype, isNull); + expect(props.ncisencrypted, isNull); + expect(props.ncmetadataetag, isNull); + expect(props.ncuploadtime, 0); + expect(props.nccreationtime, 0); + expect(props.ncrichworkspace, isNull); + expect(props.ocssharepermissions, 19); + expect(json.decode(props.ocmsharepermissions!), ['share', 'read', 'write']); }); test('Get directory props', () async { @@ -198,90 +269,86 @@ Future run(final DockerImage image) async { await client.webdav.mkdir('test'); await client.webdav.upload(data, 'test/test.txt'); - final file = await client.webdav.getProps( + final props = (await client.webdav.ls( 'test', - props: { - WebDavProps.davResourceType.name, - WebDavProps.davContentType.name, - WebDavProps.davLastModified.name, - WebDavProps.ocSize.name, - }, - ); - expect(file.isDirectory, isTrue); - expect(file.name, 'test'); - expect(file.mimeType, null); - expectDateInReasonableTimeRange(file.lastModified!, DateTime.now()); - expect(file.size, data.lengthInBytes); + prop: WebDavPropfindProp( + davgetcontenttype: true, + davgetlastmodified: true, + ocsize: true, + ), + depth: 0, + )) + .responses + .single + .propstats + .first + .prop; + expect(props.davgetcontenttype, isNull); + expectDateInReasonableTimeRange(webdavDateFormat.parseUtc(props.davgetlastmodified!), DateTime.now()); + expect(props.ocsize, data.lengthInBytes); }); test('Filter files', () async { final response = await client.webdav.upload(Uint8List.fromList(utf8.encode('test')), 'test.txt'); final id = response.headers['oc-fileid']!.first; - await client.webdav.updateProps('test.txt', {WebDavProps.ocFavorite.name: '1'}); + await client.webdav.updateProps( + 'test.txt', + WebDavProp( + ocfavorite: 1, + ), + ); - final files = await client.webdav.filter( + final responses = (await client.webdav.filter( '/', - { - WebDavProps.ocFavorite.name: '1', - }, - props: { - WebDavProps.ocId.name, - WebDavProps.ocFavorite.name, - }, - ); - expect(files, hasLength(1)); - final file = files.singleWhere((final e) => e.name == 'test.txt'); - expect(file.id, id); - expect(file.favorite, isTrue); + WebDavOcFilterRules( + ocfavorite: 1, + ), + prop: WebDavPropfindProp( + ocid: true, + ocfavorite: true, + ), + )) + .responses; + expect(responses, hasLength(1)); + final props = + responses.singleWhere((final response) => response.href!.endsWith('/test.txt')).propstats.first.prop; + expect(props.ocid, id); + expect(props.ocfavorite, 1); }); test('Set properties', () async { final createdDate = DateTime.utc(1971, 2); - final createdEpoch = createdDate.millisecondsSinceEpoch / 1000; + final createdEpoch = createdDate.millisecondsSinceEpoch ~/ 1000; final uploadTime = DateTime.now(); await client.webdav.upload(Uint8List.fromList(utf8.encode('test')), 'test.txt'); - final updated = await client.webdav.updateProps('test.txt', { - WebDavProps.ocFavorite.name: '1', - WebDavProps.ncCreationTime.name: '$createdEpoch', - }); - expect(updated, isTrue); - - final file = await client.webdav.getProps( + final updated = await client.webdav.updateProps( 'test.txt', - props: { - WebDavProps.ocFavorite.name, - WebDavProps.ncCreationTime.name, - WebDavProps.ncUploadTime.name, - }, + WebDavProp( + ocfavorite: 1, + nccreationtime: createdEpoch, + ), ); - expect(file.favorite, isTrue); - expect(file.createdDate!.isAtSameMomentAs(createdDate), isTrue); - expectDateInReasonableTimeRange(file.uploadedDate!, uploadTime); - }); - - test('Set custom properties', () async { - client.webdav.registerNamespace('http://example.com/ns', 'test'); - - await client.webdav.upload(Uint8List.fromList(utf8.encode('test')), 'test.txt'); - - final updated = await client.webdav.updateProps('test.txt', { - 'test:custom': 'test-custom-prop-value', - }); expect(updated, isTrue); - final file = await client.webdav.getProps( + final props = (await client.webdav.ls( 'test.txt', - props: { - 'test:custom', - }, - ); - - expect( - file.getProp('test:custom')!.text, - 'test-custom-prop-value', - ); + prop: WebDavPropfindProp( + ocfavorite: true, + nccreationtime: true, + ncuploadtime: true, + ), + depth: 0, + )) + .responses + .single + .propstats + .first + .prop; + expect(props.ocfavorite, 1); + expect(DateTime.fromMillisecondsSinceEpoch(props.nccreationtime! * 1000).isAtSameMomentAs(createdDate), isTrue); + expectDateInReasonableTimeRange(DateTime.fromMillisecondsSinceEpoch(props.ncuploadtime! * 1000), uploadTime); }); }); } diff --git a/tool/generate-nextcloud.sh b/tool/generate-nextcloud.sh index 9503fde9..a55880cf 100755 --- a/tool/generate-nextcloud.sh +++ b/tool/generate-nextcloud.sh @@ -62,6 +62,7 @@ jq \ ( cd packages/nextcloud rm -rf .dart_tool/build + fvm dart run nextcloud:generate_props fvm dart pub run build_runner build --delete-conflicting-outputs # For some reason we need to fix and format twice, otherwise not everything gets fixed fvm dart fix --apply lib/src/nextcloud.openapi.dart