cmd-store.c revision 45312f52ff3a3d4c137447be4c7556500c2f8bf2
a8c5a86d183db25a57bf193c06b41e092ec2e151Timo Sirainen/* Copyright (c) 2002-2009 Dovecot authors, see the included COPYING file */
945631faab2bf1aed8d95a1fd0c317a9ce153725Timo Sirainenget_modify_type(struct imap_store_context *ctx, const char *type)
f81a4d2002da0db33d11ca694d3a91b3ee2a0fdbTimo Sirainen ctx->silent = strcasecmp(type+5, ".SILENT") == 0;
f81a4d2002da0db33d11ca694d3a91b3ee2a0fdbTimo Sirainenstore_parse_modifiers(struct imap_store_context *ctx,
945631faab2bf1aed8d95a1fd0c317a9ce153725Timo Sirainen "STORE modifiers contain non-atoms.");
e6d7d19c328e7043ad35d5a52c1617bde915a16fTimo Sirainen if (strcasecmp(name, "UNCHANGEDSINCE") == 0) {
8d131435ba4648c8821160ec38d508c97177c715Timo Sirainen "Unknown STORE modifier");
2a6af811ea3de3cf9e2f15e446674dd21b0705f3Timo Sirainenstore_parse_args(struct imap_store_context *ctx, const struct imap_arg *args)
945631faab2bf1aed8d95a1fd0c317a9ce153725Timo Sirainen struct client_command_context *cmd = ctx->cmd;
bf91bed88d4e294b4577ba2a3b14d87cf35ae135Timo Sirainen if (!store_parse_modifiers(ctx, IMAP_ARG_LIST_ARGS(args)))
2a6af811ea3de3cf9e2f15e446674dd21b0705f3Timo Sirainen if (type == NULL || !get_modify_type(ctx, type)) {
2a6af811ea3de3cf9e2f15e446674dd21b0705f3Timo Sirainen client_send_command_error(cmd, "Invalid arguments.");
2a6af811ea3de3cf9e2f15e446674dd21b0705f3Timo Sirainen if (!client_parse_mail_flags(cmd, IMAP_ARG_LIST_ARGS(args),
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen if (keywords_list != NULL || ctx->modify_type == MODIFY_REPLACE) {
1cad0dd34667548ba39f794ddeb9fc486cf4c666Timo Sirainen if (mailbox_keywords_create(cmd->client->mailbox, keywords_list,
1cad0dd34667548ba39f794ddeb9fc486cf4c666Timo Sirainen /* invalid keywords */
1cad0dd34667548ba39f794ddeb9fc486cf4c666Timo Sirainenbool cmd_store(struct client_command_context *cmd)
1cad0dd34667548ba39f794ddeb9fc486cf4c666Timo Sirainen client_send_command_error(cmd, "Invalid arguments.");
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen ret = imap_search_get_seqset(cmd, IMAP_ARG_STR_NONULL(args),
3697080532ccd9f51fac108be6079b616c7a2ddfTimo Sirainen reply = "NO CONDSTORE failed: Mailbox is read-only.";
a28a6267f48971117dec958b160deefd14ebb7a6Timo Sirainen reply = "OK Store ignored with read-only mailbox.";
3697080532ccd9f51fac108be6079b616c7a2ddfTimo Sirainen (cmd->uid ? 0 : MAILBOX_SYNC_FLAG_NO_EXPUNGES),
2a6af811ea3de3cf9e2f15e446674dd21b0705f3Timo Sirainen /* update modseqs so we can check them early */
2a6af811ea3de3cf9e2f15e446674dd21b0705f3Timo Sirainen t = mailbox_transaction_begin(client->mailbox, flags);
2a6af811ea3de3cf9e2f15e446674dd21b0705f3Timo Sirainen search_ctx = mailbox_search_init(t, search_args, NULL);
3697080532ccd9f51fac108be6079b616c7a2ddfTimo Sirainen /* STORE UNCHANGEDSINCE is being used */
3697080532ccd9f51fac108be6079b616c7a2ddfTimo Sirainen mailbox_transaction_set_max_modseq(t, ctx.max_modseq,
fa5957ffc9b676bfd649fa9953e63e72ee4ebeb4Timo Sirainen while (mailbox_search_next(search_ctx, mail) > 0) {
e06c0b65c16ccce69bbee009ead14d7d3d17a256Timo Sirainen /* check early so there's less work for transaction
3697080532ccd9f51fac108be6079b616c7a2ddfTimo Sirainen commit if something has to be cancelled */
3697080532ccd9f51fac108be6079b616c7a2ddfTimo Sirainen if (ctx.modify_type == MODIFY_REPLACE || ctx.flags != 0)
3342badd8c69adff34db589fb0a221ace5996212Timo Sirainen mail_update_flags(mail, ctx.modify_type, ctx.flags);
3342badd8c69adff34db589fb0a221ace5996212Timo Sirainen if (ctx.modify_type == MODIFY_REPLACE || ctx.keywords != NULL) {
31050c3df6cbe403e8ced8ef11b5c4e12124d354Timo Sirainen mailbox_keywords_free(client->mailbox, &ctx.keywords);
fa5957ffc9b676bfd649fa9953e63e72ee4ebeb4Timo Sirainen i_array_init(&uids, array_count(&modified_set)*2);
6a19e109ee8c5a6f688da83a86a7f6abeb71abddTimo Sirainen mailbox_get_uid_range(client->mailbox, &modified_set,
b32de04eb77234b25e2e411884a2503a1bf3c255Phil Carmody str_append(str, "] Conditional store failed.");
b32de04eb77234b25e2e411884a2503a1bf3c255Phil Carmody /* With UID STORE we have to return UID for the flags as well.
b32de04eb77234b25e2e411884a2503a1bf3c255Phil Carmody Unfortunately we don't have the ability to separate those
b32de04eb77234b25e2e411884a2503a1bf3c255Phil Carmody flag changes that were caused by UID STORE and those that
b32de04eb77234b25e2e411884a2503a1bf3c255Phil Carmody came externally, so we'll just send the UID for all flag
b32de04eb77234b25e2e411884a2503a1bf3c255Phil Carmody changes that we see. */
dfdd228ab20092705da0e8812b3cd0a039319375Timo Sirainen if (cmd->uid && (!ctx.silent || (client->enabled_features &