aboutsummaryrefslogtreecommitdiffstats
path: root/mail
diff options
context:
space:
mode:
Diffstat (limited to 'mail')
-rw-r--r--mail/ChangeLog10
-rw-r--r--mail/em-composer-utils.c95
-rw-r--r--mail/em-composer-utils.h14
-rw-r--r--mail/em-folder-browser.c6
-rw-r--r--mail/em-folder-view.c10
-rw-r--r--mail/em-popup.c8
-rw-r--r--mail/mail-component.c4
7 files changed, 93 insertions, 54 deletions
diff --git a/mail/ChangeLog b/mail/ChangeLog
index eefe0837a7..64fd2c4015 100644
--- a/mail/ChangeLog
+++ b/mail/ChangeLog
@@ -1,5 +1,15 @@
2004-05-03 Not Zed <NotZed@Ximian.com>
+ * em-composer-utils.c (create_new_composer): take fromuri and
+ subject to set the basic headers/account.
+ (em_utils_compose_new_message)
+ (em_utils_compose_new_message_with_mailto, forward_attached)
+ (em_utils_forward_attached, forward_non_attached)
+ (em_utils_forward_inline, em_utils_forward_quoted)
+ (em_utils_forward_message, em_utils_forward_messages): Take the
+ from folder uri to set the from account if it can. Fixed all
+ callers. For #57964.
+
* mail-send-recv.c (receive_update_done): removed.
* em-mailer-prefs.h:
diff --git a/mail/em-composer-utils.c b/mail/em-composer-utils.c
index 5d365a8c33..c7ec92feca 100644
--- a/mail/em-composer-utils.c
+++ b/mail/em-composer-utils.c
@@ -623,14 +623,20 @@ em_composer_utils_setup_callbacks (EMsgComposer *composer, CamelFolder *folder,
/* Composing messages... */
static EMsgComposer *
-create_new_composer (void)
+create_new_composer (const char *subject, const char *fromuri)
{
EMsgComposer *composer;
-
+ EAccount *account = NULL;
+
composer = e_msg_composer_new ();
+ if (fromuri)
+ account = mail_config_get_account_by_source_url(fromuri);
+
+ e_msg_composer_set_headers (composer, account?account->name:NULL, NULL, NULL, NULL, subject);
+
em_composer_utils_setup_default_callbacks (composer);
-
+
return composer;
}
@@ -641,12 +647,15 @@ create_new_composer (void)
* window.
**/
void
-em_utils_compose_new_message (void)
+em_utils_compose_new_message (const char *fromuri)
{
GtkWidget *composer;
-
- composer = (GtkWidget *) create_new_composer ();
-
+
+ composer = (GtkWidget *) create_new_composer ("", fromuri);
+
+ e_msg_composer_unset_changed ((EMsgComposer *)composer);
+ e_msg_composer_drop_editor_undo ((EMsgComposer *)composer);
+
gtk_widget_show (composer);
}
@@ -659,9 +668,10 @@ em_utils_compose_new_message (void)
* according to the values in the mailto url.
**/
void
-em_utils_compose_new_message_with_mailto (const char *url)
+em_utils_compose_new_message_with_mailto (const char *url, const char *fromuri)
{
EMsgComposer *composer;
+ EAccount *account = NULL;
if (url != NULL)
composer = e_msg_composer_new_from_url (url);
@@ -669,6 +679,13 @@ em_utils_compose_new_message_with_mailto (const char *url)
composer = e_msg_composer_new ();
em_composer_utils_setup_default_callbacks (composer);
+
+ if (fromuri
+ && (account = mail_config_get_account_by_source_url(fromuri)))
+ e_msg_composer_set_headers (composer, account->name, NULL, NULL, NULL, "");
+
+ e_msg_composer_unset_changed (composer);
+ e_msg_composer_drop_editor_undo (composer);
gtk_widget_show ((GtkWidget *) composer);
}
@@ -743,7 +760,7 @@ static void
edit_message (CamelMimeMessage *message, CamelFolder *drafts, const char *uid)
{
EMsgComposer *composer;
-
+
composer = e_msg_composer_new_with_message (message);
em_composer_utils_setup_callbacks (composer, NULL, NULL, 0, 0, drafts, uid);
e_msg_composer_unset_changed (composer);
@@ -799,17 +816,12 @@ em_utils_edit_messages (CamelFolder *folder, GPtrArray *uids)
}
/* Forwarding messages... */
-
static void
-forward_attached (CamelFolder *folder, GPtrArray *messages, CamelMimePart *part, char *subject, void *user_data)
+forward_attached (CamelFolder *folder, GPtrArray *messages, CamelMimePart *part, char *subject, const char *fromuri)
{
EMsgComposer *composer;
- if (part == NULL)
- return;
-
- composer = create_new_composer ();
- e_msg_composer_set_headers (composer, NULL, NULL, NULL, NULL, subject);
+ composer = create_new_composer (subject, fromuri);
e_msg_composer_attach (composer, part);
e_msg_composer_unset_changed (composer);
@@ -818,10 +830,19 @@ forward_attached (CamelFolder *folder, GPtrArray *messages, CamelMimePart *part,
gtk_widget_show (GTK_WIDGET (composer));
}
+static void
+forward_attached_cb (CamelFolder *folder, GPtrArray *messages, CamelMimePart *part, char *subject, void *user_data)
+{
+ if (part)
+ forward_attached(folder, messages, part, subject, (char *)user_data);
+ g_free(user_data);
+}
+
/**
* em_utils_forward_attached:
* @folder: folder containing messages to forward
* @uids: uids of messages to forward
+ * @fromuri: from folder uri
*
* If there is more than a single message in @uids, a multipart/digest
* will be constructed and attached to a new composer window preset
@@ -830,16 +851,16 @@ forward_attached (CamelFolder *folder, GPtrArray *messages, CamelMimePart *part,
* forwarded as a simple message/rfc822 attachment.
**/
void
-em_utils_forward_attached (CamelFolder *folder, GPtrArray *uids)
+em_utils_forward_attached (CamelFolder *folder, GPtrArray *uids, const char *fromuri)
{
g_return_if_fail (CAMEL_IS_FOLDER (folder));
g_return_if_fail (uids != NULL);
- mail_build_attachment (folder, uids, forward_attached, NULL);
+ mail_build_attachment (folder, uids, forward_attached_cb, g_strdup(fromuri));
}
static void
-forward_non_attached (GPtrArray *messages, int style)
+forward_non_attached (GPtrArray *messages, int style, const char *fromuri)
{
CamelMimeMessage *message;
CamelDataWrapper *wrapper;
@@ -862,8 +883,7 @@ forward_non_attached (GPtrArray *messages, int style)
text = em_utils_message_to_html (message, _("-------- Forwarded Message --------"), flags);
if (text) {
- composer = create_new_composer ();
- e_msg_composer_set_headers (composer, NULL, NULL, NULL, NULL, subject);
+ composer = create_new_composer (subject, fromuri);
wrapper = camel_medium_get_content_object (CAMEL_MEDIUM (message));
if (CAMEL_IS_MULTIPART (wrapper))
@@ -886,57 +906,62 @@ forward_non_attached (GPtrArray *messages, int style)
static void
forward_inline (CamelFolder *folder, GPtrArray *uids, GPtrArray *messages, void *user_data)
{
- forward_non_attached (messages, MAIL_CONFIG_FORWARD_INLINE);
+ forward_non_attached (messages, MAIL_CONFIG_FORWARD_INLINE, (char *)user_data);
+ g_free(user_data);
}
/**
* em_utils_forward_inline:
* @folder: folder containing messages to forward
* @uids: uids of messages to forward
+ * @fromuri: from folder/account uri
*
* Forwards each message in the 'inline' form, each in its own composer window.
**/
void
-em_utils_forward_inline (CamelFolder *folder, GPtrArray *uids)
+em_utils_forward_inline (CamelFolder *folder, GPtrArray *uids, const char *fromuri)
{
g_return_if_fail (CAMEL_IS_FOLDER (folder));
g_return_if_fail (uids != NULL);
- mail_get_messages (folder, uids, forward_inline, NULL);
+ mail_get_messages (folder, uids, forward_inline, g_strdup(fromuri));
}
static void
forward_quoted (CamelFolder *folder, GPtrArray *uids, GPtrArray *messages, void *user_data)
{
- forward_non_attached (messages, MAIL_CONFIG_FORWARD_QUOTED);
+ forward_non_attached (messages, MAIL_CONFIG_FORWARD_QUOTED, (char *)user_data);
+ g_free(user_data);
}
/**
* em_utils_forward_quoted:
* @folder: folder containing messages to forward
* @uids: uids of messages to forward
+ * @fromuri: from folder uri
*
* Forwards each message in the 'quoted' form (each line starting with
* a "> "), each in its own composer window.
**/
void
-em_utils_forward_quoted (CamelFolder *folder, GPtrArray *uids)
+em_utils_forward_quoted (CamelFolder *folder, GPtrArray *uids, const char *fromuri)
{
g_return_if_fail (CAMEL_IS_FOLDER (folder));
g_return_if_fail (uids != NULL);
- mail_get_messages (folder, uids, forward_quoted, NULL);
+ mail_get_messages (folder, uids, forward_quoted, g_strdup(fromuri));
}
/**
* em_utils_forward_message:
* @parent: parent window
* @message: message to be forwarded
+ * @fromuri: from folder uri
*
* Forwards a message in the user's configured default style.
**/
void
-em_utils_forward_message (CamelMimeMessage *message)
+em_utils_forward_message (CamelMimeMessage *message, const char *fromuri)
{
GPtrArray *messages;
CamelMimePart *part;
@@ -957,15 +982,15 @@ em_utils_forward_message (CamelMimeMessage *message)
subject = mail_tool_generate_forward_subject (message);
- forward_attached (NULL, messages, part, subject, NULL);
+ forward_attached (NULL, messages, part, subject, fromuri);
camel_object_unref (part);
g_free (subject);
break;
case MAIL_CONFIG_FORWARD_INLINE:
- forward_non_attached (messages, MAIL_CONFIG_FORWARD_INLINE);
+ forward_non_attached (messages, MAIL_CONFIG_FORWARD_INLINE, fromuri);
break;
case MAIL_CONFIG_FORWARD_QUOTED:
- forward_non_attached (messages, MAIL_CONFIG_FORWARD_QUOTED);
+ forward_non_attached (messages, MAIL_CONFIG_FORWARD_QUOTED, fromuri);
break;
}
@@ -981,7 +1006,7 @@ em_utils_forward_message (CamelMimeMessage *message)
* style.
**/
void
-em_utils_forward_messages (CamelFolder *folder, GPtrArray *uids)
+em_utils_forward_messages (CamelFolder *folder, GPtrArray *uids, const char *fromuri)
{
GConfClient *gconf;
int mode;
@@ -992,13 +1017,13 @@ em_utils_forward_messages (CamelFolder *folder, GPtrArray *uids)
switch (mode) {
case MAIL_CONFIG_FORWARD_ATTACHED:
default:
- em_utils_forward_attached (folder, uids);
+ em_utils_forward_attached (folder, uids, fromuri);
break;
case MAIL_CONFIG_FORWARD_INLINE:
- em_utils_forward_inline (folder, uids);
+ em_utils_forward_inline (folder, uids, fromuri);
break;
case MAIL_CONFIG_FORWARD_QUOTED:
- em_utils_forward_quoted (folder, uids);
+ em_utils_forward_quoted (folder, uids, fromuri);
break;
}
}
diff --git a/mail/em-composer-utils.h b/mail/em-composer-utils.h
index 01972f1fa2..7498b0b43b 100644
--- a/mail/em-composer-utils.h
+++ b/mail/em-composer-utils.h
@@ -42,22 +42,22 @@ void em_composer_utils_setup_callbacks (struct _EMsgComposer *composer, struct _
void em_utils_composer_send_cb(struct _EMsgComposer *composer, gpointer user_data);
void em_utils_composer_save_draft_cb(struct _EMsgComposer *composer, int quit, gpointer user_data);
-void em_utils_compose_new_message (void);
+void em_utils_compose_new_message (const char *fromuri);
/* FIXME: mailto? url? should make up its mind what its called. imho use 'uri' */
-void em_utils_compose_new_message_with_mailto (const char *url);
+void em_utils_compose_new_message_with_mailto (const char *url, const char *fromuri);
void em_utils_post_to_folder (struct _CamelFolder *folder);
void em_utils_post_to_url (const char *url);
void em_utils_edit_message (struct _CamelMimeMessage *message);
void em_utils_edit_messages (struct _CamelFolder *folder, GPtrArray *uids);
-void em_utils_forward_attached (struct _CamelFolder *folder, GPtrArray *uids);
-void em_utils_forward_inline (struct _CamelFolder *folder, GPtrArray *uids);
-void em_utils_forward_quoted (struct _CamelFolder *folder, GPtrArray *uids);
+void em_utils_forward_attached (struct _CamelFolder *folder, GPtrArray *uids, const char *fromuri);
+void em_utils_forward_inline (struct _CamelFolder *folder, GPtrArray *uids, const char *fromuri);
+void em_utils_forward_quoted (struct _CamelFolder *folder, GPtrArray *uids, const char *fromuri);
-void em_utils_forward_message (struct _CamelMimeMessage *msg);
-void em_utils_forward_messages (struct _CamelFolder *folder, GPtrArray *uids);
+void em_utils_forward_message (struct _CamelMimeMessage *msg, const char *fromuri);
+void em_utils_forward_messages (struct _CamelFolder *folder, GPtrArray *uids, const char *fromuri);
void em_utils_redirect_message (struct _CamelMimeMessage *message);
void em_utils_redirect_message_by_uid (struct _CamelFolder *folder, const char *uid);
diff --git a/mail/em-folder-browser.c b/mail/em-folder-browser.c
index b3e9ca92fe..1943d99941 100644
--- a/mail/em-folder-browser.c
+++ b/mail/em-folder-browser.c
@@ -626,10 +626,12 @@ emfb_empty_trash(BonoboUIComponent *uid, void *data, const char *path)
static void
emfb_mail_compose(BonoboUIComponent *uid, void *data, const char *path)
{
- if (!em_utils_check_user_can_send_mail((GtkWidget *)data))
+ EMFolderView *emfv = data;
+
+ if (!em_utils_check_user_can_send_mail((GtkWidget *)emfv))
return;
- em_utils_compose_new_message ();
+ em_utils_compose_new_message(emfv->folder_uri);
}
static void
diff --git a/mail/em-folder-view.c b/mail/em-folder-view.c
index e91cfc4a3f..2f83ec768c 100644
--- a/mail/em-folder-view.c
+++ b/mail/em-folder-view.c
@@ -527,7 +527,7 @@ emfv_popup_forward(GtkWidget *w, EMFolderView *emfv)
return;
uids = message_list_get_selected(emfv->list);
- em_utils_forward_messages (emfv->folder, uids);
+ em_utils_forward_messages (emfv->folder, uids, emfv->folder_uri);
}
static void
@@ -1047,7 +1047,7 @@ emfv_message_forward_attached (BonoboUIComponent *uic, void *data, const char *p
return;
uids = message_list_get_selected (emfv->list);
- em_utils_forward_attached (emfv->folder, uids);
+ em_utils_forward_attached (emfv->folder, uids, emfv->folder_uri);
}
static void
@@ -1060,7 +1060,7 @@ emfv_message_forward_inline (BonoboUIComponent *uic, void *data, const char *pat
return;
uids = message_list_get_selected (emfv->list);
- em_utils_forward_inline (emfv->folder, uids);
+ em_utils_forward_inline (emfv->folder, uids, emfv->folder_uri);
}
static void
@@ -1073,7 +1073,7 @@ emfv_message_forward_quoted (BonoboUIComponent *uic, void *data, const char *pat
return;
uids = message_list_get_selected (emfv->list);
- em_utils_forward_quoted (emfv->folder, uids);
+ em_utils_forward_quoted (emfv->folder, uids, emfv->folder_uri);
}
static void
@@ -1909,7 +1909,7 @@ static void
emfv_format_link_clicked(EMFormatHTMLDisplay *efhd, const char *uri, EMFolderView *emfv)
{
if (!strncasecmp (uri, "mailto:", 7)) {
- em_utils_compose_new_message_with_mailto (uri);
+ em_utils_compose_new_message_with_mailto (uri, emfv->folder_uri);
} else if (*uri == '#') {
gtk_html_jump_to_anchor (((EMFormatHTML *) efhd)->html, uri + 1);
} else if (!strncasecmp (uri, "thismessage:", 12)) {
diff --git a/mail/em-popup.c b/mail/em-popup.c
index 70d324740f..57c4264a82 100644
--- a/mail/em-popup.c
+++ b/mail/em-popup.c
@@ -796,9 +796,10 @@ static void
emp_part_popup_forward (GtkWidget *w, EMPopupTarget *t)
{
CamelMimeMessage *message;
-
+
+ /* TODO: have a emfv specific override so we can get the parent folder uri */
message = (CamelMimeMessage *) camel_medium_get_content_object ((CamelMedium *) t->data.part.part);
- em_utils_forward_message (message);
+ em_utils_forward_message (message, NULL);
}
static EMPopupItem emp_standard_object_popups[] = {
@@ -832,7 +833,8 @@ emp_uri_popup_link_open(GtkWidget *w, EMPopupTarget *t)
static void
emp_uri_popup_address_send (GtkWidget *w, EMPopupTarget *t)
{
- em_utils_compose_new_message_with_mailto (t->data.uri);
+ /* TODO: have an emfv specific override to get the from uri */
+ em_utils_compose_new_message_with_mailto (t->data.uri, NULL);
}
static void
diff --git a/mail/mail-component.c b/mail/mail-component.c
index 102a012523..c40095ed3d 100644
--- a/mail/mail-component.c
+++ b/mail/mail-component.c
@@ -723,7 +723,7 @@ create_item(const char *type, EMFolderTreeModel *model, const char *uri)
if (!em_utils_check_user_can_send_mail(NULL))
return 0;
- em_utils_compose_new_message();
+ em_utils_compose_new_message(uri);
} else if (strcmp(type, "folder") == 0) {
EMFolderTree *folder_tree;
GtkWidget *dialog;
@@ -768,7 +768,7 @@ impl_handleURI (PortableServer_Servant servant, const char *uri, CORBA_Environme
if (!em_utils_check_user_can_send_mail(NULL))
return;
- em_utils_compose_new_message_with_mailto (uri);
+ em_utils_compose_new_message_with_mailto (uri, NULL);
}
}