aboutsummaryrefslogtreecommitdiffstats
path: root/camel
diff options
context:
space:
mode:
Diffstat (limited to 'camel')
-rw-r--r--camel/ChangeLog16
-rw-r--r--camel/providers/local/camel-local-store.c37
-rw-r--r--camel/providers/local/camel-local-store.h1
-rw-r--r--camel/providers/local/camel-maildir-store.c8
-rw-r--r--camel/providers/local/camel-mbox-store.c4
-rw-r--r--camel/providers/local/camel-mh-store.c4
-rw-r--r--camel/providers/local/camel-spool-store.c21
7 files changed, 49 insertions, 42 deletions
diff --git a/camel/ChangeLog b/camel/ChangeLog
index 4df568aec7..3c0f4281d6 100644
--- a/camel/ChangeLog
+++ b/camel/ChangeLog
@@ -1,5 +1,21 @@
2001-10-01 Dan Winship <danw@ximian.com>
+ * providers/local/camel-local-store.c (construct): Don't munge the
+ URL; CamelSession's caching relies on it not changing. Instead,
+ add a toplevel_dir field to CamelLocalStore, and set that to the
+ path, but always ending with /.
+ (camel_local_store_finalize): Free toplevel_dir
+ (camel_local_store_get_toplevel_dir): Return toplevel_dir rather
+ than url->path.
+
+ * providers/local/*: Lots of s/url->path/toplevel_dir/
+
+ * providers/local/camel-spool-store.c (construct): Likewise, don't
+ try to strip a trailing / from url->path here, but I didn't make
+ the corresponding toplevel_dir change, because there's no good
+ reason someone should expect "/var/spool/mail/danw/" to work since
+ that's not a directory.
+
* providers/pop3/camel-pop3-folder.c (pop3_refresh_info): if STAT
returns 0, don't bother sending UIDL. Speeds things up slightly
and also works around a bug in a particular random POP server.
diff --git a/camel/providers/local/camel-local-store.c b/camel/providers/local/camel-local-store.c
index 92e5159f1b..c5ed877b68 100644
--- a/camel/providers/local/camel-local-store.c
+++ b/camel/providers/local/camel-local-store.c
@@ -72,6 +72,13 @@ camel_local_store_class_init (CamelLocalStoreClass *camel_local_store_class)
camel_store_class->rename_folder = rename_folder;
}
+static void
+camel_local_store_finalize (CamelLocalStore *local_store)
+{
+ if (local_store->toplevel_dir)
+ g_free (local_store->toplevel_dir);
+}
+
CamelType
camel_local_store_get_type (void)
{
@@ -84,7 +91,7 @@ camel_local_store_get_type (void)
(CamelObjectClassInitFunc) camel_local_store_class_init,
NULL,
NULL,
- NULL);
+ (CamelObjectFinalizeFunc) camel_local_store_finalize);
}
return camel_local_store_type;
@@ -93,6 +100,7 @@ camel_local_store_get_type (void)
static void
construct (CamelService *service, CamelSession *session, CamelProvider *provider, CamelURL *url, CamelException *ex)
{
+ CamelLocalStore *local_store = CAMEL_LOCAL_STORE (service);
int len;
CAMEL_SERVICE_CLASS (parent_class)->construct (service, session, provider, url, ex);
@@ -100,26 +108,23 @@ construct (CamelService *service, CamelSession *session, CamelProvider *provider
return;
len = strlen (service->url->path);
- if (service->url->path[len - 1] != '/') {
- service->url->path = g_realloc (service->url->path, len + 2);
- strcpy (service->url->path + len, "/");
- }
+ if (service->url->path[len - 1] != '/')
+ local_store->toplevel_dir = g_strdup_printf ("%s/", service->url->path);
+ else
+ local_store->toplevel_dir = g_strdup (service->url->path);
}
const char *
camel_local_store_get_toplevel_dir (CamelLocalStore *store)
{
- CamelURL *url = CAMEL_SERVICE (store)->url;
-
- g_assert (url != NULL);
- return url->path;
+ return store->toplevel_dir;
}
static CamelFolder *
get_folder(CamelStore * store, const char *folder_name, guint32 flags, CamelException * ex)
{
struct stat st;
- char *path = ((CamelService *)store)->url->path;
+ char *path = ((CamelLocalStore *)store)->toplevel_dir;
char *sub, *slash;
if (path[0] != '/') {
@@ -177,10 +182,12 @@ get_inbox(CamelStore *store, CamelException *ex)
static char *
get_name (CamelService *service, gboolean brief)
{
+ char *dir = ((CamelLocalStore*)service)->toplevel_dir;
+
if (brief)
- return g_strdup (service->url->path);
+ return g_strdup (dir);
else
- return g_strdup_printf (_("Local mail file %s"), service->url->path);
+ return g_strdup_printf (_("Local mail file %s"), dir);
}
static CamelFolderInfo *
@@ -250,7 +257,7 @@ static int xrename(const char *oldp, const char *newp, const char *prefix, const
static void
rename_folder(CamelStore *store, const char *old, const char *new, CamelException *ex)
{
- char *path = CAMEL_SERVICE (store)->url->path;
+ char *path = CAMEL_LOCAL_STORE (store)->toplevel_dir;
/* try to rollback failures, has obvious races */
if (xrename(old, new, path, ".ibex", TRUE, ex)) {
@@ -275,7 +282,7 @@ delete_folder(CamelStore *store, const char *folder_name, CamelException *ex)
char *str;
/* remove metadata only */
- name = g_strdup_printf("%s%s", CAMEL_SERVICE(store)->url->path, folder_name);
+ name = g_strdup_printf("%s%s", CAMEL_LOCAL_STORE(store)->toplevel_dir, folder_name);
str = g_strdup_printf("%s.ev-summary", name);
if (unlink(str) == -1 && errno != ENOENT) {
camel_exception_setv(ex, CAMEL_EXCEPTION_SYSTEM,
@@ -301,7 +308,7 @@ delete_folder(CamelStore *store, const char *folder_name, CamelException *ex)
fi = g_new0 (CamelFolderInfo, 1);
fi->full_name = g_strdup (folder_name);
fi->name = g_strdup (g_basename (folder_name));
- fi->url = g_strdup_printf ("%s%s", CAMEL_SERVICE(store)->url->path, folder_name);
+ fi->url = g_strdup_printf ("%s%s", CAMEL_LOCAL_STORE(store)->toplevel_dir, folder_name);
fi->unread_message_count = -1;
camel_folder_info_build_path(fi, '/');
diff --git a/camel/providers/local/camel-local-store.h b/camel/providers/local/camel-local-store.h
index 75fe6bba98..5ecce3e288 100644
--- a/camel/providers/local/camel-local-store.h
+++ b/camel/providers/local/camel-local-store.h
@@ -41,6 +41,7 @@ extern "C" {
typedef struct {
CamelStore parent_object;
+ char *toplevel_dir;
} CamelLocalStore;
diff --git a/camel/providers/local/camel-maildir-store.c b/camel/providers/local/camel-maildir-store.c
index d6392b5ac2..5ed4e4a533 100644
--- a/camel/providers/local/camel-maildir-store.c
+++ b/camel/providers/local/camel-maildir-store.c
@@ -95,7 +95,7 @@ static CamelFolder *get_folder(CamelStore * store, const char *folder_name, guin
if (camel_exception_is_set(ex))
return NULL;
- name = g_strdup_printf("%s%s", CAMEL_SERVICE(store)->url->path, folder_name);
+ 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);
@@ -153,7 +153,7 @@ static void delete_folder(CamelStore * store, const char *folder_name, CamelExce
char *name, *tmp, *cur, *new;
struct stat st;
- name = g_strdup_printf("%s%s", CAMEL_SERVICE(store)->url->path, folder_name);
+ 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);
@@ -395,12 +395,12 @@ static CamelFolderInfo *
get_folder_info (CamelStore *store, const char *top, guint32 flags, CamelException *ex)
{
CamelFolderInfo *fi = NULL;
- CamelService *service = (CamelService *)store;
+ CamelLocalStore *local_store = (CamelLocalStore *)store;
GHashTable *visited;
visited = g_hash_table_new(inode_hash, inode_equal);
- if (scan_dir(store, visited, service->url->path, top?top:".", flags, NULL, &fi, ex) == -1 && fi != NULL) {
+ if (scan_dir(store, visited, local_store->toplevel_dir, top?top:".", flags, NULL, &fi, ex) == -1 && fi != NULL) {
camel_store_free_folder_info_full(store, fi);
fi = NULL;
}
diff --git a/camel/providers/local/camel-mbox-store.c b/camel/providers/local/camel-mbox-store.c
index adf6806510..0cebdf4450 100644
--- a/camel/providers/local/camel-mbox-store.c
+++ b/camel/providers/local/camel-mbox-store.c
@@ -84,7 +84,7 @@ get_folder(CamelStore *store, const char *folder_name, guint32 flags, CamelExcep
if (camel_exception_is_set(ex))
return NULL;
- name = g_strdup_printf("%s%s", CAMEL_SERVICE(store)->url->path, folder_name);
+ name = g_strdup_printf("%s%s", CAMEL_LOCAL_STORE(store)->toplevel_dir, folder_name);
if (stat(name, &st) == -1) {
int fd;
@@ -132,7 +132,7 @@ delete_folder (CamelStore *store, const char *folder_name, CamelException *ex)
char *name;
struct stat st;
- name = g_strdup_printf ("%s%s", CAMEL_SERVICE (store)->url->path, folder_name);
+ name = g_strdup_printf ("%s%s", CAMEL_LOCAL_STORE (store)->toplevel_dir, folder_name);
if (stat (name, &st) == -1) {
camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM,
_("Could not delete folder `%s':\n%s"),
diff --git a/camel/providers/local/camel-mh-store.c b/camel/providers/local/camel-mh-store.c
index 23515a8a61..8d3d66cbc3 100644
--- a/camel/providers/local/camel-mh-store.c
+++ b/camel/providers/local/camel-mh-store.c
@@ -82,7 +82,7 @@ static CamelFolder *get_folder(CamelStore * store, const char *folder_name, guin
if (camel_exception_is_set(ex))
return NULL;
- name = g_strdup_printf("%s%s", CAMEL_SERVICE(store)->url->path, folder_name);
+ name = g_strdup_printf("%s%s", CAMEL_LOCAL_STORE(store)->toplevel_dir, folder_name);
if (stat(name, &st) == -1) {
if (errno != ENOENT) {
@@ -121,7 +121,7 @@ static void delete_folder(CamelStore * store, const char *folder_name, CamelExce
char *name;
/* remove folder directory - will fail if not empty */
- name = g_strdup_printf("%s%s", CAMEL_SERVICE(store)->url->path, folder_name);
+ name = g_strdup_printf("%s%s", CAMEL_LOCAL_STORE(store)->toplevel_dir, folder_name);
if (rmdir(name) == -1) {
camel_exception_setv(ex, CAMEL_EXCEPTION_SYSTEM,
_("Could not delete folder `%s': %s"),
diff --git a/camel/providers/local/camel-spool-store.c b/camel/providers/local/camel-spool-store.c
index c10c0f252d..ac857c0928 100644
--- a/camel/providers/local/camel-spool-store.c
+++ b/camel/providers/local/camel-spool-store.c
@@ -96,8 +96,6 @@ camel_spool_store_get_type (void)
static void
construct (CamelService *service, CamelSession *session, CamelProvider *provider, CamelURL *url, CamelException *ex)
{
- int len;
- char *path, *name;
struct stat st;
d(printf("constructing store of type %s '%s:%s'\n",
@@ -113,25 +111,10 @@ construct (CamelService *service, CamelSession *session, CamelProvider *provider
return;
}
- len = strlen (service->url->path);
- if (len > 0 && service->url->path[len - 1] == '/') {
- service->url->path = g_realloc (service->url->path, len + 2);
- service->url->path[len-1] = 0;
- }
-
- path = service->url->path;
- len = strlen(path);
- name = path;
-#if 0
- name = alloca(len+1);
- strcpy(name, path);
- name[len-1] = 0;
-#endif
-
- if (stat(name, &st) == -1 || !S_ISREG(st.st_mode)) {
+ if (stat(service->url->path, &st) == -1 || !S_ISREG(st.st_mode)) {
camel_exception_setv(ex, CAMEL_EXCEPTION_STORE_NO_FOLDER,
_("Spool `%s' does not exist or is not a regular file"),
- path);
+ service->url->path);
return;
}
}