commands-util.c revision cb44b8fd1fa5cac5a451c39245c878e1307c332c
/* Copyright (C) 2002-2003 Timo Sirainen */
#include "common.h"
#include "array.h"
#include "buffer.h"
#include "str.h"
#include "str-sanitize.h"
#include "mail-storage.h"
#include "commands-util.h"
#include "imap-parser.h"
#include "imap-sync.h"
#include "imap-util.h"
#include "mail-namespace.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 *
{
struct mail_namespace *ns;
return ns;
return NULL;
}
struct mail_storage *
{
struct mail_namespace *ns;
}
const char *mailbox,
bool should_exist, bool should_not_exist)
{
struct mail_namespace *ns;
struct mailbox_list *list;
const char *orig_mailbox, *p;
return FALSE;
/* make sure it even looks valid */
if (*mailbox == '\0') {
return FALSE;
}
/* make sure there are no real separators used in the mailbox
name. */
for (p = orig_mailbox; *p != '\0'; p++) {
"NO Character not allowed "
"in mailbox name: '%c'",
return FALSE;
}
}
}
/* make sure two hierarchy separators aren't next to each others */
return FALSE;
}
}
return FALSE;
}
/* check what our storage thinks of it */
&mailbox_status) < 0) {
return FALSE;
}
switch (mailbox_status) {
case MAILBOX_NAME_EXISTS:
if (should_exist || !should_not_exist)
return TRUE;
break;
case MAILBOX_NAME_VALID:
if (!should_exist)
return TRUE;
"NO [TRYCREATE] Mailbox doesn't exist: ",
NULL));
break;
case MAILBOX_NAME_INVALID:
"NO Invalid mailbox name: ",
NULL));
break;
case MAILBOX_NAME_NOINFERIORS:
"NO Mailbox parent doesn't allow inferior mailboxes.");
break;
default:
i_unreached();
}
return FALSE;
}
{
return TRUE;
else {
return FALSE;
}
}
struct mail_storage *storage)
{
const char *error;
bool temporary_error;
/* we can't do forced CLOSE, so have to disconnect */
"Mailbox is in inconsistent state, please relogin.");
return;
}
}
struct mail_storage *storage)
{
const char *error;
bool temporary_error;
/* we can't do forced CLOSE, so have to disconnect */
"Mailbox is in inconsistent state, please relogin.");
return;
}
}
const char *keyword)
{
const char *const *names;
unsigned int i, count;
/* if it already exists, skip validity checks */
for (i = 0; i < count; i++) {
return TRUE;
}
}
t_strdup_printf("BAD Invalid keyword name '%s': "
"Maximum length is %u characters",
return FALSE;
}
return TRUE;
}
const char *const **keywords_r)
{
const char *const *keywords;
char *atom;
*flags_r = 0;
*keywords_r = NULL;
"Flags list contains non-atoms.");
return FALSE;
}
if (*atom == '\\') {
/* system flag */
*flags_r |= MAIL_ANSWERED;
*flags_r |= MAIL_FLAGGED;
*flags_r |= MAIL_DELETED;
*flags_r |= MAIL_DRAFT;
else {
"BAD Invalid system flag ",
return FALSE;
}
} else {
/* keyword - first make sure it's not a duplicate */
size /= sizeof(const char *);
for (i = 0; i < size; i++) {
break;
}
if (i == size) {
return FALSE;
}
}
args++;
}
return TRUE;
}
{
const char *const *names;
unsigned int i, count;
if (array_count(keywords) == 0)
return "";
for (i = 0; i < count; i++) {
}
}
#define SYSTEM_FLAGS "\\Answered \\Flagged \\Deleted \\Seen \\Draft"
{
const char *str;
if (mailbox_is_readonly(box)) {
"Read-only mailbox.");
} else {
}
}
{
bool changed;
/* first check if anything changes */
else {
else {
for (i = 0; i < count; i++) {
break;
}
}
}
}
if (!changed)
return FALSE;
for (i = 0; i < count; i++) {
}
return TRUE;
}
const char *name2)
{
const char *name1;
return FALSE;
return TRUE;
}
{
}
{
;
else {
}
}
}
{
else
}