From 9734f4252d8d24fede29bef124b9b5104cf8f0c6 Mon Sep 17 00:00:00 2001 From: Dan Winship Date: Tue, 8 Aug 2000 20:45:36 +0000 Subject: Fix up format of addresses. (write_headers): Use CamelAddress functions to * mail-format.c (mail_generate_reply): Fix up format of addresses. (write_headers): Use CamelAddress functions to simplify this. svn path=/trunk/; revision=4606 --- mail/ChangeLog | 5 ++++ mail/mail-format.c | 84 +++++++++++++++++++++--------------------------------- 2 files changed, 38 insertions(+), 51 deletions(-) (limited to 'mail') diff --git a/mail/ChangeLog b/mail/ChangeLog index 420135177e..f91fcee4f5 100644 --- a/mail/ChangeLog +++ b/mail/ChangeLog @@ -1,3 +1,8 @@ +2000-08-08 Dan Winship + + * mail-format.c (mail_generate_reply): Fix up format of addresses. + (write_headers): Use CamelAddress functions to simplify this. + 2000-08-08 Jeffrey Stedfast * mail-view.c: Lets get rid of the last separator in the toolbar diff --git a/mail/mail-format.c b/mail/mail-format.c index 41dbac4a3b..1be527bad2 100644 --- a/mail/mail-format.c +++ b/mail/mail-format.c @@ -426,47 +426,11 @@ write_field_to_stream (const char *description, const char *value, g_free (encoded_value); } -static void -write_recipients_to_stream (const gchar *recipient_type, - const CamelInternetAddress *recipients, - gboolean optional, gboolean bold, - GtkHTML *html, GtkHTMLStream *stream) -{ - int i; - char *recipients_string = NULL; - const char *name, *addr; - - i = 0; - while (camel_internet_address_get (recipients, i++, &name, &addr)) { - char *old_string = recipients_string; - - if (*name) { - recipients_string = g_strdup_printf ( - "%s%s\"%s\" <%s>", - old_string ? old_string : "", - old_string ? ", " : "", - name, addr); - } else { - recipients_string = g_strdup_printf ( - "%s%s%s", old_string ? old_string : "", - old_string ? ", " : "", addr); - } - g_free (old_string); - } - - if (recipients_string || !optional) { - write_field_to_stream (recipient_type, recipients_string, - bold, html, stream); - } - g_free (recipients_string); -} - - - static void write_headers (CamelMimeMessage *message, struct mail_format_data *mfd) { const CamelInternetAddress *recipients; + char *string; mail_html_write (mfd->html, mfd->stream, "html, mfd->stream); - if (camel_mime_message_get_reply_to (message)) { - write_field_to_stream ("Reply-To:", - camel_mime_message_get_reply_to (message), - FALSE, mfd->html, mfd->stream); + string = camel_mime_message_get_reply_to (message); + if (string) { + write_field_to_stream ("Reply-To:", string, FALSE, + mfd->html, mfd->stream); } - write_recipients_to_stream ("To:", - camel_mime_message_get_recipients (message, CAMEL_RECIPIENT_TYPE_TO), - FALSE, TRUE, mfd->html, mfd->stream); + recipients = camel_mime_message_get_recipients ( + message, CAMEL_RECIPIENT_TYPE_TO); + string = camel_address_encode (CAMEL_ADDRESS (recipients)); + write_field_to_stream ("To:", string ? string : "", TRUE, + mfd->html, mfd->stream); + g_free (string); + + recipients = camel_mime_message_get_recipients ( + message, CAMEL_RECIPIENT_TYPE_CC); + string = camel_address_encode (CAMEL_ADDRESS (recipients)); + if (string) { + write_field_to_stream ("Cc:", string, TRUE, + mfd->html, mfd->stream); + } + g_free (string); - recipients = camel_mime_message_get_recipients (message, CAMEL_RECIPIENT_TYPE_CC); - write_recipients_to_stream ("Cc:", recipients, TRUE, TRUE, - mfd->html, mfd->stream); - write_field_to_stream ("Subject: ", + write_field_to_stream ("Subject:", camel_mime_message_get_subject (message), TRUE, mfd->html, mfd->stream); - mail_html_write (mfd->html, mfd->stream, "

"); + mail_html_write (mfd->html, mfd->stream, + "

"); } @@ -1729,7 +1703,11 @@ mail_generate_reply (CamelMimeMessage *message, gboolean to_all) i = 0; cc = NULL; while (camel_internet_address_get (recip, i++, &name, &addr)) { - fulladdr = g_strdup_printf ("%s <%s>", name, addr); + if (*name) { + fulladdr = g_strdup_printf ("\"%s\" <%s>", + name, addr); + } else + fulladdr = g_strdup (addr); cc = g_list_append (cc, fulladdr); } @@ -1737,7 +1715,11 @@ mail_generate_reply (CamelMimeMessage *message, gboolean to_all) CAMEL_RECIPIENT_TYPE_CC); i = 0; while (camel_internet_address_get (recip, i++, &name, &addr)) { - fulladdr = g_strdup_printf ("%s <%s>", name, addr); + if (*name) { + fulladdr = g_strdup_printf ("\"%s\" <%s>", + name, addr); + } else + fulladdr = g_strdup (addr); cc = g_list_append (cc, fulladdr); } } else -- cgit