[evolution-data-server/wip/camel-more-gobject] Seal CamelStore properties
- From: Milan Crha <mcrha src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evolution-data-server/wip/camel-more-gobject] Seal CamelStore properties
- Date: Tue, 1 Nov 2016 22:09:22 +0000 (UTC)
commit ffb0582137cb720f686c9fd6f95ba44b764ebcc4
Author: Milan Crha <mcrha redhat com>
Date: Tue Nov 1 23:09:06 2016 +0100
Seal CamelStore properties
src/camel/camel-folder-search.c | 4 +-
src/camel/camel-folder-summary.c | 40 ++--
src/camel/camel-folder.c | 4 +-
src/camel/camel-object-bag.c | 2 +-
src/camel/camel-offline-store.c | 9 +-
src/camel/camel-store.c | 306 +++++++++++++++------
src/camel/camel-store.h | 30 +--
src/camel/camel-subscribable.c | 43 +---
src/camel/camel-vee-store.c | 18 +-
src/camel/camel-vee-summary.c | 2 +-
src/camel/providers/imapx/camel-imapx-folder.c | 2 +-
src/camel/providers/imapx/camel-imapx-server.c | 2 +-
src/camel/providers/imapx/camel-imapx-store.c | 34 ++-
src/camel/providers/imapx/camel-imapx-summary.c | 2 +-
src/camel/providers/local/camel-local-store.c | 2 +-
src/camel/providers/local/camel-maildir-store.c | 2 +-
src/camel/providers/local/camel-maildir-summary.c | 2 +-
src/camel/providers/local/camel-mbox-store.c | 4 +-
src/camel/providers/local/camel-mbox-summary.c | 8 +-
src/camel/providers/local/camel-mh-store.c | 2 +-
src/camel/providers/local/camel-mh-summary.c | 2 +-
src/camel/providers/local/camel-spool-store.c | 5 +-
src/camel/providers/local/camel-spool-summary.c | 2 +-
src/camel/providers/nntp/camel-nntp-store.c | 4 +-
src/camel/providers/nntp/camel-nntp-summary.c | 5 +-
25 files changed, 314 insertions(+), 222 deletions(-)
---
diff --git a/src/camel/camel-folder-search.c b/src/camel/camel-folder-search.c
index bda0ce6..16067dd 100644
--- a/src/camel/camel-folder-search.c
+++ b/src/camel/camel-folder-search.c
@@ -1968,7 +1968,7 @@ camel_folder_search_count (CamelFolderSearch *search,
g_free (sql_query);
dd (printf ("Equivalent sql %s\n", tmp));
- cdb = (CamelDB *) (parent_store->cdb_r);
+ cdb = camel_store_get_db (parent_store);
camel_db_count_message_info (cdb, tmp, &count, &local_error);
if (local_error != NULL) {
const gchar *message = local_error->message;
@@ -2143,7 +2143,7 @@ camel_folder_search_search (CamelFolderSearch *search,
dd (printf ("Equivalent sql %s\n", tmp));
matches = g_ptr_array_new ();
- cdb = (CamelDB *) (parent_store->cdb_r);
+ cdb = camel_store_get_db (parent_store);
camel_db_select (
cdb, tmp, (CamelDBSelectCB)
read_uid_callback, matches, &local_error);
diff --git a/src/camel/camel-folder-summary.c b/src/camel/camel-folder-summary.c
index f520824..abe7eef 100644
--- a/src/camel/camel-folder-summary.c
+++ b/src/camel/camel-folder-summary.c
@@ -461,14 +461,14 @@ summary_header_to_db (CamelFolderSummary *summary,
{
CamelFIRecord *record = g_new0 (CamelFIRecord, 1);
CamelStore *parent_store;
- CamelDB *db;
+ CamelDB *cdb;
const gchar *table_name;
/* Though we are going to read, we do this during write,
* so lets use it that way. */
table_name = camel_folder_get_full_name (summary->priv->folder);
parent_store = camel_folder_get_parent_store (summary->priv->folder);
- db = parent_store ? parent_store->cdb_w : NULL;
+ cdb = parent_store ? camel_store_get_db (parent_store) : NULL;
io (printf ("Savining header to db\n"));
@@ -480,19 +480,19 @@ summary_header_to_db (CamelFolderSummary *summary,
record->nextuid = summary->priv->nextuid;
record->time = summary->time;
- if (db && !is_in_memory_summary (summary)) {
+ if (cdb && !is_in_memory_summary (summary)) {
/* FIXME: Ever heard of Constructors and initializing ? */
- if (camel_db_count_total_message_info (db, table_name, &(record->saved_count), NULL))
+ if (camel_db_count_total_message_info (cdb, table_name, &(record->saved_count), NULL))
record->saved_count = 0;
- if (camel_db_count_junk_message_info (db, table_name, &(record->junk_count), NULL))
+ if (camel_db_count_junk_message_info (cdb, table_name, &(record->junk_count), NULL))
record->junk_count = 0;
- if (camel_db_count_deleted_message_info (db, table_name, &(record->deleted_count), NULL))
+ if (camel_db_count_deleted_message_info (cdb, table_name, &(record->deleted_count), NULL))
record->deleted_count = 0;
- if (camel_db_count_unread_message_info (db, table_name, &(record->unread_count), NULL))
+ if (camel_db_count_unread_message_info (cdb, table_name, &(record->unread_count), NULL))
record->unread_count = 0;
- if (camel_db_count_visible_message_info (db, table_name, &(record->visible_count), NULL))
+ if (camel_db_count_visible_message_info (cdb, table_name, &(record->visible_count), NULL))
record->visible_count = 0;
- if (camel_db_count_junk_not_deleted_message_info (db, table_name, &(record->jnd_count), NULL))
+ if (camel_db_count_junk_not_deleted_message_info (cdb, table_name, &(record->jnd_count),
NULL))
record->jnd_count = 0;
}
@@ -1211,7 +1211,7 @@ message_info_from_uid (CamelFolderSummary *summary,
return NULL;
}
- cdb = parent_store->cdb_r;
+ cdb = camel_store_get_db (parent_store);
data.columns_hash = NULL;
data.summary = summary;
@@ -1570,7 +1570,7 @@ cfs_reload_from_db (CamelFolderSummary *summary,
return;
folder_name = camel_folder_get_full_name (summary->priv->folder);
- cdb = parent_store->cdb_r;
+ cdb = camel_store_get_db (parent_store);
data.columns_hash = NULL;
data.summary = summary;
@@ -1657,7 +1657,7 @@ camel_folder_summary_load_from_db (CamelFolderSummary *summary,
return FALSE;
}
- cdb = parent_store->cdb_r;
+ cdb = camel_store_get_db (parent_store);
ret = camel_db_get_folder_uids (
cdb, full_name, summary->sort_by, summary->collate,
@@ -1849,7 +1849,7 @@ save_to_db_cb (gpointer key,
return;
}
- cdb = parent_store->cdb_w;
+ cdb = camel_store_get_db (parent_store);
mir = g_new0 (CamelMIRecord, 1);
bdata_str = g_string_new (NULL);
@@ -1897,7 +1897,7 @@ save_message_infos_to_db (CamelFolderSummary *summary,
if (!parent_store)
return 0;
- cdb = parent_store->cdb_w;
+ cdb = camel_store_get_db (parent_store);
if (camel_db_prepare_message_info_table (cdb, full_name, error) != 0)
return -1;
@@ -1939,7 +1939,7 @@ camel_folder_summary_save_to_db (CamelFolderSummary *summary,
if (!parent_store)
return FALSE;
- cdb = parent_store->cdb_w;
+ cdb = camel_store_get_db (parent_store);
camel_folder_summary_lock (summary);
@@ -2032,7 +2032,7 @@ camel_folder_summary_header_save_to_db (CamelFolderSummary *summary,
if (!parent_store)
return FALSE;
- cdb = parent_store->cdb_w;
+ cdb = camel_store_get_db (parent_store);
camel_folder_summary_lock (summary);
d (printf ("\ncamel_folder_summary_header_save_to_db called \n"));
@@ -2084,7 +2084,7 @@ camel_folder_summary_header_load_from_db (CamelFolderSummary *summary,
camel_folder_summary_lock (summary);
camel_folder_summary_save_to_db (summary, NULL);
- cdb = store->cdb_r;
+ cdb = camel_store_get_db (store);
record = g_new0 (CamelFIRecord, 1);
camel_db_read_folder_info_record (cdb, folder_name, record, error);
@@ -2423,7 +2423,7 @@ camel_folder_summary_clear (CamelFolderSummary *summary,
return FALSE;
}
- cdb = parent_store->cdb_w;
+ cdb = camel_store_get_db (parent_store);
if (!is_in_memory_summary (summary))
res = camel_db_clear_folder_summary (cdb, folder_name, error) == 0;
@@ -2506,7 +2506,7 @@ camel_folder_summary_remove_uid (CamelFolderSummary *summary,
if (!is_in_memory_summary (summary)) {
full_name = camel_folder_get_full_name (summary->priv->folder);
parent_store = camel_folder_get_parent_store (summary->priv->folder);
- if (!parent_store || camel_db_delete_uid (parent_store->cdb_w, full_name, uid_copy, NULL) !=
0)
+ if (!parent_store || camel_db_delete_uid (camel_store_get_db (parent_store), full_name,
uid_copy, NULL) != 0)
res = FALSE;
}
@@ -2565,7 +2565,7 @@ camel_folder_summary_remove_uids (CamelFolderSummary *summary,
if (!is_in_memory_summary (summary)) {
full_name = camel_folder_get_full_name (summary->priv->folder);
parent_store = camel_folder_get_parent_store (summary->priv->folder);
- if (!parent_store || camel_db_delete_uids (parent_store->cdb_w, full_name, uids, NULL) != 0)
+ if (!parent_store || camel_db_delete_uids (camel_store_get_db (parent_store), full_name,
uids, NULL) != 0)
res = FALSE;
}
diff --git a/src/camel/camel-folder.c b/src/camel/camel-folder.c
index bb85e1a..d297527 100644
--- a/src/camel/camel-folder.c
+++ b/src/camel/camel-folder.c
@@ -2292,7 +2292,7 @@ camel_folder_delete (CamelFolder *folder)
/* Delete the references of the folder from the DB.*/
full_name = camel_folder_get_full_name (folder);
parent_store = camel_folder_get_parent_store (folder);
- camel_db_delete_folder (parent_store->cdb_w, full_name, NULL);
+ camel_db_delete_folder (camel_store_get_db (parent_store), full_name, NULL);
service = CAMEL_SERVICE (parent_store);
session = camel_service_ref_session (service);
@@ -2347,7 +2347,7 @@ camel_folder_rename (CamelFolder *folder,
class->rename (folder, new_name);
parent_store = camel_folder_get_parent_store (folder);
- camel_db_rename_folder (parent_store->cdb_w, old_name, new_name, NULL);
+ camel_db_rename_folder (camel_store_get_db (parent_store), old_name, new_name, NULL);
service = CAMEL_SERVICE (parent_store);
session = camel_service_ref_session (service);
diff --git a/src/camel/camel-object-bag.c b/src/camel/camel-object-bag.c
index 79c3cec..e7ae173 100644
--- a/src/camel/camel-object-bag.c
+++ b/src/camel/camel-object-bag.c
@@ -530,7 +530,7 @@ camel_object_bag_rekey (CamelObjectBag *bag,
*
* <informalexample>
* <programlisting>
- * g_ptr_array_foreach (array, g_object_unref, NULL);
+ * g_ptr_array_foreach (array, (GFunc) g_object_unref, NULL);
* g_ptr_array_free (array, TRUE);
* </programlisting>
* </informalexample>
diff --git a/src/camel/camel-offline-store.c b/src/camel/camel-offline-store.c
index b49b786..3ca0db6 100644
--- a/src/camel/camel-offline-store.c
+++ b/src/camel/camel-offline-store.c
@@ -223,8 +223,7 @@ camel_offline_store_set_online_sync (CamelOfflineStore *store,
GPtrArray *folders;
guint ii;
- folders = camel_object_bag_list (
- CAMEL_STORE (store)->folders);
+ folders = camel_store_dup_opened_folders (CAMEL_STORE (store));
for (ii = 0; ii < folders->len; ii++) {
CamelFolder *folder = folders->pdata[ii];
@@ -288,8 +287,7 @@ camel_offline_store_prepare_for_offline_sync (CamelOfflineStore *store,
GPtrArray *folders;
guint ii;
- folders = camel_object_bag_list (
- CAMEL_STORE (store)->folders);
+ folders = camel_store_dup_opened_folders (CAMEL_STORE (store));
for (ii = 0; ii < folders->len; ii++) {
CamelFolder *folder = folders->pdata[ii];
@@ -359,8 +357,7 @@ camel_offline_store_requires_downsync (CamelOfflineStore *store)
GPtrArray *folders;
guint ii;
- folders = camel_object_bag_list (
- CAMEL_STORE (store)->folders);
+ folders = camel_store_dup_opened_folders (CAMEL_STORE (store));
for (ii = 0; ii < folders->len && !sync_any_folder; ii++) {
CamelFolder *folder = folders->pdata[ii];
diff --git a/src/camel/camel-store.c b/src/camel/camel-store.c
index f246ad6..dfc11c6 100644
--- a/src/camel/camel-store.c
+++ b/src/camel/camel-store.c
@@ -51,6 +51,11 @@ typedef struct _AsyncContext AsyncContext;
typedef struct _SignalClosure SignalClosure;
struct _CamelStorePrivate {
+ CamelDB *cdb;
+ CamelObjectBag *folders;
+ guint32 flags; /* bit-or of CamelStoreFlags */
+ guint32 permissions; /* bit-or of CamelStorePermissionFlags */
+
GMutex signal_emission_lock;
gboolean folder_info_stale_scheduled;
volatile gint maintenance_lock;
@@ -238,45 +243,6 @@ ignore_no_such_table_exception (GError **error)
g_clear_error (error);
}
-/* deletes folder/removes it from the folder cache, if it's there */
-static void
-cs_delete_cached_folder (CamelStore *store,
- const gchar *folder_name)
-{
- CamelFolder *folder;
- CamelVeeFolder *vfolder;
-
- if (store->folders == NULL)
- return;
-
- folder = camel_object_bag_get (store->folders, folder_name);
- if (folder == NULL)
- return;
-
- if (store->flags & CAMEL_STORE_VTRASH) {
- vfolder = camel_object_bag_get (
- store->folders, CAMEL_VTRASH_NAME);
- if (vfolder != NULL) {
- camel_vee_folder_remove_folder (vfolder, folder, NULL);
- g_object_unref (vfolder);
- }
- }
-
- if (store->flags & CAMEL_STORE_VJUNK) {
- vfolder = camel_object_bag_get (
- store->folders, CAMEL_VJUNK_NAME);
- if (vfolder != NULL) {
- camel_vee_folder_remove_folder (vfolder, folder, NULL);
- g_object_unref (vfolder);
- }
- }
-
- camel_folder_delete (folder);
-
- camel_object_bag_remove (store->folders, folder);
- g_object_unref (folder);
-}
-
static CamelFolder *
store_get_special (CamelStore *store,
CamelVTrashFolderType type)
@@ -286,7 +252,7 @@ store_get_special (CamelStore *store,
gint i;
folder = camel_vtrash_folder_new (store, type);
- folders = camel_object_bag_list (store->folders);
+ folders = camel_object_bag_list (store->priv->folders);
for (i = 0; i < folders->len; i++) {
if (!CAMEL_IS_VTRASH_FOLDER (folders->pdata[i]))
camel_vee_folder_add_folder ((CamelVeeFolder *) folder, (CamelFolder *)
folders->pdata[i], NULL);
@@ -345,13 +311,10 @@ store_finalize (GObject *object)
{
CamelStore *store = CAMEL_STORE (object);
- if (store->folders != NULL)
- camel_object_bag_destroy (store->folders);
+ if (store->priv->folders != NULL)
+ camel_object_bag_destroy (store->priv->folders);
- if (store->cdb_r != NULL) {
- g_clear_object (&store->cdb_r);
- store->cdb_w = NULL;
- }
+ g_clear_object (&store->priv->cdb);
/* Chain up to parent's finalize() method. */
G_OBJECT_CLASS (camel_store_parent_class)->finalize (object);
@@ -372,7 +335,7 @@ store_constructed (GObject *object)
g_return_if_fail (class->hash_folder_name != NULL);
g_return_if_fail (class->equal_folder_name != NULL);
- store->folders = camel_object_bag_new (
+ store->priv->folders = camel_object_bag_new (
class->hash_folder_name,
class->equal_folder_name,
(CamelCopyFunc) g_strdup, g_free);
@@ -479,7 +442,7 @@ store_synchronize_sync (CamelStore *store,
camel_folder_info_free (root);
} else {
/* sync only folders opened until now */
- folders = camel_object_bag_list (store->folders);
+ folders = camel_object_bag_list (store->priv->folders);
}
/* We don't sync any vFolders, that is used to update certain
@@ -543,7 +506,7 @@ store_initable_init (GInitable *initable,
return FALSE;
service = CAMEL_SERVICE (initable);
- if ((store->flags & CAMEL_STORE_USE_CACHE_DIR) != 0)
+ if ((store->priv->flags & CAMEL_STORE_USE_CACHE_DIR) != 0)
user_dir = camel_service_get_user_cache_dir (service);
else
user_dir = camel_service_get_user_data_dir (service);
@@ -558,18 +521,15 @@ store_initable_init (GInitable *initable,
/* This is for reading from the store */
filename = g_build_filename (user_dir, CAMEL_DB_FILE, NULL);
- store->cdb_r = camel_db_new (filename, error);
+ store->priv->cdb = camel_db_new (filename, error);
g_free (filename);
- if (store->cdb_r == NULL)
+ if (store->priv->cdb == NULL)
return FALSE;
- if (camel_db_create_folders_table (store->cdb_r, error))
+ if (camel_db_create_folders_table (store->priv->cdb, error))
return FALSE;
- /* keep cb_w to not break the ABI */
- store->cdb_w = store->cdb_r;
-
return TRUE;
}
@@ -681,18 +641,146 @@ camel_store_init (CamelStore *store)
* - Include a virtual Trash folder.
* - Allow creating/deleting/renaming folders.
*/
- store->flags =
+ store->priv->flags =
CAMEL_STORE_VJUNK |
CAMEL_STORE_VTRASH |
CAMEL_STORE_CAN_EDIT_FOLDERS;
- store->mode = CAMEL_STORE_READ | CAMEL_STORE_WRITE;
+ store->priv->permissions = CAMEL_STORE_READ | CAMEL_STORE_WRITE;
store->priv->maintenance_lock = 0;
}
G_DEFINE_QUARK (camel-store-error-quark, camel_store_error)
/**
+ * camel_store_get_db:
+ * @store: a #CamelStore
+ *
+ * Returns: (transfer none): A #CamelDB instance associated with this @store.
+ *
+ * Since: 3.24
+ **/
+CamelDB *
+camel_store_get_db (CamelStore *store)
+{
+ g_return_val_if_fail (CAMEL_IS_STORE (store), NULL);
+
+ return store->priv->cdb;
+}
+
+/**
+ * camel_store_get_folders_bag:
+ * @store: a #CamelStore
+ *
+ * Returns: (transfer none): a #CamelObjectBag of opened #CamelFolder<!-- -->s
+ *
+ * Since: 3.24
+ **/
+CamelObjectBag *
+camel_store_get_folders_bag (CamelStore *store)
+{
+ g_return_val_if_fail (CAMEL_IS_STORE (store), NULL);
+
+ return store->priv->folders;
+}
+
+/**
+ * camel_store_dup_opened_folders:
+ * @store: a #CamelStore
+ *
+ * Returns a #GPtrArray of all the opened folders for the @store. The caller owns
+ * both the array and the folder references, so to free the array use:
+ *
+ * <informalexample>
+ * <programlisting>
+ * g_ptr_array_foreach (array, (GFunc) g_object_unref, NULL);
+ * g_ptr_array_free (array, TRUE);
+ * </programlisting>
+ * </informalexample>
+ *
+ * Returns: (element-type CamelFolder) (transfer full): an array with all currently
+ * opened folders for the @store.
+ *
+ * Since: 3.24
+ **/
+GPtrArray *
+camel_store_dup_opened_folders (CamelStore *store)
+{
+ g_return_val_if_fail (CAMEL_IS_STORE (store), NULL);
+ g_return_val_if_fail (store->priv->folders != NULL, NULL);
+
+ return camel_object_bag_list (store->priv->folders);
+}
+
+/**
+ * camel_store_get_flags:
+ * @store: a #CamelStore
+ *
+ * Returns: bit-or of #CamelStoreFlags set for the @store
+ *
+ * Since: 3.24
+ **/
+guint32
+camel_store_get_flags (CamelStore *store)
+{
+ g_return_val_if_fail (CAMEL_IS_STORE (store), 0);
+
+ return store->priv->flags;
+}
+
+/**
+ * camel_store_set_flags:
+ * @store: a #CamelStore
+ * @flags: bit-or of #CamelStoreFlags
+ *
+ * Sets flags for the @store, a bit-or of #CamelStoreFlags.
+ *
+ * Since: 3.24
+ **/
+void
+camel_store_set_flags (CamelStore *store,
+ guint32 flags)
+{
+ g_return_if_fail (CAMEL_IS_STORE (store));
+
+ store->priv->flags = flags;
+}
+
+/**
+ * camel_store_get_permissions:
+ * @store: a #CamelStore
+ *
+ * Returns: Permissions of the @store, a bit-or of #CamelStorePermissionFlags
+ *
+ * Since: 3.24
+ **/
+guint32
+camel_store_get_permissions (CamelStore *store)
+{
+ g_return_val_if_fail (CAMEL_IS_STORE (store), 0);
+
+ return store->priv->permissions;
+}
+
+/**
+ * camel_store_set_permissions:
+ * @store: a #CamelStore
+ * @permissions: permissions of the @store, a bit-or of #CamelStorePermissionFlags
+ *
+ * Sets permissions for the @store, a bit-or of #CamelStorePermissionFlags
+ *
+ * Since: 3.24
+ **/
+void
+camel_store_set_permissions (CamelStore *store,
+ guint32 permissions)
+{
+ g_return_if_fail (CAMEL_IS_STORE (store));
+
+ store->priv->permissions = permissions;
+}
+
+/**
* camel_store_folder_created:
* @store: a #CamelStore
* @folder_info: information about the created folder
@@ -1242,7 +1330,7 @@ camel_store_get_folder_sync (CamelStore *store,
try_again:
/* Try cache first. */
- folder = camel_object_bag_reserve (store->folders, folder_name);
+ folder = camel_object_bag_reserve (store->priv->folders, folder_name);
if (folder != NULL) {
if ((flags & CAMEL_STORE_FOLDER_INFO_REFRESH) != 0)
camel_folder_prepare_content_refresh (folder);
@@ -1251,9 +1339,9 @@ try_again:
}
store_uses_vjunk =
- ((store->flags & CAMEL_STORE_VJUNK) != 0);
+ ((store->priv->flags & CAMEL_STORE_VJUNK) != 0);
store_uses_vtrash =
- ((store->flags & CAMEL_STORE_VTRASH) != 0);
+ ((store->priv->flags & CAMEL_STORE_VTRASH) != 0);
folder_name_is_vjunk =
store_uses_vjunk &&
(strcmp (folder_name, CAMEL_VJUNK_NAME) == 0);
@@ -1263,16 +1351,16 @@ try_again:
if (flags & CAMEL_STORE_IS_MIGRATING) {
if (folder_name_is_vtrash) {
- if (store->folders != NULL)
+ if (store->priv->folders != NULL)
camel_object_bag_abort (
- store->folders, folder_name);
+ store->priv->folders, folder_name);
return NULL;
}
if (folder_name_is_vjunk) {
- if (store->folders != NULL)
+ if (store->priv->folders != NULL)
camel_object_bag_abort (
- store->folders, folder_name);
+ store->priv->folders, folder_name);
return NULL;
}
}
@@ -1323,11 +1411,11 @@ try_again:
if (folder != NULL && store_uses_vjunk)
vjunk = camel_object_bag_get (
- store->folders, CAMEL_VJUNK_NAME);
+ store->priv->folders, CAMEL_VJUNK_NAME);
if (folder != NULL && store_uses_vtrash)
vtrash = camel_object_bag_get (
- store->folders, CAMEL_VTRASH_NAME);
+ store->priv->folders, CAMEL_VTRASH_NAME);
}
/* Release the folder name reservation before adding the
@@ -1335,10 +1423,10 @@ try_again:
* reduce the chance of deadlock. */
if (folder != NULL)
camel_object_bag_add (
- store->folders, folder_name, folder);
+ store->priv->folders, folder_name, folder);
else
camel_object_bag_abort (
- store->folders, folder_name);
+ store->priv->folders, folder_name);
/* If this is a normal folder and the store uses a
* virtual Junk folder, let the virtual Junk folder
@@ -1590,8 +1678,8 @@ camel_store_get_folder_info_sync (CamelStore *store,
/* For readability. */
allow_virtual = ((flags & CAMEL_STORE_FOLDER_INFO_NO_VIRTUAL) == 0);
start_at_root = (top == NULL || *top == '\0');
- store_has_vtrash = ((store->flags & CAMEL_STORE_VTRASH) != 0);
- store_has_vjunk = ((store->flags & CAMEL_STORE_VJUNK) != 0);
+ store_has_vtrash = ((store->priv->flags & CAMEL_STORE_VTRASH) != 0);
+ store_has_vjunk = ((store->priv->flags & CAMEL_STORE_VJUNK) != 0);
if (info != NULL && start_at_root && allow_virtual) {
if (store_has_vtrash) {
@@ -1946,7 +2034,7 @@ camel_store_get_junk_folder_sync (CamelStore *store,
{
g_return_val_if_fail (CAMEL_IS_STORE (store), NULL);
- if ((store->flags & CAMEL_STORE_VJUNK) == 0) {
+ if ((store->priv->flags & CAMEL_STORE_VJUNK) == 0) {
CamelStoreClass *class;
CamelFolder *folder;
@@ -2072,7 +2160,7 @@ camel_store_get_trash_folder_sync (CamelStore *store,
{
g_return_val_if_fail (CAMEL_IS_STORE (store), NULL);
- if ((store->flags & CAMEL_STORE_VTRASH) == 0) {
+ if ((store->priv->flags & CAMEL_STORE_VTRASH) == 0) {
CamelStoreClass *class;
CamelFolder *folder;
@@ -2254,9 +2342,9 @@ store_create_folder_thread (GTask *task,
gboolean reserved_vfolder_name;
reserved_vfolder_name =
- ((store->flags & CAMEL_STORE_VJUNK) &&
+ ((store->priv->flags & CAMEL_STORE_VJUNK) &&
g_str_equal (folder_name, CAMEL_VJUNK_NAME)) ||
- ((store->flags & CAMEL_STORE_VTRASH) &&
+ ((store->priv->flags & CAMEL_STORE_VTRASH) &&
g_str_equal (folder_name, CAMEL_VTRASH_NAME));
if (reserved_vfolder_name) {
@@ -2438,9 +2526,9 @@ store_delete_folder_thread (GTask *task,
g_return_if_fail (class->delete_folder_sync != NULL);
reserved_vfolder_name =
- ((store->flags & CAMEL_STORE_VJUNK) &&
+ ((store->priv->flags & CAMEL_STORE_VJUNK) &&
g_str_equal (folder_name, CAMEL_VJUNK_NAME)) ||
- ((store->flags & CAMEL_STORE_VTRASH) &&
+ ((store->priv->flags & CAMEL_STORE_VTRASH) &&
g_str_equal (folder_name, CAMEL_VTRASH_NAME));
if (reserved_vfolder_name) {
@@ -2465,7 +2553,7 @@ store_delete_folder_thread (GTask *task,
if (local_error != NULL) {
g_task_return_error (task, local_error);
} else {
- cs_delete_cached_folder (store, folder_name);
+ camel_store_delete_cached_folder (store, folder_name);
g_task_return_boolean (task, success);
}
}
@@ -2628,9 +2716,9 @@ store_rename_folder_thread (GTask *task,
}
reserved_vfolder_name =
- ((store->flags & CAMEL_STORE_VJUNK) &&
+ ((store->priv->flags & CAMEL_STORE_VJUNK) &&
g_str_equal (old_name, CAMEL_VJUNK_NAME)) ||
- ((store->flags & CAMEL_STORE_VTRASH) &&
+ ((store->priv->flags & CAMEL_STORE_VTRASH) &&
g_str_equal (old_name, CAMEL_VTRASH_NAME));
if (reserved_vfolder_name) {
@@ -2647,7 +2735,7 @@ store_rename_folder_thread (GTask *task,
/* If the folder is open (or any subfolders of the open folder)
* We need to rename them atomically with renaming the actual
* folder path. */
- folders = camel_object_bag_list (store->folders);
+ folders = camel_object_bag_list (store->priv->folders);
for (ii = 0; ii < folders->len; ii++) {
const gchar *full_name;
gsize full_name_len;
@@ -2690,7 +2778,7 @@ store_rename_folder_thread (GTask *task,
full_name = camel_folder_get_full_name (folder);
new = g_strdup_printf ("%s%s", new_name, full_name + strlen (old_name));
- camel_object_bag_rekey (store->folders, folder, new);
+ camel_object_bag_rekey (store->priv->folders, folder, new);
camel_folder_rename (folder, new);
g_free (new);
@@ -3133,8 +3221,60 @@ camel_store_maybe_run_db_maintenance (CamelStore *store,
if (g_atomic_int_get (&store->priv->maintenance_lock) > 0)
return TRUE;
- if (!store->cdb_w)
+ if (!store->priv->cdb)
return TRUE;
- return camel_db_maybe_run_maintenance (store->cdb_w, error);
+ return camel_db_maybe_run_maintenance (store->priv->cdb, error);
+}
+
+/**
+ * camel_store_delete_cached_folder:
+ * @store: a #CamelStore
+ * @folder_name: a folder full name to delete from the cache
+ *
+ * Deletes local data for the given @folder_name. The folder should
+ * be part of the opened folders.
+ *
+ * It doesn't delete the folder in the store (server) as such.
+ * Use camel_store_delete_folder(), or its synchronous variant,
+ * if you want to do that instead.
+ *
+ * Since: 3.24
+ **/
+void
+camel_store_delete_cached_folder (CamelStore *store,
+ const gchar *folder_name)
+{
+ CamelFolder *folder;
+ CamelVeeFolder *vfolder;
+
+ if (store->priv->folders == NULL)
+ return;
+
+ folder = camel_object_bag_get (store->priv->folders, folder_name);
+ if (folder == NULL)
+ return;
+
+ if (store->priv->flags & CAMEL_STORE_VTRASH) {
+ vfolder = camel_object_bag_get (
+ store->priv->folders, CAMEL_VTRASH_NAME);
+ if (vfolder != NULL) {
+ camel_vee_folder_remove_folder (vfolder, folder, NULL);
+ g_object_unref (vfolder);
+ }
+ }
+
+ if (store->priv->flags & CAMEL_STORE_VJUNK) {
+ vfolder = camel_object_bag_get (
+ store->priv->folders, CAMEL_VJUNK_NAME);
+ if (vfolder != NULL) {
+ camel_vee_folder_remove_folder (vfolder, folder, NULL);
+ g_object_unref (vfolder);
+ }
+ }
+
+ camel_folder_delete (folder);
+
+ camel_object_bag_remove (store->priv->folders, folder);
+ g_object_unref (folder);
}
diff --git a/src/camel/camel-store.h b/src/camel/camel-store.h
index 2820060..5c0c88b 100644
--- a/src/camel/camel-store.h
+++ b/src/camel/camel-store.h
@@ -27,9 +27,7 @@
#ifndef CAMEL_STORE_H
#define CAMEL_STORE_H
-/* for mode_t */
-#include <sys/types.h>
-
+#include <camel/camel-db.h>
#include <camel/camel-enums.h>
#include <camel/camel-folder.h>
#include <camel/camel-service.h>
@@ -121,8 +119,6 @@ typedef struct _CamelFolderInfo {
gint32 total;
} CamelFolderInfo;
-struct _CamelDB;
-
typedef struct _CamelStore CamelStore;
typedef struct _CamelStoreClass CamelStoreClass;
typedef struct _CamelStorePrivate CamelStorePrivate;
@@ -141,18 +137,6 @@ typedef enum {
struct _CamelStore {
CamelService parent;
CamelStorePrivate *priv;
-
- CamelObjectBag *folders;
- struct _CamelDB *cdb_r;
- struct _CamelDB *cdb_w;
-
- CamelStoreFlags flags;
-
- /* XXX The default "mode" (read/write) is changed only by
- * evolution-groupwise for non-writable proxy accounts.
- * The mode is only checked by the account combo box in
- * Evolution's composer window. */
- CamelStorePermissionFlags mode;
};
struct _CamelStoreClass {
@@ -234,6 +218,15 @@ struct _CamelStoreClass {
GType camel_store_get_type (void);
GQuark camel_store_error_quark (void) G_GNUC_CONST;
+CamelDB * camel_store_get_db (CamelStore *store);
+CamelObjectBag *camel_store_get_folders_bag (CamelStore *store);
+GPtrArray * camel_store_dup_opened_folders (CamelStore *store);
+guint32 camel_store_get_flags (CamelStore *store);
+void camel_store_set_flags (CamelStore *store,
+ guint32 flags);
+guint32 camel_store_get_permissions (CamelStore *store);
+void camel_store_set_permissions (CamelStore *store,
+ guint32 permissions);
void camel_store_folder_created (CamelStore *store,
CamelFolderInfo *folder_info);
void camel_store_folder_deleted (CamelStore *store,
@@ -412,6 +405,9 @@ gboolean camel_store_initial_setup_finish
gboolean camel_store_maybe_run_db_maintenance
(CamelStore *store,
GError **error);
+void camel_store_delete_cached_folder
+ (CamelStore *store,
+ const gchar *folder_name);
G_END_DECLS
diff --git a/src/camel/camel-subscribable.c b/src/camel/camel-subscribable.c
index ebb0683..a8f3fa8 100644
--- a/src/camel/camel-subscribable.c
+++ b/src/camel/camel-subscribable.c
@@ -106,46 +106,6 @@ subscribable_emit_folder_unsubscribed_cb (gpointer user_data)
}
static void
-subscribable_delete_cached_folder (CamelStore *store,
- const gchar *folder_name)
-{
- CamelFolder *folder;
- CamelVeeFolder *vfolder;
-
- /* XXX Copied from camel-store.c. Should this be public? */
-
- if (store->folders == NULL)
- return;
-
- folder = camel_object_bag_get (store->folders, folder_name);
- if (folder == NULL)
- return;
-
- if (store->flags & CAMEL_STORE_VTRASH) {
- folder_name = CAMEL_VTRASH_NAME;
- vfolder = camel_object_bag_get (store->folders, folder_name);
- if (vfolder != NULL) {
- camel_vee_folder_remove_folder (vfolder, folder, NULL);
- g_object_unref (vfolder);
- }
- }
-
- if (store->flags & CAMEL_STORE_VJUNK) {
- folder_name = CAMEL_VJUNK_NAME;
- vfolder = camel_object_bag_get (store->folders, folder_name);
- if (vfolder != NULL) {
- camel_vee_folder_remove_folder (vfolder, folder, NULL);
- g_object_unref (vfolder);
- }
- }
-
- camel_folder_delete (folder);
-
- camel_object_bag_remove (store->folders, folder);
- g_object_unref (folder);
-}
-
-static void
camel_subscribable_default_init (CamelSubscribableInterface *iface)
{
signals[FOLDER_SUBSCRIBED] = g_signal_new (
@@ -449,8 +409,7 @@ subscribable_unsubscribe_folder_thread (GTask *task,
subscribable, unsubscribe_folder_sync, success, local_error);
if (success)
- subscribable_delete_cached_folder (
- CAMEL_STORE (subscribable), folder_name);
+ camel_store_delete_cached_folder (CAMEL_STORE (subscribable), folder_name);
camel_operation_pop_message (cancellable);
diff --git a/src/camel/camel-vee-store.c b/src/camel/camel-vee-store.c
index 8e789a5..58bc973 100644
--- a/src/camel/camel-vee-store.c
+++ b/src/camel/camel-vee-store.c
@@ -233,11 +233,11 @@ vee_store_get_folder_sync (CamelStore *store,
while ( (p = strchr (p, '/'))) {
*p = 0;
- folder = camel_object_bag_reserve (store->folders, name);
+ folder = camel_object_bag_reserve (camel_store_get_folders_bag (store), name);
if (folder == NULL) {
/* create a dummy vFolder for this, makes get_folder_info simpler */
folder = camel_vee_folder_new (store, name, flags);
- camel_object_bag_add (store->folders, name, folder);
+ camel_object_bag_add (camel_store_get_folders_bag (store), name, folder);
change_folder (store, name, CHANGE_ADD | CHANGE_NOSELECT, 0);
/* FIXME: this sort of leaks folder, nobody owns a ref to it but us */
} else {
@@ -285,7 +285,7 @@ vee_store_get_folder_info_sync (CamelStore *store,
d (printf ("Get folder info '%s'\n", top ? top:"<null>"));
infos_hash = g_hash_table_new (g_str_hash, g_str_equal);
- folders = camel_object_bag_list (store->folders);
+ folders = camel_store_dup_opened_folders (store);
qsort (folders->pdata, folders->len, sizeof (folders->pdata[0]), vee_folder_cmp);
for (i = 0; i < folders->len; i++) {
CamelVeeFolder *folder = folders->pdata[i];
@@ -366,8 +366,8 @@ vee_store_get_folder_info_sync (CamelStore *store,
}
g_free (pname);
- g_object_unref (folder);
}
+ g_ptr_array_foreach (folders, (GFunc) g_object_unref, NULL);
g_ptr_array_free (folders, TRUE);
g_hash_table_destroy (infos_hash);
@@ -422,7 +422,7 @@ vee_store_delete_folder_sync (CamelStore *store,
return FALSE;
}
- folder = camel_object_bag_get (store->folders, folder_name);
+ folder = camel_object_bag_get (camel_store_get_folders_bag (store), folder_name);
if (folder) {
CamelObject *object = CAMEL_OBJECT (folder);
const gchar *state_filename;
@@ -473,7 +473,7 @@ vee_store_rename_folder_sync (CamelStore *store,
}
/* See if it exists, for vfolders, all folders are in the folders hash */
- oldfolder = camel_object_bag_get (store->folders, old);
+ oldfolder = camel_object_bag_get (camel_store_get_folders_bag (store), old);
if (oldfolder == NULL) {
g_set_error (
error, CAMEL_STORE_ERROR,
@@ -490,11 +490,11 @@ vee_store_rename_folder_sync (CamelStore *store,
while ( (p = strchr (p, '/'))) {
*p = 0;
- folder = camel_object_bag_reserve (store->folders, name);
+ folder = camel_object_bag_reserve (camel_store_get_folders_bag (store), name);
if (folder == NULL) {
/* create a dummy vFolder for this, makes get_folder_info simpler */
folder = camel_vee_folder_new (store, name, ((CamelVeeFolder *) oldfolder)->flags);
- camel_object_bag_add (store->folders, name, folder);
+ camel_object_bag_add (camel_store_get_folders_bag (store), name, folder);
change_folder (store, name, CHANGE_ADD | CHANGE_NOSELECT, 0);
/* FIXME: this sort of leaks folder, nobody owns a ref to it but us */
} else {
@@ -556,7 +556,7 @@ camel_vee_store_init (CamelVeeStore *vee_store)
vee_store->priv->unmatched_enabled = TRUE;
/* we dont want a vtrash/vjunk on this one */
- store->flags &= ~(CAMEL_STORE_VTRASH | CAMEL_STORE_VJUNK);
+ camel_store_set_flags (store, camel_store_get_flags (store) & ~(CAMEL_STORE_VTRASH |
CAMEL_STORE_VJUNK));
}
/**
diff --git a/src/camel/camel-vee-summary.c b/src/camel/camel-vee-summary.c
index e1ac50f..a99ed0a 100644
--- a/src/camel/camel-vee-summary.c
+++ b/src/camel/camel-vee-summary.c
@@ -150,7 +150,7 @@ camel_vee_summary_new (CamelFolder *parent)
/* not using DB for vee folder summaries, drop the table */
full_name = camel_folder_get_full_name (parent);
parent_store = camel_folder_get_parent_store (parent);
- camel_db_delete_folder (parent_store->cdb_w, full_name, NULL);
+ camel_db_delete_folder (camel_store_get_db (parent_store), full_name, NULL);
return summary;
}
diff --git a/src/camel/providers/imapx/camel-imapx-folder.c b/src/camel/providers/imapx/camel-imapx-folder.c
index c14b3fb..b3424f0 100644
--- a/src/camel/providers/imapx/camel-imapx-folder.c
+++ b/src/camel/providers/imapx/camel-imapx-folder.c
@@ -475,7 +475,7 @@ imapx_expunge_sync (CamelFolder *folder,
if (mailbox == NULL)
goto exit;
- if ((store->flags & CAMEL_STORE_VTRASH) == 0) {
+ if ((camel_store_get_flags (store) & CAMEL_STORE_VTRASH) == 0) {
CamelFolder *trash;
const gchar *full_name;
diff --git a/src/camel/providers/imapx/camel-imapx-server.c b/src/camel/providers/imapx/camel-imapx-server.c
index dd3eac5..4b3dcba 100644
--- a/src/camel/providers/imapx/camel-imapx-server.c
+++ b/src/camel/providers/imapx/camel-imapx-server.c
@@ -5688,7 +5688,7 @@ camel_imapx_server_expunge_sync (CamelIMAPXServer *is,
camel_folder_summary_lock (folder->summary);
camel_folder_summary_save_to_db (folder->summary, NULL);
- uids = camel_db_get_folder_deleted_uids (parent_store->cdb_r, full_name, NULL);
+ uids = camel_db_get_folder_deleted_uids (camel_store_get_db (parent_store),
full_name, NULL);
if (uids && uids->len) {
CamelFolderChangeInfo *changes;
diff --git a/src/camel/providers/imapx/camel-imapx-store.c b/src/camel/providers/imapx/camel-imapx-store.c
index 96bbb84..858a1bd 100644
--- a/src/camel/providers/imapx/camel-imapx-store.c
+++ b/src/camel/providers/imapx/camel-imapx-store.c
@@ -153,23 +153,27 @@ imapx_store_update_store_flags (CamelStore *store)
CamelService *service;
CamelSettings *settings;
CamelIMAPXSettings *imapx_settings;
+ guint32 store_flags;
service = CAMEL_SERVICE (store);
settings = camel_service_ref_settings (service);
imapx_settings = CAMEL_IMAPX_SETTINGS (settings);
+ store_flags = camel_store_get_flags (store);
if (camel_imapx_settings_get_use_real_junk_path (imapx_settings)) {
- store->flags &= ~CAMEL_STORE_VJUNK;
- store->flags |= CAMEL_STORE_REAL_JUNK_FOLDER;
+ store_flags &= ~CAMEL_STORE_VJUNK;
+ store_flags |= CAMEL_STORE_REAL_JUNK_FOLDER;
} else {
- store->flags |= CAMEL_STORE_VJUNK;
- store->flags &= ~CAMEL_STORE_REAL_JUNK_FOLDER;
+ store_flags |= CAMEL_STORE_VJUNK;
+ store_flags &= ~CAMEL_STORE_REAL_JUNK_FOLDER;
}
if (camel_imapx_settings_get_use_real_trash_path (imapx_settings))
- store->flags &= ~CAMEL_STORE_VTRASH;
+ store_flags &= ~CAMEL_STORE_VTRASH;
else
- store->flags |= CAMEL_STORE_VTRASH;
+ store_flags |= CAMEL_STORE_VTRASH;
+
+ camel_store_set_flags (store, store_flags);
g_object_unref (settings);
}
@@ -226,7 +230,7 @@ imapx_store_build_folder_info (CamelIMAPXStore *imapx_store,
fi->display_name = g_strdup (name);
}
- if ((store->flags & CAMEL_STORE_VTRASH) == 0) {
+ if ((camel_store_get_flags (store) & CAMEL_STORE_VTRASH) == 0) {
const gchar *trash_path;
trash_path = camel_imapx_settings_get_real_trash_path (
@@ -235,7 +239,7 @@ imapx_store_build_folder_info (CamelIMAPXStore *imapx_store,
fi->flags |= CAMEL_FOLDER_TYPE_TRASH;
}
- if ((store->flags & CAMEL_STORE_REAL_JUNK_FOLDER) != 0) {
+ if ((camel_store_get_flags (store) & CAMEL_STORE_REAL_JUNK_FOLDER) != 0) {
const gchar *junk_path;
junk_path = camel_imapx_settings_get_real_junk_path (
@@ -351,8 +355,7 @@ imapx_store_add_mailbox_to_folder (CamelIMAPXStore *store,
folder_path = camel_imapx_mailbox_dup_folder_path (mailbox);
- folder = camel_object_bag_get (
- CAMEL_STORE (store)->folders, folder_path);
+ folder = camel_object_bag_get (camel_store_get_folders_bag (CAMEL_STORE (store)), folder_path);
if (folder != NULL) {
camel_imapx_folder_set_mailbox (folder, mailbox);
@@ -557,7 +560,7 @@ imapx_store_process_mailbox_status (CamelIMAPXStore *imapx_store,
store = CAMEL_STORE (imapx_store);
/* Update only already opened folders */
- folder = camel_object_bag_reserve (store->folders, folder_path);
+ folder = camel_object_bag_reserve (camel_store_get_folders_bag (store), folder_path);
if (folder != NULL) {
CamelIMAPXFolder *imapx_folder;
CamelIMAPXSummary *imapx_summary;
@@ -574,7 +577,7 @@ imapx_store_process_mailbox_status (CamelIMAPXStore *imapx_store,
g_object_unref (folder);
} else {
- camel_object_bag_abort (store->folders, folder_path);
+ camel_object_bag_abort (camel_store_get_folders_bag (store), folder_path);
}
g_free (folder_path);
@@ -945,7 +948,7 @@ fill_fi (CamelStore *store,
{
CamelFolder *folder;
- folder = camel_object_bag_peek (store->folders, fi->full_name);
+ folder = camel_object_bag_peek (camel_store_get_folders_bag (store), fi->full_name);
if (folder) {
CamelIMAPXFolder *imapx_folder;
CamelIMAPXSummary *ims;
@@ -997,8 +1000,7 @@ imapx_delete_folder_from_cache (CamelIMAPXStore *imapx_store,
g_unlink (state_file);
g_free (state_file);
- camel_db_delete_folder (
- CAMEL_STORE (imapx_store)->cdb_w, folder_path, NULL);
+ camel_db_delete_folder (camel_store_get_db (CAMEL_STORE (imapx_store)), folder_path, NULL);
g_rmdir (folder_dir);
state_file = g_build_filename (folder_dir, "subfolders", NULL);
@@ -2603,7 +2605,7 @@ imapx_store_initable_init (GInitable *initable,
store = CAMEL_STORE (initable);
service = CAMEL_SERVICE (initable);
- store->flags |= CAMEL_STORE_USE_CACHE_DIR | CAMEL_STORE_SUPPORTS_INITIAL_SETUP;
+ camel_store_set_flags (store, camel_store_get_flags (store) | CAMEL_STORE_USE_CACHE_DIR |
CAMEL_STORE_SUPPORTS_INITIAL_SETUP);
imapx_migrate_to_user_cache_dir (service);
/* Chain up to parent interface's init() method. */
diff --git a/src/camel/providers/imapx/camel-imapx-summary.c b/src/camel/providers/imapx/camel-imapx-summary.c
index 7485af3..28cdb20 100644
--- a/src/camel/providers/imapx/camel-imapx-summary.c
+++ b/src/camel/providers/imapx/camel-imapx-summary.c
@@ -169,7 +169,7 @@ camel_imapx_summary_new (CamelFolder *folder)
/* Don't do DB sort. Its pretty slow to load */
if (folder && 0) {
- camel_db_set_collate (parent_store->cdb_r, "uid", "imapx_uid_sort", (CamelDBCollate)
sort_uid_cmp);
+ camel_db_set_collate (camel_store_get_db (parent_store), "uid", "imapx_uid_sort",
(CamelDBCollate) sort_uid_cmp);
summary->sort_by = "uid";
summary->collate = "imapx_uid_sort";
}
diff --git a/src/camel/providers/local/camel-local-store.c b/src/camel/providers/local/camel-local-store.c
index 324a44e..6790b95 100644
--- a/src/camel/providers/local/camel-local-store.c
+++ b/src/camel/providers/local/camel-local-store.c
@@ -532,7 +532,7 @@ local_store_rename_folder_sync (CamelStore *store,
d (printf ("local rename folder '%s' '%s'\n", old, new));
- folder = camel_object_bag_get (store->folders, old);
+ folder = camel_object_bag_get (camel_store_get_folders_bag (store), old);
if (folder && folder->index) {
if (camel_index_rename (folder->index, newibex) == -1)
goto ibex_failed;
diff --git a/src/camel/providers/local/camel-maildir-store.c b/src/camel/providers/local/camel-maildir-store.c
index be483b1..3912bfd 100644
--- a/src/camel/providers/local/camel-maildir-store.c
+++ b/src/camel/providers/local/camel-maildir-store.c
@@ -441,7 +441,7 @@ fill_fi (CamelStore *store,
{
CamelFolder *folder;
- folder = camel_object_bag_peek (store->folders, fi->full_name);
+ folder = camel_object_bag_peek (camel_store_get_folders_bag (store), fi->full_name);
if (folder) {
if ((flags & CAMEL_STORE_FOLDER_INFO_FAST) == 0)
camel_folder_refresh_info_sync (folder, cancellable, NULL);
diff --git a/src/camel/providers/local/camel-maildir-summary.c
b/src/camel/providers/local/camel-maildir-summary.c
index 9f7aa6a..7f79ae3 100644
--- a/src/camel/providers/local/camel-maildir-summary.c
+++ b/src/camel/providers/local/camel-maildir-summary.c
@@ -178,7 +178,7 @@ CamelMaildirSummary
CamelStore *parent_store;
parent_store = camel_folder_get_parent_store (folder);
- camel_db_set_collate (parent_store->cdb_r, "dreceived", NULL, NULL);
+ camel_db_set_collate (camel_store_get_db (parent_store), "dreceived", NULL, NULL);
((CamelFolderSummary *) o)->sort_by = "dreceived";
((CamelFolderSummary *) o)->collate = NULL;
}
diff --git a/src/camel/providers/local/camel-mbox-store.c b/src/camel/providers/local/camel-mbox-store.c
index cff6ff1..3ec0448 100644
--- a/src/camel/providers/local/camel-mbox-store.c
+++ b/src/camel/providers/local/camel-mbox-store.c
@@ -112,7 +112,7 @@ fill_fi (CamelStore *store,
fi->unread = -1;
fi->total = -1;
- folder = camel_object_bag_peek (store->folders, fi->full_name);
+ folder = camel_object_bag_peek (camel_store_get_folders_bag (store), fi->full_name);
if (folder) {
if ((flags & CAMEL_STORE_FOLDER_INFO_FAST) == 0)
camel_folder_refresh_info_sync (folder, NULL, NULL);
@@ -830,7 +830,7 @@ mbox_store_rename_folder_sync (CamelStore *store,
newdir = NULL;
}
- folder = camel_object_bag_get (store->folders, old);
+ folder = camel_object_bag_get (camel_store_get_folders_bag (store), old);
if (folder && folder->index) {
if (camel_index_rename (folder->index, newibex) == -1 && errno != ENOENT) {
errnosav = errno;
diff --git a/src/camel/providers/local/camel-mbox-summary.c b/src/camel/providers/local/camel-mbox-summary.c
index a5e683f..ca31190 100644
--- a/src/camel/providers/local/camel-mbox-summary.c
+++ b/src/camel/providers/local/camel-mbox-summary.c
@@ -164,7 +164,7 @@ camel_mbox_summary_new (CamelFolder *folder,
parent_store = camel_folder_get_parent_store (folder);
/* Set the functions for db sorting */
- camel_db_set_collate (parent_store->cdb_r, "bdata", "mbox_frompos_sort", (CamelDBCollate)
camel_local_frompos_sort);
+ camel_db_set_collate (camel_store_get_db (parent_store), "bdata", "mbox_frompos_sort",
(CamelDBCollate) camel_local_frompos_sort);
summary->sort_by = "bdata";
summary->collate = "mbox_frompos_sort";
@@ -461,7 +461,7 @@ summary_update (CamelLocalSummary *cls,
/* Delete all in one transaction */
full_name = camel_folder_get_full_name (camel_folder_summary_get_folder (s));
parent_store = camel_folder_get_parent_store (camel_folder_summary_get_folder (s));
- camel_db_delete_uids (parent_store->cdb_w, full_name, del, NULL);
+ camel_db_delete_uids (camel_store_get_db (parent_store), full_name, del, NULL);
g_list_foreach (del, (GFunc) camel_pstring_free, NULL);
g_list_free (del);
@@ -943,7 +943,7 @@ mbox_summary_sync (CamelLocalSummary *cls,
if (quick && expunge) {
guint32 dcount =0;
- if (camel_db_count_deleted_message_info (parent_store->cdb_w, full_name, &dcount, error) ==
-1) {
+ if (camel_db_count_deleted_message_info (camel_store_get_db (parent_store), full_name,
&dcount, error) == -1) {
camel_folder_summary_unlock (s);
return -1;
}
@@ -1187,7 +1187,7 @@ camel_mbox_summary_sync_mbox (CamelMboxSummary *cls,
full_name = camel_folder_get_full_name (camel_folder_summary_get_folder (s));
parent_store = camel_folder_get_parent_store (camel_folder_summary_get_folder (s));
- camel_db_delete_uids (parent_store->cdb_w, full_name, del, NULL);
+ camel_db_delete_uids (camel_store_get_db (parent_store), full_name, del, NULL);
g_list_foreach (del, (GFunc) camel_pstring_free, NULL);
g_list_free (del);
diff --git a/src/camel/providers/local/camel-mh-store.c b/src/camel/providers/local/camel-mh-store.c
index 7f771ec..e84d1cd 100644
--- a/src/camel/providers/local/camel-mh-store.c
+++ b/src/camel/providers/local/camel-mh-store.c
@@ -189,7 +189,7 @@ fill_fi (CamelStore *store,
CamelFolder *folder;
local_store = CAMEL_LOCAL_STORE (store);
- folder = camel_object_bag_peek (store->folders, fi->full_name);
+ folder = camel_object_bag_peek (camel_store_get_folders_bag (store), fi->full_name);
if (folder != NULL) {
fi->unread = camel_folder_get_unread_message_count (folder);
diff --git a/src/camel/providers/local/camel-mh-summary.c b/src/camel/providers/local/camel-mh-summary.c
index b471eea..7e99d61 100644
--- a/src/camel/providers/local/camel-mh-summary.c
+++ b/src/camel/providers/local/camel-mh-summary.c
@@ -103,7 +103,7 @@ camel_mh_summary_new (CamelFolder *folder,
CamelStore *parent_store;
parent_store = camel_folder_get_parent_store (folder);
- camel_db_set_collate (parent_store->cdb_r, "uid", "mh_uid_sort", (CamelDBCollate)
camel_local_frompos_sort);
+ camel_db_set_collate (camel_store_get_db (parent_store), "uid", "mh_uid_sort",
(CamelDBCollate) camel_local_frompos_sort);
((CamelFolderSummary *) o)->sort_by = "uid";
((CamelFolderSummary *) o)->collate = "mh_uid_sort";
}
diff --git a/src/camel/providers/local/camel-spool-store.c b/src/camel/providers/local/camel-spool-store.c
index b97810d..3478091 100644
--- a/src/camel/providers/local/camel-spool-store.c
+++ b/src/camel/providers/local/camel-spool-store.c
@@ -125,7 +125,7 @@ spool_fill_fi (CamelStore *store,
fi->unread = -1;
fi->total = -1;
- folder = camel_object_bag_peek (store->folders, fi->full_name);
+ folder = camel_object_bag_peek (camel_store_get_folders_bag (store), fi->full_name);
if (folder) {
if ((flags & CAMEL_STORE_FOLDER_INFO_FAST) == 0)
camel_folder_refresh_info_sync (folder, cancellable, NULL);
@@ -256,8 +256,7 @@ scan_dir (CamelStore *store,
gint isfolder = FALSE;
/* first, see if we already have it open */
- folder = camel_object_bag_peek (
- store->folders, fname);
+ folder = camel_object_bag_peek (camel_store_get_folders_bag (store), fname);
if (folder == NULL) {
fp = fopen (tmp, "r");
if (fp != NULL) {
diff --git a/src/camel/providers/local/camel-spool-summary.c b/src/camel/providers/local/camel-spool-summary.c
index e78cfc9..3ee0cad 100644
--- a/src/camel/providers/local/camel-spool-summary.c
+++ b/src/camel/providers/local/camel-spool-summary.c
@@ -97,7 +97,7 @@ camel_spool_summary_new (CamelFolder *folder,
CamelStore *parent_store;
parent_store = camel_folder_get_parent_store (folder);
- camel_db_set_collate (parent_store->cdb_r, "bdata", "spool_frompos_sort", (CamelDBCollate)
camel_local_frompos_sort);
+ camel_db_set_collate (camel_store_get_db (parent_store), "bdata", "spool_frompos_sort",
(CamelDBCollate) camel_local_frompos_sort);
((CamelFolderSummary *) new)->sort_by = "bdata";
((CamelFolderSummary *) new)->collate = "spool_frompos_sort";
}
diff --git a/src/camel/providers/nntp/camel-nntp-store.c b/src/camel/providers/nntp/camel-nntp-store.c
index 100dd09..6c2e5b4 100644
--- a/src/camel/providers/nntp/camel-nntp-store.c
+++ b/src/camel/providers/nntp/camel-nntp-store.c
@@ -1471,7 +1471,7 @@ nntp_store_initable_init (GInitable *initable,
store = CAMEL_STORE (initable);
service = CAMEL_SERVICE (initable);
- store->flags |= CAMEL_STORE_USE_CACHE_DIR;
+ camel_store_set_flags (store, camel_store_get_flags (store) | CAMEL_STORE_USE_CACHE_DIR);
nntp_migrate_to_user_cache_dir (service);
/* Chain up to parent interface's init() method. */
@@ -1783,7 +1783,7 @@ camel_nntp_store_init (CamelNNTPStore *nntp_store)
/* Clear the default flags. We don't want a virtual Junk or Trash
* folder and the user can't create/delete/rename newsgroup folders. */
- CAMEL_STORE (nntp_store)->flags = 0;
+ camel_store_set_flags (CAMEL_STORE (nntp_store), 0);
}
/**
diff --git a/src/camel/providers/nntp/camel-nntp-summary.c b/src/camel/providers/nntp/camel-nntp-summary.c
index bc0646e..3964205 100644
--- a/src/camel/providers/nntp/camel-nntp-summary.c
+++ b/src/camel/providers/nntp/camel-nntp-summary.c
@@ -514,7 +514,7 @@ camel_nntp_summary_check (CamelNNTPSummary *cns,
g_clear_object (&nntp_cache);
}
- camel_db_delete_uids (parent_store->cdb_w, full_name, del, NULL);
+ camel_db_delete_uids (camel_store_get_db (parent_store), full_name, del, NULL);
g_list_foreach (del, (GFunc) camel_pstring_free, NULL);
g_list_free (del);
@@ -551,8 +551,7 @@ update:
guint32 unread = 0;
count = camel_folder_summary_count (s);
- camel_db_count_unread_message_info (
- parent_store->cdb_r, full_name, &unread, NULL);
+ camel_db_count_unread_message_info (camel_store_get_db (parent_store), full_name, &unread,
NULL);
if (si->info.unread != unread
|| si->info.total != count
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]