notmuch_message_get_header (node->envelope_file, "from"));
} else if (GMIME_IS_MESSAGE (node->part)) {
GMimeMessage *message = GMIME_MESSAGE (node->part);
- InternetAddressList *recipients;
char *recipients_string;
- recipients = g_mime_message_get_recipients (message, GMIME_RECIPIENT_TYPE_TO);
- recipients_string = internet_address_list_to_string (recipients, 0);
g_mime_stream_printf (stream, "> From: %s\n", g_mime_message_get_from_string (message));
+ recipients_string = g_mime_message_get_address_string (message, GMIME_ADDRESS_TYPE_TO);
if (recipients_string)
g_mime_stream_printf (stream, "> To: %s\n",
recipients_string);
g_free (recipients_string);
- recipients = g_mime_message_get_recipients (message, GMIME_RECIPIENT_TYPE_CC);
- recipients_string = internet_address_list_to_string (recipients, 0);
+ recipients_string = g_mime_message_get_address_string (message, GMIME_ADDRESS_TYPE_CC);
if (recipients_string)
g_mime_stream_printf (stream, "> Cc: %s\n",
recipients_string);
static InternetAddressList *get_to(GMimeMessage *message)
{
- return g_mime_message_get_recipients (message, GMIME_RECIPIENT_TYPE_TO);
+ return g_mime_message_get_addresses (message, GMIME_ADDRESS_TYPE_TO);
}
static InternetAddressList *get_cc(GMimeMessage *message)
{
- return g_mime_message_get_recipients (message, GMIME_RECIPIENT_TYPE_CC);
+ return g_mime_message_get_addresses (message, GMIME_ADDRESS_TYPE_CC);
}
static InternetAddressList *get_bcc(GMimeMessage *message)
{
- return g_mime_message_get_recipients (message, GMIME_RECIPIENT_TYPE_BCC);
+ return g_mime_message_get_addresses (message, GMIME_ADDRESS_TYPE_BCC);
}
/* Augment the recipients of 'reply' from the "Reply-to:", "From:",
InternetAddressList * (*get_header)(GMimeMessage *message);
GMimeRecipientType recipient_type;
} reply_to_map[] = {
- { get_sender, GMIME_RECIPIENT_TYPE_TO },
- { get_to, GMIME_RECIPIENT_TYPE_TO },
- { get_cc, GMIME_RECIPIENT_TYPE_CC },
- { get_bcc, GMIME_RECIPIENT_TYPE_BCC },
+ { get_sender, GMIME_ADDRESS_TYPE_TO },
+ { get_to, GMIME_ADDRESS_TYPE_TO },
+ { get_cc, GMIME_ADDRESS_TYPE_CC },
+ { get_bcc, GMIME_ADDRESS_TYPE_BCC },
};
const char *from_addr = NULL;
unsigned int i;
/* Any changes to the JSON or S-Expression format should be
* reflected in the file devel/schemata. */
- InternetAddressList *recipients;
char *recipients_string;
const char *reply_to_string;
void *local = talloc_new (sp);
sp->map_key (sp, "From");
sp->string (sp, g_mime_message_get_from_string (message));
- recipients = g_mime_message_get_recipients (message, GMIME_RECIPIENT_TYPE_TO);
- recipients_string = internet_address_list_to_string (recipients, 0);
+ recipients_string = g_mime_message_get_address_string (message, GMIME_ADDRESS_TYPE_TO);
if (recipients_string) {
sp->map_key (sp, "To");
sp->string (sp, recipients_string);
g_free (recipients_string);
}
- recipients = g_mime_message_get_recipients (message, GMIME_RECIPIENT_TYPE_CC);
- recipients_string = internet_address_list_to_string (recipients, 0);
+ recipients_string = g_mime_message_get_address_string (message, GMIME_ADDRESS_TYPE_CC);
if (recipients_string) {
sp->map_key (sp, "Cc");
sp->string (sp, recipients_string);
g_free (recipients_string);
}
- recipients = g_mime_message_get_recipients (message, GMIME_RECIPIENT_TYPE_BCC);
- recipients_string = internet_address_list_to_string (recipients, 0);
+ recipients_string = g_mime_message_get_address_string (message, GMIME_ADDRESS_TYPE_BCC);
if (recipients_string) {
sp->map_key (sp, "Bcc");
sp->string (sp, recipients_string);
if (GMIME_IS_MESSAGE (node->part)) {
GMimeMessage *message = GMIME_MESSAGE (node->part);
- InternetAddressList *recipients;
char *recipients_string;
char *date_string;
if (node->envelope_file)
g_mime_stream_printf (stream, "%s\n", _get_one_line_summary (ctx, node->envelope_file));
g_mime_stream_printf (stream, "Subject: %s\n", g_mime_message_get_subject (message));
- recipients = g_mime_message_get_recipients (message, GMIME_RECIPIENT_TYPE_TO);
- recipients_string = internet_address_list_to_string (recipients, 0);
g_mime_stream_printf (stream, "From: %s\n", g_mime_message_get_from_string (message));
+ recipients_string = g_mime_message_get_address_string (message, GMIME_ADDRESS_TYPE_TO);
if (recipients_string)
g_mime_stream_printf (stream, "To: %s\n", recipients_string);
g_free (recipients_string);
- recipients = g_mime_message_get_recipients (message, GMIME_RECIPIENT_TYPE_CC);
- recipients_string = internet_address_list_to_string (recipients, 0);
+ recipients_string = g_mime_message_get_address_string (message, GMIME_ADDRESS_TYPE_CC);
if (recipients_string)
g_mime_stream_printf (stream, "Cc: %s\n", recipients_string);
g_free (recipients_string);
#if (GMIME_MAJOR_VERSION < 3)
+char *
+g_mime_message_get_address_string (GMimeMessage *message, GMimeRecipientType type)
+{
+ InternetAddressList *list = g_mime_message_get_recipients (message, type);
+ return internet_address_list_to_string (list, 0);
+}
+
+inline InternetAddressList *
+g_mime_message_get_addresses (GMimeMessage *message, GMimeRecipientType type)
+{
+ return g_mime_message_get_recipients (message, type);
+}
+
char *
g_mime_message_get_date_string (void *ctx, GMimeMessage *message)
{
#else /* GMime >= 3.0 */
+char *
+g_mime_message_get_address_string (GMimeMessage *message, GMimeAddressType type)
+{
+ InternetAddressList *list = g_mime_message_get_addresses (message, type);
+ return internet_address_list_to_string (list, NULL, 0);
+}
+
char *
g_mime_message_get_date_string (void *ctx, GMimeMessage *message)
{
#include <talloc.h>
+
+#if (GMIME_MAJOR_VERSION < 3)
+
+#define GMIME_ADDRESS_TYPE_TO GMIME_RECIPIENT_TYPE_TO
+#define GMIME_ADDRESS_TYPE_CC GMIME_RECIPIENT_TYPE_CC
+#define GMIME_ADDRESS_TYPE_BCC GMIME_RECIPIENT_TYPE_BCC
+
+
+#else /* GMime >= 3.0 */
+typedef GMimeAddressType GMimeRecipientType;
+#endif
+
+/**
+ * Return the contents of the appropriate address header as a string
+ * Should be freed using g_free
+ */
+char *g_mime_message_get_address_string (GMimeMessage *message, GMimeRecipientType type);
+
+InternetAddressList * g_mime_message_get_addresses (GMimeMessage *message, GMimeRecipientType type);
+
/**
* return talloc allocated date string
*/
* return talloc allocated reply-to string
*/
char * g_mime_message_get_reply_to_string (void *ctx, GMimeMessage *message);
-
-
#endif