aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--mail/e-mail-reader-utils.c56
-rw-r--r--mail/e-mail-reader.c41
-rw-r--r--mail/e-mail-reader.h1
-rw-r--r--mail/em-composer-utils.c32
-rw-r--r--modules/mail/e-mail-shell-view-actions.c7
-rw-r--r--modules/mail/e-mail-shell-view-private.c19
6 files changed, 66 insertions, 90 deletions
diff --git a/mail/e-mail-reader-utils.c b/mail/e-mail-reader-utils.c
index 6544f1f9da..1da1a65084 100644
--- a/mail/e-mail-reader-utils.c
+++ b/mail/e-mail-reader-utils.c
@@ -453,9 +453,9 @@ mail_reader_remove_duplicates_cb (CamelFolder *folder,
void
e_mail_reader_remove_duplicates (EMailReader *reader)
{
+ EActivity *activity;
AsyncContext *context;
GCancellable *cancellable;
- EMailBackend *backend;
CamelFolder *folder;
GPtrArray *uids;
@@ -471,25 +471,19 @@ e_mail_reader_remove_duplicates (EMailReader *reader)
/* Find duplicate messages asynchronously. */
+ activity = e_mail_reader_new_activity (reader);
+ cancellable = e_activity_get_cancellable (activity);
+
context = g_slice_new0 (AsyncContext);
- context->activity = e_activity_new ();
+ context->activity = activity;
context->reader = g_object_ref (reader);
- cancellable = camel_operation_new ();
- e_activity_set_cancellable (context->activity, cancellable);
-
- backend = e_mail_reader_get_backend (reader);
- e_shell_backend_add_activity (
- E_SHELL_BACKEND (backend), context->activity);
-
e_mail_folder_find_duplicate_messages (
folder, uids, G_PRIORITY_DEFAULT,
cancellable, (GAsyncReadyCallback)
mail_reader_remove_duplicates_cb,
context);
- g_object_unref (cancellable);
-
g_ptr_array_unref (uids);
}
@@ -711,7 +705,6 @@ void
e_mail_reader_create_filter_from_selected (EMailReader *reader,
gint filter_type)
{
- EMailBackend *backend;
CamelFolder *folder;
const gchar *filter_source;
GPtrArray *uids;
@@ -719,7 +712,6 @@ e_mail_reader_create_filter_from_selected (EMailReader *reader,
g_return_if_fail (E_IS_MAIL_READER (reader));
folder = e_mail_reader_get_folder (reader);
- backend = e_mail_reader_get_backend (reader);
if (em_utils_folder_is_sent (folder))
filter_source = E_FILTER_SOURCE_OUTGOING;
@@ -731,31 +723,23 @@ e_mail_reader_create_filter_from_selected (EMailReader *reader,
uids = e_mail_reader_get_selected_uids (reader);
if (uids->len == 1) {
+ EActivity *activity;
AsyncContext *context;
- EAlertSink *alert_sink;
GCancellable *cancellable;
+ activity = e_mail_reader_new_activity (reader);
+ cancellable = e_activity_get_cancellable (activity);
+
context = g_slice_new0 (AsyncContext);
- context->activity = e_activity_new ();
+ context->activity = activity;
context->reader = g_object_ref (reader);
context->filter_source = filter_source;
context->filter_type = filter_type;
- alert_sink = e_mail_reader_get_alert_sink (reader);
- e_activity_set_alert_sink (context->activity, alert_sink);
-
- cancellable = camel_operation_new ();
- e_activity_set_cancellable (context->activity, cancellable);
-
- e_shell_backend_add_activity (
- E_SHELL_BACKEND (backend), context->activity);
-
camel_folder_get_message (
folder, uids->pdata[0], G_PRIORITY_DEFAULT,
cancellable, (GAsyncReadyCallback)
mail_reader_create_filter_cb, context);
-
- g_object_unref (cancellable);
}
em_utils_uids_free (uids);
@@ -818,43 +802,33 @@ void
e_mail_reader_create_vfolder_from_selected (EMailReader *reader,
gint vfolder_type)
{
- EMailBackend *backend;
CamelFolder *folder;
GPtrArray *uids;
g_return_if_fail (E_IS_MAIL_READER (reader));
folder = e_mail_reader_get_folder (reader);
- backend = e_mail_reader_get_backend (reader);
uids = e_mail_reader_get_selected_uids (reader);
if (uids->len == 1) {
+ EActivity *activity;
AsyncContext *context;
- EAlertSink *alert_sink;
GCancellable *cancellable;
+ activity = e_mail_reader_new_activity (reader);
+ cancellable = e_activity_get_cancellable (activity);
+
context = g_slice_new0 (AsyncContext);
- context->activity = e_activity_new ();
+ context->activity = activity;
context->folder = g_object_ref (folder);
context->reader = g_object_ref (reader);
context->filter_type = vfolder_type;
- alert_sink = e_mail_reader_get_alert_sink (reader);
- e_activity_set_alert_sink (context->activity, alert_sink);
-
- cancellable = camel_operation_new ();
- e_activity_set_cancellable (context->activity, cancellable);
-
- e_shell_backend_add_activity (
- E_SHELL_BACKEND (backend), context->activity);
-
camel_folder_get_message (
folder, uids->pdata[0], G_PRIORITY_DEFAULT,
cancellable, (GAsyncReadyCallback)
mail_reader_create_vfolder_cb, context);
-
- g_object_unref (cancellable);
}
em_utils_uids_free (uids);
diff --git a/mail/e-mail-reader.c b/mail/e-mail-reader.c
index 8cca498aec..85d623ddde 100644
--- a/mail/e-mail-reader.c
+++ b/mail/e-mail-reader.c
@@ -2556,7 +2556,6 @@ mail_reader_message_selected_timeout_cb (EMailReader *reader)
GtkWidget *message_list;
EWebView *web_view;
CamelFolder *folder;
- EMailBackend *backend;
const gchar *cursor_uid;
const gchar *format_uid;
@@ -2564,7 +2563,6 @@ mail_reader_message_selected_timeout_cb (EMailReader *reader)
folder = e_mail_reader_get_folder (reader);
- backend = e_mail_reader_get_backend (reader);
formatter = e_mail_reader_get_formatter (reader);
message_list = e_mail_reader_get_message_list (reader);
@@ -2601,14 +2599,12 @@ mail_reader_message_selected_timeout_cb (EMailReader *reader)
#endif
g_free (string);
- activity = e_activity_new ();
-
- cancellable = camel_operation_new ();
- e_activity_set_cancellable (activity, cancellable);
+ 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);
- closure->activity = g_object_ref (activity);
closure->message_uid = g_strdup (cursor_uid);
camel_folder_get_message (
@@ -2616,14 +2612,9 @@ mail_reader_message_selected_timeout_cb (EMailReader *reader)
cancellable, (GAsyncReadyCallback)
mail_reader_message_loaded_cb, closure);
- e_shell_backend_add_activity (
- E_SHELL_BACKEND (backend), activity);
-
if (priv->retrieving_message != NULL)
g_object_unref (priv->retrieving_message);
- priv->retrieving_message = cancellable;
-
- g_object_unref (activity);
+ priv->retrieving_message = g_object_ref (cancellable);
}
} else {
/* FIXME Need to pass a GCancellable. */
@@ -3742,7 +3733,31 @@ e_mail_reader_check_state (EMailReader *reader)
em_utils_uids_free (uids);
return state;
+}
+
+EActivity *
+e_mail_reader_new_activity (EMailReader *reader)
+{
+ EActivity *activity;
+ EMailBackend *backend;
+ EAlertSink *alert_sink;
+ GCancellable *cancellable;
+
+ g_return_val_if_fail (E_IS_MAIL_READER (reader), NULL);
+
+ activity = e_activity_new ();
+
+ alert_sink = e_mail_reader_get_alert_sink (reader);
+ e_activity_set_alert_sink (activity, alert_sink);
+
+ cancellable = camel_operation_new ();
+ e_activity_set_cancellable (activity, cancellable);
+ g_object_unref (cancellable);
+
+ backend = e_mail_reader_get_backend (reader);
+ e_shell_backend_add_activity (E_SHELL_BACKEND (backend), activity);
+ return activity;
}
void
diff --git a/mail/e-mail-reader.h b/mail/e-mail-reader.h
index 9c5da8fcd8..0e874603c4 100644
--- a/mail/e-mail-reader.h
+++ b/mail/e-mail-reader.h
@@ -115,6 +115,7 @@ void e_mail_reader_init (EMailReader *reader,
gboolean connect_signals);
void e_mail_reader_changed (EMailReader *reader);
guint32 e_mail_reader_check_state (EMailReader *reader);
+EActivity * e_mail_reader_new_activity (EMailReader *reader);
void e_mail_reader_update_actions (EMailReader *reader,
guint32 state);
GtkAction * e_mail_reader_get_action (EMailReader *reader,
diff --git a/mail/em-composer-utils.c b/mail/em-composer-utils.c
index c91870ff5b..98e24ac8a2 100644
--- a/mail/em-composer-utils.c
+++ b/mail/em-composer-utils.c
@@ -1314,33 +1314,27 @@ em_utils_edit_messages (EMailReader *reader,
GPtrArray *uids,
gboolean replace)
{
+ EActivity *activity;
AsyncContext *context;
GCancellable *cancellable;
- EMailBackend *backend;
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);
+
context = g_slice_new0 (AsyncContext);
- context->activity = e_activity_new ();
+ context->activity = activity;
context->reader = g_object_ref (reader);
context->ptr_array = g_ptr_array_ref (uids);
context->replace = replace;
- cancellable = camel_operation_new ();
- e_activity_set_cancellable (context->activity, cancellable);
-
- backend = e_mail_reader_get_backend (reader);
- e_shell_backend_add_activity (
- E_SHELL_BACKEND (backend), context->activity);
-
e_mail_folder_get_multiple_messages (
folder, uids, G_PRIORITY_DEFAULT,
cancellable, (GAsyncReadyCallback)
edit_messages_cb, context);
-
- g_object_unref (cancellable);
}
static void
@@ -1681,27 +1675,23 @@ em_utils_forward_messages (EMailReader *reader,
GPtrArray *uids,
EMailForwardStyle style)
{
+ EActivity *activity;
AsyncContext *context;
GCancellable *cancellable;
- EMailBackend *backend;
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);
+
context = g_slice_new0 (AsyncContext);
- context->activity = e_activity_new ();
+ context->activity = activity;
context->reader = g_object_ref (reader);
context->ptr_array = g_ptr_array_ref (uids);
context->style = style;
- cancellable = camel_operation_new ();
- e_activity_set_cancellable (context->activity, cancellable);
-
- backend = e_mail_reader_get_backend (reader);
- e_shell_backend_add_activity (
- E_SHELL_BACKEND (backend), context->activity);
-
switch (style) {
case E_MAIL_FORWARD_STYLE_ATTACHED:
e_mail_folder_build_attachment (
@@ -1721,8 +1711,6 @@ em_utils_forward_messages (EMailReader *reader,
default:
g_warn_if_reached ();
}
-
- g_object_unref (cancellable);
}
/* Redirecting messages... */
diff --git a/modules/mail/e-mail-shell-view-actions.c b/modules/mail/e-mail-shell-view-actions.c
index d44ac6f5ad..a0a6ec2dfe 100644
--- a/modules/mail/e-mail-shell-view-actions.c
+++ b/modules/mail/e-mail-shell-view-actions.c
@@ -522,10 +522,13 @@ action_mail_folder_unsubscribe_cb (GtkAction *action,
session = e_mail_backend_get_session (backend);
activity = e_activity_new ();
- cancellable = camel_operation_new ();
+
alert_sink = E_ALERT_SINK (shell_content);
e_activity_set_alert_sink (activity, alert_sink);
+
+ cancellable = camel_operation_new ();
e_activity_set_cancellable (activity, cancellable);
+
e_shell_backend_add_activity (shell_backend, activity);
folder_uri = em_folder_tree_get_selected_uri (folder_tree);
@@ -536,6 +539,8 @@ action_mail_folder_unsubscribe_cb (GtkAction *action,
activity);
g_free (folder_uri);
+
+ g_object_unref (cancellable);
}
static void
diff --git a/modules/mail/e-mail-shell-view-private.c b/modules/mail/e-mail-shell-view-private.c
index d99b643d38..b3cfb7e796 100644
--- a/modules/mail/e-mail-shell-view-private.c
+++ b/modules/mail/e-mail-shell-view-private.c
@@ -94,16 +94,14 @@ mail_shell_view_folder_tree_selected_cb (EMailShellView *mail_shell_view,
EMFolderTree *folder_tree)
{
EMailShellContent *mail_shell_content;
- EShellBackend *shell_backend;
EShellView *shell_view;
EMailReader *reader;
EMailView *mail_view;
GCancellable *cancellable;
- EAlertSink *alert_sink;
AsyncContext *context;
+ EActivity *activity;
shell_view = E_SHELL_VIEW (mail_shell_view);
- shell_backend = e_shell_view_get_shell_backend (shell_view);
mail_shell_content = mail_shell_view->priv->mail_shell_content;
mail_view = e_mail_shell_content_get_mail_view (mail_shell_content);
@@ -127,20 +125,15 @@ mail_shell_view_folder_tree_selected_cb (EMailShellView *mail_shell_view,
/* Open the selected folder asynchronously. */
+ activity = e_mail_reader_new_activity (reader);
+ cancellable = e_activity_get_cancellable (activity);
+ mail_shell_view->priv->opening_folder = g_object_ref (cancellable);
+
context = g_slice_new0 (AsyncContext);
- context->activity = e_activity_new ();
+ context->activity = activity;
context->reader = g_object_ref (reader);
context->shell_view = g_object_ref (shell_view);
- alert_sink = E_ALERT_SINK (mail_shell_content);
- e_activity_set_alert_sink (context->activity, alert_sink);
-
- cancellable = camel_operation_new ();
- e_activity_set_cancellable (context->activity, cancellable);
- mail_shell_view->priv->opening_folder = cancellable;
-
- e_shell_backend_add_activity (shell_backend, context->activity);
-
camel_store_get_folder (
store, folder_name, 0, G_PRIORITY_DEFAULT, cancellable,
(GAsyncReadyCallback) mail_shell_view_got_folder_cb, context);