diff options
author | Matthew Barnes <mbarnes@redhat.com> | 2011-05-13 04:31:12 +0800 |
---|---|---|
committer | Matthew Barnes <mbarnes@redhat.com> | 2011-05-13 06:24:42 +0800 |
commit | 9cbfb1963b7747deec5333b7e376e9a42c5da299 (patch) | |
tree | df4fbc169015d27cca85eaa6dc258ffe9c2f78b8 /mail/e-mail-reader.c | |
parent | 366dacefa0a59c66320f65f19796eb30ad23f255 (diff) | |
download | gsoc2013-evolution-9cbfb1963b7747deec5333b7e376e9a42c5da299.tar.gz gsoc2013-evolution-9cbfb1963b7747deec5333b7e376e9a42c5da299.tar.zst gsoc2013-evolution-9cbfb1963b7747deec5333b7e376e9a42c5da299.zip |
Reimplement the "mail-redirect" action.
Now fetches the message itself using camel_folder_get_message(),
then calls em_utils_redirect_message().
Diffstat (limited to 'mail/e-mail-reader.c')
-rw-r--r-- | mail/e-mail-reader.c | 67 |
1 files changed, 59 insertions, 8 deletions
diff --git a/mail/e-mail-reader.c b/mail/e-mail-reader.c index 85d623ddde..315e6b91c1 100644 --- a/mail/e-mail-reader.c +++ b/mail/e-mail-reader.c @@ -1033,28 +1033,79 @@ action_mail_print_preview_cb (GtkAction *action, } static void -action_mail_redirect_cb (GtkAction *action, - EMailReader *reader) +mail_reader_redirect_cb (CamelFolder *folder, + GAsyncResult *result, + EMailReaderClosure *closure) { EShell *shell; EMailBackend *backend; - EShellBackend *shell_backend; + EAlertSink *alert_sink; + CamelMimeMessage *message; + GError *error = NULL; + + alert_sink = e_activity_get_alert_sink (closure->activity); + + message = camel_folder_get_message_finish (folder, result, &error); + + if (e_activity_handle_cancellation (closure->activity, error)) { + g_warn_if_fail (message == NULL); + mail_reader_closure_free (closure); + g_error_free (error); + return; + + } else if (error != NULL) { + g_warn_if_fail (message == NULL); + e_alert_submit ( + alert_sink, "no-retrieve-message", + error->message, NULL); + mail_reader_closure_free (closure); + g_error_free (error); + return; + } + + g_return_if_fail (CAMEL_IS_MIME_MESSAGE (message)); + + backend = e_mail_reader_get_backend (closure->reader); + shell = e_shell_backend_get_shell (E_SHELL_BACKEND (backend)); + + em_utils_redirect_message (shell, message); + check_close_browser_reader (closure->reader); + + g_object_unref (message); + + mail_reader_closure_free (closure); +} + +static void +action_mail_redirect_cb (GtkAction *action, + EMailReader *reader) +{ + EActivity *activity; + GCancellable *cancellable; + EMailReaderClosure *closure; GtkWidget *message_list; CamelFolder *folder; const gchar *uid; - backend = e_mail_reader_get_backend (reader); folder = e_mail_reader_get_folder (reader); message_list = e_mail_reader_get_message_list (reader); uid = MESSAGE_LIST (message_list)->cursor_uid; g_return_if_fail (uid != NULL); - shell_backend = E_SHELL_BACKEND (backend); - shell = e_shell_backend_get_shell (shell_backend); + /* Open the message asynchronously. */ - em_utils_redirect_message_by_uid (shell, folder, uid); - check_close_browser_reader (reader); + activity = e_mail_reader_new_activity (reader); + cancellable = e_activity_get_cancellable (activity); + + closure = g_slice_new0 (EMailReaderClosure); + closure->activity = activity; + closure->reader = g_object_ref (reader); + + camel_folder_get_message ( + folder, uid, G_PRIORITY_DEFAULT, + cancellable, (GAsyncReadyCallback) + mail_reader_redirect_cb, closure); } static void |