]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
Added mail_index_lookup_view_flags()
authorTimo Sirainen <tss@iki.fi>
Tue, 31 Mar 2009 00:27:02 +0000 (20:27 -0400)
committerTimo Sirainen <tss@iki.fi>
Tue, 31 Mar 2009 00:27:02 +0000 (20:27 -0400)
--HG--
branch : HEAD

src/lib-index/mail-index-view.c
src/lib-index/mail-index.h

index a30b9b904faf98b53008d815697b70421782788c..15059e61b75662e0d0bab78c900f239ffb15ecaa 100644 (file)
@@ -389,25 +389,30 @@ static void view_lookup_keywords(struct mail_index_view *view, uint32_t seq,
        mail_index_data_lookup_keywords(map, data, keyword_idx);
 }
 
+static const void *
+view_map_lookup_ext_full(struct mail_index_map *map,
+                        const struct mail_index_record *rec, uint32_t ext_id)
+{
+       const struct mail_index_ext *ext;
+       uint32_t idx;
+
+       if (!mail_index_map_get_ext_idx(map, ext_id, &idx))
+               return NULL;
+
+       ext = array_idx(&map->extensions, idx);
+       return ext->record_offset == 0 ? NULL :
+               CONST_PTR_OFFSET(rec, ext->record_offset);
+}
+
 static void
 view_lookup_ext_full(struct mail_index_view *view, uint32_t seq,
                     uint32_t ext_id, struct mail_index_map **map_r,
                     const void **data_r, bool *expunged_r)
 {
-       const struct mail_index_ext *ext;
        const struct mail_index_record *rec;
-       uint32_t idx, offset;
 
        rec = view->v.lookup_full(view, seq, map_r, expunged_r);
-       if (!mail_index_map_get_ext_idx(*map_r, ext_id, &idx)) {
-               *data_r = NULL;
-               return;
-       }
-
-       ext = array_idx(&(*map_r)->extensions, idx);
-       offset = ext->record_offset;
-
-       *data_r = offset == 0 ? NULL : CONST_PTR_OFFSET(rec, offset);
+       *data_r = view_map_lookup_ext_full(*map_r, rec, ext_id);
 }
 
 static void view_get_header_ext(struct mail_index_view *view,
@@ -524,6 +529,23 @@ void mail_index_lookup_keywords(struct mail_index_view *view, uint32_t seq,
        view->v.lookup_keywords(view, seq, keyword_idx);
 }
 
+void mail_index_lookup_view_flags(struct mail_index_view *view, uint32_t seq,
+                                 enum mail_flags *flags_r,
+                                 ARRAY_TYPE(keyword_indexes) *keyword_idx)
+{
+       const struct mail_index_record *rec;
+       const unsigned char *keyword_data;
+
+       i_assert(seq > 0 && seq <= mail_index_view_get_messages_count(view));
+
+       rec = MAIL_INDEX_MAP_IDX(view->map, seq-1);
+       *flags_r = rec->flags;
+
+       keyword_data = view_map_lookup_ext_full(view->map, rec,
+                                               view->index->keywords_ext_id);
+       mail_index_data_lookup_keywords(view->map, keyword_data, keyword_idx);
+}
+
 void mail_index_lookup_uid(struct mail_index_view *view, uint32_t seq,
                           uint32_t *uid_r)
 {
index 75aa5961bc4b21fa695e8ccc6e8d14f42e21a27d..d9c6381317ce4661d580a2507b18021a27b5ad6d 100644 (file)
@@ -343,6 +343,12 @@ void mail_index_lookup_keywords(struct mail_index_view *view, uint32_t seq,
 /* Return keywords from given map. */
 void mail_index_map_lookup_keywords(struct mail_index_map *map, uint32_t seq,
                                    ARRAY_TYPE(keyword_indexes) *keyword_idx);
+/* mail_index_lookup[_keywords]() returns the latest flag changes.
+   This function instead attempts to return the flags and keywords done by the
+   last view sync. */
+void mail_index_lookup_view_flags(struct mail_index_view *view, uint32_t seq,
+                                 enum mail_flags *flags_r,
+                                 ARRAY_TYPE(keyword_indexes) *keyword_idx);
 /* Returns the UID for given message. May be slightly faster than
    mail_index_lookup()->uid. */
 void mail_index_lookup_uid(struct mail_index_view *view, uint32_t seq,