static bool cmd_setmetadata_continue(struct client_command_context *cmd) { struct imap_setmetadata_context *ctx = cmd->context; const char *entry, *error_string; enum mail_error error; const struct imap_arg *value; int ret; if (cmd->cancel) { cmd_setmetadata_deinit(ctx); return TRUE; } if (ctx->input != NULL) { if ((ret = cmd_setmetadata_entry_read_stream(ctx)) == 0) return FALSE; if (ret < 0) { cmd_setmetadata_deinit(ctx); return TRUE; } } while ((ret = cmd_setmetadata_parse_entryvalue(ctx, &entry, &value)) > 0 && entry != NULL) { ret = ctx->failed ? 1 : cmd_setmetadata_entry(ctx, entry, value); imap_parser_reset(ctx->parser); if (ret <= 0) break; } if (ret == 0) return 0; if (ret < 0 || ctx->cmd_error_sent) { /* already sent the error to client */ ; } else if (ctx->storage_failure) { if (ctx->box == NULL) client_disconnect_if_inconsistent(cmd->client); error_string = imap_metadata_transaction_get_last_error (ctx->trans, &error); client_send_tagline(cmd, imap_get_error_string(cmd, error_string, error)); } else if (imap_metadata_transaction_commit(&ctx->trans, &error, &error_string) < 0) { if (ctx->box == NULL) client_disconnect_if_inconsistent(cmd->client); client_send_tagline(cmd, imap_get_error_string(cmd, error_string, error)); } else { client_send_tagline(cmd, "OK Setmetadata completed."); } cmd_setmetadata_deinit(ctx); return TRUE; }
void client_send_list_error(struct client_command_context *cmd, struct mailbox_list *list) { const char *error_string; enum mail_error error; error_string = mailbox_list_get_last_error(list, &error); client_send_tagline(cmd, imap_get_error_string(cmd, error_string, error)); }
void client_send_storage_error(struct client_command_context *cmd, struct mail_storage *storage) { const char *error_string; enum mail_error error; error_string = mail_storage_get_last_error(storage, &error); client_send_tagline(cmd, imap_get_error_string(cmd, error_string, error)); if (cmd->client->mailbox != NULL && mailbox_is_inconsistent(cmd->client->mailbox)) { /* we can't do forced CLOSE, so have to disconnect */ client_disconnect_with_error(cmd->client, "IMAP session state is inconsistent, please relogin."); } }
int imap_status_get(struct client_command_context *cmd, struct mail_namespace *ns, const char *mailbox, const struct imap_status_items *items, struct imap_status_result *result_r) { struct client *client = cmd->client; struct mailbox *box; const char *errstr; int ret = 0; if (client->mailbox != NULL && mailbox_equals(client->mailbox, ns, mailbox)) { /* this mailbox is selected */ box = client->mailbox; } else { /* open the mailbox */ box = mailbox_alloc(ns->list, mailbox, MAILBOX_FLAG_READONLY); mailbox_set_reason(box, "STATUS"); if (client->enabled_features != 0) (void)mailbox_enable(box, client->enabled_features); } if ((items->status & STATUS_HIGHESTMODSEQ) != 0) (void)client_enable(client, MAILBOX_FEATURE_CONDSTORE); ret = mailbox_get_status(box, items->status, &result_r->status); if (items->metadata != 0 && ret == 0) { ret = mailbox_get_metadata(box, items->metadata, &result_r->metadata); } if (ret < 0) { errstr = mailbox_get_last_error(box, &result_r->error); result_r->errstr = imap_get_error_string(cmd, errstr, result_r->error); } if (box != client->mailbox) mailbox_free(&box); return ret; }