aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--mail/e-mail-display.c6
-rw-r--r--mail/e-mail-reader.c22
-rw-r--r--mail/em-composer-utils.c95
-rw-r--r--mail/em-composer-utils.h9
-rw-r--r--modules/mail/e-mail-shell-backend.c39
-rw-r--r--plugins/mailing-list-actions/mailing-list-actions.c17
6 files changed, 107 insertions, 81 deletions
diff --git a/mail/e-mail-display.c b/mail/e-mail-display.c
index c3ca4d3f10..03d6e1d9ef 100644
--- a/mail/e-mail-display.c
+++ b/mail/e-mail-display.c
@@ -239,7 +239,6 @@ mail_display_process_mailto (EWebView *web_view, const gchar *mailto_uri)
EMailDisplayPrivate *priv;
EMFormat *format;
CamelFolder *folder = NULL;
- const gchar *folder_uri = NULL;
EShell *shell;
priv = E_MAIL_DISPLAY (web_view)->priv;
@@ -250,12 +249,9 @@ mail_display_process_mailto (EWebView *web_view, const gchar *mailto_uri)
if (format != NULL && format->folder != NULL)
folder = format->folder;
- if (folder != NULL)
- folder_uri = camel_folder_get_uri (folder);
-
shell = e_shell_get_default ();
em_utils_compose_new_message_with_mailto (
- shell, mailto_uri, folder_uri);
+ shell, mailto_uri, folder);
return TRUE;
}
diff --git a/mail/e-mail-reader.c b/mail/e-mail-reader.c
index 9d3ca5c228..ad596bba26 100644
--- a/mail/e-mail-reader.c
+++ b/mail/e-mail-reader.c
@@ -689,11 +689,9 @@ action_mail_forward_cb (GtkAction *action,
CamelFolder *folder;
GtkWindow *window;
GPtrArray *uids;
- const gchar *folder_uri;
backend = e_mail_reader_get_backend (reader);
folder = e_mail_reader_get_folder (reader);
- folder_uri = e_mail_reader_get_folder_uri (reader);
uids = e_mail_reader_get_selected_uids (reader);
window = e_mail_reader_get_window (reader);
@@ -704,7 +702,7 @@ action_mail_forward_cb (GtkAction *action,
if (em_utils_ask_open_many (window, uids->len))
em_utils_forward_messages (
- shell, folder, uids, folder_uri,
+ shell, folder, uids,
e_mail_reader_get_forward_style (reader));
else
em_utils_uids_free (uids);
@@ -722,11 +720,9 @@ action_mail_forward_attached_cb (GtkAction *action,
CamelFolder *folder;
GtkWindow *window;
GPtrArray *uids;
- const gchar *folder_uri;
backend = e_mail_reader_get_backend (reader);
folder = e_mail_reader_get_folder (reader);
- folder_uri = e_mail_reader_get_folder_uri (reader);
uids = e_mail_reader_get_selected_uids (reader);
window = e_mail_reader_get_window (reader);
@@ -737,7 +733,7 @@ action_mail_forward_attached_cb (GtkAction *action,
if (em_utils_ask_open_many (window, uids->len))
em_utils_forward_messages (
- shell, folder, uids, folder_uri,
+ shell, folder, uids,
E_MAIL_FORWARD_STYLE_ATTACHED);
else
em_utils_uids_free (uids);
@@ -755,11 +751,9 @@ action_mail_forward_inline_cb (GtkAction *action,
CamelFolder *folder;
GtkWindow *window;
GPtrArray *uids;
- const gchar *folder_uri;
backend = e_mail_reader_get_backend (reader);
folder = e_mail_reader_get_folder (reader);
- folder_uri = e_mail_reader_get_folder_uri (reader);
uids = e_mail_reader_get_selected_uids (reader);
window = e_mail_reader_get_window (reader);
@@ -770,7 +764,7 @@ action_mail_forward_inline_cb (GtkAction *action,
if (em_utils_ask_open_many (window, uids->len))
em_utils_forward_messages (
- shell, folder, uids, folder_uri,
+ shell, folder, uids,
E_MAIL_FORWARD_STYLE_INLINE);
else
em_utils_uids_free (uids);
@@ -788,11 +782,9 @@ action_mail_forward_quoted_cb (GtkAction *action,
CamelFolder *folder;
GtkWindow *window;
GPtrArray *uids;
- const gchar *folder_uri;
backend = e_mail_reader_get_backend (reader);
folder = e_mail_reader_get_folder (reader);
- folder_uri = e_mail_reader_get_folder_uri (reader);
uids = e_mail_reader_get_selected_uids (reader);
window = e_mail_reader_get_window (reader);
@@ -803,7 +795,7 @@ action_mail_forward_quoted_cb (GtkAction *action,
if (em_utils_ask_open_many (window, uids->len))
em_utils_forward_messages (
- shell, folder, uids, folder_uri,
+ shell, folder, uids,
E_MAIL_FORWARD_STYLE_QUOTED);
else
em_utils_uids_free (uids);
@@ -933,15 +925,15 @@ action_mail_message_new_cb (GtkAction *action,
EShell *shell;
EMailBackend *backend;
EShellBackend *shell_backend;
- const gchar *folder_uri;
+ CamelFolder *folder;
+ folder = e_mail_reader_get_folder (reader);
backend = e_mail_reader_get_backend (reader);
- folder_uri = e_mail_reader_get_folder_uri (reader);
shell_backend = E_SHELL_BACKEND (backend);
shell = e_shell_backend_get_shell (shell_backend);
- em_utils_compose_new_message (shell, folder_uri);
+ em_utils_compose_new_message (shell, folder);
}
static void
diff --git a/mail/em-composer-utils.c b/mail/em-composer-utils.c
index 2d3e7de605..d1f8666d8e 100644
--- a/mail/em-composer-utils.c
+++ b/mail/em-composer-utils.c
@@ -87,7 +87,6 @@ struct _ForwardData {
EShell *shell;
CamelFolder *folder;
GPtrArray *uids;
- gchar *from_uri;
EMailForwardStyle style;
};
@@ -121,8 +120,6 @@ forward_data_free (ForwardData *data)
if (data->uids != NULL)
em_utils_uids_free (data->uids);
- g_free (data->from_uri);
-
g_slice_free (ForwardData, data);
}
@@ -876,7 +873,7 @@ em_utils_composer_print_cb (EMsgComposer *composer,
static EMsgComposer *
create_new_composer (EShell *shell,
const gchar *subject,
- const gchar *from_uri)
+ CamelFolder *folder)
{
EMsgComposer *composer;
EComposerHeaderTable *table;
@@ -886,14 +883,23 @@ create_new_composer (EShell *shell,
table = e_msg_composer_get_header_table (composer);
- if (from_uri != NULL) {
+ if (folder != NULL) {
+ CamelStore *store;
+ const gchar *uid;
+ gchar *folder_uri;
GList *list;
- account = e_get_account_by_source_url (from_uri);
+ store = camel_folder_get_parent_store (folder);
+ uid = camel_service_get_uid (CAMEL_SERVICE (store));
+ account = e_get_account_by_uid (uid);
- list = g_list_prepend (NULL, (gpointer) from_uri);
+ folder_uri = e_mail_folder_uri_from_folder (folder);
+
+ list = g_list_prepend (NULL, folder_uri);
e_composer_header_table_set_post_to_list (table, list);
g_list_free (list);
+
+ g_free (folder_uri);
}
e_composer_header_table_set_account (table, account);
@@ -905,40 +911,42 @@ create_new_composer (EShell *shell,
/**
* em_utils_compose_new_message:
* @shell: an #EShell
+ * @folder: a #CamelFolder, or %NULL
*
* Opens a new composer window as a child window of @parent's toplevel
* window.
**/
void
em_utils_compose_new_message (EShell *shell,
- const gchar *from_uri)
+ CamelFolder *folder)
{
- GtkWidget *composer;
+ EMsgComposer *composer;
g_return_if_fail (E_IS_SHELL (shell));
- composer = (GtkWidget *) create_new_composer (shell, "", from_uri);
- if (composer == NULL)
- return;
+ if (folder != NULL)
+ g_return_if_fail (CAMEL_IS_FOLDER (folder));
- composer_set_no_change (E_MSG_COMPOSER (composer));
+ composer = create_new_composer (shell, "", folder);
+ composer_set_no_change (composer);
- gtk_widget_show (composer);
+ gtk_widget_show (GTK_WIDGET (composer));
}
/**
* em_utils_compose_new_message_with_mailto:
* @shell: an #EShell
- * @url: mailto url
+ * @mailto: a mailto URL
+ * @folder: a #CamelFolder, or %NULL
*
* Opens a new composer window as a child window of @parent's toplevel
- * window. If @url is non-NULL, the composer fields will be filled in
- * according to the values in the mailto url.
+ * window. If @mailto is non-NULL, the composer fields will be filled in
+ * according to the values in the mailto URL.
**/
EMsgComposer *
em_utils_compose_new_message_with_mailto (EShell *shell,
- const gchar *url,
- const gchar *from_uri)
+ const gchar *mailto,
+ CamelFolder *folder)
{
EMsgComposer *composer;
EComposerHeaderTable *table;
@@ -946,15 +954,26 @@ em_utils_compose_new_message_with_mailto (EShell *shell,
g_return_val_if_fail (E_IS_SHELL (shell), NULL);
- if (url != NULL)
- composer = e_msg_composer_new_from_url (shell, url);
+ if (folder != NULL)
+ g_return_val_if_fail (CAMEL_IS_FOLDER (folder), NULL);
+
+ if (mailto != NULL)
+ composer = e_msg_composer_new_from_url (shell, mailto);
else
composer = e_msg_composer_new (shell);
table = e_msg_composer_get_header_table (composer);
- if (from_uri
- && (account = e_get_account_by_source_url (from_uri)))
+ if (folder != NULL) {
+ CamelStore *store;
+ const gchar *uid;
+
+ store = camel_folder_get_parent_store (folder);
+ uid = camel_service_get_uid (CAMEL_SERVICE (store));
+ account = e_get_account_by_uid (uid);
+ }
+
+ if (account != NULL)
e_composer_header_table_set_account_name (table, account->name);
composer_set_no_change (composer);
@@ -1371,14 +1390,11 @@ forward_attached (EShell *shell,
GPtrArray *uids,
GPtrArray *messages,
CamelMimePart *part,
- gchar *subject,
- const gchar *from_uri)
+ gchar *subject)
{
EMsgComposer *composer;
- composer = create_new_composer (shell, subject, from_uri);
- if (composer == NULL)
- return NULL;
+ composer = create_new_composer (shell, subject, folder);
e_msg_composer_attach (composer, part);
@@ -1404,7 +1420,7 @@ forward_attached_cb (CamelFolder *folder,
if (part)
forward_attached (
data->shell, folder, data->uids,
- messages, part, subject, data->from_uri);
+ messages, part, subject);
forward_data_free (data);
}
@@ -1414,8 +1430,7 @@ forward_non_attached (EShell *shell,
CamelFolder *folder,
GPtrArray *uids,
GPtrArray *messages,
- EMailForwardStyle style,
- const gchar *from_uri)
+ EMailForwardStyle style)
{
CamelMimeMessage *message;
EMsgComposer *composer = NULL;
@@ -1444,7 +1459,7 @@ forward_non_attached (EShell *shell,
message, forward, flags, NULL, NULL, &validity_found);
if (text) {
- composer = create_new_composer (shell, subject, from_uri);
+ composer = create_new_composer (shell, subject, folder);
if (composer) {
if (CAMEL_IS_MULTIPART (camel_medium_get_content ((CamelMedium *)message)))
@@ -1476,7 +1491,7 @@ forward_non_attached (EShell *shell,
* em_utils_forward_message:
* @shell: an #EShell
* @message: message to be forwarded
- * @from_uri: from folder uri
+ * @folder: a #CamelFolder, or %NULL
* @style: the forward style to use
*
* Forwards a message in the given style. See em_utils_forward_messages()
@@ -1485,7 +1500,7 @@ forward_non_attached (EShell *shell,
EMsgComposer *
em_utils_forward_message (EShell *shell,
CamelMimeMessage *message,
- const gchar *from_uri,
+ CamelFolder *folder,
EMailForwardStyle style)
{
GPtrArray *messages;
@@ -1506,8 +1521,7 @@ em_utils_forward_message (EShell *shell,
subject = mail_tool_generate_forward_subject (message);
composer = forward_attached (
- shell, NULL, NULL, messages,
- part, subject, from_uri);
+ shell, NULL, NULL, messages, part, subject);
g_object_unref (part);
g_free (subject);
@@ -1516,13 +1530,13 @@ em_utils_forward_message (EShell *shell,
case E_MAIL_FORWARD_STYLE_INLINE:
composer = forward_non_attached (
shell, NULL, NULL, messages,
- E_MAIL_FORWARD_STYLE_INLINE, from_uri);
+ E_MAIL_FORWARD_STYLE_INLINE);
break;
case E_MAIL_FORWARD_STYLE_QUOTED:
composer = forward_non_attached (
shell, NULL, NULL, messages,
- E_MAIL_FORWARD_STYLE_QUOTED, from_uri);
+ E_MAIL_FORWARD_STYLE_QUOTED);
break;
}
@@ -1540,8 +1554,7 @@ forward_got_messages_cb (CamelFolder *folder,
ForwardData *data = user_data;
forward_non_attached (
- data->shell, folder, uids, messages,
- data->style, data->from_uri);
+ data->shell, folder, uids, messages, data->style);
forward_data_free (data);
}
@@ -1573,7 +1586,6 @@ void
em_utils_forward_messages (EShell *shell,
CamelFolder *folder,
GPtrArray *uids,
- const gchar *from_uri,
EMailForwardStyle style)
{
ForwardData *data;
@@ -1583,7 +1595,6 @@ em_utils_forward_messages (EShell *shell,
data = g_slice_new0 (ForwardData);
data->shell = g_object_ref (shell);
data->uids = em_utils_uids_copy (uids);
- data->from_uri = g_strdup (from_uri);
data->style = style;
switch (style) {
diff --git a/mail/em-composer-utils.h b/mail/em-composer-utils.h
index bab32c450e..b5a2f8ab84 100644
--- a/mail/em-composer-utils.h
+++ b/mail/em-composer-utils.h
@@ -32,11 +32,11 @@
G_BEGIN_DECLS
void em_utils_compose_new_message (EShell *shell,
- const gchar *from_uri);
+ CamelFolder *folder);
EMsgComposer * em_utils_compose_new_message_with_mailto
(EShell *shell,
- const gchar *url,
- const gchar *from_uri);
+ const gchar *mailto,
+ CamelFolder *folder);
GtkWidget * em_utils_edit_message (EShell *shell,
CamelFolder *folder,
CamelMimeMessage *message);
@@ -46,12 +46,11 @@ void em_utils_edit_messages (EShell *shell,
gboolean replace);
EMsgComposer * em_utils_forward_message (EShell *shell,
CamelMimeMessage *msg,
- const gchar *from_uri,
+ CamelFolder *folder,
EMailForwardStyle style);
void em_utils_forward_messages (EShell *shell,
CamelFolder *folder,
GPtrArray *uids,
- const gchar *from_uri,
EMailForwardStyle style);
void em_utils_redirect_message (EShell *shell,
CamelMimeMessage *message);
diff --git a/modules/mail/e-mail-shell-backend.c b/modules/mail/e-mail-shell-backend.c
index 609e483083..3d75b87f2c 100644
--- a/modules/mail/e-mail-shell-backend.c
+++ b/modules/mail/e-mail-shell-backend.c
@@ -36,6 +36,7 @@
#include "e-mail-shell-view.h"
#include "e-mail-browser.h"
+#include "e-mail-folder-utils.h"
#include "e-mail-reader.h"
#include "e-mail-session.h"
#include "e-mail-store.h"
@@ -147,12 +148,14 @@ action_mail_message_new_cb (GtkAction *action,
EShellWindow *shell_window)
{
EMailShellSidebar *mail_shell_sidebar;
+ EShellBackend *shell_backend;
EShellSidebar *shell_sidebar;
EShellView *shell_view;
EShell *shell;
EMFolderTree *folder_tree;
+ CamelFolder *folder = NULL;
const gchar *view_name;
- gchar *uri = NULL;
+ gchar *folder_uri = NULL;
shell = e_shell_window_get_shell (shell_window);
@@ -165,16 +168,40 @@ action_mail_message_new_cb (GtkAction *action,
goto exit;
shell_view = e_shell_window_get_shell_view (shell_window, view_name);
+ shell_backend = e_shell_view_get_shell_backend (shell_view);
shell_sidebar = e_shell_view_get_shell_sidebar (shell_view);
mail_shell_sidebar = E_MAIL_SHELL_SIDEBAR (shell_sidebar);
folder_tree = e_mail_shell_sidebar_get_folder_tree (mail_shell_sidebar);
- uri = em_folder_tree_get_selected_uri (folder_tree);
+ folder_uri = em_folder_tree_get_selected_uri (folder_tree);
+
+ if (folder_uri != NULL) {
+ EMailBackend *backend;
+ EMailSession *session;
+ CamelStore *store;
+ gchar *folder_name;
+ gboolean success;
+
+ backend = E_MAIL_BACKEND (shell_backend);
+ session = e_mail_backend_get_session (backend);
+
+ success = e_mail_folder_uri_parse (
+ CAMEL_SESSION (session), folder_uri,
+ &store, &folder_name, NULL);
+
+ /* FIXME This blocks and is not cancellable. */
+ if (success) {
+ folder = camel_store_get_folder_sync (
+ store, folder_name, 0, NULL, NULL);
+ g_object_unref (store);
+ g_free (folder_name);
+ }
-exit:
- em_utils_compose_new_message (shell, uri);
+ g_free (folder_uri);
+ }
- g_free (uri);
+exit:
+ em_utils_compose_new_message (shell, folder);
}
static GtkActionEntry item_entries[] = {
@@ -307,7 +334,7 @@ mail_shell_backend_handle_email_uri_cb (gchar *folder_uri,
shell_settings, "mail-forward-style");
em_utils_forward_messages (
- shell, folder, uids, folder_uri, forward_style);
+ shell, folder, uids, forward_style);
} else {
GtkWidget *browser;
diff --git a/plugins/mailing-list-actions/mailing-list-actions.c b/plugins/mailing-list-actions/mailing-list-actions.c
index 8090c21063..310c9affce 100644
--- a/plugins/mailing-list-actions/mailing-list-actions.c
+++ b/plugins/mailing-list-actions/mailing-list-actions.c
@@ -100,12 +100,11 @@ e_plugin_lib_enable (EPlugin *ep, gint enable)
typedef struct {
EMailReader *reader;
EmlaAction action;
- gchar * uri;
} emla_action_data;
static void
emla_list_action_do (CamelFolder *folder,
- const gchar *uid,
+ const gchar *message_uid,
CamelMimeMessage *msg,
gpointer data)
{
@@ -121,10 +120,16 @@ emla_list_action_do (CamelFolder *folder,
EShellBackend *shell_backend;
EAccount *account;
GtkWindow *window;
+ CamelStore *store;
+ const gchar *uid;
if (msg == NULL)
return;
+ store = camel_folder_get_parent_store (folder);
+ uid = camel_service_get_uid (CAMEL_SERVICE (store));
+ account = e_get_account_by_uid (uid);
+
backend = e_mail_reader_get_backend (action_data->reader);
shell_backend = E_SHELL_BACKEND (backend);
@@ -181,14 +186,14 @@ emla_list_action_do (CamelFolder *folder,
if (send_message_response == GTK_RESPONSE_YES) {
/* directly send message */
composer = e_msg_composer_new_from_url (shell, url);
- if ((account = e_get_account_by_source_url (action_data->uri)))
+ if (account != NULL)
e_composer_header_table_set_account (
e_msg_composer_get_header_table (composer),
account);
e_msg_composer_send (composer);
} else if (send_message_response == GTK_RESPONSE_NO) {
/* show composer */
- em_utils_compose_new_message_with_mailto (shell, url, action_data->uri);
+ em_utils_compose_new_message_with_mailto (shell, url, folder);
}
goto exit;
@@ -212,7 +217,6 @@ emla_list_action_do (CamelFolder *folder,
exit:
g_object_unref (action_data->reader);
- g_free (action_data->uri);
g_free (action_data);
g_free (url);
}
@@ -224,10 +228,8 @@ emla_list_action (EMailReader *reader,
CamelFolder *folder;
GPtrArray *uids;
emla_action_data *data;
- const gchar *folder_uri;
folder = e_mail_reader_get_folder (reader);
- folder_uri = e_mail_reader_get_folder_uri (reader);
uids = e_mail_reader_get_selected_uids (reader);
g_return_if_fail (uids->len == 1);
@@ -235,7 +237,6 @@ emla_list_action (EMailReader *reader,
data = g_malloc (sizeof (emla_action_data));
data->reader = g_object_ref (reader);
data->action = action;
- data->uri = g_strdup (folder_uri);
mail_get_message (
folder, uids->pdata[0],