imapc-mail-fetch.c revision 27a44fcfd8d19bffe0f267f20a2b5d3fe7600fdd
/* Copyright (c) 2011-2012 Dovecot authors, see the included COPYING file */
#include "lib.h"
#include "str.h"
#include "istream.h"
#include "istream-header-filter.h"
#include "imap-arg.h"
#include "imap-date.h"
#include "imapc-client.h"
#include "imapc-mail.h"
#include "imapc-storage.h"
static void
void *context)
{
struct imapc_mailbox *mbox =
if (--mail->fetch_count == 0) {
struct imapc_mail *const *fetch_mails;
unsigned int i, count;
for (i = 0; i < count; i++) {
if (fetch_mails[i] == mail) {
break;
}
}
mail->fetching_fields = 0;
}
;
reply);
/* The disconnection message was already logged */
} else {
}
}
static int
{
struct imapc_command *cmd;
struct mail_index_view *view;
return -1;
/* drop any fields that we may already be fetching currently */
if (fields == 0)
return 0;
/* if we already know that the mail is expunged,
don't try to FETCH it */
return -1;
}
/* opened as save-only. we'll need to fetch the mail,
if (imapc_mailbox_select(mbox) < 0)
return -1;
}
if ((fields & MAIL_FETCH_STREAM_BODY) != 0)
if ((fields & MAIL_FETCH_RECEIVED_DATE) != 0)
if ((fields & MAIL_FETCH_PHYSICAL_SIZE) != 0)
if ((fields & MAIL_FETCH_GUID) != 0) {
}
if ((fields & MAIL_FETCH_STREAM_BODY) != 0)
else if ((fields & MAIL_FETCH_STREAM_HEADER) != 0)
if (mail->fetch_count++ == 0)
return 0;
}
struct imapc_mail_cache *cache)
{
if (mail->body_fetched)
return;
} else {
return;
}
}
{
enum mail_fetch_field fields = 0;
else
}
} T_END;
}
static bool
{
if ((fields & MAIL_FETCH_RECEIVED_DATE) != 0) {
return FALSE;
}
if ((fields & MAIL_FETCH_PHYSICAL_SIZE) != 0) {
return FALSE;
}
if ((fields & MAIL_FETCH_GUID) != 0) {
return FALSE;
fields &= ~MAIL_FETCH_GUID;
}
if ((fields & (MAIL_FETCH_STREAM_HEADER |
MAIL_FETCH_STREAM_BODY)) != 0) {
return FALSE;
}
return TRUE;
}
{
struct imapc_mailbox *mbox =
int ret;
if ((fields & MAIL_FETCH_GUID) != 0 &&
"Message GUID not available in this server");
return -1;
}
T_BEGIN {
} T_END;
if (ret < 0)
return -1;
/* we'll continue waiting until we've got all the fields we wanted,
or until all FETCH replies have been received (i.e. some FETCHes
failed) */
return 0;
}
{
unsigned int i, count;
for (i = 0; i < reply->file_args_count; i++) {
return TRUE;
}
}
return FALSE;
}
{
static const char *imapc_hide_headers[] = {
/* Added by MS Exchange 2010 when \Flagged flag is set.
This violates IMAP guarantee of messages being immutable. */
"X-Message-Flag"
};
struct istream *filter_input;
*null_header_filter_callback, (void *)NULL);
*input = filter_input;
}
{
int ret;
return;
}
} else if (have_body) {
if (ret < 0) {
return;
}
/* we'll assume that the remote server is working properly and
sending CRLF linefeeds */
}
}
static void
const struct imapc_untagged_reply *reply,
{
const char *value;
int fd;
if (!body)
return;
/* maybe the existing stream has no body. replace it. */
i_error("close(imapc mail) failed: %m");
}
}
return;
i_error("dup() failed: %m");
return;
}
} else {
return;
return;
}
}
}
}
const struct imapc_untagged_reply *reply,
{
struct imapc_mailbox *mbox =
unsigned int i;
time_t t;
int tz;
break;
}
}
}
if (!match) {
/* this is only a FETCH FLAGS update for the wanted mail */
} else {
}
}