mirror of https://github.com/djcb/mu.git
* mu-msg-fields.[ch]: add info whether the field should be normalized/escaped
This commit is contained in:
parent
6a62a52015
commit
d573c57485
|
@ -33,8 +33,10 @@ enum _FieldFlags {
|
|||
FLAG_XAPIAN_INDEX = 1 << 1, /* field is indexed in xapian */
|
||||
FLAG_XAPIAN_TERM = 1 << 2, /* field stored as term in xapian */
|
||||
FLAG_XAPIAN_VALUE = 1 << 3, /* field stored as value in xapian */
|
||||
FLAG_XAPIAN_CONTACT = 1 << 4 /* field contains an e-mail
|
||||
* address */
|
||||
FLAG_XAPIAN_CONTACT = 1 << 4, /* field contains an e-mail-addr */
|
||||
FLAG_XAPIAN_ESCAPE = 1 << 5, /* field needs escaping for xapian */
|
||||
FLAG_NORMALIZE = 1 << 6 /* field needs fix for case/accents */
|
||||
|
||||
};
|
||||
typedef enum _FieldFlags FieldFlags;
|
||||
|
||||
|
@ -61,7 +63,7 @@ static const MuMsgField FIELD_DATA[] = {
|
|||
MU_MSG_FIELD_ID_BODY_TEXT,
|
||||
MU_MSG_FIELD_TYPE_STRING,
|
||||
"body", 'b', 'B',
|
||||
FLAG_GMIME | FLAG_XAPIAN_INDEX
|
||||
FLAG_GMIME | FLAG_XAPIAN_INDEX | FLAG_NORMALIZE
|
||||
},
|
||||
|
||||
{
|
||||
|
@ -110,7 +112,8 @@ static const MuMsgField FIELD_DATA[] = {
|
|||
MU_MSG_FIELD_ID_MAILDIR,
|
||||
MU_MSG_FIELD_TYPE_STRING,
|
||||
"maildir", 'm', 'M',
|
||||
FLAG_GMIME | FLAG_XAPIAN_TERM | FLAG_XAPIAN_VALUE
|
||||
FLAG_GMIME | FLAG_XAPIAN_TERM | FLAG_XAPIAN_VALUE |
|
||||
FLAG_NORMALIZE
|
||||
},
|
||||
|
||||
{
|
||||
|
@ -131,7 +134,8 @@ static const MuMsgField FIELD_DATA[] = {
|
|||
MU_MSG_FIELD_ID_SUBJECT,
|
||||
MU_MSG_FIELD_TYPE_STRING,
|
||||
"subject", 's', 'S',
|
||||
FLAG_GMIME | FLAG_XAPIAN_INDEX | FLAG_XAPIAN_VALUE
|
||||
FLAG_GMIME | FLAG_XAPIAN_INDEX | FLAG_XAPIAN_VALUE |
|
||||
FLAG_NORMALIZE
|
||||
},
|
||||
|
||||
{
|
||||
|
@ -145,7 +149,8 @@ static const MuMsgField FIELD_DATA[] = {
|
|||
MU_MSG_FIELD_ID_MSGID,
|
||||
MU_MSG_FIELD_TYPE_STRING,
|
||||
"msgid", 'i', 'I', /* 'i' for Id */
|
||||
FLAG_GMIME | FLAG_XAPIAN_TERM | FLAG_XAPIAN_VALUE
|
||||
FLAG_GMIME | FLAG_XAPIAN_TERM | FLAG_XAPIAN_VALUE |
|
||||
FLAG_XAPIAN_ESCAPE
|
||||
},
|
||||
|
||||
{
|
||||
|
@ -256,6 +261,21 @@ mu_msg_field_xapian_contact (MuMsgFieldId id)
|
|||
}
|
||||
|
||||
|
||||
gboolean
|
||||
mu_msg_field_normalize (MuMsgFieldId id)
|
||||
{
|
||||
g_return_val_if_fail (mu_msg_field_id_is_valid(id),FALSE);
|
||||
return mu_msg_field(id)->_flags & FLAG_NORMALIZE;
|
||||
}
|
||||
|
||||
gboolean
|
||||
mu_msg_field_xapian_escape (MuMsgFieldId id)
|
||||
{
|
||||
g_return_val_if_fail (mu_msg_field_id_is_valid(id),FALSE);
|
||||
return mu_msg_field(id)->_flags & FLAG_XAPIAN_ESCAPE;
|
||||
}
|
||||
|
||||
|
||||
gboolean
|
||||
mu_msg_field_is_numeric (MuMsgFieldId mfid)
|
||||
{
|
||||
|
@ -293,6 +313,8 @@ mu_msg_field_xapian_prefix (MuMsgFieldId id)
|
|||
}
|
||||
|
||||
|
||||
|
||||
|
||||
MuMsgFieldType
|
||||
mu_msg_field_type (MuMsgFieldId id)
|
||||
{
|
||||
|
|
|
@ -163,6 +163,28 @@ gboolean mu_msg_field_xapian_term (MuMsgFieldId id) G_GNUC_PURE;
|
|||
*/
|
||||
gboolean mu_msg_field_xapian_value (MuMsgFieldId id) G_GNUC_PURE;
|
||||
|
||||
|
||||
/**
|
||||
* should this field be escaped for xapian? in practice, should
|
||||
* word-breaking chars be replaced with '_'?
|
||||
*
|
||||
* @param field a MuMsgField
|
||||
*
|
||||
* @return TRUE if the field is Xapian-escaped, FALSE otherwise
|
||||
*/
|
||||
gboolean mu_msg_field_xapian_escape (MuMsgFieldId id) G_GNUC_PURE;
|
||||
|
||||
|
||||
/**
|
||||
* should this field be normalized? ie. should it be downcased and
|
||||
* accents removed?
|
||||
*
|
||||
* @param field a MuMsgField
|
||||
*
|
||||
* @return TRUE if the field is normalized, FALSE otherwise
|
||||
*/
|
||||
gboolean mu_msg_field_normalize (MuMsgFieldId id) G_GNUC_PURE;
|
||||
|
||||
/**
|
||||
* should this field be stored as contact information? This means that
|
||||
* e-mail address will be stored as terms, and names will be indexed
|
||||
|
|
Loading…
Reference in New Issue