diff options
author | Not Zed <NotZed@Ximian.com> | 2004-03-11 11:04:45 +0800 |
---|---|---|
committer | Michael Zucci <zucchi@src.gnome.org> | 2004-03-11 11:04:45 +0800 |
commit | 6071a963e85f69133cc1761e37b6ed942629d70d (patch) | |
tree | 95c9e1644c80d083e2baf049e66b9f99c5997051 /camel/providers/local/camel-mh-store.c | |
parent | ecda7da11e893ff29258388c7b594b5ef4fa902a (diff) | |
download | gsoc2013-evolution-6071a963e85f69133cc1761e37b6ed942629d70d.tar gsoc2013-evolution-6071a963e85f69133cc1761e37b6ed942629d70d.tar.gz gsoc2013-evolution-6071a963e85f69133cc1761e37b6ed942629d70d.tar.bz2 gsoc2013-evolution-6071a963e85f69133cc1761e37b6ed942629d70d.tar.lz gsoc2013-evolution-6071a963e85f69133cc1761e37b6ed942629d70d.tar.xz gsoc2013-evolution-6071a963e85f69133cc1761e37b6ed942629d70d.tar.zst gsoc2013-evolution-6071a963e85f69133cc1761e37b6ed942629d70d.zip |
turn off NOINFERIORS always, translate to nochildren.
2004-03-11 Not Zed <NotZed@Ximian.com>
* providers/imap/camel-imap-store.c (get_one_folder_offline):
(parse_list_response_as_folder_info): turn
off NOINFERIORS always, translate to nochildren.
2004-03-08 Not Zed <NotZed@Ximian.com>
* camel-vee-store.c (vee_get_folder_info): setup virtual/system
flags as appropriate.
(change_folder): setup flags properly.
* providers/nntp/camel-nntp-store.c
(nntp_store_get_subscribed_folder_info): mark all folders as
system folders.
* providers/local/camel-mh-store.c (fill_fi): add this to setup
folderinfo.
(folder_info_new): call fill_fi to fill unread/total.
(recursive_scan, folders_scan): ahh yeah, so wtf was i thinking,
store->flags != get_folder_info flags!!!!
* providers/local/camel-maildir-store.c (camel_folder_info_new):
remove unread count arg & setup total.
(fill_fi): setup total field.
(scan_dir): remove the code that checked the directory directly -
use fill_fi instead. It will more accurately reflect what you get
when you visit the folder.
(camel_folder_info_new): mark "." as a system folder.
(scan_dir): try to setup children/no children flags properly.
* providers/local/camel-mbox-store.c (fill_fi): setup total field.
(scan_dir): init total.
(get_folder_info): "
2004-03-05 Not Zed <NotZed@Ximian.com>
* providers/imap/camel-imap-store.c
(parse_list_response_as_folder_info): mark INBOX as a system
folder. Can't be renamed/deleted.
(fill_fi): setup total field.
(get_folder_counts): ditto.
* camel-store.c (add_special_info): set the system folder flag.
* camel-store.h: time to fix up the camelfolderinfo mess. fix
some member names, and add some type fields. Fixed all uses.
svn path=/trunk/; revision=25019
Diffstat (limited to 'camel/providers/local/camel-mh-store.c')
-rw-r--r-- | camel/providers/local/camel-mh-store.c | 82 |
1 files changed, 53 insertions, 29 deletions
diff --git a/camel/providers/local/camel-mh-store.c b/camel/providers/local/camel-mh-store.c index b16c140a66..e1c03c2349 100644 --- a/camel/providers/local/camel-mh-store.c +++ b/camel/providers/local/camel-mh-store.c @@ -38,6 +38,8 @@ #include <camel/camel-stream-fs.h> #include <camel/camel-stream-buffer.h> +#include "camel-mh-summary.h" + static CamelLocalStoreClass *parent_class = NULL; #define d(x) @@ -290,35 +292,57 @@ rename_folder(CamelStore *store, const char *old, const char *new, CamelExceptio } } -static CamelFolderInfo *folder_info_new(CamelStore *store, const char *root, const char *path) +static void +fill_fi(CamelStore *store, CamelFolderInfo *fi, guint32 flags) +{ + CamelFolder *folder; + + folder = camel_object_bag_get(store->folders, fi->full_name); + if (folder) { + if ((flags & CAMEL_STORE_FOLDER_INFO_FAST) == 0) + camel_folder_refresh_info(folder, NULL); + fi->unread = camel_folder_get_unread_message_count(folder); + fi->total = camel_folder_get_message_count(folder); + camel_object_unref(folder); + } else { + char *path, *folderpath; + CamelFolderSummary *s; + const char *root; + + /* This should be fast enough not to have to test for INFO_FAST */ + + /* We could: if we have no folder, and FAST isn't specified, perform a full + scan of all messages for their status flags. But its probably not worth + it as we need to read the top of every file, i.e. very very slow */ + + root = camel_local_store_get_toplevel_dir((CamelLocalStore *)store); + path = g_strdup_printf("%s/%s.ev-summary", root, fi->full_name); + folderpath = g_strdup_printf("%s/%s", root, fi->full_name); + s = (CamelFolderSummary *)camel_mh_summary_new(path, folderpath, NULL); + if (camel_folder_summary_header_load(s) != -1) { + fi->unread = s->unread_count; + fi->total = s->saved_count; + } + camel_object_unref(s); + g_free(folderpath); + g_free(path); + } +} + +static CamelFolderInfo *folder_info_new(CamelStore *store, const char *root, const char *path, guint32 flags) { CamelFolderInfo *fi; char *base; - CamelFolder *folder; base = strrchr(path, '/'); /* Build the folder info structure. */ fi = g_malloc0(sizeof(*fi)); - fi->url = g_strdup_printf("mh:%s#%s", root, path); + fi->uri = g_strdup_printf("mh:%s#%s", root, path); fi->full_name = g_strdup(path); fi->name = g_strdup(base?base+1:path); - fi->unread_message_count = 0; - - /* check unread count if open */ - folder = camel_object_bag_get(store->folders, path); - if (folder) { - if ((((CamelMhStore *)store)->flags & CAMEL_STORE_FOLDER_INFO_FAST) == 0) - camel_folder_refresh_info(folder, NULL); - fi->unread_message_count = camel_folder_get_unread_message_count(folder); - camel_object_unref(folder); - } - - /* We could: if we have no folder, and FAST isn't specified, perform a full - scan of all messages for their status flags. But its probably not worth - it as we need to read the top of every file, i.e. very very slow */ - camel_folder_info_build_path(fi, '/'); + fill_fi(store, fi, flags); d(printf("New folderinfo:\n '%s'\n '%s'\n '%s'\n", fi->full_name, fi->url, fi->path)); @@ -333,7 +357,7 @@ struct _inode { /* Scan path, under root, for directories to add folders for. Both * root and path should have a trailing "/" if they aren't empty. */ -static void recursive_scan(CamelStore *store, CamelFolderInfo **fip, CamelFolderInfo *parent, GHashTable *visited, const char *root, const char *path) +static void recursive_scan(CamelStore *store, CamelFolderInfo **fip, CamelFolderInfo *parent, GHashTable *visited, const char *root, const char *path, guint32 flags) { char *fullpath, *tmp; DIR *dp; @@ -364,12 +388,12 @@ static void recursive_scan(CamelStore *store, CamelFolderInfo **fip, CamelFolder g_hash_table_insert(visited, inew, inew); /* link in ... */ - fi = folder_info_new(store, root, path); + fi = folder_info_new(store, root, path, flags); fi->parent = parent; - fi->sibling = *fip; + fi->next = *fip; *fip = fi; - if ((( ((CamelMhStore *)store)->flags & CAMEL_STORE_FOLDER_INFO_RECURSIVE) || parent == NULL)) { + if (((flags & CAMEL_STORE_FOLDER_INFO_RECURSIVE) || parent == NULL)) { /* now check content for possible other directories */ dp = opendir(fullpath); if (dp == NULL) @@ -390,10 +414,10 @@ static void recursive_scan(CamelStore *store, CamelFolderInfo **fip, CamelFolder /* otherwise, treat at potential node, and recurse, a bit more expensive than needed, but tough! */ if (path[0]) { tmp = g_strdup_printf("%s/%s", path, d->d_name); - recursive_scan(store, &fi->child, fi, visited, root, tmp); + recursive_scan(store, &fi->child, fi, visited, root, tmp, flags); g_free(tmp); } else { - recursive_scan(store, &fi->child, fi, visited, root, d->d_name); + recursive_scan(store, &fi->child, fi, visited, root, d->d_name, flags); } } @@ -403,7 +427,7 @@ static void recursive_scan(CamelStore *store, CamelFolderInfo **fip, CamelFolder /* scan a .folders file */ static void -folders_scan(CamelStore *store, const char *root, const char *top, CamelFolderInfo **fip) +folders_scan(CamelStore *store, const char *root, const char *top, CamelFolderInfo **fip, guint32 flags) { CamelFolderInfo *fi; char line[512], *path, *tmp; @@ -452,7 +476,7 @@ folders_scan(CamelStore *store, const char *root, const char *top, CamelFolderIn continue; /* check is not sub-subdir if not recursive */ - if (( ((CamelMhStore *)store)->flags & CAMEL_STORE_FOLDER_INFO_RECURSIVE) == 0 + if ((flags & CAMEL_STORE_FOLDER_INFO_RECURSIVE) == 0 && (tmp = strrchr(line, '/')) && tmp > line+toplen) continue; @@ -466,7 +490,7 @@ folders_scan(CamelStore *store, const char *root, const char *top, CamelFolderIn path = g_strdup_printf("%s/%s", root, line); if (stat(path, &st) == 0 && S_ISDIR(st.st_mode)) { - fi = folder_info_new(store, root, line); + fi = folder_info_new(store, root, line, flags); g_ptr_array_add(folders, fi); } g_free(path); @@ -512,14 +536,14 @@ get_folder_info (CamelStore *store, const char *top, guint32 flags, CamelExcepti /* use .folders if we are supposed to */ if (((CamelMhStore *)store)->flags & CAMEL_MH_DOTFOLDERS) { - folders_scan(store, root, top, &fi); + folders_scan(store, root, top, &fi, flags); } else { GHashTable *visited = g_hash_table_new(inode_hash, inode_equal); if (top == NULL) top = ""; - recursive_scan(store, &fi, NULL, visited, root, top); + recursive_scan(store, &fi, NULL, visited, root, top, flags); /* if we actually scanned from root, we have a "" root node we dont want */ if (fi != NULL && top[0] == 0) { |