[evolution-data-server] Add CamelImapSettings.
- From: Matthew Barnes <mbarnes src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evolution-data-server] Add CamelImapSettings.
- Date: Mon, 15 Aug 2011 15:56:12 +0000 (UTC)
commit 19cb716be9a886cef95a9ee4622c0ab9900ef319
Author: Matthew Barnes <mbarnes redhat com>
Date: Mon Jun 13 10:08:58 2011 -0400
Add CamelImapSettings.
CamelImapSettings replaces the various URL parameters used in
CamelImapStore with equivalent GObject properties.
Adapt the imap provider to use CamelImapSettings.
camel/camel-enums.h | 19 +
camel/providers/imap/Makefile.am | 2 +
camel/providers/imap/camel-imap-folder.c | 138 ++-
camel/providers/imap/camel-imap-provider.c | 30 +-
camel/providers/imap/camel-imap-settings.c | 1192 +++++++++++++++++++++++
camel/providers/imap/camel-imap-settings.h | 140 +++
camel/providers/imap/camel-imap-store-summary.c | 4 +-
camel/providers/imap/camel-imap-store.c | 472 +++++-----
camel/providers/imap/camel-imap-store.h | 22 +-
9 files changed, 1705 insertions(+), 314 deletions(-)
---
diff --git a/camel/camel-enums.h b/camel/camel-enums.h
index 06e0945..7b48241 100644
--- a/camel/camel-enums.h
+++ b/camel/camel-enums.h
@@ -125,6 +125,25 @@ typedef enum { /*< flags >*/
CAMEL_STORE_INFO_FOLDER_LAST = 1 << 24 /*< skip >*/
} CamelStoreInfoFlags;
+/**
+ * CamelFetchHeadersType:
+ * @CAMEL_FETCH_HEADERS_BASIC:
+ * Fetch only basic headers (Date, From, To, Subject, etc.).
+ * @CAMEL_FETCH_HEADERS_BASIC_AND_MAILING_LIST:
+ * Fetch all basic headers and mailing list headers.
+ * @CAMEL_FETCH_HEADERS_ALL:
+ * Fetch all available message headers.
+ *
+ * Describes what headers to fetch when downloading message summaries.
+ *
+ * Since: 3.2
+ **/
+typedef enum {
+ CAMEL_FETCH_HEADERS_BASIC,
+ CAMEL_FETCH_HEADERS_BASIC_AND_MAILING_LIST,
+ CAMEL_FETCH_HEADERS_ALL
+} CamelFetchHeadersType;
+
typedef enum {
CAMEL_JUNK_STATUS_INCONCLUSIVE,
CAMEL_JUNK_STATUS_MESSAGE_IS_JUNK,
diff --git a/camel/providers/imap/Makefile.am b/camel/providers/imap/Makefile.am
index bef9a83..a47084e 100644
--- a/camel/providers/imap/Makefile.am
+++ b/camel/providers/imap/Makefile.am
@@ -18,6 +18,7 @@ libcamelimap_la_SOURCES = \
camel-imap-message-cache.c \
camel-imap-provider.c \
camel-imap-search.c \
+ camel-imap-settings.c \
camel-imap-store.c \
camel-imap-store-summary.c \
camel-imap-summary.c \
@@ -30,6 +31,7 @@ noinst_HEADERS = \
camel-imap-folder.h \
camel-imap-message-cache.h \
camel-imap-search.h \
+ camel-imap-settings.h \
camel-imap-store.h \
camel-imap-store-summary.h \
camel-imap-summary.h \
diff --git a/camel/providers/imap/camel-imap-folder.c b/camel/providers/imap/camel-imap-folder.c
index 4aa965c..b7b65b7 100644
--- a/camel/providers/imap/camel-imap-folder.c
+++ b/camel/providers/imap/camel-imap-folder.c
@@ -46,6 +46,7 @@
#include "camel-imap-message-cache.h"
#include "camel-imap-private.h"
#include "camel-imap-search.h"
+#include "camel-imap-settings.h"
#include "camel-imap-store.h"
#include "camel-imap-store-summary.h"
#include "camel-imap-summary.h"
@@ -357,7 +358,6 @@ CamelFolder *
camel_imap_folder_new (CamelStore *parent, const gchar *folder_name,
const gchar *folder_dir, GError **error)
{
- CamelImapStore *imap_store = CAMEL_IMAP_STORE (parent);
CamelFolder *folder;
CamelImapFolder *imap_folder;
const gchar *short_name;
@@ -415,28 +415,70 @@ camel_imap_folder_new (CamelStore *parent, const gchar *folder_name,
CamelService *service;
CamelSettings *settings;
gboolean filter_inbox;
+ gboolean filter_junk;
+ gboolean filter_junk_inbox;
service = CAMEL_SERVICE (parent);
settings = camel_service_get_settings (service);
- filter_inbox = camel_store_settings_get_filter_inbox (
- CAMEL_STORE_SETTINGS (settings));
+ g_object_get (
+ settings,
+ "filter-inbox", &filter_inbox,
+ "filter-junk", &filter_junk,
+ "filter-junk-inbox", &filter_junk_inbox,
+ NULL);
if (filter_inbox)
folder->folder_flags |= CAMEL_FOLDER_FILTER_RECENT;
- if ((imap_store->parameters & IMAP_PARAM_FILTER_JUNK))
+ if (filter_junk)
+ folder->folder_flags |= CAMEL_FOLDER_FILTER_JUNK;
+ if (filter_junk_inbox)
folder->folder_flags |= CAMEL_FOLDER_FILTER_JUNK;
} else {
- if ((imap_store->parameters & (IMAP_PARAM_FILTER_JUNK|IMAP_PARAM_FILTER_JUNK_INBOX)) == (IMAP_PARAM_FILTER_JUNK))
+ CamelService *service;
+ CamelSettings *settings;
+ const gchar *junk_path;
+ const gchar *trash_path;
+ gboolean filter_junk;
+ gboolean folder_is_junk;
+ gboolean folder_is_trash;
+
+ service = CAMEL_SERVICE (parent);
+ settings = camel_service_get_settings (service);
+
+ junk_path = camel_imap_settings_get_real_junk_path (
+ CAMEL_IMAP_SETTINGS (settings));
+
+ /* So we can safely compare strings. */
+ if (junk_path == NULL)
+ junk_path = "";
+
+ trash_path = camel_imap_settings_get_real_trash_path (
+ CAMEL_IMAP_SETTINGS (settings));
+
+ /* So we can safely compare strings. */
+ if (trash_path == NULL)
+ trash_path = "";
+
+ filter_junk = camel_imap_settings_get_filter_junk (
+ CAMEL_IMAP_SETTINGS (settings));
+
+ if (filter_junk)
folder->folder_flags |= CAMEL_FOLDER_FILTER_JUNK;
- if ((parent->flags & CAMEL_STORE_VTRASH) == 0 && imap_store->real_trash_path && g_ascii_strcasecmp (imap_store->real_trash_path, folder_name) == 0) {
+ folder_is_trash =
+ (parent->flags & CAMEL_STORE_VTRASH) == 0 &&
+ g_ascii_strcasecmp (trash_path, folder_name) == 0;
+
+ if (folder_is_trash)
folder->folder_flags |= CAMEL_FOLDER_IS_TRASH;
- }
- if ((parent->flags & CAMEL_STORE_VJUNK) == 0 && imap_store->real_junk_path && g_ascii_strcasecmp (imap_store->real_junk_path, folder_name) == 0) {
+ folder_is_junk =
+ (parent->flags & CAMEL_STORE_VJUNK) == 0 &&
+ g_ascii_strcasecmp (junk_path, folder_name) == 0;
+
+ if (folder_is_junk)
folder->folder_flags |= CAMEL_FOLDER_IS_JUNK;
- }
}
imap_folder->search = camel_imap_search_new (folder_dir);
@@ -1563,6 +1605,8 @@ imap_synchronize_sync (CamelFolder *folder,
GCancellable *cancellable,
GError **error)
{
+ CamelService *service;
+ CamelSettings *settings;
CamelStore *parent_store;
CamelImapStore *store;
CamelImapMessageInfo *info;
@@ -1570,6 +1614,7 @@ imap_synchronize_sync (CamelFolder *folder,
gboolean success, is_gmail;
CamelFolder *real_junk = NULL;
CamelFolder *real_trash = NULL;
+ const gchar *folder_path;
GError *local_error = NULL;
GPtrArray *matches, *summary, *deleted_uids = NULL, *junked_uids = NULL;
@@ -1580,6 +1625,9 @@ imap_synchronize_sync (CamelFolder *folder,
store = CAMEL_IMAP_STORE (parent_store);
is_gmail = is_google_account (parent_store);
+ service = CAMEL_SERVICE (parent_store);
+ settings = camel_service_get_settings (service);
+
if (folder->permanent_flags == 0 || !camel_offline_store_get_online (CAMEL_OFFLINE_STORE (store))) {
if (expunge) {
if (!imap_expunge_sync (folder, cancellable, error))
@@ -1588,7 +1636,7 @@ imap_synchronize_sync (CamelFolder *folder,
return imap_sync_offline (folder, error);
}
- camel_service_lock (CAMEL_SERVICE (store), CAMEL_SERVICE_REC_CONNECT_LOCK);
+ camel_service_lock (service, CAMEL_SERVICE_REC_CONNECT_LOCK);
/* write local changes first */
replay_offline_journal (store, imap_folder, cancellable, NULL);
@@ -1602,16 +1650,17 @@ imap_synchronize_sync (CamelFolder *folder,
max = summary->len;
/* deleted_uids is NULL when not using real trash */
- if (store->real_trash_path && *store->real_trash_path) {
+ folder_path = camel_imap_settings_get_real_trash_path (
+ CAMEL_IMAP_SETTINGS (settings));
+ if (folder_path != NULL) {
if ((folder->folder_flags & CAMEL_FOLDER_IS_TRASH) != 0) {
/* syncing the trash, expunge deleted when found any */
- real_trash = folder;
- g_object_ref (real_trash);
+ real_trash = g_object_ref (folder);
} else {
real_trash = camel_store_get_trash_folder_sync (
parent_store, cancellable, NULL);
- if (!store->real_trash_path && real_trash) {
+ if (folder_path == NULL && real_trash) {
/* failed to open real trash */
g_object_unref (real_trash);
real_trash = NULL;
@@ -1623,15 +1672,18 @@ imap_synchronize_sync (CamelFolder *folder,
deleted_uids = g_ptr_array_new ();
/* junked_uids is NULL when not using real junk */
- if (store->real_junk_path && *store->real_junk_path) {
+ folder_path = camel_imap_settings_get_real_junk_path (
+ CAMEL_IMAP_SETTINGS (settings));
+ if (folder_path != NULL) {
if ((folder->folder_flags & CAMEL_FOLDER_IS_JUNK) != 0) {
- /* syncing the junk, but cannot move messages to itself, thus do nothing */
+ /* syncing the junk, but cannot move
+ * messages to itself, thus do nothing */
real_junk = NULL;
} else {
real_junk = camel_store_get_junk_folder_sync (
parent_store, cancellable, NULL);
- if (!store->real_junk_path && real_junk) {
+ if (folder_path == NULL && real_junk) {
/* failed to open real junk */
g_object_unref (real_junk);
real_junk = NULL;
@@ -1753,7 +1805,7 @@ imap_synchronize_sync (CamelFolder *folder,
g_ptr_array_free (matches, TRUE);
/* We unlock here so that other threads can have a chance to grab the connect_lock */
- camel_service_unlock (CAMEL_SERVICE (store), CAMEL_SERVICE_REC_CONNECT_LOCK);
+ camel_service_unlock (service, CAMEL_SERVICE_REC_CONNECT_LOCK);
/* check for an exception */
if (local_error != NULL) {
@@ -1774,7 +1826,7 @@ imap_synchronize_sync (CamelFolder *folder,
}
/* Re-lock the connect_lock */
- camel_service_lock (CAMEL_SERVICE (store), CAMEL_SERVICE_REC_CONNECT_LOCK);
+ camel_service_lock (service, CAMEL_SERVICE_REC_CONNECT_LOCK);
}
if (local_error == NULL)
@@ -1811,7 +1863,7 @@ imap_synchronize_sync (CamelFolder *folder,
/* Save the summary */
success = imap_sync_offline (folder, error);
- camel_service_unlock (CAMEL_SERVICE (store), CAMEL_SERVICE_REC_CONNECT_LOCK);
+ camel_service_unlock (service, CAMEL_SERVICE_REC_CONNECT_LOCK);
return success;
}
@@ -2765,9 +2817,12 @@ do_copy (CamelFolder *source,
GCancellable *cancellable,
GError **error)
{
+ CamelService *service;
+ CamelSettings *settings;
CamelStore *parent_store;
CamelImapStore *store;
CamelImapResponse *response;
+ const gchar *trash_path;
const gchar *full_name;
gchar *uidset;
gint uid = 0, last=0, i;
@@ -2776,7 +2831,14 @@ do_copy (CamelFolder *source,
parent_store = camel_folder_get_parent_store (source);
store = CAMEL_IMAP_STORE (parent_store);
- mark_moved = is_google_account (parent_store) && store && store->real_trash_path && *store->real_trash_path;
+
+ service = CAMEL_SERVICE (parent_store);
+ settings = camel_service_get_settings (service);
+
+ trash_path = camel_imap_settings_get_real_trash_path (
+ CAMEL_IMAP_SETTINGS (settings));
+
+ mark_moved = is_google_account (parent_store) && trash_path != NULL;
full_name = camel_folder_get_full_name (destination);
@@ -3916,9 +3978,12 @@ imap_update_summary (CamelFolder *folder,
{
CamelStore *parent_store;
CamelService *service;
+ CamelSettings *settings;
CamelImapStore *store;
CamelImapFolder *imap_folder = CAMEL_IMAP_FOLDER (folder);
GPtrArray *fetch_data = NULL, *messages = NULL, *needheaders;
+ CamelFetchHeadersType fetch_headers;
+ const gchar * const *extra_headers;
guint32 flags, uidval;
gint i, seq, first, size, got;
CamelImapResponseType type;
@@ -3931,25 +3996,40 @@ imap_update_summary (CamelFolder *folder,
parent_store = camel_folder_get_parent_store (folder);
store = CAMEL_IMAP_STORE (parent_store);
- service = CAMEL_SERVICE (store);
+ service = CAMEL_SERVICE (parent_store);
+ settings = camel_service_get_settings (service);
+
+ fetch_headers = camel_imap_settings_get_fetch_headers (
+ CAMEL_IMAP_SETTINGS (settings));
+
+ extra_headers = camel_imap_settings_get_fetch_headers_extra (
+ CAMEL_IMAP_SETTINGS (settings));
if (store->server_level >= IMAP_LEVEL_IMAP4REV1) {
- if (store->headers == IMAP_FETCH_ALL_HEADERS)
+ if (fetch_headers == CAMEL_FETCH_HEADERS_ALL)
header_spec = g_string_new ("HEADER");
else {
gchar *temp;
header_spec = g_string_new ("HEADER.FIELDS (");
- header_spec = g_string_append (header_spec, CAMEL_MESSAGE_INFO_HEADERS);
- if (store->headers == IMAP_FETCH_MAILING_LIST_HEADERS)
- header_spec = g_string_append (header_spec, MAILING_LIST_HEADERS);
- if (store->custom_headers)
- header_spec = g_string_append (header_spec, store->custom_headers);
+ g_string_append (header_spec, CAMEL_MESSAGE_INFO_HEADERS);
+ if (fetch_headers == CAMEL_FETCH_HEADERS_BASIC_AND_MAILING_LIST)
+ g_string_append (header_spec, MAILING_LIST_HEADERS);
+ if (extra_headers != NULL) {
+ guint length, ii;
+
+ length = g_strv_length ((gchar **) extra_headers);
+ for (ii = 0; ii < length; ii++) {
+ g_string_append (header_spec, extra_headers[ii]);
+ if (ii + 1 < length)
+ g_string_append_c (header_spec, ' ');
+ }
+ }
temp = g_string_free (header_spec, FALSE);
temp = g_strstrip (temp);
header_spec = g_string_new (temp);
g_free (temp);
- header_spec = g_string_append (header_spec, ")");
+ g_string_append (header_spec, ")");
}
} else
header_spec = g_string_new ("0");
diff --git a/camel/providers/imap/camel-imap-provider.c b/camel/providers/imap/camel-imap-provider.c
index 7d261fa..4cf6ca9 100644
--- a/camel/providers/imap/camel-imap-provider.c
+++ b/camel/providers/imap/camel-imap-provider.c
@@ -38,47 +38,47 @@ static gint imap_url_equal (gconstpointer a, gconstpointer b);
static CamelProviderConfEntry imap_conf_entries[] = {
{ CAMEL_PROVIDER_CONF_SECTION_START, "mailcheck", NULL,
N_("Checking for New Mail") },
- { CAMEL_PROVIDER_CONF_CHECKBOX, "check_all", NULL,
+ { CAMEL_PROVIDER_CONF_CHECKBOX, "check-all", NULL,
N_("C_heck for new messages in all folders"), "1" },
- { CAMEL_PROVIDER_CONF_CHECKBOX, "check_lsub", NULL,
+ { CAMEL_PROVIDER_CONF_CHECKBOX, "check-subscribed", NULL,
N_("Ch_eck for new messages in subscribed folders"), "0" },
{ CAMEL_PROVIDER_CONF_SECTION_END },
#ifndef G_OS_WIN32
{ CAMEL_PROVIDER_CONF_SECTION_START, "cmdsection", NULL,
N_("Connection to Server") },
- { CAMEL_PROVIDER_CONF_CHECKBOX, "use_command", NULL,
+ { CAMEL_PROVIDER_CONF_CHECKBOX, "use-shell-command", NULL,
N_("_Use custom command to connect to server"), "0" },
- { CAMEL_PROVIDER_CONF_ENTRY, "command", "use_command",
+ { CAMEL_PROVIDER_CONF_ENTRY, "shell-command", "use-shell-command",
N_("Co_mmand:"), "ssh -C -l %u %h exec /usr/sbin/imapd" },
{ CAMEL_PROVIDER_CONF_SECTION_END },
#endif
{ CAMEL_PROVIDER_CONF_SECTION_START, "folders", NULL,
N_("Folders") },
- { CAMEL_PROVIDER_CONF_CHECKBOX, "use_lsub", NULL,
+ { CAMEL_PROVIDER_CONF_CHECKBOX, "use-subscriptions", NULL,
N_("_Show only subscribed folders"), "1" },
- { CAMEL_PROVIDER_CONF_CHECKBOX, "override_namespace", NULL,
+ { CAMEL_PROVIDER_CONF_CHECKBOX, "use-namespace", NULL,
N_("O_verride server-supplied folder namespace"), "0" },
- { CAMEL_PROVIDER_CONF_ENTRY, "namespace", "override_namespace",
+ { CAMEL_PROVIDER_CONF_ENTRY, "namespace", "use-namespace",
N_("Names_pace:") },
{ CAMEL_PROVIDER_CONF_SECTION_END },
{ CAMEL_PROVIDER_CONF_SECTION_START, "general", NULL, N_("Options") },
- { CAMEL_PROVIDER_CONF_CHECKBOX, "filter", NULL,
+ { CAMEL_PROVIDER_CONF_CHECKBOX, "filter-inbox", NULL,
N_("_Apply filters to new messages in Inbox on this server"), "1" },
- { CAMEL_PROVIDER_CONF_CHECKBOX, "filter_junk", NULL,
+ { CAMEL_PROVIDER_CONF_CHECKBOX, "filter-junk", NULL,
N_("Check new messages for Jun_k contents"), "0" },
- { CAMEL_PROVIDER_CONF_CHECKBOX, "filter_junk_inbox", "filter_junk",
+ { CAMEL_PROVIDER_CONF_CHECKBOX, "filter-junk-inbox", "filter_junk",
N_("Only check for Junk messages in the IN_BOX folder"), "0" },
- { CAMEL_PROVIDER_CONF_CHECKBOX, "sync_offline", NULL,
+ { CAMEL_PROVIDER_CONF_CHECKBOX, "stay-synchronized", NULL,
N_("Automatically synchroni_ze remote mail locally"), "0" },
{ CAMEL_PROVIDER_CONF_SECTION_END },
{ CAMEL_PROVIDER_CONF_END }
};
CamelProviderPortEntry imap_port_entries[] = {
- { 143, N_("IMAP default port"), FALSE },
- { 993, N_("IMAP over SSL"), TRUE },
- { 0, NULL, 0 }
- };
+ { 143, N_("IMAP default port"), FALSE },
+ { 993, N_("IMAP over SSL"), TRUE },
+ { 0, NULL, 0 }
+};
static CamelProvider imap_provider = {
"imap",
diff --git a/camel/providers/imap/camel-imap-settings.c b/camel/providers/imap/camel-imap-settings.c
new file mode 100644
index 0000000..f5713b7
--- /dev/null
+++ b/camel/providers/imap/camel-imap-settings.c
@@ -0,0 +1,1192 @@
+/*
+ * camel-imap-settings.c
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) version 3.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with the program; if not, see <http://www.gnu.org/licenses/>
+ *
+ */
+
+#include "camel-imap-settings.h"
+
+#define CAMEL_IMAP_SETTINGS_GET_PRIVATE(obj) \
+ (G_TYPE_INSTANCE_GET_PRIVATE \
+ ((obj), CAMEL_TYPE_IMAP_SETTINGS, CamelImapSettingsPrivate))
+
+struct _CamelImapSettingsPrivate {
+ gchar *namespace;
+ gchar *shell_command;
+ gchar *real_junk_path;
+ gchar *real_trash_path;
+ gchar **fetch_headers_extra;
+
+ gboolean check_all;
+ gboolean check_subscribed;
+ gboolean filter_junk;
+ gboolean filter_junk_inbox;
+ gboolean use_namespace;
+ gboolean use_real_junk_path;
+ gboolean use_real_trash_path;
+ gboolean use_shell_command;
+ gboolean use_subscriptions;
+
+ CamelFetchHeadersType fetch_headers;
+};
+
+enum {
+ PROP_0,
+ PROP_CHECK_ALL,
+ PROP_CHECK_SUBSCRIBED,
+ PROP_FETCH_HEADERS,
+ PROP_FETCH_HEADERS_EXTRA,
+ PROP_FILTER_JUNK,
+ PROP_FILTER_JUNK_INBOX,
+ PROP_NAMESPACE,
+ PROP_REAL_JUNK_PATH,
+ PROP_REAL_TRASH_PATH,
+ PROP_SECURITY_METHOD,
+ PROP_SHELL_COMMAND,
+ PROP_USE_NAMESPACE,
+ PROP_USE_REAL_JUNK_PATH,
+ PROP_USE_REAL_TRASH_PATH,
+ PROP_USE_SHELL_COMMAND,
+ PROP_USE_SUBSCRIPTIONS
+};
+
+G_DEFINE_TYPE_WITH_CODE (
+ CamelImapSettings,
+ camel_imap_settings,
+ CAMEL_TYPE_OFFLINE_SETTINGS,
+ G_IMPLEMENT_INTERFACE (
+ CAMEL_TYPE_NETWORK_SETTINGS, NULL))
+
+static void
+imap_settings_set_property (GObject *object,
+ guint property_id,
+ const GValue *value,
+ GParamSpec *pspec)
+{
+ switch (property_id) {
+ case PROP_CHECK_ALL:
+ camel_imap_settings_set_check_all (
+ CAMEL_IMAP_SETTINGS (object),
+ g_value_get_boolean (value));
+ return;
+
+ case PROP_CHECK_SUBSCRIBED:
+ camel_imap_settings_set_check_subscribed (
+ CAMEL_IMAP_SETTINGS (object),
+ g_value_get_boolean (value));
+ return;
+
+ case PROP_FETCH_HEADERS:
+ camel_imap_settings_set_fetch_headers (
+ CAMEL_IMAP_SETTINGS (object),
+ g_value_get_enum (value));
+ return;
+
+ case PROP_FETCH_HEADERS_EXTRA:
+ camel_imap_settings_set_fetch_headers_extra (
+ CAMEL_IMAP_SETTINGS (object),
+ g_value_get_boxed (value));
+ return;
+
+ case PROP_FILTER_JUNK:
+ camel_imap_settings_set_filter_junk (
+ CAMEL_IMAP_SETTINGS (object),
+ g_value_get_boolean (value));
+ return;
+
+ case PROP_FILTER_JUNK_INBOX:
+ camel_imap_settings_set_filter_junk_inbox (
+ CAMEL_IMAP_SETTINGS (object),
+ g_value_get_boolean (value));
+ return;
+
+ case PROP_NAMESPACE:
+ camel_imap_settings_set_namespace (
+ CAMEL_IMAP_SETTINGS (object),
+ g_value_get_string (value));
+ return;
+
+ case PROP_REAL_JUNK_PATH:
+ camel_imap_settings_set_real_junk_path (
+ CAMEL_IMAP_SETTINGS (object),
+ g_value_get_string (value));
+ return;
+
+ case PROP_REAL_TRASH_PATH:
+ camel_imap_settings_set_real_trash_path (
+ CAMEL_IMAP_SETTINGS (object),
+ g_value_get_string (value));
+ return;
+
+ case PROP_SECURITY_METHOD:
+ camel_network_settings_set_security_method (
+ CAMEL_NETWORK_SETTINGS (object),
+ g_value_get_enum (value));
+ return;
+
+ case PROP_SHELL_COMMAND:
+ camel_imap_settings_set_shell_command (
+ CAMEL_IMAP_SETTINGS (object),
+ g_value_get_string (value));
+ return;
+
+ case PROP_USE_NAMESPACE:
+ camel_imap_settings_set_use_namespace (
+ CAMEL_IMAP_SETTINGS (object),
+ g_value_get_boolean (value));
+ return;
+
+ case PROP_USE_REAL_JUNK_PATH:
+ camel_imap_settings_set_use_real_junk_path (
+ CAMEL_IMAP_SETTINGS (object),
+ g_value_get_boolean (value));
+ return;
+
+ case PROP_USE_REAL_TRASH_PATH:
+ camel_imap_settings_set_use_real_trash_path (
+ CAMEL_IMAP_SETTINGS (object),
+ g_value_get_boolean (value));
+ return;
+
+ case PROP_USE_SHELL_COMMAND:
+ camel_imap_settings_set_use_shell_command (
+ CAMEL_IMAP_SETTINGS (object),
+ g_value_get_boolean (value));
+ return;
+
+ case PROP_USE_SUBSCRIPTIONS:
+ camel_imap_settings_set_use_subscriptions (
+ CAMEL_IMAP_SETTINGS (object),
+ g_value_get_boolean (value));
+ return;
+ }
+
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+}
+
+static void
+imap_settings_get_property (GObject *object,
+ guint property_id,
+ GValue *value,
+ GParamSpec *pspec)
+{
+ switch (property_id) {
+ case PROP_CHECK_ALL:
+ g_value_set_boolean (
+ value,
+ camel_imap_settings_get_check_all (
+ CAMEL_IMAP_SETTINGS (object)));
+ return;
+
+ case PROP_CHECK_SUBSCRIBED:
+ g_value_set_boolean (
+ value,
+ camel_imap_settings_get_check_subscribed (
+ CAMEL_IMAP_SETTINGS (object)));
+ return;
+
+ case PROP_FETCH_HEADERS:
+ g_value_set_enum (
+ value,
+ camel_imap_settings_get_fetch_headers (
+ CAMEL_IMAP_SETTINGS (object)));
+ return;
+
+ case PROP_FETCH_HEADERS_EXTRA:
+ g_value_set_boxed (
+ value,
+ camel_imap_settings_get_fetch_headers_extra (
+ CAMEL_IMAP_SETTINGS (object)));
+ return;
+
+ case PROP_FILTER_JUNK:
+ g_value_set_boolean (
+ value,
+ camel_imap_settings_get_filter_junk (
+ CAMEL_IMAP_SETTINGS (object)));
+ return;
+
+ case PROP_FILTER_JUNK_INBOX:
+ g_value_set_boolean (
+ value,
+ camel_imap_settings_get_filter_junk_inbox (
+ CAMEL_IMAP_SETTINGS (object)));
+ return;
+
+ case PROP_NAMESPACE:
+ g_value_set_string (
+ value,
+ camel_imap_settings_get_namespace (
+ CAMEL_IMAP_SETTINGS (object)));
+ return;
+
+ case PROP_REAL_JUNK_PATH:
+ g_value_set_string (
+ value,
+ camel_imap_settings_get_real_junk_path (
+ CAMEL_IMAP_SETTINGS (object)));
+ return;
+
+ case PROP_REAL_TRASH_PATH:
+ g_value_set_string (
+ value,
+ camel_imap_settings_get_real_trash_path (
+ CAMEL_IMAP_SETTINGS (object)));
+ return;
+
+ case PROP_SECURITY_METHOD:
+ g_value_set_enum (
+ value,
+ camel_network_settings_get_security_method (
+ CAMEL_NETWORK_SETTINGS (object)));
+ return;
+
+ case PROP_SHELL_COMMAND:
+ g_value_set_string (
+ value,
+ camel_imap_settings_get_shell_command (
+ CAMEL_IMAP_SETTINGS (object)));
+ return;
+
+ case PROP_USE_NAMESPACE:
+ g_value_set_boolean (
+ value,
+ camel_imap_settings_get_use_namespace (
+ CAMEL_IMAP_SETTINGS (object)));
+ return;
+
+ case PROP_USE_REAL_JUNK_PATH:
+ g_value_set_boolean (
+ value,
+ camel_imap_settings_get_use_real_junk_path (
+ CAMEL_IMAP_SETTINGS (object)));
+ return;
+
+ case PROP_USE_REAL_TRASH_PATH:
+ g_value_set_boolean (
+ value,
+ camel_imap_settings_get_use_real_trash_path (
+ CAMEL_IMAP_SETTINGS (object)));
+ return;
+
+ case PROP_USE_SHELL_COMMAND:
+ g_value_set_boolean (
+ value,
+ camel_imap_settings_get_use_shell_command (
+ CAMEL_IMAP_SETTINGS (object)));
+ return;
+
+ case PROP_USE_SUBSCRIPTIONS:
+ g_value_set_boolean (
+ value,
+ camel_imap_settings_get_use_subscriptions (
+ CAMEL_IMAP_SETTINGS (object)));
+ return;
+ }
+
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+}
+
+static void
+imap_settings_finalize (GObject *object)
+{
+ CamelImapSettingsPrivate *priv;
+
+ priv = CAMEL_IMAP_SETTINGS_GET_PRIVATE (object);
+
+ g_free (priv->namespace);
+ g_free (priv->shell_command);
+ g_free (priv->real_junk_path);
+ g_free (priv->real_trash_path);
+ g_strfreev (priv->fetch_headers_extra);
+
+ /* Chain up to parent's finalize() method. */
+ G_OBJECT_CLASS (camel_imap_settings_parent_class)->finalize (object);
+}
+
+static void
+camel_imap_settings_class_init (CamelImapSettingsClass *class)
+{
+ GObjectClass *object_class;
+
+ g_type_class_add_private (class, sizeof (CamelImapSettingsPrivate));
+
+ object_class = G_OBJECT_CLASS (class);
+ object_class->set_property = imap_settings_set_property;
+ object_class->get_property = imap_settings_get_property;
+ object_class->finalize = imap_settings_finalize;
+
+ g_object_class_install_property (
+ object_class,
+ PROP_CHECK_ALL,
+ g_param_spec_boolean (
+ "check-all",
+ "Check All",
+ "Check all folders for new messages",
+ FALSE,
+ G_PARAM_READWRITE |
+ G_PARAM_CONSTRUCT |
+ G_PARAM_STATIC_STRINGS));
+
+ g_object_class_install_property (
+ object_class,
+ PROP_CHECK_SUBSCRIBED,
+ g_param_spec_boolean (
+ "check-subscribed",
+ "Check Subscribed",
+ "Check only subscribed folders for new messages",
+ FALSE,
+ G_PARAM_READWRITE |
+ G_PARAM_CONSTRUCT |
+ G_PARAM_STATIC_STRINGS));
+
+ g_object_class_install_property (
+ object_class,
+ PROP_FETCH_HEADERS,
+ g_param_spec_enum (
+ "fetch-headers",
+ "Fetch Headers",
+ "Headers to fetch in message summaries",
+ CAMEL_TYPE_FETCH_HEADERS_TYPE,
+ CAMEL_FETCH_HEADERS_BASIC_AND_MAILING_LIST,
+ G_PARAM_READWRITE |
+ G_PARAM_CONSTRUCT |
+ G_PARAM_STATIC_STRINGS));
+
+ g_object_class_install_property (
+ object_class,
+ PROP_FETCH_HEADERS_EXTRA,
+ g_param_spec_boxed (
+ "fetch-headers-extra",
+ "Fetch Headers Extra",
+ "Additional headers to fetch in message summaries",
+ G_TYPE_STRV,
+ G_PARAM_READWRITE |
+ G_PARAM_CONSTRUCT |
+ G_PARAM_STATIC_STRINGS));
+
+ g_object_class_install_property (
+ object_class,
+ PROP_FILTER_JUNK,
+ g_param_spec_boolean (
+ "filter-junk",
+ "Filter Junk",
+ "Whether to filter junk from all folders",
+ FALSE,
+ G_PARAM_READWRITE |
+ G_PARAM_CONSTRUCT |
+ G_PARAM_STATIC_STRINGS));
+
+ g_object_class_install_property (
+ object_class,
+ PROP_FILTER_JUNK_INBOX,
+ g_param_spec_boolean (
+ "filter-junk-inbox",
+ "Filter Junk Inbox",
+ "Whether to filter junk from Inbox only",
+ FALSE,
+ G_PARAM_READWRITE |
+ G_PARAM_CONSTRUCT |
+ G_PARAM_STATIC_STRINGS));
+
+ g_object_class_install_property (
+ object_class,
+ PROP_NAMESPACE,
+ g_param_spec_string (
+ "namespace",
+ "Namespace",
+ "Custom IMAP namespace",
+ NULL,
+ G_PARAM_READWRITE |
+ G_PARAM_CONSTRUCT |
+ G_PARAM_STATIC_STRINGS));
+
+ g_object_class_install_property (
+ object_class,
+ PROP_REAL_JUNK_PATH,
+ g_param_spec_string (
+ "real-junk-path",
+ "Real Junk Path",
+ "Path for a non-virtual Junk folder",
+ NULL,
+ G_PARAM_READWRITE |
+ G_PARAM_CONSTRUCT |
+ G_PARAM_STATIC_STRINGS));
+
+ g_object_class_install_property (
+ object_class,
+ PROP_REAL_TRASH_PATH,
+ g_param_spec_string (
+ "real-trash-path",
+ "Real Trash Path",
+ "Path for a non-virtual Trash folder",
+ NULL,
+ G_PARAM_READWRITE |
+ G_PARAM_CONSTRUCT |
+ G_PARAM_STATIC_STRINGS));
+
+ /* Inherited from CamelNetworkSettings. */
+ g_object_class_override_property (
+ object_class,
+ PROP_SECURITY_METHOD,
+ "security-method");
+
+ g_object_class_install_property (
+ object_class,
+ PROP_SHELL_COMMAND,
+ g_param_spec_string (
+ "shell-command",
+ "Shell Command",
+ "Shell command for connecting to the server",
+ "ssh -C -l %u %h exec /usr/sbin/imapd",
+ G_PARAM_READWRITE |
+ G_PARAM_CONSTRUCT |
+ G_PARAM_STATIC_STRINGS));
+
+ g_object_class_install_property (
+ object_class,
+ PROP_USE_NAMESPACE,
+ g_param_spec_boolean (
+ "use-namespace",
+ "Use Namespace",
+ "Whether to use a custom IMAP namespace",
+ FALSE,
+ G_PARAM_READWRITE |
+ G_PARAM_CONSTRUCT |
+ G_PARAM_STATIC_STRINGS));
+
+ g_object_class_install_property (
+ object_class,
+ PROP_USE_REAL_JUNK_PATH,
+ g_param_spec_boolean (
+ "use-real-junk-path",
+ "Use Real Junk Path",
+ "Whether to use a non-virtual Junk folder",
+ FALSE,
+ G_PARAM_READWRITE |
+ G_PARAM_CONSTRUCT |
+ G_PARAM_STATIC_STRINGS));
+
+ g_object_class_install_property (
+ object_class,
+ PROP_USE_REAL_TRASH_PATH,
+ g_param_spec_boolean (
+ "use-real-trash-path",
+ "Use Real Trash Path",
+ "Whether to use a non-virtual Trash folder",
+ FALSE,
+ G_PARAM_READWRITE |
+ G_PARAM_CONSTRUCT |
+ G_PARAM_STATIC_STRINGS));
+
+ g_object_class_install_property (
+ object_class,
+ PROP_USE_SHELL_COMMAND,
+ g_param_spec_boolean (
+ "use-shell-command",
+ "Use Shell Command",
+ "Whether to use a custom shell "
+ "command to connect to the server",
+ FALSE,
+ G_PARAM_READWRITE |
+ G_PARAM_CONSTRUCT |
+ G_PARAM_STATIC_STRINGS));
+
+ g_object_class_install_property (
+ object_class,
+ PROP_USE_SUBSCRIPTIONS,
+ g_param_spec_boolean (
+ "use-subscriptions",
+ "Use Subscriptions",
+ "Whether to honor folder subscriptions",
+ TRUE,
+ G_PARAM_READWRITE |
+ G_PARAM_CONSTRUCT |
+ G_PARAM_STATIC_STRINGS));
+}
+
+static void
+camel_imap_settings_init (CamelImapSettings *settings)
+{
+ settings->priv = CAMEL_IMAP_SETTINGS_GET_PRIVATE (settings);
+}
+
+/**
+ * camel_imap_settings_get_check_all:
+ * @settings: a #CamelImapSettings
+ *
+ * Returns whether to check all folders for new messages.
+ *
+ * Returns: whether to check all folders for new messages
+ *
+ * Since: 3.2
+ **/
+gboolean
+camel_imap_settings_get_check_all (CamelImapSettings *settings)
+{
+ g_return_val_if_fail (CAMEL_IS_IMAP_SETTINGS (settings), FALSE);
+
+ return settings->priv->check_all;
+}
+
+/**
+ * camel_imap_settings_set_check_all:
+ * @settings: a #CamelImapSettings
+ * @check_all: whether to check all folders for new messages
+ *
+ * Sets whether to check all folders for new messages.
+ *
+ * Since: 3.2
+ **/
+void
+camel_imap_settings_set_check_all (CamelImapSettings *settings,
+ gboolean check_all)
+{
+ g_return_if_fail (CAMEL_IS_IMAP_SETTINGS (settings));
+
+ settings->priv->check_all = check_all;
+
+ g_object_notify (G_OBJECT (settings), "check-all");
+}
+
+/**
+ * camel_imap_settings_get_check_subscribed:
+ * @settings: a #CamelImapSettings
+ *
+ * Returns whether to check only subscribed folders for new messages.
+ * Note that #CamelImapSettings:check-all, if %TRUE, overrides this setting.
+ *
+ * Returns: whether to check only subscribed folders for new messages
+ *
+ * Since: 3.2
+ **/
+gboolean
+camel_imap_settings_get_check_subscribed (CamelImapSettings *settings)
+{
+ g_return_val_if_fail (CAMEL_IS_IMAP_SETTINGS (settings), FALSE);
+
+ return settings->priv->check_subscribed;
+}
+
+/**
+ * camel_imap_settings_set_check_subscribed:
+ * @settings: a #CamelImapSettings
+ * @check_subscribed: whether to check only subscribed folders for new messages
+ *
+ * Sets whether to check only subscribed folders for new messages. Note
+ * that #CamelImapSettings:check-all, if %TRUE, overrides this setting.
+ *
+ * Since: 3.2
+ **/
+void
+camel_imap_settings_set_check_subscribed (CamelImapSettings *settings,
+ gboolean check_subscribed)
+{
+ g_return_if_fail (CAMEL_IS_IMAP_SETTINGS (settings));
+
+ settings->priv->check_subscribed = check_subscribed;
+
+ g_object_notify (G_OBJECT (settings), "check-subscribed");
+}
+
+/**
+ * camel_imap_settings_get_fetch_headers:
+ * @settings: a #CamelImapSettings
+ *
+ * Returns the subset of headers to fetch when downloading message summaries.
+ * Fewer headers means faster downloads, but filtering rules for incoming
+ * messages may require additional headers such as mailing list headers.
+ *
+ * Returns: which subset of message headers to fetch
+ *
+ * Since: 3.2
+ **/
+CamelFetchHeadersType
+camel_imap_settings_get_fetch_headers (CamelImapSettings *settings)
+{
+ g_return_val_if_fail (
+ CAMEL_IS_IMAP_SETTINGS (settings),
+ CAMEL_FETCH_HEADERS_BASIC);
+
+ return settings->priv->fetch_headers;
+}
+
+/**
+ * camel_imap_settings_set_fetch_headers:
+ * @settings: a #CamelImapSettings
+ * @fetch_headers: which subset of message headers to fetch
+ *
+ * Sets the subset of headers to fetch when downloading message summaries.
+ * Fewer headers means faster downloads, but filtering rules for incoming
+ * messages may require additional headers such as mailing list headers.
+ *
+ * Since: 3.2
+ **/
+void
+camel_imap_settings_set_fetch_headers (CamelImapSettings *settings,
+ CamelFetchHeadersType fetch_headers)
+{
+ g_return_if_fail (CAMEL_IS_IMAP_SETTINGS (settings));
+
+ settings->priv->fetch_headers = fetch_headers;
+
+ g_object_notify (G_OBJECT (settings), "fetch-headers");
+}
+
+/**
+ * camel_imap_settings_get_fetch_headers_extra:
+ * @settings: a #CamelImapSettings
+ *
+ * Returns a %NULL-terminated list of extra headers to fetch when downloading
+ * message summaries, or %NULL if there are no extra headers to fetch. This
+ * is mainly used for filtering rules that check for a specific headeder which
+ * is not included in the %CAMEL_FETCH_HEADERS_BASIC_AND_MAILING_LIST subset.
+ *
+ * Returns: a %NULL-terminated list of extra headers to fetch
+ *
+ * Since: 3.2
+ **/
+const gchar * const *
+camel_imap_settings_get_fetch_headers_extra (CamelImapSettings *settings)
+{
+ g_return_val_if_fail (CAMEL_IS_IMAP_SETTINGS (settings), NULL);
+
+ return (const gchar * const *) settings->priv->fetch_headers_extra;
+}
+
+/**
+ * camel_imap_settings_set_fetch_headers_extra:
+ * @settings: a #CamelImapSettings
+ * @fetch_headers_extra: a %NULL-terminated list of extra headers to fetch,
+ * or %NULL
+ *
+ * Sets a %NULL-terminated list of extra headers to fetch when downloading
+ * message summaries. This is mainly used for filtering rules that check
+ * for a specific header which is not included in the
+ * %CAMEL_FETCH_HEADERS_BASIC_AND_MAILING_LIST subset.
+ *
+ * Since: 3.2
+ **/
+void
+camel_imap_settings_set_fetch_headers_extra (CamelImapSettings *settings,
+ const gchar * const *fetch_headers_extra)
+{
+ gchar **strv = NULL;
+
+ g_return_if_fail (CAMEL_IS_IMAP_SETTINGS (settings));
+
+ g_strfreev (settings->priv->fetch_headers_extra);
+
+ if (fetch_headers_extra != NULL) {
+ guint ii, length;
+
+ length = g_strv_length ((gchar **) fetch_headers_extra);
+ strv = g_new0 (gchar *, length + 1);
+
+ for (ii = 0; ii < length; ii++)
+ strv[ii] = g_strdup (fetch_headers_extra[ii]);
+ }
+
+ settings->priv->fetch_headers_extra = strv;
+
+ g_object_notify (G_OBJECT (settings), "fetch-headers-extra");
+}
+
+/**
+ * camel_imap_settings_get_filter_junk:
+ * @settings: a #CamelImapSettings
+ *
+ * Returns whether to automatically find and tag junk messages amongst new
+ * messages in all folders.
+ *
+ * Returns: whether to filter junk in all folders
+ *
+ * Since: 3.2
+ **/
+gboolean
+camel_imap_settings_get_filter_junk (CamelImapSettings *settings)
+{
+ g_return_val_if_fail (CAMEL_IS_IMAP_SETTINGS (settings), FALSE);
+
+ return settings->priv->filter_junk;
+}
+
+/**
+ * camel_imap_settings_set_filter_junk:
+ * @settings: a #CamelImapSettings
+ * @filter_junk: whether to filter junk in all filers
+ *
+ * Sets whether to automatically find and tag junk messages amongst new
+ * messages in all folders.
+ *
+ * Since: 3.2
+ **/
+void
+camel_imap_settings_set_filter_junk (CamelImapSettings *settings,
+ gboolean filter_junk)
+{
+ g_return_if_fail (CAMEL_IS_IMAP_SETTINGS (settings));
+
+ settings->priv->filter_junk = filter_junk;
+
+ g_object_notify (G_OBJECT (settings), "filter-junk");
+}
+
+/**
+ * camel_imap_settings_get_filter_junk_inbox:
+ * @settings: a #CamelImapSettings
+ *
+ * Returns whether to automatically find and tag junk messages amongst new
+ * messages in the Inbox folder only.
+ *
+ * Returns: whether to filter junk in Inbox only
+ *
+ * Since: 3.2
+ **/
+gboolean
+camel_imap_settings_get_filter_junk_inbox (CamelImapSettings *settings)
+{
+ g_return_val_if_fail (CAMEL_IS_IMAP_SETTINGS (settings), FALSE);
+
+ return settings->priv->filter_junk_inbox;
+}
+
+/**
+ * camel_imap_settings_set_filter_junk_inbox:
+ * @settings: a #CamelImapSettings
+ * @filter_junk_inbox: whether to filter junk in Inbox only
+ *
+ * Sets whether to automatically find and tag junk messages amongst new
+ * messages in the Inbox folder only.
+ *
+ * Since: 3.2
+ **/
+void
+camel_imap_settings_set_filter_junk_inbox (CamelImapSettings *settings,
+ gboolean filter_junk_inbox)
+{
+ g_return_if_fail (CAMEL_IS_IMAP_SETTINGS (settings));
+
+ settings->priv->filter_junk_inbox = filter_junk_inbox;
+
+ g_object_notify (G_OBJECT (settings), "filter-junk-inbox");
+}
+
+/**
+ * camel_imap_settings_get_namespace:
+ * @settings: a #CamelImapSettings
+ *
+ * Returns the custom IMAP namespace in which to find folders.
+ *
+ * Returns: the custom IMAP namespace, or %NULL
+ *
+ * Since: 3.2
+ **/
+const gchar *
+camel_imap_settings_get_namespace (CamelImapSettings *settings)
+{
+ g_return_val_if_fail (CAMEL_IS_IMAP_SETTINGS (settings), NULL);
+
+ return settings->priv->namespace;
+}
+
+/**
+ * camel_imap_settings_set_namespace:
+ * @settings: a #CamelImapSettings
+ * @namespace: an IMAP namespace, or %NULL
+ *
+ * Sets the custom IMAP namespace in which to find folders. If @namespace
+ * is %NULL, the default namespace is used.
+ *
+ * Since: 3.2
+ **/
+void
+camel_imap_settings_set_namespace (CamelImapSettings *settings,
+ const gchar *namespace)
+{
+ g_return_if_fail (CAMEL_IS_IMAP_SETTINGS (settings));
+
+ /* The default namespace is an empty string. */
+ if (namespace == NULL)
+ namespace = "";
+
+ g_free (settings->priv->namespace);
+ settings->priv->namespace = g_strdup (namespace);
+
+ g_object_notify (G_OBJECT (settings), "namespace");
+}
+
+/**
+ * camel_imap_settings_get_real_junk_path:
+ * @settings: a #CamelImapSettings
+ *
+ * Returns the path to a real, non-virtual Junk folder to be used instead
+ * of Camel's standard virtual Junk folder.
+ *
+ * Returns: path to a real Junk folder
+ *
+ * Since: 3.2
+ **/
+const gchar *
+camel_imap_settings_get_real_junk_path (CamelImapSettings *settings)
+{
+ g_return_val_if_fail (CAMEL_IS_IMAP_SETTINGS (settings), NULL);
+
+ return settings->priv->real_junk_path;
+}
+
+/**
+ * camel_imap_settings_set_real_junk_path:
+ * @settings: a #CamelImapSettings
+ * @real_junk_path: path to a real Junk folder, or %NULL
+ *
+ * Sets the path to a real, non-virtual Junk folder to be used instead of
+ * Camel's standard virtual Junk folder.
+ *
+ * Since: 3.2
+ **/
+void
+camel_imap_settings_set_real_junk_path (CamelImapSettings *settings,
+ const gchar *real_junk_path)
+{
+ g_return_if_fail (CAMEL_IS_IMAP_SETTINGS (settings));
+
+ /* An empty string is equivalent to NULL. */
+ if (real_junk_path != NULL && *real_junk_path == '\0')
+ real_junk_path = NULL;
+
+ g_free (settings->priv->real_junk_path);
+ settings->priv->real_junk_path = g_strdup (real_junk_path);
+
+ g_object_notify (G_OBJECT (settings), "real-junk-path");
+}
+
+/**
+ * camel_imap_settings_get_real_trash_path:
+ * @settings: a #CamelImapSettings
+ *
+ * Returns the path to a real, non-virtual Trash folder to be used instead
+ * of Camel's standard virtual Trash folder.
+ *
+ * Returns: path to a real Trash folder
+ *
+ * Since: 3.2
+ **/
+const gchar *
+camel_imap_settings_get_real_trash_path (CamelImapSettings *settings)
+{
+ g_return_val_if_fail (CAMEL_IS_IMAP_SETTINGS (settings), NULL);
+
+ return settings->priv->real_trash_path;
+}
+
+/**
+ * camel_imap_settings_set_real_trash_path:
+ * @settings: a #CamelImapSettings
+ * @real_trash_path: path to a real Trash folder, or %NULL
+ *
+ * Sets the path to a real, non-virtual Trash folder to be used instead of
+ * Camel's standard virtual Trash folder.
+ *
+ * Since: 3.2
+ **/
+void
+camel_imap_settings_set_real_trash_path (CamelImapSettings *settings,
+ const gchar *real_trash_path)
+{
+ g_return_if_fail (CAMEL_IS_IMAP_SETTINGS (settings));
+
+ /* An empty string is equivalent to NULL. */
+ if (real_trash_path != NULL && *real_trash_path == '\0')
+ real_trash_path = NULL;
+
+ g_free (settings->priv->real_trash_path);
+ settings->priv->real_trash_path = g_strdup (real_trash_path);
+
+ g_object_notify (G_OBJECT (settings), "real-trash-path");
+}
+
+/**
+ * camel_imap_settings_get_shell_command:
+ * @settings: a #CamelImapSettings
+ *
+ * Returns an optional shell command used to establish an input/output
+ * stream with an IMAP server. Normally the input/output stream is
+ * established through a network socket.
+ *
+ * This option is useful only to a select few advanced users who likely
+ * administer their own IMAP server. Most users will not understand what
+ * this option means or how to use it. Probably not worth exposing in a
+ * graphical interface.
+ *
+ * Returns: shell command for connecting to the server, or %NULL
+ *
+ * Since: 3.2
+ **/
+const gchar *
+camel_imap_settings_get_shell_command (CamelImapSettings *settings)
+{
+ g_return_val_if_fail (CAMEL_IS_IMAP_SETTINGS (settings), NULL);
+
+ return settings->priv->shell_command;
+}
+
+/**
+ * camel_imap_settings_set_shell_command:
+ * @settings: a #CamelImapSettings
+ * @shell_command: shell command for connecting to the server, or %NULL
+ *
+ * Sets an optional shell command used to establish an input/output stream
+ * with an IMAP server. Normally the input/output stream is established
+ * through a network socket.
+ *
+ * This option is useful only to a select few advanced users who likely
+ * administer their own IMAP server. Most users will not understand what
+ * this option means or how to use it. Probably not worth exposing in a
+ * graphical interface.
+ *
+ * Since: 3.2
+ **/
+void
+camel_imap_settings_set_shell_command (CamelImapSettings *settings,
+ const gchar *shell_command)
+{
+ g_return_if_fail (CAMEL_IS_IMAP_SETTINGS (settings));
+
+ /* An empty string is equivalent to NULL. */
+ if (shell_command != NULL && *shell_command == '\0')
+ shell_command = NULL;
+
+ g_free (settings->priv->shell_command);
+ settings->priv->shell_command = g_strdup (shell_command);
+
+ g_object_notify (G_OBJECT (settings), "shell-command");
+}
+
+/**
+ * camel_imap_settings_get_use_namespace:
+ * @settings: a #CamelImapSettings
+ *
+ * Returns whether to use a custom IMAP namespace to find folders. The
+ * namespace itself is given by the #CamelImapSettings:namespace property.
+ *
+ * Returns: whether to use a custom IMAP namespace
+ *
+ * Since: 3.2
+ **/
+gboolean
+camel_imap_settings_get_use_namespace (CamelImapSettings *settings)
+{
+ g_return_val_if_fail (CAMEL_IS_IMAP_SETTINGS (settings), FALSE);
+
+ return settings->priv->use_namespace;
+}
+
+/**
+ * camel_imap_settings_set_use_namespace:
+ * @settings: a #CamelImapSettings
+ * @use_namespace: whether to use a custom IMAP namespace
+ *
+ * Sets whether to use a custom IMAP namespace to find folders. The
+ * namespace itself is given by the #CamelImapSettings:namespace property.
+ *
+ * Since: 3.2
+ **/
+void
+camel_imap_settings_set_use_namespace (CamelImapSettings *settings,
+ gboolean use_namespace)
+{
+ g_return_if_fail (CAMEL_IS_IMAP_SETTINGS (settings));
+
+ settings->priv->use_namespace = use_namespace;
+
+ g_object_notify (G_OBJECT (settings), "use-namespace");
+}
+
+/**
+ * camel_imap_settings_get_use_real_junk_path:
+ * @settings: a #CamelImapSettings
+ *
+ * Returns whether to use a real, non-virtual Junk folder instead of Camel's
+ * standard virtual Junk folder.
+ *
+ * Returns: whether to use a real Junk folder
+ *
+ * Since: 3.2
+ **/
+gboolean
+camel_imap_settings_get_use_real_junk_path (CamelImapSettings *settings)
+{
+ g_return_val_if_fail (CAMEL_IS_IMAP_SETTINGS (settings), FALSE);
+
+ return settings->priv->use_real_junk_path;
+}
+
+/**
+ * camel_imap_settings_set_use_real_junk_path:
+ * @settings: a #CamelImapSettings
+ * @use_real_junk_path: whether to use a real Junk folder
+ *
+ * Sets whether to use a real, non-virtual Junk folder instead of Camel's
+ * standard virtual Junk folder.
+ *
+ * Since: 3.2
+ **/
+void
+camel_imap_settings_set_use_real_junk_path (CamelImapSettings *settings,
+ gboolean use_real_junk_path)
+{
+ g_return_if_fail (CAMEL_IS_IMAP_SETTINGS (settings));
+
+ settings->priv->use_real_junk_path = use_real_junk_path;
+
+ g_object_notify (G_OBJECT (settings), "use-real-junk-path");
+}
+
+/**
+ * camel_imap_settings_get_use_real_trash_path:
+ * @settings: a #CamelImapSettings
+ *
+ * Returns whether to use a real, non-virtual Trash folder instead of Camel's
+ * standard virtual Trash folder.
+ *
+ * Returns: whether to use a real Trash folder
+ *
+ * Since: 3.2
+ **/
+gboolean
+camel_imap_settings_get_use_real_trash_path (CamelImapSettings *settings)
+{
+ g_return_val_if_fail (CAMEL_IS_IMAP_SETTINGS (settings), FALSE);
+
+ return settings->priv->use_real_trash_path;
+}
+
+/**
+ * camel_imap_settings_set_use_real_trash_path:
+ * @settings: a #CamelImapSettings
+ * @use_real_trash_path: whether to use a real Trash folder
+ *
+ * Sets whether to use a real, non-virtual Trash folder instead of Camel's
+ * standard virtual Trash folder.
+ *
+ * Since: 3.2
+ **/
+void
+camel_imap_settings_set_use_real_trash_path (CamelImapSettings *settings,
+ gboolean use_real_trash_path)
+{
+ g_return_if_fail (CAMEL_IS_IMAP_SETTINGS (settings));
+
+ settings->priv->use_real_trash_path = use_real_trash_path;
+
+ g_object_notify (G_OBJECT (settings), "use-real-trash-path");
+}
+
+/**
+ * camel_imap_settings_get_use_shell_command:
+ * @settings: a #CamelImapSettings
+ *
+ * Returns whether to use a custom shell command to establish an input/output
+ * stream with an IMAP server, instead of the more common method of opening a
+ * network socket. The shell command itself is given by the
+ * #CamelImapSettings:shell-command property.
+ *
+ * This option is useful only to a select few advanced users who likely
+ * administer their own IMAP server. Most users will not understand what
+ * this option means or how to use it. Probably not worth exposing in a
+ * graphical interface.
+ *
+ * Returns: whether to use a custom shell command to connect to the server
+ *
+ * Since: 3.2
+ **/
+gboolean
+camel_imap_settings_get_use_shell_command (CamelImapSettings *settings)
+{
+ g_return_val_if_fail (CAMEL_IS_IMAP_SETTINGS (settings), FALSE);
+
+ return settings->priv->use_shell_command;
+}
+
+/**
+ * camel_imap_settings_set_use_shell_command:
+ * @settings: a #CamelImapSettings
+ * @use_shell_command: whether to use a custom shell command to connect
+ * to the server
+ *
+ * Sets whether to use a custom shell command to establish an input/output
+ * stream with an IMAP server, instead of the more common method of opening
+ * a network socket. The shell command itself is given by the
+ * #CamelImapSettings:shell-command property.
+ *
+ * This option is useful only to a select few advanced users who likely
+ * administer their own IMAP server. Most users will not understand what
+ * this option means or how to use it. Probably not worth exposing in a
+ * graphical interface.
+ *
+ * Since: 3.2
+ **/
+void
+camel_imap_settings_set_use_shell_command (CamelImapSettings *settings,
+ gboolean use_shell_command)
+{
+ g_return_if_fail (CAMEL_IS_IMAP_SETTINGS (settings));
+
+ settings->priv->use_shell_command = use_shell_command;
+
+ g_object_notify (G_OBJECT (settings), "use-shell-command");
+}
+
+/**
+ * camel_imap_settings_get_use_subscriptions:
+ * @settings: a #CamelImapSettings
+ *
+ * Returns whether to list and operate only on subscribed folders, or to
+ * list and operate on all available folders regardless of subscriptions.
+ *
+ * Returns: whether to honor folder subscriptions
+ *
+ * Since: 3.2
+ **/
+gboolean
+camel_imap_settings_get_use_subscriptions (CamelImapSettings *settings)
+{
+ g_return_val_if_fail (CAMEL_IS_IMAP_SETTINGS (settings), FALSE);
+
+ return settings->priv->use_subscriptions;
+}
+
+/**
+ * camel_imap_settings_set_use_subscriptions:
+ * @settings: a #CamelImapSettings
+ * @use_subscriptions: whether to honor folder subscriptions
+ *
+ * Sets whether to list and operate only on subscribed folders, or to
+ * list and operate on all available folders regardless of subscriptions.
+ *
+ * Since: 3.2
+ **/
+void
+camel_imap_settings_set_use_subscriptions (CamelImapSettings *settings,
+ gboolean use_subscriptions)
+{
+ g_return_if_fail (CAMEL_IS_IMAP_SETTINGS (settings));
+
+ settings->priv->use_subscriptions = use_subscriptions;
+
+ g_object_notify (G_OBJECT (settings), "use-subscriptions");
+}
+
diff --git a/camel/providers/imap/camel-imap-settings.h b/camel/providers/imap/camel-imap-settings.h
new file mode 100644
index 0000000..b02d563
--- /dev/null
+++ b/camel/providers/imap/camel-imap-settings.h
@@ -0,0 +1,140 @@
+/*
+ * camel-imap-settings.h
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) version 3.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with the program; if not, see <http://www.gnu.org/licenses/>
+ *
+ */
+
+#ifndef CAMEL_IMAP_SETTINGS_H
+#define CAMEL_IMAP_SETTINGS_H
+
+#include <camel/camel.h>
+
+/* Standard GObject macros */
+#define CAMEL_TYPE_IMAP_SETTINGS \
+ (camel_imap_settings_get_type ())
+#define CAMEL_IMAP_SETTINGS(obj) \
+ (G_TYPE_CHECK_INSTANCE_CAST \
+ ((obj), CAMEL_TYPE_IMAP_SETTINGS, CamelImapSettings))
+#define CAMEL_IMAP_SETTINGS_CLASS(cls) \
+ (G_TYPE_CHECK_CLASS_CAST \
+ ((cls), CAMEL_TYPE_IMAP_SETTINGS, CamelImapSettingsClass))
+#define CAMEL_IS_IMAP_SETTINGS(obj) \
+ (G_TYPE_CHECK_INSTANCE_TYPE \
+ ((obj), CAMEL_TYPE_IMAP_SETTINGS))
+#define CAMEL_IS_IMAP_SETTINGS_CLASS(cls) \
+ (G_TYPE_CHECK_CLASS_TYPE \
+ ((cls), CAMEL_TYPE_IMAP_SETTINGS))
+#define CAMEL_IMAP_SETTINGS_GET_CLASS(obj) \
+ (G_TYPE_INSTANCE_GET_CLASS \
+ ((obj), CAMEL_TYPE_IMAP_SETTINGS))
+
+G_BEGIN_DECLS
+
+typedef struct _CamelImapSettings CamelImapSettings;
+typedef struct _CamelImapSettingsClass CamelImapSettingsClass;
+typedef struct _CamelImapSettingsPrivate CamelImapSettingsPrivate;
+
+struct _CamelImapSettings {
+ CamelOfflineSettings parent;
+ CamelImapSettingsPrivate *priv;
+};
+
+struct _CamelImapSettingsClass {
+ CamelOfflineSettingsClass parent_class;
+};
+
+GType camel_imap_settings_get_type
+ (void) G_GNUC_CONST;
+gboolean camel_imap_settings_get_check_all
+ (CamelImapSettings *settings);
+void camel_imap_settings_set_check_all
+ (CamelImapSettings *settings,
+ gboolean check_all);
+gboolean camel_imap_settings_get_check_subscribed
+ (CamelImapSettings *settings);
+void camel_imap_settings_set_check_subscribed
+ (CamelImapSettings *settings,
+ gboolean check_subscribed);
+CamelFetchHeadersType
+ camel_imap_settings_get_fetch_headers
+ (CamelImapSettings *settings);
+void camel_imap_settings_set_fetch_headers
+ (CamelImapSettings *settings,
+ CamelFetchHeadersType fetch_headers);
+const gchar * const *
+ camel_imap_settings_get_fetch_headers_extra
+ (CamelImapSettings *settings);
+void camel_imap_settings_set_fetch_headers_extra
+ (CamelImapSettings *settings,
+ const gchar * const *fetch_headers_extra);
+gboolean camel_imap_settings_get_filter_junk
+ (CamelImapSettings *settings);
+void camel_imap_settings_set_filter_junk
+ (CamelImapSettings *settings,
+ gboolean filter_junk);
+gboolean camel_imap_settings_get_filter_junk_inbox
+ (CamelImapSettings *settings);
+void camel_imap_settings_set_filter_junk_inbox
+ (CamelImapSettings *settings,
+ gboolean filter_junk_inbox);
+const gchar * camel_imap_settings_get_namespace
+ (CamelImapSettings *settings);
+void camel_imap_settings_set_namespace
+ (CamelImapSettings *settings,
+ const gchar *namespace_);
+const gchar * camel_imap_settings_get_real_junk_path
+ (CamelImapSettings *settings);
+void camel_imap_settings_set_real_junk_path
+ (CamelImapSettings *settings,
+ const gchar *real_junk_path);
+const gchar * camel_imap_settings_get_real_trash_path
+ (CamelImapSettings *settings);
+void camel_imap_settings_set_real_trash_path
+ (CamelImapSettings *settings,
+ const gchar *real_trash_path);
+const gchar * camel_imap_settings_get_shell_command
+ (CamelImapSettings *settings);
+void camel_imap_settings_set_shell_command
+ (CamelImapSettings *settings,
+ const gchar *shell_command);
+gboolean camel_imap_settings_get_use_namespace
+ (CamelImapSettings *settings);
+void camel_imap_settings_set_use_namespace
+ (CamelImapSettings *settings,
+ gboolean use_namespace);
+gboolean camel_imap_settings_get_use_real_junk_path
+ (CamelImapSettings *settings);
+void camel_imap_settings_set_use_real_junk_path
+ (CamelImapSettings *settings,
+ gboolean use_real_junk_path);
+gboolean camel_imap_settings_get_use_real_trash_path
+ (CamelImapSettings *settings);
+void camel_imap_settings_set_use_real_trash_path
+ (CamelImapSettings *settings,
+ gboolean use_real_trash_path);
+gboolean camel_imap_settings_get_use_shell_command
+ (CamelImapSettings *settings);
+void camel_imap_settings_set_use_shell_command
+ (CamelImapSettings *settings,
+ gboolean use_shell_command);
+gboolean camel_imap_settings_get_use_subscriptions
+ (CamelImapSettings *settings);
+void camel_imap_settings_set_use_subscriptions
+ (CamelImapSettings *settings,
+ gboolean use_subscriptions);
+
+G_END_DECLS
+
+#endif /* CAMEL_IMAP_SETTINGS_H */
diff --git a/camel/providers/imap/camel-imap-store-summary.c b/camel/providers/imap/camel-imap-store-summary.c
index f669158..88ef06f 100644
--- a/camel/providers/imap/camel-imap-store-summary.c
+++ b/camel/providers/imap/camel-imap-store-summary.c
@@ -370,7 +370,9 @@ camel_imap_store_summary_namespace_set_main (CamelImapStoreSummary *s, const gch
CamelImapStoreNamespace *ns;
g_return_if_fail (s != NULL);
- g_return_if_fail (full_name != NULL);
+
+ if (full_name == NULL)
+ full_name = "";
ns = namespace_find (s->namespace, full_name, dir_sep);
diff --git a/camel/providers/imap/camel-imap-store.c b/camel/providers/imap/camel-imap-store.c
index fb4d6da..2dcd896 100644
--- a/camel/providers/imap/camel-imap-store.c
+++ b/camel/providers/imap/camel-imap-store.c
@@ -38,6 +38,7 @@
#include "camel-imap-command.h"
#include "camel-imap-folder.h"
#include "camel-imap-message-cache.h"
+#include "camel-imap-settings.h"
#include "camel-imap-store-summary.h"
#include "camel-imap-store.h"
#include "camel-imap-summary.h"
@@ -110,13 +111,6 @@ static struct {
{ NULL, 0 }
};
-enum {
- PROP_0,
- PROP_DEFAULT_PORT,
- PROP_SECURITY_METHOD,
- PROP_SERVICE_NAME
-};
-
extern CamelServiceAuthType camel_imap_password_authtype;
static GInitableIface *parent_initable_interface;
@@ -209,6 +203,7 @@ connect_to_server (CamelService *service,
GError **error)
{
CamelImapStore *store = (CamelImapStore *) service;
+ CamelSettings *settings;
CamelURL *url;
CamelImapResponse *response;
CamelStream *tcp_stream;
@@ -225,6 +220,9 @@ connect_to_server (CamelService *service,
return FALSE;
url = camel_service_get_camel_url (service);
+ settings = camel_service_get_settings (service);
+
+ g_object_get (settings, "security-method", &method, NULL);
store->ostream = tcp_stream;
store->istream = camel_stream_buffer_new (tcp_stream, CAMEL_STREAM_BUFFER_READ);
@@ -314,9 +312,6 @@ connect_to_server (CamelService *service,
store->server_level = IMAP_LEVEL_IMAP4;
}
- method = camel_network_service_get_security_method (
- CAMEL_NETWORK_SERVICE (service));
-
if (method != CAMEL_NETWORK_SECURITY_METHOD_STARTTLS_ON_STANDARD_PORT)
return TRUE; /* we're done */
@@ -567,18 +562,20 @@ connect_to_server_wrapper (CamelService *service,
GCancellable *cancellable,
GError **error)
{
- CamelURL *url;
-
#ifndef G_OS_WIN32
- const gchar *command;
-#endif
-
- url = camel_service_get_camel_url (service);
-
-#ifndef G_OS_WIN32
- if (camel_url_get_param (url, "use_command")
- && (command = camel_url_get_param (url, "command")))
- return connect_to_server_process (service, command, cancellable, error);
+ CamelSettings *settings;
+ const gchar *shell_command;
+ gboolean use_shell_command;
+
+ settings = camel_service_get_settings (service);
+ shell_command = camel_imap_settings_get_shell_command (
+ CAMEL_IMAP_SETTINGS (settings));
+ use_shell_command = camel_imap_settings_get_use_shell_command (
+ CAMEL_IMAP_SETTINGS (settings));
+
+ if (use_shell_command && shell_command != NULL)
+ return connect_to_server_process (
+ service, shell_command, cancellable, error);
#endif
return connect_to_server (service, cancellable, error);
@@ -806,55 +803,6 @@ free_key (gpointer key, gpointer value, gpointer user_data)
}
static void
-imap_store_set_property (GObject *object,
- guint property_id,
- const GValue *value,
- GParamSpec *pspec)
-{
- switch (property_id) {
- case PROP_SECURITY_METHOD:
- camel_network_service_set_security_method (
- CAMEL_NETWORK_SERVICE (object),
- g_value_get_uint (value));
- return;
- }
-
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
-}
-
-static void
-imap_store_get_property (GObject *object,
- guint property_id,
- GValue *value,
- GParamSpec *pspec)
-{
- switch (property_id) {
- case PROP_DEFAULT_PORT:
- g_value_set_uint (
- value,
- camel_network_service_get_default_port (
- CAMEL_NETWORK_SERVICE (object)));
- return;
-
- case PROP_SECURITY_METHOD:
- g_value_set_uint (
- value,
- camel_network_service_get_security_method (
- CAMEL_NETWORK_SERVICE (object)));
- return;
-
- case PROP_SERVICE_NAME:
- g_value_set_string (
- value,
- camel_network_service_get_service_name (
- CAMEL_NETWORK_SERVICE (object)));
- return;
- }
-
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
-}
-
-static void
imap_store_dispose (GObject *object)
{
CamelImapStore *imap_store = CAMEL_IMAP_STORE (object);
@@ -879,41 +827,11 @@ imap_store_finalize (GObject *object)
camel_service_disconnect_sync (CAMEL_SERVICE (imap_store), TRUE, NULL);
g_free (imap_store->base_url);
- g_free (imap_store->users_namespace);
- g_free (imap_store->custom_headers);
- g_free (imap_store->real_trash_path);
- g_free (imap_store->real_junk_path);
/* Chain up to parent's finalize() method. */
G_OBJECT_CLASS (camel_imap_store_parent_class)->finalize (object);
}
-static void
-imap_store_constructed (GObject *object)
-{
- CamelURL *url;
- const gchar *use_ssl;
-
- /* Chain up to parent's constructed() method. */
- G_OBJECT_CLASS (camel_imap_store_parent_class)->constructed (object);
-
- url = camel_service_get_camel_url (CAMEL_SERVICE (object));
- use_ssl = camel_url_get_param (url, "use_ssl");
-
- if (g_strcmp0 (use_ssl, "never") == 0)
- camel_network_service_set_security_method (
- CAMEL_NETWORK_SERVICE (object),
- CAMEL_NETWORK_SECURITY_METHOD_NONE);
- else if (g_strcmp0 (use_ssl, "always") == 0)
- camel_network_service_set_security_method (
- CAMEL_NETWORK_SERVICE (object),
- CAMEL_NETWORK_SECURITY_METHOD_SSL_ON_ALTERNATE_PORT);
- else if (g_strcmp0 (use_ssl, "when-possible") == 0)
- camel_network_service_set_security_method (
- CAMEL_NETWORK_SERVICE (object),
- CAMEL_NETWORK_SECURITY_METHOD_STARTTLS_ON_STANDARD_PORT);
-}
-
static gchar *
imap_store_get_name (CamelService *service,
gboolean brief)
@@ -938,10 +856,16 @@ imap_store_connect_sync (CamelService *service,
{
CamelImapStore *store = CAMEL_IMAP_STORE (service);
CamelImapResponse *response;
+ CamelSettings *settings;
+ CamelImapSettings *imap_settings;
gchar *result, *name;
gsize len;
+ const gchar *namespace;
GError *local_error = NULL;
+ settings = camel_service_get_settings (service);
+ imap_settings = CAMEL_IMAP_SETTINGS (settings);
+
if (!camel_offline_store_get_online (CAMEL_OFFLINE_STORE (store)))
return TRUE;
@@ -956,6 +880,7 @@ imap_store_connect_sync (CamelService *service,
/* Get namespace and hierarchy separator */
if (store->capabilities & IMAP_CAPABILITY_NAMESPACE) {
struct _namespaces *namespaces;
+ const gchar *namespace;
response = camel_imap_command (store, NULL, cancellable, &local_error, "NAMESPACE");
if (!response)
@@ -967,12 +892,12 @@ imap_store_connect_sync (CamelService *service,
namespaces = imap_parse_namespace_response (result);
- if (!(store->parameters & IMAP_PARAM_OVERRIDE_NAMESPACE)) {
- g_free (store->users_namespace);
- store->users_namespace = NULL;
- }
+ if (!camel_imap_settings_get_use_namespace (imap_settings))
+ camel_imap_settings_set_namespace (imap_settings, NULL);
+
+ namespace = camel_imap_settings_get_namespace (imap_settings);
- if (namespaces && !store->users_namespace) {
+ if (namespaces != NULL && namespace == NULL) {
struct _namespace *np = NULL;
if (namespaces->personal)
@@ -982,9 +907,9 @@ imap_store_connect_sync (CamelService *service,
else if (namespaces->shared)
np = namespaces->shared;
- if (np) {
- store->users_namespace = g_strdup (np->prefix);
- }
+ if (np != NULL)
+ camel_imap_settings_set_namespace (
+ imap_settings, np->prefix);
}
if (namespaces) {
@@ -1008,14 +933,20 @@ imap_store_connect_sync (CamelService *service,
imap_namespaces_destroy (namespaces);
- if (!store->users_namespace) {
+ if (camel_imap_settings_get_namespace (imap_settings) == NULL) {
/* fallback for a broken result */
name = camel_strstrcase (result, "NAMESPACE ((");
if (name) {
+ gchar *ns;
gchar *sep;
name += 12;
- store->users_namespace = imap_parse_string ((const gchar **) &name, &len);
+ ns = imap_parse_string (
+ (const gchar **) &name, &len);
+ camel_imap_settings_set_namespace (
+ imap_settings, ns);
+ g_free (ns);
+
if (name && *name++ == ' ') {
sep = imap_parse_string ((const gchar **) &name, &len);
if (sep) {
@@ -1028,30 +959,34 @@ imap_store_connect_sync (CamelService *service,
g_free (result);
}
- if (!store->users_namespace)
- store->users_namespace = g_strdup ("");
-
if (!store->dir_sep) {
- const gchar *use_namespace = store->summary->namespace ? store->summary->namespace->full_name : NULL;
+ const gchar *use_namespace = NULL;
+
+ if (store->summary->namespace != NULL)
+ use_namespace = store->summary->namespace->full_name;
- if (!use_namespace)
- use_namespace = store->users_namespace;
+ if (use_namespace == NULL)
+ use_namespace = camel_imap_settings_get_namespace (
+ imap_settings);
+
+ if (use_namespace == NULL)
+ use_namespace = "";
if (store->server_level >= IMAP_LEVEL_IMAP4REV1) {
/* This idiom means "tell me the hierarchy separator
* for the given path, even if that path doesn't exist.
*/
- response = camel_imap_command (store, NULL, cancellable, &local_error,
- "LIST %G \"\"",
- use_namespace);
+ response = camel_imap_command (
+ store, NULL, cancellable, &local_error,
+ "LIST %G \"\"", use_namespace);
} else {
/* Plain IMAP4 doesn't have that idiom, so we fall back
* to "tell me about this folder", which will fail if
* the folder doesn't exist (eg, if namespace is "").
*/
- response = camel_imap_command (store, NULL, cancellable, &local_error,
- "LIST \"\" %G",
- use_namespace);
+ response = camel_imap_command (
+ store, NULL, cancellable, &local_error,
+ "LIST \"\" %G", use_namespace);
}
if (!response)
goto done;
@@ -1068,14 +1003,21 @@ imap_store_connect_sync (CamelService *service,
}
/* canonicalize the namespace to not end with dir_sep */
- len = strlen (store->users_namespace);
- if (len && store->users_namespace[len - 1] == store->dir_sep)
- store->users_namespace[len - 1] = 0;
+ namespace = camel_imap_settings_get_namespace (imap_settings);
+ len = (namespace != NULL) ? strlen (namespace) : 0;
+ if (len && namespace[len - 1] == store->dir_sep) {
+ gchar *tmp = g_strdup (namespace);
+ tmp[len - 1] = '\0';
+ camel_imap_settings_set_namespace (imap_settings, tmp);
+ namespace = camel_imap_settings_get_namespace (imap_settings);
+ g_free (tmp);
+ }
- camel_imap_store_summary_namespace_set_main (store->summary, store->users_namespace, store->dir_sep);
+ camel_imap_store_summary_namespace_set_main (
+ store->summary, namespace, store->dir_sep);
- if ((store->parameters & IMAP_PARAM_SUBSCRIPTIONS)
- && camel_store_summary_count ((CamelStoreSummary *) store->summary) == 0) {
+ if (camel_imap_settings_get_use_subscriptions (imap_settings) &&
+ camel_store_summary_count ((CamelStoreSummary *) store->summary) == 0) {
CamelStoreInfo *si;
/* look in all namespaces */
@@ -1121,6 +1063,11 @@ imap_store_disconnect_sync (CamelService *service,
GError **error)
{
CamelImapStore *store = CAMEL_IMAP_STORE (service);
+ CamelSettings *settings;
+ CamelImapSettings *imap_settings;
+
+ settings = camel_service_get_settings (service);
+ imap_settings = CAMEL_IMAP_SETTINGS (settings);
if (camel_offline_store_get_online (CAMEL_OFFLINE_STORE (store)) && clean) {
CamelImapResponse *response;
@@ -1154,10 +1101,8 @@ imap_store_disconnect_sync (CamelService *service,
store->authtypes = NULL;
}
- if (store->users_namespace && !(store->parameters & IMAP_PARAM_OVERRIDE_NAMESPACE)) {
- g_free (store->users_namespace);
- store->users_namespace = NULL;
- }
+ if (camel_imap_settings_get_use_namespace (imap_settings))
+ camel_imap_settings_set_namespace (imap_settings, NULL);
return TRUE;
}
@@ -1210,9 +1155,12 @@ imap_store_initable_init (GInitable *initable,
{
CamelImapStore *imap_store;
CamelService *service;
+ CamelSettings *settings;
CamelURL *summary_url;
CamelURL *url;
const gchar *user_data_dir;
+ const gchar *real_path;
+ gboolean use_real_path;
gchar *tmp;
imap_store = CAMEL_IMAP_STORE (initable);
@@ -1223,6 +1171,7 @@ imap_store_initable_init (GInitable *initable,
service = CAMEL_SERVICE (initable);
url = camel_service_get_camel_url (service);
+ settings = camel_service_get_settings (service);
user_data_dir = camel_service_get_user_data_dir (service);
/* FIXME */
@@ -1230,53 +1179,33 @@ imap_store_initable_init (GInitable *initable,
url, CAMEL_URL_HIDE_PASSWORD |
CAMEL_URL_HIDE_PARAMS | CAMEL_URL_HIDE_AUTH);
- imap_store->parameters = 0;
- if (camel_url_get_param (url, "use_lsub"))
- imap_store->parameters |= IMAP_PARAM_SUBSCRIPTIONS;
- if (camel_url_get_param (url, "override_namespace") && camel_url_get_param (url, "namespace")) {
- imap_store->parameters |= IMAP_PARAM_OVERRIDE_NAMESPACE;
- g_free (imap_store->users_namespace);
- imap_store->users_namespace = g_strdup (camel_url_get_param (url, "namespace"));
- }
- if (camel_url_get_param (url, "check_all"))
- imap_store->parameters |= IMAP_PARAM_CHECK_ALL;
- if (camel_url_get_param (url, "check_lsub"))
- imap_store->parameters |= IMAP_PARAM_CHECK_LSUB;
- if (camel_url_get_param (url, "filter_junk"))
- imap_store->parameters |= IMAP_PARAM_FILTER_JUNK;
- if (camel_url_get_param (url, "filter_junk_inbox"))
- imap_store->parameters |= IMAP_PARAM_FILTER_JUNK_INBOX;
-
- imap_store->headers = IMAP_FETCH_MAILING_LIST_HEADERS;
- if (camel_url_get_param (url, "all_headers"))
- imap_store->headers = IMAP_FETCH_ALL_HEADERS;
- else if (camel_url_get_param (url, "basic_headers"))
- imap_store->headers = IMAP_FETCH_MINIMAL_HEADERS;
-
- if (camel_url_get_param (url, "imap_custom_headers")) {
- imap_store->custom_headers = g_strdup(camel_url_get_param (url, "imap_custom_headers"));
- }
+ /* XXX Using CamelStoreFlags like this is suboptimal because they're
+ * only set once during initialization. Subsequent changes to the
+ * CamelSettings are not propagated to the flags -- a restart
+ * is required. Probably should define interfaces for this. */
- imap_store->real_trash_path = g_strdup (camel_url_get_param (url, "real_trash_path"));
- imap_store->real_junk_path = g_strdup (camel_url_get_param (url, "real_junk_path"));
+ real_path = camel_imap_settings_get_real_junk_path (
+ CAMEL_IMAP_SETTINGS (settings));
+ use_real_path = camel_imap_settings_get_use_real_junk_path (
+ CAMEL_IMAP_SETTINGS (settings));
- if (imap_store->real_trash_path && !*imap_store->real_trash_path) {
- g_free (imap_store->real_trash_path);
- imap_store->real_trash_path = NULL;
+ if (use_real_path && real_path != NULL) {
+ CAMEL_STORE (service)->flags &= ~CAMEL_STORE_VJUNK;
+ CAMEL_STORE (service)->flags |= CAMEL_STORE_REAL_JUNK_FOLDER;
+ } else {
+ CAMEL_STORE (service)->flags &= CAMEL_STORE_REAL_JUNK_FOLDER;
+ CAMEL_STORE (service)->flags |= CAMEL_STORE_VJUNK;
}
- if (imap_store->real_trash_path && *imap_store->real_trash_path)
- CAMEL_STORE (imap_store)->flags &= ~CAMEL_STORE_VTRASH;
-
- if (imap_store->real_junk_path && !*imap_store->real_junk_path) {
- g_free (imap_store->real_junk_path);
- imap_store->real_junk_path = NULL;
- }
+ real_path = camel_imap_settings_get_real_trash_path (
+ CAMEL_IMAP_SETTINGS (settings));
+ use_real_path = camel_imap_settings_get_use_real_trash_path (
+ CAMEL_IMAP_SETTINGS (settings));
- if (imap_store->real_junk_path && *imap_store->real_junk_path) {
- CAMEL_STORE (imap_store)->flags &= ~CAMEL_STORE_VJUNK;
- CAMEL_STORE (imap_store)->flags |= CAMEL_STORE_REAL_JUNK_FOLDER;
- }
+ if (use_real_path && real_path != NULL)
+ CAMEL_STORE (service)->flags &= ~CAMEL_STORE_VTRASH;
+ else
+ CAMEL_STORE (service)->flags |= CAMEL_STORE_VTRASH;
/* setup/load the store summary */
tmp = alloca (strlen (user_data_dir) + 32);
@@ -1290,10 +1219,14 @@ imap_store_initable_init (GInitable *initable,
CamelImapStoreSummary *is = imap_store->summary;
if (is->namespace) {
+ const gchar *namespace;
+
+ namespace = camel_imap_settings_get_namespace (
+ CAMEL_IMAP_SETTINGS (settings));
+
/* if namespace has changed, clear folder list */
- if (imap_store->users_namespace && strcmp (imap_store->users_namespace, is->namespace->full_name) != 0) {
+ if (g_strcmp0 (namespace, is->namespace->full_name) != 0)
camel_store_summary_clear ((CamelStoreSummary *) is);
- }
}
imap_store->capabilities = is->capabilities;
@@ -1304,13 +1237,11 @@ imap_store_initable_init (GInitable *initable,
}
static const gchar *
-imap_store_get_service_name (CamelNetworkService *service)
+imap_store_get_service_name (CamelNetworkService *service,
+ CamelNetworkSecurityMethod method)
{
- CamelNetworkSecurityMethod method;
const gchar *service_name;
- method = camel_network_service_get_security_method (service);
-
switch (method) {
case CAMEL_NETWORK_SECURITY_METHOD_SSL_ON_ALTERNATE_PORT:
service_name = "imaps";
@@ -1325,13 +1256,11 @@ imap_store_get_service_name (CamelNetworkService *service)
}
static guint16
-imap_store_get_default_port (CamelNetworkService *service)
+imap_store_get_default_port (CamelNetworkService *service,
+ CamelNetworkSecurityMethod method)
{
- CamelNetworkSecurityMethod method;
guint16 default_port;
- method = camel_network_service_get_security_method (service);
-
switch (method) {
case CAMEL_NETWORK_SECURITY_METHOD_SSL_ON_ALTERNATE_PORT:
default_port = IMAPS_PORT;
@@ -1353,13 +1282,11 @@ camel_imap_store_class_init (CamelImapStoreClass *class)
CamelStoreClass *store_class;
object_class = G_OBJECT_CLASS (class);
- object_class->set_property = imap_store_set_property;
- object_class->get_property = imap_store_get_property;
object_class->dispose = imap_store_dispose;
object_class->finalize = imap_store_finalize;
- object_class->constructed = imap_store_constructed;
service_class = CAMEL_SERVICE_CLASS (class);
+ service_class->settings_type = CAMEL_TYPE_IMAP_SETTINGS;
service_class->get_name = imap_store_get_name;
service_class->connect_sync = imap_store_connect_sync;
service_class->disconnect_sync = imap_store_disconnect_sync;
@@ -1381,24 +1308,6 @@ camel_imap_store_class_init (CamelImapStoreClass *class)
store_class->subscribe_folder_sync = imap_store_subscribe_folder_sync;
store_class->unsubscribe_folder_sync = imap_store_unsubscribe_folder_sync;
store_class->noop_sync = imap_store_noop_sync;
-
- /* Inherited from CamelNetworkService. */
- g_object_class_override_property (
- object_class,
- PROP_DEFAULT_PORT,
- "default-port");
-
- /* Inherited from CamelNetworkService. */
- g_object_class_override_property (
- object_class,
- PROP_SECURITY_METHOD,
- "security-method");
-
- /* Inherited from CamelNetworkService. */
- g_object_class_override_property (
- object_class,
- PROP_SERVICE_NAME,
- "service-name");
}
static void
@@ -1651,18 +1560,24 @@ imap_store_get_trash_folder_sync (CamelStore *store,
GCancellable *cancellable,
GError **error)
{
+ CamelService *service;
+ CamelSettings *settings;
CamelFolder *folder = NULL;
- CamelImapStore *imap_store = CAMEL_IMAP_STORE (store);
+ const gchar *trash_path;
+ const gchar *user_data_dir;
+
+ service = CAMEL_SERVICE (store);
+ settings = camel_service_get_settings (service);
+ user_data_dir = camel_service_get_user_data_dir (service);
- if (imap_store->real_trash_path && *imap_store->real_trash_path) {
+ trash_path = camel_imap_settings_get_real_trash_path (
+ CAMEL_IMAP_SETTINGS (settings));
+ if (trash_path != NULL) {
folder = camel_store_get_folder_sync (
- store, imap_store->real_trash_path, 0,
- cancellable, NULL);
- if (!folder) {
- /* cannot find configured folder, just report on console and unset in a store structure to not try again */
- g_free (imap_store->real_trash_path);
- imap_store->real_trash_path = NULL;
- }
+ store, trash_path, 0, cancellable, NULL);
+ if (folder == NULL)
+ camel_imap_settings_set_real_trash_path (
+ CAMEL_IMAP_SETTINGS (settings), NULL);
}
if (folder)
@@ -1673,13 +1588,8 @@ imap_store_get_trash_folder_sync (CamelStore *store,
if (folder) {
CamelObject *object = CAMEL_OBJECT (folder);
- CamelService *service;
- const gchar *user_data_dir;
gchar *state;
- service = CAMEL_SERVICE (store);
- user_data_dir = camel_service_get_user_data_dir (service);
-
state = g_build_filename (
user_data_dir, "system", "Trash.cmeta", NULL);
@@ -1697,18 +1607,24 @@ imap_store_get_junk_folder_sync (CamelStore *store,
GCancellable *cancellable,
GError **error)
{
+ CamelService *service;
+ CamelSettings *settings;
CamelFolder *folder = NULL;
- CamelImapStore *imap_store = CAMEL_IMAP_STORE (store);
+ const gchar *junk_path;
+ const gchar *user_data_dir;
+
+ service = CAMEL_SERVICE (store);
+ settings = camel_service_get_settings (service);
+ user_data_dir = camel_service_get_user_data_dir (service);
- if (imap_store->real_junk_path && *imap_store->real_junk_path) {
+ junk_path = camel_imap_settings_get_real_junk_path (
+ CAMEL_IMAP_SETTINGS (settings));
+ if (junk_path != NULL) {
folder = camel_store_get_folder_sync (
- store, imap_store->real_junk_path, 0,
- cancellable, NULL);
- if (!folder) {
- /* cannot find configured folder, just report on console and unset in a store structure to not try again */
- g_free (imap_store->real_junk_path);
- imap_store->real_junk_path = NULL;
- }
+ store, junk_path, 0, cancellable, NULL);
+ if (folder == NULL)
+ camel_imap_settings_set_real_junk_path (
+ CAMEL_IMAP_SETTINGS (settings), NULL);
}
if (folder)
@@ -1719,13 +1635,8 @@ imap_store_get_junk_folder_sync (CamelStore *store,
if (folder) {
CamelObject *object = CAMEL_OBJECT (folder);
- CamelService *service;
- const gchar *user_data_dir;
gchar *state;
- service = CAMEL_SERVICE (store);
- user_data_dir = camel_service_get_user_data_dir (service);
-
state = g_build_filename (
user_data_dir, "system", "Junk.cmeta", NULL);
@@ -2265,13 +2176,19 @@ imap_store_rename_folder_sync (CamelStore *store,
CamelImapStore *imap_store = CAMEL_IMAP_STORE (store);
CamelImapResponse *response;
CamelService *service;
+ CamelSettings *settings;
const gchar *user_data_dir;
gchar *oldpath, *newpath, *storage_path;
+ gboolean use_subscriptions;
gboolean success = TRUE;
service = CAMEL_SERVICE (store);
+ settings = camel_service_get_settings (service);
user_data_dir = camel_service_get_user_data_dir (service);
+ use_subscriptions = camel_imap_settings_get_use_subscriptions (
+ CAMEL_IMAP_SETTINGS (settings));
+
camel_service_lock (service, CAMEL_SERVICE_REC_CONNECT_LOCK);
if (!camel_imap_store_connected (imap_store, error)) {
@@ -2295,13 +2212,13 @@ imap_store_rename_folder_sync (CamelStore *store,
imap_store->current_folder = NULL;
imap_store->renaming = TRUE;
- if (imap_store->parameters & IMAP_PARAM_SUBSCRIPTIONS)
+ if (use_subscriptions)
manage_subscriptions (
store, old_name, FALSE, cancellable);
response = camel_imap_command (imap_store, NULL, cancellable, error, "RENAME %F %F", old_name, new_name_in);
if (!response) {
- if (imap_store->parameters & IMAP_PARAM_SUBSCRIPTIONS)
+ if (use_subscriptions)
manage_subscriptions (
store, old_name, TRUE, cancellable);
success = FALSE;
@@ -2313,7 +2230,7 @@ imap_store_rename_folder_sync (CamelStore *store,
/* rename summary, and handle broken server */
rename_folder_info (imap_store, old_name, new_name_in);
- if (imap_store->parameters & IMAP_PARAM_SUBSCRIPTIONS)
+ if (use_subscriptions)
manage_subscriptions (
store, new_name_in, TRUE, cancellable);
@@ -2814,13 +2731,23 @@ refresh_refresh (CamelSession *session,
CamelImapStore *store,
GError **error)
{
+ CamelService *service;
+ CamelSettings *settings;
+ const gchar *namespace;
+
+ service = CAMEL_SERVICE (store);
+ settings = camel_service_get_settings (service);
+
+ namespace = camel_imap_settings_get_namespace (
+ CAMEL_IMAP_SETTINGS (settings));
+
camel_service_lock (
CAMEL_SERVICE (store), CAMEL_SERVICE_REC_CONNECT_LOCK);
if (!camel_imap_store_connected (store, error))
goto done;
- if (store->users_namespace && store->users_namespace[0]) {
+ if (namespace != NULL) {
if (!get_folders_sync (store, "INBOX", cancellable, error))
goto done;
} else {
@@ -2947,14 +2874,39 @@ get_folder_info_offline (CamelStore *store, const gchar *top,
CamelImapStore *imap_store = CAMEL_IMAP_STORE (store);
gboolean include_inbox = FALSE;
CamelFolderInfo *fi;
+ CamelService *service;
+ CamelSettings *settings;
GPtrArray *folders;
gchar *pattern, *name;
gint i;
CamelImapStoreNamespace *main_ns, *ns;
+ gboolean use_subscriptions;
+ const gchar *junk_path;
+ const gchar *trash_path;
if (camel_debug("imap:folder_info"))
printf("get folder info offline\n");
+ service = CAMEL_SERVICE (store);
+ settings = camel_service_get_settings (service);
+
+ use_subscriptions = camel_imap_settings_get_use_subscriptions (
+ CAMEL_IMAP_SETTINGS (settings));
+
+ junk_path = camel_imap_settings_get_real_junk_path (
+ CAMEL_IMAP_SETTINGS (settings));
+
+ /* So we can safely compare strings. */
+ if (junk_path == NULL)
+ junk_path = "";
+
+ trash_path = camel_imap_settings_get_real_trash_path (
+ CAMEL_IMAP_SETTINGS (settings));
+
+ /* So we can safely compare strings. */
+ if (trash_path == NULL)
+ trash_path = "";
+
/* FIXME: obey other flags */
folders = g_ptr_array_new ();
@@ -2984,6 +2936,8 @@ get_folder_info_offline (CamelStore *store, const gchar *top,
for (i=0;i<camel_store_summary_count ((CamelStoreSummary *) imap_store->summary);i++) {
CamelStoreInfo *si = camel_store_summary_index ((CamelStoreSummary *) imap_store->summary, i);
const gchar *full_name;
+ gboolean folder_is_junk;
+ gboolean folder_is_trash;
if (si == NULL)
continue;
@@ -3000,7 +2954,7 @@ get_folder_info_offline (CamelStore *store, const gchar *top,
|| imap_match_pattern (ns, pattern, full_name)
|| (include_inbox && !g_ascii_strcasecmp (full_name, "INBOX")))
&& ((ns == main_ns &&
- ((imap_store->parameters & IMAP_PARAM_SUBSCRIPTIONS) == 0
+ (!use_subscriptions
|| (flags & CAMEL_STORE_FOLDER_INFO_SUBSCRIBED) == 0))
|| (si->flags & CAMEL_STORE_INFO_FOLDER_SUBSCRIBED)
|| (flags & CAMEL_STORE_FOLDER_INFO_SUBSCRIPTION_LIST) != 0)) {
@@ -3019,16 +2973,21 @@ get_folder_info_offline (CamelStore *store, const gchar *top,
if (!g_ascii_strcasecmp(fi->full_name, "inbox"))
fi->flags = (fi->flags & ~CAMEL_FOLDER_TYPE_MASK) | CAMEL_FOLDER_TYPE_INBOX;
- if ((fi->flags & CAMEL_FOLDER_TYPE_MASK) == 0 &&
- imap_store->real_trash_path && *imap_store->real_trash_path &&
- g_ascii_strcasecmp (fi->full_name, imap_store->real_trash_path) == 0) {
- fi->flags = (fi->flags & ~CAMEL_FOLDER_TYPE_MASK) | CAMEL_FOLDER_TYPE_TRASH;
+ folder_is_trash =
+ (fi->flags & CAMEL_FOLDER_TYPE_MASK) == 0 &&
+ g_ascii_strcasecmp (fi->full_name, trash_path) == 0;
+ if (folder_is_trash) {
+ fi->flags &= ~CAMEL_FOLDER_TYPE_MASK;
+ fi->flags |= CAMEL_FOLDER_TYPE_TRASH;
}
- if ((fi->flags & CAMEL_FOLDER_TYPE_MASK) == 0 &&
- imap_store->real_junk_path && *imap_store->real_junk_path &&
- g_ascii_strcasecmp (fi->full_name, imap_store->real_junk_path) == 0) {
- fi->flags = (fi->flags & ~CAMEL_FOLDER_TYPE_MASK) | CAMEL_FOLDER_TYPE_JUNK;
+ folder_is_junk =
+ (fi->flags & CAMEL_FOLDER_TYPE_MASK) == 0 &&
+ g_ascii_strcasecmp (fi->full_name, junk_path) == 0;
+
+ if (folder_is_junk) {
+ fi->flags &= ~CAMEL_FOLDER_TYPE_MASK;
+ fi->flags |= CAMEL_FOLDER_TYPE_JUNK;
}
if (!(si->flags & CAMEL_FOLDER_NOSELECT))
@@ -3277,17 +3236,28 @@ imap_can_refresh_folder (CamelStore *store,
CamelFolderInfo *info,
GError **error)
{
- CamelURL *url;
+ CamelService *service;
+ CamelSettings *settings;
gboolean res;
+ gboolean check_all;
+ gboolean check_subscribed;
+ gboolean subscribed;
GError *local_error = NULL;
- url = camel_service_get_camel_url (CAMEL_SERVICE (store));
+ service = CAMEL_SERVICE (store);
+ settings = camel_service_get_settings (service);
+
+ check_all = camel_imap_settings_get_check_all (
+ CAMEL_IMAP_SETTINGS (settings));
+
+ check_subscribed = camel_imap_settings_get_check_subscribed (
+ CAMEL_IMAP_SETTINGS (settings));
+
+ subscribed = ((info->flags & CAMEL_FOLDER_SUBSCRIBED) != 0);
res = CAMEL_STORE_CLASS (camel_imap_store_parent_class)->
can_refresh_folder (store, info, &local_error) ||
- (camel_url_get_param (url, "check_all") != NULL) ||
- (camel_url_get_param (url, "check_lsub") != NULL &&
- (info->flags & CAMEL_FOLDER_SUBSCRIBED) != 0);
+ check_all || (check_subscribed && subscribed);
if (!res && local_error == NULL && CAMEL_IS_IMAP_STORE (store)) {
CamelStoreInfo *si;
diff --git a/camel/providers/imap/camel-imap-store.h b/camel/providers/imap/camel-imap-store.h
index 17d4524..98ba492 100644
--- a/camel/providers/imap/camel-imap-store.h
+++ b/camel/providers/imap/camel-imap-store.h
@@ -50,6 +50,7 @@ G_BEGIN_DECLS
typedef struct _CamelImapStore CamelImapStore;
typedef struct _CamelImapStoreClass CamelImapStoreClass;
+typedef struct _CamelImapStorePrivate CamelImapStorePrivate;
/* CamelFolderInfo flags */
#define CAMEL_IMAP_FOLDER_MARKED (1 << 16)
@@ -75,19 +76,9 @@ typedef enum {
#define IMAP_CAPABILITY_LOGINDISABLED (1 << 11)
#define IMAP_CAPABILITY_QUOTA (1 << 12)
-#define IMAP_PARAM_OVERRIDE_NAMESPACE (1 << 0)
-#define IMAP_PARAM_CHECK_ALL (1 << 1)
-#define IMAP_PARAM_FILTER_JUNK (1 << 2)
-#define IMAP_PARAM_FILTER_JUNK_INBOX (1 << 3)
-#define IMAP_PARAM_SUBSCRIPTIONS (1 << 4)
-#define IMAP_PARAM_CHECK_LSUB (1 << 5) /* check for new messages in subscribed folders */
-
-#define IMAP_FETCH_ALL_HEADERS 1
-#define IMAP_FETCH_MAILING_LIST_HEADERS 2 /* Fetches Minimal and Mailing List Headers. Default behavior */
-#define IMAP_FETCH_MINIMAL_HEADERS 3
-
struct _CamelImapStore {
CamelOfflineStore parent;
+ CamelImapStorePrivate *priv;
CamelStream *istream;
CamelStream *ostream;
@@ -110,16 +101,11 @@ struct _CamelImapStore {
/* Information about the server */
CamelImapServerLevel server_level;
- guint32 capabilities, parameters;
- gchar *users_namespace, dir_sep, *base_url;
+ guint32 capabilities;
+ gchar dir_sep, *base_url;
GHashTable *authtypes;
time_t refresh_stamp;
-
- guint32 headers;
- gchar *custom_headers;
-
- gchar *real_trash_path, *real_junk_path;
};
struct _CamelImapStoreClass {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]