/* Copyright (c) 2011-2018 Dovecot authors, see the included COPYING file */
#include "lib.h"
#include "str.h"
#include "istream.h"
#include "istream-crlf.h"
#include "ostream.h"
#include "imap-date.h"
#include "imap-util.h"
#include "index-mail.h"
#include "mail-copy.h"
#include "mailbox-list-private.h"
#include "imapc-storage.h"
#include "imapc-sync.h"
#include "imapc-mail.h"
struct imapc_save_context {
int fd;
char *temp_path;
unsigned int save_count;
};
struct imapc_save_cmd_context {
int ret;
};
struct mail_save_context *
{
}
return t->save_ctx;
}
{
const char *path;
return -1;
&path);
"Couldn't create temp file %s", path);
return -1;
}
/* we may not know the size of the input, or be sure that it contains
only CRLFs. so we'll always first write the mail to a temp file and
upload it from there to remote server. */
return 0;
}
{
return -1;
return -1;
}
return 0;
}
const struct imapc_command_reply *reply,
{
const char *const *args;
*uid_r = 0;
/* <uidvalidity> <dest uid-set> */
return;
return;
if (ctx->dest_uid_validity == 0)
return;
32, dest_uid);
}
}
static void
{
/* we'll temporarily append messages and at commit time expunge
them all, since we can't guarantee that no one else has saved
messages to remote server during our transaction */
}
ctx->save_count++;
}
void *context)
{
} else {
}
}
static void
void *context)
{
/* we don't really care about the reply */
}
static void
{
const char *const *kw_p;
unsigned int i;
}
}
{
}
}
/* e.g. Courier doesn't send EXISTS reply before the tagged
APPEND reply. That isn't exactly required by the IMAP RFC,
but it makes the behavior better. See if NOOP finds
the mail. */
}
}
{
if (!mail_storage_set_error_from_errno(storage)) {
}
}
}
if (imapc_save_append(ctx) < 0)
}
}
{
(void)imapc_save_finish(_ctx);
}
{
/* expunge all added messages from index before commit */
for (i = 0; i < ctx->save_count; i++)
}
return 0;
}
{
}
{
/* FIXME: if we really want to rollback, we should expunge messages
we already saved */
}
const struct imapc_command_reply *reply,
{
const char *const *args;
*uid_r = 0;
/* <uidvalidity> <source uid-set> <dest uid-set> */
return;
return;
if (ctx->dest_uid_validity == 0)
return;
32, dest_uid);
}
}
void *context)
{
} else {
}
}
{
/* same server, we can use COPY for the mail */
}
}