cmd-select.c revision ee32cb2843bf6be232e418591100f0297c7ead83
/* Copyright (c) 2002-2008 Dovecot authors, see the included COPYING file */
#include "common.h"
#include "seq-range-array.h"
#include "commands.h"
#include "mail-search.h"
#include "imap-messageset.h"
#include "imap-fetch.h"
#include "imap-sync.h"
#include <stdlib.h>
struct imap_select_context {
struct client_command_context *cmd;
struct mail_storage *storage;
struct imap_fetch_context *fetch_ctx;
unsigned int condstore:1;
};
{
struct seq_range_iter seq_iter;
/* change all n:m ranges to n,m and store the results */
for (i = 0; i < uid_count; i++) {
return -1;
if (diff > 0) {
n += diff - 1;
return -1;
}
}
return -1;
return 0;
}
static bool
{
unsigned int count;
MAILBOX_FEATURE_QRESYNC) == 0) {
return FALSE;
}
"QRESYNC parameters missing");
return FALSE;
}
"Invalid QRESYNC parameters");
return FALSE;
}
if (count > 2) {
"Invalid QRESYNC known-uids");
return FALSE;
}
} else {
}
if (count > 3) {
"Invalid QRESYNC known set parameters");
return FALSE;
}
if (imap_messageset_parse(&seqset,
IMAP_ARG_STR_NONULL(&args[0])) < 0) {
"Invalid QRESYNC known-sequence-set");
return FALSE;
}
if (imap_messageset_parse(&uidset,
"Invalid QRESYNC known-uid-set");
return FALSE;
}
"Invalid QRESYNC sets");
return FALSE;
}
}
return TRUE;
}
static bool
{
const char *name;
"SELECT options contain non-atoms.");
return FALSE;
}
args++;
return FALSE;
args++;
} else {
"Unknown FETCH modifier");
return FALSE;
}
}
return TRUE;
}
{
}
{
if (ret < 0) {
} else {
"OK [READ-ONLY] Select completed." :
"OK [READ-WRITE] Select completed.");
}
}
{
int ret;
/* unfinished */
return FALSE;
}
return TRUE;
}
{
struct imap_fetch_context *fetch_ctx;
struct mail_search_arg *search_arg;
return -1;
(void)imap_fetch_deinit(fetch_ctx);
return -1;
}
if (imap_fetch_begin(fetch_ctx) == 0) {
if (imap_fetch_more(fetch_ctx) == 0) {
/* unfinished */
return FALSE;
}
}
return imap_fetch_deinit(fetch_ctx);
}
static int
{
struct mailbox_status status;
enum mailbox_open_flags open_flags = 0;
if (readonly)
return -1;
if (client->enabled_features != 0)
STATUS_HIGHESTMODSEQ, &status) < 0)
return -1;
client->select_counter++;
if (status.first_unseen_seq != 0) {
t_strdup_printf("* OK [UNSEEN %u] First unseen.",
}
t_strdup_printf("* OK [UIDVALIDITY %u] UIDs valid",
t_strdup_printf("* OK [UIDNEXT %u] Predicted next UID",
if (status.highest_modseq == 0) {
"* OK [NOMODSEQ] No permanent modsequences");
} else {
t_strdup_printf("* OK [HIGHESTMODSEQ %llu]",
(unsigned long long)status.highest_modseq));
}
if (select_qresync(ctx) < 0)
return -1;
}
return 0;
}
{
struct imap_select_context *ctx;
const char *mailbox;
int ret;
/* <mailbox> [(optional parameters)] */
return FALSE;
return FALSE;
}
return TRUE;
return TRUE;
}
}
if (mailbox_close(&box) < 0) {
}
/* CLOSED response is required by QRESYNC */
}
/* Enable while no mailbox is opened to avoid sending
HIGHESTMODSEQ for previously opened mailbox */
}
return TRUE;
}
{
}