Commit 64e41af5 authored by Richard P. Curnow's avatar Richard P. Curnow

Add flag fields to in-core database and hook up with file db.

parent f2fb55a0
......@@ -484,6 +484,9 @@ struct database *new_database_from_file(char *db_filename, int do_integrity_chec
break;
}
result->msgs[i].seen = (input->msg_type_and_flags[i] & FLAG_SEEN) ? 1:0;
result->msgs[i].replied = (input->msg_type_and_flags[i] & FLAG_REPLIED) ? 1:0;
result->msgs[i].flagged = (input->msg_type_and_flags[i] & FLAG_FLAGGED) ? 1:0;
result->msgs[i].date = input->date_table[i];
result->msgs[i].tid = input->tid_table[i];
}
......@@ -700,6 +703,9 @@ static void scan_new_messages(struct database *db, int start_at)/*{{{*/
if(msg)
{
db->msgs[i].date = msg->hdrs.date;
db->msgs[i].seen = 0;
db->msgs[i].replied = 0;
db->msgs[i].flagged = 0;
tokenise_message(i, db, msg);
free_rfc822(msg);
}
......
......@@ -51,6 +51,12 @@ struct msgpath {/*{{{*/
/* Now fields that are common to both types of message. */
time_t date; /* representation of Date: header in message */
int tid; /* thread-id */
/* Message flags. */
unsigned int seen:1;
unsigned int replied:1;
unsigned int flagged:1;
/* + other stuff eventually */
};
/*}}}*/
......
......@@ -945,6 +945,9 @@ int add_mbox_messages(struct database *db)/*{{{*/
printf("Scanning %s[%d] at [%d,%d)\n", mb->path, j, (int)start, (int)(start + len));
}
db->msgs[n].date = r8->hdrs.date;
db->msgs[n].seen = 0;
db->msgs[n].replied = 0;
db->msgs[n].flagged = 0;
tokenise_message(n, db, r8);
free_rfc822(r8);
} else {
......
......@@ -118,6 +118,10 @@
#define DB_MSG_MBOX 2
/*}}}*/
#define FLAG_SEEN (1<<3)
#define FLAG_REPLIED (1<<4)
#define FLAG_FLAGGED (1<<5)
struct toktable_db {/*{{{*/
unsigned int n; /* number of entries in this table */
unsigned int *tok_offsets; /* offset to table of token offsets */
......
......@@ -307,10 +307,11 @@ static void write_header(char *data, unsigned int *uidata, struct database *db,
return;
}
/*}}}*/
static char *write_type_table(struct database *db, unsigned int *uidata, char *data, char *cdata)/*{{{*/
static char *write_type_and_flag_table(struct database *db, unsigned int *uidata, char *data, char *cdata)/*{{{*/
{
int i;
for (i=0; i<db->n_msgs; i++) {
struct msgpath *msgdata = db->msgs + i;
switch (db->type[i]) {
case MTY_FILE:
cdata[i] = DB_MSG_FILE;
......@@ -322,6 +323,10 @@ static char *write_type_table(struct database *db, unsigned int *uidata, char *d
cdata[i] = DB_MSG_DEAD;
break;
}
if (msgdata->seen) cdata[i] |= FLAG_SEEN;
if (msgdata->replied) cdata[i] |= FLAG_REPLIED;
if (msgdata->flagged) cdata[i] |= FLAG_FLAGGED;
}
uidata[UI_MSG_TYPE_AND_FLAGS] = cdata - data;
return cdata + db->n_msgs;
......@@ -579,7 +584,7 @@ void write_database(struct database *db, char *filename, int do_integrity_checks
cdata = data + (4 * map.beyond_last_ui_offset);
write_header(data, uidata, db, &map);
cdata = write_type_table(db, uidata, data, cdata);
cdata = write_type_and_flag_table(db, uidata, data, cdata);
cdata = write_messages(db, &map, uidata, data, cdata);
cdata = write_mbox_headers(db, &map, uidata, data, cdata);
cdata = write_mbox_checksums(db, &map, uidata, data, cdata);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment