[dovecot-cvs] dovecot/src/lib-storage/index/mbox mbox-mail.c, 1.19, 1.20 mbox-save.c, 1.70, 1.71 mbox-storage.c, 1.107, 1.108 mbox-storage.h, 1.31, 1.32 mbox-sync-private.h, 1.41, 1.42 mbox-sync-update.c, 1.26, 1.27 mbox-sync.c, 1.131, 1.132

cras at dovecot.org cras at dovecot.org
Sun Dec 26 11:12:50 EET 2004


Update of /var/lib/cvs/dovecot/src/lib-storage/index/mbox
In directory talvi:/tmp/cvs-serv26125/lib-storage/index/mbox

Modified Files:
	mbox-mail.c mbox-save.c mbox-storage.c mbox-storage.h 
	mbox-sync-private.h mbox-sync-update.c mbox-sync.c 
Log Message:
Initial support for keywords. Syncing to mbox/maildir doesn't work yet.



Index: mbox-mail.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib-storage/index/mbox/mbox-mail.c,v
retrieving revision 1.19
retrieving revision 1.20
diff -u -d -r1.19 -r1.20
--- mbox-mail.c	5 Dec 2004 01:45:54 -0000	1.19
+++ mbox-mail.c	26 Dec 2004 09:12:45 -0000	1.20
@@ -72,21 +72,6 @@
 	return 1;
 }
 
-static const struct mail_full_flags *mbox_mail_get_flags(struct mail *_mail)
-{
-	return index_mail_get_flags(_mail);
-	/*FIXME:struct index_mail *mail = (struct index_mail *)_mail;
-	struct index_mail_data *data = &mail->data;
-
-	i_assert(_mail->seq <= mail->ibox->mbox_data_count);
-
-	(void)index_mail_get_flags(_mail);
-	if ((mail->ibox->mbox_data[_mail->seq-1] & 1) != 0)
-		data->flags.flags |= MAIL_RECENT;
-
-	return &data->flags;*/
-}
-
 static time_t mbox_mail_get_received_date(struct mail *_mail)
 {
 	struct index_mail *mail = (struct index_mail *)_mail;
@@ -178,7 +163,8 @@
 struct mail mbox_mail = {
 	0, 0, 0, 0, 0, 0,
 
-	mbox_mail_get_flags,
+	index_mail_get_flags,
+	index_mail_get_keywords,
 	index_mail_get_parts,
 	mbox_mail_get_received_date,
 	index_mail_get_date,
@@ -189,5 +175,6 @@
 	mbox_mail_get_stream,
 	mbox_mail_get_special,
 	index_mail_update_flags,
+	index_mail_update_keywords,
 	index_mail_expunge
 };

Index: mbox-save.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib-storage/index/mbox/mbox-save.c,v
retrieving revision 1.70
retrieving revision 1.71
diff -u -d -r1.70 -r1.71
--- mbox-save.c	17 Dec 2004 00:05:54 -0000	1.70
+++ mbox-save.c	26 Dec 2004 09:12:45 -0000	1.71
@@ -41,7 +41,6 @@
 	char last_char;
 
 	struct index_mail mail;
-	const struct mail_full_flags *flags;
 	struct mbox_md5_context *mbox_md5_ctx;
 
 	unsigned int synced:1;
@@ -222,19 +221,19 @@
 	}
 }
 
-static void mbox_save_append_keyword_headers(struct mbox_save_context *ctx,
-					     const char *const *keywords,
-					     unsigned int count)
+static void
+mbox_save_append_keyword_headers(struct mbox_save_context *ctx,
+				 const struct mail_keywords *keywords)
 {
 	unsigned char space[MBOX_HEADER_PADDING+1 +
 			    sizeof("Content-Length: \n")-1 + MAX_INT_STRLEN];
 	unsigned int i;
 
 	str_append(ctx->headers, "X-Keywords:");
-	for (i = 0; i < count; i++) {
+	/*FIXME:for (i = 0; i < count; i++) {
 		str_append_c(ctx->headers, ' ');
 		str_append(ctx->headers, keywords[i]);
-	}
+	}*/
 
 	memset(space, ' ', sizeof(space));
 	str_append_n(ctx->headers, space, sizeof(space));
@@ -302,7 +301,7 @@
 
 struct mail_save_context *
 mbox_save_init(struct mailbox_transaction_context *_t,
-	       const struct mail_full_flags *flags,
+	       enum mail_flags flags, const struct mail_keywords *keywords,
 	       time_t received_date, int timezone_offset __attr_unused__,
 	       const char *from_envelope, struct istream *input, int want_mail)
 {
@@ -311,7 +310,6 @@
 	struct index_mailbox *ibox = t->ictx.ibox;
 	struct mbox_save_context *ctx = t->save_ctx;
 	enum mail_flags save_flags;
-	keywords_mask_t keywords;
 	uint64_t offset;
 
 	/* FIXME: we could write timezone_offset to From-line.. */
@@ -333,25 +331,22 @@
 	ctx->failed = FALSE;
 	ctx->seq = 0;
 
-	ctx->flags = flags;
-
 	if (mbox_save_init_file(ctx, t, want_mail) < 0) {
 		ctx->failed = TRUE;
 		return &ctx->ctx;
 	}
 
-	save_flags = (flags->flags & ~MAIL_RECENT) | MAIL_RECENT;
+	save_flags = (flags & ~MAIL_RECENT) | MAIL_RECENT;
 	str_truncate(ctx->headers, 0);
 	if (ctx->synced) {
 		str_printfa(ctx->headers, "X-UID: %u\n", ctx->next_uid);
 		if (!ibox->keep_recent)
 			save_flags &= ~MAIL_RECENT;
 
-		memset(keywords, 0, INDEX_KEYWORDS_BYTE_COUNT);
 		// FIXME: set keywords
 		mail_index_append(ctx->trans, ctx->next_uid, &ctx->seq);
 		mail_index_update_flags(ctx->trans, ctx->seq, MODIFY_REPLACE,
-					save_flags, keywords);
+					save_flags);
 
 		offset = ctx->output->offset == 0 ? 0 :
 			ctx->output->offset - 1;
@@ -361,8 +356,7 @@
 	}
 	mbox_save_append_flag_headers(ctx->headers,
 				      save_flags ^ MBOX_NONRECENT);
-	mbox_save_append_keyword_headers(ctx, flags->keywords,
-					 flags->keywords_count);
+	mbox_save_append_keyword_headers(ctx, keywords);
 	str_append_c(ctx->headers, '\n');
 
 	i_assert(ibox->mbox_lock_type == F_WRLCK);

Index: mbox-storage.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib-storage/index/mbox/mbox-storage.c,v
retrieving revision 1.107
retrieving revision 1.108
diff -u -d -r1.107 -r1.108
--- mbox-storage.c	15 Dec 2004 20:05:18 -0000	1.107
+++ mbox-storage.c	26 Dec 2004 09:12:45 -0000	1.108
@@ -861,6 +861,7 @@
 	mbox_transaction_begin,
 	mbox_transaction_commit,
 	mbox_transaction_rollback,
+	index_keywords_create,
 	index_storage_fetch,
 	index_storage_get_uids,
 	index_header_lookup_init,

Index: mbox-storage.h
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib-storage/index/mbox/mbox-storage.h,v
retrieving revision 1.31
retrieving revision 1.32
diff -u -d -r1.31 -r1.32
--- mbox-storage.h	8 Dec 2004 17:15:46 -0000	1.31
+++ mbox-storage.h	26 Dec 2004 09:12:45 -0000	1.32
@@ -43,7 +43,7 @@
 
 struct mail_save_context *
 mbox_save_init(struct mailbox_transaction_context *_t,
-	       const struct mail_full_flags *flags,
+	       enum mail_flags flags, const struct mail_keywords *keywords,
 	       time_t received_date, int timezone_offset,
 	       const char *from_envelope, struct istream *input, int want_mail);
 int mbox_save_continue(struct mail_save_context *ctx);

Index: mbox-sync-private.h
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib-storage/index/mbox/mbox-sync-private.h,v
retrieving revision 1.41
retrieving revision 1.42
diff -u -d -r1.41 -r1.42
--- mbox-sync-private.h	15 Dec 2004 19:24:11 -0000	1.41
+++ mbox-sync-private.h	26 Dec 2004 09:12:45 -0000	1.42
@@ -39,7 +39,7 @@
 	uint32_t uid;
 	uint32_t idx_seq;
 	uint8_t flags;
-	keywords_mask_t keywords;
+	uint32_t keywords_idx; /* +1 */
 
 	uoff_t from_offset;
 	uoff_t body_size;

Index: mbox-sync-update.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib-storage/index/mbox/mbox-sync-update.c,v
retrieving revision 1.26
retrieving revision 1.27
diff -u -d -r1.26 -r1.27
--- mbox-sync-update.c	2 Nov 2004 00:35:15 -0000	1.26
+++ mbox-sync-update.c	26 Dec 2004 09:12:45 -0000	1.27
@@ -100,16 +100,9 @@
 	}
 }
 
-static void keywords_append(struct mbox_sync_mail_context *ctx,
-			    keywords_mask_t keywords)
-{
-	// FIXME
-}
-
 static void mbox_sync_add_missing_headers(struct mbox_sync_mail_context *ctx)
 {
 	size_t old_hdr_size, new_hdr_size;
-	int i, have_keywords;
 
 	old_hdr_size = ctx->body_offset - ctx->hdr_offset;
 	new_hdr_size = str_len(ctx->header);
@@ -160,18 +153,11 @@
 		str_append_c(ctx->header, '\n');
 	}
 
-	have_keywords = FALSE;
-	for (i = 0; i < INDEX_KEYWORDS_BYTE_COUNT; i++) {
-		if (ctx->mail.keywords[i] != 0) {
-			have_keywords = TRUE;
-			break;
-		}
-	}
-
-	if (ctx->hdr_pos[MBOX_HDR_X_KEYWORDS] == (size_t)-1 && have_keywords) {
+	if (ctx->hdr_pos[MBOX_HDR_X_KEYWORDS] == (size_t)-1 &&
+	    ctx->mail.keywords_idx != 0) {
 		str_append(ctx->header, "X-Keywords: ");
 		ctx->hdr_pos[MBOX_HDR_X_KEYWORDS] = str_len(ctx->header);
-		keywords_append(ctx, ctx->mail.keywords);
+		//keywords_append(ctx, ctx->mail.keywords);
 		str_append_c(ctx->header, '\n');
 	}
 
@@ -277,7 +263,7 @@
 	const struct mail_index_sync_rec *sync;
 	size_t size, i;
 	uint8_t old_flags;
-	keywords_mask_t old_keywords;
+	uint32_t old_keywords_idx;
 
 	i_assert(ctx->mail.uid != 0 || ctx->pseudo);
 
@@ -287,14 +273,14 @@
 	old_flags = ctx->mail.flags;
 
 	if (size != 0) {
-		memcpy(old_keywords, ctx->mail.keywords, sizeof(old_keywords));
+		old_keywords_idx = ctx->mail.keywords_idx;
 
 		for (i = 0; i < size; i++) {
 			if (sync[i].type != MAIL_INDEX_SYNC_TYPE_FLAGS)
 				continue;
 
-			mail_index_sync_flags_apply(&sync[i], &ctx->mail.flags,
-						    ctx->mail.keywords);
+			// FIXME: keywords
+			mail_index_sync_flags_apply(&sync[i], &ctx->mail.flags);
 		}
 
 		/* keep our old recent flag. especially because we use it
@@ -305,9 +291,9 @@
 		if ((old_flags & XSTATUS_FLAGS_MASK) !=
 		    (ctx->mail.flags & XSTATUS_FLAGS_MASK))
 			mbox_sync_update_xstatus(ctx);
-		if (memcmp(old_keywords, ctx->mail.keywords,
+		/*FIXME:if (memcmp(old_keywords, ctx->mail.keywords,
 			   INDEX_KEYWORDS_BYTE_COUNT) != 0)
-			mbox_sync_update_xkeywords(ctx);
+			mbox_sync_update_xkeywords(ctx);*/
 	}
 
 	if (!ctx->sync_ctx->ibox->keep_recent)
@@ -341,12 +327,12 @@
 			(mail->flags & XSTATUS_FLAGS_MASK);
 		mbox_sync_update_xstatus(ctx);
 	}
-	if (memcmp(ctx->mail.keywords, mail->keywords,
+	/*FIXME:if (memcmp(ctx->mail.keywords, mail->keywords,
 		   INDEX_KEYWORDS_BYTE_COUNT) != 0) {
 		memcpy(ctx->mail.keywords, mail->keywords,
 		       INDEX_KEYWORDS_BYTE_COUNT);
 		mbox_sync_update_xkeywords(ctx);
-	}
+	}*/
 
 	i_assert(ctx->mail.uid == 0 || ctx->mail.uid == mail->uid);
 	ctx->mail.uid = mail->uid;

Index: mbox-sync.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib-storage/index/mbox/mbox-sync.c,v
retrieving revision 1.131
retrieving revision 1.132
diff -u -d -r1.131 -r1.132
--- mbox-sync.c	17 Dec 2004 00:05:54 -0000	1.131
+++ mbox-sync.c	26 Dec 2004 09:12:45 -0000	1.132
@@ -193,8 +193,7 @@
 	return 0;
 }
 
-static void mbox_sync_apply_index_syncs(buffer_t *syncs_buf, uint8_t *flags,
-					keywords_mask_t keywords)
+static void mbox_sync_apply_index_syncs(buffer_t *syncs_buf, uint8_t *flags)
 {
 	const struct mail_index_sync_rec *sync;
 	size_t size, i;
@@ -205,7 +204,7 @@
 	for (i = 0; i < size; i++) {
 		if (sync[i].type != MAIL_INDEX_SYNC_TYPE_FLAGS)
 			continue;
-		mail_index_sync_flags_apply(&sync[i], flags, keywords);
+		mail_index_sync_flags_apply(&sync[i], flags);
 	}
 }
 
@@ -331,7 +330,6 @@
 				  const struct mail_index_record *rec)
 {
 	struct mbox_sync_mail *mail = &mail_ctx->mail;
-	keywords_mask_t idx_keywords;
 	uint8_t idx_flags, mbox_flags;
 
 	if (rec == NULL) {
@@ -344,8 +342,7 @@
 		    (mail->flags & MBOX_NONRECENT) == 0)
 			mbox_flags |= MAIL_RECENT;
 		mail_index_update_flags(sync_ctx->t, sync_ctx->idx_seq,
-					MODIFY_REPLACE, mbox_flags,
-					mail->keywords);
+					MODIFY_REPLACE, mbox_flags);
 
 		if (sync_ctx->ibox->mbox_save_md5 != 0) {
 			mail_index_update_ext(sync_ctx->t, sync_ctx->idx_seq,
@@ -355,9 +352,7 @@
 	} else {
 		/* see if flags changed */
 		idx_flags = rec->flags;
-		memcpy(idx_keywords, rec->keywords, INDEX_KEYWORDS_BYTE_COUNT);
-		mbox_sync_apply_index_syncs(sync_ctx->syncs,
-					    &idx_flags, idx_keywords);
+		mbox_sync_apply_index_syncs(sync_ctx->syncs, &idx_flags);
 
 		if ((idx_flags & MAIL_INDEX_MAIL_FLAG_DIRTY) != 0) {
 			/* flags are dirty, ignore whatever was in the file.
@@ -377,35 +372,27 @@
 			mbox_flags &= ~MAIL_INDEX_MAIL_FLAG_DIRTY;
 
 		if ((idx_flags & ~MAIL_INDEX_MAIL_FLAG_DIRTY) ==
-		    (mbox_flags & ~MAIL_INDEX_MAIL_FLAG_DIRTY) &&
-		    memcmp(idx_keywords, mail->keywords,
-			   INDEX_KEYWORDS_BYTE_COUNT) == 0) {
+		    (mbox_flags & ~MAIL_INDEX_MAIL_FLAG_DIRTY)) {
 			if (idx_flags != mbox_flags) {
 				/* dirty flag state changed */
 				int dirty = (mbox_flags &
 					     MAIL_INDEX_MAIL_FLAG_DIRTY) != 0;
-				memset(idx_keywords, 0,
-				       INDEX_KEYWORDS_BYTE_COUNT);
 				mail_index_update_flags(sync_ctx->t,
 					sync_ctx->idx_seq,
 					dirty ? MODIFY_ADD : MODIFY_REMOVE,
-					MAIL_INDEX_MAIL_FLAG_DIRTY,
-					idx_keywords);
+					MAIL_INDEX_MAIL_FLAG_DIRTY);
 			}
 		} else if ((idx_flags & ~MAIL_RECENT) !=
-			   (mbox_flags & ~MAIL_RECENT) ||
-			   memcmp(idx_keywords, mail->keywords,
-				  INDEX_KEYWORDS_BYTE_COUNT) != 0) {
+			   (mbox_flags & ~MAIL_RECENT)) {
 			mail_index_update_flags(sync_ctx->t, sync_ctx->idx_seq,
-						MODIFY_REPLACE, mbox_flags,
-						mail->keywords);
+						MODIFY_REPLACE, mbox_flags);
 		} else if (((idx_flags ^ mbox_flags) & MAIL_RECENT) != 0) {
 			/* drop recent flag */
-			memset(idx_keywords, 0, INDEX_KEYWORDS_BYTE_COUNT);
 			mail_index_update_flags(sync_ctx->t, sync_ctx->idx_seq,
-						MODIFY_REMOVE, MAIL_RECENT,
-						idx_keywords);
+						MODIFY_REMOVE, MAIL_RECENT);
 		}
+
+		// FIXME: keywords
 	}
 
 	if (mail_ctx->recent &&



More information about the dovecot-cvs mailing list