From 9971c1e7aee3b7d4ecf91c4a8843c7eb2c45bc96 Mon Sep 17 00:00:00 2001 From: "Dirk-Jan C. Binnema" Date: Thu, 16 Jun 2011 00:26:30 +0300 Subject: [PATCH] * add basic support for X-Label (WIP) --- src/mu-msg-fields.c | 17 +++++++++++++---- src/mu-msg-fields.h | 1 + src/mu-msg-file.c | 19 +++++++++++++++---- src/mu-msg.c | 8 ++++++++ src/mu-msg.h | 17 +++++++++++++---- src/mu-store.cc | 1 - 6 files changed, 50 insertions(+), 13 deletions(-) diff --git a/src/mu-msg-fields.c b/src/mu-msg-fields.c index 8bdcafea..aa6d8e24 100644 --- a/src/mu-msg-fields.c +++ b/src/mu-msg-fields.c @@ -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; diff --git a/src/mu-msg-fields.h b/src/mu-msg-fields.h index 93bcd202..4edd631e 100644 --- a/src/mu-msg-fields.h +++ b/src/mu-msg-fields.h @@ -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, diff --git a/src/mu-msg-file.c b/src/mu-msg-file.c index 5a212805..6d14bb97 100644 --- a/src/mu-msg-file.c +++ b/src/mu-msg-file.c @@ -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) { diff --git a/src/mu-msg.c b/src/mu-msg.c index bd7c7e67..9afdb570 100644 --- a/src/mu-msg.c +++ b/src/mu-msg.c @@ -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) { diff --git a/src/mu-msg.h b/src/mu-msg.h index ceda6e1e..13a4c556 100644 --- a/src/mu-msg.h +++ b/src/mu-msg.h @@ -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:? */ diff --git a/src/mu-store.cc b/src/mu-store.cc index eea84d82..a8bdcaa7 100644 --- a/src/mu-store.cc +++ b/src/mu-store.cc @@ -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 **