[dovecot-cvs] dovecot/src/lib-storage mail-copy.c, 1.1, 1.2 mail-storage-private.h, 1.9, 1.10 mail-storage.c, 1.31, 1.32 mail-storage.h, 1.84, 1.85 proxy-mail.c, 1.6, 1.7 proxy-mailbox.c, 1.12, 1.13

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


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

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



Index: mail-copy.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib-storage/mail-copy.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- mail-copy.c	22 Aug 2004 09:17:08 -0000	1.1
+++ mail-copy.c	26 Dec 2004 09:12:41 -0000	1.2
@@ -10,7 +10,8 @@
 {
 	struct mail_save_context *ctx;
 	struct istream *input;
-	const char *from_envelope;
+	struct mail_keywords *keywords;
+	const char *from_envelope, *const *keywords_list;
 
 	input = mail->get_stream(mail, NULL, NULL);
 	if (input == NULL)
@@ -18,9 +19,13 @@
 
 	from_envelope = mail->get_special(mail, MAIL_FETCH_FROM_ENVELOPE);
 
-	ctx = mailbox_save_init(t, mail->get_flags(mail),
+	keywords_list = mail->get_keywords(mail);
+	keywords = keywords_list == NULL ? NULL :
+		mailbox_keywords_create(t, keywords_list);
+	ctx = mailbox_save_init(t, mail->get_flags(mail), keywords,
 				mail->get_received_date(mail),
 				0, from_envelope, input, dest_mail_r != NULL);
+
 	while (i_stream_read(input) != -1) {
 		if (mailbox_save_continue(ctx) < 0)
 			break;

Index: mail-storage-private.h
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib-storage/mail-storage-private.h,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -d -r1.9 -r1.10
--- mail-storage-private.h	29 Aug 2004 07:52:02 -0000	1.9
+++ mail-storage-private.h	26 Dec 2004 09:12:41 -0000	1.10
@@ -81,6 +81,10 @@
 				  enum mailbox_sync_flags flags);
 	void (*transaction_rollback)(struct mailbox_transaction_context *t);
 
+	struct mail_keywords *
+		(*keywords_create)(struct mailbox_transaction_context *t,
+				   const char *const keywords[]);
+
 	struct mail *(*fetch)(struct mailbox_transaction_context *t,
 			      uint32_t seq,
 			      enum mail_fetch_field wanted_fields);
@@ -105,7 +109,8 @@
 
 	struct mail_save_context *
 		(*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);

Index: mail-storage.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib-storage/mail-storage.c,v
retrieving revision 1.31
retrieving revision 1.32
diff -u -d -r1.31 -r1.32
--- mail-storage.c	11 Oct 2004 18:27:40 -0000	1.31
+++ mail-storage.c	26 Dec 2004 09:12:41 -0000	1.32
@@ -347,6 +347,13 @@
 	box->notify_changes(box, min_interval, callback, context);
 }
 
+struct mail_keywords *
+mailbox_keywords_create(struct mailbox_transaction_context *t,
+			const char *const keywords[])
+{
+	return t->box->keywords_create(t, keywords);
+}
+
 struct mail *mailbox_fetch(struct mailbox_transaction_context *t, uint32_t seq,
 			   enum mail_fetch_field wanted_fields)
 {
@@ -416,12 +423,13 @@
 
 struct mail_save_context *
 mailbox_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)
 {
-	return t->box->save_init(t, flags, received_date, timezone_offset,
+	return t->box->save_init(t, flags, keywords,
+				 received_date, timezone_offset,
 				 from_envelope, input, want_mail);
 }
 

Index: mail-storage.h
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib-storage/mail-storage.h,v
retrieving revision 1.84
retrieving revision 1.85
diff -u -d -r1.84 -r1.85
--- mail-storage.h	19 Dec 2004 06:36:12 -0000	1.84
+++ mail-storage.h	26 Dec 2004 09:12:41 -0000	1.85
@@ -103,16 +103,13 @@
 
 enum mailbox_sync_type {
 	MAILBOX_SYNC_TYPE_EXPUNGE	= 0x01,
-	MAILBOX_SYNC_TYPE_FLAGS		= 0x02
+	MAILBOX_SYNC_TYPE_FLAGS		= 0x02,
+	MAILBOX_SYNC_TYPE_KEYWORDS	= 0x04
 };
 
 struct mail_storage;
-struct mail_storage_callbacks;
-struct mailbox_list;
-struct mailbox_status;
 struct mail_search_arg;
-struct fetch_context;
-struct search_context;
+struct mail_keywords;
 struct mail;
 struct mailbox;
 struct mailbox_list_context;
@@ -137,7 +134,7 @@
 
 	/* may be allocated from data stack */
 	unsigned int keywords_count;
-	const char **keywords;
+	const char *const *keywords;
 };
 
 struct mailbox_sync_rec {
@@ -289,6 +286,11 @@
 			       enum mailbox_sync_flags flags);
 void mailbox_transaction_rollback(struct mailbox_transaction_context *t);
 
+/* Build mail_keywords from NULL-terminated keywords list. */
+struct mail_keywords *
+mailbox_keywords_create(struct mailbox_transaction_context *t,
+			const char *const keywords[]);
+
 /* Simplified fetching for a single sequence. */
 struct mail *mailbox_fetch(struct mailbox_transaction_context *t, uint32_t seq,
 			   enum mail_fetch_field wanted_fields);
@@ -337,7 +339,7 @@
    require mailbox syncing, so don't set it unless you need it. */
 struct mail_save_context *
 mailbox_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);
@@ -367,7 +369,8 @@
 	unsigned int has_nuls:1; /* message data is known to contain NULs */
 	unsigned int has_no_nuls:1; /* -''- known to not contain NULs */
 
-	const struct mail_full_flags *(*get_flags)(struct mail *mail);
+	enum mail_flags (*get_flags)(struct mail *mail);
+	const char *const *(*get_keywords)(struct mail *mail);
 	const struct message_part *(*get_parts)(struct mail *mail);
 
 	/* Get the time message was received (IMAP INTERNALDATE).
@@ -402,9 +405,11 @@
 				   enum mail_fetch_field field);
 
 	/* Update message flags. */
-	int (*update_flags)(struct mail *mail,
-			    const struct mail_full_flags *flags,
-			    enum modify_type modify_type);
+	int (*update_flags)(struct mail *mail, enum modify_type modify_type,
+			    enum mail_flags flags);
+	/* Update message keywords. */
+	int (*update_keywords)(struct mail *mail, enum modify_type modify_type,
+			       const struct mail_keywords *keywords);
 
 	/* Expunge this message. Sequence numbers don't change until commit. */
 	int (*expunge)(struct mail *mail);

Index: proxy-mail.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib-storage/proxy-mail.c,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -d -r1.6 -r1.7
--- proxy-mail.c	28 Aug 2004 10:32:17 -0000	1.6
+++ proxy-mail.c	26 Dec 2004 09:12:41 -0000	1.7
@@ -3,13 +3,20 @@
 #include "lib.h"
 #include "proxy-mail.h"
 
-static const struct mail_full_flags *_get_flags(struct mail *mail)
+static enum mail_flags _get_flags(struct mail *mail)
 {
 	struct proxy_mail *p = (struct proxy_mail *) mail;
 
 	return p->mail->get_flags(p->mail);
 }
 
+static const char *const *_get_keywords(struct mail *mail)
+{
+	struct proxy_mail *p = (struct proxy_mail *) mail;
+
+	return p->mail->get_keywords(p->mail);
+}
+
 static const struct message_part *_get_parts(struct mail *mail)
 {
 	struct proxy_mail *p = (struct proxy_mail *) mail;
@@ -76,13 +83,20 @@
 	return p->mail->get_special(p->mail, field);
 }
 
-static int _update_flags(struct mail *mail,
-			 const struct mail_full_flags *flags,
-			 enum modify_type modify_type)
+static int _update_flags(struct mail *mail, enum modify_type modify_type,
+			 enum mail_flags flags)
 {
 	struct proxy_mail *p = (struct proxy_mail *) mail;
 
-	return p->mail->update_flags(p->mail, flags, modify_type);
+	return p->mail->update_flags(p->mail, modify_type, flags);
+}
+
+static int _update_keywords(struct mail *mail, enum modify_type modify_type,
+			    const struct mail_keywords *keywords)
+{
+	struct proxy_mail *p = (struct proxy_mail *) mail;
+
+	return p->mail->update_keywords(p->mail, modify_type, keywords);
 }
 
 static int _expunge(struct mail *mail)
@@ -101,6 +115,7 @@
 	pm->box = mail->box;
 
 	pm->get_flags = _get_flags;
+	pm->get_keywords = _get_keywords;
 	pm->get_parts = _get_parts;
 	pm->get_received_date = _get_received_date;
 	pm->get_date = _get_date;
@@ -111,6 +126,7 @@
 	pm->get_stream = _get_stream;
 	pm->get_special = _get_special;
 	pm->update_flags = _update_flags;
+	pm->update_keywords = _update_keywords;
 	pm->expunge = _expunge;
 }
 

Index: proxy-mailbox.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib-storage/proxy-mailbox.c,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -d -r1.12 -r1.13
--- proxy-mailbox.c	15 Sep 2004 13:20:16 -0000	1.12
+++ proxy-mailbox.c	26 Dec 2004 09:12:41 -0000	1.13
@@ -116,9 +116,20 @@
 	pbox->box->transaction_rollback(pt->ctx);
 }
 
+static struct mail_keywords *
+_keywords_create(struct mailbox_transaction_context *t,
+		 const char *const keywords[])
+{
+	struct proxy_mailbox_transaction_context *pt =
+		(struct proxy_mailbox_transaction_context *)t;
+	struct proxy_mailbox *pbox = (struct proxy_mailbox *)t->box;
+
+	return pbox->box->keywords_create(pt->ctx, keywords);
+}
+
 static struct mail_save_context *
 _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)
 {
@@ -126,7 +137,7 @@
 		(struct proxy_mailbox_transaction_context *)t;
 	struct proxy_mailbox *pbox = (struct proxy_mailbox *)t->box;
 
-	return pbox->box->save_init(pt->ctx, flags, received_date,
+	return pbox->box->save_init(pt->ctx, flags, keywords, received_date,
 				    timezone_offset, from_envelope, input,
 				    want_mail);
 }
@@ -178,6 +189,8 @@
 	pb->transaction_commit = _transaction_commit;
 	pb->transaction_rollback = _transaction_rollback;
 
+	pb->keywords_create = _keywords_create;
+
 	pb->save_init = _save_init;
 	pb->save_continue = box->save_continue;
 	pb->save_finish = box->save_finish;



More information about the dovecot-cvs mailing list