[evolution-data-server] CamelLocalStore cleanups.
- From: Matthew Barnes <mbarnes src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evolution-data-server] CamelLocalStore cleanups.
- Date: Fri, 8 Jul 2011 19:46:54 +0000 (UTC)
commit aee9e04d14c65dbcdd12f163a873e363aba918fa
Author: Matthew Barnes <mbarnes redhat com>
Date: Fri Jul 8 15:32:52 2011 -0400
CamelLocalStore cleanups.
camel/providers/local/camel-local-store.c | 441 ++++++++++++++++-------------
camel/providers/local/camel-local-store.h | 34 ++-
camel/providers/local/camel-mbox-store.c | 53 +++-
3 files changed, 294 insertions(+), 234 deletions(-)
---
diff --git a/camel/providers/local/camel-local-store.c b/camel/providers/local/camel-local-store.c
index 2d21b67..dbe2bef 100644
--- a/camel/providers/local/camel-local-store.c
+++ b/camel/providers/local/camel-local-store.c
@@ -39,22 +39,63 @@
#define d(x)
-static CamelFolder *local_store_get_folder_sync (CamelStore *store, const gchar *folder_name, CamelStoreGetFolderFlags flags, GCancellable *cancellable, GError **error);
-static gchar *get_name (CamelService *service, gboolean brief);
-static CamelFolder *local_store_get_inbox_folder_sync (CamelStore *store, GCancellable *cancellable, GError **error);
-static CamelFolder *local_store_get_junk_folder_sync (CamelStore *store, GCancellable *cancellable, GError **error);
-static CamelFolder *local_store_get_trash_folder_sync (CamelStore *store, GCancellable *cancellable, GError **error);
-static CamelFolderInfo *local_store_get_folder_info_sync (CamelStore *store, const gchar *top, CamelStoreGetFolderInfoFlags flags, GCancellable *cancellable, GError **error);
-static gboolean local_store_delete_folder_sync (CamelStore *store, const gchar *folder_name, GCancellable *cancellable, GError **error);
-static gboolean local_store_rename_folder_sync (CamelStore *store, const gchar *old, const gchar *new, GCancellable *cancellable, GError **error);
-static CamelFolderInfo *local_store_create_folder_sync (CamelStore *store, const gchar *parent_name, const gchar *folder_name, GCancellable *cancellable, GError **error);
-static gboolean local_can_refresh_folder (CamelStore *store, CamelFolderInfo *info, GError **error);
-
-static gchar *local_get_full_path (CamelLocalStore *lf, const gchar *full_name);
-static gchar *local_get_meta_path (CamelLocalStore *lf, const gchar *full_name, const gchar *ext);
-
G_DEFINE_TYPE (CamelLocalStore, camel_local_store, CAMEL_TYPE_STORE)
+static gint
+xrename (const gchar *oldp,
+ const gchar *newp,
+ const gchar *prefix,
+ const gchar *suffix,
+ gint missingok,
+ GError **error)
+{
+ struct stat st;
+ gchar *old = g_strconcat (prefix, oldp, suffix, NULL);
+ gchar *new = g_strconcat (prefix, newp, suffix, NULL);
+ gint ret = -1;
+ gint err = 0;
+
+ d(printf("renaming %s%s to %s%s\n", oldp, suffix, newp, suffix));
+
+ if (g_stat (old, &st) == -1) {
+ if (missingok && errno == ENOENT) {
+ ret = 0;
+ } else {
+ err = errno;
+ ret = -1;
+ }
+ } else if ((!g_file_test (new, G_FILE_TEST_EXISTS) || g_remove (new) == 0) &&
+ g_rename (old, new) == 0) {
+ ret = 0;
+ } else {
+ err = errno;
+ ret = -1;
+ }
+
+ if (ret == -1) {
+ g_set_error (
+ error, G_IO_ERROR,
+ g_io_error_from_errno (err),
+ _("Could not rename folder %s to %s: %s"),
+ old, new, g_strerror (err));
+ }
+
+ g_free (old);
+ g_free (new);
+ return ret;
+}
+
+static void
+local_store_finalize (GObject *object)
+{
+ CamelLocalStore *local_store = CAMEL_LOCAL_STORE (object);
+
+ g_free (local_store->toplevel_dir);
+
+ /* Chain up to parent's finalize() method. */
+ G_OBJECT_CLASS (camel_local_store_parent_class)->finalize (object);
+}
+
static void
local_store_constructed (GObject *object)
{
@@ -103,56 +144,25 @@ local_store_constructed (GObject *object)
g_free (local_store_path);
}
-static void
-local_store_finalize (GObject *object)
-{
- CamelLocalStore *local_store = CAMEL_LOCAL_STORE (object);
-
- g_free (local_store->toplevel_dir);
-
- /* Chain up to parent's finalize() method. */
- G_OBJECT_CLASS (camel_local_store_parent_class)->finalize (object);
-}
-
-static void
-camel_local_store_class_init (CamelLocalStoreClass *class)
+static gchar *
+local_store_get_name (CamelService *service,
+ gboolean brief)
{
- GObjectClass *object_class;
- CamelServiceClass *service_class;
- CamelStoreClass *store_class;
-
- object_class = G_OBJECT_CLASS (class);
- object_class->finalize = local_store_finalize;
- object_class->constructed = local_store_constructed;
-
- service_class = CAMEL_SERVICE_CLASS (class);
- service_class->get_name = get_name;
-
- store_class = CAMEL_STORE_CLASS (class);
- store_class->can_refresh_folder = local_can_refresh_folder;
- store_class->free_folder_info = camel_store_free_folder_info_full;
- store_class->get_folder_sync = local_store_get_folder_sync;
- store_class->get_folder_info_sync = local_store_get_folder_info_sync;
- store_class->get_inbox_folder_sync = local_store_get_inbox_folder_sync;
- store_class->get_junk_folder_sync = local_store_get_junk_folder_sync;
- store_class->get_trash_folder_sync = local_store_get_trash_folder_sync;
- store_class->create_folder_sync = local_store_create_folder_sync;
- store_class->delete_folder_sync = local_store_delete_folder_sync;
- store_class->rename_folder_sync = local_store_rename_folder_sync;
-
- class->get_full_path = local_get_full_path;
- class->get_meta_path = local_get_meta_path;
-}
+ gchar *dir = ((CamelLocalStore*) service)->toplevel_dir;
-static void
-camel_local_store_init (CamelLocalStore *local_store)
-{
+ if (brief)
+ return g_strdup (dir);
+ else
+ return g_strdup_printf (_("Local mail file %s"), dir);
}
-const gchar *
-camel_local_store_get_toplevel_dir (CamelLocalStore *store)
+static gboolean
+local_store_can_refresh_folder (CamelStore *store,
+ CamelFolderInfo *info,
+ GError **error)
{
- return store->toplevel_dir;
+ /* any local folder can be refreshed */
+ return TRUE;
}
static CamelFolder *
@@ -212,6 +222,22 @@ local_store_get_folder_sync (CamelStore *store,
return (CamelFolder *) 0xdeadbeef;
}
+static CamelFolderInfo *
+local_store_get_folder_info_sync (CamelStore *store,
+ const gchar *top,
+ CamelStoreGetFolderInfoFlags flags,
+ GCancellable *cancellable,
+ GError **error)
+{
+ /* FIXME: This is broken, but it corresponds to what was
+ * there before.
+ */
+
+ d(printf("-- LOCAL STORE -- get folder info: %s\n", top));
+
+ return NULL;
+}
+
static CamelFolder *
local_store_get_inbox_folder_sync (CamelStore *store,
GCancellable *cancellable,
@@ -226,22 +252,26 @@ local_store_get_inbox_folder_sync (CamelStore *store,
}
static CamelFolder *
-local_store_get_trash_folder_sync (CamelStore *store,
- GCancellable *cancellable,
- GError **error)
+local_store_get_junk_folder_sync (CamelStore *store,
+ GCancellable *cancellable,
+ GError **error)
{
CamelFolder *folder;
- /* Chain up to parent's get_trash_folder_sync() method. */
+ /* Chain up to parent's get_junk_folder_sync() method. */
folder = CAMEL_STORE_CLASS (camel_local_store_parent_class)->
- get_trash_folder_sync (store, cancellable, error);
+ get_junk_folder_sync (store, cancellable, error);
if (folder) {
CamelObject *object = CAMEL_OBJECT (folder);
- gchar *state = camel_local_store_get_meta_path(store, CAMEL_VTRASH_NAME, ".cmeta");
+ gchar *state;
+ state = camel_local_store_get_meta_path (
+ CAMEL_LOCAL_STORE (store),
+ CAMEL_VJUNK_NAME, ".cmeta");
camel_object_set_state_filename (object, state);
g_free (state);
+
/* no defaults? */
camel_object_state_read (object);
}
@@ -250,22 +280,26 @@ local_store_get_trash_folder_sync (CamelStore *store,
}
static CamelFolder *
-local_store_get_junk_folder_sync (CamelStore *store,
- GCancellable *cancellable,
- GError **error)
+local_store_get_trash_folder_sync (CamelStore *store,
+ GCancellable *cancellable,
+ GError **error)
{
CamelFolder *folder;
- /* Chain up to parent's get_junk_folder_sync() method. */
+ /* Chain up to parent's get_trash_folder_sync() method. */
folder = CAMEL_STORE_CLASS (camel_local_store_parent_class)->
- get_junk_folder_sync (store, cancellable, error);
+ get_trash_folder_sync (store, cancellable, error);
if (folder) {
CamelObject *object = CAMEL_OBJECT (folder);
- gchar *state = camel_local_store_get_meta_path(store, CAMEL_VJUNK_NAME, ".cmeta");
+ gchar *state;
+ state = camel_local_store_get_meta_path (
+ CAMEL_LOCAL_STORE (store),
+ CAMEL_VTRASH_NAME, ".cmeta");
camel_object_set_state_filename (object, state);
g_free (state);
+
/* no defaults? */
camel_object_state_read (object);
}
@@ -273,33 +307,6 @@ local_store_get_junk_folder_sync (CamelStore *store,
return folder;
}
-static gchar *
-get_name (CamelService *service, gboolean brief)
-{
- gchar *dir = ((CamelLocalStore*) service)->toplevel_dir;
-
- if (brief)
- return g_strdup (dir);
- else
- return g_strdup_printf (_("Local mail file %s"), dir);
-}
-
-static CamelFolderInfo *
-local_store_get_folder_info_sync (CamelStore *store,
- const gchar *top,
- CamelStoreGetFolderInfoFlags flags,
- GCancellable *cancellable,
- GError **error)
-{
- /* FIXME: This is broken, but it corresponds to what was
- * there before.
- */
-
- d(printf("-- LOCAL STORE -- get folder info: %s\n", top));
-
- return NULL;
-}
-
static CamelFolderInfo *
local_store_create_folder_sync (CamelStore *store,
const gchar *parent_name,
@@ -358,48 +365,72 @@ local_store_create_folder_sync (CamelStore *store,
return info;
}
-static gint
-xrename (const gchar *oldp,
- const gchar *newp,
- const gchar *prefix,
- const gchar *suffix,
- gint missingok,
- GError **error)
+/* default implementation, only delete metadata */
+static gboolean
+local_store_delete_folder_sync (CamelStore *store,
+ const gchar *folder_name,
+ GCancellable *cancellable,
+ GError **error)
{
- struct stat st;
- gchar *old = g_strconcat (prefix, oldp, suffix, NULL);
- gchar *new = g_strconcat (prefix, newp, suffix, NULL);
- gint ret = -1;
- gint err = 0;
+ CamelFolderInfo *fi;
+ CamelFolder *lf;
+ gchar *name;
+ gchar *str;
- d(printf("renaming %s%s to %s%s\n", oldp, suffix, newp, suffix));
+ /* remove metadata only */
+ name = g_strdup_printf("%s%s", CAMEL_LOCAL_STORE(store)->toplevel_dir, folder_name);
+ str = g_strdup_printf("%s.ibex", name);
+ if (camel_text_index_remove (str) == -1 && errno != ENOENT && errno != ENOTDIR) {
+ g_set_error (
+ error, G_IO_ERROR,
+ g_io_error_from_errno (errno),
+ _("Could not delete folder index file '%s': %s"),
+ str, g_strerror (errno));
+ g_free (str);
+ g_free (name);
+ return FALSE;
+ }
+ g_free (str);
- if (g_stat (old, &st) == -1) {
- if (missingok && errno == ENOENT) {
- ret = 0;
- } else {
- err = errno;
- ret = -1;
- }
- } else if ((!g_file_test (new, G_FILE_TEST_EXISTS) || g_remove (new) == 0) &&
- g_rename (old, new) == 0) {
- ret = 0;
- } else {
- err = errno;
- ret = -1;
+ str = NULL;
+ if ((lf = camel_store_get_folder_sync (store, folder_name, 0, cancellable, NULL))) {
+ CamelObject *object = CAMEL_OBJECT (lf);
+ const gchar *state_filename;
+
+ state_filename = camel_object_get_state_filename (object);
+ str = g_strdup (state_filename);
+
+ camel_object_set_state_filename (object, NULL);
+
+ g_object_unref (lf);
}
- if (ret == -1) {
+ if (str == NULL)
+ str = g_strdup_printf ("%s.cmeta", name);
+
+ if (g_unlink (str) == -1 && errno != ENOENT && errno != ENOTDIR) {
g_set_error (
error, G_IO_ERROR,
- g_io_error_from_errno (err),
- _("Could not rename folder %s to %s: %s"),
- old, new, g_strerror (err));
+ g_io_error_from_errno (errno),
+ _("Could not delete folder meta file '%s': %s"),
+ str, g_strerror (errno));
+ g_free (name);
+ g_free (str);
+ return FALSE;
}
- g_free (old);
- g_free (new);
- return ret;
+ g_free (str);
+ g_free (name);
+
+ fi = camel_folder_info_new ();
+ fi->full_name = g_strdup (folder_name);
+ fi->display_name = g_path_get_basename (folder_name);
+ fi->unread = -1;
+
+ camel_store_folder_deleted (store, fi);
+ camel_folder_info_free (fi);
+
+ return TRUE;
}
/* default implementation, rename all */
@@ -479,91 +510,60 @@ ibex_failed:
return FALSE;
}
-/* default implementation, only delete metadata */
-static gboolean
-local_store_delete_folder_sync (CamelStore *store,
- const gchar *folder_name,
- GCancellable *cancellable,
- GError **error)
+static gchar *
+local_store_get_full_path (CamelLocalStore *ls,
+ const gchar *full_name)
{
- CamelFolderInfo *fi;
- CamelFolder *lf;
- gchar *name;
- gchar *str;
-
- /* remove metadata only */
- name = g_strdup_printf("%s%s", CAMEL_LOCAL_STORE(store)->toplevel_dir, folder_name);
- str = g_strdup_printf("%s.ibex", name);
- if (camel_text_index_remove (str) == -1 && errno != ENOENT && errno != ENOTDIR) {
- g_set_error (
- error, G_IO_ERROR,
- g_io_error_from_errno (errno),
- _("Could not delete folder index file '%s': %s"),
- str, g_strerror (errno));
- g_free (str);
- g_free (name);
- return FALSE;
- }
- g_free (str);
-
- str = NULL;
- if ((lf = camel_store_get_folder_sync (store, folder_name, 0, cancellable, NULL))) {
- CamelObject *object = CAMEL_OBJECT (lf);
- const gchar *state_filename;
-
- state_filename = camel_object_get_state_filename (object);
- str = g_strdup (state_filename);
-
- camel_object_set_state_filename (object, NULL);
-
- g_object_unref (lf);
- }
-
- if (str == NULL)
- str = g_strdup_printf ("%s.cmeta", name);
+ return g_strdup_printf ("%s%s", ls->toplevel_dir, full_name);
+}
- if (g_unlink (str) == -1 && errno != ENOENT && errno != ENOTDIR) {
- g_set_error (
- error, G_IO_ERROR,
- g_io_error_from_errno (errno),
- _("Could not delete folder meta file '%s': %s"),
- str, g_strerror (errno));
- g_free (name);
- g_free (str);
- return FALSE;
- }
+static gchar *
+local_store_get_meta_path (CamelLocalStore *ls,
+ const gchar *full_name,
+ const gchar *ext)
+{
+ return g_strdup_printf ("%s%s%s", ls->toplevel_dir, full_name, ext);
+}
- g_free (str);
- g_free (name);
+static void
+camel_local_store_class_init (CamelLocalStoreClass *class)
+{
+ GObjectClass *object_class;
+ CamelServiceClass *service_class;
+ CamelStoreClass *store_class;
- fi = camel_folder_info_new ();
- fi->full_name = g_strdup (folder_name);
- fi->display_name = g_path_get_basename (folder_name);
- fi->unread = -1;
+ object_class = G_OBJECT_CLASS (class);
+ object_class->finalize = local_store_finalize;
+ object_class->constructed = local_store_constructed;
- camel_store_folder_deleted (store, fi);
- camel_folder_info_free (fi);
+ service_class = CAMEL_SERVICE_CLASS (class);
+ service_class->get_name = local_store_get_name;
- return TRUE;
-}
+ store_class = CAMEL_STORE_CLASS (class);
+ store_class->can_refresh_folder = local_store_can_refresh_folder;
+ store_class->free_folder_info = camel_store_free_folder_info_full;
+ store_class->get_folder_sync = local_store_get_folder_sync;
+ store_class->get_folder_info_sync = local_store_get_folder_info_sync;
+ store_class->get_inbox_folder_sync = local_store_get_inbox_folder_sync;
+ store_class->get_junk_folder_sync = local_store_get_junk_folder_sync;
+ store_class->get_trash_folder_sync = local_store_get_trash_folder_sync;
+ store_class->create_folder_sync = local_store_create_folder_sync;
+ store_class->delete_folder_sync = local_store_delete_folder_sync;
+ store_class->rename_folder_sync = local_store_rename_folder_sync;
-static gchar *
-local_get_full_path (CamelLocalStore *ls, const gchar *full_name)
-{
- return g_strdup_printf("%s%s", ls->toplevel_dir, full_name);
+ class->get_full_path = local_store_get_full_path;
+ class->get_meta_path = local_store_get_meta_path;
}
-static gchar *
-local_get_meta_path (CamelLocalStore *ls, const gchar *full_name, const gchar *ext)
+static void
+camel_local_store_init (CamelLocalStore *local_store)
{
- return g_strdup_printf("%s%s%s", ls->toplevel_dir, full_name, ext);
}
-static gboolean
-local_can_refresh_folder (CamelStore *store, CamelFolderInfo *info, GError **error)
+const gchar *
+camel_local_store_get_toplevel_dir (CamelLocalStore *store)
{
- /* any local folder can be refreshed */
- return TRUE;
+ return store->toplevel_dir;
}
/* Returns whether is this store used as 'On This Computer' main store */
@@ -575,8 +575,41 @@ camel_local_store_is_main_store (CamelLocalStore *store)
return store->is_main_store;
}
+gchar *
+camel_local_store_get_full_path (CamelLocalStore *store,
+ const gchar *full_name)
+{
+ CamelLocalStoreClass *class;
+
+ g_return_val_if_fail (CAMEL_IS_LOCAL_STORE (store), NULL);
+ /* XXX Guard against full_name == NULL? */
+
+ class = CAMEL_LOCAL_STORE_GET_CLASS (store);
+ g_return_val_if_fail (class->get_full_path != NULL, NULL);
+
+ return class->get_full_path (store, full_name);
+}
+
+gchar *
+camel_local_store_get_meta_path (CamelLocalStore *store,
+ const gchar *full_name,
+ const gchar *ext)
+{
+ CamelLocalStoreClass *class;
+
+ g_return_val_if_fail (CAMEL_IS_LOCAL_STORE (store), NULL);
+ /* XXX Guard against full_name == NULL? */
+ /* XXX Guard against ext == NULL? */
+
+ class = CAMEL_LOCAL_STORE_GET_CLASS (store);
+ g_return_val_if_fail (class->get_meta_path != NULL, NULL);
+
+ return class->get_meta_path (store, full_name, ext);
+}
+
guint32
-camel_local_store_get_folder_type_by_full_name (CamelLocalStore *store, const gchar *full_name)
+camel_local_store_get_folder_type_by_full_name (CamelLocalStore *store,
+ const gchar *full_name)
{
g_return_val_if_fail (store != NULL, 0);
g_return_val_if_fail (full_name != NULL, 0);
diff --git a/camel/providers/local/camel-local-store.h b/camel/providers/local/camel-local-store.h
index 7198fb9..c6effa0 100644
--- a/camel/providers/local/camel-local-store.h
+++ b/camel/providers/local/camel-local-store.h
@@ -48,9 +48,11 @@ G_BEGIN_DECLS
typedef struct _CamelLocalStore CamelLocalStore;
typedef struct _CamelLocalStoreClass CamelLocalStoreClass;
+typedef struct _CamelLocalStorePrivate CamelLocalStorePrivate;
struct _CamelLocalStore {
CamelStore parent;
+ CamelLocalStorePrivate *priv;
gchar *toplevel_dir;
gboolean is_main_store;
@@ -59,23 +61,25 @@ struct _CamelLocalStore {
struct _CamelLocalStoreClass {
CamelStoreClass parent_class;
- gchar *(*get_full_path)(CamelLocalStore *ls, const gchar *full_name);
- gchar *(*get_meta_path)(CamelLocalStore *ls, const gchar *full_name, const gchar *ext);
+ gchar * (*get_full_path) (CamelLocalStore *ls,
+ const gchar *full_name);
+ gchar * (*get_meta_path) (CamelLocalStore *ls,
+ const gchar *full_name,
+ const gchar *ext);
};
-GType camel_local_store_get_type (void);
-
-const gchar *camel_local_store_get_toplevel_dir (CamelLocalStore *store);
-
-gboolean camel_local_store_is_main_store (CamelLocalStore *store);
-guint32 camel_local_store_get_folder_type_by_full_name (CamelLocalStore *store, const gchar *full_name);
-
-#define camel_local_store_get_full_path(ls, name) \
- (CAMEL_LOCAL_STORE_GET_CLASS (ls)->get_full_path \
- (CAMEL_LOCAL_STORE (ls), (name)))
-#define camel_local_store_get_meta_path(ls, name, ext) \
- (CAMEL_LOCAL_STORE_GET_CLASS (ls)->get_meta_path \
- (CAMEL_LOCAL_STORE (ls), (name), (ext)))
+GType camel_local_store_get_type (void);
+const gchar * camel_local_store_get_toplevel_dir
+ (CamelLocalStore *store);
+gboolean camel_local_store_is_main_store (CamelLocalStore *store);
+gchar * camel_local_store_get_full_path (CamelLocalStore *store,
+ const gchar *full_name);
+gchar * camel_local_store_get_meta_path (CamelLocalStore *store,
+ const gchar *full_name,
+ const gchar *ext);
+guint32 camel_local_store_get_folder_type_by_full_name
+ (CamelLocalStore *store,
+ const gchar *full_name);
G_END_DECLS
diff --git a/camel/providers/local/camel-mbox-store.c b/camel/providers/local/camel-mbox-store.c
index f1e72f6..01f37c0 100644
--- a/camel/providers/local/camel-mbox-store.c
+++ b/camel/providers/local/camel-mbox-store.c
@@ -112,12 +112,17 @@ fill_fi (CamelStore *store,
fi->total = camel_folder_get_message_count (folder);
g_object_unref (folder);
} else {
+ CamelLocalStore *local_store;
gchar *path, *folderpath;
CamelMboxSummary *mbs;
+ local_store = CAMEL_LOCAL_STORE (store);
+
/* This should be fast enough not to have to test for INFO_FAST */
- path = camel_local_store_get_meta_path(store, fi->full_name, ".ev-summary");
- folderpath = camel_local_store_get_full_path (store, fi->full_name);
+ path = camel_local_store_get_meta_path (
+ local_store, fi->full_name, ".ev-summary");
+ folderpath = camel_local_store_get_full_path (
+ local_store, fi->full_name);
mbs = (CamelMboxSummary *) camel_mbox_summary_new (NULL, path, folderpath, NULL);
/* FIXME[disk-summary] track exception */
@@ -321,6 +326,7 @@ mbox_store_get_folder_sync (CamelStore *store,
GError **error)
{
CamelStoreClass *store_class;
+ CamelLocalStore *local_store;
struct stat st;
gchar *name;
@@ -329,7 +335,8 @@ mbox_store_get_folder_sync (CamelStore *store,
if (!store_class->get_folder_sync (store, folder_name, flags, cancellable, error))
return NULL;
- name = camel_local_store_get_full_path (store, folder_name);
+ local_store = CAMEL_LOCAL_STORE (store);
+ name = camel_local_store_get_full_path (local_store, folder_name);
if (g_stat (name, &st) == -1) {
gchar *basename;
@@ -423,6 +430,7 @@ mbox_store_get_folder_info_sync (CamelStore *store,
GCancellable *cancellable,
GError **error)
{
+ CamelLocalStore *local_store;
GHashTable *visited;
#ifndef G_OS_WIN32
struct _inode *inode;
@@ -432,8 +440,11 @@ mbox_store_get_folder_info_sync (CamelStore *store,
gchar *basename;
struct stat st;
- top = top ? top : "";
- path = camel_local_store_get_full_path (store, top);
+ if (top == NULL)
+ top = "";
+
+ local_store = CAMEL_LOCAL_STORE (store);
+ path = camel_local_store_get_full_path (local_store, top);
if (*top == '\0') {
/* requesting root dir scan */
@@ -506,12 +517,16 @@ mbox_store_create_folder_sync (CamelStore *store,
{
/* FIXME: this is almost an exact copy of CamelLocalStore::create_folder() except that we use
* different path schemes... need to find a way to share parent's code? */
- const gchar *toplevel_dir =((CamelLocalStore *) store)->toplevel_dir;
+ CamelLocalStore *local_store;
CamelFolderInfo *info = NULL;
+ const gchar *toplevel_dir;
gchar *path, *name, *dir;
CamelFolder *folder;
struct stat st;
+ local_store = CAMEL_LOCAL_STORE (store);
+ toplevel_dir = local_store->toplevel_dir;
+
if (!g_path_is_absolute (toplevel_dir)) {
g_set_error (
error, CAMEL_STORE_ERROR,
@@ -529,11 +544,11 @@ mbox_store_create_folder_sync (CamelStore *store,
}
if (parent_name && *parent_name)
- name = g_strdup_printf("%s/%s", parent_name, folder_name);
+ name = g_strdup_printf ("%s/%s", parent_name, folder_name);
else
name = g_strdup (folder_name);
- path = camel_local_store_get_full_path (store, name);
+ path = camel_local_store_get_full_path (local_store, name);
dir = g_path_get_dirname (path);
if (g_mkdir_with_parents (dir, 0777) == -1 && errno != EEXIST) {
@@ -587,12 +602,14 @@ mbox_store_delete_folder_sync (CamelStore *store,
GCancellable *cancellable,
GError **error)
{
+ CamelLocalStore *local_store;
CamelFolderInfo *fi;
CamelFolder *lf;
gchar *name, *path;
struct stat st;
- name = camel_local_store_get_full_path (store, folder_name);
+ local_store = CAMEL_LOCAL_STORE (store);
+ name = camel_local_store_get_full_path (local_store, folder_name);
path = g_strdup_printf("%s.sbd", name);
if (g_rmdir (path) == -1 && errno != ENOENT) {
@@ -652,7 +669,8 @@ mbox_store_delete_folder_sync (CamelStore *store,
* naming convention is different. Need to find a way for
* CamelLocalStore to be able to construct the folder & meta
* paths itself */
- path = camel_local_store_get_meta_path(store, folder_name, ".ev-summary");
+ path = camel_local_store_get_meta_path (
+ local_store, folder_name, ".ev-summary");
if (g_unlink (path) == -1 && errno != ENOENT) {
g_set_error (
error, G_IO_ERROR,
@@ -666,7 +684,8 @@ mbox_store_delete_folder_sync (CamelStore *store,
g_free (path);
- path = camel_local_store_get_meta_path(store, folder_name, ".ev-summary-meta");
+ path = camel_local_store_get_meta_path (
+ local_store, folder_name, ".ev-summary-meta");
if (g_unlink (path) == -1 && errno != ENOENT) {
g_set_error (
error, G_IO_ERROR,
@@ -680,7 +699,8 @@ mbox_store_delete_folder_sync (CamelStore *store,
g_free (path);
- path = camel_local_store_get_meta_path(store, folder_name, ".ibex");
+ path = camel_local_store_get_meta_path (
+ local_store, folder_name, ".ibex");
if (camel_text_index_remove (path) == -1 && errno != ENOENT) {
g_set_error (
error, G_IO_ERROR,
@@ -708,7 +728,8 @@ mbox_store_delete_folder_sync (CamelStore *store,
}
if (path == NULL)
- path = camel_local_store_get_meta_path(store, folder_name, ".cmeta");
+ path = camel_local_store_get_meta_path (
+ local_store, folder_name, ".cmeta");
if (g_unlink (path) == -1 && errno != ENOENT) {
g_set_error (
@@ -743,6 +764,7 @@ mbox_store_rename_folder_sync (CamelStore *store,
GCancellable *cancellable,
GError **error)
{
+ CamelLocalStore *local_store;
CamelLocalFolder *folder = NULL;
gchar *oldibex, *newibex, *newdir;
gint errnosav;
@@ -756,8 +778,9 @@ mbox_store_rename_folder_sync (CamelStore *store,
/* try to rollback failures, has obvious races */
- oldibex = camel_local_store_get_meta_path (store, old, ".ibex");
- newibex = camel_local_store_get_meta_path (store, new, ".ibex");
+ local_store = CAMEL_LOCAL_STORE (store);
+ oldibex = camel_local_store_get_meta_path (local_store, old, ".ibex");
+ newibex = camel_local_store_get_meta_path (local_store, new, ".ibex");
newdir = g_path_get_dirname (newibex);
if (g_mkdir_with_parents (newdir, 0700) == -1) {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]