aboutsummaryrefslogtreecommitdiffstats
path: root/mail
diff options
context:
space:
mode:
Diffstat (limited to 'mail')
-rw-r--r--mail/ChangeLog17
-rw-r--r--mail/folder-browser-factory.c4
-rw-r--r--mail/mail-callbacks.c94
-rw-r--r--mail/mail-callbacks.h11
-rw-r--r--mail/mail-tools.c69
-rw-r--r--mail/mail-tools.h2
-rw-r--r--mail/mail-view.c8
7 files changed, 167 insertions, 38 deletions
diff --git a/mail/ChangeLog b/mail/ChangeLog
index 48757cd6f8..efb5995653 100644
--- a/mail/ChangeLog
+++ b/mail/ChangeLog
@@ -1,3 +1,20 @@
+2001-03-08 Jeffrey Stedfast <fejj@ximian.com>
+
+ * folder-browser-factory.c: Set the Forward->Quoted callback.
+ Also set the forward->Attachment callback.
+
+ * mail-view.c (view_forward_msg): Specify FORWARD_ATTACHED.
+
+ * mail-callbacks.c (forward_attached): Don't call
+ forward_messages() anymore...never really needed to. Just handle
+ it directly.
+ (forward_inlined): Specify FORWARD_INLINE as the flag argument.
+ (forward_quoted): New function sorta like forward_inlined except
+ this forwards the message quoted.
+
+ * mail-tools.c (mail_tool_forward_message): New function to
+ prepare a message to be forwarded.
+
2001-03-08 Jon Trowbridge <trow@ximian.com>
* mail-format.c (write_field_row_begin): Added. Table row HTML
diff --git a/mail/folder-browser-factory.c b/mail/folder-browser-factory.c
index 0ba731bbe7..4a0252b091 100644
--- a/mail/folder-browser-factory.c
+++ b/mail/folder-browser-factory.c
@@ -64,8 +64,10 @@ BonoboUIVerb verbs [] = {
BONOBO_UI_UNSAFE_VERB ("MessagePrint", print_msg),
BONOBO_UI_UNSAFE_VERB ("MessageReplySndr", reply_to_sender),
BONOBO_UI_UNSAFE_VERB ("MessageReplyAll", reply_to_all),
- BONOBO_UI_UNSAFE_VERB ("MessageForwardInlined", forward_inlined),
BONOBO_UI_UNSAFE_VERB ("MessageForwardAttached", forward_attached),
+ BONOBO_UI_UNSAFE_VERB ("MessageForwardInlined", forward_inlined),
+ BONOBO_UI_UNSAFE_VERB ("MessageForwardQuoted", forward_quoted),
+ BONOBO_UI_UNSAFE_VERB ("MessageForwardAttachment", forward_attached),
BONOBO_UI_UNSAFE_VERB ("MessageMarkAsRead", mark_as_seen),
BONOBO_UI_UNSAFE_VERB ("MessageMarkAsUnRead", mark_as_unseen),
diff --git a/mail/mail-callbacks.c b/mail/mail-callbacks.c
index b4356d05e5..36213a2c8a 100644
--- a/mail/mail-callbacks.c
+++ b/mail/mail-callbacks.c
@@ -722,54 +722,80 @@ forward_get_composer (const char *subject)
} else {
g_warning("Could not create composer");
}
-
+
return composer;
}
static void
-do_forward_inline(CamelFolder *folder, char *uid, CamelMimeMessage *message, void *data)
+do_forward_inline (CamelFolder *folder, char *uid, CamelMimeMessage *message, void *data)
{
char *subject;
char *text;
+
+ if (message) {
+ subject = mail_tool_generate_forward_subject (message);
+ text = mail_tool_forward_message (message);
+
+ if (text) {
+ EMsgComposer *composer = forward_get_composer (subject);
+ if (composer) {
+ e_msg_composer_set_body_text (composer, text);
+ gtk_widget_show (GTK_WIDGET (composer));
+ e_msg_composer_unset_changed (composer);
+ }
+ g_free (text);
+ }
+
+ g_free (subject);
+ }
+}
+static void
+do_forward_quoted (CamelFolder *folder, char *uid, CamelMimeMessage *message, void *data)
+{
+ char *subject;
+ char *text;
+
if (message) {
- subject = mail_tool_generate_forward_subject(message);
+ subject = mail_tool_generate_forward_subject (message);
text = mail_tool_quote_message (message, _("Forwarded message:\n"));
-
+
if (text) {
- EMsgComposer *composer = forward_get_composer(subject);
+ EMsgComposer *composer = forward_get_composer (subject);
if (composer) {
- e_msg_composer_set_body_text(composer, text);
- gtk_widget_show(GTK_WIDGET(composer));
- e_msg_composer_unset_changed(composer);
+ e_msg_composer_set_body_text (composer, text);
+ gtk_widget_show (GTK_WIDGET (composer));
+ e_msg_composer_unset_changed (composer);
}
- g_free(text);
+ g_free (text);
}
-
- g_free(subject);
+
+ g_free (subject);
}
}
static void
-do_forward_attach(CamelFolder *folder, GPtrArray *messages, CamelMimePart *part, char *subject, void *data)
+do_forward_attach (CamelFolder *folder, GPtrArray *messages, CamelMimePart *part, char *subject, void *data)
{
if (part) {
- EMsgComposer *composer = forward_get_composer(subject);
+ EMsgComposer *composer = forward_get_composer (subject);
if (composer) {
- e_msg_composer_attach(composer, part);
- gtk_widget_show(GTK_WIDGET(composer));
- e_msg_composer_unset_changed(composer);
+ e_msg_composer_attach (composer, part);
+ gtk_widget_show (GTK_WIDGET (composer));
+ e_msg_composer_unset_changed (composer);
}
}
}
void
-forward_messages (CamelFolder *folder, GPtrArray *uids, gboolean doinline)
+forward_messages (CamelFolder *folder, GPtrArray *uids, int flags)
{
- if (doinline && uids->len == 1) {
- mail_get_message(folder, uids->pdata[0], do_forward_inline, NULL, mail_thread_new);
+ if (flags == FORWARD_INLINE && uids->len == 1) {
+ mail_get_message (folder, uids->pdata[0], do_forward_inline, NULL, mail_thread_new);
+ } else if (flags == FORWARD_QUOTED && uids->len == 1) {
+ mail_get_message (folder, uids->pdata[0], do_forward_quoted, NULL, mail_thread_new);
} else {
- mail_build_attachment(folder, uids, do_forward_attach, NULL);
+ mail_build_attachment (folder, uids, do_forward_attach, NULL);
}
}
@@ -784,7 +810,23 @@ forward_inlined (GtkWidget *widget, gpointer user_data)
uids = g_ptr_array_new ();
g_ptr_array_add (uids, g_strdup (fb->message_list->cursor_uid));
- forward_messages (fb->message_list->folder, uids, TRUE);
+ forward_messages (fb->message_list->folder, uids, FORWARD_INLINE);
+ g_free (uids->pdata[0]);
+ g_ptr_array_free (uids, TRUE);
+}
+
+void
+forward_quoted (GtkWidget *widget, gpointer user_data)
+{
+ FolderBrowser *fb = FOLDER_BROWSER (user_data);
+ GPtrArray *uids;
+
+ if (!check_send_configuration (fb))
+ return;
+
+ uids = g_ptr_array_new ();
+ g_ptr_array_add (uids, g_strdup (fb->message_list->cursor_uid));
+ forward_messages (fb->message_list->folder, uids, FORWARD_QUOTED);
g_free (uids->pdata[0]);
g_ptr_array_free (uids, TRUE);
}
@@ -794,13 +836,13 @@ forward_attached (GtkWidget *widget, gpointer user_data)
{
GPtrArray *uids;
FolderBrowser *fb = (FolderBrowser *)user_data;
-
+
if (!check_send_configuration (fb))
return;
-
- uids = g_ptr_array_new();
- message_list_foreach(fb->message_list, enumerate_msg, uids);
- forward_messages(fb->message_list->folder, uids, FALSE);
+
+ uids = g_ptr_array_new ();
+ message_list_foreach (fb->message_list, enumerate_msg, uids);
+ mail_build_attachment (fb->message_list->folder, uids, do_forward_attach, NULL);
}
static void
diff --git a/mail/mail-callbacks.h b/mail/mail-callbacks.h
index 5cfeb54b7b..bc04110b3c 100644
--- a/mail/mail-callbacks.h
+++ b/mail/mail-callbacks.h
@@ -42,9 +42,18 @@ void send_receive_mail (GtkWidget *widget, gpointer user_data);
void compose_msg (GtkWidget *widget, gpointer user_data);
void send_to_url (const char *url);
-void forward_messages (CamelFolder *folder, GPtrArray *uids, gboolean doinline);
+
+enum {
+ FORWARD_INLINE,
+ FORWARD_QUOTED,
+ FORWARD_ATTACHED
+};
+
+void forward_messages (CamelFolder *folder, GPtrArray *uids, int flag);
void forward_inlined (GtkWidget *widget, gpointer user_data);
+void forward_quoted (GtkWidget *widget, gpointer user_data);
void forward_attached (GtkWidget *widget, gpointer user_data);
+
void reply_to_sender (GtkWidget *widget, gpointer user_data);
void reply_to_all (GtkWidget *widget, gpointer user_data);
void delete_msg (GtkWidget *widget, gpointer user_data);
diff --git a/mail/mail-tools.c b/mail/mail-tools.c
index 0c623916ac..48a0bd94e8 100644
--- a/mail/mail-tools.c
+++ b/mail/mail-tools.c
@@ -167,12 +167,6 @@ mail_tool_do_movemail (const gchar *source_url, CamelException *ex)
return dest_path;
}
-void
-mail_tool_set_uid_flags (CamelFolder *folder, const char *uid, guint32 mask, guint32 set)
-{
- camel_folder_set_message_flags (folder, uid, mask, set);
-}
-
char *
mail_tool_generate_forward_subject (CamelMimeMessage *msg)
{
@@ -376,3 +370,66 @@ mail_tool_quote_message (CamelMimeMessage *message, const char *fmt, ...)
return NULL;
}
+
+/**
+ * mail_tool_forward_message:
+ * @message: mime message to quote
+ *
+ * Returns an allocated buffer containing the forwarded message.
+ */
+gchar *
+mail_tool_forward_message (CamelMimeMessage *message)
+{
+ CamelDataWrapper *contents;
+ gboolean want_plain, is_html;
+ 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);
+
+ /* Set the quoted reply text. */
+ if (text) {
+ gchar *ret_text, *credits = NULL;
+ const CamelInternetAddress *cia;
+ const char *subject;
+ char *buf, *from, *to;
+
+ /* create credits */
+ cia = camel_mime_message_get_from (message);
+ buf = camel_address_format (CAMEL_ADDRESS (cia));
+ from = e_text_to_html (buf, E_TEXT_TO_HTML_CONVERT_NL | E_TEXT_TO_HTML_CONVERT_URLS);
+ g_free (buf);
+
+ cia = camel_mime_message_get_recipients (message, CAMEL_RECIPIENT_TYPE_TO);
+ buf = camel_address_format (CAMEL_ADDRESS (cia));
+ to = e_text_to_html (buf, E_TEXT_TO_HTML_CONVERT_NL | E_TEXT_TO_HTML_CONVERT_URLS);
+ g_free (buf);
+
+ subject = camel_mime_message_get_subject (message);
+
+ credits = g_strdup_printf (_("-----Forwarded Message-----<br>"
+ "<b>From:</b> %s<br>"
+ "<b>To:</b> %s<br>"
+ "<b>Subject:</b> %s<br>"),
+ from, to, subject);
+ 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;
+}
diff --git a/mail/mail-tools.h b/mail/mail-tools.h
index 7f6aa647f3..5738ea0efa 100644
--- a/mail/mail-tools.h
+++ b/mail/mail-tools.h
@@ -76,4 +76,6 @@ mail_lookup_url_table (CamelMimeMessage *mime_message);
gchar *mail_tool_quote_message (CamelMimeMessage *message, const char *fmt, ...);
+gchar *mail_tool_forward_message (CamelMimeMessage *message);
+
#endif
diff --git a/mail/mail-view.c b/mail/mail-view.c
index 320ad9510d..d70c9d4bca 100644
--- a/mail/mail-view.c
+++ b/mail/mail-view.c
@@ -101,10 +101,10 @@ view_forward_msg (GtkWidget *widget, gpointer user_data)
{
mail_view_data *data = (mail_view_data *) user_data;
GPtrArray *uids;
-
- uids = g_ptr_array_new();
- g_ptr_array_add(uids, g_strdup (data->uid));
- forward_messages(data->source, uids, FALSE);
+
+ uids = g_ptr_array_new ();
+ g_ptr_array_add (uids, g_strdup (data->uid));
+ forward_messages (data->source, uids, FORWARD_ATTACHED);
}
static void