aboutsummaryrefslogtreecommitdiffstats
path: root/mail
diff options
context:
space:
mode:
authorMatthew Barnes <mbarnes@redhat.com>2013-06-03 02:30:06 +0800
committerMatthew Barnes <mbarnes@redhat.com>2013-06-03 02:30:06 +0800
commit13b2bd263cc68e60839d04f801fd8b6f4b80b3d2 (patch)
tree49f8f9d582b85103377c60c06fb4cf7d88ef19dc /mail
parent43610e343194912394e5097655403f6ab7993ab0 (diff)
downloadgsoc2013-evolution-13b2bd263cc68e60839d04f801fd8b6f4b80b3d2.tar
gsoc2013-evolution-13b2bd263cc68e60839d04f801fd8b6f4b80b3d2.tar.gz
gsoc2013-evolution-13b2bd263cc68e60839d04f801fd8b6f4b80b3d2.tar.bz2
gsoc2013-evolution-13b2bd263cc68e60839d04f801fd8b6f4b80b3d2.tar.lz
gsoc2013-evolution-13b2bd263cc68e60839d04f801fd8b6f4b80b3d2.tar.xz
gsoc2013-evolution-13b2bd263cc68e60839d04f801fd8b6f4b80b3d2.tar.zst
gsoc2013-evolution-13b2bd263cc68e60839d04f801fd8b6f4b80b3d2.zip
Add e_mail_reader_edit_messages().
Replaces em_utils_edit_messages().
Diffstat (limited to 'mail')
-rw-r--r--mail/e-mail-folder-pane.c4
-rw-r--r--mail/e-mail-reader-utils.c119
-rw-r--r--mail/e-mail-reader-utils.h5
-rw-r--r--mail/e-mail-reader.c2
-rw-r--r--mail/em-composer-utils.c121
-rw-r--r--mail/em-composer-utils.h5
6 files changed, 125 insertions, 131 deletions
diff --git a/mail/e-mail-folder-pane.c b/mail/e-mail-folder-pane.c
index a84aab1453..300835384e 100644
--- a/mail/e-mail-folder-pane.c
+++ b/mail/e-mail-folder-pane.c
@@ -100,7 +100,7 @@ mail_paned_view_open_selected_mail (EMailPanedView *view)
if (em_utils_folder_is_drafts (registry, folder) ||
em_utils_folder_is_outbox (registry, folder) ||
em_utils_folder_is_templates (registry, folder)) {
- em_utils_edit_messages (reader, folder, uids, TRUE, TRUE);
+ e_mail_reader_edit_messages (reader, folder, uids, TRUE, TRUE);
g_ptr_array_unref (uids);
return 0;
}
@@ -134,7 +134,7 @@ mail_paned_view_open_selected_mail (EMailPanedView *view)
edits = g_ptr_array_new_with_free_func (
(GDestroyNotify) g_free);
g_ptr_array_add (edits, real_uid);
- em_utils_edit_messages (
+ e_mail_reader_edit_messages (
reader, real_folder, edits, TRUE, TRUE);
g_ptr_array_unref (edits);
} else {
diff --git a/mail/e-mail-reader-utils.c b/mail/e-mail-reader-utils.c
index 0a7dc8d421..81efa8fac2 100644
--- a/mail/e-mail-reader-utils.c
+++ b/mail/e-mail-reader-utils.c
@@ -73,6 +73,8 @@ struct _AsyncContext {
GtkPrintOperationAction print_action;
const gchar *filter_source;
gint filter_type;
+ gboolean replace;
+ gboolean keep_signature;
};
static void
@@ -817,7 +819,7 @@ e_mail_reader_open_selected (EMailReader *reader)
if (em_utils_folder_is_drafts (registry, folder) ||
em_utils_folder_is_outbox (registry, folder) ||
em_utils_folder_is_templates (registry, folder)) {
- em_utils_edit_messages (reader, folder, uids, TRUE, TRUE);
+ e_mail_reader_edit_messages (reader, folder, uids, TRUE, TRUE);
return uids->len;
}
@@ -849,7 +851,7 @@ e_mail_reader_open_selected (EMailReader *reader)
edits = g_ptr_array_new ();
g_ptr_array_add (edits, real_uid);
- em_utils_edit_messages (
+ e_mail_reader_edit_messages (
reader, real_folder, edits, TRUE, TRUE);
} else {
g_free (real_uid);
@@ -1270,6 +1272,119 @@ e_mail_reader_remove_duplicates (EMailReader *reader)
g_ptr_array_unref (uids);
}
+static void
+mail_reader_edit_messages_cb (GObject *source_object,
+ GAsyncResult *result,
+ gpointer user_data)
+{
+ CamelFolder *folder;
+ EShell *shell;
+ EMailBackend *backend;
+ EActivity *activity;
+ EAlertSink *alert_sink;
+ GHashTable *hash_table;
+ GHashTableIter iter;
+ gpointer key, value;
+ AsyncContext *async_context;
+ GError *local_error = NULL;
+
+ folder = CAMEL_FOLDER (source_object);
+ async_context = (AsyncContext *) user_data;
+
+ activity = async_context->activity;
+ alert_sink = e_activity_get_alert_sink (activity);
+
+ hash_table = e_mail_folder_get_multiple_messages_finish (
+ folder, result, &local_error);
+
+ /* Sanity check. */
+ g_return_if_fail (
+ ((hash_table != NULL) && (local_error == NULL)) ||
+ ((hash_table == NULL) && (local_error != NULL)));
+
+ if (e_activity_handle_cancellation (activity, local_error)) {
+ g_error_free (local_error);
+ goto exit;
+
+ } else if (local_error != NULL) {
+ e_alert_submit (
+ alert_sink,
+ "mail:get-multiple-messages",
+ local_error->message, NULL);
+ g_error_free (local_error);
+ goto exit;
+ }
+
+ backend = e_mail_reader_get_backend (async_context->reader);
+ shell = e_shell_backend_get_shell (E_SHELL_BACKEND (backend));
+
+ /* Open each message in its own composer window. */
+
+ g_hash_table_iter_init (&iter, hash_table);
+
+ while (g_hash_table_iter_next (&iter, &key, &value)) {
+ EMsgComposer *composer;
+ CamelMimeMessage *message;
+ const gchar *message_uid = NULL;
+
+ if (async_context->replace)
+ message_uid = (const gchar *) key;
+
+ message = CAMEL_MIME_MESSAGE (value);
+
+ camel_medium_remove_header (
+ CAMEL_MEDIUM (message), "X-Mailer");
+
+ composer = em_utils_edit_message (
+ shell, folder, message, message_uid,
+ async_context->keep_signature);
+
+ e_mail_reader_composer_created (
+ async_context->reader, composer, message);
+ }
+
+ g_hash_table_unref (hash_table);
+
+ e_activity_set_state (activity, E_ACTIVITY_COMPLETED);
+
+exit:
+ async_context_free (async_context);
+}
+
+void
+e_mail_reader_edit_messages (EMailReader *reader,
+ CamelFolder *folder,
+ GPtrArray *uids,
+ gboolean replace,
+ gboolean keep_signature)
+{
+ EActivity *activity;
+ GCancellable *cancellable;
+ AsyncContext *async_context;
+
+ g_return_if_fail (E_IS_MAIL_READER (reader));
+ g_return_if_fail (CAMEL_IS_FOLDER (folder));
+ g_return_if_fail (uids != NULL);
+
+ activity = e_mail_reader_new_activity (reader);
+ cancellable = e_activity_get_cancellable (activity);
+
+ async_context = g_slice_new0 (AsyncContext);
+ async_context->activity = g_object_ref (activity);
+ async_context->reader = g_object_ref (reader);
+ async_context->replace = replace;
+ async_context->keep_signature = keep_signature;
+
+ e_mail_folder_get_multiple_messages (
+ folder, uids,
+ G_PRIORITY_DEFAULT,
+ cancellable,
+ mail_reader_edit_messages_cb,
+ async_context);
+
+ g_object_unref (activity);
+}
+
/* Helper for e_mail_reader_reply_to_message()
* XXX This function belongs in e-html-utils.c */
static gboolean
diff --git a/mail/e-mail-reader-utils.h b/mail/e-mail-reader-utils.h
index 110c5dfa37..1b91a8f1fc 100644
--- a/mail/e-mail-reader-utils.h
+++ b/mail/e-mail-reader-utils.h
@@ -68,6 +68,11 @@ void e_mail_reader_print (EMailReader *reader,
void e_mail_reader_remove_attachments
(EMailReader *reader);
void e_mail_reader_remove_duplicates (EMailReader *reader);
+void e_mail_reader_edit_messages (EMailReader *reader,
+ CamelFolder *folder,
+ GPtrArray *uids,
+ gboolean replace,
+ gboolean keep_signature);
void e_mail_reader_reply_to_message (EMailReader *reader,
CamelMimeMessage *message,
EMailReplyType reply_type);
diff --git a/mail/e-mail-reader.c b/mail/e-mail-reader.c
index fb01182700..4730ac5b3b 100644
--- a/mail/e-mail-reader.c
+++ b/mail/e-mail-reader.c
@@ -879,7 +879,7 @@ action_mail_message_edit_cb (GtkAction *action,
g_ptr_array_set_free_func (uids, (GDestroyNotify) g_free);
replace = em_utils_folder_is_drafts (registry, folder);
- em_utils_edit_messages (reader, folder, uids, replace, replace);
+ e_mail_reader_edit_messages (reader, folder, uids, replace, replace);
g_ptr_array_unref (uids);
}
diff --git a/mail/em-composer-utils.c b/mail/em-composer-utils.c
index 60c3855d60..d6c85f3968 100644
--- a/mail/em-composer-utils.c
+++ b/mail/em-composer-utils.c
@@ -80,8 +80,6 @@ struct _AsyncContext {
EMailForwardStyle style;
gchar *folder_uri;
gchar *message_uid;
- gboolean replace;
- gboolean keep_signature;
};
struct _ForwardData {
@@ -1491,125 +1489,6 @@ em_utils_edit_message (EShell *shell,
}
static void
-edit_messages_cb (GObject *source_object,
- GAsyncResult *result,
- gpointer user_data)
-{
- CamelFolder *folder;
- EShell *shell;
- EMailBackend *backend;
- EActivity *activity;
- EAlertSink *alert_sink;
- GHashTable *hash_table;
- GHashTableIter iter;
- gpointer key, value;
- AsyncContext *async_context;
- GError *local_error = NULL;
-
- folder = CAMEL_FOLDER (source_object);
- async_context = (AsyncContext *) user_data;
-
- activity = async_context->activity;
- alert_sink = e_activity_get_alert_sink (activity);
-
- hash_table = e_mail_folder_get_multiple_messages_finish (
- folder, result, &local_error);
-
- /* Sanity check. */
- g_return_if_fail (
- ((hash_table != NULL) && (local_error == NULL)) ||
- ((hash_table == NULL) && (local_error != NULL)));
-
- if (e_activity_handle_cancellation (activity, local_error)) {
- g_error_free (local_error);
- goto exit;
-
- } else if (local_error != NULL) {
- e_alert_submit (
- alert_sink,
- "mail:get-multiple-messages",
- local_error->message, NULL);
- g_error_free (local_error);
- goto exit;
- }
-
- backend = e_mail_reader_get_backend (async_context->reader);
- shell = e_shell_backend_get_shell (E_SHELL_BACKEND (backend));
-
- /* Open each message in its own composer window. */
-
- g_hash_table_iter_init (&iter, hash_table);
-
- while (g_hash_table_iter_next (&iter, &key, &value)) {
- EMsgComposer *composer;
- CamelMimeMessage *message;
- const gchar *message_uid;
-
- if (!async_context->replace)
- key = NULL;
-
- message_uid = (const gchar *) key;
- message = CAMEL_MIME_MESSAGE (value);
-
- camel_medium_remove_header (CAMEL_MEDIUM (value), "X-Mailer");
-
- composer = em_utils_edit_message (
- shell, folder, message, message_uid,
- async_context->keep_signature);
-
- e_mail_reader_composer_created (
- async_context->reader, composer, message);
- }
-
- g_hash_table_unref (hash_table);
-
- e_activity_set_state (activity, E_ACTIVITY_COMPLETED);
-
-exit:
- async_context_free (async_context);
-}
-
-/**
- * em_utils_edit_messages:
- * @reader: an #EMailReader
- * @folder: folder containing messages to edit
- * @uids: uids of messages to edit
- * @replace: replace the existing message(s) when sent or saved.
- *
- * Opens a composer for each message to be edited.
- **/
-void
-em_utils_edit_messages (EMailReader *reader,
- CamelFolder *folder,
- GPtrArray *uids,
- gboolean replace,
- gboolean keep_signature)
-{
- EActivity *activity;
- AsyncContext *async_context;
- GCancellable *cancellable;
-
- g_return_if_fail (E_IS_MAIL_READER (reader));
- g_return_if_fail (CAMEL_IS_FOLDER (folder));
- g_return_if_fail (uids != NULL);
-
- activity = e_mail_reader_new_activity (reader);
- cancellable = e_activity_get_cancellable (activity);
-
- async_context = g_slice_new0 (AsyncContext);
- async_context->activity = activity;
- async_context->reader = g_object_ref (reader);
- async_context->ptr_array = g_ptr_array_ref (uids);
- async_context->replace = replace;
- async_context->keep_signature = keep_signature;
-
- e_mail_folder_get_multiple_messages (
- folder, uids, G_PRIORITY_DEFAULT,
- cancellable, edit_messages_cb,
- async_context);
-}
-
-static void
emu_update_composers_security (EMsgComposer *composer,
guint32 validity_found)
{
diff --git a/mail/em-composer-utils.h b/mail/em-composer-utils.h
index 924dc79a16..3cca98334c 100644
--- a/mail/em-composer-utils.h
+++ b/mail/em-composer-utils.h
@@ -43,11 +43,6 @@ EMsgComposer * em_utils_edit_message (EShell *shell,
CamelMimeMessage *message,
const gchar *message_uid,
gboolean keep_signature);
-void em_utils_edit_messages (EMailReader *reader,
- CamelFolder *folder,
- GPtrArray *uids,
- gboolean replace,
- gboolean keep_signature);
EMsgComposer * em_utils_forward_message (EMailBackend *backend,
CamelMimeMessage *message,
EMailForwardStyle style,