Mercurial > dovecot > core-2.2
annotate src/lib-storage/index/index-storage.c @ 171:4716cf66c2cc HEAD
Moved lib-index/mail-messageset.* to lib-storage/index/index-messageset.*.
author | Timo Sirainen <tss@iki.fi> |
---|---|
date | Sat, 07 Sep 2002 04:52:21 +0300 |
parents | 0c3ffb677ad1 |
children | 73bf05a1d862 |
rev | line source |
---|---|
0 | 1 /* Copyright (C) 2002 Timo Sirainen */ |
2 | |
3 #include "lib.h" | |
4 #include "mail-index.h" | |
114
0c3ffb677ad1
Reset index error message after it's been moved to storage.
Timo Sirainen <tss@iki.fi>
parents:
106
diff
changeset
|
5 #include "mail-index-util.h" |
0 | 6 #include "index-storage.h" |
7 | |
8 IndexMailbox *index_storage_init(MailStorage *storage, Mailbox *box, | |
9 MailIndex *index, const char *name, | |
10 int readonly) | |
11 { | |
12 IndexMailbox *ibox; | |
13 FlagsFile *flagsfile; | |
13
bb294faf7379
"Critical errors" aren't displayed to users anymore, ie. anything that is
Timo Sirainen <tss@iki.fi>
parents:
10
diff
changeset
|
14 const char *path; |
0 | 15 |
16 i_assert(name != NULL); | |
17 | |
18 /* open the index first */ | |
19 if (!index->open_or_create(index, !readonly)) { | |
13
bb294faf7379
"Critical errors" aren't displayed to users anymore, ie. anything that is
Timo Sirainen <tss@iki.fi>
parents:
10
diff
changeset
|
20 mail_storage_set_internal_error(storage); |
0 | 21 index->free(index); |
22 return NULL; | |
23 } | |
24 | |
25 /* then flags file */ | |
26 path = t_strconcat(index->dir, "/", FLAGS_FILE_NAME, NULL); | |
27 flagsfile = flags_file_open_or_create(storage, path); | |
28 if (flagsfile == NULL) { | |
29 index->free(index); | |
30 return NULL; | |
31 } | |
32 | |
33 ibox = i_new(IndexMailbox, 1); | |
34 ibox->box = *box; | |
35 | |
36 ibox->box.storage = storage; | |
37 ibox->box.name = i_strdup(name); | |
38 ibox->box.readonly = readonly; | |
39 | |
40 ibox->index = index; | |
41 ibox->flagsfile = flagsfile; | |
106
5fe3e04ca8d9
Added support for caching of MessagePart data. This is useful for fetching
Timo Sirainen <tss@iki.fi>
parents:
47
diff
changeset
|
42 ibox->cache = imap_msgcache_alloc(&index_msgcache_iface); |
0 | 43 |
44 return ibox; | |
45 } | |
46 | |
47 void index_storage_close(Mailbox *box) | |
48 { | |
49 IndexMailbox *ibox = (IndexMailbox *) box; | |
50 | |
51 flags_file_destroy(ibox->flagsfile); | |
52 imap_msgcache_free(ibox->cache); | |
53 ibox->index->free(ibox->index); | |
54 i_free(box->name); | |
55 i_free(box); | |
56 } | |
57 | |
58 int mail_storage_set_index_error(IndexMailbox *ibox) | |
59 { | |
60 ibox->box.inconsistent = | |
61 ibox->index->is_inconsistency_error(ibox->index); | |
13
bb294faf7379
"Critical errors" aren't displayed to users anymore, ie. anything that is
Timo Sirainen <tss@iki.fi>
parents:
10
diff
changeset
|
62 mail_storage_set_internal_error(ibox->box.storage); |
114
0c3ffb677ad1
Reset index error message after it's been moved to storage.
Timo Sirainen <tss@iki.fi>
parents:
106
diff
changeset
|
63 index_reset_error(ibox->index); |
0 | 64 return FALSE; |
65 } | |
66 | |
10
82b7de533f98
s/user_data/context/ and some s/Data/Context/
Timo Sirainen <tss@iki.fi>
parents:
0
diff
changeset
|
67 static MailFlags get_used_flags(void *context) |
0 | 68 { |
10
82b7de533f98
s/user_data/context/ and some s/Data/Context/
Timo Sirainen <tss@iki.fi>
parents:
0
diff
changeset
|
69 IndexMailbox *ibox = context; |
0 | 70 MailIndexRecord *rec; |
71 MailFlags used_flags; | |
72 | |
73 used_flags = 0; | |
74 | |
75 rec = ibox->index->lookup(ibox->index, 1); | |
76 while (rec != NULL) { | |
77 used_flags |= rec->msg_flags; | |
78 rec = ibox->index->next(ibox->index, rec); | |
79 } | |
80 | |
81 return used_flags; | |
82 } | |
83 | |
84 int index_mailbox_fix_custom_flags(IndexMailbox *ibox, MailFlags *flags, | |
85 const char *custom_flags[]) | |
86 { | |
87 return flags_file_fix_custom_flags(ibox->flagsfile, flags, | |
88 custom_flags, get_used_flags, ibox); | |
89 } |