setMetaDataEntries method

Future<Mailbox> setMetaDataEntries(
  1. List<MetaDataEntry> entries
)

Saves the given meta data entries.

Note that each MetaDataEntry.mailboxName is expected to be the same. Set MetaDataEntry.value to null to delete the specified meta data entry Compare https://tools.ietf.org/html/rfc5464 for details.

Implementation

Future<Mailbox> setMetaDataEntries(List<MetaDataEntry> entries) {
  final parts = <String>[];
  var cmd = StringBuffer();
  cmd.write('SETMETADATA ');
  var entry = entries.first;
  cmd.write('"${entry.mailboxName}" (');
  for (entry in entries) {
    cmd.write(' ');
    cmd.write(entry.name);
    cmd.write(' ');
    if (entry.value == null) {
      cmd.write('NIL');
    } else if (_isSafeForQuotedTransmission(entry.valueText!)) {
      cmd.write('"${entry.valueText}"');
    } else {
      cmd.write('{${entry.value!.length}}');
      parts.add(cmd.toString());
      cmd = StringBuffer();
      cmd.write(entry.valueText);
    }
  }
  cmd.write(')');
  parts.add(cmd.toString());
  final parser = NoopParser(this, _selectedMailbox);
  Command command;
  if (parts.length == 1) {
    command = Command(parts.first);
  } else {
    command = Command.withContinuation(parts);
  }
  return sendCommand<Mailbox>(command, parser);
}