コード例 #1
0
ファイル: request.c プロジェクト: Neil-Smithline/imapfilter
/*
 * Add, remove or replace the specified flags of the messages.
 */
int
request_store(const char *server, const char *port, const char *user,
    const char *mesg, const char *mode, const char *flags)
{
	int t, r;
	session *s;

	if (!(s = session_find(server, port, user)))
		return -1;

	t = imap_store(s, mesg, mode, flags);
	if ((r = response_generic(s, t)) == -1)
		goto fail;

	if (xstrcasestr(flags, "\\Deleted") && get_option_boolean("expunge"))
		if (response_generic(s, imap_expunge(s)) == -1)
			goto fail;

	return r;
fail:
	close_connection(s);
	session_destroy(s);

	return -1;
}
コード例 #2
0
cmd_expunge_finish(struct client_command_context *cmd,
		   struct mail_search_args *search_args)
{
	struct client *client = cmd->client;
	const char *errstr;
	enum mail_error error = MAIL_ERROR_NONE;
	int ret;

	ret = imap_expunge(client->mailbox, search_args == NULL ? NULL :
			   search_args->args);
	if (search_args != NULL)
		mail_search_args_unref(&search_args);
	if (ret < 0) {
		errstr = mailbox_get_last_error(client->mailbox, &error);
		if (error != MAIL_ERROR_PERM) {
			client_send_box_error(cmd, client->mailbox);
			return TRUE;
		} else {
			return cmd_sync(cmd, 0, IMAP_SYNC_FLAG_SAFE,
				t_strdup_printf("OK Expunge ignored: %s.",
						errstr));
		}
	}

	client->sync_seen_deletes = FALSE;
	if ((client->enabled_features & MAILBOX_FEATURE_QRESYNC) != 0) {
		return cmd_sync(cmd, MAILBOX_SYNC_FLAG_EXPUNGE,
				IMAP_SYNC_FLAG_SAFE, "OK Expunge completed.");
	} else {
		return cmd_sync_callback(cmd, MAILBOX_SYNC_FLAG_EXPUNGE,
					 IMAP_SYNC_FLAG_SAFE,
					 cmd_expunge_callback);
	}
}
コード例 #3
0
ファイル: request.c プロジェクト: Neil-Smithline/imapfilter
/*
 * Remove all messages marked for deletion from selected mailbox.
 */
int
request_expunge(const char *server, const char *port, const char *user)
{
	int r;
	session *s;

	if (!(s = session_find(server, port, user)))
		return -1;

	if ((r = response_generic(s, imap_expunge(s))) == -1)
		goto fail;

	return r;
fail:
	close_connection(s);
	session_destroy(s);

	return -1;
}
コード例 #4
0
ファイル: cmd-close.c プロジェクト: via/dovecot-clouddb
bool cmd_close(struct client_command_context *cmd)
{
	struct client *client = cmd->client;
	struct mailbox *mailbox = client->mailbox;
	struct mail_storage *storage;

	if (!client_verify_open_mailbox(cmd))
		return TRUE;

	i_assert(client->mailbox_change_lock == NULL);
	client->mailbox = NULL;

	storage = mailbox_get_storage(mailbox);
	if (imap_expunge(mailbox, NULL) < 0)
		client_send_untagged_storage_error(client, storage);
	if (mailbox_sync(mailbox, 0) < 0)
		client_send_untagged_storage_error(client, storage);

	mailbox_free(&mailbox);
	client_update_mailbox_flags(client, NULL);

	client_send_tagline(cmd, "OK Close completed.");
	return TRUE;
}