aboutsummaryrefslogtreecommitdiffstats
path: root/modules
diff options
context:
space:
mode:
authorMatthew Barnes <mbarnes@redhat.com>2013-06-15 10:55:03 +0800
committerMatthew Barnes <mbarnes@redhat.com>2013-06-15 11:21:41 +0800
commit5b1742b202ca9505ccd818918b4afe82fc61b63b (patch)
tree6653da03ad3e8139e938e79ed3571c5fea4c818a /modules
parentcf669f10f22de13ab4ee9b323d274325af22b0b9 (diff)
downloadgsoc2013-evolution-5b1742b202ca9505ccd818918b4afe82fc61b63b.tar
gsoc2013-evolution-5b1742b202ca9505ccd818918b4afe82fc61b63b.tar.gz
gsoc2013-evolution-5b1742b202ca9505ccd818918b4afe82fc61b63b.tar.bz2
gsoc2013-evolution-5b1742b202ca9505ccd818918b4afe82fc61b63b.tar.lz
gsoc2013-evolution-5b1742b202ca9505ccd818918b4afe82fc61b63b.tar.xz
gsoc2013-evolution-5b1742b202ca9505ccd818918b4afe82fc61b63b.tar.zst
gsoc2013-evolution-5b1742b202ca9505ccd818918b4afe82fc61b63b.zip
Add e_mail_reader_ref_folder().
Replaces e_mail_reader_get_folder().
Diffstat (limited to 'modules')
-rw-r--r--modules/mail/e-mail-shell-view-actions.c29
-rw-r--r--modules/mail/e-mail-shell-view-private.c31
-rw-r--r--modules/mail/e-mail-shell-view.c23
-rw-r--r--modules/mdn/evolution-mdn.c35
4 files changed, 77 insertions, 41 deletions
diff --git a/modules/mail/e-mail-shell-view-actions.c b/modules/mail/e-mail-shell-view-actions.c
index c123696de4..4056a7b08f 100644
--- a/modules/mail/e-mail-shell-view-actions.c
+++ b/modules/mail/e-mail-shell-view-actions.c
@@ -210,9 +210,6 @@ action_mail_create_search_folder_cb (GtkAction *action,
if (search_text == NULL || *search_text == '\0')
search_text = "''";
- reader = E_MAIL_READER (mail_view);
- folder = e_mail_reader_get_folder (reader);
-
backend = E_MAIL_BACKEND (shell_backend);
session = e_mail_backend_get_session (backend);
@@ -224,12 +221,15 @@ action_mail_create_search_folder_cb (GtkAction *action,
e_filter_rule_set_name (search_rule, rule_name);
g_free (rule_name);
+ reader = E_MAIL_READER (mail_view);
+ folder = e_mail_reader_ref_folder (reader);
folder_uri = e_mail_folder_uri_from_folder (folder);
vfolder_rule = EM_VFOLDER_RULE (search_rule);
em_vfolder_rule_add_source (vfolder_rule, folder_uri);
vfolder_gui_add_rule (vfolder_rule);
+ g_clear_object (&folder);
g_free (folder_uri);
}
@@ -702,18 +702,22 @@ action_mail_folder_mark_all_as_read_cb (GtkAction *action,
reader = E_MAIL_READER (mail_view);
- folder = e_mail_reader_get_folder (reader);
+ folder = e_mail_reader_ref_folder (reader);
g_return_if_fail (folder != NULL);
- if (folder->summary &&
- camel_folder_summary_get_unread_count (folder->summary) == 0)
+ if (folder->summary != NULL &&
+ camel_folder_summary_get_unread_count (folder->summary) == 0) {
+ g_object_unref (folder);
return;
+ }
e_mail_shell_view_actions_mark_all_read (
mail_shell_view,
camel_folder_get_parent_store (folder),
camel_folder_get_full_name (folder),
FALSE);
+
+ g_object_unref (folder);
}
static void
@@ -985,7 +989,7 @@ action_mail_label_cb (GtkToggleAction *action,
mail_view = e_mail_shell_content_get_mail_view (mail_shell_content);
reader = E_MAIL_READER (mail_view);
- folder = e_mail_reader_get_folder (reader);
+ folder = e_mail_reader_ref_folder (reader);
uids = e_mail_reader_get_selected_uids (reader);
camel_folder_freeze (folder);
@@ -1002,6 +1006,7 @@ action_mail_label_cb (GtkToggleAction *action,
}
camel_folder_thaw (folder);
+ g_clear_object (&folder);
em_utils_uids_free (uids);
}
@@ -1067,13 +1072,14 @@ action_mail_label_new_cb (GtkAction *action,
mail_view = e_mail_shell_content_get_mail_view (mail_shell_content);
reader = E_MAIL_READER (mail_view);
- folder = e_mail_reader_get_folder (reader);
+ folder = e_mail_reader_ref_folder (reader);
uids = e_mail_reader_get_selected_uids (reader);
for (ii = 0; ii < uids->len; ii++)
camel_folder_set_message_user_flag (
folder, uids->pdata[ii], label_tag, TRUE);
+ g_clear_object (&folder);
em_utils_uids_free (uids);
g_free (label_tag);
@@ -1112,7 +1118,7 @@ action_mail_label_none_cb (GtkAction *action,
mail_view = e_mail_shell_content_get_mail_view (mail_shell_content);
reader = E_MAIL_READER (mail_view);
- folder = e_mail_reader_get_folder (reader);
+ folder = e_mail_reader_ref_folder (reader);
uids = e_mail_reader_get_selected_uids (reader);
valid = gtk_tree_model_get_iter_first (
@@ -1136,6 +1142,7 @@ action_mail_label_none_cb (GtkAction *action,
GTK_TREE_MODEL (label_store), &iter);
}
+ g_clear_object (&folder);
em_utils_uids_free (uids);
}
@@ -2237,7 +2244,7 @@ mail_shell_view_update_label_action (GtkToggleAction *action,
gboolean sensitive;
guint ii;
- folder = e_mail_reader_get_folder (reader);
+ folder = e_mail_reader_ref_folder (reader);
/* Figure out the proper label action state for the selected
* messages. If all the selected messages have the given label,
@@ -2277,6 +2284,8 @@ mail_shell_view_update_label_action (GtkToggleAction *action,
sensitive = !(exists && not_exists);
gtk_toggle_action_set_active (action, exists);
gtk_action_set_sensitive (GTK_ACTION (action), sensitive);
+
+ g_clear_object (&folder);
}
void
diff --git a/modules/mail/e-mail-shell-view-private.c b/modules/mail/e-mail-shell-view-private.c
index aa9addf4a5..16971771de 100644
--- a/modules/mail/e-mail-shell-view-private.c
+++ b/modules/mail/e-mail-shell-view-private.c
@@ -212,7 +212,7 @@ mail_shell_view_folder_tree_selection_done_cb (EMailShellView *mail_shell_view,
reader = E_MAIL_READER (mail_view);
message_list = e_mail_reader_get_message_list (reader);
- /* Don't use e_mail_reader_get_folder() here. The fact that the
+ /* Don't use e_mail_reader_ref_folder() here. The fact that the
* method gets the folder from the message list is supposed to be
* a hidden implementation detail, and we want to explicitly get
* the folder URI from the message list here. */
@@ -523,18 +523,18 @@ mail_shell_view_prepare_for_quit_cb (EMailShellView *mail_shell_view,
mail_view = e_mail_shell_content_get_mail_view (mail_shell_content);
reader = E_MAIL_READER (mail_view);
- folder = e_mail_reader_get_folder (reader);
+ folder = e_mail_reader_ref_folder (reader);
message_list = e_mail_reader_get_message_list (reader);
message_list_save_state (MESSAGE_LIST (message_list));
- if (folder == NULL)
- return;
-
- mail_sync_folder (
- folder, TRUE,
- mail_shell_view_prepare_for_quit_done_cb,
- g_object_ref (activity));
+ if (folder != NULL) {
+ mail_sync_folder (
+ folder, TRUE,
+ mail_shell_view_prepare_for_quit_done_cb,
+ g_object_ref (activity));
+ g_object_unref (folder);
+ }
}
static void
@@ -914,7 +914,7 @@ e_mail_shell_view_restore_state (EMailShellView *mail_shell_view)
searchbar = e_mail_shell_content_get_searchbar (mail_shell_content);
reader = E_MAIL_READER (mail_view);
- folder = e_mail_reader_get_folder (reader);
+ folder = e_mail_reader_ref_folder (reader);
if (folder == NULL) {
if (e_shell_searchbar_get_state_group (searchbar)) {
@@ -930,11 +930,11 @@ e_mail_shell_view_restore_state (EMailShellView *mail_shell_view)
vee_folder = mail_shell_view->priv->search_account_all;
if (vee_folder != NULL && folder == CAMEL_FOLDER (vee_folder))
- return;
+ goto exit;
vee_folder = mail_shell_view->priv->search_account_current;
if (vee_folder != NULL && folder == CAMEL_FOLDER (vee_folder))
- return;
+ goto exit;
folder_uri = e_mail_folder_uri_from_folder (folder);
new_state_group = g_strdup_printf ("Folder %s", folder_uri);
@@ -948,6 +948,9 @@ e_mail_shell_view_restore_state (EMailShellView *mail_shell_view)
}
g_free (new_state_group);
+
+exit:
+ g_clear_object (&folder);
}
void
@@ -989,7 +992,7 @@ e_mail_shell_view_update_sidebar (EMailShellView *mail_shell_view)
registry = e_shell_get_registry (shell);
reader = E_MAIL_READER (mail_view);
- folder = e_mail_reader_get_folder (reader);
+ folder = e_mail_reader_ref_folder (reader);
/* If no folder is selected, reset the sidebar banners
* to their default values and stop. */
@@ -1113,6 +1116,8 @@ e_mail_shell_view_update_sidebar (EMailShellView *mail_shell_view)
g_free (title);
g_string_free (buffer, TRUE);
+
+ g_clear_object (&folder);
}
typedef struct {
diff --git a/modules/mail/e-mail-shell-view.c b/modules/mail/e-mail-shell-view.c
index ca4d01e266..a5e5d62eaa 100644
--- a/modules/mail/e-mail-shell-view.c
+++ b/modules/mail/e-mail-shell-view.c
@@ -327,7 +327,7 @@ mail_shell_view_execute_search (EShellView *shell_view)
folder_tree = e_mail_shell_sidebar_get_folder_tree (mail_shell_sidebar);
reader = E_MAIL_READER (mail_view);
- folder = e_mail_reader_get_folder (reader);
+ folder = e_mail_reader_ref_folder (reader);
message_list = e_mail_reader_get_message_list (reader);
registry = e_mail_session_get_registry (session);
@@ -613,14 +613,17 @@ all_accounts:
camel_service_connect_sync (service, NULL, NULL);
search_folder = (CamelVeeFolder *) camel_vee_folder_new (
- CAMEL_STORE (service), _("All Account Search"), CAMEL_STORE_FOLDER_PRIVATE);
+ CAMEL_STORE (service),
+ _("All Account Search"),
+ CAMEL_STORE_FOLDER_PRIVATE);
priv->search_account_all = search_folder;
g_object_unref (service);
camel_vee_folder_set_expression (search_folder, query);
- all_accounts_setup:
+all_accounts_setup:
+
list = em_folder_tree_model_list_stores (EM_FOLDER_TREE_MODEL (
gtk_tree_view_get_model (GTK_TREE_VIEW (folder_tree))));
g_list_foreach (list, (GFunc) g_object_ref, NULL);
@@ -714,14 +717,16 @@ current_account:
camel_service_connect_sync (service, NULL, NULL);
search_folder = (CamelVeeFolder *) camel_vee_folder_new (
- CAMEL_STORE (service), _("Account Search"), CAMEL_STORE_FOLDER_PRIVATE);
+ CAMEL_STORE (service),
+ _("Account Search"),
+ CAMEL_STORE_FOLDER_PRIVATE);
priv->search_account_current = search_folder;
g_object_unref (service);
camel_vee_folder_set_expression (search_folder, query);
- current_accout_setup:
+current_accout_setup:
if (folder != NULL && folder != CAMEL_FOLDER (search_folder)) {
store = camel_folder_get_parent_store (folder);
@@ -760,6 +765,8 @@ execute:
g_slist_free (search_strings);
g_free (query);
+
+ g_clear_object (&folder);
}
static void
@@ -897,7 +904,7 @@ mail_shell_view_update_actions (EShellView *shell_view)
GtkTreeRowReference *reference;
CamelFolder *folder;
- folder = e_mail_reader_get_folder (reader);
+ folder = e_mail_reader_ref_folder (reader);
/* XXX If the user right-clicks on a folder other than what
* the message list is showing, disable folder rename.
@@ -906,13 +913,15 @@ mail_shell_view_update_actions (EShellView *shell_view)
* back to where it was to avoid cancelling the inline
* folder tree editing, it's just too hairy to try to
* get right. So we're punting. */
- if (CAMEL_IS_FOLDER (folder)) {
+ if (folder != NULL) {
gchar *folder_uri;
folder_uri = e_mail_folder_uri_from_folder (folder);
folder_tree_and_message_list_agree =
(g_strcmp0 (uri, folder_uri) == 0);
g_free (folder_uri);
+
+ g_object_unref (folder);
}
reference = em_folder_tree_model_lookup_uri (model, uri);
diff --git a/modules/mdn/evolution-mdn.c b/modules/mdn/evolution-mdn.c
index 441b063dc1..b037fc36c3 100644
--- a/modules/mdn/evolution-mdn.c
+++ b/modules/mdn/evolution-mdn.c
@@ -481,13 +481,13 @@ mdn_message_loaded_cb (EMailReader *reader,
session = e_mail_backend_get_session (backend);
registry = e_mail_session_get_registry (session);
- folder = e_mail_reader_get_folder (reader);
+ folder = e_mail_reader_ref_folder (reader);
mdn_remove_alert (mdn);
info = camel_folder_get_message_info (folder, message_uid);
if (info == NULL)
- return;
+ goto exit;
if (camel_message_info_user_flag (info, MDN_USER_FLAG)) {
alert = e_alert_new ("mdn:sender-notified", NULL);
@@ -500,11 +500,18 @@ mdn_message_loaded_cb (EMailReader *reader,
if (notify_to == NULL)
goto exit;
- /* do not show the notice in special folders */
- if (em_utils_folder_is_drafts (registry, folder) ||
- em_utils_folder_is_templates (registry, folder) ||
- em_utils_folder_is_sent (registry, folder) ||
- em_utils_folder_is_outbox (registry, folder))
+ /* Do not show the notice in special folders. */
+
+ if (em_utils_folder_is_drafts (registry, folder))
+ goto exit;
+
+ if (em_utils_folder_is_templates (registry, folder))
+ goto exit;
+
+ if (em_utils_folder_is_sent (registry, folder))
+ goto exit;
+
+ if (em_utils_folder_is_outbox (registry, folder))
goto exit;
/* This returns a new ESource reference. */
@@ -560,7 +567,10 @@ mdn_message_loaded_cb (EMailReader *reader,
g_object_unref (source);
exit:
- camel_folder_free_message_info (folder, info);
+ g_clear_object (&folder);
+
+ if (info != NULL)
+ camel_folder_free_message_info (folder, info);
g_free (notify_to);
}
@@ -584,11 +594,11 @@ mdn_message_seen_cb (EMailReader *reader,
session = e_mail_backend_get_session (backend);
registry = e_mail_session_get_registry (session);
- folder = e_mail_reader_get_folder (reader);
+ folder = e_mail_reader_ref_folder (reader);
info = camel_folder_get_message_info (folder, message_uid);
if (info == NULL)
- return;
+ goto exit;
if (camel_message_info_user_flag (info, MDN_USER_FLAG))
goto exit;
@@ -617,7 +627,10 @@ mdn_message_seen_cb (EMailReader *reader,
g_object_unref (source);
exit:
- camel_folder_free_message_info (folder, info);
+ g_clear_object (&folder);
+
+ if (info != NULL)
+ camel_folder_free_message_info (folder, info);
g_free (notify_to);
}