dovecot-2.1: imapc: mailbox_status now returns permanent flags/k...
dovecot at dovecot.org
dovecot at dovecot.org
Mon Sep 5 10:33:36 EEST 2011
details: http://hg.dovecot.org/dovecot-2.1/rev/4ddbbfa1c515
changeset: 13396:4ddbbfa1c515
user: Timo Sirainen <tss at iki.fi>
date: Mon Sep 05 10:32:47 2011 +0300
description:
imapc: mailbox_status now returns permanent flags/keywords as they are on remote server.
diffstat:
src/lib-storage/index/imapc/imapc-mailbox.c | 39 +++++++++++++++++++++++++++++
src/lib-storage/index/imapc/imapc-storage.c | 8 +++++-
src/lib-storage/index/imapc/imapc-storage.h | 3 ++
3 files changed, 49 insertions(+), 1 deletions(-)
diffs (99 lines):
diff -r a5e47ce5a5a0 -r 4ddbbfa1c515 src/lib-storage/index/imapc/imapc-mailbox.c
--- a/src/lib-storage/index/imapc/imapc-mailbox.c Mon Sep 05 10:30:15 2011 +0300
+++ b/src/lib-storage/index/imapc/imapc-mailbox.c Mon Sep 05 10:32:47 2011 +0300
@@ -325,6 +325,43 @@
mbox->sync_uid_next = uid_next;
}
+static void
+imapc_resp_text_permanentflags(const struct imapc_untagged_reply *reply,
+ struct imapc_mailbox *mbox)
+{
+ const struct imap_arg *flags_args, *arg;
+ const char *flag;
+
+ i_assert(reply->args[0].type == IMAP_ARG_ATOM);
+
+ if (mbox == NULL || !imap_arg_get_list(&reply->args[1], &flags_args))
+ return;
+
+ mbox->permanent_flags = 0;
+ array_clear(&mbox->permanent_keywords);
+ mbox->box.disallow_new_keywords = TRUE;
+
+ for (arg = flags_args; arg->type != IMAP_ARG_EOL; arg++) {
+ if (!imap_arg_get_atom(arg, &flag))
+ continue;
+
+ if (strcmp(flag, "\\*") == 0)
+ mbox->box.disallow_new_keywords = FALSE;
+ else if (*flag == '\\')
+ mbox->permanent_flags |= imap_parse_system_flag(flag);
+ else {
+ /* this wastes some memory when called multiple times,
+ but that should happen quite rarely */
+ flag = p_strdup(mbox->box.pool, flag);
+ array_append(&mbox->permanent_keywords, &flag, 1);
+ }
+ }
+ /* NULL-terminate it */
+ (void)array_append_space(&mbox->permanent_keywords);
+ array_delete(&mbox->permanent_keywords,
+ array_count(&mbox->permanent_keywords)-1, 1);
+}
+
void imapc_mailbox_register_untagged(struct imapc_mailbox *mbox,
const char *key,
imapc_mailbox_callback_t *callback)
@@ -359,4 +396,6 @@
imapc_resp_text_uidvalidity);
imapc_mailbox_register_resp_text(mbox, "UIDNEXT",
imapc_resp_text_uidnext);
+ imapc_mailbox_register_resp_text(mbox, "PERMANENTFLAGS",
+ imapc_resp_text_permanentflags);
}
diff -r a5e47ce5a5a0 -r 4ddbbfa1c515 src/lib-storage/index/imapc/imapc-storage.c
--- a/src/lib-storage/index/imapc/imapc-storage.c Mon Sep 05 10:30:15 2011 +0300
+++ b/src/lib-storage/index/imapc/imapc-storage.c Mon Sep 05 10:32:47 2011 +0300
@@ -304,6 +304,7 @@
p_array_init(&mbox->untagged_callbacks, pool, 16);
p_array_init(&mbox->resp_text_callbacks, pool, 16);
p_array_init(&mbox->fetch_mails, pool, 16);
+ p_array_init(&mbox->permanent_keywords, pool, 32);
imapc_mailbox_register_callbacks(mbox);
return &mbox->box;
}
@@ -456,6 +457,10 @@
struct mailbox_status *status_r)
{
index_storage_get_status(&mbox->box, items, status_r);
+ if ((items & STATUS_KEYWORDS) != 0)
+ status_r->keywords = &mbox->permanent_keywords;
+ if ((items & STATUS_PERMANENT_FLAGS) != 0)
+ status_r->permanent_flags = mbox->permanent_flags;
}
static int imapc_mailbox_get_status(struct mailbox *box,
@@ -474,7 +479,8 @@
}
/* mailbox isn't opened yet */
- if ((items & (STATUS_FIRST_UNSEEN_SEQ | STATUS_KEYWORDS)) != 0) {
+ if ((items & (STATUS_FIRST_UNSEEN_SEQ | STATUS_KEYWORDS |
+ STATUS_PERMANENT_FLAGS)) != 0) {
/* getting these requires opening the mailbox */
if (mailbox_open(box) < 0)
return -1;
diff -r a5e47ce5a5a0 -r 4ddbbfa1c515 src/lib-storage/index/imapc/imapc-storage.h
--- a/src/lib-storage/index/imapc/imapc-storage.h Mon Sep 05 10:30:15 2011 +0300
+++ b/src/lib-storage/index/imapc/imapc-storage.h Mon Sep 05 10:32:47 2011 +0300
@@ -54,6 +54,9 @@
ARRAY_DEFINE(untagged_callbacks, struct imapc_mailbox_event_callback);
ARRAY_DEFINE(resp_text_callbacks, struct imapc_mailbox_event_callback);
+ enum mail_flags permanent_flags;
+ ARRAY_TYPE(keywords) permanent_keywords;
+
uint32_t sync_uid_validity;
uint32_t sync_uid_next;
uint32_t sync_fetch_first_uid;
More information about the dovecot-cvs
mailing list