renameMailbox method
Renames the specified mailbox
box
the mailbox that should be renamed
newName
the desired future name of the mailbox
Implementation
Future<Mailbox> renameMailbox(Mailbox box, String newName) async {
final path = _encodeMailboxPath(box.path);
newName = _encodeMailboxPath(newName);
final cmd = Command('RENAME $path $newName');
final response = await sendCommand<Mailbox>(
cmd, NoopParser(this, _selectedMailbox ?? box));
if (box.name == 'INBOX') {
/* Renaming INBOX is permitted, and has special behavior. It moves
all messages in INBOX to a new mailbox with the given name,
leaving INBOX empty. If the server implementation supports
inferior hierarchical names of INBOX, these are unaffected by a
rename of INBOX.
*/
// question: do we need to create a new mailbox and return that one instead?
}
box.name = newName;
return response;
}