imapc-mail.c revision eb1365e61674c54c7c453143356a891fb2e2b3d6
/* Copyright (c) 2011-2015 Dovecot authors, see the included COPYING file */
#include "lib.h"
#include "str.h"
#include "hex-binary.h"
#include "sha1.h"
#include "istream.h"
#include "imap-envelope.h"
#include "imapc-msgmap.h"
#include "imapc-mail.h"
#include "imapc-client.h"
#include "imapc-storage.h"
struct mail *
imapc_mail_alloc(struct mailbox_transaction_context *t,
struct mailbox_header_lookup_ctx *wanted_headers)
{
struct imapc_mail *mail;
}
{
struct imapc_msgmap *msgmap;
if (!mbox->initial_sync_done) {
/* unknown at this point */
return FALSE;
}
/* check if another session has already expunged it */
return TRUE;
}
/* check if we've received EXPUNGE for it */
return TRUE;
/* we may be running against a server that hasn't bothered sending
us an EXPUNGE. see if NOOP sends it. */
}
{
/* we've already logged a disconnection error */
} else {
/* NOTE: earlier we didn't treat this as a failure, because
old Exchange versions fail to return any data for messages
in Calendars mailbox. But it's a bad idea to always assume
that a missing field is intentional, because there's
potential for data loss. Ideally we could detect whether
this is an Exchange issue or not, but I don't have access
to such an old Exchange anymore. So at least for now until
someone complains, the Exchange workaround is disabled. */
"imapc: Remote server didn't send %s for UID %u in %s",
}
}
{
return 0;
return -1;
return -1;
}
}
return 0;
}
{
/* FIXME: we could use a value stored in cache */
}
return 0;
}
{
int ret;
return 0;
}
}
/* trust RFC822.SIZE to be correct */
return -1;
return -1;
}
return 0;
}
return -1;
&data->physical_size);
if (ret <= 0) {
"imapc: stat(%s) failed: %m",
return -1;
}
return 0;
}
static int
struct mailbox_header_lookup_ctx *headers,
{
int ret;
}
/* see if the wanted headers are already in cache */
if (ret == 0)
return 0;
/* fetch only the wanted headers */
return -1;
/* the headers should cached now. */
}
static int
bool decode_to_utf8, const char *const **value_r)
{
struct mailbox_header_lookup_ctx *headers;
const char *header_names[2];
const unsigned char *data;
int ret;
header_names[0] = field;
if (ret < 0)
return -1;
/* the header should cached now. */
}
static int
bool decode_to_utf8, const char **value_r)
{
const char *const *values;
int ret;
if (ret <= 0)
return ret;
return 1;
}
static int
struct message_size *hdr_size,
{
enum mail_fetch_field fetch_field;
/* we've fetched the header, but we need the body now too */
}
if (!data->initialized) {
/* coming here from mail_set_seq() */
return -1;
}
fetch_field = get_body ||
return -1;
return -1;
}
}
stream_r);
}
static bool
struct mailbox_header_lookup_ctx *headers)
{
unsigned int i;
return FALSE;
}
return TRUE;
}
{
struct mailbox_header_lookup_ctx *header_ctx;
}
}
}
(void)imapc_mail_get_cached_guid(_mail);
/* see if all wanted headers exist in cache */
}
if (data->access_part == 0 &&
/* the common code already checked this partially,
but we need a guaranteed correct answer */
}
}
{
/* searching code handles prefetching internally,
elsewhere we want to do it immediately */
(void)imapc_mail_prefetch(_mail);
}
static void
enum mail_fetch_field fields,
struct mailbox_header_lookup_ctx *headers)
{
}
{
if (mail->fetch_count > 0) {
while (mail->fetch_count > 0)
}
if (mail->body_fetched) {
} else {
}
}
i_error("close(imapc mail) failed: %m");
}
}
{
const unsigned char *data;
unsigned char sha1_output[SHA1_RESULTLEN];
const char *sha1_str;
return -1;
}
return 0;
}
{
const enum index_cache_field cache_idx =
/* GUID was prefetched - add to cache */
}
return TRUE;
}
return TRUE;
}
return FALSE;
}
{
const enum index_cache_field cache_idx =
if (imapc_mail_get_cached_guid(_mail)) {
return 0;
}
/* GUID not in cache, fetch it */
return -1;
return -1;
}
} else {
/* use hash of message headers as the GUID */
if (imapc_mail_get_hdr_hash(imail) < 0)
return -1;
}
return 0;
}
static int
const char **value_r)
{
switch (field) {
case MAIL_FETCH_GUID:
/* GUIDs not supported by server */
break;
}
*value_r = "";
case MAIL_FETCH_UIDL_BACKEND:
break;
return -1;
"X-GM-MSGID not 64bit integer as expected for POP3 UIDL generation: %s", *value_r);
return -1;
}
(unsigned long long)num);
return 0;
default:
break;
}
}
struct mail_vfuncs imapc_mail_vfuncs = {
NULL,
};