Beispiel #1
0
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;
}
static bool cmd_setmetadata_continue(struct client_command_context *cmd)
{
	struct imap_setmetadata_context *ctx = cmd->context;
	const char *entry;
	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)
		client_send_box_error(cmd, ctx->box);
	else if (mailbox_transaction_commit(&ctx->trans) < 0)
		client_send_box_error(cmd, ctx->box);
	else
		client_send_tagline(cmd, "OK Setmetadata completed.");
	cmd_setmetadata_deinit(ctx);
	return TRUE;
}