cmd-select.c revision bd74402ca1a39ec303075fefb1212d7e18a71531
8fcff4c5b52f24d9c681805fdf06b486f1d0fcbeTimo Sirainen/* Copyright (C) 2002 Timo Sirainen */
8fcff4c5b52f24d9c681805fdf06b486f1d0fcbeTimo Sirainenbool _cmd_select_full(struct client_command_context *cmd, bool readonly)
8fcff4c5b52f24d9c681805fdf06b486f1d0fcbeTimo Sirainen /* <mailbox> */
8fcff4c5b52f24d9c681805fdf06b486f1d0fcbeTimo Sirainen if (!client_read_string_args(cmd, 1, &mailbox))
fdc557286bc9f92c5f3bb49096ff6e2bcec0ea79Timo Sirainen client_send_untagged_storage_error(client, storage);
63a61b7a739ae0f3f520215137d9c50f94d0f34fTimo Sirainen box = mailbox_open(storage, mailbox, NULL, !readonly ? 0 :
63a61b7a739ae0f3f520215137d9c50f94d0f34fTimo Sirainen (MAILBOX_OPEN_READONLY | MAILBOX_OPEN_KEEP_RECENT));
d30da25fb6be1f1c667d93767c9194000194b618Timo Sirainen if (imap_sync_nonselected(box, MAILBOX_SYNC_FLAG_FULL_READ) < 0) {
63a61b7a739ae0f3f520215137d9c50f94d0f34fTimo Sirainen if (mailbox_get_status(box, STATUS_MESSAGES | STATUS_RECENT |
63a61b7a739ae0f3f520215137d9c50f94d0f34fTimo Sirainen STATUS_FIRST_UNSEEN_SEQ | STATUS_UIDVALIDITY |
f1901fd21906911f7be075c965ac882f6a87b4c3Timo Sirainen client_save_keywords(&client->keywords, status.keywords);
f1901fd21906911f7be075c965ac882f6a87b4c3Timo Sirainen /* set client's mailbox only after getting status to make sure
f1901fd21906911f7be075c965ac882f6a87b4c3Timo Sirainen we're not sending any expunge/exists replies too early to client */
f1901fd21906911f7be075c965ac882f6a87b4c3Timo Sirainen client_send_mailbox_flags(client, box, status.keywords);
f1901fd21906911f7be075c965ac882f6a87b4c3Timo Sirainen t_strdup_printf("* %u EXISTS", status.messages));
f1901fd21906911f7be075c965ac882f6a87b4c3Timo Sirainen t_strdup_printf("* %u RECENT", status.recent));
8fcff4c5b52f24d9c681805fdf06b486f1d0fcbeTimo Sirainen t_strdup_printf("* OK [UNSEEN %u] First unseen.",
8fcff4c5b52f24d9c681805fdf06b486f1d0fcbeTimo Sirainen t_strdup_printf("* OK [UIDVALIDITY %u] UIDs valid",
8fcff4c5b52f24d9c681805fdf06b486f1d0fcbeTimo Sirainen t_strdup_printf("* OK [UIDNEXT %u] Predicted next UID",
8fcff4c5b52f24d9c681805fdf06b486f1d0fcbeTimo Sirainen client_send_tagline(cmd, mailbox_is_readonly(box) ?
8fcff4c5b52f24d9c681805fdf06b486f1d0fcbeTimo Sirainen "OK [READ-ONLY] Select completed." :
8fcff4c5b52f24d9c681805fdf06b486f1d0fcbeTimo Sirainen "OK [READ-WRITE] Select completed.");