mirror of
https://git.notmuchmail.org/git/notmuch
synced 2024-11-21 18:38:08 +01:00
lib: add version of _n_m_f_get_combinded_header for gmime 3.0
The iterator is gone, so we need a new loop structure.
This commit is contained in:
parent
439c5896b6
commit
eeb64cdeeb
1 changed files with 34 additions and 0 deletions
|
@ -232,6 +232,7 @@ _extend_header (char *combined, const char *value) {
|
|||
return combined;
|
||||
}
|
||||
|
||||
#if (GMIME_MAJOR_VERSION < 3)
|
||||
static char *
|
||||
_notmuch_message_file_get_combined_header (notmuch_message_file_t *message,
|
||||
const char *header)
|
||||
|
@ -271,6 +272,39 @@ _notmuch_message_file_get_combined_header (notmuch_message_file_t *message,
|
|||
|
||||
return combined;
|
||||
}
|
||||
#else
|
||||
static char *
|
||||
_notmuch_message_file_get_combined_header (notmuch_message_file_t *message,
|
||||
const char *header)
|
||||
{
|
||||
char *combined = NULL;
|
||||
GMimeHeaderList *headers;
|
||||
|
||||
headers = g_mime_object_get_header_list (GMIME_OBJECT (message->message));
|
||||
if (! headers)
|
||||
return NULL;
|
||||
|
||||
|
||||
for (int i=0; i < g_mime_header_list_get_count (headers); i++) {
|
||||
const char *value;
|
||||
GMimeHeader *g_header = g_mime_header_list_get_header_at (headers, i);
|
||||
|
||||
if (strcasecmp (g_mime_header_get_name (g_header), header) != 0)
|
||||
continue;
|
||||
|
||||
/* GMime retains ownership of value, we hope */
|
||||
value = g_mime_header_get_value (g_header);
|
||||
|
||||
combined = _extend_header (combined, value);
|
||||
}
|
||||
|
||||
/* Return empty string for non-existing headers. */
|
||||
if (! combined)
|
||||
combined = g_strdup ("");
|
||||
|
||||
return combined;
|
||||
}
|
||||
#endif
|
||||
|
||||
const char *
|
||||
_notmuch_message_file_get_header (notmuch_message_file_t *message,
|
||||
|
|
Loading…
Reference in a new issue