From b61d2c08d7f16171e3c6a2ddb4759a2a2803aaf3 Mon Sep 17 00:00:00 2001 From: Matthew Barnes Date: Mon, 16 May 2011 22:43:46 -0400 Subject: Remove mail_remove_attachments(). Use e_mail_folder_remove_attachments() instead. --- mail/e-mail-reader-utils.c | 63 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 63 insertions(+) (limited to 'mail/e-mail-reader-utils.c') diff --git a/mail/e-mail-reader-utils.c b/mail/e-mail-reader-utils.c index 6df8ebe71d..281acbbe52 100644 --- a/mail/e-mail-reader-utils.c +++ b/mail/e-mail-reader-utils.c @@ -421,6 +421,69 @@ e_mail_reader_print (EMailReader *reader, em_utils_uids_free (uids); } +static void +mail_reader_remove_attachments_cb (CamelFolder *folder, + GAsyncResult *result, + AsyncContext *context) +{ + EAlertSink *alert_sink; + GError *error = NULL; + + alert_sink = e_mail_reader_get_alert_sink (context->reader); + + e_mail_folder_remove_attachments_finish (folder, result, &error); + + if (e_activity_handle_cancellation (context->activity, error)) { + g_error_free (error); + + } else if (error != NULL) { + e_alert_submit ( + alert_sink, + "mail:remove-attachments", + error->message, NULL); + g_error_free (error); + } + + async_context_free (context); +} + +void +e_mail_reader_remove_attachments (EMailReader *reader) +{ + EActivity *activity; + AsyncContext *context; + GCancellable *cancellable; + CamelFolder *folder; + GPtrArray *uids; + + g_return_if_fail (E_IS_MAIL_READER (reader)); + + folder = e_mail_reader_get_folder (reader); + uids = e_mail_reader_get_selected_uids (reader); + g_return_if_fail (uids != NULL); + + /* XXX Either e_mail_reader_get_selected_uids() + * or MessageList should do this itself. */ + g_ptr_array_set_free_func (uids, (GDestroyNotify) g_free); + + /* Remove attachments asynchronously. */ + + activity = e_mail_reader_new_activity (reader); + cancellable = e_activity_get_cancellable (activity); + + context = g_slice_new0 (AsyncContext); + context->activity = activity; + context->reader = g_object_ref (reader); + + e_mail_folder_remove_attachments ( + folder, uids, G_PRIORITY_DEFAULT, + cancellable, (GAsyncReadyCallback) + mail_reader_remove_attachments_cb, + context); + + g_ptr_array_unref (uids); +} + static void mail_reader_remove_duplicates_cb (CamelFolder *folder, GAsyncResult *result, -- cgit