aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJeffrey Stedfast <fejj@helixcode.com>2000-11-18 06:29:53 +0800
committerJeffrey Stedfast <fejj@src.gnome.org>2000-11-18 06:29:53 +0800
commitb8262fdf8dcffd0a141c14d219f562893476f9ce (patch)
tree4755b9a46a7813140c23444d2e21c0ea4fccdb20
parent3d20f476af63c73f7bb0f8566426591375b73aba (diff)
downloadgsoc2013-evolution-b8262fdf8dcffd0a141c14d219f562893476f9ce.tar.gz
gsoc2013-evolution-b8262fdf8dcffd0a141c14d219f562893476f9ce.tar.zst
gsoc2013-evolution-b8262fdf8dcffd0a141c14d219f562893476f9ce.zip
Use the new quote_message function and make it start with "On %s, %s
2000-11-17 Jeffrey Stedfast <fejj@helixcode.com> * mail-format.c (mail_generate_reply): Use the new quote_message function and make it start with "On %s, %s wrote:" since people seem to want that. * mail-ops.c (cleanup_forward_messages): Use the new quote_message function. * mail-tools.c (mail_tool_quote_message): New convenience function to quote a message body (since both the reply and forward code do similar quoting) svn path=/trunk/; revision=6605
-rw-r--r--mail/ChangeLog13
-rw-r--r--mail/mail-format.c64
-rw-r--r--mail/mail-ops.c54
-rw-r--r--mail/mail-tools.c95
-rw-r--r--mail/mail-tools.h2
5 files changed, 123 insertions, 105 deletions
diff --git a/mail/ChangeLog b/mail/ChangeLog
index b73815fd03..56110fc2d9 100644
--- a/mail/ChangeLog
+++ b/mail/ChangeLog
@@ -1,3 +1,16 @@
+2000-11-17 Jeffrey Stedfast <fejj@helixcode.com>
+
+ * mail-format.c (mail_generate_reply): Use the new quote_message
+ function and make it start with "On %s, %s wrote:" since people
+ seem to want that.
+
+ * mail-ops.c (cleanup_forward_messages): Use the new quote_message
+ function.
+
+ * mail-tools.c (mail_tool_quote_message): New convenience function
+ to quote a message body (since both the reply and forward code do
+ similar quoting)
+
2000-11-17 Not Zed <NotZed@HelixCode.com>
* message-list.c (message_list_destroy): Before we destroy
diff --git a/mail/mail-format.c b/mail/mail-format.c
index 3a747b199f..d85f54febf 100644
--- a/mail/mail-format.c
+++ b/mail/mail-format.c
@@ -1643,15 +1643,16 @@ list_add_addresses(GList *list, const CamelInternetAddress *cia, const char *not
EMsgComposer *
mail_generate_reply (CamelMimeMessage *message, gboolean to_all)
{
- CamelDataWrapper *contents;
- char *text, *subject;
+ char *text, *subject, *date_str;
EMsgComposer *composer;
- gboolean want_plain, is_html;
const char *message_id, *references;
+ const char *name = NULL, *address = NULL;
GList *to = NULL, *cc = NULL;
MailConfigIdentity *id;
gchar *sig_file = NULL;
- const CamelInternetAddress *reply_to;
+ const CamelInternetAddress *reply_to, *sender;
+ time_t date;
+ int offset;
id = mail_config_get_default_identity ();
if (id)
@@ -1661,56 +1662,15 @@ mail_generate_reply (CamelMimeMessage *message, gboolean to_all)
if (!composer)
return NULL;
- want_plain = !mail_config_send_html ();
- contents = camel_medium_get_content_object (CAMEL_MEDIUM (message));
- text = mail_get_message_body (contents, want_plain, &is_html);
+ sender = camel_mime_message_get_from (message);
+ camel_internet_address_get (sender, 0, &name, &address);
+ date = camel_mime_message_get_date (message, &offset);
+ date_str = header_format_date (date, offset);
+ text = mail_tool_quote_message (message, _("On %s, %s wrote:\n"), date_str, name ? name : address);
+ g_free (date_str);
- /* Set the quoted reply text. */
if (text) {
- char *repl_text;
-
- if (is_html) {
- repl_text = g_strdup_printf ("<blockquote><i>\n%s\n"
- "</i></blockquote>\n",
- text);
- } else {
- char *s, *d, *quoted_text;
- int 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++;
- quoted_text = g_malloc (strlen (text) + lines * 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;
- sprintf (d, "> %.*s\n", len, s);
- s += len;
- if (!*s++)
- break;
- d += len + 3;
- }
- *d = '\0';
-
- /* Now convert that to HTML. */
- repl_text = e_text_to_html (quoted_text, E_TEXT_TO_HTML_PRE);
- g_free (quoted_text);
- }
-
- e_msg_composer_set_body_text (composer, repl_text);
- g_free (repl_text);
+ e_msg_composer_set_body_text (composer, text);
g_free (text);
}
diff --git a/mail/mail-ops.c b/mail/mail-ops.c
index 49b36f3eee..cb3fd03cbb 100644
--- a/mail/mail-ops.c
+++ b/mail/mail-ops.c
@@ -1612,62 +1612,12 @@ cleanup_forward_messages (gpointer in_data, gpointer op_data,
}
} else {
CamelMimeMessage *message = data->parts->pdata[0];
- CamelDataWrapper *contents;
- gboolean want_plain, is_html;
char *text;
- want_plain = !mail_config_send_html ();
- contents = camel_medium_get_content_object (CAMEL_MEDIUM (message));
- text = mail_get_message_body (contents, want_plain, &is_html);
+ text = mail_tool_quote_message (message, _("Forwarded message:\n"));
- /* FIXME: we should share this code with Reply */
-
- /* Set the quoted reply text. */
if (text) {
- char *repl_text;
-
- if (is_html) {
- repl_text = g_strdup_printf ("<blockquote><i>\n%s\n"
- "</i></blockquote>\n",
- text);
- } else {
- char *s, *d, *quoted_text;
- int 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++;
- quoted_text = g_malloc (strlen (text) + lines * 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;
- sprintf (d, "> %.*s\n", len, s);
- s += len;
- if (!*s++)
- break;
- d += len + 3;
- }
- *d = '\0';
-
- /* Now convert that to HTML. */
- repl_text = e_text_to_html (quoted_text, E_TEXT_TO_HTML_PRE);
- g_free (quoted_text);
- }
-
- e_msg_composer_set_body_text (input->composer, repl_text);
- g_free (repl_text);
+ e_msg_composer_set_body_text (input->composer, text);
g_free (text);
}
diff --git a/mail/mail-tools.c b/mail/mail-tools.c
index 25b353016e..b56ef33750 100644
--- a/mail/mail-tools.c
+++ b/mail/mail-tools.c
@@ -2,9 +2,10 @@
/* mail-ops.c: callbacks for the mail toolbar/menus */
/*
- * Author :
+ * Authors:
* Dan Winship <danw@helixcode.com>
* Peter Williams <peterw@helixcode.com>
+ * Jeffrey Stedfast <fejj@helixcode.com>
*
* Copyright 2000 Helix Code, Inc. (http://www.helixcode.com)
*
@@ -38,6 +39,7 @@
#include "mail.h" /*session*/
#include "mail-tools.h"
#include "mail-local.h"
+#include "e-util/e-html-utils.h"
/* **************************************** */
@@ -530,3 +532,94 @@ mail_tool_uri_to_folder_noex (const char *uri)
return result;
}
+
+/**
+ * mail_tool_quote_message:
+ * @message: mime message to quote
+ * @fmt: credits format - example: "On %s, %s wrote:\n"
+ * @Varargs: arguments
+ *
+ * Returns an allocated buffer containing the quoted message.
+ */
+gchar *
+mail_tool_quote_message (CamelMimeMessage *message, const char *fmt, ...)
+{
+ CamelDataWrapper *contents;
+ gboolean want_plain, is_html;
+ gchar *text;
+
+ want_plain = !mail_config_send_html ();
+ contents = camel_medium_get_content_object (CAMEL_MEDIUM (message));
+ text = mail_get_message_body (contents, want_plain, &is_html);
+
+ /* Set the quoted reply text. */
+ if (text) {
+ gchar *ret_text, *credits = NULL;
+
+ /* create credits */
+ if (fmt) {
+ gchar *buf;
+ va_list ap;
+
+ va_start (ap, fmt);
+ credits = g_strdup_vprintf (fmt, ap);
+ va_end (ap);
+ }
+
+ if (is_html) {
+ if (credits) {
+ ret_text = g_strdup_printf ("<blockquote><i>\n%s\n%s\n"
+ "</i></blockquote>\n",
+ credits, text);
+ } else {
+ ret_text = g_strdup_printf ("<blockquote><i>\n%s\n"
+ "</i></blockquote>\n",
+ text);
+ }
+ } else {
+ gchar *s, *d, *quoted_text;
+ gint lines, len, offset = 0;
+
+ /* 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 = credits ? strlen (credits) : 0;
+ quoted_text = g_malloc (offset + strlen (text) + lines * 2);
+
+ if (credits)
+ memcpy (quoted_text, credits, offset);
+
+ s = text;
+ d = quoted_text + offset;
+
+ /* Copy text to quoted_text line by line,
+ * prepending "> ".
+ */
+ while (1) {
+ len = strcspn (s, "\n");
+ if (len == 0 && !*s)
+ break;
+ sprintf (d, "> %.*s\n", len, s);
+ s += len;
+ if (!*s++)
+ break;
+ d += len + 3;
+ }
+ *d = '\0';
+
+ /* Now convert that to HTML. */
+ ret_text = e_text_to_html (quoted_text, E_TEXT_TO_HTML_PRE);
+ g_free (quoted_text);
+ }
+
+ g_free (text);
+ return ret_text;
+ }
+
+ return NULL;
+}
diff --git a/mail/mail-tools.h b/mail/mail-tools.h
index da5c0af8ff..1c04ae821b 100644
--- a/mail/mail-tools.h
+++ b/mail/mail-tools.h
@@ -99,4 +99,6 @@ mail_lookup_url_table (CamelMimeMessage *mime_message);
CamelFolder *
mail_tool_filter_get_folder_func (FilterDriver *d, const char *uri, void *data);
+gchar *mail_tool_quote_message (CamelMimeMessage *message, const char *fmt, ...);
+
#endif