aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthew Barnes <mbarnes@redhat.com>2011-05-06 04:38:30 +0800
committerRodrigo Moya <rodrigo@gnome-db.org>2011-06-30 00:42:09 +0800
commit7d3aa5b78a472e93ab8bdc01580cde7199588701 (patch)
tree84e1c1d6fe855759592e98b54a5d1fb04faf9a91
parent09b0db195641cb2a7d7b942c012be1b50420f0cd (diff)
downloadgsoc2013-evolution-7d3aa5b78a472e93ab8bdc01580cde7199588701.tar
gsoc2013-evolution-7d3aa5b78a472e93ab8bdc01580cde7199588701.tar.gz
gsoc2013-evolution-7d3aa5b78a472e93ab8bdc01580cde7199588701.tar.bz2
gsoc2013-evolution-7d3aa5b78a472e93ab8bdc01580cde7199588701.tar.lz
gsoc2013-evolution-7d3aa5b78a472e93ab8bdc01580cde7199588701.tar.xz
gsoc2013-evolution-7d3aa5b78a472e93ab8bdc01580cde7199588701.tar.zst
gsoc2013-evolution-7d3aa5b78a472e93ab8bdc01580cde7199588701.zip
Simplify e_mail_session_unsubscribe_folder_sync().
-rw-r--r--mail/e-mail-session-utils.c49
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;
}