From dd958f0120603d87e2c8b3250b742d53230f2780 Mon Sep 17 00:00:00 2001 From: Milan Crha Date: Thu, 22 Nov 2012 16:18:51 +0100 Subject: Bug #202576 - A way to refresh IMAP folder list --- modules/mail/e-mail-shell-view-actions.c | 63 ++++++++++++++++++++++++++++++++ modules/mail/e-mail-shell-view-actions.h | 2 + modules/mail/e-mail-shell-view.c | 4 ++ 3 files changed, 69 insertions(+) (limited to 'modules') diff --git a/modules/mail/e-mail-shell-view-actions.c b/modules/mail/e-mail-shell-view-actions.c index 123352b181..1d39ad7cd2 100644 --- a/modules/mail/e-mail-shell-view-actions.c +++ b/modules/mail/e-mail-shell-view-actions.c @@ -124,6 +124,58 @@ action_mail_account_properties_cb (GtkAction *action, g_object_unref (source); } +static void +account_refresh_folder_info_received_cb (GObject *source, + GAsyncResult *result, + gpointer user_data) +{ + CamelStore *store; + CamelFolderInfo *info; + EActivity *activity; + GError *error = NULL; + + store = CAMEL_STORE (source); + activity = user_data; + info = camel_store_get_folder_info_finish (store, result, &error); + if (info) { + /* provider takes care of notifications of new/removed folders, + thus it's enough to free the returned list */ + camel_store_free_folder_info (store, info); + } + + if (error && !g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) + g_message ("%s: Failed: %s", G_STRFUNC, error->message); + + g_clear_error (&error); + + if (activity) + g_object_unref (activity); +} + +static void +action_mail_account_refresh_cb (GtkAction *action, + EMailShellView *mail_shell_view) +{ + EMailShellSidebar *mail_shell_sidebar; + EMFolderTree *folder_tree; + EMailReader *reader; + EActivity *activity; + CamelStore *store; + GCancellable *cancellable; + + mail_shell_sidebar = mail_shell_view->priv->mail_shell_sidebar; + folder_tree = e_mail_shell_sidebar_get_folder_tree (mail_shell_sidebar); + store = em_folder_tree_get_selected_store (folder_tree); + g_return_if_fail (store != NULL); + + reader = E_MAIL_READER (e_mail_shell_content_get_mail_view (mail_shell_view->priv->mail_shell_content)); + activity = e_mail_reader_new_activity (reader); + cancellable = e_activity_get_cancellable (activity); + + camel_store_get_folder_info (store, NULL, CAMEL_STORE_FOLDER_INFO_RECURSIVE, + G_PRIORITY_DEFAULT, cancellable, account_refresh_folder_info_received_cb, activity); +} + static void action_mail_create_search_folder_cb (GtkAction *action, EMailShellView *mail_shell_view) @@ -1242,6 +1294,13 @@ static GtkActionEntry mail_entries[] = { N_("Edit properties of this account"), G_CALLBACK (action_mail_account_properties_cb) }, + { "mail-account-refresh", + GTK_STOCK_REFRESH, + N_("_Refresh"), + NULL, + N_("Refresh list of folders of this account"), + G_CALLBACK (action_mail_account_refresh_cb) }, + { "mail-download", NULL, N_("_Download Messages for Offline Usage"), @@ -1505,6 +1564,10 @@ static EPopupActionEntry mail_popup_entries[] = { NULL, "mail-account-expunge" }, + { "mail-popup-account-refresh", + NULL, + "mail-account-refresh" }, + { "mail-popup-account-properties", NULL, "mail-account-properties" }, diff --git a/modules/mail/e-mail-shell-view-actions.h b/modules/mail/e-mail-shell-view-actions.h index d3197dde90..ff0829b662 100644 --- a/modules/mail/e-mail-shell-view-actions.h +++ b/modules/mail/e-mail-shell-view-actions.h @@ -31,6 +31,8 @@ E_SHELL_WINDOW_ACTION ((window), "mail-account-expunge") #define E_SHELL_WINDOW_ACTION_MAIL_ACCOUNT_PROPERTIES(window) \ E_SHELL_WINDOW_ACTION ((window), "mail-account-properties") +#define E_SHELL_WINDOW_ACTION_MAIL_ACCOUNT_REFRESH(window) \ + E_SHELL_WINDOW_ACTION ((window), "mail-account-refresh") #define E_SHELL_WINDOW_ACTION_MAIL_ADD_SENDER(window) \ E_SHELL_WINDOW_ACTION ((window), "mail-add-sender") #define E_SHELL_WINDOW_ACTION_MAIL_CARET_MODE(window) \ diff --git a/modules/mail/e-mail-shell-view.c b/modules/mail/e-mail-shell-view.c index 42cb277d11..419ad3edb3 100644 --- a/modules/mail/e-mail-shell-view.c +++ b/modules/mail/e-mail-shell-view.c @@ -944,6 +944,10 @@ mail_shell_view_update_actions (EShellView *shell_view) sensitive = folder_is_store && !store_is_builtin; gtk_action_set_sensitive (action, sensitive); + action = ACTION (MAIL_ACCOUNT_REFRESH); + sensitive = folder_is_store; + gtk_action_set_sensitive (action, sensitive); + action = ACTION (MAIL_FLUSH_OUTBOX); sensitive = folder_is_outbox; gtk_action_set_sensitive (action, sensitive); -- cgit v1.2.3