* 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

@ -195,17 +195,26 @@ static const MuMsgField FIELD_DATA[] = {
{ {
MU_MSG_FIELD_ID_TIMESTAMP, MU_MSG_FIELD_ID_TIMESTAMP,
MU_MSG_FIELD_TYPE_TIME_T, MU_MSG_FIELD_TYPE_TIME_T,
"timestamp", 'x', 0, "timestamp", 0, 0,
FLAG_GMIME FLAG_GMIME
}, },
{ {
MU_MSG_FIELD_ID_REFS, MU_MSG_FIELD_ID_REFS,
MU_MSG_FIELD_TYPE_STRING_LIST, MU_MSG_FIELD_TYPE_STRING_LIST,
"refs", 'r', 'R', NULL, 'r', 'R',
FLAG_GMIME | FLAG_XAPIAN_VALUE | FLAG_GMIME | FLAG_XAPIAN_VALUE |
FLAG_XAPIAN_PREFIX_ONLY 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; /* the MsgField data in an array, indexed by the MsgFieldId;

View File

@ -44,6 +44,7 @@ enum _MuMsgFieldId {
/* string list items... */ /* string list items... */
MU_MSG_FIELD_ID_REFS, MU_MSG_FIELD_ID_REFS,
MU_MSG_FIELD_ID_TAGS,
/* then the numerical ones */ /* then the numerical ones */
MU_MSG_FIELD_ID_DATE, 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* char*
mu_msg_file_get_str_field (MuMsgFile *self, MuMsgFieldId mfid, gboolean *do_free) 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: case MU_MSG_FIELD_ID_REFS:
*do_free = TRUE; *do_free = TRUE;
return get_references (self); return get_references (self);
case MU_MSG_FIELD_ID_TAGS:
*do_free = TRUE;
return get_tags (self);
default: default:
g_return_val_if_reached (NULL); g_return_val_if_reached (NULL);
} }
} }
gint64 gint64
mu_msg_file_get_num_field (MuMsgFile *self, const MuMsgFieldId mfid) 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* const char*
mu_msg_get_field_string (MuMsg *self, MuMsgFieldId mfid) 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 * @param msg a valid MuMsg
* *
* @return a comma-separated string with the references or NULL if * @return a list with the references for this msg. Don't modify/free
* there are none. 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:? */ enum _MuMsgContactType { /* Reply-To:? */

View File

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