diff options
author | Dan Winship <danw@src.gnome.org> | 2001-09-07 04:10:02 +0800 |
---|---|---|
committer | Dan Winship <danw@src.gnome.org> | 2001-09-07 04:10:02 +0800 |
commit | e243f47a722dcbabbc1e82fa2cfeb8d4edcc0f60 (patch) | |
tree | 0a967cdf3e1ccf771ce74f4336238452d023d956 /mail/mail-tools.c | |
parent | 3f7f2d2f2e9d344dd102d245aed8e0af2a102f47 (diff) | |
download | gsoc2013-evolution-e243f47a722dcbabbc1e82fa2cfeb8d4edcc0f60.tar.gz gsoc2013-evolution-e243f47a722dcbabbc1e82fa2cfeb8d4edcc0f60.tar.zst gsoc2013-evolution-e243f47a722dcbabbc1e82fa2cfeb8d4edcc0f60.zip |
Fix a bunch of replying/forwarding-related formatting bugs.
2749 - Message text not included in reply, but html attachment is
4294 - "forward inline" should quote the same headers as the
normal mail display
6100 - Reply to a forwarded email displays email headers
7255 - Replying to HTML message
7527 - replying to forwarded message w/ attachments does the wrong
thing
* mail-format.c (mail_get_message_rfc822): New function to get
message headers and body together, for inline forwards, or replies
containing attached messages.
(mail_get_message_body): Redo this to always return HTML, but keep
the "want_plain" flag, to decide whether to return HTML that looks
like HTML or HTML that looks like plain text. Use
mail_get_message_rfc822 to handle attached message/rfc822 parts.
Don't include the text of vcard or icalendar attachments. Don't
fail to include text parts just because we found an HTML part.
(Since we're always returning HTML now, this doesn't cause
problems any more.)
* mail-tools.c (mail_tool_quote_message): Simplify greatly.
mail_get_message_body always returns HTML now, and we let it take
care of prepending "> "s too. We then let GtkHTML deal with
converting the HTML to plain text if the user wants to reply in
plain text.
(mail_tool_forward_message): Simplify this a ton too: parts of it
are moved into mail_get_message_rfc822 and parts are now
unnecessary.
* mail-callbacks.c (do_forward_non_attached): Call
mail_tool_forward_message here always, and let it do the "> "
quoting in the "quoted" case, so that we get the headers too when
forwarding quoted. Related to bug #4294.
svn path=/trunk/; revision=12657
Diffstat (limited to 'mail/mail-tools.c')
-rw-r--r-- | mail/mail-tools.c | 162 |
1 files changed, 26 insertions, 136 deletions
diff --git a/mail/mail-tools.c b/mail/mail-tools.c index 56575ef4b1..45d5a45a5e 100644 --- a/mail/mail-tools.c +++ b/mail/mail-tools.c @@ -386,12 +386,15 @@ gchar * mail_tool_quote_message (CamelMimeMessage *message, const char *fmt, ...) { CamelDataWrapper *contents; - gboolean want_plain, is_html; + gboolean want_plain; gchar *text; want_plain = !mail_config_get_send_html (); contents = camel_medium_get_content_object (CAMEL_MEDIUM (message)); - text = mail_get_message_body (contents, want_plain, &is_html); + /* We pass "want_plain" for "cite", since if it's HTML, we'll + * do the citing ourself below. + */ + text = mail_get_message_body (contents, want_plain, want_plain); /* Set the quoted reply text. */ if (text) { @@ -406,68 +409,15 @@ mail_tool_quote_message (CamelMimeMessage *message, const char *fmt, ...) va_end (ap); } - if (is_html) { - ret_text = g_strdup_printf ("%s<!--+GtkHTML:<DATA class=\"ClueFlow\" key=\"orig\" value=\"1\">-->" - "<blockquote><i><font color=\"%06x\">\n%s\n" - "</font></i></blockquote>" - "<!--+GtkHTML:<DATA class=\"ClueFlow\" clear=\"orig\">-->", - credits ? credits : "", - mail_config_get_citation_color (), text); - } else { - gchar *s, *d, *quoted_text, *orig_text; - gint lines, len; - - /* Count the number of lines in the body. If - * the text ends with a \n, this will be one - * too high, but that's ok. Allocate enough - * space for the text and the "> "s. - */ - for (s = text, lines = 0; s; s = strchr (s + 1, '\n')) - lines++; - - /* offset is the size of the credits, strlen (text) - * covers the body, lines * 2 does the "> "s, and - * the last +2 covers the final "\0", plus an extra - * "\n" in case text doesn't end with one. - */ - quoted_text = g_malloc (strlen (text) + lines * 2 + 2); - - s = text; - d = quoted_text; - - /* Copy text to quoted_text line by line, - * prepending "> ". - */ - while (1) { - len = strcspn (s, "\n"); - if (len == 0 && !*s) - break; - if (!strncmp ("-- \n", s, 4)) - break; - sprintf (d, "> %.*s\n", len, s); - s += len; - if (!*s++) - break; - d += len + 3; - } - *d = '\0'; - - /* Now convert that to HTML. */ - orig_text = e_text_to_html_full (quoted_text, E_TEXT_TO_HTML_PRE - | (mail_config_get_citation_highlight () - ? E_TEXT_TO_HTML_MARK_CITATION : 0), - mail_config_get_citation_color ()); - g_free (quoted_text); - ret_text = g_strdup_printf ("%s<!--+GtkHTML:<DATA class=\"ClueFlow\" key=\"orig\" value=\"1\">-->" - "%s" - "<!--+GtkHTML:<DATA class=\"ClueFlow\" clear=\"orig\">-->", - credits ? credits : "", - orig_text); - g_free (orig_text); - } - + ret_text = g_strdup_printf ("%s<!--+GtkHTML:<DATA class=\"ClueFlow\" key=\"orig\" value=\"1\">-->" + "<font color=\"%06x\">\n%s%s%s</font>" + "<!--+GtkHTML:<DATA class=\"ClueFlow\" clear=\"orig\">-->", + credits ? credits : "", + mail_config_get_citation_color (), + want_plain ? "" : "<blockquote><i>", + text, + want_plain ? "" : "</i></blockquote>"); g_free (text); - return ret_text; } @@ -476,82 +426,22 @@ mail_tool_quote_message (CamelMimeMessage *message, const char *fmt, ...) /** * mail_tool_forward_message: - * @message: mime message to quote + * @message: mime message to forward + * @quoted: whether to forwarded it quoted (%TRUE) or inline (%FALSE) * * Returns an allocated buffer containing the forwarded message. */ gchar * -mail_tool_forward_message (CamelMimeMessage *message) +mail_tool_forward_message (CamelMimeMessage *message, gboolean quoted) { - CamelDataWrapper *contents; - gboolean want_plain, is_html; - XEvolution *xev; - gchar *text; - - xev = mail_tool_remove_xevolution_headers (message); - - want_plain = !mail_config_get_send_html (); - contents = camel_medium_get_content_object (CAMEL_MEDIUM (message)); - text = mail_get_message_body (contents, want_plain, &is_html); - - mail_tool_restore_xevolution_headers (message, xev); - mail_tool_destroy_xevolution (xev); - - /* Set the quoted reply text. */ - if (text) { - gchar *ret_text, *credits = NULL; - const CamelInternetAddress *cia; - char *buf, *from, *to, *subject; - char *title; - - /* create credits */ - cia = camel_mime_message_get_from (message); - buf = camel_address_format (CAMEL_ADDRESS (cia)); - if (buf) { - from = e_text_to_html (buf, E_TEXT_TO_HTML_CONVERT_NL | E_TEXT_TO_HTML_CONVERT_URLS); - g_free (buf); - } else - from = NULL; - - cia = camel_mime_message_get_recipients (message, CAMEL_RECIPIENT_TYPE_TO); - buf = camel_address_format (CAMEL_ADDRESS (cia)); - if (buf) { - to = e_text_to_html (buf, E_TEXT_TO_HTML_CONVERT_NL | E_TEXT_TO_HTML_CONVERT_URLS); - g_free (buf); - } else - to = NULL; - - buf = (char *) camel_mime_message_get_subject (message); - if (buf) - subject = e_text_to_html (buf, E_TEXT_TO_HTML_CONVERT_NL | E_TEXT_TO_HTML_CONVERT_URLS); - else - subject = ""; - - title = e_utf8_from_locale_string (_("Forwarded Message")); - credits = g_strdup_printf ("-----%s-----<br>" - "<b>From:</b> %s<br>" - "<b>To:</b> %s<br>" - "<b>Subject:</b> %s<br>", - title, from ? from : "", - to ? to : "", subject); - g_free (title); - g_free (from); - g_free (to); - - if (!is_html) { - /* Now convert that to HTML. */ - ret_text = e_text_to_html (text, E_TEXT_TO_HTML_PRE); - g_free (text); - text = ret_text; - } - - ret_text = g_strdup_printf ("%s<br>%s\n", credits, text); - - g_free (credits); - g_free (text); - - return ret_text; - } - - return NULL; + gchar *title, *body, *ret; + + body = mail_get_message_body (CAMEL_DATA_WRAPPER (message), + !mail_config_get_send_html (), + quoted); + title = e_utf8_from_locale_string (_("Forwarded Message")); + ret = g_strdup_printf ("-----%s-----<br>%s", title, body ? body : ""); + g_free (title); + g_free (body); + return ret; } |