cmd-select.c revision 878d69326d44013f83641d7a81ed8ae3e4996f15
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen/* Copyright (C) 2002 Timo Sirainen */
2a6af811ea3de3cf9e2f15e446674dd21b0705f3Timo Sirainenint _cmd_select_full(struct client_command_context *cmd, int readonly)
2a6af811ea3de3cf9e2f15e446674dd21b0705f3Timo Sirainen /* <mailbox> */
2a6af811ea3de3cf9e2f15e446674dd21b0705f3Timo Sirainen if (!client_read_string_args(cmd, 1, &mailbox))
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen client_send_untagged_storage_error(client, storage);
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen box = mailbox_open(storage, mailbox, NULL, !readonly ? 0 :
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen (MAILBOX_OPEN_READONLY | MAILBOX_OPEN_KEEP_RECENT));
fc7b17677ac1a5fa3f7fe13d5ef7dcfea8d9b4a1Timo Sirainen if (imap_sync_nonselected(box, MAILBOX_SYNC_FLAG_FULL_READ) < 0) {
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen if (mailbox_get_status(box, STATUS_MESSAGES | STATUS_RECENT |
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen STATUS_FIRST_UNSEEN_SEQ | STATUS_UIDVALIDITY |
2a6af811ea3de3cf9e2f15e446674dd21b0705f3Timo Sirainen client_save_keywords(&client->keywords, status.keywords);
44ff75ca53188056ff5a3e50428e3f2078800b3cTimo Sirainen /* set client's mailbox only after getting status to make sure
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen we're not sending any expunge/exists replies too early to client */
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen client_send_mailbox_flags(client, box, status.keywords);
45e62043058738e294f89504c319d852e25943ccTimo Sirainen t_strdup_printf("* %u EXISTS", status.messages));
45e62043058738e294f89504c319d852e25943ccTimo Sirainen t_strdup_printf("* %u RECENT", status.recent));
d5960ce1c0adda5c9e259bc429123ebc29c60baeTimo Sirainen t_strdup_printf("* OK [UNSEEN %u] First unseen.",
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen t_strdup_printf("* OK [UIDVALIDITY %u] UIDs valid",
6eb30032b4a50c383dea4c9c74342d906de6ad36Timo Sirainen t_strdup_printf("* OK [UIDNEXT %u] Predicted next UID",
2a6af811ea3de3cf9e2f15e446674dd21b0705f3Timo Sirainen client_send_tagline(cmd, mailbox_is_readonly(box) ?
4bc96ba6f1d67a90a75fa131bcd2cd508ea5a05aTimo Sirainen "OK [READ-ONLY] Select completed." :
4bc96ba6f1d67a90a75fa131bcd2cd508ea5a05aTimo Sirainen "OK [READ-WRITE] Select completed.");