[dovecot-cvs] dovecot/src/lib-storage/index/maildir maildir-copy.c,
1.32, 1.33 maildir-mail.c, 1.8, 1.9 maildir-save.c, 1.45,
1.46 maildir-storage.c, 1.87, 1.88 maildir-storage.h, 1.32,
1.33 maildir-sync.c, 1.47, 1.48 maildir-util.c, 1.8, 1.9
cras at dovecot.org
cras at dovecot.org
Sun Dec 26 11:12:46 EET 2004
- Previous message: [dovecot-cvs] dovecot/src/lib-storage/index index-mail.c, 1.66,
1.67 index-mail.h, 1.24, 1.25 index-search.c, 1.97,
1.98 index-status.c, 1.34, 1.35 index-storage.c, 1.65,
1.66 index-storage.h, 1.84, 1.85 index-sync.c, 1.44, 1.45
- Next message: [dovecot-cvs]
dovecot/src/pop3 client.c, 1.45, 1.46 commands.c, 1.37, 1.38
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
Update of /var/lib/cvs/dovecot/src/lib-storage/index/maildir
In directory talvi:/tmp/cvs-serv26125/lib-storage/index/maildir
Modified Files:
maildir-copy.c maildir-mail.c maildir-save.c maildir-storage.c
maildir-storage.h maildir-sync.c maildir-util.c
Log Message:
Initial support for keywords. Syncing to mbox/maildir doesn't work yet.
Index: maildir-copy.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib-storage/index/maildir/maildir-copy.c,v
retrieving revision 1.32
retrieving revision 1.33
diff -u -d -r1.32 -r1.33
--- maildir-copy.c 22 Aug 2004 09:17:08 -0000 1.32
+++ maildir-copy.c 26 Dec 2004 09:12:43 -0000 1.33
@@ -59,12 +59,14 @@
struct index_mail *imail = (struct index_mail *) mail;
struct hardlink_ctx do_ctx;
struct rollback *rb;
- const struct mail_full_flags *flags;
+ enum mail_flags flags;
+ const char *const *keywords;
const char *dest_fname;
flags = mail->get_flags(mail);
+ keywords = mail->get_keywords(mail);
dest_fname = maildir_generate_tmp_filename(&ioloop_timeval);
- dest_fname = maildir_filename_set_flags(dest_fname, flags->flags, NULL);
+ dest_fname = maildir_filename_set_flags(dest_fname, flags, keywords);
memset(&do_ctx, 0, sizeof(do_ctx));
do_ctx.dest_path =
Index: maildir-mail.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib-storage/index/maildir/maildir-mail.c,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -d -r1.8 -r1.9
--- maildir-mail.c 19 Dec 2004 06:36:12 -0000 1.8
+++ maildir-mail.c 26 Dec 2004 09:12:43 -0000 1.9
@@ -232,6 +232,7 @@
0, 0, 0, 0, 0, 0,
index_mail_get_flags,
+ index_mail_get_keywords,
index_mail_get_parts,
maildir_mail_get_received_date,
index_mail_get_date,
@@ -242,5 +243,6 @@
maildir_mail_get_stream,
maildir_mail_get_special,
index_mail_update_flags,
+ index_mail_update_keywords,
index_mail_expunge
};
Index: maildir-save.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib-storage/index/maildir/maildir-save.c,v
retrieving revision 1.45
retrieving revision 1.46
diff -u -d -r1.45 -r1.46
--- maildir-save.c 24 Nov 2004 17:32:06 -0000 1.45
+++ maildir-save.c 26 Dec 2004 09:12:43 -0000 1.46
@@ -106,7 +106,7 @@
struct mail_save_context *
maildir_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 __attr_unused__,
struct istream *input, int want_mail __attr_unused__)
@@ -118,8 +118,6 @@
struct maildir_filename *mf;
struct ostream *output;
const char *fname, *dest_fname, *path;
- enum mail_flags mail_flags;
- keywords_mask_t keywords;
t_push();
@@ -149,19 +147,16 @@
o_stream_create_lf(default_pool, output);
o_stream_unref(output);
- mail_flags = (flags->flags & ~MAIL_RECENT) |
- (ibox->keep_recent ? MAIL_RECENT : 0);
- /*FIXME:if (!index_mailbox_fix_keywords(ibox, &mail_flags,
- flags->keywords,
- flags->keywords_count))
- return FALSE;*/
+ flags &= ~MAIL_RECENT;
+ if (ibox->keep_recent)
+ flags |= MAIL_RECENT;
/* now, we want to be able to rollback the whole append session,
so we'll just store the name of this temp file and move it later
into new/ or cur/. if dest_fname is NULL, it's moved to new/,
otherwise to cur/. */
- dest_fname = mail_flags == MAIL_RECENT ? NULL :
- maildir_filename_set_flags(fname, mail_flags, NULL);
+ dest_fname = flags == MAIL_RECENT ? NULL :
+ maildir_filename_set_flags(fname, flags, NULL); // FIXME
mf = p_new(ctx->pool, struct maildir_filename, 1);
mf->next = ctx->files;
@@ -170,12 +165,12 @@
ctx->files = mf;
/* insert into index */
- memset(keywords, 0, INDEX_KEYWORDS_BYTE_COUNT);
- // FIXME: set keywords
-
mail_index_append(ctx->trans, 0, &ctx->seq);
- mail_index_update_flags(ctx->trans, ctx->seq, MODIFY_REPLACE,
- mail_flags, keywords);
+ mail_index_update_flags(ctx->trans, ctx->seq, MODIFY_REPLACE, flags);
+ if (keywords != NULL) {
+ mail_index_update_keywords(ctx->trans, ctx->seq,
+ MODIFY_REPLACE, keywords);
+ }
t_pop();
ctx->failed = FALSE;
Index: maildir-storage.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib-storage/index/maildir/maildir-storage.c,v
retrieving revision 1.87
retrieving revision 1.88
diff -u -d -r1.87 -r1.88
--- maildir-storage.c 11 Nov 2004 22:24:08 -0000 1.87
+++ maildir-storage.c 26 Dec 2004 09:12:43 -0000 1.88
@@ -794,6 +794,7 @@
maildir_transaction_begin,
maildir_transaction_commit,
maildir_transaction_rollback,
+ index_keywords_create,
index_storage_fetch,
index_storage_get_uids,
index_header_lookup_init,
Index: maildir-storage.h
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib-storage/index/maildir/maildir-storage.h,v
retrieving revision 1.32
retrieving revision 1.33
diff -u -d -r1.32 -r1.33
--- maildir-storage.h 19 Dec 2004 08:33:58 -0000 1.32
+++ maildir-storage.h 26 Dec 2004 09:12:43 -0000 1.33
@@ -58,7 +58,7 @@
struct mail_save_context *
maildir_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);
@@ -79,10 +79,11 @@
int maildir_sync_last_commit(struct index_mailbox *ibox);
-int maildir_filename_get_flags(const char *fname, enum mail_flags *flags_r,
- keywords_mask_t keywords_r);
+int maildir_filename_get_flags(const char *fname, pool_t pool,
+ enum mail_flags *flags_r,
+ const char *const **keywords_r);
const char *maildir_filename_set_flags(const char *fname, enum mail_flags flags,
- keywords_mask_t keywords);
+ const char *const *keywords);
unsigned int maildir_hash(const void *p);
int maildir_cmp(const void *p1, const void *p2);
Index: maildir-sync.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib-storage/index/maildir/maildir-sync.c,v
retrieving revision 1.47
retrieving revision 1.48
diff -u -d -r1.47 -r1.48
--- maildir-sync.c 5 Dec 2004 01:45:54 -0000 1.47
+++ maildir-sync.c 26 Dec 2004 09:12:43 -0000 1.48
@@ -229,15 +229,16 @@
struct maildir_index_sync_context *ctx = context;
const char *newpath;
enum mail_flags flags;
+ const char *const *keywords;
uint8_t flags8;
- keywords_mask_t keywords;
ctx->dirty_state = 0;
- (void)maildir_filename_get_flags(path, &flags, keywords);
+ (void)maildir_filename_get_flags(path, pool_datastack_create(),
+ &flags, &keywords);
flags8 = flags;
- mail_index_sync_flags_apply(&ctx->sync_rec, &flags8, keywords);
+ mail_index_sync_flags_apply(&ctx->sync_rec, &flags8);
newpath = maildir_filename_set_flags(path, flags8, keywords);
if (rename(path, newpath) == 0) {
@@ -250,9 +251,8 @@
return 0;
if (ENOSPACE(errno) || errno == EACCES) {
- memset(keywords, 0, sizeof(keywords));
mail_index_update_flags(ctx->trans, ctx->seq, MODIFY_ADD,
- MAIL_INDEX_MAIL_FLAG_DIRTY, keywords);
+ MAIL_INDEX_MAIL_FLAG_DIRTY);
ctx->dirty_state = 1;
return 1;
}
@@ -308,15 +308,15 @@
return -1;
if (ctx->dirty_state < 0) {
/* flag isn't dirty anymore */
- keywords_mask_t keywords;
-
- memset(keywords, 0, sizeof(keywords));
mail_index_update_flags(ctx->trans, ctx->seq,
- MODIFY_REMOVE,
- MAIL_INDEX_MAIL_FLAG_DIRTY, keywords);
+ MODIFY_REMOVE,
+ MAIL_INDEX_MAIL_FLAG_DIRTY);
}
}
break;
+ case MAIL_INDEX_SYNC_TYPE_KEYWORDS:
+ // FIXME
+ break;
}
return 0;
@@ -604,7 +604,7 @@
enum maildir_uidlist_rec_flag uflags;
const char *filename;
enum mail_flags flags;
- keywords_mask_t keywords;
+ const char *const *keywords;
uint32_t uid_validity, next_uid;
int ret;
@@ -628,7 +628,9 @@
seq = 0;
iter = maildir_uidlist_iter_init(ibox->uidlist);
while (maildir_uidlist_iter_next(iter, &uid, &uflags, &filename)) {
- maildir_filename_get_flags(filename, &flags, keywords);
+ // FIXME: t_push..
+ maildir_filename_get_flags(filename, pool_datastack_create(),
+ &flags, &keywords);
if ((uflags & MAILDIR_UIDLIST_REC_FLAG_RECENT) != 0 &&
(uflags & MAILDIR_UIDLIST_REC_FLAG_NEW_DIR) != 0 &&
@@ -680,7 +682,8 @@
mail_index_append(trans, uid, &seq);
mail_index_update_flags(trans, seq, MODIFY_REPLACE,
- flags, keywords);
+ flags);
+ // FIXME: set keywords
continue;
}
@@ -733,7 +736,7 @@
} else {
mail_index_update_flags(trans, seq,
MODIFY_REMOVE,
- MAIL_RECENT, keywords);
+ MAIL_RECENT);
}
}
@@ -749,21 +752,19 @@
}
if (((uint8_t)flags & ~MAIL_RECENT) !=
- (rec->flags & (MAIL_FLAGS_MASK^MAIL_RECENT)) ||
- memcmp(keywords, rec->keywords,
- INDEX_KEYWORDS_BYTE_COUNT) != 0) {
+ (rec->flags & (MAIL_FLAGS_MASK^MAIL_RECENT))) {
/* FIXME: this is wrong if there's pending changes in
transaction log already. it gets fixed in next sync
however.. */
mail_index_update_flags(trans, seq, MODIFY_REPLACE,
- flags, keywords);
+ flags);
} else if ((flags & MAIL_RECENT) == 0 &&
(rec->flags & MAIL_RECENT) != 0) {
/* just remove recent flag */
- memset(keywords, 0, sizeof(keywords));
mail_index_update_flags(trans, seq, MODIFY_REMOVE,
- MAIL_RECENT, keywords);
+ MAIL_RECENT);
}
+ // FIXME: update keywords
}
maildir_uidlist_iter_deinit(iter);
Index: maildir-util.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib-storage/index/maildir/maildir-util.c,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -d -r1.8 -r1.9
--- maildir-util.c 5 Sep 2004 20:03:37 -0000 1.8
+++ maildir-util.c 26 Dec 2004 09:12:43 -0000 1.9
@@ -63,14 +63,15 @@
return ret == -2 ? 0 : ret;
}
-int maildir_filename_get_flags(const char *fname, enum mail_flags *flags_r,
- keywords_mask_t keywords_r)
+int maildir_filename_get_flags(const char *fname, pool_t pool,
+ enum mail_flags *flags_r,
+ const char *const **keywords_r)
{
const char *info;
unsigned int num;
*flags_r = 0;
- memset(keywords_r, 0, INDEX_KEYWORDS_BYTE_COUNT);
+ *keywords_r = NULL;
info = strchr(fname, ':');
if (info == NULL || info[1] != '2' || info[2] != ',')
@@ -95,9 +96,8 @@
break;
default:
if (*info >= 'a' && *info <= 'z') {
- /* keyword */
+ /* FIXME: keyword */
num = (*info - 'a');
- keywords_r[num / CHAR_BIT] |= num % CHAR_BIT;
break;
}
@@ -110,21 +110,12 @@
}
const char *maildir_filename_set_flags(const char *fname, enum mail_flags flags,
- keywords_mask_t keywords)
+ const char *const *keywords)
{
string_t *flags_str;
+ enum mail_flags flags_left;
const char *info, *oldflags;
- int i, nextflag;
-
- if (keywords != NULL) {
- /* see if any keywords are given */
- for (i = 0; i < INDEX_KEYWORDS_BYTE_COUNT; i++) {
- if (keywords[i] != 0)
- break;
- }
- if (i == INDEX_KEYWORDS_BYTE_COUNT)
- keywords = NULL;
- }
+ int nextflag;
/* remove the old :info from file name, and get the old flags */
info = strrchr(fname, ':');
@@ -143,6 +134,7 @@
flags_str = t_str_new(256);
str_append(flags_str, fname);
str_append(flags_str, ":2,");
+ flags_left = flags;
for (;;) {
/* skip all known flags */
while (*oldflags == 'D' || *oldflags == 'F' ||
@@ -154,34 +146,29 @@
nextflag = *oldflags == '\0' || *oldflags == ',' ? 256 :
(unsigned char) *oldflags;
- if ((flags & MAIL_DRAFT) && nextflag > 'D') {
+ if ((flags_left & MAIL_DRAFT) && nextflag > 'D') {
str_append_c(flags_str, 'D');
- flags &= ~MAIL_DRAFT;
+ flags_left &= ~MAIL_DRAFT;
}
- if ((flags & MAIL_FLAGGED) && nextflag > 'F') {
+ if ((flags_left & MAIL_FLAGGED) && nextflag > 'F') {
str_append_c(flags_str, 'F');
- flags &= ~MAIL_FLAGGED;
+ flags_left &= ~MAIL_FLAGGED;
}
- if ((flags & MAIL_ANSWERED) && nextflag > 'R') {
+ if ((flags_left & MAIL_ANSWERED) && nextflag > 'R') {
str_append_c(flags_str, 'R');
- flags &= ~MAIL_ANSWERED;
+ flags_left &= ~MAIL_ANSWERED;
}
- if ((flags & MAIL_SEEN) && nextflag > 'S') {
+ if ((flags_left & MAIL_SEEN) && nextflag > 'S') {
str_append_c(flags_str, 'S');
- flags &= ~MAIL_SEEN;
+ flags_left &= ~MAIL_SEEN;
}
- if ((flags & MAIL_DELETED) && nextflag > 'T') {
+ if ((flags_left & MAIL_DELETED) && nextflag > 'T') {
str_append_c(flags_str, 'T');
- flags &= ~MAIL_DELETED;
+ flags_left &= ~MAIL_DELETED;
}
if (keywords != NULL && nextflag > 'a') {
- for (i = 0; i < INDEX_KEYWORDS_COUNT; i++) {
- if ((keywords[i / CHAR_BIT] &
- (1 << (i % CHAR_BIT))) != 0)
- str_append_c(flags_str, 'a' + i);
- }
- keywords = NULL;
+ // FIXME
}
if (*oldflags == '\0' || *oldflags == ',')
- Previous message: [dovecot-cvs] dovecot/src/lib-storage/index index-mail.c, 1.66,
1.67 index-mail.h, 1.24, 1.25 index-search.c, 1.97,
1.98 index-status.c, 1.34, 1.35 index-storage.c, 1.65,
1.66 index-storage.h, 1.84, 1.85 index-sync.c, 1.44, 1.45
- Next message: [dovecot-cvs]
dovecot/src/pop3 client.c, 1.45, 1.46 commands.c, 1.37, 1.38
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
More information about the dovecot-cvs
mailing list