diff options
author | Michael Zucci <zucchi@src.gnome.org> | 2001-09-21 08:55:36 +0800 |
---|---|---|
committer | Michael Zucci <zucchi@src.gnome.org> | 2001-09-21 08:55:36 +0800 |
commit | 5de6e2a14b9d3e4fc3260cfa195921d020249a22 (patch) | |
tree | 59a15ad96fb6ba95b33a855e205cbb3a2849e02e | |
parent | 8ee783370fbc98b8a6556a65eae8aa1c94d0cc86 (diff) | |
download | gsoc2013-evolution-5de6e2a14b9d3e4fc3260cfa195921d020249a22.tar.gz gsoc2013-evolution-5de6e2a14b9d3e4fc3260cfa195921d020249a22.tar.zst gsoc2013-evolution-5de6e2a14b9d3e4fc3260cfa195921d020249a22.zip |
Setup unread count properly, and also setup the url properly.
* providers/local/camel-local-folder.c
(camel_local_folder_construct): Setup unread count properly, and
also setup the url properly.
(scan_dir): Dont include empty host part in url for folder.
(scan_dir): Lookup folder counts for any folders we currenty have
open.
svn path=/trunk/; revision=13035
-rw-r--r-- | camel/ChangeLog | 7 | ||||
-rw-r--r-- | camel/camel-store.c | 2 | ||||
-rw-r--r-- | camel/providers/local/camel-local-folder.c | 6 | ||||
-rw-r--r-- | camel/providers/local/camel-maildir-store.c | 34 |
4 files changed, 36 insertions, 13 deletions
diff --git a/camel/ChangeLog b/camel/ChangeLog index 482549acdc..5d8203658b 100644 --- a/camel/ChangeLog +++ b/camel/ChangeLog @@ -1,7 +1,14 @@ 2001-09-20 <NotZed@Ximian.com> + * providers/local/camel-local-folder.c + (camel_local_folder_construct): Setup unread count properly, and + also setup the url properly. + * providers/local/camel-maildir-store.c (camel_folder_info_new): Build the path on the folderinfo. + (scan_dir): Dont include empty host part in url for folder. + (scan_dir): Lookup folder counts for any folders we currenty have + open. * providers/local/camel-spool-store.c (get_folder_info): If we have this folder open, then set unread from the folder itself. diff --git a/camel/camel-store.c b/camel/camel-store.c index 939b99bb4d..62b1c48902 100644 --- a/camel/camel-store.c +++ b/camel/camel-store.c @@ -132,7 +132,7 @@ static void camel_store_finalize (CamelObject *object) { CamelStore *store = CAMEL_STORE (object); - + if (store->folders) { if (g_hash_table_size (store->folders) != 0) { g_warning ("Folder cache for store %p contains " diff --git a/camel/providers/local/camel-local-folder.c b/camel/providers/local/camel-local-folder.c index 2887fcce73..2e9e348695 100644 --- a/camel/providers/local/camel-local-folder.c +++ b/camel/providers/local/camel-local-folder.c @@ -224,9 +224,11 @@ 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 (lf->folder_path); - fi->unread_message_count = -1; + fi->url = g_strdup_printf("%s:%s#%s", ((CamelService *)parent_store)->url->protocol, + ((CamelService *)parent_store)->url->protocol, full_name); + fi->unread_message_count = camel_folder_get_unread_message_count(folder); camel_folder_info_build_path(fi, '/'); + camel_object_trigger_event(CAMEL_OBJECT (parent_store), "folder_created", fi); camel_folder_info_free(fi); diff --git a/camel/providers/local/camel-maildir-store.c b/camel/providers/local/camel-maildir-store.c index 974a66a038..b0d4c072f8 100644 --- a/camel/providers/local/camel-maildir-store.c +++ b/camel/providers/local/camel-maildir-store.c @@ -35,6 +35,7 @@ #include "camel-maildir-folder.h" #include "camel-exception.h" #include "camel-url.h" +#include "camel-private.h" #define d(x) @@ -141,11 +142,10 @@ static CamelFolder *get_folder(CamelStore * store, const char *folder_name, guin return folder; } -/* fixes bug #1138 */ static CamelFolder * get_inbox (CamelStore *store, CamelException *ex) { - return get_folder (store, "", 0, ex); + return get_folder (store, ".", 0, ex); } static void delete_folder(CamelStore * store, const char *folder_name, CamelException * ex) @@ -226,6 +226,8 @@ static CamelFolderInfo *camel_folder_info_new(const char *url, const char *full, fi->unread_message_count = unread; camel_folder_info_build_path(fi, '/'); + d(printf("Adding maildir info: '%s' '%s' '%s'\n", fi->path, fi->name, fi->full_name)); + return fi; } @@ -236,7 +238,7 @@ struct _inode { }; /* returns number of records found at or below this level */ -static int scan_dir(GHashTable *visited, char *root, const char *path, guint32 flags, CamelFolderInfo *parent, CamelFolderInfo **fip, CamelException *ex) +static int scan_dir(CamelStore *store, GHashTable *visited, char *root, const char *path, guint32 flags, CamelFolderInfo *parent, CamelFolderInfo **fip, CamelException *ex) { DIR *dir; struct dirent *d; @@ -244,6 +246,8 @@ static int scan_dir(GHashTable *visited, char *root, const char *path, guint32 f const char *base; CamelFolderInfo *fi = NULL; struct stat st; + CamelFolder *folder; + int unread; /* look for folders matching the right structure, recursively */ name = g_strdup_printf("%s/%s", root, path); @@ -256,17 +260,27 @@ static int scan_dir(GHashTable *visited, char *root, const char *path, guint32 f if (stat(tmp, &st) == 0 && S_ISDIR(st.st_mode) && stat(cur, &st) == 0 && S_ISDIR(st.st_mode) - && stat(new, &st) == 0 && S_ISDIR(st.st_mode)) - uri = g_strdup_printf("maildir://%s#%s", root, path); - else - uri = g_strdup_printf("maildir://%s;noselect=yes#%s", root, path); + && stat(new, &st) == 0 && S_ISDIR(st.st_mode)) { + uri = g_strdup_printf("maildir:%s#%s", root, path); + } else + uri = g_strdup_printf("maildir:%s;noselect=yes#%s", root, path); base = strrchr(path, '/'); if (base) base++; else base = path; - fi = camel_folder_info_new(uri, path, base, -1); + + /* if we have this folder open, get the real unread count */ + CAMEL_STORE_LOCK(store, cache_lock); + folder = g_hash_table_lookup(store->folders, path); + if (folder) + unread = camel_folder_get_message_count(folder); + else + unread = 0; + CAMEL_STORE_UNLOCK(store, cache_lock); + + fi = camel_folder_info_new(uri, path, base, unread); d(printf("found! uri = %s\n", fi->url)); d(printf(" full_name = %s\n name = '%s'\n", fi->full_name, fi->name)); @@ -310,7 +324,7 @@ static int scan_dir(GHashTable *visited, char *root, const char *path, guint32 f *inew = in; g_hash_table_insert(visited, inew, inew); new = g_strdup_printf("%s/%s", path, d->d_name); - if (scan_dir(visited, root, new, flags, fi, &fi->child, ex) == -1) { + if (scan_dir(store, visited, root, new, flags, fi, &fi->child, ex) == -1) { g_free(tmp); g_free(new); closedir(dir); @@ -357,7 +371,7 @@ get_folder_info (CamelStore *store, const char *top, guint32 flags, CamelExcepti visited = g_hash_table_new(inode_hash, inode_equal); - if (scan_dir(visited, service->url->path, top?top:".", flags, NULL, &fi, ex) == -1 && fi != NULL) { + if (scan_dir(store, visited, service->url->path, top?top:".", flags, NULL, &fi, ex) == -1 && fi != NULL) { camel_store_free_folder_info_full(store, fi); fi = NULL; } |