aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--camel/ChangeLog25
-rw-r--r--camel/camel-store.c24
-rw-r--r--camel/camel-store.h5
-rw-r--r--camel/providers/imap/camel-imap-store.c6
-rw-r--r--camel/providers/local/camel-local-folder.c3
-rw-r--r--camel/providers/local/camel-local-store.c52
-rw-r--r--camel/providers/local/camel-maildir-store.c7
7 files changed, 103 insertions, 19 deletions
diff --git a/camel/ChangeLog b/camel/ChangeLog
index 6776cb0b34..64c4914a74 100644
--- a/camel/ChangeLog
+++ b/camel/ChangeLog
@@ -1,7 +1,32 @@
+2001-10-28 <NotZed@Ximian.com>
+
+ * providers/local/camel-local-folder.c
+ (camel_local_folder_construct): Use path not protocol as the path
+ part of the uri of the folder_created event.
+
+ * providers/local/camel-maildir-store.c (scan_dir): If FAST is
+ set, dont try and scan for unread counts.
+
+ * providers/local/camel-local-store.c (create_folder): Implement,
+ just return the folderinfo of the folder matched, not all of it.
+
+ * camel-store.c (camel_store_rename_folder): Rename the
+ camelfolders before emitting the folderchanged event (otherwise
+ vstore fails to pick up change.
+
2001-10-27 <NotZed@Ximian.com>
+ * camel-store.c (camel_store_init): Always use a default dir_sep
+ of '/'.
+
+ * camel-store.h (struct _CamelStore): Added a dir_sep to the base
+ store so rename and whatnot can work, temporary fix for mixed dir
+ separator in folder name api's.
+
* providers/imap/camel-imap-store.c (rename_folder): Finished
implementation.
+ (imap_connect_online): Also set the store's dir_sep here.
+ (imap_connect_offline): "
* providers/local/camel-local-folder.c (local_rename): Implement
local rename of folder objects.
diff --git a/camel/camel-store.c b/camel/camel-store.c
index c6ffdcdaae..c993c74fee 100644
--- a/camel/camel-store.c
+++ b/camel/camel-store.c
@@ -122,6 +122,8 @@ camel_store_init (void *o)
/* set vtrash on by default */
store->flags = CAMEL_STORE_VTRASH;
+
+ store->dir_sep = '/';
store->priv = g_malloc0 (sizeof (*store->priv));
#ifdef ENABLE_THREADS
@@ -433,17 +435,6 @@ camel_store_rename_folder (CamelStore *store, const char *old_name, const char *
guint32 flags = CAMEL_STORE_FOLDER_INFO_RECURSIVE;
CamelRenameInfo reninfo;
- /* Emit changed signal */
- if (store->flags & CAMEL_STORE_SUBSCRIPTIONS)
- flags |= CAMEL_STORE_FOLDER_INFO_SUBSCRIBED;
-
- reninfo.old_base = (char *)old_name;
- reninfo.new = ((CamelStoreClass *)((CamelObject *)store)->classfuncs)->get_folder_info(store, new_name, flags, ex);
- if (info.new != NULL) {
- camel_object_trigger_event(CAMEL_OBJECT(store), "folder_renamed", &reninfo);
- ((CamelStoreClass *)((CamelObject *)store)->classfuncs)->free_folder_info(store, reninfo.new);
- }
-
CAMEL_STORE_LOCK(store, cache_lock);
for (i=0;i<info.folders->len;i++) {
char *new;
@@ -464,6 +455,17 @@ camel_store_rename_folder (CamelStore *store, const char *old_name, const char *
camel_object_unref((CamelObject *)folder);
}
CAMEL_STORE_UNLOCK(store, cache_lock);
+
+ /* Emit changed signal */
+ if (store->flags & CAMEL_STORE_SUBSCRIPTIONS)
+ flags |= CAMEL_STORE_FOLDER_INFO_SUBSCRIBED;
+
+ reninfo.old_base = (char *)old_name;
+ reninfo.new = ((CamelStoreClass *)((CamelObject *)store)->classfuncs)->get_folder_info(store, new_name, flags, ex);
+ if (info.new != NULL) {
+ camel_object_trigger_event(CAMEL_OBJECT(store), "folder_renamed", &reninfo);
+ ((CamelStoreClass *)((CamelObject *)store)->classfuncs)->free_folder_info(store, reninfo.new);
+ }
} else {
/* Failed, just unlock our folders for re-use */
for (i=0;i<info.folders->len;i++) {
diff --git a/camel/camel-store.h b/camel/camel-store.h
index 6b66811e24..af963fe872 100644
--- a/camel/camel-store.h
+++ b/camel/camel-store.h
@@ -78,6 +78,11 @@ struct _CamelStore
GHashTable *folders;
int flags;
+
+ /* FIXME: This is a temporary measure until IMAP namespaces are properly implemented,
+ after that, all external folder api's will assume a dir separator of '/' */
+ /* This is always a copy of IMAP_STORE()->dir_sep, or '/' */
+ char dir_sep;
};
diff --git a/camel/providers/imap/camel-imap-store.c b/camel/providers/imap/camel-imap-store.c
index 78fed3b5e6..aa7fc5fb17 100644
--- a/camel/providers/imap/camel-imap-store.c
+++ b/camel/providers/imap/camel-imap-store.c
@@ -666,6 +666,7 @@ imap_connect_online (CamelService *service, CamelException *ex)
sep = imap_parse_string (&name, &len);
if (sep) {
store->dir_sep = *sep;
+ ((CamelStore *)store)->dir_sep = store->dir_sep;
g_free (sep);
}
}
@@ -700,8 +701,10 @@ imap_connect_online (CamelService *service, CamelException *ex)
imap_parse_list_response (store, result, NULL, &store->dir_sep, NULL);
g_free (result);
}
- if (!store->dir_sep)
+ if (!store->dir_sep) {
store->dir_sep = '/'; /* Guess */
+ ((CamelStore *)store)->dir_sep = store->dir_sep;
+ }
}
/* canonicalize the namespace to end with dir_sep */
@@ -792,6 +795,7 @@ imap_connect_offline (CamelService *service, CamelException *ex)
camel_file_util_decode_string (storeinfo, &store->namespace);
camel_file_util_decode_uint32 (storeinfo, &tmp);
store->dir_sep = tmp;
+ ((CamelStore *)store)->dir_sep = tmp;
/* Get subscribed folders */
store->subscribed_folders = g_hash_table_new (g_str_hash, g_str_equal);
diff --git a/camel/providers/local/camel-local-folder.c b/camel/providers/local/camel-local-folder.c
index 6077a66da0..0a4d581bdf 100644
--- a/camel/providers/local/camel-local-folder.c
+++ b/camel/providers/local/camel-local-folder.c
@@ -229,8 +229,7 @@ camel_local_folder_construct(CamelLocalFolder *lf, CamelStore *parent_store, con
fi = g_new0 (CamelFolderInfo, 1);
fi->full_name = g_strdup (full_name);
fi->name = g_strdup (name);
- fi->url = g_strdup_printf("%s:%s#%s", ((CamelService *)parent_store)->url->protocol,
- ((CamelService *)parent_store)->url->protocol, full_name);
+ fi->url = g_strdup_printf("%s:%s#%s", ((CamelService *)parent_store)->url->protocol, ((CamelService *)parent_store)->url->path, full_name);
fi->unread_message_count = camel_folder_get_unread_message_count(folder);
camel_folder_info_build_path(fi, '/');
diff --git a/camel/providers/local/camel-local-store.c b/camel/providers/local/camel-local-store.c
index 918b8db420..9b48b91175 100644
--- a/camel/providers/local/camel-local-store.c
+++ b/camel/providers/local/camel-local-store.c
@@ -44,10 +44,10 @@ static CamelFolder *get_folder(CamelStore * store, const char *folder_name, guin
static char *get_name(CamelService *service, gboolean brief);
static CamelFolder *get_inbox (CamelStore *store, CamelException *ex);
static void rename_folder(CamelStore *store, const char *old_name, const char *new_name, CamelException *ex);
-static CamelFolderInfo *get_folder_info (CamelStore *store, const char *top,
- guint32 flags, CamelException *ex);
+static CamelFolderInfo *get_folder_info (CamelStore *store, const char *top, guint32 flags, CamelException *ex);
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 CamelFolderInfo *create_folder(CamelStore *store, const char *parent_name, const char *folder_name, CamelException *ex);
static CamelStoreClass *parent_class = NULL;
@@ -67,6 +67,7 @@ camel_local_store_class_init (CamelLocalStoreClass *camel_local_store_class)
camel_store_class->get_folder_info = get_folder_info;
camel_store_class->free_folder_info = camel_store_free_folder_info_full;
+ camel_store_class->create_folder = create_folder;
camel_store_class->delete_folder = delete_folder;
camel_store_class->rename_folder = rename_folder;
}
@@ -202,6 +203,53 @@ get_folder_info (CamelStore *store, const char *top,
return NULL;
}
+static CamelFolderInfo *
+create_folder(CamelStore *store, const char *parent_name, const char *folder_name, CamelException *ex)
+{
+ char *path = ((CamelLocalStore *)store)->toplevel_dir;
+ char *name;
+ CamelFolder *folder;
+ CamelFolderInfo *info = NULL;
+ struct stat st;
+
+ /* This is a pretty hacky version of create folder, but should basically work */
+
+ /* FIXME: The strings here are funny because of string freeze */
+
+ if (path[0] != '/') {
+ camel_exception_setv(ex, CAMEL_EXCEPTION_STORE_NO_FOLDER,
+ _("Store root %s is not an absolute path"), path);
+ return NULL;
+ }
+
+ name = g_strdup_printf("%s/%s/%s", path, parent_name, folder_name);
+
+ if (stat(name, &st) == 0 || errno != ENOENT) {
+ camel_exception_setv(ex, CAMEL_EXCEPTION_STORE_NO_FOLDER,
+ _("Cannot get folder: %s: %s"), name, strerror(errno));
+ g_free(name);
+ return NULL;
+ }
+
+ g_free(name);
+
+ name = g_strdup_printf("%s/%s", parent_name, folder_name);
+
+ folder = ((CamelStoreClass *)((CamelObject *)store)->classfuncs)->get_folder(store, name, CAMEL_STORE_FOLDER_CREATE, ex);
+ if (folder) {
+ camel_object_unref((CamelObject *)folder);
+ info = ((CamelStoreClass *)((CamelObject *)store)->classfuncs)->get_folder_info(store, name, 0, ex);
+
+ /* get_folder(CREATE) will emit a folder_created event for us */
+ /*if (info)
+ camel_object_trigger_event((CamelObject *)store, "folder_created", info);*/
+ }
+
+ g_free(name);
+
+ return info;
+}
+
static int xrename(const char *oldp, const char *newp, const char *prefix, const char *suffix, int missingok, CamelException *ex)
{
struct stat st;
diff --git a/camel/providers/local/camel-maildir-store.c b/camel/providers/local/camel-maildir-store.c
index 4d754e5f12..e26ab6b23e 100644
--- a/camel/providers/local/camel-maildir-store.c
+++ b/camel/providers/local/camel-maildir-store.c
@@ -271,18 +271,19 @@ static int scan_dir(CamelStore *store, GHashTable *visited, char *root, const ch
base = path;
/* if we have this folder open, get the real unread count */
+ unread = -1;
+
CAMEL_STORE_LOCK(store, cache_lock);
folder = g_hash_table_lookup(store->folders, path);
if (folder)
unread = camel_folder_get_unread_message_count(folder);
- else
- unread = 0;
CAMEL_STORE_UNLOCK(store, cache_lock);
/* if we dont have a folder, then scan the directory and get the unread
count from there, which is reasonably cheap (on decent filesystem) */
/* Well we could get this from the summary, but this is more accurate */
- if (folder == NULL) {
+ if (folder == NULL
+ && (flags & CAMEL_STORE_FOLDER_INFO_FAST) == 0) {
unread = 0;
dir = opendir(new);
if (dir) {