[dovecot-cvs] dovecot/src/lib-storage/index/mbox mbox-save.c,1.30,1.31 mbox-storage.c,1.31,1.32 mbox-storage.h,1.12,1.13

cras at procontrol.fi cras at procontrol.fi
Mon Jan 20 16:52:54 EET 2003


Update of /home/cvs/dovecot/src/lib-storage/index/mbox
In directory danu:/tmp/cvs-serv7093/lib-storage/index/mbox

Modified Files:
	mbox-save.c mbox-storage.c mbox-storage.h 
Log Message:
mail-storage.h interface changes, affects pretty much everything.
FETCH, SEARCH, SORT and THREAD handling were pretty much moved from
lib-storage/ to imap/ so adding non-index storages would be much easier now.
Also POP3 server can now be easily implemented with lib-storage.

Not too well tested, and at least one major problem: partial fetching is
_slow_.



Index: mbox-save.c
===================================================================
RCS file: /home/cvs/dovecot/src/lib-storage/index/mbox/mbox-save.c,v
retrieving revision 1.30
retrieving revision 1.31
diff -u -d -r1.30 -r1.31
--- mbox-save.c	5 Jan 2003 13:09:53 -0000	1.30
+++ mbox-save.c	20 Jan 2003 14:52:52 -0000	1.31
@@ -107,11 +107,12 @@
 
 static int write_flags(struct mail_storage *storage, struct ostream *output,
 		       const char *mbox_path,
-		       enum mail_flags flags, const char *custom_flags[])
+		       const struct mail_full_flags *full_flags)
 {
+	enum mail_flags flags = full_flags->flags;
 	const char *str;
 	unsigned int field;
-	int i;
+	unsigned int i;
 
 	if (flags == 0)
 		return TRUE;
@@ -138,15 +139,18 @@
 			return write_error(storage, mbox_path);
 
 		field = 1 << MAIL_CUSTOM_FLAG_1_BIT;
-		for (i = 0; i < MAIL_CUSTOM_FLAGS_COUNT; i++, field <<= 1) {
-			if ((flags & field) && custom_flags[i] != NULL) {
+		for (i = 0; i < full_flags->custom_flags_count; i++) {
+			const char *custom_flag = full_flags->custom_flags[i];
+
+			if ((flags & field) && custom_flag != NULL) {
 				if (o_stream_send(output, " ", 1) < 0)
 					return write_error(storage, mbox_path);
 
-				if (o_stream_send_str(output,
-						      custom_flags[i]) < 0)
+				if (o_stream_send_str(output, custom_flag) < 0)
 					return write_error(storage, mbox_path);
 			}
+
+                        field <<= 1;
 		}
 
 		if (o_stream_send(output, "\n", 1) < 0)
@@ -156,8 +160,8 @@
 	return TRUE;
 }
 
-int mbox_storage_save(struct mailbox *box, enum mail_flags flags,
-		      const char *custom_flags[], time_t internal_date,
+int mbox_storage_save(struct mailbox *box, const struct mail_full_flags *flags,
+		      time_t internal_date,
 		      int timezone_offset __attr_unused__,
 		      struct istream *data, uoff_t data_size)
 {
@@ -176,8 +180,10 @@
 
 	/* we don't need the real flag positions, easier to keep using our own.
 	   they need to be checked/added though. */
-	real_flags = flags;
-	if (!index_mailbox_fix_custom_flags(ibox, &real_flags, custom_flags))
+	real_flags = flags->flags;
+	if (!index_mailbox_fix_custom_flags(ibox, &real_flags,
+					    flags->custom_flags,
+					    flags->custom_flags_count))
 		return FALSE;
 
 	if (!index_storage_sync_and_lock(ibox, FALSE, MAIL_LOCK_EXCLUSIVE))
@@ -198,8 +204,7 @@
 
 		if (!write_from_line(box->storage, output, mbox_path,
 				     internal_date) ||
-		    !write_flags(box->storage, output, mbox_path, flags,
-				 custom_flags) ||
+		    !write_flags(box->storage, output, mbox_path, flags) ||
 		    !index_storage_save(box->storage, mbox_path,
 					data, output, data_size) ||
 		    !mbox_append_lf(box->storage, output, mbox_path)) {

Index: mbox-storage.c
===================================================================
RCS file: /home/cvs/dovecot/src/lib-storage/index/mbox/mbox-storage.c,v
retrieving revision 1.31
retrieving revision 1.32
diff -u -d -r1.31 -r1.32
--- mbox-storage.c	11 Jan 2003 15:44:16 -0000	1.31
+++ mbox-storage.c	20 Jan 2003 14:52:52 -0000	1.32
@@ -620,8 +620,15 @@
 	index_storage_expunge,
 	index_storage_update_flags,
 	index_storage_copy,
-	index_storage_fetch,
-	index_storage_search,
+	index_storage_fetch_init,
+	index_storage_fetch_deinit,
+	index_storage_fetch_next,
+	index_storage_fetch_uid,
+	index_storage_fetch_seq,
+        index_storage_search_get_sorting,
+	index_storage_search_init,
+	index_storage_search_deinit,
+	index_storage_search_next,
 	mbox_storage_save,
 	mail_storage_is_inconsistency_error,
 

Index: mbox-storage.h
===================================================================
RCS file: /home/cvs/dovecot/src/lib-storage/index/mbox/mbox-storage.h,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -d -r1.12 -r1.13
--- mbox-storage.h	11 Jan 2003 19:55:57 -0000	1.12
+++ mbox-storage.h	20 Jan 2003 14:52:52 -0000	1.13
@@ -5,9 +5,8 @@
 
 int mbox_storage_copy(struct mailbox *box, struct mailbox *destbox,
 		      const char *messageset, int uidset);
-int mbox_storage_save(struct mailbox *box, enum mail_flags flags,
-		      const char *custom_flags[], time_t internal_date,
-		      int timezone_offset,
+int mbox_storage_save(struct mailbox *box, const struct mail_full_flags *flags,
+		      time_t internal_date, int timezone_offset,
 		      struct istream *data, uoff_t data_size);
 
 int mbox_find_mailboxes(struct mail_storage *storage, const char *mask,




More information about the dovecot-cvs mailing list