Mercurial > dovecot > original-hg > dovecot-1.2
annotate src/lib-index/mail-index-transaction-view.c @ 2892:62d53b49110d HEAD
Changed mail_index_get_header() to return the header as return value because
it can't fail anymore.
author | Timo Sirainen <tss@iki.fi> |
---|---|
date | Wed, 24 Nov 2004 20:39:57 +0200 |
parents | 173a0296e81d |
children | 642ba9cd3dac |
rev | line source |
---|---|
2224
a816e2d88406
Added mail_index_transaction_get_updated_view() which can be used to access
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
1 /* Copyright (C) 2004 Timo Sirainen */ |
a816e2d88406
Added mail_index_transaction_get_updated_view() which can be used to access
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
2 |
a816e2d88406
Added mail_index_transaction_get_updated_view() which can be used to access
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
3 #include "lib.h" |
a816e2d88406
Added mail_index_transaction_get_updated_view() which can be used to access
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
4 #include "buffer.h" |
a816e2d88406
Added mail_index_transaction_get_updated_view() which can be used to access
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
5 #include "mail-index-private.h" |
a816e2d88406
Added mail_index_transaction_get_updated_view() which can be used to access
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
6 #include "mail-index-view-private.h" |
a816e2d88406
Added mail_index_transaction_get_updated_view() which can be used to access
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
7 #include "mail-index-transaction-private.h" |
a816e2d88406
Added mail_index_transaction_get_updated_view() which can be used to access
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
8 |
a816e2d88406
Added mail_index_transaction_get_updated_view() which can be used to access
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
9 struct mail_index_view_transaction { |
a816e2d88406
Added mail_index_transaction_get_updated_view() which can be used to access
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
10 struct mail_index_view view; |
a816e2d88406
Added mail_index_transaction_get_updated_view() which can be used to access
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
11 struct mail_index_view_methods *parent; |
a816e2d88406
Added mail_index_transaction_get_updated_view() which can be used to access
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
12 struct mail_index_transaction *t; |
a816e2d88406
Added mail_index_transaction_get_updated_view() which can be used to access
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
13 }; |
a816e2d88406
Added mail_index_transaction_get_updated_view() which can be used to access
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
14 |
a816e2d88406
Added mail_index_transaction_get_updated_view() which can be used to access
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
15 static void _tview_close(struct mail_index_view *view) |
a816e2d88406
Added mail_index_transaction_get_updated_view() which can be used to access
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
16 { |
a816e2d88406
Added mail_index_transaction_get_updated_view() which can be used to access
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
17 struct mail_index_view_transaction *tview = |
a816e2d88406
Added mail_index_transaction_get_updated_view() which can be used to access
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
18 (struct mail_index_view_transaction *)view; |
a816e2d88406
Added mail_index_transaction_get_updated_view() which can be used to access
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
19 |
2271
15d959d262a4
UIDs for appended messages can now be assigned all at once. Maildir now
Timo Sirainen <tss@iki.fi>
parents:
2240
diff
changeset
|
20 mail_index_transaction_unref(tview->t); |
2627 | 21 tview->parent->close(view); |
2224
a816e2d88406
Added mail_index_transaction_get_updated_view() which can be used to access
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
22 } |
a816e2d88406
Added mail_index_transaction_get_updated_view() which can be used to access
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
23 |
a816e2d88406
Added mail_index_transaction_get_updated_view() which can be used to access
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
24 static uint32_t _tview_get_message_count(struct mail_index_view *view) |
a816e2d88406
Added mail_index_transaction_get_updated_view() which can be used to access
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
25 { |
a816e2d88406
Added mail_index_transaction_get_updated_view() which can be used to access
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
26 struct mail_index_view_transaction *tview = |
a816e2d88406
Added mail_index_transaction_get_updated_view() which can be used to access
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
27 (struct mail_index_view_transaction *)view; |
a816e2d88406
Added mail_index_transaction_get_updated_view() which can be used to access
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
28 |
a816e2d88406
Added mail_index_transaction_get_updated_view() which can be used to access
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
29 return view->messages_count + |
a816e2d88406
Added mail_index_transaction_get_updated_view() which can be used to access
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
30 (tview->t->last_new_seq == 0 ? 0 : |
a816e2d88406
Added mail_index_transaction_get_updated_view() which can be used to access
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
31 tview->t->last_new_seq - tview->t->first_new_seq); |
a816e2d88406
Added mail_index_transaction_get_updated_view() which can be used to access
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
32 } |
a816e2d88406
Added mail_index_transaction_get_updated_view() which can be used to access
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
33 |
2892
62d53b49110d
Changed mail_index_get_header() to return the header as return value because
Timo Sirainen <tss@iki.fi>
parents:
2884
diff
changeset
|
34 static const struct mail_index_header * |
62d53b49110d
Changed mail_index_get_header() to return the header as return value because
Timo Sirainen <tss@iki.fi>
parents:
2884
diff
changeset
|
35 _tview_get_header(struct mail_index_view *view) |
2224
a816e2d88406
Added mail_index_transaction_get_updated_view() which can be used to access
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
36 { |
a816e2d88406
Added mail_index_transaction_get_updated_view() which can be used to access
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
37 struct mail_index_view_transaction *tview = |
a816e2d88406
Added mail_index_transaction_get_updated_view() which can be used to access
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
38 (struct mail_index_view_transaction *)view; |
a816e2d88406
Added mail_index_transaction_get_updated_view() which can be used to access
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
39 |
2884
173a0296e81d
Update view's header only after syncing the view. This and other changes fix
Timo Sirainen <tss@iki.fi>
parents:
2853
diff
changeset
|
40 /* FIXME: header counters may not be correct */ |
2892
62d53b49110d
Changed mail_index_get_header() to return the header as return value because
Timo Sirainen <tss@iki.fi>
parents:
2884
diff
changeset
|
41 return tview->parent->get_header(view); |
2224
a816e2d88406
Added mail_index_transaction_get_updated_view() which can be used to access
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
42 } |
a816e2d88406
Added mail_index_transaction_get_updated_view() which can be used to access
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
43 |
a816e2d88406
Added mail_index_transaction_get_updated_view() which can be used to access
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
44 static int _tview_lookup_full(struct mail_index_view *view, uint32_t seq, |
a816e2d88406
Added mail_index_transaction_get_updated_view() which can be used to access
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
45 struct mail_index_map **map_r, |
a816e2d88406
Added mail_index_transaction_get_updated_view() which can be used to access
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
46 const struct mail_index_record **rec_r) |
a816e2d88406
Added mail_index_transaction_get_updated_view() which can be used to access
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
47 { |
a816e2d88406
Added mail_index_transaction_get_updated_view() which can be used to access
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
48 struct mail_index_view_transaction *tview = |
a816e2d88406
Added mail_index_transaction_get_updated_view() which can be used to access
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
49 (struct mail_index_view_transaction *)view; |
a816e2d88406
Added mail_index_transaction_get_updated_view() which can be used to access
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
50 |
a816e2d88406
Added mail_index_transaction_get_updated_view() which can be used to access
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
51 if (seq >= tview->t->first_new_seq) { |
a816e2d88406
Added mail_index_transaction_get_updated_view() which can be used to access
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
52 /* FIXME: is this right to return index map..? |
a816e2d88406
Added mail_index_transaction_get_updated_view() which can be used to access
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
53 it's not there yet. */ |
a816e2d88406
Added mail_index_transaction_get_updated_view() which can be used to access
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
54 *map_r = view->index->map; |
a816e2d88406
Added mail_index_transaction_get_updated_view() which can be used to access
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
55 *rec_r = mail_index_transaction_lookup(tview->t, seq); |
a816e2d88406
Added mail_index_transaction_get_updated_view() which can be used to access
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
56 return 1; |
a816e2d88406
Added mail_index_transaction_get_updated_view() which can be used to access
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
57 } else { |
a816e2d88406
Added mail_index_transaction_get_updated_view() which can be used to access
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
58 return tview->parent->lookup_full(view, seq, map_r, rec_r); |
a816e2d88406
Added mail_index_transaction_get_updated_view() which can be used to access
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
59 } |
a816e2d88406
Added mail_index_transaction_get_updated_view() which can be used to access
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
60 } |
a816e2d88406
Added mail_index_transaction_get_updated_view() which can be used to access
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
61 |
a816e2d88406
Added mail_index_transaction_get_updated_view() which can be used to access
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
62 static int _tview_lookup_uid(struct mail_index_view *view, uint32_t seq, |
a816e2d88406
Added mail_index_transaction_get_updated_view() which can be used to access
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
63 uint32_t *uid_r) |
a816e2d88406
Added mail_index_transaction_get_updated_view() which can be used to access
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
64 { |
a816e2d88406
Added mail_index_transaction_get_updated_view() which can be used to access
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
65 struct mail_index_view_transaction *tview = |
a816e2d88406
Added mail_index_transaction_get_updated_view() which can be used to access
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
66 (struct mail_index_view_transaction *)view; |
a816e2d88406
Added mail_index_transaction_get_updated_view() which can be used to access
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
67 |
a816e2d88406
Added mail_index_transaction_get_updated_view() which can be used to access
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
68 if (seq >= tview->t->first_new_seq) { |
a816e2d88406
Added mail_index_transaction_get_updated_view() which can be used to access
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
69 *uid_r = mail_index_transaction_lookup(tview->t, seq)->uid; |
a816e2d88406
Added mail_index_transaction_get_updated_view() which can be used to access
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
70 return 0; |
a816e2d88406
Added mail_index_transaction_get_updated_view() which can be used to access
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
71 } else { |
a816e2d88406
Added mail_index_transaction_get_updated_view() which can be used to access
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
72 return tview->parent->lookup_uid(view, seq, uid_r); |
a816e2d88406
Added mail_index_transaction_get_updated_view() which can be used to access
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
73 } |
a816e2d88406
Added mail_index_transaction_get_updated_view() which can be used to access
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
74 } |
a816e2d88406
Added mail_index_transaction_get_updated_view() which can be used to access
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
75 |
a816e2d88406
Added mail_index_transaction_get_updated_view() which can be used to access
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
76 static int _tview_lookup_uid_range(struct mail_index_view *view, |
a816e2d88406
Added mail_index_transaction_get_updated_view() which can be used to access
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
77 uint32_t first_uid, uint32_t last_uid, |
a816e2d88406
Added mail_index_transaction_get_updated_view() which can be used to access
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
78 uint32_t *first_seq_r, uint32_t *last_seq_r) |
a816e2d88406
Added mail_index_transaction_get_updated_view() which can be used to access
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
79 { |
a816e2d88406
Added mail_index_transaction_get_updated_view() which can be used to access
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
80 struct mail_index_view_transaction *tview = |
a816e2d88406
Added mail_index_transaction_get_updated_view() which can be used to access
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
81 (struct mail_index_view_transaction *)view; |
a816e2d88406
Added mail_index_transaction_get_updated_view() which can be used to access
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
82 |
a816e2d88406
Added mail_index_transaction_get_updated_view() which can be used to access
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
83 if (tview->parent->lookup_uid_range(view, first_uid, last_uid, |
a816e2d88406
Added mail_index_transaction_get_updated_view() which can be used to access
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
84 first_seq_r, last_seq_r) < 0) |
a816e2d88406
Added mail_index_transaction_get_updated_view() which can be used to access
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
85 return -1; |
a816e2d88406
Added mail_index_transaction_get_updated_view() which can be used to access
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
86 |
a816e2d88406
Added mail_index_transaction_get_updated_view() which can be used to access
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
87 /* FIXME: we don't need this function yet.. new UIDs might be 0 as |
a816e2d88406
Added mail_index_transaction_get_updated_view() which can be used to access
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
88 well.. */ |
a816e2d88406
Added mail_index_transaction_get_updated_view() which can be used to access
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
89 |
a816e2d88406
Added mail_index_transaction_get_updated_view() which can be used to access
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
90 if (*first_seq_r == 0) { |
a816e2d88406
Added mail_index_transaction_get_updated_view() which can be used to access
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
91 /* nothing found, either doesn't exist or it's completely |
a816e2d88406
Added mail_index_transaction_get_updated_view() which can be used to access
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
92 newly appended. */ |
a816e2d88406
Added mail_index_transaction_get_updated_view() which can be used to access
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
93 } else if (*last_seq_r + 1 == tview->t->first_new_seq) { |
a816e2d88406
Added mail_index_transaction_get_updated_view() which can be used to access
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
94 /* last_seq_r may be growed from transactions */ |
a816e2d88406
Added mail_index_transaction_get_updated_view() which can be used to access
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
95 } |
a816e2d88406
Added mail_index_transaction_get_updated_view() which can be used to access
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
96 |
a816e2d88406
Added mail_index_transaction_get_updated_view() which can be used to access
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
97 return 0; |
a816e2d88406
Added mail_index_transaction_get_updated_view() which can be used to access
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
98 } |
a816e2d88406
Added mail_index_transaction_get_updated_view() which can be used to access
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
99 |
a816e2d88406
Added mail_index_transaction_get_updated_view() which can be used to access
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
100 static int _tview_lookup_first(struct mail_index_view *view, |
a816e2d88406
Added mail_index_transaction_get_updated_view() which can be used to access
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
101 enum mail_flags flags, uint8_t flags_mask, |
a816e2d88406
Added mail_index_transaction_get_updated_view() which can be used to access
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
102 uint32_t *seq_r) |
a816e2d88406
Added mail_index_transaction_get_updated_view() which can be used to access
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
103 { |
a816e2d88406
Added mail_index_transaction_get_updated_view() which can be used to access
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
104 struct mail_index_view_transaction *tview = |
a816e2d88406
Added mail_index_transaction_get_updated_view() which can be used to access
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
105 (struct mail_index_view_transaction *)view; |
a816e2d88406
Added mail_index_transaction_get_updated_view() which can be used to access
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
106 const struct mail_index_record *rec; |
a816e2d88406
Added mail_index_transaction_get_updated_view() which can be used to access
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
107 uint32_t seq, message_count; |
a816e2d88406
Added mail_index_transaction_get_updated_view() which can be used to access
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
108 |
a816e2d88406
Added mail_index_transaction_get_updated_view() which can be used to access
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
109 if (tview->parent->lookup_first(view, flags, flags_mask, seq_r) < 0) |
a816e2d88406
Added mail_index_transaction_get_updated_view() which can be used to access
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
110 return -1; |
a816e2d88406
Added mail_index_transaction_get_updated_view() which can be used to access
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
111 |
a816e2d88406
Added mail_index_transaction_get_updated_view() which can be used to access
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
112 if (*seq_r != 0) |
a816e2d88406
Added mail_index_transaction_get_updated_view() which can be used to access
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
113 return 0; |
a816e2d88406
Added mail_index_transaction_get_updated_view() which can be used to access
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
114 |
a816e2d88406
Added mail_index_transaction_get_updated_view() which can be used to access
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
115 rec = buffer_get_data(tview->t->appends, NULL); |
a816e2d88406
Added mail_index_transaction_get_updated_view() which can be used to access
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
116 seq = tview->t->first_new_seq; |
a816e2d88406
Added mail_index_transaction_get_updated_view() which can be used to access
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
117 message_count = tview->t->last_new_seq; |
2563
5752e5ac88f0
Save extra record/header infos into index file permanently.
Timo Sirainen <tss@iki.fi>
parents:
2271
diff
changeset
|
118 for (; seq <= message_count; seq++, rec++) { |
2224
a816e2d88406
Added mail_index_transaction_get_updated_view() which can be used to access
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
119 if ((rec->flags & flags_mask) == (uint8_t)flags) { |
a816e2d88406
Added mail_index_transaction_get_updated_view() which can be used to access
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
120 *seq_r = seq; |
a816e2d88406
Added mail_index_transaction_get_updated_view() which can be used to access
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
121 break; |
a816e2d88406
Added mail_index_transaction_get_updated_view() which can be used to access
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
122 } |
a816e2d88406
Added mail_index_transaction_get_updated_view() which can be used to access
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
123 } |
a816e2d88406
Added mail_index_transaction_get_updated_view() which can be used to access
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
124 |
a816e2d88406
Added mail_index_transaction_get_updated_view() which can be used to access
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
125 return 0; |
a816e2d88406
Added mail_index_transaction_get_updated_view() which can be used to access
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
126 } |
a816e2d88406
Added mail_index_transaction_get_updated_view() which can be used to access
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
127 |
2853
512dd7d76cdc
Removed cache_offset from mail_index_record and changed it to use extension
Timo Sirainen <tss@iki.fi>
parents:
2671
diff
changeset
|
128 static int |
512dd7d76cdc
Removed cache_offset from mail_index_record and changed it to use extension
Timo Sirainen <tss@iki.fi>
parents:
2671
diff
changeset
|
129 _tview_lookup_ext_full(struct mail_index_view *view, uint32_t seq, |
512dd7d76cdc
Removed cache_offset from mail_index_record and changed it to use extension
Timo Sirainen <tss@iki.fi>
parents:
2671
diff
changeset
|
130 uint32_t ext_id, struct mail_index_map **map_r, |
512dd7d76cdc
Removed cache_offset from mail_index_record and changed it to use extension
Timo Sirainen <tss@iki.fi>
parents:
2671
diff
changeset
|
131 const void **data_r) |
2563
5752e5ac88f0
Save extra record/header infos into index file permanently.
Timo Sirainen <tss@iki.fi>
parents:
2271
diff
changeset
|
132 { |
5752e5ac88f0
Save extra record/header infos into index file permanently.
Timo Sirainen <tss@iki.fi>
parents:
2271
diff
changeset
|
133 struct mail_index_view_transaction *tview = |
5752e5ac88f0
Save extra record/header infos into index file permanently.
Timo Sirainen <tss@iki.fi>
parents:
2271
diff
changeset
|
134 (struct mail_index_view_transaction *)view; |
2671
3b70ddb51771
Renamed "extra record info" and variations of it to "extension" or "ext" in
Timo Sirainen <tss@iki.fi>
parents:
2627
diff
changeset
|
135 const struct mail_index_ext *ext; |
3b70ddb51771
Renamed "extra record info" and variations of it to "extension" or "ext" in
Timo Sirainen <tss@iki.fi>
parents:
2627
diff
changeset
|
136 buffer_t *const *ext_bufs; |
2563
5752e5ac88f0
Save extra record/header infos into index file permanently.
Timo Sirainen <tss@iki.fi>
parents:
2271
diff
changeset
|
137 size_t size, pos; |
5752e5ac88f0
Save extra record/header infos into index file permanently.
Timo Sirainen <tss@iki.fi>
parents:
2271
diff
changeset
|
138 |
2671
3b70ddb51771
Renamed "extra record info" and variations of it to "extension" or "ext" in
Timo Sirainen <tss@iki.fi>
parents:
2627
diff
changeset
|
139 i_assert(ext_id < view->index->extensions->used / sizeof(*ext)); |
2563
5752e5ac88f0
Save extra record/header infos into index file permanently.
Timo Sirainen <tss@iki.fi>
parents:
2271
diff
changeset
|
140 |
2671
3b70ddb51771
Renamed "extra record info" and variations of it to "extension" or "ext" in
Timo Sirainen <tss@iki.fi>
parents:
2627
diff
changeset
|
141 ext = view->index->extensions->data; |
3b70ddb51771
Renamed "extra record info" and variations of it to "extension" or "ext" in
Timo Sirainen <tss@iki.fi>
parents:
2627
diff
changeset
|
142 ext += ext_id; |
2563
5752e5ac88f0
Save extra record/header infos into index file permanently.
Timo Sirainen <tss@iki.fi>
parents:
2271
diff
changeset
|
143 |
2853
512dd7d76cdc
Removed cache_offset from mail_index_record and changed it to use extension
Timo Sirainen <tss@iki.fi>
parents:
2671
diff
changeset
|
144 if (tview->t->ext_rec_updates == NULL) { |
512dd7d76cdc
Removed cache_offset from mail_index_record and changed it to use extension
Timo Sirainen <tss@iki.fi>
parents:
2671
diff
changeset
|
145 ext_bufs = NULL; |
512dd7d76cdc
Removed cache_offset from mail_index_record and changed it to use extension
Timo Sirainen <tss@iki.fi>
parents:
2671
diff
changeset
|
146 size = 0; |
512dd7d76cdc
Removed cache_offset from mail_index_record and changed it to use extension
Timo Sirainen <tss@iki.fi>
parents:
2671
diff
changeset
|
147 } else { |
512dd7d76cdc
Removed cache_offset from mail_index_record and changed it to use extension
Timo Sirainen <tss@iki.fi>
parents:
2671
diff
changeset
|
148 ext_bufs = buffer_get_data(tview->t->ext_rec_updates, &size); |
512dd7d76cdc
Removed cache_offset from mail_index_record and changed it to use extension
Timo Sirainen <tss@iki.fi>
parents:
2671
diff
changeset
|
149 size /= sizeof(*ext_bufs); |
512dd7d76cdc
Removed cache_offset from mail_index_record and changed it to use extension
Timo Sirainen <tss@iki.fi>
parents:
2671
diff
changeset
|
150 } |
2563
5752e5ac88f0
Save extra record/header infos into index file permanently.
Timo Sirainen <tss@iki.fi>
parents:
2271
diff
changeset
|
151 |
2853
512dd7d76cdc
Removed cache_offset from mail_index_record and changed it to use extension
Timo Sirainen <tss@iki.fi>
parents:
2671
diff
changeset
|
152 *map_r = view->index->map; |
2671
3b70ddb51771
Renamed "extra record info" and variations of it to "extension" or "ext" in
Timo Sirainen <tss@iki.fi>
parents:
2627
diff
changeset
|
153 if (size <= ext_id || ext_bufs[ext_id] == NULL || |
3b70ddb51771
Renamed "extra record info" and variations of it to "extension" or "ext" in
Timo Sirainen <tss@iki.fi>
parents:
2627
diff
changeset
|
154 !mail_index_seq_buffer_lookup(ext_bufs[ext_id], seq, |
3b70ddb51771
Renamed "extra record info" and variations of it to "extension" or "ext" in
Timo Sirainen <tss@iki.fi>
parents:
2627
diff
changeset
|
155 ext->record_size, &pos)) { |
2853
512dd7d76cdc
Removed cache_offset from mail_index_record and changed it to use extension
Timo Sirainen <tss@iki.fi>
parents:
2671
diff
changeset
|
156 /* not updated, return the existing value */ |
512dd7d76cdc
Removed cache_offset from mail_index_record and changed it to use extension
Timo Sirainen <tss@iki.fi>
parents:
2671
diff
changeset
|
157 if (seq < tview->t->first_new_seq) { |
512dd7d76cdc
Removed cache_offset from mail_index_record and changed it to use extension
Timo Sirainen <tss@iki.fi>
parents:
2671
diff
changeset
|
158 return tview->parent->lookup_ext_full(view, seq, ext_id, |
512dd7d76cdc
Removed cache_offset from mail_index_record and changed it to use extension
Timo Sirainen <tss@iki.fi>
parents:
2671
diff
changeset
|
159 map_r, data_r); |
512dd7d76cdc
Removed cache_offset from mail_index_record and changed it to use extension
Timo Sirainen <tss@iki.fi>
parents:
2671
diff
changeset
|
160 } |
512dd7d76cdc
Removed cache_offset from mail_index_record and changed it to use extension
Timo Sirainen <tss@iki.fi>
parents:
2671
diff
changeset
|
161 |
2563
5752e5ac88f0
Save extra record/header infos into index file permanently.
Timo Sirainen <tss@iki.fi>
parents:
2271
diff
changeset
|
162 *data_r = NULL; |
5752e5ac88f0
Save extra record/header infos into index file permanently.
Timo Sirainen <tss@iki.fi>
parents:
2271
diff
changeset
|
163 return 1; |
5752e5ac88f0
Save extra record/header infos into index file permanently.
Timo Sirainen <tss@iki.fi>
parents:
2271
diff
changeset
|
164 } |
5752e5ac88f0
Save extra record/header infos into index file permanently.
Timo Sirainen <tss@iki.fi>
parents:
2271
diff
changeset
|
165 |
2671
3b70ddb51771
Renamed "extra record info" and variations of it to "extension" or "ext" in
Timo Sirainen <tss@iki.fi>
parents:
2627
diff
changeset
|
166 *data_r = CONST_PTR_OFFSET(ext_bufs[ext_id]->data, pos); |
2563
5752e5ac88f0
Save extra record/header infos into index file permanently.
Timo Sirainen <tss@iki.fi>
parents:
2271
diff
changeset
|
167 return 1; |
5752e5ac88f0
Save extra record/header infos into index file permanently.
Timo Sirainen <tss@iki.fi>
parents:
2271
diff
changeset
|
168 } |
5752e5ac88f0
Save extra record/header infos into index file permanently.
Timo Sirainen <tss@iki.fi>
parents:
2271
diff
changeset
|
169 |
2853
512dd7d76cdc
Removed cache_offset from mail_index_record and changed it to use extension
Timo Sirainen <tss@iki.fi>
parents:
2671
diff
changeset
|
170 static int _tview_get_header_ext(struct mail_index_view *view, |
512dd7d76cdc
Removed cache_offset from mail_index_record and changed it to use extension
Timo Sirainen <tss@iki.fi>
parents:
2671
diff
changeset
|
171 struct mail_index_map *map, uint32_t ext_id, |
512dd7d76cdc
Removed cache_offset from mail_index_record and changed it to use extension
Timo Sirainen <tss@iki.fi>
parents:
2671
diff
changeset
|
172 const void **data_r, size_t *data_size_r) |
512dd7d76cdc
Removed cache_offset from mail_index_record and changed it to use extension
Timo Sirainen <tss@iki.fi>
parents:
2671
diff
changeset
|
173 { |
512dd7d76cdc
Removed cache_offset from mail_index_record and changed it to use extension
Timo Sirainen <tss@iki.fi>
parents:
2671
diff
changeset
|
174 struct mail_index_view_transaction *tview = |
512dd7d76cdc
Removed cache_offset from mail_index_record and changed it to use extension
Timo Sirainen <tss@iki.fi>
parents:
2671
diff
changeset
|
175 (struct mail_index_view_transaction *)view; |
512dd7d76cdc
Removed cache_offset from mail_index_record and changed it to use extension
Timo Sirainen <tss@iki.fi>
parents:
2671
diff
changeset
|
176 |
512dd7d76cdc
Removed cache_offset from mail_index_record and changed it to use extension
Timo Sirainen <tss@iki.fi>
parents:
2671
diff
changeset
|
177 /* FIXME: check updates */ |
512dd7d76cdc
Removed cache_offset from mail_index_record and changed it to use extension
Timo Sirainen <tss@iki.fi>
parents:
2671
diff
changeset
|
178 return tview->parent->get_header_ext(view, map, ext_id, |
512dd7d76cdc
Removed cache_offset from mail_index_record and changed it to use extension
Timo Sirainen <tss@iki.fi>
parents:
2671
diff
changeset
|
179 data_r, data_size_r); |
512dd7d76cdc
Removed cache_offset from mail_index_record and changed it to use extension
Timo Sirainen <tss@iki.fi>
parents:
2671
diff
changeset
|
180 } |
512dd7d76cdc
Removed cache_offset from mail_index_record and changed it to use extension
Timo Sirainen <tss@iki.fi>
parents:
2671
diff
changeset
|
181 |
2224
a816e2d88406
Added mail_index_transaction_get_updated_view() which can be used to access
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
182 static struct mail_index_view_methods view_methods = { |
a816e2d88406
Added mail_index_transaction_get_updated_view() which can be used to access
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
183 _tview_close, |
a816e2d88406
Added mail_index_transaction_get_updated_view() which can be used to access
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
184 _tview_get_message_count, |
a816e2d88406
Added mail_index_transaction_get_updated_view() which can be used to access
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
185 _tview_get_header, |
a816e2d88406
Added mail_index_transaction_get_updated_view() which can be used to access
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
186 _tview_lookup_full, |
a816e2d88406
Added mail_index_transaction_get_updated_view() which can be used to access
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
187 _tview_lookup_uid, |
a816e2d88406
Added mail_index_transaction_get_updated_view() which can be used to access
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
188 _tview_lookup_uid_range, |
2563
5752e5ac88f0
Save extra record/header infos into index file permanently.
Timo Sirainen <tss@iki.fi>
parents:
2271
diff
changeset
|
189 _tview_lookup_first, |
2853
512dd7d76cdc
Removed cache_offset from mail_index_record and changed it to use extension
Timo Sirainen <tss@iki.fi>
parents:
2671
diff
changeset
|
190 _tview_lookup_ext_full, |
512dd7d76cdc
Removed cache_offset from mail_index_record and changed it to use extension
Timo Sirainen <tss@iki.fi>
parents:
2671
diff
changeset
|
191 _tview_get_header_ext |
2224
a816e2d88406
Added mail_index_transaction_get_updated_view() which can be used to access
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
192 }; |
a816e2d88406
Added mail_index_transaction_get_updated_view() which can be used to access
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
193 |
a816e2d88406
Added mail_index_transaction_get_updated_view() which can be used to access
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
194 struct mail_index_view * |
2271
15d959d262a4
UIDs for appended messages can now be assigned all at once. Maildir now
Timo Sirainen <tss@iki.fi>
parents:
2240
diff
changeset
|
195 mail_index_transaction_open_updated_view(struct mail_index_transaction *t) |
2224
a816e2d88406
Added mail_index_transaction_get_updated_view() which can be used to access
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
196 { |
a816e2d88406
Added mail_index_transaction_get_updated_view() which can be used to access
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
197 struct mail_index_view_transaction *tview; |
a816e2d88406
Added mail_index_transaction_get_updated_view() which can be used to access
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
198 |
2884
173a0296e81d
Update view's header only after syncing the view. This and other changes fix
Timo Sirainen <tss@iki.fi>
parents:
2853
diff
changeset
|
199 if (t->view->syncing) { |
173a0296e81d
Update view's header only after syncing the view. This and other changes fix
Timo Sirainen <tss@iki.fi>
parents:
2853
diff
changeset
|
200 /* transaction view is being synced. while it's done, it's not |
173a0296e81d
Update view's header only after syncing the view. This and other changes fix
Timo Sirainen <tss@iki.fi>
parents:
2853
diff
changeset
|
201 possible to add new messages, but the view itself might |
173a0296e81d
Update view's header only after syncing the view. This and other changes fix
Timo Sirainen <tss@iki.fi>
parents:
2853
diff
changeset
|
202 change. so we can't make a copy of the view. */ |
173a0296e81d
Update view's header only after syncing the view. This and other changes fix
Timo Sirainen <tss@iki.fi>
parents:
2853
diff
changeset
|
203 mail_index_view_ref(t->view); |
173a0296e81d
Update view's header only after syncing the view. This and other changes fix
Timo Sirainen <tss@iki.fi>
parents:
2853
diff
changeset
|
204 return t->view; |
173a0296e81d
Update view's header only after syncing the view. This and other changes fix
Timo Sirainen <tss@iki.fi>
parents:
2853
diff
changeset
|
205 } |
173a0296e81d
Update view's header only after syncing the view. This and other changes fix
Timo Sirainen <tss@iki.fi>
parents:
2853
diff
changeset
|
206 |
2271
15d959d262a4
UIDs for appended messages can now be assigned all at once. Maildir now
Timo Sirainen <tss@iki.fi>
parents:
2240
diff
changeset
|
207 tview = i_new(struct mail_index_view_transaction, 1); |
15d959d262a4
UIDs for appended messages can now be assigned all at once. Maildir now
Timo Sirainen <tss@iki.fi>
parents:
2240
diff
changeset
|
208 mail_index_view_clone(&tview->view, t->view); |
15d959d262a4
UIDs for appended messages can now be assigned all at once. Maildir now
Timo Sirainen <tss@iki.fi>
parents:
2240
diff
changeset
|
209 tview->view.methods = view_methods; |
15d959d262a4
UIDs for appended messages can now be assigned all at once. Maildir now
Timo Sirainen <tss@iki.fi>
parents:
2240
diff
changeset
|
210 tview->parent = &t->view->methods; |
15d959d262a4
UIDs for appended messages can now be assigned all at once. Maildir now
Timo Sirainen <tss@iki.fi>
parents:
2240
diff
changeset
|
211 tview->t = t; |
2224
a816e2d88406
Added mail_index_transaction_get_updated_view() which can be used to access
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
212 |
2271
15d959d262a4
UIDs for appended messages can now be assigned all at once. Maildir now
Timo Sirainen <tss@iki.fi>
parents:
2240
diff
changeset
|
213 mail_index_transaction_ref(t); |
15d959d262a4
UIDs for appended messages can now be assigned all at once. Maildir now
Timo Sirainen <tss@iki.fi>
parents:
2240
diff
changeset
|
214 return &tview->view; |
2224
a816e2d88406
Added mail_index_transaction_get_updated_view() which can be used to access
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
215 } |