imap-commands-util.c revision 921a0bd6baf92fd83889c11b60d7275c59b61ab2
/* Copyright (c) 2002-2010 Dovecot authors, see the included COPYING file */
#include "imap-common.h"
#include "array.h"
#include "buffer.h"
#include "str.h"
#include "str-sanitize.h"
#include "imap-resp-code.h"
#include "imap-parser.h"
#include "imap-sync.h"
#include "imap-util.h"
#include "mail-storage.h"
#include "mail-namespace.h"
#include "imap-commands-util.h"
/* Maximum length for mailbox name, including it's path. This isn't fully
exact since the user can create folder hierarchy with small names, then
rename them to larger names. Mail storages should set more strict limits
#define MAILBOX_MAX_NAME_LEN 512
struct mail_namespace *
const char **storage_name_r,
{
struct mail_namespace *ns;
const char *storage_name, *p;
unsigned int storage_name_len;
"NO Client tried to access nonexistent namespace. "
"(Mailbox name should probably be prefixed with: %s)",
return NULL;
}
if (mailbox_status_r == NULL) {
return ns;
}
/* make sure it even looks valid */
return NULL;
}
WORKAROUND_TB_EXTRA_MAILBOX_SEP) != 0 &&
storage_name_len > 0 &&
/* drop the extra trailing hierarchy separator */
}
/* make sure there are no real separators used in the mailbox
name. */
for (p = mailbox; *p != '\0'; p++) {
"NO Character not allowed "
"in mailbox name: '%c'",
return NULL;
}
}
}
/* make sure two hierarchy separators aren't next to each others */
return NULL;
}
}
if (storage_name_len > MAILBOX_MAX_NAME_LEN) {
return NULL;
}
/* check what our storage thinks of it */
mailbox_status_r) < 0) {
return NULL;
}
return ns;
}
const char *mailbox_name,
const char *resp_code,
enum mailbox_name_status status)
{
switch (status) {
case MAILBOX_NAME_EXISTS_DIR:
"NO [", IMAP_RESP_CODE_ALREADYEXISTS,
"] Mailbox already exists: ",
NULL));
break;
case MAILBOX_NAME_VALID:
resp_code = "";
else
NULL));
break;
case MAILBOX_NAME_INVALID:
"NO Invalid mailbox name: ",
NULL));
break;
case MAILBOX_NAME_NOINFERIORS:
"NO Parent mailbox doesn't allow child mailboxes.");
break;
}
}
{
return TRUE;
else {
return FALSE;
}
}
const char *
{
switch (error) {
case MAIL_ERROR_NONE:
break;
case MAIL_ERROR_TEMP:
break;
case MAIL_ERROR_NOTPOSSIBLE:
case MAIL_ERROR_PARAMS:
break;
case MAIL_ERROR_PERM:
break;
case MAIL_ERROR_NOSPACE:
break;
case MAIL_ERROR_NOTFOUND:
break;
case MAIL_ERROR_EXISTS:
break;
case MAIL_ERROR_EXPUNGED:
break;
case MAIL_ERROR_INUSE:
break;
}
else
}
struct mailbox_list *list)
{
const char *error_string;
enum mail_error error;
error));
}
struct mail_storage *storage)
{
const char *error_string;
enum mail_error error;
/* we can't do forced CLOSE, so have to disconnect */
"IMAP session state is inconsistent, please relogin.");
return;
}
error));
}
struct mail_storage *storage)
{
const char *error_string;
enum mail_error error;
/* we can't do forced CLOSE, so have to disconnect */
"IMAP session state is inconsistent, please relogin.");
return;
}
}
enum mail_flags *flags_r,
const char *const **keywords_r)
{
const char *atom;
enum mail_flags flag;
ARRAY_DEFINE(keywords, const char *);
*flags_r = 0;
*keywords_r = NULL;
while (!IMAP_ARG_IS_EOL(args)) {
"Flags list contains non-atoms.");
return FALSE;
}
if (*atom == '\\') {
/* system flag */
else {
"BAD Invalid system flag ",
return FALSE;
}
} else {
/* keyword validity checks are done by lib-storage */
}
args++;
}
if (array_count(&keywords) == 0)
*keywords_r = NULL;
else {
}
return TRUE;
}
{
const char *const *names;
}
}
#define SYSTEM_FLAGS "\\Answered \\Flagged \\Deleted \\Seen \\Draft"
{
const char *str;
/* no changes to keywords and we're not selecting a mailbox */
return;
}
"Read-only mailbox.");
} else {
")] Flags permitted.", NULL));
}
}
{
}
const char *const *
{
const unsigned int *kw_indexes;
const char *const *all_names;
unsigned int all_count;
/* convert indexes to names */
unsigned int kw_index = *kw_indexes;
}
(void)array_append_space(dest);
}
{
const char *name1;
return FALSE;
return TRUE;
}
{
}
{
;
else {
}
}
}
{
else
}