]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
Added mailbox_get_uid_range().
authorTimo Sirainen <tss@iki.fi>
Fri, 6 Jun 2008 22:34:16 +0000 (01:34 +0300)
committerTimo Sirainen <tss@iki.fi>
Fri, 6 Jun 2008 22:34:16 +0000 (01:34 +0300)
--HG--
branch : HEAD

src/lib-storage/index/cydir/cydir-storage.c
src/lib-storage/index/dbox/dbox-storage.c
src/lib-storage/index/index-fetch.c
src/lib-storage/index/index-storage.h
src/lib-storage/index/maildir/maildir-storage.c
src/lib-storage/index/mbox/mbox-storage.c
src/lib-storage/index/raw/raw-storage.c
src/lib-storage/mail-storage-private.h
src/lib-storage/mail-storage.c
src/lib-storage/mail-storage.h

index 2937948e839065e2473ad092c101f463dbaa0a7a..3fe0a36585d8a424afa2fac35a02785a41992bd2 100644 (file)
@@ -431,6 +431,7 @@ struct mailbox cydir_mailbox = {
                index_keywords_create,
                index_keywords_free,
                index_storage_get_seq_range,
+               index_storage_get_uid_range,
                index_storage_get_expunged_uids,
                index_mail_alloc,
                index_header_lookup_init,
index 0e00e54aca1b23f790e1f748b83af48a3aa6fe17..4c34d989b7fec77c94faabea587216cd419f38fd 100644 (file)
@@ -680,6 +680,7 @@ struct mailbox dbox_mailbox = {
                index_keywords_create,
                index_keywords_free,
                index_storage_get_seq_range,
+               index_storage_get_uid_range,
                index_storage_get_expunged_uids,
                dbox_mail_alloc,
                index_header_lookup_init,
index bfbe630d117a0131a5a6ed07236ab7ab8676653b..5c889a1dc198b793c830b2f05b6584cce2a9e108 100644 (file)
@@ -15,6 +15,30 @@ void index_storage_get_seq_range(struct mailbox *box,
        mail_index_lookup_seq_range(ibox->view, uid1, uid2, seq1_r, seq2_r);
 }
 
+void index_storage_get_uid_range(struct mailbox *box,
+                                const ARRAY_TYPE(seq_range) *seqs,
+                                ARRAY_TYPE(seq_range) *uids)
+{
+       struct index_mailbox *ibox = (struct index_mailbox *)box;
+       const struct seq_range *range;
+       unsigned int i, count;
+       uint32_t seq, uid;
+
+       range = array_get(seqs, &count);
+       for (i = 0; i < count; i++) {
+               if (range[i].seq2 == (uint32_t)-1) {
+                       i_assert(count == i-1);
+                       mail_index_lookup_uid(ibox->view, range[i].seq1, &uid);
+                       seq_range_array_add_range(uids, uid, (uint32_t)-1);
+                       break;
+               }
+               for (seq = range[i].seq1; seq <= range[i].seq2; seq++) {
+                       mail_index_lookup_uid(ibox->view, seq, &uid);
+                       seq_range_array_add(uids, 0, uid);
+               }
+       }
+}
+
 bool index_storage_get_expunged_uids(struct mailbox *box, uint64_t modseq,
                                     const ARRAY_TYPE(seq_range) *uids,
                                     ARRAY_TYPE(seq_range) *expunged_uids)
index b72665a60e6cc47107af879c66ab1d2809d936f7..d1a2a9458d228060ed573efbcc18e54d8bd60e26 100644 (file)
@@ -147,6 +147,9 @@ void index_storage_get_status(struct mailbox *box,
 void index_storage_get_seq_range(struct mailbox *box,
                                 uint32_t uid1, uint32_t uid2,
                                 uint32_t *seq1_r, uint32_t *seq2_r);
+void index_storage_get_uid_range(struct mailbox *box,
+                                const ARRAY_TYPE(seq_range) *seqs,
+                                ARRAY_TYPE(seq_range) *uids);
 bool index_storage_get_expunged_uids(struct mailbox *box, uint64_t modseq,
                                     const ARRAY_TYPE(seq_range) *uids,
                                     ARRAY_TYPE(seq_range) *expunged_uids);
index 1051fdcf1f1061e955aebd0befec2de73ef7fe7f..1d9e1cb10d95d148a5cab725f78573f1922df80d 100644 (file)
@@ -1038,6 +1038,7 @@ struct mailbox maildir_mailbox = {
                index_keywords_create,
                index_keywords_free,
                index_storage_get_seq_range,
+               index_storage_get_uid_range,
                index_storage_get_expunged_uids,
                index_mail_alloc,
                index_header_lookup_init,
index e0078ce99032efe76e467149ba4803aa2cda028c..205575b6f9890b9543704155d6a71e45083bfdc8 100644 (file)
@@ -988,6 +988,7 @@ struct mailbox mbox_mailbox = {
                index_keywords_create,
                index_keywords_free,
                index_storage_get_seq_range,
+               index_storage_get_uid_range,
                index_storage_get_expunged_uids,
                index_mail_alloc,
                index_header_lookup_init,
index dbdc8f166a826824ae7f7cce231cfcff51a40d83..84780160a9b2f1a79d6e705c723d68510b9b6916 100644 (file)
@@ -288,6 +288,7 @@ struct mailbox raw_mailbox = {
                index_keywords_create,
                index_keywords_free,
                index_storage_get_seq_range,
+               index_storage_get_uid_range,
                index_storage_get_expunged_uids,
                index_mail_alloc,
                index_header_lookup_init,
index 444f8856cd0d380a1c9368ad8de42f57605db4b4..19aadf65c23a48e43452c6e9da8daa97b2ceae50 100644 (file)
@@ -125,6 +125,9 @@ struct mailbox_vfuncs {
 
        void (*get_seq_range)(struct mailbox *box, uint32_t uid1, uint32_t uid2,
                              uint32_t *seq1_r, uint32_t *seq2_r);
+       void (*get_uid_range)(struct mailbox *box,
+                             const ARRAY_TYPE(seq_range) *seqs,
+                             ARRAY_TYPE(seq_range) *uids);
        bool (*get_expunged_uids)(struct mailbox *box, uint64_t modseq,
                                  const ARRAY_TYPE(seq_range) *uids,
                                  ARRAY_TYPE(seq_range) *expunged_uids);
index 542dcae21a0d6ccdebdbafc931cde51a315b68d9..2b065488fd12d83d939443d8c45923ac665b3d3d 100644 (file)
@@ -609,6 +609,13 @@ void mailbox_get_seq_range(struct mailbox *box, uint32_t uid1, uint32_t uid2,
        box->v.get_seq_range(box, uid1, uid2, seq1_r, seq2_r);
 }
 
+void mailbox_get_uid_range(struct mailbox *box,
+                          const ARRAY_TYPE(seq_range) *seqs,
+                          ARRAY_TYPE(seq_range) *uids)
+{
+       box->v.get_uid_range(box, seqs, uids);
+}
+
 bool mailbox_get_expunged_uids(struct mailbox *box, uint64_t modseq,
                               const ARRAY_TYPE(seq_range) *uids,
                               ARRAY_TYPE(seq_range) *expunged_uids)
index d229595c42e75584e3f9deb97ded1b33449af9d9..a18debc2320ee67909163b1ff4babf3db7790961 100644 (file)
@@ -368,6 +368,11 @@ void mailbox_keywords_free(struct mailbox *box,
 /* Convert uid range to sequence range. */
 void mailbox_get_seq_range(struct mailbox *box, uint32_t uid1, uint32_t uid2,
                           uint32_t *seq1_r, uint32_t *seq2_r);
+/* Convert sequence range to uid range. If sequences contain
+   (uint32_t)-1 to specify "*", they're preserved. */
+void mailbox_get_uid_range(struct mailbox *box,
+                          const ARRAY_TYPE(seq_range) *seqs,
+                          ARRAY_TYPE(seq_range) *uids);
 /* Get list of UIDs expunged after modseq and within the given range.
    UIDs that have been expunged after the last mailbox sync aren't returned.
    Returns TRUE if ok, FALSE if modseq is lower than we can check for. */