* mu: allow 'recip:' in queries as a shortcut for "to:foo OR cc:foo OR bcc:foo"

This commit is contained in:
djcb
2012-10-25 12:28:55 +03:00
parent 9bf8edf03b
commit 412de6f4aa
5 changed files with 31 additions and 11 deletions

View File

@ -67,6 +67,10 @@ static const MuMsgFieldId MU_MSG_FIELD_ID_NONE = (MuMsgFieldId)-1;
* in mu-query.cc and mu-str.c */
#define MU_MSG_FIELD_PSEUDO_CONTACT "contact"
/* this is a shortcut for To/Cc/Bcc in queries; handled specially in
* mu-query.cc and mu-str.c */
#define MU_MSG_FIELD_PSEUDO_RECIP "recip"
#define mu_msg_field_id_is_valid(MFID) \
((MFID) < MU_MSG_FIELD_ID_NUM)

View File

@ -187,8 +187,7 @@ private:
void add_special_prefixes () {
char pfx[] = { '\0', '\0' };
/* add 'contact' as a shortcut for
* From/Cc/Bcc/To: */
/* add 'contact' as a shortcut for From/Cc/Bcc/To: */
pfx[0] = mu_msg_field_xapian_prefix(MU_MSG_FIELD_ID_FROM);
_qparser.add_prefix (MU_MSG_FIELD_PSEUDO_CONTACT, pfx);
pfx[0] = mu_msg_field_xapian_prefix(MU_MSG_FIELD_ID_TO);
@ -197,6 +196,14 @@ private:
_qparser.add_prefix (MU_MSG_FIELD_PSEUDO_CONTACT, pfx);
pfx[0] = mu_msg_field_xapian_prefix(MU_MSG_FIELD_ID_BCC);
_qparser.add_prefix (MU_MSG_FIELD_PSEUDO_CONTACT, pfx);
/* add 'recip' as a shortcut for Cc/Bcc/To: */
pfx[0] = mu_msg_field_xapian_prefix(MU_MSG_FIELD_ID_TO);
_qparser.add_prefix (MU_MSG_FIELD_PSEUDO_RECIP, pfx);
pfx[0] = mu_msg_field_xapian_prefix(MU_MSG_FIELD_ID_CC);
_qparser.add_prefix (MU_MSG_FIELD_PSEUDO_RECIP, pfx);
pfx[0] = mu_msg_field_xapian_prefix(MU_MSG_FIELD_ID_BCC);
_qparser.add_prefix (MU_MSG_FIELD_PSEUDO_RECIP, pfx);
}
Xapian::QueryParser _qparser;

View File

@ -439,8 +439,11 @@ check_for_field (const char *str, gboolean *is_field,
&pfx);
/* also check special prefixes... */
if (!pfx.match)
pfx.match = g_str_has_prefix
(str, MU_MSG_FIELD_PSEUDO_CONTACT ":");
pfx.match =
g_str_has_prefix
(str, MU_MSG_FIELD_PSEUDO_CONTACT ":") ||
g_str_has_prefix
(str, MU_MSG_FIELD_PSEUDO_RECIP ":");
*is_field = pfx.match;
*is_range_field = pfx.range_field;