Mercurial > dovecot > core-2.2
changeset 1378:bda297ecd516 HEAD
allow deleting selected mailbox
author | Timo Sirainen <tss@iki.fi> |
---|---|
date | Tue, 22 Apr 2003 21:49:00 +0300 |
parents | b0f075271b2f |
children | 42d30992c0a4 |
files | src/imap/cmd-delete.c |
diffstat | 1 files changed, 12 insertions(+), 9 deletions(-) [+] |
line wrap: on
line diff
--- a/src/imap/cmd-delete.c Tue Apr 22 21:37:58 2003 +0300 +++ b/src/imap/cmd-delete.c Tue Apr 22 21:49:00 2003 +0300 @@ -5,26 +5,29 @@ int cmd_delete(struct client *client) { - const char *mailbox; + struct mailbox *mailbox; + const char *name; /* <mailbox> */ - if (!client_read_string_args(client, 1, &mailbox)) + if (!client_read_string_args(client, 1, &name)) return FALSE; - if (strcasecmp(mailbox, "INBOX") == 0) { + if (strcasecmp(name, "INBOX") == 0) { /* INBOX can't be deleted */ client_send_tagline(client, "NO INBOX can't be deleted."); return TRUE; } - if (client->mailbox != NULL && - strcmp(client->mailbox->name, mailbox) == 0) { - client_send_tagline(client, - "NO Selected mailbox can't be deleted."); - return TRUE; + mailbox = client->mailbox; + if (mailbox != NULL && strcmp(mailbox->name, name) == 0) { + /* deleting selected mailbox. close it first */ + client->mailbox = NULL; + + if (!mailbox->close(mailbox)) + client_send_untagged_storage_error(client); } - if (client->storage->delete_mailbox(client->storage, mailbox)) + if (client->storage->delete_mailbox(client->storage, name)) client_send_tagline(client, "OK Delete completed."); else client_send_storage_error(client);