/* Copyright (c) 2011-2018 Dovecot authors, see the included COPYING file */
#include "lib.h"
#include "array.h"
#include "str.h"
#include "ioloop.h"
#include "safe-mkstemp.h"
#include "iostream-ssl.h"
#include "imapc-msgmap.h"
#include "imapc-connection.h"
#include "imapc-client-private.h"
#include <unistd.h>
const char *imapc_command_state_names[] = {
"OK", "NO", "BAD", "(auth failed)", "(disconnected)"
};
{ "SASL-IR", IMAPC_CAPABILITY_SASL_IR },
{ "LITERAL+", IMAPC_CAPABILITY_LITERALPLUS },
{ "QRESYNC", IMAPC_CAPABILITY_QRESYNC },
{ "IDLE", IMAPC_CAPABILITY_IDLE },
{ "UIDPLUS", IMAPC_CAPABILITY_UIDPLUS },
{ "AUTH=PLAIN", IMAPC_CAPABILITY_AUTH_PLAIN },
{ "STARTTLS", IMAPC_CAPABILITY_STARTTLS },
{ "X-GM-EXT-1", IMAPC_CAPABILITY_X_GM_EXT_1 },
{ "CONDSTORE", IMAPC_CAPABILITY_CONDSTORE },
{ "NAMESPACE", IMAPC_CAPABILITY_NAMESPACE },
{ "UNSELECT", IMAPC_CAPABILITY_UNSELECT },
{ "ESEARCH", IMAPC_CAPABILITY_ESEARCH },
{ "WITHIN", IMAPC_CAPABILITY_WITHIN },
{ "QUOTA", IMAPC_CAPABILITY_QUOTA },
{ "ID", IMAPC_CAPABILITY_ID },
{ "IMAP4REV1", IMAPC_CAPABILITY_IMAP4REV1 },
{ NULL, 0 }
};
unsigned int imapc_client_cmd_tag_counter = 0;
static void
void *context ATTR_UNUSED)
{
}
struct imapc_client *
{
const char *error;
set->connect_retry_interval_msecs > 0);
&error) < 0) {
i_error("imapc(%s:%u): Couldn't initialize SSL context: %s",
}
}
return client;
}
{
}
{
return;
}
{
unsigned int i, count;
for (i = count; i > 0; i--) {
}
}
{
}
void *context)
{
}
{
}
}
{
}
{
}
{
}
{
return;
}
{
}
void *context)
{
/* reopen the mailbox */
} else {
}
}
/* call the login callback only once */
}
}
static struct imapc_client_connection *
{
conn);
return conn;
}
static struct imapc_connection *
{
/* FIXME: stupid algorithm */
}
struct imapc_command *
{
}
static struct imapc_client_connection *
{
unsigned int i, count;
for (i = 0; i < count; i++) {
return conns[i];
}
return imapc_client_add_connection(client);
}
{
}
struct imapc_logout_ctx {
unsigned int logout_count;
};
static void
void *context)
{
if (--ctx->logout_count == 0)
}
{
/* send LOGOUT to all connections */
continue;
ctx.logout_count++;
}
/* wait for LOGOUT to finish */
while (ctx.logout_count > 0)
/* we should have disconnected all clients already, but if there were
any timeouts there may be some clients left. */
}
struct imapc_client_mailbox *
void *untagged_box_context)
{
/* if we get disconnected before the SELECT is finished, allow
one reconnect retry. */
return box;
}
void *context)
{
}
{
/* the reconnect_ok flag attempts to avoid infinite reconnection loops
to a server that keeps disconnecting us (e.g. some of the commands
we send keeps crashing it always) */
}
const char *errmsg)
{
}
{
/* cancel any pending commands */
if (box->reconnecting) {
/* need to abort the reconnection so it won't try to access
the box */
}
/* set this only after unselect, which may cancel some commands that
reference this box */
break;
}
}
}
struct imapc_command *
{
return cmd;
}
struct imapc_msgmap *
{
}
{
}
{
/* send the IDLE with a delay to avoid unnecessary IDLEs that are
immediately aborted */
box->to_send_idle =
}
/* we're done with all work at this point. */
}
{
return FALSE;
if (selected_box != box) {
if (selected_box != NULL)
i_error("imapc: Selected mailbox changed unexpectedly");
return FALSE;
}
return TRUE;
}
static bool
enum imapc_capability *capabilities_r)
{
return TRUE;
}
}
return FALSE;
}
enum imapc_capability *capabilities_r)
{
/* try to find a connection that is already logged in */
return 0;
/* if there are no connections yet, create one */
(void)imapc_client_add_connection(client);
/* wait for any of the connections to login */
return 0;
/* failed */
return -1;
}
const char **path_r)
{
int fd;
i_error("imapc: temp_path_prefix not set, "
"can't create temp file");
return -1;
}
if (fd == -1) {
return -1;
}
/* we just want the fd, unlink it */
/* shouldn't happen.. */
i_close_fd(&fd);
return -1;
}
return fd;
}
void *context)
{
}
void
{
}