* add 'flag:unread' as a synonym for 'flag:new OR NOT flag:seen'
- update documentation - update test cases - some cleanups in the C++-code - bump the database version, to trigger the --rebuild warning
This commit is contained in:
@ -99,7 +99,8 @@ mu_msg_file_get_flags_from_path (const char *path)
|
||||
|
||||
mtype = check_msg_type (path, &info);
|
||||
if (mtype == MSG_TYPE_NEW) { /* we ignore any new-msg flags */
|
||||
flags = MU_MSG_FLAG_NEW;
|
||||
/* note NEW implies UNREAD */
|
||||
flags = MU_MSG_FLAG_NEW | MU_MSG_FLAG_UNREAD;
|
||||
goto leave;
|
||||
}
|
||||
|
||||
@ -120,6 +121,10 @@ mu_msg_file_get_flags_from_path (const char *path)
|
||||
}
|
||||
}
|
||||
|
||||
/* the UNREAD pseudo flag => NEW OR NOT SEEN */
|
||||
if (!(flags & MU_MSG_FLAG_SEEN))
|
||||
flags |= MU_MSG_FLAG_UNREAD;
|
||||
|
||||
leave:
|
||||
g_free(info);
|
||||
return flags;
|
||||
@ -147,7 +152,7 @@ get_flags_str_s (MuMsgFlags flags)
|
||||
flagstr[i++] = 'S';
|
||||
if (flags & MU_MSG_FLAG_TRASHED)
|
||||
flagstr[i++] = 'T';
|
||||
|
||||
|
||||
flagstr[i] = '\0';
|
||||
|
||||
return flagstr;
|
||||
|
||||
@ -37,6 +37,7 @@ static const MuMsgFlags ALL_FLAGS[] = {
|
||||
/* r */ MU_MSG_FLAG_REPLIED,
|
||||
/* s */ MU_MSG_FLAG_SEEN,
|
||||
/* t */ MU_MSG_FLAG_TRASHED,
|
||||
/* u */ MU_MSG_FLAG_UNREAD,
|
||||
/* x */ MU_MSG_FLAG_ENCRYPTED,
|
||||
/* z */ MU_MSG_FLAG_SIGNED
|
||||
};
|
||||
@ -53,7 +54,10 @@ mu_msg_flag_from_char (char k)
|
||||
case 't': return MU_MSG_FLAG_TRASHED;
|
||||
case 'd': return MU_MSG_FLAG_DRAFT;
|
||||
case 'f': return MU_MSG_FLAG_FLAGGED;
|
||||
|
||||
|
||||
/* NEW OR NOT SEEN */
|
||||
case 'u': return MU_MSG_FLAG_UNREAD;
|
||||
|
||||
case 'z': return MU_MSG_FLAG_SIGNED;
|
||||
case 'x': return MU_MSG_FLAG_ENCRYPTED;
|
||||
case 'a': return MU_MSG_FLAG_HAS_ATTACH;
|
||||
@ -75,6 +79,9 @@ mu_msg_flag_name (MuMsgFlags flag)
|
||||
case MU_MSG_FLAG_TRASHED: return "trashed";
|
||||
case MU_MSG_FLAG_DRAFT: return "draft";
|
||||
case MU_MSG_FLAG_FLAGGED: return "flagged";
|
||||
|
||||
/* ie., NEW or NOT SEEN */
|
||||
case MU_MSG_FLAG_UNREAD: return "unread";
|
||||
|
||||
case MU_MSG_FLAG_SIGNED: return "signed";
|
||||
case MU_MSG_FLAG_ENCRYPTED: return "encrypted";
|
||||
@ -96,6 +103,9 @@ mu_msg_flag_char (MuMsgFlags flag)
|
||||
case MU_MSG_FLAG_TRASHED: return 't';
|
||||
case MU_MSG_FLAG_DRAFT: return 'd';
|
||||
case MU_MSG_FLAG_FLAGGED: return 'f';
|
||||
|
||||
/* NEW OR NOT SEEN */
|
||||
case MU_MSG_FLAG_UNREAD: return 'u';
|
||||
|
||||
case MU_MSG_FLAG_SIGNED: return 'z';
|
||||
case MU_MSG_FLAG_ENCRYPTED: return 'x';
|
||||
|
||||
@ -56,14 +56,19 @@ enum _MuMsgFlags {
|
||||
/* "F"->flagged message */
|
||||
MU_MSG_FLAG_FLAGGED = 1 << 6,
|
||||
|
||||
/* "U"->unread message; it's a pseudo/convenience flag that
|
||||
* means (NEW or not SEEN) */
|
||||
MU_MSG_FLAG_UNREAD = 1 << 7,
|
||||
|
||||
|
||||
/* these we get from the contents */
|
||||
|
||||
/* "Z"->signed message */
|
||||
MU_MSG_FLAG_SIGNED = 1 << 7,
|
||||
MU_MSG_FLAG_SIGNED = 1 << 8,
|
||||
/* "X"->encrypted message */
|
||||
MU_MSG_FLAG_ENCRYPTED = 1 << 8,
|
||||
MU_MSG_FLAG_ENCRYPTED = 1 << 9,
|
||||
/* "A"->message has attachment */
|
||||
MU_MSG_FLAG_HAS_ATTACH = 1 << 9
|
||||
MU_MSG_FLAG_HAS_ATTACH = 1 << 10
|
||||
};
|
||||
typedef enum _MuMsgFlags MuMsgFlags;
|
||||
|
||||
|
||||
@ -309,30 +309,24 @@ add_terms_values_date (Xapian::Document& doc, MuMsg *msg,
|
||||
|
||||
|
||||
static void
|
||||
add_terms_values_number (Xapian::Document& doc, MuMsg *msg,
|
||||
MuMsgFieldId mfid)
|
||||
add_terms_values_number (Xapian::Document& doc, MuMsg *msg, MuMsgFieldId mfid)
|
||||
{
|
||||
const std::string pfx (1, mu_msg_field_xapian_prefix(mfid));
|
||||
gint64 num = mu_msg_get_field_numeric (msg, mfid);
|
||||
|
||||
const std::string numstr (Xapian::sortable_serialise((double)num));
|
||||
|
||||
doc.add_value ((Xapian::valueno)mfid, numstr);
|
||||
|
||||
if (mfid == MU_MSG_FIELD_ID_FLAGS) {
|
||||
const char* flags, *cur;
|
||||
cur = flags = mu_msg_flags_str_s ((MuMsgFlags)num);
|
||||
while (cur && *cur) {
|
||||
char kar = tolower (*cur);
|
||||
doc.add_term (pfx + kar);
|
||||
++cur;
|
||||
}
|
||||
for (const char *cur = mu_msg_flags_str_s ((MuMsgFlags)num);
|
||||
cur && *cur; ++cur)
|
||||
doc.add_term (pfx + (char)tolower (*cur));
|
||||
|
||||
} else if (mfid == MU_MSG_FIELD_ID_PRIO) {
|
||||
doc.add_term (pfx + std::string(1,
|
||||
mu_msg_prio_char((MuMsgPrio)num)));
|
||||
|
||||
} else
|
||||
doc.add_term (pfx + numstr);
|
||||
} //else
|
||||
// doc.add_term (pfx + numstr);
|
||||
}
|
||||
|
||||
static void
|
||||
|
||||
@ -40,14 +40,15 @@ static void test_mu_msg_file_get_flags_from_path(void)
|
||||
MuMsgFlags flags;
|
||||
} paths[] = {
|
||||
{
|
||||
"/home/foo/Maildir/test/cur/123456:2,FR",
|
||||
MU_MSG_FLAG_REPLIED | MU_MSG_FLAG_FLAGGED}, {
|
||||
"/home/foo/Maildir/test/new/123456", MU_MSG_FLAG_NEW}, {
|
||||
"/home/foo/Maildir/test/cur/123456:2,FSR",
|
||||
MU_MSG_FLAG_REPLIED | MU_MSG_FLAG_SEEN | MU_MSG_FLAG_FLAGGED}, {
|
||||
"/home/foo/Maildir/test/new/123456",
|
||||
MU_MSG_FLAG_NEW | MU_MSG_FLAG_UNREAD}, {
|
||||
"/home/foo/Maildir/test/new/123456:2,FR",
|
||||
MU_MSG_FLAG_NEW}, {
|
||||
MU_MSG_FLAG_NEW | MU_MSG_FLAG_UNREAD}, {
|
||||
"/home/foo/Maildir/test/cur/123456:2,DTP",
|
||||
MU_MSG_FLAG_DRAFT | MU_MSG_FLAG_TRASHED |
|
||||
MU_MSG_FLAG_PASSED}, {
|
||||
MU_MSG_FLAG_PASSED | MU_MSG_FLAG_UNREAD }, {
|
||||
"/home/foo/Maildir/test/cur/123456:2,S",
|
||||
MU_MSG_FLAG_SEEN}
|
||||
};
|
||||
|
||||
@ -182,7 +182,7 @@ test_mu_msg_03 (void)
|
||||
"\nLet's write some fünkÿ text\nusing umlauts.\n\nFoo.\n");
|
||||
|
||||
g_assert_cmpuint (mu_msg_get_flags(msg),
|
||||
==, 0);
|
||||
==, MU_MSG_FLAG_UNREAD);
|
||||
|
||||
|
||||
mu_msg_unref (msg);
|
||||
|
||||
Reference in New Issue
Block a user