statusMailbox method

Future<Mailbox> statusMailbox(
  1. Mailbox box,
  2. List<StatusFlags> flags
)

Checks the status of the currently not selected box.

The STATUS command requests the status of the indicated mailbox. It does not change the currently selected mailbox, nor does it affect the state of any messages in the queried mailbox (in particular, STATUS MUST NOT cause messages to lose the \Recent flag).

The STATUS command provides an alternative to opening a second IMAP4rev1 connection and doing an EXAMINE command on a mailbox to query that mailbox's status without deselecting the current mailbox in the first IMAP4rev1 connection.

Implementation

Future<Mailbox> statusMailbox(Mailbox box, List<StatusFlags> flags) {
  final path = _encodeMailboxPath(box.path);
  final buffer = StringBuffer()..write('STATUS ')..write(path)..write(' (');
  var addSpace = false;
  for (final flag in flags) {
    if (addSpace) {
      buffer.write(' ');
    }
    switch (flag) {
      case StatusFlags.messages:
        buffer.write('MESSAGES');
        break;
      case StatusFlags.recent:
        buffer.write('RECENT');
        break;
      case StatusFlags.uidNext:
        buffer.write('UIDNEXT');
        break;
      case StatusFlags.uidValidity:
        buffer.write('UIDVALIDITY');
        break;
      case StatusFlags.unseen:
        buffer.write('UNSEEN');
        break;
      case StatusFlags.highestModSequence:
        buffer.write('HIGHESTMODSEQ');
        break;
    }
    addSpace = true;
  }
  buffer.write(')');
  final cmd = Command(buffer.toString());
  final parser = StatusParser(box);
  return sendCommand<Mailbox>(cmd, parser);
}