getMetaData method

Future<List<MetaDataEntry>> getMetaData(
  1. String entry, {
  2. String? mailboxName,
  3. int? maxSize,
  4. MetaDataDepth? depth,
})

Retrieves the specified meta data entry.

entry defines the path of the meta data Optionally specify mailboxName, the maxSize in bytes or the depth.

Compare https://tools.ietf.org/html/rfc5464 for details. Note that errata of the RFC exist.

Implementation

Future<List<MetaDataEntry>> getMetaData(String entry,
    {String? mailboxName, int? maxSize, MetaDataDepth? depth}) {
  var cmd = 'GETMETADATA ';
  if (maxSize != null || depth != null) {
    cmd += '(';
  }
  if (maxSize != null) {
    cmd += 'MAXSIZE $maxSize';
  }
  if (depth != null) {
    if (maxSize != null) {
      cmd += ' ';
    }
    cmd += 'DEPTH ';
    switch (depth) {
      case MetaDataDepth.none:
        cmd += '0';
        break;
      case MetaDataDepth.directChildren:
        cmd += '1';
        break;
      case MetaDataDepth.allChildren:
        cmd += 'infinity';
        break;
    }
  }
  if (maxSize != null || depth != null) {
    cmd += ') ';
  }
  cmd += '"${mailboxName ?? ''}" ($entry)';
  final parser = MetaDataParser();
  return sendCommand<List<MetaDataEntry>>(Command(cmd), parser);
}