cmd-getmetadata.c revision 77b4e728245a1905b1cce68fce9e9b7adf7efc2c
/* Copyright (c) 2013 Dovecot authors, see the included COPYING file */
#include "imap-common.h"
#include "str.h"
#include "istream.h"
#include "ostream.h"
#include "imap-quote.h"
#include "imap-metadata.h"
struct imap_getmetadata_context {
struct client_command_context *cmd;
struct mailbox_transaction_context *trans;
unsigned int depth;
struct istream *cur_stream;
struct mailbox_attribute_iter *iter;
const char *key_prefix;
unsigned int entry_idx;
bool first_entry_sent;
bool failed;
};
static bool
{
const char *value;
while (!IMAP_ARG_IS_EOL(options)) {
options++;
"Invalid value for MAXSIZE option");
return FALSE;
}
options++;
"Invalid value for DEPTH option");
return FALSE;
}
else {
"Invalid value for DEPTH option");
return FALSE;
}
} else {
return FALSE;
}
options++;
}
return TRUE;
}
static bool
{
const char *value;
return FALSE;
}
return FALSE;
/* names are case-insensitive so we'll always lowercase them */
}
return TRUE;
}
const char *entry)
{
enum mail_attribute_type type;
struct mail_attribute_value value;
enum mail_error error;
const char *key;
strlen(MAILBOX_ATTRIBUTE_PREFIX_DOVECOT_PVT)) == 0) {
/* skip over dovecot's internal attributes. (if key_prefix
isn't NULL, we're getting server metadata, which is handled
inside the private metadata.) */
return;
}
}
}
return;
}
} else {
/* skip nonexistent entries */
return;
}
/* value length is larger than specified MAXSIZE,
skip this entry */
return;
}
if (!ctx->first_entry_sent) {
/* nothing can be sent until untagged METADATA is finished */
} else {
}
} else {
ctx->cur_stream_offset = 0;
}
}
static bool
{
if (ret > 0)
/* finished */
return TRUE;
}
i_error("read(%s) failed: %s",
"Internal GETMETADATA failure");
return -1;
}
/* Input stream gave less data than expected */
i_error("read(%s): GETMETADATA stream had less data than expected",
"Internal GETMETADATA failure");
return -1;
}
return FALSE;
}
const char *entry)
{
const char *key;
enum mail_attribute_type type;
return 0;
}
}
/* DEPTH iteration */
do {
/* iteration finished, get to the next entry */
}
return -1;
}
}
return 0;
}
/* already iterating the entry */
return 1;
/* no iteration for the entry */
return -1;
} else {
/* we just sent the entry root. iterate its children. */
return 1;
}
}
{
}
{
const char *const *entries;
unsigned int count;
int ret;
return TRUE;
}
return FALSE;
}
do {
T_BEGIN {
} T_END;
if (ret == 0)
return FALSE;
} while (ret > 0);
}
if (ctx->first_entry_sent)
} else if (ctx->largest_seen_size != 0) {
} else {
}
return TRUE;
}
{
struct imap_getmetadata_context *ctx;
struct mail_namespace *ns;
const char *mailbox, *entry_name;
return FALSE;
return TRUE;
}
return TRUE;
args++;
}
return TRUE;
}
return TRUE;
}
}
return TRUE;
if (mailbox[0] == '\0') {
/* server attribute */
mailbox = "INBOX";
} else {
return TRUE;
}
return TRUE;
}
if (!cmd_getmetadata_continue(cmd)) {
return FALSE;
}
return TRUE;
}