* lib: get_tags: support X-Label, X-Keywords and Keywords
This commit is contained in:
@ -515,33 +515,34 @@ get_references (MuMsgFile *self)
|
|||||||
static GSList*
|
static GSList*
|
||||||
get_tags (MuMsgFile *self)
|
get_tags (MuMsgFile *self)
|
||||||
{
|
{
|
||||||
GSList *lst1, *lst2, *last;
|
GSList *lst;
|
||||||
char *hdr;
|
unsigned u;
|
||||||
|
struct {
|
||||||
|
const char *header;
|
||||||
|
char sepa;
|
||||||
|
} tagfields[] = {
|
||||||
|
{ "X-Label", ' ' },
|
||||||
|
{ "X-Keywords", ',' },
|
||||||
|
{ "Keywords", ' ' }
|
||||||
|
};
|
||||||
|
|
||||||
lst1 = lst2 = NULL;
|
for (lst = NULL, u = 0; u != G_N_ELEMENTS(tagfields); ++u) {
|
||||||
|
gchar *hdr;
|
||||||
|
hdr = mu_msg_file_get_header (self, tagfields[u].header);
|
||||||
|
if (hdr) {
|
||||||
|
GSList *hlst;
|
||||||
|
hlst = mu_str_to_list (hdr, tagfields[u].sepa, TRUE);
|
||||||
|
|
||||||
/* X-Label are space-separated */
|
if (lst)
|
||||||
hdr = mu_msg_file_get_header (self, "X-Label");
|
(g_slist_last (lst))->next = hlst;
|
||||||
if (hdr) {
|
else
|
||||||
lst1 = mu_str_to_list (hdr, ' ', TRUE);
|
lst = hlst;
|
||||||
g_free (hdr);
|
|
||||||
|
g_free (hdr);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* X-Keywords are ','-separated */
|
return lst;
|
||||||
hdr = mu_msg_file_get_header (self, "X-Keywords");
|
|
||||||
if (hdr) {
|
|
||||||
lst2 = mu_str_to_list (hdr, ',', TRUE);
|
|
||||||
g_free (hdr);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!lst1)
|
|
||||||
return lst2;
|
|
||||||
|
|
||||||
/* append lst2, if any */
|
|
||||||
last = g_slist_last (lst1);
|
|
||||||
last->next = lst2;
|
|
||||||
|
|
||||||
return lst1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user