[evolution-patches] 59507, trying to write files in spool directories
- From: Not Zed <notzed ximian com>
- To: asdf <evolution-patches lists ximian com>
- Subject: [evolution-patches] 59507, trying to write files in spool directories
- Date: Thu, 24 Feb 2005 13:09:45 +0800
cleans up a bunch of code in the process.
Index: camel/providers/local/ChangeLog
===================================================================
RCS file: /cvs/gnome/evolution-data-server/camel/providers/local/ChangeLog,v
retrieving revision 1.2
diff -u -p -r1.2 ChangeLog
--- camel/providers/local/ChangeLog 24 Feb 2005 01:43:09 -0000 1.2
+++ camel/providers/local/ChangeLog 24 Feb 2005 05:05:22 -0000
@@ -1,3 +1,24 @@
+2005-02-24 Not Zed <NotZed Ximian com>
+
+ ** See bug #59507
+
+ * camel-spool-store.c (spool_get_full_path): handle mbox/elm cases
+ explictly, not based on stat of path.
+ (spool_get_meta_path): store all meta files in ~/.evolution
+ somewhere.
+
+ * camel-local-folder.c (camel_local_folder_construct): remove the
+ special case test for a direct folder, leave it to subclasses to
+ decide.
+
+ * camel-local-store.c (local_get_trash, local_get_junk): calculate
+ the state file based on the new store get_meta_path calls. Also
+ use the CAMEL_VJUNK_NAME, etc.
+
+ * camel-local-folder.c, camel-local-store.c: Moved the
+ get_meta_path and get_full_path routines to the store instead of
+ the folder. fix all subclasses.
+
2005-02-23 Not Zed <NotZed Ximian com>
** See bug #71812
Index: camel/providers/local/camel-local-folder.c
===================================================================
RCS file: /cvs/gnome/evolution-data-server/camel/providers/local/camel-local-folder.c,v
retrieving revision 1.54
diff -u -p -r1.54 camel-local-folder.c
--- camel/providers/local/camel-local-folder.c 28 Sep 2004 04:32:13 -0000 1.54
+++ camel/providers/local/camel-local-folder.c 24 Feb 2005 05:05:22 -0000
@@ -73,9 +73,6 @@ static int local_setv(CamelObject *objec
static int local_lock(CamelLocalFolder *lf, CamelLockType type, CamelException *ex);
static void local_unlock(CamelLocalFolder *lf);
-static char *local_get_full_path(CamelLocalFolder *lf, const char *toplevel_dir, const char *full_name);
-static char *local_get_meta_path(CamelLocalFolder *lf, const char *toplevel_dir, const char *full_name, const char *ext);
-
static void local_refresh_info(CamelFolder *folder, CamelException *ex);
static void local_sync(CamelFolder *folder, gboolean expunge, CamelException *ex);
@@ -113,9 +110,6 @@ camel_local_folder_class_init(CamelLocal
camel_folder_class->delete = local_delete;
camel_folder_class->rename = local_rename;
- camel_local_folder_class->get_full_path = local_get_full_path;
- camel_local_folder_class->get_meta_path = local_get_meta_path;
-
camel_local_folder_class->lock = local_lock;
camel_local_folder_class->unlock = local_unlock;
}
@@ -216,6 +210,7 @@ camel_local_folder_construct(CamelLocalF
struct stat st;
int forceindex, len;
CamelURL *url;
+ CamelLocalStore *ls = (CamelLocalStore *)parent_store;
folder = (CamelFolder *)lf;
@@ -227,7 +222,7 @@ camel_local_folder_construct(CamelLocalF
camel_folder_construct(folder, parent_store, full_name, name);
- root_dir_path = camel_local_store_get_toplevel_dir(CAMEL_LOCAL_STORE(folder->parent_store));
+ root_dir_path = camel_local_store_get_toplevel_dir(ls);
/* strip the trailing '/' which is always present */
len = strlen (root_dir_path);
tmp = g_alloca (len + 1);
@@ -237,19 +232,11 @@ camel_local_folder_construct(CamelLocalF
lf->base_path = g_strdup(root_dir_path);
- /* if the base store points to a file, then use that */
- if (stat(tmp, &st) != -1 && S_ISREG(st.st_mode)) {
- lf->folder_path = g_strdup(tmp);
- /* not really sure to do with these for now? */
- lf->summary_path = g_strdup_printf("%s.ev-summary", tmp);
- lf->index_path = g_strdup_printf("%s.ibex", tmp);
- statepath = g_strdup_printf("%s.cmeta", tmp);
- } else {
- lf->folder_path = CLOCALF_CLASS(lf)->get_full_path(lf, root_dir_path, full_name);
- lf->summary_path = CLOCALF_CLASS(lf)->get_meta_path(lf, root_dir_path, full_name, ".ev-summary");
- lf->index_path = CLOCALF_CLASS(lf)->get_meta_path(lf, root_dir_path, full_name, ".ibex");
- statepath = CLOCALF_CLASS(lf)->get_meta_path(lf, root_dir_path, full_name, ".cmeta");
- }
+ lf->folder_path = camel_local_store_get_full_path(ls, full_name);
+ lf->summary_path = camel_local_store_get_meta_path(ls, full_name, ".ev-summary");
+ lf->index_path = camel_local_store_get_meta_path(ls, full_name, ".ibex");
+ statepath = camel_local_store_get_meta_path(ls, full_name, ".cmeta");
+
camel_object_set(lf, NULL, CAMEL_OBJECT_STATE_FILE, statepath, NULL);
g_free(statepath);
@@ -462,18 +449,6 @@ local_setv(CamelObject *object, CamelExc
return ((CamelObjectClass *)parent_class)->setv(object, ex, args);
}
-static char *
-local_get_full_path(CamelLocalFolder *lf, const char *toplevel_dir, const char *full_name)
-{
- return g_strdup_printf("%s/%s", toplevel_dir, full_name);
-}
-
-static char *
-local_get_meta_path(CamelLocalFolder *lf, const char *toplevel_dir, const char *full_name, const char *ext)
-{
- return g_strdup_printf("%s/%s%s", toplevel_dir, full_name, ext);
-}
-
static int
local_lock(CamelLocalFolder *lf, CamelLockType type, CamelException *ex)
{
@@ -549,6 +524,7 @@ local_rename(CamelFolder *folder, const
{
CamelLocalFolder *lf = (CamelLocalFolder *)folder;
char *statepath;
+ CamelLocalStore *ls = (CamelLocalStore *)folder->parent_store;
d(printf("renaming local folder paths to '%s'\n", newname));
@@ -558,10 +534,10 @@ local_rename(CamelFolder *folder, const
g_free(lf->summary_path);
g_free(lf->index_path);
- lf->folder_path = CLOCALF_CLASS(lf)->get_full_path(lf, lf->base_path, newname);
- lf->summary_path = CLOCALF_CLASS(lf)->get_meta_path(lf, lf->base_path, newname, ".ev-summary");
- lf->index_path = CLOCALF_CLASS(lf)->get_meta_path(lf, lf->base_path, newname, ".ibex");
- statepath = CLOCALF_CLASS(lf)->get_meta_path(lf, lf->base_path, newname, ".cmeta");
+ lf->folder_path = camel_local_store_get_full_path(ls, newname);
+ lf->summary_path = camel_local_store_get_meta_path(ls, newname, ".ev-summary");
+ lf->index_path = camel_local_store_get_meta_path(ls, newname, ".ibex");
+ statepath = camel_local_store_get_meta_path(ls, newname, ".cmeta");
camel_object_set(lf, NULL, CAMEL_OBJECT_STATE_FILE, statepath, NULL);
g_free(statepath);
Index: camel/providers/local/camel-local-folder.h
===================================================================
RCS file: /cvs/gnome/evolution-data-server/camel/providers/local/camel-local-folder.h,v
retrieving revision 1.14
diff -u -p -r1.14 camel-local-folder.h
--- camel/providers/local/camel-local-folder.h 28 Sep 2004 04:32:13 -0000 1.14
+++ camel/providers/local/camel-local-folder.h 24 Feb 2005 05:05:22 -0000
@@ -74,10 +74,6 @@ typedef struct {
/* Virtual methods */
- /* path construction, only used at init */
- char * (* get_full_path)(CamelLocalFolder *lf, const char *toplevel_dir, const char *full_name);
- char * (* get_meta_path)(CamelLocalFolder *lf, const char *toplevel_dir, const char *full_name, const char *ext);
-
/* summary factory, only used at init */
CamelLocalSummary *(*create_summary)(CamelLocalFolder *lf, const char *path, const char *folder, CamelIndex *index);
Index: camel/providers/local/camel-local-store.c
===================================================================
RCS file: /cvs/gnome/evolution-data-server/camel/providers/local/camel-local-store.c,v
retrieving revision 1.37
diff -u -p -r1.37 camel-local-store.c
--- camel/providers/local/camel-local-store.c 20 Sep 2004 05:59:54 -0000 1.37
+++ camel/providers/local/camel-local-store.c 24 Feb 2005 05:05:22 -0000
@@ -41,6 +41,7 @@
#include "camel-local-folder.h"
#include <camel/camel-text-index.h>
#include <camel/camel-file-utils.h>
+#include <camel/camel-vtrash-folder.h>
#define d(x)
@@ -59,6 +60,9 @@ static void delete_folder(CamelStore *st
static void rename_folder(CamelStore *store, const char *old, const char *new, CamelException *ex);
static CamelFolderInfo *create_folder(CamelStore *store, const char *parent_name, const char *folder_name, CamelException *ex);
+static char *local_get_full_path(CamelLocalStore *lf, const char *full_name);
+static char *local_get_meta_path(CamelLocalStore *lf, const char *full_name, const char *ext);
+
static CamelStoreClass *parent_class = NULL;
static void
@@ -82,6 +86,9 @@ camel_local_store_class_init (CamelLocal
camel_store_class->create_folder = create_folder;
camel_store_class->delete_folder = delete_folder;
camel_store_class->rename_folder = rename_folder;
+
+ camel_local_store_class->get_full_path = local_get_full_path;
+ camel_local_store_class->get_meta_path = local_get_meta_path;
}
static void
@@ -186,7 +193,7 @@ local_get_trash(CamelStore *store, Camel
CamelFolder *folder = CAMEL_STORE_CLASS(parent_class)->get_trash(store, ex);
if (folder) {
- char *state = g_build_filename(((CamelLocalStore *)store)->toplevel_dir, ".Trash.cmeta", NULL);
+ char *state = camel_local_store_get_meta_path(store, CAMEL_VTRASH_NAME, ".cmeta");
camel_object_set(folder, NULL, CAMEL_OBJECT_STATE_FILE, state, NULL);
g_free(state);
@@ -203,7 +210,7 @@ local_get_junk(CamelStore *store, CamelE
CamelFolder *folder = CAMEL_STORE_CLASS(parent_class)->get_junk(store, ex);
if (folder) {
- char *state = g_build_filename(((CamelLocalStore *)store)->toplevel_dir, ".Junk.cmeta", NULL);
+ char *state = camel_local_store_get_meta_path(store, CAMEL_VJUNK_NAME, ".cmeta");
camel_object_set(folder, NULL, CAMEL_OBJECT_STATE_FILE, state, NULL);
g_free(state);
@@ -474,4 +481,16 @@ delete_folder(CamelStore *store, const c
camel_object_trigger_event (store, "folder_deleted", fi);
camel_folder_info_free (fi);
+}
+
+static char *
+local_get_full_path(CamelLocalStore *ls, const char *full_name)
+{
+ return g_strdup_printf("%s%s", ls->toplevel_dir, full_name);
+}
+
+static char *
+local_get_meta_path(CamelLocalStore *ls, const char *full_name, const char *ext)
+{
+ return g_strdup_printf("%s%s%s", ls->toplevel_dir, full_name, ext);
}
Index: camel/providers/local/camel-local-store.h
===================================================================
RCS file: /cvs/gnome/evolution-data-server/camel/providers/local/camel-local-store.h,v
retrieving revision 1.6
diff -u -p -r1.6 camel-local-store.h
--- camel/providers/local/camel-local-store.h 27 Oct 2001 16:59:30 -0000 1.6
+++ camel/providers/local/camel-local-store.h 24 Feb 2005 05:05:22 -0000
@@ -20,11 +20,9 @@
* USA
*/
-
#ifndef CAMEL_LOCAL_STORE_H
#define CAMEL_LOCAL_STORE_H 1
-
#ifdef __cplusplus
extern "C" {
#pragma }
@@ -37,27 +35,26 @@ extern "C" {
#define CAMEL_LOCAL_STORE_CLASS(k) (CAMEL_CHECK_CLASS_CAST ((k), CAMEL_LOCAL_STORE_TYPE, CamelLocalStoreClass))
#define CAMEL_IS_LOCAL_STORE(o) (CAMEL_CHECK_TYPE((o), CAMEL_LOCAL_STORE_TYPE))
-
typedef struct {
CamelStore parent_object;
+
char *toplevel_dir;
-
} CamelLocalStore;
-
-
typedef struct {
CamelStoreClass parent_class;
+ char *(*get_full_path)(CamelLocalStore *ls, const char *full_name);
+ char *(*get_meta_path)(CamelLocalStore *ls, const char *full_name, const char *ext);
} CamelLocalStoreClass;
-
-/* public methods */
-
/* Standard Camel function */
CamelType camel_local_store_get_type (void);
const gchar *camel_local_store_get_toplevel_dir (CamelLocalStore *store);
+
+#define camel_local_store_get_full_path(ls, name) ((CamelLocalStoreClass *)((CamelObject *)ls)->klass)->get_full_path((CamelLocalStore *)ls, name)
+#define camel_local_store_get_meta_path(ls, name, ext) ((CamelLocalStoreClass *)((CamelObject *)ls)->klass)->get_meta_path((CamelLocalStore *)ls, name, ext)
#ifdef __cplusplus
}
Index: camel/providers/local/camel-mbox-folder.c
===================================================================
RCS file: /cvs/gnome/evolution-data-server/camel/providers/local/camel-mbox-folder.c,v
retrieving revision 1.37
diff -u -p -r1.37 camel-mbox-folder.c
--- camel/providers/local/camel-mbox-folder.c 12 Nov 2004 05:53:12 -0000 1.37
+++ camel/providers/local/camel-mbox-folder.c 24 Feb 2005 05:05:23 -0000
@@ -76,8 +76,6 @@ camel_mbox_folder_class_init(CamelMboxFo
camel_folder_class->append_message = mbox_append_message;
camel_folder_class->get_message = mbox_get_message;
- lclass->get_full_path = camel_mbox_folder_get_full_path;
- lclass->get_meta_path = camel_mbox_folder_get_meta_path;
lclass->create_summary = mbox_create_summary;
lclass->lock = mbox_lock;
lclass->unlock = mbox_unlock;
@@ -129,67 +127,6 @@ camel_mbox_folder_new(CamelStore *parent
parent_store, full_name, flags, ex);
return folder;
-}
-
-char *
-camel_mbox_folder_get_full_path (CamelLocalFolder *lf, const char *toplevel_dir, const char *full_name)
-{
- const char *inptr = full_name;
- int subdirs = 0;
- char *path, *p;
-
- while (*inptr != '\0') {
- if (*inptr == '/')
- subdirs++;
- inptr++;
- }
-
- path = g_malloc (strlen (toplevel_dir) + (inptr - full_name) + (4 * subdirs) + 1);
- p = g_stpcpy (path, toplevel_dir);
-
- inptr = full_name;
- while (*inptr != '\0') {
- while (*inptr != '/' && *inptr != '\0')
- *p++ = *inptr++;
-
- if (*inptr == '/') {
- p = g_stpcpy (p, ".sbd/");
- inptr++;
-
- /* strip extranaeous '/'s */
- while (*inptr == '/')
- inptr++;
- }
- }
-
- *p = '\0';
-
- return path;
-}
-
-char *
-camel_mbox_folder_get_meta_path (CamelLocalFolder *lf, const char *toplevel_dir, const char *full_name, const char *ext)
-{
-/*#define USE_HIDDEN_META_FILES*/
-#ifdef USE_HIDDEN_META_FILES
- char *name, *slash;
-
- name = g_alloca (strlen (full_name) + strlen (ext) + 2);
- if ((slash = strrchr (full_name, '/')))
- sprintf (name, "%.*s.%s%s", slash - full_name + 1, full_name, slash + 1, ext);
- else
- sprintf (name, ".%s%s", full_name, ext);
-
- return camel_mbox_folder_get_full_path (lf, toplevel_dir, name);
-#else
- char *full_path, *path;
-
- full_path = camel_mbox_folder_get_full_path (lf, toplevel_dir, full_name);
- path = g_strdup_printf ("%s%s", full_path, ext);
- g_free (full_path);
-
- return path;
-#endif
}
static CamelLocalSummary *mbox_create_summary(CamelLocalFolder *lf, const char *path, const char *folder, CamelIndex *index)
Index: camel/providers/local/camel-mbox-folder.h
===================================================================
RCS file: /cvs/gnome/evolution-data-server/camel/providers/local/camel-mbox-folder.h,v
retrieving revision 1.7
diff -u -p -r1.7 camel-mbox-folder.h
--- camel/providers/local/camel-mbox-folder.h 28 Sep 2004 04:32:13 -0000 1.7
+++ camel/providers/local/camel-mbox-folder.h 24 Feb 2005 05:05:23 -0000
@@ -55,10 +55,6 @@ CamelFolder *camel_mbox_folder_new(Camel
/* Standard Camel function */
CamelType camel_mbox_folder_get_type(void);
-/* utilities */
-char *camel_mbox_folder_get_full_path (CamelLocalFolder *lf, const char *toplevel_dir, const char *full_name);
-char *camel_mbox_folder_get_meta_path (CamelLocalFolder *lf, const char *toplevel_dir, const char *full_name, const char *ext);
-
#ifdef __cplusplus
}
#endif /* __cplusplus */
Index: camel/providers/local/camel-mbox-store.c
===================================================================
RCS file: /cvs/gnome/evolution-data-server/camel/providers/local/camel-mbox-store.c,v
retrieving revision 1.40
diff -u -p -r1.40 camel-mbox-store.c
--- camel/providers/local/camel-mbox-store.c 12 Nov 2004 05:53:12 -0000 1.40
+++ camel/providers/local/camel-mbox-store.c 24 Feb 2005 05:05:23 -0000
@@ -53,6 +53,8 @@ static void delete_folder(CamelStore *st
static void rename_folder(CamelStore *store, const char *old, const char *new, CamelException *ex);
static CamelFolderInfo *create_folder(CamelStore *store, const char *parent_name, const char *folder_name, CamelException *ex);
static CamelFolderInfo *get_folder_info(CamelStore *store, const char *top, guint32 flags, CamelException *ex);
+static char *mbox_get_meta_path(CamelLocalStore *ls, const char *full_name, const char *ext);
+static char *mbox_get_full_path(CamelLocalStore *ls, const char *full_name);
static void
camel_mbox_store_class_init(CamelMboxStoreClass *camel_mbox_store_class)
@@ -69,6 +71,9 @@ camel_mbox_store_class_init(CamelMboxSto
camel_store_class->get_folder_info = get_folder_info;
camel_store_class->free_folder_info = camel_store_free_folder_info_full;
+
+ ((CamelLocalStoreClass *)camel_store_class)->get_full_path = mbox_get_full_path;
+ ((CamelLocalStoreClass *)camel_store_class)->get_meta_path = mbox_get_meta_path;
}
CamelType
@@ -89,22 +94,6 @@ camel_mbox_store_get_type(void)
return camel_mbox_store_type;
}
-static char *
-mbox_folder_name_to_path(CamelStore *store, const char *folder_name)
-{
- const char *toplevel_dir = CAMEL_LOCAL_STORE(store)->toplevel_dir;
-
- return camel_mbox_folder_get_full_path(NULL, toplevel_dir, folder_name);
-}
-
-static char *
-mbox_folder_name_to_meta_path(CamelStore *store, const char *folder_name, const char *ext)
-{
- const char *toplevel_dir = CAMEL_LOCAL_STORE(store)->toplevel_dir;
-
- return camel_mbox_folder_get_meta_path(NULL, toplevel_dir, folder_name, ext);
-}
-
static char *extensions[] = {
".msf", ".ev-summary", ".ibex.index", ".ibex.index.data", ".cmeta", ".lock"
};
@@ -140,7 +129,7 @@ get_folder(CamelStore *store, const char
if (!((CamelStoreClass *) parent_class)->get_folder(store, folder_name, flags, ex))
return NULL;
- name = mbox_folder_name_to_path(store, folder_name);
+ name = camel_local_store_get_full_path(store, folder_name);
if (stat(name, &st) == -1) {
const char *basename;
@@ -226,7 +215,7 @@ delete_folder(CamelStore *store, const c
char *name, *path;
struct stat st;
- name = mbox_folder_name_to_path(store, folder_name);
+ name = camel_local_store_get_full_path(store, folder_name);
path = g_strdup_printf("%s.sbd", name);
if (rmdir(path) == -1 && errno != ENOENT) {
@@ -276,7 +265,7 @@ delete_folder(CamelStore *store, const c
* naming convention is different. Need to find a way for
* CamelLocalStore to be able to construct the folder & meta
* paths itself */
- path = mbox_folder_name_to_meta_path(store, folder_name, ".ev-summary");
+ path = camel_local_store_get_meta_path(store, folder_name, ".ev-summary");
if (unlink(path) == -1 && errno != ENOENT) {
camel_exception_setv(ex, CAMEL_EXCEPTION_SYSTEM,
_("Could not delete folder summary file `%s': %s"),
@@ -288,7 +277,7 @@ delete_folder(CamelStore *store, const c
g_free(path);
- path = mbox_folder_name_to_meta_path(store, folder_name, ".ibex");
+ path = camel_local_store_get_meta_path(store, folder_name, ".ibex");
if (camel_text_index_remove(path) == -1 && errno != ENOENT) {
camel_exception_setv(ex, CAMEL_EXCEPTION_SYSTEM,
_("Could not delete folder index file `%s': %s"),
@@ -311,7 +300,7 @@ delete_folder(CamelStore *store, const c
}
if (path == NULL)
- path = mbox_folder_name_to_meta_path(store, folder_name, ".cmeta");
+ path = camel_local_store_get_meta_path(store, folder_name, ".cmeta");
if (unlink(path) == -1 && errno != ENOENT) {
camel_exception_setv(ex, CAMEL_EXCEPTION_SYSTEM,
@@ -365,7 +354,7 @@ create_folder(CamelStore *store, const c
else
name = g_strdup(folder_name);
- path = mbox_folder_name_to_path(store, name);
+ path = camel_local_store_get_full_path(store, name);
dir = g_path_get_dirname(path);
if (camel_mkdir(dir, 0777) == -1 && errno != EEXIST) {
@@ -409,18 +398,18 @@ create_folder(CamelStore *store, const c
static int
xrename(CamelStore *store, const char *old_name, const char *new_name, const char *ext, gboolean missingok)
{
- const char *toplevel_dir =((CamelLocalStore *) store)->toplevel_dir;
+ CamelLocalStore *ls = (CamelLocalStore *)store;
char *oldpath, *newpath;
struct stat st;
int ret = -1;
int err = 0;
if (ext != NULL) {
- oldpath = camel_mbox_folder_get_meta_path(NULL, toplevel_dir, old_name, ext);
- newpath = camel_mbox_folder_get_meta_path(NULL, toplevel_dir, new_name, ext);
+ oldpath = camel_local_store_get_meta_path(ls, old_name, ext);
+ newpath = camel_local_store_get_meta_path(ls, new_name, ext);
} else {
- oldpath = camel_mbox_folder_get_full_path(NULL, toplevel_dir, old_name);
- newpath = camel_mbox_folder_get_full_path(NULL, toplevel_dir, new_name);
+ oldpath = camel_local_store_get_full_path(ls, old_name);
+ newpath = camel_local_store_get_full_path(ls, new_name);
}
if (stat(oldpath, &st) == -1) {
@@ -473,8 +462,8 @@ rename_folder(CamelStore *store, const c
/* try to rollback failures, has obvious races */
- oldibex = mbox_folder_name_to_meta_path(store, old, ".ibex");
- newibex = mbox_folder_name_to_meta_path(store, new, ".ibex");
+ oldibex = camel_local_store_get_meta_path(store, old, ".ibex");
+ newibex = camel_local_store_get_meta_path(store, new, ".ibex");
newdir = g_path_get_dirname(newibex);
if (camel_mkdir(newdir, 0777) == -1) {
@@ -611,12 +600,10 @@ fill_fi(CamelStore *store, CamelFolderIn
} else {
char *path, *folderpath;
CamelMboxSummary *mbs;
- const char *root;
/* This should be fast enough not to have to test for INFO_FAST */
- root = camel_local_store_get_toplevel_dir((CamelLocalStore *)store);
- path = camel_mbox_folder_get_meta_path(NULL, root, fi->full_name, ".ev-summary");
- folderpath = camel_mbox_folder_get_full_path(NULL, root, fi->full_name);
+ path = camel_local_store_get_meta_path(store, fi->full_name, ".ev-summary");
+ folderpath = camel_local_store_get_full_path(store, fi->full_name);
mbs = (CamelMboxSummary *)camel_mbox_summary_new(NULL, path, folderpath, NULL);
if (camel_folder_summary_header_load((CamelFolderSummary *)mbs) != -1) {
@@ -761,7 +748,7 @@ get_folder_info(CamelStore *store, const
CamelURL *url;
top = top ? top : "";
- path = mbox_folder_name_to_path(store, top);
+ path = camel_local_store_get_full_path(store, top);
if (*top == '\0') {
/* requesting root dir scan */
@@ -835,4 +822,65 @@ get_folder_info(CamelStore *store, const
g_free(path);
return fi;
+}
+
+static char *
+mbox_get_full_path(CamelLocalStore *ls, const char *full_name)
+{
+ const char *inptr = full_name;
+ int subdirs = 0;
+ char *path, *p;
+
+ while (*inptr != '\0') {
+ if (*inptr == '/')
+ subdirs++;
+ inptr++;
+ }
+
+ path = g_malloc (strlen (ls->toplevel_dir) + (inptr - full_name) + (4 * subdirs) + 1);
+ p = g_stpcpy (path, ls->toplevel_dir);
+
+ inptr = full_name;
+ while (*inptr != '\0') {
+ while (*inptr != '/' && *inptr != '\0')
+ *p++ = *inptr++;
+
+ if (*inptr == '/') {
+ p = g_stpcpy (p, ".sbd/");
+ inptr++;
+
+ /* strip extranaeous '/'s */
+ while (*inptr == '/')
+ inptr++;
+ }
+ }
+
+ *p = '\0';
+
+ return path;
+}
+
+static char *
+mbox_get_meta_path(CamelLocalStore *ls, const char *full_name, const char *ext)
+{
+/*#define USE_HIDDEN_META_FILES*/
+#ifdef USE_HIDDEN_META_FILES
+ char *name, *slash;
+
+ name = g_alloca (strlen (full_name) + strlen (ext) + 2);
+ if ((slash = strrchr (full_name, '/')))
+ sprintf (name, "%.*s.%s%s", slash - full_name + 1, full_name, slash + 1, ext);
+ else
+ sprintf (name, ".%s%s", full_name, ext);
+
+ return mbox_get_full_path(ls, name);
+#else
+ char *full_path, *path;
+
+ full_path = mbox_get_full_path(ls, full_name);
+ path = g_strdup_printf ("%s%s", full_path, ext);
+ g_free (full_path);
+
+ return path;
+#endif
}
Index: camel/providers/local/camel-spool-folder.c
===================================================================
RCS file: /cvs/gnome/evolution-data-server/camel/providers/local/camel-spool-folder.c,v
retrieving revision 1.21
diff -u -p -r1.21 camel-spool-folder.c
--- camel/providers/local/camel-spool-folder.c 12 Nov 2004 05:53:12 -0000 1.21
+++ camel/providers/local/camel-spool-folder.c 24 Feb 2005 05:05:23 -0000
@@ -56,8 +56,6 @@ static CamelFolderClass *parent_class =
#define CF_CLASS(so) CAMEL_FOLDER_CLASS (CAMEL_OBJECT_GET_CLASS(so))
#define CSPOOLS_CLASS(so) CAMEL_STORE_CLASS (CAMEL_OBJECT_GET_CLASS(so))
-static char *spool_get_full_path(CamelLocalFolder *lf, const char *toplevel_dir, const char *full_name);
-static char *spool_get_meta_path(CamelLocalFolder *lf, const char *toplevel_dir, const char *full_name, const char *ext);
static CamelLocalSummary *spool_create_summary(CamelLocalFolder *lf, const char *path, const char *folder, CamelIndex *index);
static int spool_lock(CamelLocalFolder *lf, CamelLockType type, CamelException *ex);
@@ -72,8 +70,6 @@ camel_spool_folder_class_init(CamelSpool
parent_class = (CamelFolderClass *)camel_mbox_folder_get_type();
- lklass->get_full_path = spool_get_full_path;
- lklass->get_meta_path = spool_get_meta_path;
lklass->create_summary = spool_create_summary;
lklass->lock = spool_lock;
lklass->unlock = spool_unlock;
@@ -131,30 +127,6 @@ camel_spool_folder_new(CamelStore *paren
}
return folder;
-}
-
-static char *
-spool_get_full_path(CamelLocalFolder *lf, const char *toplevel_dir, const char *full_name)
-{
- return g_strdup_printf ("%s/%s", toplevel_dir, full_name);
-}
-
-static char *
-spool_get_meta_path(CamelLocalFolder *lf, const char *toplevel_dir, const char *full_name, const char *ext)
-{
- CamelService *service = (CamelService *)((CamelFolder *)lf)->parent_store;
- char *root = camel_session_get_storage_path(service->session, service, NULL);
- char *path;
-
- if (root == NULL)
- return NULL;
-
-
- camel_mkdir(root, 0777);
- path = g_strdup_printf("%s/%s%s", root, full_name, ext);
- g_free(root);
-
- return path;
}
static CamelLocalSummary *
Index: camel/providers/local/camel-spool-store.c
===================================================================
RCS file: /cvs/gnome/evolution-data-server/camel/providers/local/camel-spool-store.c,v
retrieving revision 1.24
diff -u -p -r1.24 camel-spool-store.c
--- camel/providers/local/camel-spool-store.c 28 Sep 2004 04:32:13 -0000 1.24
+++ camel/providers/local/camel-spool-store.c 24 Feb 2005 05:05:23 -0000
@@ -42,6 +42,8 @@
#include "camel-url.h"
#include "camel-private.h"
#include "camel-i18n.h"
+#include "camel-session.h"
+#include "camel-file-utils.h"
#define d(x)
@@ -60,6 +62,9 @@ static void free_folder_info (CamelStore
static void delete_folder(CamelStore *store, const char *folder_name, CamelException *ex);
static void rename_folder(CamelStore *store, const char *old, const char *new, CamelException *ex);
+static char *spool_get_meta_path(CamelLocalStore *ls, const char *full_name, const char *ext);
+static char *spool_get_full_path(CamelLocalStore *ls, const char *full_name);
+
static CamelStoreClass *parent_class = NULL;
static void
@@ -80,6 +85,9 @@ camel_spool_store_class_init (CamelSpool
camel_store_class->delete_folder = delete_folder;
camel_store_class->rename_folder = rename_folder;
+
+ ((CamelLocalStoreClass *)camel_store_class)->get_full_path = spool_get_full_path;
+ ((CamelLocalStoreClass *)camel_store_class)->get_meta_path = spool_get_meta_path;
}
CamelType
@@ -463,4 +471,32 @@ get_folder_info(CamelStore *store, const
return get_folder_info_mbox(store, top, flags, ex);
else
return get_folder_info_elm(store, top, flags, ex);
+}
+
+static char *
+spool_get_full_path(CamelLocalStore *ls, const char *full_name)
+{
+ if (((CamelSpoolStore *)ls)->type == CAMEL_SPOOL_STORE_MBOX)
+ /* a trailing / is always present on toplevel_dir from CamelLocalStore */
+ return g_strndup(ls->toplevel_dir, strlen(ls->toplevel_dir)-1);
+ else
+ return g_strdup_printf("%s/%s", ls->toplevel_dir, full_name);
+}
+
+static char *
+spool_get_meta_path(CamelLocalStore *ls, const char *full_name, const char *ext)
+{
+ char *root = camel_session_get_storage_path(((CamelService *)ls)->session, (CamelService *)ls, NULL);
+ char *path, *key;
+
+ if (root == NULL)
+ return NULL;
+
+ camel_mkdir(root, 0777);
+ key = camel_file_util_safe_filename(full_name);
+ path = g_strdup_printf("%s/%s%s", root, key, ext);
+ g_free(key);
+ g_free(root);
+
+ return path;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]