2009-11-25 21:55:06 +01:00
|
|
|
/*
|
2010-09-05 11:37:47 +02:00
|
|
|
** Copyright (C) 2008-2010 Dirk-Jan C. Binnema <djcb@djcbsoftware.nl>
|
2009-11-25 21:55:06 +01:00
|
|
|
**
|
|
|
|
** This program is free software; you can redistribute it and/or modify
|
|
|
|
** it under the terms of the GNU General Public License as published by
|
|
|
|
** the Free Software Foundation; either version 3 of the License, or
|
|
|
|
** (at your option) any later version.
|
|
|
|
**
|
|
|
|
** This program is distributed in the hope that it will be useful,
|
|
|
|
** but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
** GNU General Public License for more details.
|
|
|
|
**
|
|
|
|
** You should have received a copy of the GNU General Public License
|
|
|
|
** along with this program; if not, write to the Free Software Foundation,
|
|
|
|
** Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
|
|
**
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef __MU_MSG_FIELDS_H__
|
|
|
|
#define __MU_MSG_FIELDS_H__
|
|
|
|
|
|
|
|
#include <glib.h>
|
|
|
|
|
|
|
|
G_BEGIN_DECLS
|
|
|
|
|
2010-09-05 11:37:47 +02:00
|
|
|
/* don't change the order, add new types at the end, as these numbers
|
|
|
|
* are used in the database */
|
2011-05-01 17:31:00 +02:00
|
|
|
enum _MuMsgFieldId {
|
2011-05-14 17:06:33 +02:00
|
|
|
|
|
|
|
/* first all the string-based ones */
|
2011-12-01 20:23:13 +01:00
|
|
|
MU_MSG_FIELD_ID_BCC = 0,
|
2009-11-25 21:55:06 +01:00
|
|
|
MU_MSG_FIELD_ID_BODY_HTML,
|
2011-05-14 17:06:33 +02:00
|
|
|
MU_MSG_FIELD_ID_BODY_TEXT,
|
2009-11-25 21:55:06 +01:00
|
|
|
MU_MSG_FIELD_ID_CC,
|
2011-12-01 20:23:13 +01:00
|
|
|
MU_MSG_FIELD_ID_EMBEDDED_TEXT,
|
2011-11-23 23:10:37 +01:00
|
|
|
MU_MSG_FIELD_ID_FILE,
|
2009-11-25 21:55:06 +01:00
|
|
|
MU_MSG_FIELD_ID_FROM,
|
2011-05-14 17:06:33 +02:00
|
|
|
MU_MSG_FIELD_ID_MAILDIR,
|
2011-11-23 23:10:37 +01:00
|
|
|
MU_MSG_FIELD_ID_MIME, /* mime-type */
|
2011-05-14 17:06:33 +02:00
|
|
|
MU_MSG_FIELD_ID_MSGID,
|
2009-11-25 21:55:06 +01:00
|
|
|
MU_MSG_FIELD_ID_PATH,
|
|
|
|
MU_MSG_FIELD_ID_SUBJECT,
|
|
|
|
MU_MSG_FIELD_ID_TO,
|
2011-11-11 08:13:35 +01:00
|
|
|
|
|
|
|
MU_MSG_FIELD_ID_UID, /* special, generated from path */
|
|
|
|
|
2011-06-15 22:51:49 +02:00
|
|
|
/* string list items... */
|
|
|
|
MU_MSG_FIELD_ID_REFS,
|
2011-06-15 23:26:30 +02:00
|
|
|
MU_MSG_FIELD_ID_TAGS,
|
2011-09-12 19:42:30 +02:00
|
|
|
|
2011-05-14 17:06:33 +02:00
|
|
|
/* then the numerical ones */
|
|
|
|
MU_MSG_FIELD_ID_DATE,
|
|
|
|
MU_MSG_FIELD_ID_FLAGS,
|
|
|
|
MU_MSG_FIELD_ID_PRIO,
|
|
|
|
MU_MSG_FIELD_ID_SIZE,
|
2011-09-12 19:42:30 +02:00
|
|
|
|
|
|
|
MU_MSG_FIELD_ID_NUM
|
2009-11-25 21:55:06 +01:00
|
|
|
};
|
2011-06-15 22:51:49 +02:00
|
|
|
typedef guint8 MuMsgFieldId;
|
2009-11-25 21:55:06 +01:00
|
|
|
|
2010-11-21 17:12:01 +01:00
|
|
|
/* some specials... */
|
|
|
|
static const MuMsgFieldId MU_MSG_FIELD_ID_NONE = (MuMsgFieldId)-1;
|
2011-11-11 08:13:35 +01:00
|
|
|
#define MU_MSG_STRING_FIELD_ID_NUM (MU_MSG_FIELD_ID_UID + 1)
|
2011-05-14 17:06:33 +02:00
|
|
|
|
2010-11-20 13:41:21 +01:00
|
|
|
#define mu_msg_field_id_is_valid(MFID) \
|
|
|
|
((MFID) < MU_MSG_FIELD_ID_NUM)
|
|
|
|
|
2010-01-06 20:41:58 +01:00
|
|
|
/* don't change the order, add new types at the end (before _NUM)*/
|
2009-11-25 21:55:06 +01:00
|
|
|
enum _MuMsgFieldType {
|
|
|
|
MU_MSG_FIELD_TYPE_STRING,
|
2011-06-15 22:51:49 +02:00
|
|
|
MU_MSG_FIELD_TYPE_STRING_LIST,
|
2011-09-12 19:42:30 +02:00
|
|
|
|
|
|
|
MU_MSG_FIELD_TYPE_BYTESIZE,
|
2009-11-25 21:55:06 +01:00
|
|
|
MU_MSG_FIELD_TYPE_TIME_T,
|
|
|
|
MU_MSG_FIELD_TYPE_INT,
|
|
|
|
|
|
|
|
MU_MSG_FIELD_TYPE_NUM
|
|
|
|
};
|
2011-06-15 22:51:49 +02:00
|
|
|
typedef guint8 MuMsgFieldType;
|
2010-11-21 12:38:11 +01:00
|
|
|
static const MuMsgFieldType MU_MSG_FIELD_TYPE_NONE = (MuMsgFieldType)-1;
|
2010-11-20 13:41:21 +01:00
|
|
|
|
2012-04-13 20:49:53 +02:00
|
|
|
typedef void (*MuMsgFieldForeachFunc) (MuMsgFieldId id,
|
2009-11-25 21:55:06 +01:00
|
|
|
gconstpointer data);
|
2010-01-08 19:52:50 +01:00
|
|
|
|
2010-09-12 15:28:34 +02:00
|
|
|
/**
|
2010-01-08 19:52:50 +01:00
|
|
|
* iterator over all possible message fields
|
2011-09-12 19:42:30 +02:00
|
|
|
*
|
2010-01-08 19:52:50 +01:00
|
|
|
* @param func a function called for each field
|
|
|
|
* @param data a user data pointer passed the callback function
|
|
|
|
*/
|
2012-04-13 20:49:53 +02:00
|
|
|
void mu_msg_field_foreach (MuMsgFieldForeachFunc func, gconstpointer data);
|
2009-11-25 21:55:06 +01:00
|
|
|
|
2010-01-06 20:41:58 +01:00
|
|
|
|
2010-09-12 15:28:34 +02:00
|
|
|
/**
|
2010-01-08 19:52:50 +01:00
|
|
|
* get the name of the field -- this a name that can be use in queries,
|
|
|
|
* ie. 'subject:foo', with 'subject' being the name
|
2011-09-12 19:42:30 +02:00
|
|
|
*
|
2010-11-20 13:41:21 +01:00
|
|
|
* @param id a MuMsgFieldId
|
2011-09-12 19:42:30 +02:00
|
|
|
*
|
2010-01-08 19:52:50 +01:00
|
|
|
* @return the name of the field as a constant string, or
|
|
|
|
* NULL if the field is unknown
|
|
|
|
*/
|
2010-11-20 13:41:21 +01:00
|
|
|
const char* mu_msg_field_name (MuMsgFieldId id) G_GNUC_PURE;
|
2010-01-08 19:52:50 +01:00
|
|
|
|
2010-09-12 15:28:34 +02:00
|
|
|
/**
|
2010-01-08 19:52:50 +01:00
|
|
|
* get the shortcut of the field -- this a shortcut that can be use in
|
|
|
|
* queries, ie. 's:foo', with 's' meaning 'subject' being the name
|
2011-09-12 19:42:30 +02:00
|
|
|
*
|
2010-11-20 13:41:21 +01:00
|
|
|
* @param id a MuMsgFieldId
|
2011-09-12 19:42:30 +02:00
|
|
|
*
|
2010-11-20 13:41:21 +01:00
|
|
|
* @return the shortcut character, or 0 if the field is unknown
|
2010-01-08 19:52:50 +01:00
|
|
|
*/
|
2010-11-20 13:41:21 +01:00
|
|
|
char mu_msg_field_shortcut (MuMsgFieldId id) G_GNUC_PURE;
|
2010-01-08 19:52:50 +01:00
|
|
|
|
2010-09-12 15:28:34 +02:00
|
|
|
/**
|
2010-01-08 19:52:50 +01:00
|
|
|
* get the xapian prefix of the field -- that is, the prefix used in
|
|
|
|
* the Xapian database to identify the field
|
2011-09-12 19:42:30 +02:00
|
|
|
*
|
2010-11-20 13:41:21 +01:00
|
|
|
* @param id a MuMsgFieldId
|
2011-09-12 19:42:30 +02:00
|
|
|
*
|
2010-11-20 13:41:21 +01:00
|
|
|
* @return the xapian prefix char or 0 if the field is unknown
|
2010-01-08 19:52:50 +01:00
|
|
|
*/
|
2010-11-20 13:41:21 +01:00
|
|
|
char mu_msg_field_xapian_prefix (MuMsgFieldId id) G_GNUC_PURE;
|
2010-01-08 19:52:50 +01:00
|
|
|
|
|
|
|
|
2010-09-12 15:28:34 +02:00
|
|
|
/**
|
2010-01-08 19:52:50 +01:00
|
|
|
* get the type of the field (string, size, time etc.)
|
2011-09-12 19:42:30 +02:00
|
|
|
*
|
2010-01-08 19:52:50 +01:00
|
|
|
* @param field a MuMsgField
|
2011-09-12 19:42:30 +02:00
|
|
|
*
|
2010-01-08 19:52:50 +01:00
|
|
|
* @return the type of the field (a #MuMsgFieldType), or
|
|
|
|
* MU_MSG_FIELD_TYPE_NONE if it is not found
|
|
|
|
*/
|
2010-11-20 13:41:21 +01:00
|
|
|
MuMsgFieldType mu_msg_field_type (MuMsgFieldId id) G_GNUC_PURE;
|
2009-11-25 21:55:06 +01:00
|
|
|
|
|
|
|
|
2012-04-13 20:49:53 +02:00
|
|
|
|
2011-05-09 01:58:33 +02:00
|
|
|
/**
|
|
|
|
* is the field a string?
|
2011-09-12 19:42:30 +02:00
|
|
|
*
|
2011-05-09 01:58:33 +02:00
|
|
|
* @param id a MuMsgFieldId
|
2011-09-12 19:42:30 +02:00
|
|
|
*
|
2011-05-09 01:58:33 +02:00
|
|
|
* @return TRUE if the field a string, FALSE otherwise
|
|
|
|
*/
|
|
|
|
#define mu_msg_field_is_string(MFID)\
|
|
|
|
(mu_msg_field_type((MFID))==MU_MSG_FIELD_TYPE_STRING?TRUE:FALSE)
|
|
|
|
|
2011-06-15 22:51:49 +02:00
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* is the field a string-list?
|
2011-09-12 19:42:30 +02:00
|
|
|
*
|
2011-06-15 22:51:49 +02:00
|
|
|
* @param id a MuMsgFieldId
|
2011-09-12 19:42:30 +02:00
|
|
|
*
|
2011-06-15 22:51:49 +02:00
|
|
|
* @return TRUE if the field a string-list, FALSE otherwise
|
|
|
|
*/
|
|
|
|
#define mu_msg_field_is_string_list(MFID)\
|
|
|
|
(mu_msg_field_type((MFID))==MU_MSG_FIELD_TYPE_STRING_LIST?TRUE:FALSE)
|
|
|
|
|
2010-09-12 15:28:34 +02:00
|
|
|
/**
|
2010-01-08 19:52:50 +01:00
|
|
|
* is the field numeric (has type MU_MSG_FIELD_TYPE_(BYTESIZE|TIME_T|INT))?
|
2011-09-12 19:42:30 +02:00
|
|
|
*
|
2010-11-20 13:41:21 +01:00
|
|
|
* @param id a MuMsgFieldId
|
2011-09-12 19:42:30 +02:00
|
|
|
*
|
2010-01-08 19:52:50 +01:00
|
|
|
* @return TRUE if the field is numeric, FALSE otherwise
|
|
|
|
*/
|
2010-11-20 13:41:21 +01:00
|
|
|
gboolean mu_msg_field_is_numeric (MuMsgFieldId id) G_GNUC_PURE;
|
2010-02-08 20:20:11 +01:00
|
|
|
|
|
|
|
|
2011-05-14 17:06:33 +02:00
|
|
|
/**
|
|
|
|
* whether the field value should be cached (in MuMsg) -- we cache
|
|
|
|
* values so we can use the MuMsg without needing to keep the
|
|
|
|
* underlying data source (the GMimeMessage or the database ptr) alive
|
|
|
|
* in practice, the fields we *don't* cache are the message body
|
|
|
|
* (html, txt), because they take too much memory
|
|
|
|
*/
|
|
|
|
gboolean mu_msg_field_is_cacheable (MuMsgFieldId id) G_GNUC_PURE;
|
|
|
|
|
|
|
|
|
2010-09-12 15:28:34 +02:00
|
|
|
/**
|
2010-02-08 20:20:11 +01:00
|
|
|
* is the field Xapian-indexable? That is, should this field be
|
|
|
|
* indexed in the in the Xapian database, so we can use the all the
|
|
|
|
* phrasing, stemming etc. magic
|
2011-09-12 19:42:30 +02:00
|
|
|
*
|
2010-11-20 13:41:21 +01:00
|
|
|
* @param id a MuMsgFieldId
|
2011-09-12 19:42:30 +02:00
|
|
|
*
|
2010-01-08 19:52:50 +01:00
|
|
|
* @return TRUE if the field is Xapian-enabled, FALSE otherwise
|
|
|
|
*/
|
2010-11-20 13:41:21 +01:00
|
|
|
gboolean mu_msg_field_xapian_index (MuMsgFieldId id) G_GNUC_PURE;
|
2010-01-08 19:52:50 +01:00
|
|
|
|
2010-09-12 15:28:34 +02:00
|
|
|
/**
|
2010-02-08 20:20:11 +01:00
|
|
|
* should this field be stored as a xapian term?
|
2011-09-12 19:42:30 +02:00
|
|
|
*
|
|
|
|
* @param id a MuMsgFieldId
|
|
|
|
*
|
2010-02-08 20:20:11 +01:00
|
|
|
* @return TRUE if the field is Xapian-enabled, FALSE otherwise
|
|
|
|
*/
|
2010-11-20 13:41:21 +01:00
|
|
|
gboolean mu_msg_field_xapian_term (MuMsgFieldId id) G_GNUC_PURE;
|
2010-01-08 19:52:50 +01:00
|
|
|
|
2010-09-12 15:28:34 +02:00
|
|
|
/**
|
2010-02-08 20:20:11 +01:00
|
|
|
* should this field be stored as a xapian value?
|
2011-09-12 19:42:30 +02:00
|
|
|
*
|
2010-01-08 19:52:50 +01:00
|
|
|
* @param field a MuMsgField
|
2011-09-12 19:42:30 +02:00
|
|
|
*
|
2010-01-08 19:52:50 +01:00
|
|
|
* @return TRUE if the field is Xapian-enabled, FALSE otherwise
|
|
|
|
*/
|
2010-11-20 13:41:21 +01:00
|
|
|
gboolean mu_msg_field_xapian_value (MuMsgFieldId id) G_GNUC_PURE;
|
2009-11-25 21:55:06 +01:00
|
|
|
|
2010-11-29 20:18:37 +01:00
|
|
|
|
2011-05-20 20:30:04 +02:00
|
|
|
/**
|
|
|
|
* whether we should use add_boolean_prefix (see Xapian documentation)
|
|
|
|
* for this field in queries. Used in mu-query.cc
|
2011-09-12 19:42:30 +02:00
|
|
|
*
|
2011-05-20 20:30:04 +02:00
|
|
|
* @param id a MuMsgFieldId
|
2011-09-12 19:42:30 +02:00
|
|
|
*
|
2011-05-20 20:30:04 +02:00
|
|
|
* @return TRUE if this field wants add_boolean_prefix, FALSE
|
|
|
|
* otherwise
|
|
|
|
*/
|
|
|
|
gboolean mu_msg_field_uses_boolean_prefix (MuMsgFieldId id) G_GNUC_PURE;
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* wether this fields needs a prefix in queries -- ie,
|
|
|
|
* 'msgid:<some-message-id>' will only match with the explicit prefix,
|
|
|
|
* while 'subject:foo' will also match as just 'foo'. Used in
|
|
|
|
* mu-query.cc
|
2011-09-12 19:42:30 +02:00
|
|
|
*
|
2011-05-20 20:30:04 +02:00
|
|
|
* @param id a MuMsgFieldId
|
2011-09-12 19:42:30 +02:00
|
|
|
*
|
2011-05-20 20:30:04 +02:00
|
|
|
* @return TRUE if this field only matches with a prefix, FALSE
|
|
|
|
* otherwise
|
|
|
|
*/
|
|
|
|
gboolean mu_msg_field_needs_prefix (MuMsgFieldId id) G_GNUC_PURE;
|
|
|
|
|
|
|
|
|
2010-11-29 20:18:37 +01:00
|
|
|
/**
|
|
|
|
* should this field be escaped for xapian? in practice, should
|
|
|
|
* word-breaking chars be replaced with '_'?
|
2011-09-12 19:42:30 +02:00
|
|
|
*
|
2010-11-29 20:18:37 +01:00
|
|
|
* @param field a MuMsgField
|
2011-09-12 19:42:30 +02:00
|
|
|
*
|
2010-11-29 20:18:37 +01:00
|
|
|
* @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
|
2011-07-02 10:27:08 +02:00
|
|
|
* accents removed when storing as Xapian term?
|
2011-09-12 19:42:30 +02:00
|
|
|
*
|
2010-11-29 20:18:37 +01:00
|
|
|
* @param field a MuMsgField
|
2011-09-12 19:42:30 +02:00
|
|
|
*
|
2012-04-13 20:49:53 +02:00
|
|
|
* @return TRUE if the field is to be normalized, FALSE otherwise
|
2010-11-29 20:18:37 +01:00
|
|
|
*/
|
|
|
|
gboolean mu_msg_field_normalize (MuMsgFieldId id) G_GNUC_PURE;
|
|
|
|
|
2012-04-13 20:49:53 +02:00
|
|
|
/**
|
|
|
|
* is this a range-field? ie. date, or size
|
|
|
|
*
|
|
|
|
* @param id a MuMsgField
|
|
|
|
*
|
|
|
|
* @return TRUE if this field is a range field, FALSE otherwise
|
|
|
|
*/
|
|
|
|
gboolean mu_msg_field_is_range_field (MuMsgFieldId id) G_GNUC_PURE;
|
|
|
|
|
2011-07-02 10:27:08 +02:00
|
|
|
|
2010-09-12 15:28:34 +02:00
|
|
|
/**
|
|
|
|
* should this field be stored as contact information? This means that
|
|
|
|
* e-mail address will be stored as terms, and names will be indexed
|
2011-09-12 19:42:30 +02:00
|
|
|
*
|
2010-11-20 13:41:21 +01:00
|
|
|
* @param id a MuMsgFieldId
|
2011-09-12 19:42:30 +02:00
|
|
|
*
|
2010-09-12 15:28:34 +02:00
|
|
|
* @return TRUE if the field should be stored as contact information,
|
|
|
|
* FALSE otherwise
|
|
|
|
*/
|
2010-11-20 13:41:21 +01:00
|
|
|
gboolean mu_msg_field_xapian_contact (MuMsgFieldId id) G_GNUC_PURE;
|
2010-01-08 19:52:50 +01:00
|
|
|
|
2010-09-12 15:28:34 +02:00
|
|
|
/**
|
2010-01-08 19:52:50 +01:00
|
|
|
* is the field gmime-enabled? That is, can be field be retrieved
|
|
|
|
* using GMime?
|
2011-09-12 19:42:30 +02:00
|
|
|
*
|
2010-11-20 13:41:21 +01:00
|
|
|
* @param id a MuMsgFieldId
|
2011-09-12 19:42:30 +02:00
|
|
|
*
|
2010-01-08 19:52:50 +01:00
|
|
|
* @return TRUE if the field is Gmime-enabled, FALSE otherwise
|
|
|
|
*/
|
2010-11-20 13:41:21 +01:00
|
|
|
gboolean mu_msg_field_gmime (MuMsgFieldId id) G_GNUC_PURE;
|
2010-01-08 19:52:50 +01:00
|
|
|
|
|
|
|
|
2010-09-12 15:28:34 +02:00
|
|
|
/**
|
2010-01-08 19:52:50 +01:00
|
|
|
* get the corresponding MuMsgField for a name (as in mu_msg_field_name)
|
2011-09-12 19:42:30 +02:00
|
|
|
*
|
2010-01-08 19:52:50 +01:00
|
|
|
* @param str a name
|
2010-11-20 13:41:21 +01:00
|
|
|
* @param err, if TRUE, when the shortcut is not found, will issue a
|
|
|
|
* g_critical warning
|
2011-09-12 19:42:30 +02:00
|
|
|
*
|
2010-01-08 19:52:50 +01:00
|
|
|
* @return a MuMsgField, or NULL if it could not be found
|
|
|
|
*/
|
2010-11-20 13:41:21 +01:00
|
|
|
MuMsgFieldId mu_msg_field_id_from_name (const char* str,
|
|
|
|
gboolean err) G_GNUC_PURE;
|
2010-01-08 19:52:50 +01:00
|
|
|
|
|
|
|
|
2010-09-12 15:28:34 +02:00
|
|
|
/**
|
2010-01-08 19:52:50 +01:00
|
|
|
* get the corresponding MuMsgField for a shortcut (as in mu_msg_field_shortcut)
|
2011-09-12 19:42:30 +02:00
|
|
|
*
|
2010-01-08 19:52:50 +01:00
|
|
|
* @param kar a shortcut character
|
2010-11-20 13:41:21 +01:00
|
|
|
* @param err, if TRUE, when the shortcut is not found, will issue a
|
|
|
|
* g_critical warning
|
2011-09-12 19:42:30 +02:00
|
|
|
*
|
2010-01-08 19:52:50 +01:00
|
|
|
* @return a MuMsgField, or NULL if it could not be found
|
|
|
|
*/
|
2010-11-20 13:41:21 +01:00
|
|
|
MuMsgFieldId mu_msg_field_id_from_shortcut (char kar,
|
|
|
|
gboolean err) G_GNUC_PURE;
|
2009-11-25 21:55:06 +01:00
|
|
|
G_END_DECLS
|
|
|
|
|
|
|
|
#endif /*__MU_MSG_FIELDS_H__*/
|