diff options
Diffstat (limited to 'camel/providers/local')
-rw-r--r-- | camel/providers/local/camel-local-folder.c | 4 | ||||
-rw-r--r-- | camel/providers/local/camel-local-store.c | 4 | ||||
-rw-r--r-- | camel/providers/local/camel-maildir-store.c | 43 | ||||
-rw-r--r-- | camel/providers/local/camel-mbox-store.c | 34 | ||||
-rw-r--r-- | camel/providers/local/camel-mh-store.c | 82 | ||||
-rw-r--r-- | camel/providers/local/camel-spool-store.c | 18 |
6 files changed, 111 insertions, 74 deletions
diff --git a/camel/providers/local/camel-local-folder.c b/camel/providers/local/camel-local-folder.c index 719d133645..5ea484ef99 100644 --- a/camel/providers/local/camel-local-folder.c +++ b/camel/providers/local/camel-local-folder.c @@ -313,8 +313,8 @@ 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->path, full_name); - fi->unread_message_count = camel_folder_get_unread_message_count(folder); + fi->uri = g_strdup_printf("%s:%s#%s", ((CamelService *)parent_store)->url->protocol, ((CamelService *)parent_store)->url->path, full_name); + fi->unread = camel_folder_get_unread_message_count(folder); camel_folder_info_build_path(fi, '/'); camel_object_trigger_event(CAMEL_OBJECT (parent_store), "folder_created", fi); diff --git a/camel/providers/local/camel-local-store.c b/camel/providers/local/camel-local-store.c index fae124e448..a883f4a4dd 100644 --- a/camel/providers/local/camel-local-store.c +++ b/camel/providers/local/camel-local-store.c @@ -427,9 +427,9 @@ 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_path_get_basename (folder_name); - fi->url = g_strdup_printf ("%s:%s#%s", ((CamelService *) store)->url->protocol, + fi->uri = g_strdup_printf ("%s:%s#%s", ((CamelService *) store)->url->protocol, CAMEL_LOCAL_STORE(store)->toplevel_dir, folder_name); - fi->unread_message_count = -1; + fi->unread = -1; camel_folder_info_build_path(fi, '/'); camel_object_trigger_event (store, "folder_deleted", fi); diff --git a/camel/providers/local/camel-maildir-store.c b/camel/providers/local/camel-maildir-store.c index b0412d3d9a..5d0654c6e4 100644 --- a/camel/providers/local/camel-maildir-store.c +++ b/camel/providers/local/camel-maildir-store.c @@ -222,17 +222,21 @@ static void delete_folder(CamelStore * store, const char *folder_name, CamelExce g_free(new); } -static CamelFolderInfo *camel_folder_info_new(const char *url, const char *full, const char *name, int unread) +static CamelFolderInfo *camel_folder_info_new(const char *url, const char *full, const char *name) { CamelFolderInfo *fi; fi = g_malloc0(sizeof(*fi)); - fi->url = g_strdup(url); + fi->uri = g_strdup(url); fi->full_name = g_strdup(full); fi->name = g_strdup(name); - fi->unread_message_count = unread; + fi->unread = -1; + fi->total = -1; camel_folder_info_build_path(fi, '/'); + if (!strcmp(full, ".")) + fi->flags |= CAMEL_FOLDER_SYSTEM; + d(printf("Adding maildir info: '%s' '%s' '%s' '%s'\n", fi->path, fi->name, fi->full_name, fi->url)); return fi; @@ -242,13 +246,13 @@ static void fill_fi(CamelStore *store, CamelFolderInfo *fi, guint32 flags) { CamelFolder *folder; - int unread = -1; 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); - unread = camel_folder_get_unread_message_count(folder); + 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; @@ -260,14 +264,14 @@ fill_fi(CamelStore *store, CamelFolderInfo *fi, guint32 flags) 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_maildir_summary_new(path, folderpath, NULL); - if (camel_folder_summary_header_load(s) != -1) - unread = s->unread_count; + 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); } - - fi->unread_message_count = unread; } /* used to find out where we've visited already */ @@ -285,8 +289,6 @@ static int scan_dir(CamelStore *store, GHashTable *visited, char *root, const ch 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); @@ -310,6 +312,7 @@ static int scan_dir(CamelStore *store, GHashTable *visited, char *root, const ch else base = path; +#if 0 /* if we have this folder open, get the real unread count */ folder = camel_object_bag_get(store->folders, path); if (folder) { @@ -348,16 +351,15 @@ static int scan_dir(CamelStore *store, GHashTable *visited, char *root, const ch closedir(dir); } } - - fi = camel_folder_info_new(uri, path, base, -1); - /* fills the unread count */ +#endif + fi = camel_folder_info_new(uri, path, base); fill_fi(store, fi, flags); d(printf("found! uri = %s\n", fi->url)); d(printf(" full_name = %s\n name = '%s'\n", fi->full_name, fi->name)); fi->parent = parent; - fi->sibling = *fip; + fi->next = *fip; *fip = fi; g_free(uri); @@ -365,10 +367,10 @@ static int scan_dir(CamelStore *store, GHashTable *visited, char *root, const ch g_free(cur); g_free(new); - unread = 0; - /* always look further if asked */ if (((flags & CAMEL_STORE_FOLDER_INFO_RECURSIVE) || parent == NULL)) { + int children = 0; + dir = opendir(name); if (dir == NULL) { camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM, @@ -394,6 +396,8 @@ static int scan_dir(CamelStore *store, GHashTable *visited, char *root, const ch if (g_hash_table_lookup(visited, &in) == NULL) { struct _inode *inew = g_malloc(sizeof(*inew)); + children++; + *inew = in; g_hash_table_insert(visited, inew, inew); new = g_strdup_printf("%s/%s", path, d->d_name); @@ -409,6 +413,11 @@ static int scan_dir(CamelStore *store, GHashTable *visited, char *root, const ch g_free(tmp); } closedir(dir); + + if (children) + fi->flags |= CAMEL_FOLDER_CHILDREN; + else + fi->flags |= CAMEL_FOLDER_NOCHILDREN; } g_free(name); diff --git a/camel/providers/local/camel-mbox-store.c b/camel/providers/local/camel-mbox-store.c index 94b2e6fbeb..595445f99c 100644 --- a/camel/providers/local/camel-mbox-store.c +++ b/camel/providers/local/camel-mbox-store.c @@ -330,8 +330,8 @@ 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_path_get_basename(folder_name); - fi->url = g_strdup_printf("mbox:%s#%s",((CamelService *) store)->url->path, folder_name); - fi->unread_message_count = -1; + fi->uri = g_strdup_printf("mbox:%s#%s",((CamelService *) store)->url->path, folder_name); + fi->unread = -1; camel_folder_info_build_path(fi, '/'); camel_object_trigger_event(store, "folder_deleted", fi); @@ -600,13 +600,15 @@ static void fill_fi(CamelStore *store, CamelFolderInfo *fi, guint32 flags) { CamelFolder *folder; - int unread = -1; + fi->unread = -1; + fi->total = -1; 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); - unread = camel_folder_get_unread_message_count(folder); + 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; @@ -619,15 +621,15 @@ fill_fi(CamelStore *store, CamelFolderInfo *fi, guint32 flags) folderpath = camel_mbox_folder_get_full_path(root, fi->full_name); mbs = (CamelMboxSummary *)camel_mbox_summary_new(path, folderpath, NULL); - if (camel_folder_summary_header_load((CamelFolderSummary *)mbs) != -1) - unread = ((CamelFolderSummary *)mbs)->unread_count; + if (camel_folder_summary_header_load((CamelFolderSummary *)mbs) != -1) { + fi->unread = ((CamelFolderSummary *)mbs)->unread_count; + fi->total = ((CamelFolderSummary *)mbs)->saved_count; + } camel_object_unref(mbs); g_free(folderpath); g_free(path); } - - fi->unread_message_count = unread; } static CamelFolderInfo * @@ -692,7 +694,7 @@ scan_dir(CamelStore *store, GHashTable *visited, CamelFolderInfo *parent, const fi->flags =(fi->flags & ~CAMEL_FOLDER_NOCHILDREN) | CAMEL_FOLDER_CHILDREN; } else { fi->flags &= ~CAMEL_FOLDER_NOSELECT; - if ((ext = strchr(fi->url, ';')) && !strncmp(ext, ";noselect=yes", 13)) + if ((ext = strchr(fi->uri, ';')) && !strncmp(ext, ";noselect=yes", 13)) memmove(ext, ext + 13, strlen(ext + 13) + 1); } } else { @@ -700,13 +702,14 @@ scan_dir(CamelStore *store, GHashTable *visited, CamelFolderInfo *parent, const fi->parent = parent; /* add ";noselect=yes" if we haven't found the mbox file yet. when we find it, remove the noselect */ - fi->url = g_strdup_printf("mbox:%s%s#%s",((CamelService *) store)->url->path, + fi->uri = g_strdup_printf("mbox:%s%s#%s",((CamelService *) store)->url->path, S_ISDIR(st.st_mode) ? ";noselect=yes" : "", full_name); fi->name = short_name; fi->full_name = full_name; fi->path = g_strdup_printf("/%s", full_name); - fi->unread_message_count = -1; - + fi->unread = -1; + fi->total = -1; + if (S_ISDIR(st.st_mode)) fi->flags = CAMEL_FOLDER_NOSELECT; else @@ -715,7 +718,7 @@ scan_dir(CamelStore *store, GHashTable *visited, CamelFolderInfo *parent, const if (tail == NULL) folders = fi; else - tail->sibling = fi; + tail->next = fi; tail = fi; @@ -802,10 +805,11 @@ get_folder_info(CamelStore *store, const char *top, guint32 flags, CamelExceptio fi = g_new0(CamelFolderInfo, 1); fi->parent = NULL; - fi->url = g_strdup_printf("mbox:%s#%s",((CamelService *) store)->url->path, top); + fi->uri = g_strdup_printf("mbox:%s#%s",((CamelService *) store)->url->path, top); fi->name = g_strdup(base); fi->full_name = g_strdup(top); - fi->unread_message_count = -1; + fi->unread = -1; + fi->total = -1; fi->path = g_strdup_printf("/%s", top); subdir = g_strdup_printf("%s.sbd", path); 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) { diff --git a/camel/providers/local/camel-spool-store.c b/camel/providers/local/camel-spool-store.c index 09720e4a01..1aa18965ae 100644 --- a/camel/providers/local/camel-spool-store.c +++ b/camel/providers/local/camel-spool-store.c @@ -228,7 +228,7 @@ delete_folder(CamelStore *store, const char *folder_name, CamelException *ex) static void free_folder_info (CamelStore *store, CamelFolderInfo *fi) { if (fi) { - g_free(fi->url); + g_free(fi->uri); g_free(fi->name); g_free(fi->full_name); g_free(fi->path); @@ -242,10 +242,10 @@ camel_folder_info_new(const char *url, const char *full, const char *name, int u CamelFolderInfo *fi; fi = g_malloc0(sizeof(*fi)); - fi->url = g_strdup(url); + fi->uri = g_strdup(url); fi->full_name = g_strdup(full); fi->name = g_strdup(name); - fi->unread_message_count = unread; + fi->unread = unread; camel_folder_info_build_path(fi, '/'); d(printf("Adding spoold info: '%s' '%s' '%s' '%s'\n", fi->path, fi->name, fi->full_name, fi->url)); @@ -303,7 +303,7 @@ static int scan_dir(CamelStore *store, GHashTable *visited, char *root, const ch uri = g_strdup_printf("%s:%s#%s", ((CamelService *)store)->url->protocol, root, path); fi = camel_folder_info_new(uri, path, tmp, unread); fi->parent = parent; - fi->sibling = *fip; + fi->next = *fip; *fip = fi; g_free(uri); } @@ -327,7 +327,7 @@ static int scan_dir(CamelStore *store, GHashTable *visited, char *root, const ch tmp++; fi = camel_folder_info_new(uri, path, tmp, -1); fi->parent = parent; - fi->sibling = *fip; + fi->next = *fip; *fip = fi; g_free(uri); @@ -376,7 +376,7 @@ static int scan_dir(CamelStore *store, GHashTable *visited, char *root, const ch uri = g_strdup_printf("%s:%s#%s", ((CamelService *)store)->url->protocol, root, fname); fi = camel_folder_info_new(uri, fname, d->d_name, unread); fi->parent = parent; - fi->sibling = *fip; + fi->next = *fip; *fip = fi; g_free(uri); } @@ -458,14 +458,14 @@ get_folder_info_mbox(CamelStore *store, const char *top, guint32 flags, CamelExc fi = g_malloc0(sizeof(*fi)); fi->full_name = g_strdup("INBOX"); fi->name = g_strdup("INBOX"); - fi->url = g_strdup_printf("%s:%s#%s", service->url->protocol, service->url->path, fi->name); + fi->uri = g_strdup_printf("%s:%s#%s", service->url->protocol, service->url->path, fi->name); folder = camel_object_bag_get(store->folders, fi->full_name); if (folder) { - fi->unread_message_count = camel_folder_get_unread_message_count(folder); + fi->unread = camel_folder_get_unread_message_count(folder); camel_object_unref(folder); } else - fi->unread_message_count = -1; + fi->unread = -1; camel_folder_info_build_path(fi, '/'); } |