[evolution-data-server] Adapt to camel api changes
- From: Chenthill Palanisamy <pchen src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evolution-data-server] Adapt to camel api changes
- Date: Mon, 25 Oct 2010 10:43:15 +0000 (UTC)
commit 4b332e096772f4ffd6fe29c90d6e15ae3be21d21
Author: Chenthill Palanisamy <pchenthill novell com>
Date: Mon Oct 4 14:10:30 2010 +0530
Adapt to camel api changes
camel/providers/local/camel-maildir-store.c | 328 +++------------------------
1 files changed, 31 insertions(+), 297 deletions(-)
---
diff --git a/camel/providers/local/camel-maildir-store.c b/camel/providers/local/camel-maildir-store.c
index 4552cc9..fd65245 100644
--- a/camel/providers/local/camel-maildir-store.c
+++ b/camel/providers/local/camel-maildir-store.c
@@ -44,51 +44,17 @@ G_DEFINE_TYPE (CamelMaildirStore, camel_maildir_store, CAMEL_TYPE_LOCAL_STORE)
#define HIER_SEP "."
#define HIER_SEP_CHAR '.'
-static CamelFolder *maildir_get_folder (CamelStore * store, const gchar *folder_name, guint32 flags, GError **error);
-static CamelFolderInfo *maildir_create_folder (CamelStore *store, const gchar *parent_name, const gchar *folder_name,
- GError **error);
-static CamelFolder *maildir_get_inbox (CamelStore *store, GError **error);
-static gboolean maildir_delete_folder (CamelStore * store, const gchar *folder_name, GError **error);
-static gboolean maildir_rename_folder (CamelStore *store, const gchar *old, const gchar *new, GError **error);
+static CamelFolder * maildir_store_get_folder_sync (CamelStore *store, const gchar *folder_name, CamelStoreGetFolderFlags flags,
+ GCancellable *cancellable, GError **error);
+static CamelFolderInfo *maildir_store_create_folder_sync (CamelStore *store, const gchar *parent_name, const gchar *folder_name,
+ GCancellable *cancellable, GError **error);
+static gboolean maildir_store_delete_folder_sync (CamelStore * store, const gchar *folder_name, GCancellable *cancellable, GError **error);
-static CamelFolderInfo * maildir_get_folder_info (CamelStore *store, const gchar *top, guint32 flags, GError **error);
-
-static gboolean maildir_compare_folder_name (gconstpointer a, gconstpointer b);
-static guint maildir_hash_folder_name (gconstpointer a);
static char *maildir_full_name_to_dir_name (const gchar *full_name);
static char *maildir_dir_name_to_fullname (const gchar *dir_name);
static gchar *maildir_get_full_path (CamelLocalStore *ls, const gchar *full_name);
static gchar *maildir_get_meta_path (CamelLocalStore *ls, const gchar *full_name, const gchar *ext);
-G_DEFINE_TYPE (CamelMaildirStore, camel_maildir_store, CAMEL_TYPE_LOCAL_STORE)
-
-static void
-camel_maildir_store_class_init (CamelMaildirStoreClass *class)
-{
- CamelStoreClass *store_class;
- CamelLocalStoreClass *local_class;
-
- store_class = CAMEL_STORE_CLASS (class);
- store_class->hash_folder_name = maildir_hash_folder_name;
- store_class->compare_folder_name = maildir_compare_folder_name;
- store_class->get_folder = maildir_get_folder;
- store_class->create_folder = maildir_create_folder;
- store_class->get_inbox = maildir_get_inbox;
- store_class->delete_folder = maildir_delete_folder;
- store_class->rename_folder = maildir_rename_folder;
- store_class->get_folder_info = maildir_get_folder_info;
- store_class->free_folder_info = camel_store_free_folder_info_full;
-
- local_class = CAMEL_LOCAL_STORE_CLASS (class);
- local_class->get_full_path = maildir_get_full_path;
- local_class->get_meta_path = maildir_get_meta_path;
-}
-
-static void
-camel_maildir_store_init (CamelMaildirStore *maildir_store)
-{
-}
-
/* This fixes up some historical cruft of names starting with "./" */
static const gchar *
md_canon_name (const gchar *a)
@@ -103,23 +69,11 @@ md_canon_name (const gchar *a)
return a;
}
-static guint
-maildir_hash_folder_name (gconstpointer a)
-{
- return g_str_hash (md_canon_name (a));
-}
-
-static gboolean
-maildir_compare_folder_name (gconstpointer a,
- gconstpointer b)
-{
- return g_str_equal (md_canon_name (a), md_canon_name (b));
-}
-
static CamelFolderInfo *
-maildir_create_folder (CamelStore *store,
+maildir_store_create_folder_sync (CamelStore *store,
const gchar *parent_name,
const gchar *folder_name,
+ GCancellable *cancellable,
GError **error)
{
gchar *path = ((CamelLocalStore *)store)->toplevel_dir;
@@ -162,23 +116,24 @@ maildir_create_folder (CamelStore *store,
else
name = g_strdup_printf("%s", folder_name);
- folder = maildir_get_folder (store, name, CAMEL_STORE_FOLDER_CREATE, error);
+ folder = maildir_store_get_folder_sync (store, name, CAMEL_STORE_FOLDER_CREATE, cancellable, error);
if (folder) {
g_object_unref (folder);
- info = CAMEL_STORE_GET_CLASS (store)->get_folder_info (
- store, name, 0, error);
+ info = CAMEL_STORE_GET_CLASS (store)->get_folder_info_sync (
+ store, name, 0, cancellable, error);
}
g_free (name);
return info;
}
-
+
static CamelFolder *
-maildir_get_folder (CamelStore *store,
- const gchar *folder_name,
- guint32 flags,
- GError **error)
+maildir_store_get_folder_sync (CamelStore *store,
+ const gchar *folder_name,
+ CamelStoreGetFolderFlags flags,
+ GCancellable *cancellable,
+ GError **error)
{
CamelStoreClass *store_class;
gchar *name, *tmp, *cur, *new, *dir_name;
@@ -191,7 +146,7 @@ maildir_get_folder (CamelStore *store,
dir_name = maildir_full_name_to_dir_name (folder_name);
store_class = CAMEL_STORE_CLASS (camel_maildir_store_parent_class);
- if (!store_class->get_folder (store, dir_name, flags, error))
+ if (!store_class->get_folder_sync (store, dir_name, flags, cancellable, error))
return NULL;
/* maildir++ directory names start with a '.' */
@@ -221,7 +176,7 @@ maildir_get_folder (CamelStore *store,
goto fail;
}
}
- folder = camel_maildir_folder_new (store, folder_name, flags, error);
+ folder = camel_maildir_folder_new (store, folder_name, flags, cancellable, error);
} else if (g_stat (name, &st) == -1) {
/* folder doesn't exist, see if we should create it */
if (errno != ENOENT) {
@@ -251,7 +206,7 @@ maildir_get_folder (CamelStore *store,
rmdir (new);
rmdir (name);
} else {
- folder = camel_maildir_folder_new (store, folder_name, flags, error);
+ folder = camel_maildir_folder_new (store, folder_name, flags, cancellable, error);
}
}
} else if (!S_ISDIR (st.st_mode)
@@ -269,7 +224,7 @@ maildir_get_folder (CamelStore *store,
_("Cannot create folder '%s': folder exists."),
folder_name);
} else {
- folder = camel_maildir_folder_new (store, folder_name, flags, error);
+ folder = camel_maildir_folder_new (store, folder_name, flags, cancellable, error);
}
fail:
g_free (name);
@@ -280,17 +235,10 @@ fail:
return folder;
}
-static CamelFolder *
-maildir_get_inbox (CamelStore *store,
- GError **error)
-{
- return camel_store_get_folder (
- store, ".", CAMEL_STORE_FOLDER_CREATE, error);
-}
-
static gboolean
-maildir_delete_folder (CamelStore *store,
+maildir_store_delete_folder_sync (CamelStore *store,
const gchar *folder_name,
+ GCancellable *cancellable,
GError **error)
{
gchar *name, *tmp, *cur, *new, *dir_name;
@@ -369,8 +317,8 @@ maildir_delete_folder (CamelStore *store,
/* Chain up to parent's delete_folder() method. */
store_class = CAMEL_STORE_CLASS (camel_maildir_store_parent_class);
- success = store_class->delete_folder (
- store, folder_name, error);
+ success = store_class->delete_folder_sync (
+ store, folder_name, cancellable, error);
}
}
@@ -382,29 +330,6 @@ maildir_delete_folder (CamelStore *store,
return success;
}
-static gboolean
-maildir_rename_folder (CamelStore *store,
- const gchar *old,
- const gchar *new,
- GError **error)
-{
- CamelStoreClass *store_class;
-
- if (strcmp(old, ".") == 0) {
- g_set_error (
- error, CAMEL_STORE_ERROR,
- CAMEL_STORE_ERROR_NO_FOLDER,
- _("Cannot rename folder: %s: Invalid operation"),
- _("Inbox"));
- return FALSE;
- }
-
- /* Chain up to parent's rename_folder() method. */
- store_class = CAMEL_STORE_CLASS (camel_maildir_store_parent_class);
- return store_class->rename_folder (store, old, new, error);
-}
-
->>>>>>> Change the maildir folder hierarchy as per maildir++ spec
static void
fill_fi (CamelStore *store,
CamelFolderInfo *fi,
@@ -596,7 +521,7 @@ scan_dirs (CamelStore *store,
continue;
}
- fi = scan_fi (store, flags, url, full_name, short_name);
+ fi = scan_fi (store, flags, url, full_name, short_name, cancellable);
g_free (full_name);
fi->flags &= ~CAMEL_FOLDER_NOCHILDREN;
@@ -633,109 +558,6 @@ maildir_store_compare_folder_name (gconstpointer a,
return g_str_equal (md_canon_name (a), md_canon_name (b));
}
-static CamelFolder *
-maildir_store_get_folder_sync (CamelStore *store,
- const gchar *folder_name,
- CamelStoreGetFolderFlags flags,
- GCancellable *cancellable,
- GError **error)
-{
- CamelStoreClass *store_class;
- gchar *name, *tmp, *cur, *new;
- struct stat st;
- CamelFolder *folder = NULL;
-
- folder_name = md_canon_name (folder_name);
-
- /* Chain up to parent's get_folder_sync() method. */
- store_class = CAMEL_STORE_CLASS (camel_maildir_store_parent_class);
- if (!store_class->get_folder_sync (
- store, folder_name, flags, cancellable, error))
- return NULL;
-
- name = g_strdup_printf("%s%s", CAMEL_LOCAL_STORE(store)->toplevel_dir, folder_name);
- tmp = g_strdup_printf("%s/tmp", name);
- cur = g_strdup_printf("%s/cur", name);
- new = g_strdup_printf("%s/new", name);
-
- if (!strcmp(folder_name, ".")) {
- /* special case "." (aka inbox), may need to be created */
- if (g_stat (tmp, &st) != 0 || !S_ISDIR (st.st_mode)
- || g_stat (cur, &st) != 0 || !S_ISDIR (st.st_mode)
- || g_stat (new, &st) != 0 || !S_ISDIR (st.st_mode)) {
- if (mkdir (tmp, 0700) != 0
- || mkdir (cur, 0700) != 0
- || mkdir (new, 0700) != 0) {
- g_set_error (
- error, G_IO_ERROR,
- g_io_error_from_errno (errno),
- _("Cannot create folder '%s': %s"),
- folder_name, g_strerror (errno));
- rmdir (tmp);
- rmdir (cur);
- rmdir (new);
- goto fail;
- }
- }
- folder = camel_maildir_folder_new (store, folder_name, flags, cancellable, error);
- } else if (g_stat (name, &st) == -1) {
- /* folder doesn't exist, see if we should create it */
- if (errno != ENOENT) {
- g_set_error (
- error, G_IO_ERROR,
- g_io_error_from_errno (errno),
- _("Cannot get folder '%s': %s"),
- folder_name, g_strerror (errno));
- } else if ((flags & CAMEL_STORE_FOLDER_CREATE) == 0) {
- g_set_error (
- error, CAMEL_STORE_ERROR,
- CAMEL_STORE_ERROR_NO_FOLDER,
- _("Cannot get folder '%s': folder does not exist."),
- folder_name);
- } else {
- if (mkdir (name, 0700) != 0
- || mkdir (tmp, 0700) != 0
- || mkdir (cur, 0700) != 0
- || mkdir (new, 0700) != 0) {
- g_set_error (
- error, G_IO_ERROR,
- g_io_error_from_errno (errno),
- _("Cannot create folder '%s': %s"),
- folder_name, g_strerror (errno));
- rmdir (tmp);
- rmdir (cur);
- rmdir (new);
- rmdir (name);
- } else {
- folder = camel_maildir_folder_new (store, folder_name, flags, cancellable, error);
- }
- }
- } else if (!S_ISDIR (st.st_mode)
- || g_stat (tmp, &st) != 0 || !S_ISDIR (st.st_mode)
- || g_stat (cur, &st) != 0 || !S_ISDIR (st.st_mode)
- || g_stat (new, &st) != 0 || !S_ISDIR (st.st_mode)) {
- /* folder exists, but not maildir */
- g_set_error (
- error, CAMEL_ERROR, CAMEL_ERROR_GENERIC,
- _("Cannot get folder '%s': not a maildir directory."),
- name);
- } else if (flags & CAMEL_STORE_FOLDER_EXCL) {
- g_set_error (
- error, CAMEL_ERROR, CAMEL_ERROR_GENERIC,
- _("Cannot create folder '%s': folder exists."),
- folder_name);
- } else {
- folder = camel_maildir_folder_new (store, folder_name, flags, cancellable, error);
- }
-fail:
- g_free (name);
- g_free (tmp);
- g_free (cur);
- g_free (new);
-
- return folder;
-}
-
static CamelFolderInfo *
maildir_store_get_folder_info_sync (CamelStore *store,
const gchar *top,
@@ -782,7 +604,6 @@ fail:
return NULL;
}
-<<<<<<< HEAD
static CamelFolder *
maildir_store_get_inbox_sync (CamelStore *store,
GCancellable *cancellable,
@@ -793,98 +614,6 @@ maildir_store_get_inbox_sync (CamelStore *store,
}
static gboolean
-maildir_store_delete_folder_sync (CamelStore *store,
- const gchar *folder_name,
- GCancellable *cancellable,
- GError **error)
-{
- gchar *name, *tmp, *cur, *new;
- struct stat st;
- gboolean success = TRUE;
-
- if (strcmp(folder_name, ".") == 0) {
- g_set_error (
- error, CAMEL_STORE_ERROR,
- CAMEL_STORE_ERROR_NO_FOLDER,
- _("Cannot delete folder: %s: Invalid operation"),
- _("Inbox"));
- return FALSE;
- }
-
- name = g_strdup_printf("%s%s", CAMEL_LOCAL_STORE(store)->toplevel_dir, folder_name);
-
- tmp = g_strdup_printf("%s/tmp", name);
- cur = g_strdup_printf("%s/cur", name);
- new = g_strdup_printf("%s/new", name);
-
- if (g_stat (name, &st) == -1 || !S_ISDIR (st.st_mode)
- || g_stat (tmp, &st) == -1 || !S_ISDIR (st.st_mode)
- || g_stat (cur, &st) == -1 || !S_ISDIR (st.st_mode)
- || g_stat (new, &st) == -1 || !S_ISDIR (st.st_mode)) {
- g_set_error (
- error, G_IO_ERROR,
- g_io_error_from_errno (errno),
- _("Could not delete folder '%s': %s"),
- folder_name, errno ? g_strerror (errno) :
- _("not a maildir directory"));
- } else {
- gint err = 0;
-
- /* remove subdirs first - will fail if not empty */
- if (rmdir (cur) == -1 || rmdir (new) == -1) {
- err = errno;
- } else {
- DIR *dir;
- struct dirent *d;
-
- /* for tmp (only), its contents is irrelevant */
- dir = opendir (tmp);
- if (dir) {
- while ((d=readdir (dir))) {
- gchar *name = d->d_name, *file;
-
- if (!strcmp(name, ".") || !strcmp(name, ".."))
- continue;
- file = g_strdup_printf("%s/%s", tmp, name);
- unlink (file);
- g_free (file);
- }
- closedir (dir);
- }
- if (rmdir (tmp) == -1 || rmdir (name) == -1)
- err = errno;
- }
-
- if (err != 0) {
- /* easier just to mkdir all (and let them fail), than remember what we got to */
- mkdir (name, 0700);
- mkdir (cur, 0700);
- mkdir (new, 0700);
- mkdir (tmp, 0700);
- g_set_error (
- error, G_IO_ERROR,
- g_io_error_from_errno (err),
- _("Could not delete folder '%s': %s"),
- folder_name, g_strerror (err));
- } else {
- CamelStoreClass *store_class;
-
- /* Chain up to parent's delete_folder_sync() method. */
- store_class = CAMEL_STORE_CLASS (camel_maildir_store_parent_class);
- success = store_class->delete_folder_sync (
- store, folder_name, cancellable, error);
- }
- }
-
- g_free (name);
- g_free (tmp);
- g_free (cur);
- g_free (new);
-
- return success;
-}
-
-static gboolean
maildir_store_rename_folder_sync (CamelStore *store,
const gchar *old,
const gchar *new,
@@ -912,16 +641,22 @@ static void
camel_maildir_store_class_init (CamelMaildirStoreClass *class)
{
CamelStoreClass *store_class;
+ CamelLocalStoreClass *local_class;
store_class = CAMEL_STORE_CLASS (class);
store_class->hash_folder_name = maildir_store_hash_folder_name;
store_class->compare_folder_name = maildir_store_compare_folder_name;
+ store_class->create_folder_sync = maildir_store_create_folder_sync;
store_class->free_folder_info = camel_store_free_folder_info_full;
store_class->get_folder_sync = maildir_store_get_folder_sync;
store_class->get_folder_info_sync = maildir_store_get_folder_info_sync;
store_class->get_inbox_folder_sync = maildir_store_get_inbox_sync;
store_class->delete_folder_sync = maildir_store_delete_folder_sync;
store_class->rename_folder_sync = maildir_store_rename_folder_sync;
+
+ local_class = CAMEL_LOCAL_STORE_CLASS (class);
+ local_class->get_full_path = maildir_get_full_path;
+ local_class->get_meta_path = maildir_get_meta_path;
}
static void
@@ -952,4 +687,3 @@ maildir_get_meta_path (CamelLocalStore *ls, const gchar *full_name, const gchar
return path;
}
->>>>>>> override get_full_path and get_meta_path in maildir store
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]