Mercurial > dovecot > core-2.2
diff src/lib-storage/index/index-storage.c @ 175:73bf05a1d862 HEAD
Moved custom flags handling into lib-index.
author | Timo Sirainen <tss@iki.fi> |
---|---|
date | Sun, 08 Sep 2002 02:31:56 +0300 |
parents | 4716cf66c2cc |
children | 95d21ab87eeb |
line wrap: on
line diff
--- a/src/lib-storage/index/index-storage.c Sat Sep 07 22:01:14 2002 +0300 +++ b/src/lib-storage/index/index-storage.c Sun Sep 08 02:31:56 2002 +0300 @@ -3,6 +3,7 @@ #include "lib.h" #include "mail-index.h" #include "mail-index-util.h" +#include "mail-custom-flags.h" #include "index-storage.h" IndexMailbox *index_storage_init(MailStorage *storage, Mailbox *box, @@ -10,8 +11,6 @@ int readonly) { IndexMailbox *ibox; - FlagsFile *flagsfile; - const char *path; i_assert(name != NULL); @@ -22,14 +21,6 @@ return NULL; } - /* then flags file */ - path = t_strconcat(index->dir, "/", FLAGS_FILE_NAME, NULL); - flagsfile = flags_file_open_or_create(storage, path); - if (flagsfile == NULL) { - index->free(index); - return NULL; - } - ibox = i_new(IndexMailbox, 1); ibox->box = *box; @@ -38,7 +29,6 @@ ibox->box.readonly = readonly; ibox->index = index; - ibox->flagsfile = flagsfile; ibox->cache = imap_msgcache_alloc(&index_msgcache_iface); return ibox; @@ -48,7 +38,6 @@ { IndexMailbox *ibox = (IndexMailbox *) box; - flags_file_destroy(ibox->flagsfile); imap_msgcache_free(ibox->cache); ibox->index->free(ibox->index); i_free(box->name); @@ -64,26 +53,21 @@ return FALSE; } -static MailFlags get_used_flags(void *context) +int index_mailbox_fix_custom_flags(IndexMailbox *ibox, MailFlags *flags, + const char *custom_flags[]) { - IndexMailbox *ibox = context; - MailIndexRecord *rec; - MailFlags used_flags; - - used_flags = 0; + int ret; - rec = ibox->index->lookup(ibox->index, 1); - while (rec != NULL) { - used_flags |= rec->msg_flags; - rec = ibox->index->next(ibox->index, rec); + ret = mail_custom_flags_fix_list(ibox->index->custom_flags, + flags, custom_flags); + switch (ret) { + case 1: + return TRUE; + case 0: + mail_storage_set_error(ibox->box.storage, "Maximum number of " + "different custom flags exceeded"); + return FALSE; + default: + return mail_storage_set_index_error(ibox); } - - return used_flags; } - -int index_mailbox_fix_custom_flags(IndexMailbox *ibox, MailFlags *flags, - const char *custom_flags[]) -{ - return flags_file_fix_custom_flags(ibox->flagsfile, flags, - custom_flags, get_used_flags, ibox); -}