diff options
author | Matthew Barnes <mbarnes@redhat.com> | 2011-05-13 07:00:09 +0800 |
---|---|---|
committer | Matthew Barnes <mbarnes@redhat.com> | 2011-05-13 07:00:09 +0800 |
commit | b663d51f1bd01979030b8dff57a2631cd672775e (patch) | |
tree | 40648b9162fb41c49ae5bf20f3bbc24b0b030bea /mail | |
parent | 8ff0684fa2e371a80cca60e8df167cc104c473c2 (diff) | |
download | gsoc2013-evolution-b663d51f1bd01979030b8dff57a2631cd672775e.tar.gz gsoc2013-evolution-b663d51f1bd01979030b8dff57a2631cd672775e.tar.zst gsoc2013-evolution-b663d51f1bd01979030b8dff57a2631cd672775e.zip |
Miscellaneous cleanups.
Diffstat (limited to 'mail')
-rw-r--r-- | mail/e-mail-reader-utils.c | 115 | ||||
-rw-r--r-- | mail/e-mail-reader.c | 25 | ||||
-rw-r--r-- | mail/em-utils.c | 9 | ||||
-rw-r--r-- | mail/message-list.c | 4 |
4 files changed, 81 insertions, 72 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); } diff --git a/mail/e-mail-reader.c b/mail/e-mail-reader.c index 673a5b206f..a281634a9f 100644 --- a/mail/e-mail-reader.c +++ b/mail/e-mail-reader.c @@ -153,15 +153,16 @@ action_mail_add_sender_cb (GtkAction *action, CamelFolder *folder; GPtrArray *uids; const gchar *address; + const gchar *message_uid; 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) - goto exit; + 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); - info = camel_folder_get_message_info (folder, uids->pdata[0]); + info = camel_folder_get_message_info (folder, message_uid); if (info == NULL) goto exit; @@ -1455,20 +1456,22 @@ action_mail_save_as_cb (GtkAction *action, CamelFolder *folder; GPtrArray *uids; GFile *file; + const gchar *message_uid; const gchar *title; gchar *suggestion = NULL; gchar *uri; folder = e_mail_reader_get_folder (reader); backend = e_mail_reader_get_backend (reader); - uids = e_mail_reader_get_selected_uids (reader); - g_return_if_fail (uids->len > 0); + 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); title = ngettext ("Save Message", "Save Messages", uids->len); /* Suggest as a filename the subject of the first message. */ - info = camel_folder_get_message_info (folder, uids->pdata[0]); + info = camel_folder_get_message_info (folder, message_uid); if (info != NULL) { const gchar *subject = camel_message_info_subject (info); @@ -1569,12 +1572,14 @@ action_mail_show_source_cb (GtkAction *action, CamelFolder *folder; GtkWidget *browser; GPtrArray *uids; + const gchar *message_uid; backend = e_mail_reader_get_backend (reader); folder = e_mail_reader_get_folder (reader); - uids = e_mail_reader_get_selected_uids (reader); - g_return_if_fail (uids->len > 0); + 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); browser = e_mail_browser_new (backend); reader = E_MAIL_READER (browser); @@ -1585,7 +1590,7 @@ action_mail_show_source_cb (GtkAction *action, EM_FORMAT (formatter), EM_FORMAT_MODE_SOURCE); e_mail_reader_set_folder (reader, folder); - e_mail_reader_set_message (reader, uids->pdata[0]); + e_mail_reader_set_message (reader, message_uid); gtk_widget_show (browser); em_utils_uids_free (uids); diff --git a/mail/em-utils.c b/mail/em-utils.c index 67ee603038..a9027e0fa2 100644 --- a/mail/em-utils.c +++ b/mail/em-utils.c @@ -444,8 +444,10 @@ em_utils_flag_for_followup (EMailReader *reader, /* special-case... */ if (uids->len == 1) { CamelMessageInfo *info; + const gchar *message_uid; - info = camel_folder_get_message_info (folder, uids->pdata[0]); + message_uid = g_ptr_array_index (uids, 0); + info = camel_folder_get_message_info (folder, message_uid); if (info) { tags = (CamelTag *) camel_message_info_user_tags (info); @@ -899,7 +901,10 @@ em_utils_selection_set_urilist (GtkSelectionData *data, /* Try to get the drop filename from the message or folder */ if (uids->len == 1) { - info = camel_folder_get_message_info (folder, uids->pdata[0]); + const gchar *message_uid; + + message_uid = g_ptr_array_index (uids, 0); + info = camel_folder_get_message_info (folder, message_uid); if (info) { file = g_strdup (camel_message_info_subject (info)); camel_folder_free_message_info (folder, info); diff --git a/mail/message-list.c b/mail/message-list.c index 592e8e1370..9adf2b4776 100644 --- a/mail/message-list.c +++ b/mail/message-list.c @@ -3937,14 +3937,14 @@ static void on_selection_changed_cmd (ETree *tree, MessageList *ml) { GPtrArray *uids; - gchar *newuid; + const gchar *newuid; ETreePath cursor; /* not sure if we could just ignore this for the cursor, i think sometimes you only get a selection changed when you should also get a cursor activated? */ uids = message_list_get_selected (ml); if (uids->len == 1) - newuid = uids->pdata[0]; + newuid = g_ptr_array_index (uids, 0); else if ((cursor = e_tree_get_cursor (tree))) newuid = (gchar *) camel_message_info_uid (e_tree_memory_node_get_data ((ETreeMemory *) tree, cursor)); else |