(mailbox_flush): New function. Marks all
messages as seen and saves the attributes to the mailbox, optionally expunging it.
Showing
1 changed file
with
23 additions
and
0 deletions
... | @@ -199,9 +199,32 @@ mailbox_close (mailbox_t mbox) | ... | @@ -199,9 +199,32 @@ mailbox_close (mailbox_t mbox) |
199 | { | 199 | { |
200 | if (mbox == NULL || mbox->_close == NULL) | 200 | if (mbox == NULL || mbox->_close == NULL) |
201 | return MU_ERR_EMPTY_VFN; | 201 | return MU_ERR_EMPTY_VFN; |
202 | |||
202 | return mbox->_close (mbox); | 203 | return mbox->_close (mbox); |
203 | } | 204 | } |
204 | 205 | ||
206 | int | ||
207 | mailbox_flush (mailbox_t mbox, int expunge) | ||
208 | { | ||
209 | size_t i, total = 0; | ||
210 | int status = 0; | ||
211 | |||
212 | mailbox_messages_count (mbox, &total); | ||
213 | for (i = 1; i <= total; i++) | ||
214 | { | ||
215 | message_t msg = NULL; | ||
216 | attribute_t attr = NULL; | ||
217 | mailbox_get_message (mbox, i, &msg); | ||
218 | message_get_attribute (msg, &attr); | ||
219 | attribute_set_seen (attr); | ||
220 | } | ||
221 | if (expunge) | ||
222 | status = mailbox_expunge (mbox); | ||
223 | else | ||
224 | status = mailbox_save_attributes (mbox); | ||
225 | return status; | ||
226 | } | ||
227 | |||
205 | /* messages */ | 228 | /* messages */ |
206 | int | 229 | int |
207 | mailbox_append_message (mailbox_t mbox, message_t msg) | 230 | mailbox_append_message (mailbox_t mbox, message_t msg) | ... | ... |
-
Please register or sign in to post a comment