diff options
author | Matthew Barnes <mbarnes@redhat.com> | 2011-05-06 04:38:30 +0800 |
---|---|---|
committer | Rodrigo Moya <rodrigo@gnome-db.org> | 2011-06-30 00:42:09 +0800 |
commit | 7d3aa5b78a472e93ab8bdc01580cde7199588701 (patch) | |
tree | 84e1c1d6fe855759592e98b54a5d1fb04faf9a91 /mail | |
parent | 09b0db195641cb2a7d7b942c012be1b50420f0cd (diff) | |
download | gsoc2013-evolution-7d3aa5b78a472e93ab8bdc01580cde7199588701.tar.gz gsoc2013-evolution-7d3aa5b78a472e93ab8bdc01580cde7199588701.tar.zst gsoc2013-evolution-7d3aa5b78a472e93ab8bdc01580cde7199588701.zip |
Simplify e_mail_session_unsubscribe_folder_sync().
Diffstat (limited to 'mail')
-rw-r--r-- | mail/e-mail-session-utils.c | 49 |
1 files changed, 18 insertions, 31 deletions
diff --git a/mail/e-mail-session-utils.c b/mail/e-mail-session-utils.c index 4f13ff4ab9..b307fdc15c 100644 --- a/mail/e-mail-session-utils.c +++ b/mail/e-mail-session-utils.c @@ -23,6 +23,7 @@ #include <mail/mail-tools.h> #include <mail/e-mail-local.h> +#include <mail/e-mail-folder-utils.h> #include <e-util/e-account-utils.h> #include <filter/e-filter-rule.h> @@ -832,50 +833,36 @@ e_mail_session_unsubscribe_folder_sync (EMailSession *session, GCancellable *cancellable, GError **error) { - CamelURL *url; - CamelService *service; - CamelProvider *provider; + CamelStore *store = NULL; + gchar *folder_name = NULL; const gchar *message; - const gchar *path = NULL; gboolean success = FALSE; g_return_val_if_fail (E_IS_MAIL_SESSION (session), FALSE); g_return_val_if_fail (folder_uri != NULL, FALSE); - message = _("Unsubscribing from folder '%s'"); - camel_operation_push_message (cancellable, message, folder_uri); - - url = camel_url_new (folder_uri, error); - if (url == NULL) - goto exit; + success = e_mail_folder_uri_parse ( + CAMEL_SESSION (session), folder_uri, + &store, &folder_name, error); - service = camel_session_get_service_by_url ( - CAMEL_SESSION (session), url, CAMEL_PROVIDER_STORE); + if (!success) + return FALSE; - if (!CAMEL_IS_STORE (service)) - goto exit; + message = _("Unsubscribing from folder '%s'"); + camel_operation_push_message (cancellable, message, folder_name); /* FIXME This should take our GCancellable. */ - if (!camel_service_connect_sync (service, error)) - goto exit; + success = + camel_service_connect_sync ( + CAMEL_SERVICE (store), error) && + camel_store_unsubscribe_folder_sync ( + store, folder_name, cancellable, error); - provider = camel_service_get_provider (service); - - if (provider->url_flags & CAMEL_URL_FRAGMENT_IS_PATH) - path = url->fragment; - else if (url->path != NULL && *url->path != '\0') - path = url->path + 1; - - g_return_val_if_fail (path != NULL, FALSE); - - success = camel_store_unsubscribe_folder_sync ( - CAMEL_STORE (service), path, cancellable, error); - - camel_url_free (url); - -exit: camel_operation_pop_message (cancellable); + g_object_unref (store); + g_free (folder_name); + return success; } |