mirror of
https://git.notmuchmail.org/git/notmuch
synced 2024-11-21 10:28:09 +01:00
cli: replace use of g_mime_message_get_recipients
This function, and associated enum, have been renamed and generalized in gmime-3.0.
This commit is contained in:
parent
cbb2d5608e
commit
32819f74d3
4 changed files with 54 additions and 26 deletions
|
@ -44,18 +44,15 @@ format_part_reply (GMimeStream *stream, mime_node_t *node)
|
|||
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);
|
||||
|
@ -297,17 +294,17 @@ static InternetAddressList *get_sender(GMimeMessage *message)
|
|||
|
||||
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:",
|
||||
|
@ -338,10 +335,10 @@ add_recipients_from_message (GMimeMessage *reply,
|
|||
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;
|
||||
|
|
|
@ -201,7 +201,6 @@ format_headers_sprinter (sprinter_t *sp, GMimeMessage *message,
|
|||
/* 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);
|
||||
|
@ -214,24 +213,21 @@ format_headers_sprinter (sprinter_t *sp, GMimeMessage *message,
|
|||
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);
|
||||
|
@ -512,7 +508,6 @@ format_part_text (const void *ctx, sprinter_t *sp, mime_node_t *node,
|
|||
|
||||
if (GMIME_IS_MESSAGE (node->part)) {
|
||||
GMimeMessage *message = GMIME_MESSAGE (node->part);
|
||||
InternetAddressList *recipients;
|
||||
char *recipients_string;
|
||||
char *date_string;
|
||||
|
||||
|
@ -520,14 +515,12 @@ format_part_text (const void *ctx, sprinter_t *sp, mime_node_t *node,
|
|||
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);
|
||||
|
|
|
@ -32,6 +32,19 @@ g_string_talloc_strdup (void *ctx, char *g_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)
|
||||
{
|
||||
|
@ -74,6 +87,13 @@ g_mime_message_get_reply_to_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)
|
||||
{
|
||||
|
|
|
@ -6,6 +6,26 @@ GMimeStream *g_mime_stream_stdout_new(void);
|
|||
|
||||
#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
|
||||
*/
|
||||
|
@ -30,6 +50,4 @@ InternetAddressList * g_mime_message_get_reply_to_list (GMimeMessage *message);
|
|||
* return talloc allocated reply-to string
|
||||
*/
|
||||
char * g_mime_message_get_reply_to_string (void *ctx, GMimeMessage *message);
|
||||
|
||||
|
||||
#endif
|
||||
|
|
Loading…
Reference in a new issue