imapc-storage.c revision 9438ecaf1caee1bb33c8d7f638742875ac42c4e5
/* Copyright (c) 2011-2012 Dovecot authors, see the included COPYING file */
#include "lib.h"
#include "ioloop.h"
#include "str.h"
#include "imap-arg.h"
#include "imap-resp-code.h"
#include "mailbox-tree.h"
#include "imapc-client.h"
#include "imapc-connection.h"
#include "imapc-msgmap.h"
#include "imapc-mail.h"
#include "imapc-list.h"
#include "imapc-sync.h"
#include "imapc-settings.h"
#include "imapc-storage.h"
#define DNS_CLIENT_SOCKET_NAME "dns-client"
struct imapc_open_context {
struct imapc_mailbox *mbox;
int ret;
};
struct imapc_resp_code_map {
const char *code;
enum mail_error error;
};
extern struct mail_storage imapc_storage;
extern struct mailbox imapc_mailbox;
static struct imapc_resp_code_map imapc_resp_code_map[] = {
/* { IMAP_RESP_CODE_CLIENTBUG, 0 }, */
};
struct imapc_storage *storage);
static bool
{
unsigned int i;
return FALSE;
for (i = 0; i < N_ELEMENTS(imapc_resp_code_map); i++) {
return TRUE;
}
}
return FALSE;
}
static struct mail_storage *imapc_storage_alloc(void)
{
struct imapc_storage *storage;
}
enum mail_error default_error,
const struct imapc_command_reply *reply)
{
enum mail_error error;
} else {
}
}
struct imapc_storage *storage)
{
}
{
}
{
do {
} while (storage->reopen_count > 0);
}
void *context)
{
} else {
}
}
{
struct imapc_command *cmd;
struct imapc_simple_context sctx;
}
void *context)
{
const struct imapc_storage_event_callback *cb;
const struct imapc_mailbox_event_callback *mcb;
}
return;
}
}
}
}
static int
const char **error_r)
{
struct imapc_command *cmd;
struct imapc_simple_context sctx;
return -1;
}
*error_r = "LIST didn't return hierarchy separator";
return -1;
}
}
static int
struct mail_namespace *ns,
const char **error_r)
{
struct imapc_client_settings set;
*error_r = "missing imapc_host";
return -1;
}
*error_r = "missing imapc_password";
return -1;
}
else
/* connect to imap server and get the hierarchy separator. */
return -1;
}
return 0;
}
{
}
const char *name,
{
struct imapc_storage_event_callback *cb;
}
static void
struct mailbox_list_settings *set)
{
}
static struct mailbox *
{
struct imapc_mailbox *mbox;
}
static int
enum mailbox_existence *existence_r)
{
enum mailbox_info_flags flags;
return -1;
if ((flags & MAILBOX_NONEXISTENT) != 0)
else if ((flags & MAILBOX_NOSELECT) != 0)
else
return 0;
}
{
}
static void
void *context)
{
"imapc: Reopening mailbox '%s' failed: %s",
}
}
static void imapc_mailbox_reopen(void *context)
{
struct imapc_command *cmd;
/* we're reconnecting and need to reopen the mailbox */
mbox->prev_skipped_rseq = 0;
mbox->prev_skipped_uid = 0;
else
}
static void
void *context)
{
} else {
"imapc: Opening mailbox '%s' failed: %s",
}
}
{
enum imapc_capability capa =
/* see if we can get message GUIDs somehow */
if ((capa & IMAPC_CAPABILITY_X_GM_EXT_1) != 0) {
/* GMail */
}
}
}
{
struct imapc_command *cmd;
struct imapc_open_context ctx;
mbox->client_box =
else
}
{
return -1;
/* We don't actually want to SELECT the mailbox. */
return 0;
}
/* trying to open INBOX as the namespace prefix.
Don't allow this. */
"Mailbox isn't selectable");
return -1;
}
if (imapc_mailbox_select(mbox) < 0) {
return -1;
}
return 0;
}
{
i_error("close(imapc cached mail) failed: %m");
}
}
{
}
}
static int
bool directory)
{
struct imapc_command *cmd;
struct imapc_simple_context sctx;
if (directory) {
}
}
{
"Not supported");
return -1;
}
struct imapc_storage *storage)
{
struct mailbox_status *status;
unsigned int i;
return;
return;
return;
}
}
enum mailbox_status_items items,
struct mailbox_status *status_r)
{
if ((items & STATUS_PERMANENT_FLAGS) != 0)
}
enum mailbox_status_items items,
struct mailbox_status *status_r)
{
struct imapc_command *cmd;
struct imapc_simple_context sctx;
return 0;
}
/* mailbox isn't opened yet */
STATUS_PERMANENT_FLAGS)) != 0) {
/* getting these requires opening the mailbox */
if (mailbox_open(box) < 0)
return -1;
return 0;
}
if ((items & STATUS_MESSAGES) != 0)
if ((items & STATUS_RECENT) != 0)
if ((items & STATUS_UIDNEXT) != 0)
if ((items & STATUS_UIDVALIDITY) != 0)
if ((items & STATUS_UNSEEN) != 0)
/* nothing requested */
return 0;
}
}
enum mailbox_metadata_items items,
struct mailbox_metadata *metadata_r)
{
return -1;
if ((items & MAILBOX_METADATA_GUID) != 0) {
/* a bit ugly way to do this, but better than nothing for now.
FIXME: if indexes are enabled, keep this there. */
}
return 0;
}
void *context)
{
;
else {
}
}
{
struct imapc_command *cmd;
}
void *context)
{
}
{
struct imapc_command *cmd;
enum imapc_capability capa;
return;
}
if ((capa & IMAPC_CAPABILITY_IDLE) != 0) {
/* remote server is already in IDLE. but since some servers
don't notice changes immediately, we'll force them to check
here by sending a NOOP. this helps with clients that break
IDLE when clicking "get mail". */
} else {
/* remote server doesn't support IDLE.
check for changes with NOOP every once in a while. */
}
}
{
return TRUE;
}
struct mail_storage imapc_storage = {
.v = {
NULL,
NULL,
}
};
struct mailbox imapc_mailbox = {
.v = {
NULL,
NULL,
NULL,
NULL,
}
};