aboutsummaryrefslogtreecommitdiffstats
path: root/mail/e-mail-reader-utils.c
diff options
context:
space:
mode:
authorMatthew Barnes <mbarnes@redhat.com>2011-05-13 07:00:09 +0800
committerMatthew Barnes <mbarnes@redhat.com>2011-05-13 07:00:09 +0800
commitb663d51f1bd01979030b8dff57a2631cd672775e (patch)
tree40648b9162fb41c49ae5bf20f3bbc24b0b030bea /mail/e-mail-reader-utils.c
parent8ff0684fa2e371a80cca60e8df167cc104c473c2 (diff)
downloadgsoc2013-evolution-b663d51f1bd01979030b8dff57a2631cd672775e.tar.gz
gsoc2013-evolution-b663d51f1bd01979030b8dff57a2631cd672775e.tar.zst
gsoc2013-evolution-b663d51f1bd01979030b8dff57a2631cd672775e.zip
Miscellaneous cleanups.
Diffstat (limited to 'mail/e-mail-reader-utils.c')
-rw-r--r--mail/e-mail-reader-utils.c115
1 files changed, 57 insertions, 58 deletions
diff --git a/mail/e-mail-reader-utils.c b/mail/e-mail-reader-utils.c
index 194758489e..12a5991512 100644
--- a/mail/e-mail-reader-utils.c
+++ b/mail/e-mail-reader-utils.c
@@ -387,39 +387,36 @@ void
e_mail_reader_print (EMailReader *reader,
GtkPrintOperationAction action)
{
+ EActivity *activity;
+ AsyncContext *context;
+ GCancellable *cancellable;
CamelFolder *folder;
GPtrArray *uids;
+ const gchar *message_uid;
g_return_if_fail (E_IS_MAIL_READER (reader));
folder = e_mail_reader_get_folder (reader);
- g_return_if_fail (folder != NULL);
+ g_return_if_fail (CAMEL_IS_FOLDER (folder));
/* XXX Learn to handle len > 1. */
uids = e_mail_reader_get_selected_uids (reader);
- g_return_if_fail (uids != NULL);
+ g_return_if_fail (uids != NULL && uids->len == 1);
+ message_uid = g_ptr_array_index (uids, 0);
- if (uids->len == 1) {
- EActivity *activity;
- AsyncContext *context;
- GCancellable *cancellable;
- const gchar *message_uid;
-
- activity = e_mail_reader_new_activity (reader);
- cancellable = e_activity_get_cancellable (activity);
- message_uid = uids->pdata[0];
-
- context = g_slice_new0 (AsyncContext);
- context->activity = activity;
- context->reader = g_object_ref (reader);
- context->message_uid = g_strdup (message_uid);
- context->print_action = action;
-
- camel_folder_get_message (
- folder, message_uid, G_PRIORITY_DEFAULT,
- cancellable, (GAsyncReadyCallback)
- mail_reader_print_cb, context);
- }
+ 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);
+ context->message_uid = g_strdup (message_uid);
+ context->print_action = action;
+
+ camel_folder_get_message (
+ folder, message_uid, G_PRIORITY_DEFAULT,
+ cancellable, (GAsyncReadyCallback)
+ mail_reader_print_cb, context);
em_utils_uids_free (uids);
}
@@ -773,13 +770,18 @@ void
e_mail_reader_create_filter_from_selected (EMailReader *reader,
gint filter_type)
{
+ EActivity *activity;
+ AsyncContext *context;
+ GCancellable *cancellable;
CamelFolder *folder;
- const gchar *filter_source;
GPtrArray *uids;
+ const gchar *filter_source;
+ const gchar *message_uid;
g_return_if_fail (E_IS_MAIL_READER (reader));
folder = e_mail_reader_get_folder (reader);
+ g_return_if_fail (CAMEL_IS_FOLDER (folder));
if (em_utils_folder_is_sent (folder))
filter_source = E_FILTER_SOURCE_OUTGOING;
@@ -789,26 +791,22 @@ e_mail_reader_create_filter_from_selected (EMailReader *reader,
filter_source = E_FILTER_SOURCE_INCOMING;
uids = e_mail_reader_get_selected_uids (reader);
+ g_return_if_fail (uids != NULL && uids->len == 1);
+ message_uid = g_ptr_array_index (uids, 0);
- if (uids->len == 1) {
- EActivity *activity;
- AsyncContext *context;
- GCancellable *cancellable;
-
- activity = e_mail_reader_new_activity (reader);
- cancellable = e_activity_get_cancellable (activity);
+ 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);
- context->filter_source = filter_source;
- context->filter_type = filter_type;
+ context = g_slice_new0 (AsyncContext);
+ context->activity = activity;
+ context->reader = g_object_ref (reader);
+ context->filter_source = filter_source;
+ context->filter_type = filter_type;
- camel_folder_get_message (
- folder, uids->pdata[0], G_PRIORITY_DEFAULT,
- cancellable, (GAsyncReadyCallback)
- mail_reader_create_filter_cb, context);
- }
+ camel_folder_get_message (
+ folder, message_uid, G_PRIORITY_DEFAULT,
+ cancellable, (GAsyncReadyCallback)
+ mail_reader_create_filter_cb, context);
em_utils_uids_free (uids);
}
@@ -870,34 +868,35 @@ void
e_mail_reader_create_vfolder_from_selected (EMailReader *reader,
gint vfolder_type)
{
+ EActivity *activity;
+ AsyncContext *context;
+ GCancellable *cancellable;
CamelFolder *folder;
GPtrArray *uids;
+ const gchar *message_uid;
g_return_if_fail (E_IS_MAIL_READER (reader));
folder = e_mail_reader_get_folder (reader);
+ g_return_if_fail (CAMEL_IS_FOLDER (folder));
uids = e_mail_reader_get_selected_uids (reader);
+ g_return_if_fail (uids != NULL && uids->len == 1);
+ message_uid = g_ptr_array_index (uids, 0);
- if (uids->len == 1) {
- EActivity *activity;
- AsyncContext *context;
- GCancellable *cancellable;
-
- activity = e_mail_reader_new_activity (reader);
- cancellable = e_activity_get_cancellable (activity);
+ activity = e_mail_reader_new_activity (reader);
+ cancellable = e_activity_get_cancellable (activity);
- context = g_slice_new0 (AsyncContext);
- context->activity = activity;
- context->folder = g_object_ref (folder);
- context->reader = g_object_ref (reader);
- context->filter_type = vfolder_type;
+ context = g_slice_new0 (AsyncContext);
+ context->activity = activity;
+ context->folder = g_object_ref (folder);
+ context->reader = g_object_ref (reader);
+ context->filter_type = vfolder_type;
- camel_folder_get_message (
- folder, uids->pdata[0], G_PRIORITY_DEFAULT,
- cancellable, (GAsyncReadyCallback)
- mail_reader_create_vfolder_cb, context);
- }
+ camel_folder_get_message (
+ folder, message_uid, G_PRIORITY_DEFAULT,
+ cancellable, (GAsyncReadyCallback)
+ mail_reader_create_vfolder_cb, context);
em_utils_uids_free (uids);
}