* add basic support for X-Label (WIP)

This commit is contained in:
Dirk-Jan C. Binnema 2011-06-16 00:26:30 +03:00
parent 2a36799054
commit 9971c1e7ae
6 changed files with 50 additions and 13 deletions

View File

@ -62,9 +62,9 @@ struct _MuMsgField {
MuMsgFieldId _id; /* the id of the field */
MuMsgFieldType _type; /* the type of the field */
const char *_name; /* the name of the field */
const char _shortcut; /* the shortcut for use in
const char _shortcut; /* the shortcut for use in
* --fields and sorting */
const char _xprefix; /* the Xapian-prefix */
const char _xprefix; /* the Xapian-prefix */
FieldFlags _flags; /* the flags that tells us
* what to do */
};
@ -195,17 +195,26 @@ static const MuMsgField FIELD_DATA[] = {
{
MU_MSG_FIELD_ID_TIMESTAMP,
MU_MSG_FIELD_TYPE_TIME_T,
"timestamp", 'x', 0,
"timestamp", 0, 0,
FLAG_GMIME
},
{
MU_MSG_FIELD_ID_REFS,
MU_MSG_FIELD_TYPE_STRING_LIST,
"refs", 'r', 'R',
NULL, 'r', 'R',
FLAG_GMIME | FLAG_XAPIAN_VALUE |
FLAG_XAPIAN_PREFIX_ONLY
},
{
MU_MSG_FIELD_ID_TAGS,
MU_MSG_FIELD_TYPE_STRING_LIST,
"tag", 'x', 'X',
FLAG_GMIME | FLAG_XAPIAN_TERM | FLAG_XAPIAN_VALUE |
FLAG_XAPIAN_PREFIX_ONLY
}
};
/* the MsgField data in an array, indexed by the MsgFieldId;

View File

@ -44,6 +44,7 @@ enum _MuMsgFieldId {
/* string list items... */
MU_MSG_FIELD_ID_REFS,
MU_MSG_FIELD_ID_TAGS,
/* then the numerical ones */
MU_MSG_FIELD_ID_DATE,

View File

@ -714,6 +714,18 @@ get_references (MuMsgFile *self)
static GSList*
get_tags (MuMsgFile *self)
{
GMimeObject *obj;
obj = GMIME_OBJECT(self->_mime_msg);
return mu_str_to_list (g_mime_object_get_header
(obj, "X-Label"), ',');
}
char*
mu_msg_file_get_str_field (MuMsgFile *self, MuMsgFieldId mfid, gboolean *do_free)
{
@ -774,16 +786,15 @@ mu_msg_file_get_str_list_field (MuMsgFile *self, MuMsgFieldId mfid,
case MU_MSG_FIELD_ID_REFS:
*do_free = TRUE;
return get_references (self);
case MU_MSG_FIELD_ID_TAGS:
*do_free = TRUE;
return get_tags (self);
default:
g_return_val_if_reached (NULL);
}
}
gint64
mu_msg_file_get_num_field (MuMsgFile *self, const MuMsgFieldId mfid)
{

View File

@ -426,6 +426,14 @@ mu_msg_get_references (MuMsg *self)
}
const GSList*
mu_msg_get_tags (MuMsg *self)
{
g_return_val_if_fail (self, NULL);
return get_str_list_field (self, MU_MSG_FIELD_ID_TAGS);
}
const char*
mu_msg_get_field_string (MuMsg *self, MuMsgFieldId mfid)
{

View File

@ -322,14 +322,23 @@ const char* mu_msg_get_header (MuMsg *self, const char *header);
/**
* get the list of references as a comma-separated string
* get the list of references
*
* @param msg a valid MuMsg
*
* @return a comma-separated string with the references or NULL if
* there are none. Don't modify/free
* @return a list with the references for this msg. Don't modify/free
*/
const char* mu_msg_get_references_str (MuMsg *msg);
const GSList* mu_msg_get_references (MuMsg *msg);
/**
* get the list of tags
*
* @param msg a valid MuMsg
*
* @return a list with the tags for this msg. Don't modify/free
*/
const GSList* mu_msg_get_tags (MuMsg *self);
enum _MuMsgContactType { /* Reply-To:? */

View File

@ -1,5 +1,4 @@
/* -*-mode: c++; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8-*- */
/*
** Copyright (C) 2008-2011 Dirk-Jan C. Binnema <djcb@djcbsoftware.nl>
**