* mu: add 'contact:' as an alias for to:/from:/cc:/bcc:
This commit is contained in:
@ -63,6 +63,10 @@ typedef guint8 MuMsgFieldId;
|
||||
static const MuMsgFieldId MU_MSG_FIELD_ID_NONE = (MuMsgFieldId)-1;
|
||||
#define MU_MSG_STRING_FIELD_ID_NUM (MU_MSG_FIELD_ID_UID + 1)
|
||||
|
||||
/* this is a shortcut for To/From/Cc/Bcc in queries; handled specially
|
||||
* in mu-query.cc and mu-str.c */
|
||||
#define MU_MSG_FIELD_PSEUDO_CONTACT "contact"
|
||||
|
||||
#define mu_msg_field_id_is_valid(MFID) \
|
||||
((MFID) < MU_MSG_FIELD_ID_NUM)
|
||||
|
||||
|
||||
@ -166,6 +166,9 @@ public:
|
||||
|
||||
mu_msg_field_foreach ((MuMsgFieldForeachFunc)add_prefix,
|
||||
&_qparser);
|
||||
|
||||
/* add some convenient special prefixes */
|
||||
add_special_prefixes ();
|
||||
}
|
||||
|
||||
~_MuQuery () { mu_store_unref (_store); }
|
||||
@ -181,6 +184,21 @@ public:
|
||||
Xapian::QueryParser& query_parser () { return _qparser; }
|
||||
|
||||
private:
|
||||
void add_special_prefixes () {
|
||||
char pfx[] = { '\0', '\0' };
|
||||
|
||||
/* 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);
|
||||
_qparser.add_prefix (MU_MSG_FIELD_PSEUDO_CONTACT, pfx);
|
||||
pfx[0] = mu_msg_field_xapian_prefix(MU_MSG_FIELD_ID_CC);
|
||||
_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);
|
||||
}
|
||||
|
||||
Xapian::QueryParser _qparser;
|
||||
MuDateRangeProcessor _date_range_processor;
|
||||
MuSizeRangeProcessor _size_range_processor;
|
||||
|
||||
@ -437,6 +437,10 @@ check_for_field (const char *str, gboolean *is_field,
|
||||
|
||||
mu_msg_field_foreach ((MuMsgFieldForeachFunc)each_check_prefix,
|
||||
&pfx);
|
||||
/* also check special prefixes... */
|
||||
if (!pfx.match)
|
||||
pfx.match = g_str_has_prefix
|
||||
(str, MU_MSG_FIELD_PSEUDO_CONTACT ":");
|
||||
|
||||
*is_field = pfx.match;
|
||||
*is_range_field = pfx.range_field;
|
||||
|
||||
Reference in New Issue
Block a user