aboutsummaryrefslogtreecommitdiffstats
path: root/libemail-engine
diff options
context:
space:
mode:
authorMatthew Barnes <mbarnes@redhat.com>2013-11-30 22:37:08 +0800
committerMatthew Barnes <mbarnes@redhat.com>2013-11-30 22:45:57 +0800
commitf02bb4526c6b80f728241de157d9c19a8b19187a (patch)
treeb184c04f0cfc58ae32e761b148d3b8973742da7c /libemail-engine
parentf911f1754abaf97b9d08f751b97cfb2905d47616 (diff)
downloadgsoc2013-evolution-f02bb4526c6b80f728241de157d9c19a8b19187a.tar
gsoc2013-evolution-f02bb4526c6b80f728241de157d9c19a8b19187a.tar.gz
gsoc2013-evolution-f02bb4526c6b80f728241de157d9c19a8b19187a.tar.bz2
gsoc2013-evolution-f02bb4526c6b80f728241de157d9c19a8b19187a.tar.lz
gsoc2013-evolution-f02bb4526c6b80f728241de157d9c19a8b19187a.tar.xz
gsoc2013-evolution-f02bb4526c6b80f728241de157d9c19a8b19187a.tar.zst
gsoc2013-evolution-f02bb4526c6b80f728241de157d9c19a8b19187a.zip
em_utils_is_local_delivery_mbox_file(): Take a CamelService.
More convenient than constructing a CamelURL just for this function. Also, document it.
Diffstat (limited to 'libemail-engine')
-rw-r--r--libemail-engine/e-mail-utils.c52
-rw-r--r--libemail-engine/e-mail-utils.h2
-rw-r--r--libemail-engine/mail-ops.c13
3 files changed, 52 insertions, 15 deletions
diff --git a/libemail-engine/e-mail-utils.c b/libemail-engine/e-mail-utils.c
index 9610da7419..0e76b2b329 100644
--- a/libemail-engine/e-mail-utils.c
+++ b/libemail-engine/e-mail-utils.c
@@ -670,16 +670,54 @@ em_utils_ref_mail_identity_for_store (ESourceRegistry *registry,
return source;
}
-/* Returns TRUE if CamelURL points to a local mbox file. */
+/**
+ * em_utils_is_local_delivery_mbox_file:
+ * @service: a #CamelService
+ *
+ * Returns whether @service refers to a local mbox file where new mail
+ * is delivered by some external software.
+ *
+ * Specifically that means @service's #CamelProvider protocol is "mbox"
+ * and its #CamelLocalSettings:path setting points to an existing file,
+ * not a directory.
+ *
+ * Returns: whether @service is for local mbox delivery
+ **/
gboolean
-em_utils_is_local_delivery_mbox_file (CamelURL *url)
+em_utils_is_local_delivery_mbox_file (CamelService *service)
{
- g_return_val_if_fail (url != NULL, FALSE);
+ CamelProvider *provider;
+ CamelSettings *settings;
+ gchar *mbox_path = NULL;
+ gboolean is_local_delivery_mbox_file;
+
+ g_return_val_if_fail (CAMEL_IS_SERVICE (service), FALSE);
+
+ provider = camel_service_get_provider (service);
+ g_return_val_if_fail (provider != NULL, FALSE);
+ g_return_val_if_fail (provider->protocol != NULL, FALSE);
+
+ if (!g_str_equal (provider->protocol, "mbox"))
+ return FALSE;
+
+ settings = camel_service_ref_settings (service);
+
+ if (CAMEL_IS_LOCAL_SETTINGS (settings)) {
+ CamelLocalSettings *local_settings;
+
+ local_settings = CAMEL_LOCAL_SETTINGS (settings);
+ mbox_path = camel_local_settings_dup_path (local_settings);
+ }
+
+ is_local_delivery_mbox_file =
+ (mbox_path != NULL) &&
+ g_file_test (mbox_path, G_FILE_TEST_EXISTS) &&
+ !g_file_test (mbox_path, G_FILE_TEST_IS_DIR);
+
+ g_free (mbox_path);
+ g_clear_object (&settings);
- return g_str_equal (url->protocol, "mbox") &&
- (url->path != NULL) &&
- g_file_test (url->path, G_FILE_TEST_EXISTS) &&
- !g_file_test (url->path, G_FILE_TEST_IS_DIR);
+ return is_local_delivery_mbox_file;
}
/* Expands groups to individual addresses, or removes empty groups completely.
diff --git a/libemail-engine/e-mail-utils.h b/libemail-engine/e-mail-utils.h
index f055f3d6aa..1643a3f66f 100644
--- a/libemail-engine/e-mail-utils.h
+++ b/libemail-engine/e-mail-utils.h
@@ -76,7 +76,7 @@ ESource * em_utils_ref_mail_identity_for_store
(ESourceRegistry *registry,
CamelStore *store);
gboolean em_utils_is_local_delivery_mbox_file
- (CamelURL *url);
+ (CamelService *service);
void em_utils_expand_groups (CamelInternetAddress *addresses);
diff --git a/libemail-engine/mail-ops.c b/libemail-engine/mail-ops.c
index df90596e53..406d3d6462 100644
--- a/libemail-engine/mail-ops.c
+++ b/libemail-engine/mail-ops.c
@@ -245,7 +245,6 @@ fetch_mail_exec (struct _fetch_mail_msg *m,
CamelSettings *settings;
CamelStore *parent_store;
CamelUIDCache *cache = NULL;
- CamelURL *url;
gboolean keep = TRUE;
gboolean delete_fetched;
gboolean is_local_delivery = FALSE;
@@ -281,15 +280,16 @@ fetch_mail_exec (struct _fetch_mail_msg *m,
/* Just for readability. */
delete_fetched = !keep;
- url = camel_service_new_camel_url (service);
- is_local_delivery = em_utils_is_local_delivery_mbox_file (url);
-
- if (is_local_delivery) {
+ if (em_utils_is_local_delivery_mbox_file (service)) {
+ CamelURL *url;
gchar *path;
gchar *url_string;
path = mail_tool_do_movemail (m->store, error);
+
+ url = camel_service_new_camel_url (service);
url_string = camel_url_to_string (url, CAMEL_URL_HIDE_ALL);
+ camel_url_free (url);
if (path && (!error || !*error)) {
camel_folder_freeze (fm->destination);
@@ -306,6 +306,7 @@ fetch_mail_exec (struct _fetch_mail_msg *m,
g_free (path);
g_free (url_string);
+
} else {
uid = camel_service_get_uid (service);
if (m->provider_lock)
@@ -316,8 +317,6 @@ fetch_mail_exec (struct _fetch_mail_msg *m,
fm->session, uid, cancellable, error);
}
- camel_url_free (url);
-
if (folder == NULL)
goto exit;