aboutsummaryrefslogtreecommitdiffstats
path: root/mail/mail-tools.c
diff options
context:
space:
mode:
authorMatthew Barnes <mbarnes@redhat.com>2010-10-07 11:38:52 +0800
committerMatthew Barnes <mbarnes@redhat.com>2010-10-13 01:58:59 +0800
commita06e4484b8df804124b5bcf88d94dec5acfba270 (patch)
tree4fa42793d7dc461f2b3767296d76592182c48222 /mail/mail-tools.c
parent5e0758bb6934a7859b1d8a247c8fb21c156772cf (diff)
downloadgsoc2013-evolution-a06e4484b8df804124b5bcf88d94dec5acfba270.tar
gsoc2013-evolution-a06e4484b8df804124b5bcf88d94dec5acfba270.tar.gz
gsoc2013-evolution-a06e4484b8df804124b5bcf88d94dec5acfba270.tar.bz2
gsoc2013-evolution-a06e4484b8df804124b5bcf88d94dec5acfba270.tar.lz
gsoc2013-evolution-a06e4484b8df804124b5bcf88d94dec5acfba270.tar.xz
gsoc2013-evolution-a06e4484b8df804124b5bcf88d94dec5acfba270.tar.zst
gsoc2013-evolution-a06e4484b8df804124b5bcf88d94dec5acfba270.zip
Give MailSession a permanent home.
Global variables in shared libraries are a bad idea. EMailBackend now owns the MailSession instance, which is actually now EMailSession. Move the blocking utility functions in mail-tools.c to e-mail-session.c and add asynchronous variants. Same approach as Camel. Replace EMailReader.get_shell_backend() with EMailReader.get_backend(), which returns an EMailBackend. Easier access to the EMailSession.
Diffstat (limited to 'mail/mail-tools.c')
-rw-r--r--mail/mail-tools.c141
1 files changed, 1 insertions, 140 deletions
diff --git a/mail/mail-tools.c b/mail/mail-tools.c
index 3a77da2742..c005c27f71 100644
--- a/mail/mail-tools.c
+++ b/mail/mail-tools.c
@@ -36,76 +36,13 @@
#include <glib/gi18n.h>
+#include "e-mail-session.h"
#include "em-utils.h"
#include "mail-folder-cache.h"
-#include "mail-session.h"
#include "mail-tools.h"
/* **************************************** */
-CamelFolder *
-mail_tool_get_inbox (const gchar *url,
- GCancellable *cancellable,
- GError **error)
-{
- CamelStore *store;
- CamelFolder *folder;
-
- store = camel_session_get_store (session, url, error);
- if (!store)
- return NULL;
-
- folder = camel_store_get_inbox_folder_sync (store, cancellable, error);
- g_object_unref (store);
-
- return folder;
-}
-
-static gboolean
-is_local_provider (CamelStore *store)
-{
- CamelProvider *provider;
-
- g_return_val_if_fail (store != NULL, FALSE);
-
- provider = camel_service_get_provider (CAMEL_SERVICE (store));
-
- g_return_val_if_fail (provider != NULL, FALSE);
-
- return (provider->flags & CAMEL_PROVIDER_IS_LOCAL) != 0;
-}
-
-CamelFolder *
-mail_tool_get_trash (const gchar *url,
- gint connect,
- GCancellable *cancellable,
- GError **error)
-{
- CamelStore *store;
- CamelFolder *trash;
-
- if (connect)
- store = camel_session_get_store (session, url, error);
- else
- store = (CamelStore *) camel_session_get_service (
- session, url, CAMEL_PROVIDER_STORE, error);
-
- if (!store)
- return NULL;
-
- if (connect ||
- (CAMEL_SERVICE (store)->status == CAMEL_SERVICE_CONNECTED ||
- is_local_provider (store)))
- trash = camel_store_get_trash_folder_sync (
- store, cancellable, error);
- else
- trash = NULL;
-
- g_object_unref (store);
-
- return trash;
-}
-
#ifndef G_OS_WIN32
static gchar *
@@ -296,82 +233,6 @@ mail_tool_make_message_attachment (CamelMimeMessage *message)
return part;
}
-CamelFolder *
-mail_tool_uri_to_folder (const gchar *uri,
- guint32 flags,
- GCancellable *cancellable,
- GError **error)
-{
- CamelURL *url;
- CamelStore *store = NULL;
- CamelFolder *folder = NULL;
- gint offset = 0;
- gchar *curi = NULL;
-
- g_return_val_if_fail (uri != NULL, NULL);
-
- /* TODO: vtrash and vjunk are no longer used for these uri's */
- if (!strncmp (uri, "vtrash:", 7))
- offset = 7;
- else if (!strncmp (uri, "vjunk:", 6))
- offset = 6;
- else if (!strncmp(uri, "email:", 6)) {
- /* FIXME?: the filter:get_folder callback should do this itself? */
- curi = em_uri_to_camel (uri);
- if (uri == NULL) {
- g_set_error (
- error,
- CAMEL_ERROR, CAMEL_ERROR_GENERIC,
- _("Invalid folder: '%s'"), uri);
- return NULL;
- }
- uri = curi;
- }
-
- url = camel_url_new (uri + offset, error);
- if (!url) {
- g_free (curi);
- return NULL;
- }
-
- store = (CamelStore *) camel_session_get_service (
- session, uri + offset, CAMEL_PROVIDER_STORE, error);
- if (store) {
- const gchar *name;
-
- /* if we have a fragment, then the path is actually used by the store,
- so the fragment is the path to the folder instead */
- if (url->fragment) {
- name = url->fragment;
- } else {
- if (url->path && *url->path)
- name = url->path + 1;
- else
- name = "";
- }
-
- if (offset) {
- if (offset == 7)
- folder = camel_store_get_trash_folder_sync (
- store, cancellable, error);
- else if (offset == 6)
- folder = camel_store_get_junk_folder_sync (
- store, cancellable, error);
- } else
- folder = camel_store_get_folder_sync (
- store, name, flags, cancellable, error);
- g_object_unref (store);
- }
-
- if (folder)
- mail_folder_cache_note_folder (mail_folder_cache_get_default (), folder);
-
- camel_url_free (url);
- g_free (curi);
-
- return folder;
-}
-
/* FIXME: This should be a property on CamelFolder */
gchar *
mail_tools_folder_to_url (CamelFolder *folder)