diff options
author | Not Zed <NotZed@Ximian.com> | 2004-02-16 17:38:24 +0800 |
---|---|---|
committer | Michael Zucci <zucchi@src.gnome.org> | 2004-02-16 17:38:24 +0800 |
commit | 1ceb4cd764fbdd89a3b67903251dc89ad3e7d723 (patch) | |
tree | a551592e442ee3404caa5d05a8362d7dd1d553b0 /camel/providers/imap | |
parent | 22fdff59a00dbbdcc6c6a59f452cfa7141bc7aad (diff) | |
download | gsoc2013-evolution-1ceb4cd764fbdd89a3b67903251dc89ad3e7d723.tar gsoc2013-evolution-1ceb4cd764fbdd89a3b67903251dc89ad3e7d723.tar.gz gsoc2013-evolution-1ceb4cd764fbdd89a3b67903251dc89ad3e7d723.tar.bz2 gsoc2013-evolution-1ceb4cd764fbdd89a3b67903251dc89ad3e7d723.tar.lz gsoc2013-evolution-1ceb4cd764fbdd89a3b67903251dc89ad3e7d723.tar.xz gsoc2013-evolution-1ceb4cd764fbdd89a3b67903251dc89ad3e7d723.tar.zst gsoc2013-evolution-1ceb4cd764fbdd89a3b67903251dc89ad3e7d723.zip |
** See bug #51045.
2004-02-16 Not Zed <NotZed@Ximian.com>
** See bug #51045.
* providers/imap/camel-imap-store.c (fill_fi): similar to mbox
version.
(get_folder_counts): use fill_fi to try and get folder counts if
we're not doing the hard slog.
(get_one_folder_offline): use fill_fi to try to get folder counts
from open folders or summaries.
* providers/local/camel-maildir-store.c (fill_fi): similar to mbox
version.
(scan_dir): use fill_fi to get the unread count now.
* providers/local/camel-mbox-store.c (fill_fi): helper to lookup
unread count either from active folder or from summary file, if
it's available.
(scan_dir, get_folder_info): use helper above to get folder info.
* devel-docs/camel-folder-summary.txt: New document describing the
format/conventions in the CamelFolderSummary file.
* providers/nntp/camel-nntp-summary.c (summary_header_load/save):
* providers/imapp/camel-imapp-summary.c (summary_header_load/save):
* providers/imap/camel-imap-summary.c (summary_header_load/save):
Handle versions, per-class version number (1).
* providers/local/camel-mbox-summary.c (summary_header_load/save):
Handle versions properly, add a per-class version (1). Write out the
folder size as a size_t rather than 32 bit int.
* providers/local/camel-local-summary.c (summary_header_load/save):
read/write the per-class version number (1).
* camel-folder-summary.c (summary_header_load): do version
checking differently, allow the version to be bumped without
aborting the load. Added unread/deleted/junk counts to base
header.
(summary_header_save): Save out the new-format header. Version
bumped to 13.
* camel.c (camel_init): return 0 rather than spit a compiler warning.
* camel-file-utils.c (camel_file_util_encode_*_t): macro-ise the
type encoder/decoders. Also add size_t encoder/decoder.
svn path=/trunk/; revision=24744
Diffstat (limited to 'camel/providers/imap')
-rw-r--r-- | camel/providers/imap/camel-imap-store.c | 53 | ||||
-rw-r--r-- | camel/providers/imap/camel-imap-summary.c | 28 | ||||
-rw-r--r-- | camel/providers/imap/camel-imap-summary.h | 1 |
3 files changed, 67 insertions, 15 deletions
diff --git a/camel/providers/imap/camel-imap-store.c b/camel/providers/imap/camel-imap-store.c index 7b86773b4c..4ca1b1d4bd 100644 --- a/camel/providers/imap/camel-imap-store.c +++ b/camel/providers/imap/camel-imap-store.c @@ -2349,6 +2349,48 @@ dumpfi(CamelFolderInfo *fi) #endif 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); + camel_object_unref(folder); + } else { + char *storage_path, *folder_dir, *path; + CamelFolderSummary *s; + + printf("looking up counts from '%s'\n", fi->full_name); + + /* This is a lot of work for one path! */ + storage_path = g_strdup_printf("%s/folders", ((CamelImapStore *)store)->storage_path); + folder_dir = e_path_to_physical(storage_path, fi->full_name); + path = g_strdup_printf("%s/summary", folder_dir); + s = (CamelFolderSummary *)camel_object_new(camel_imap_summary_get_type()); + camel_folder_summary_set_build_content(s, TRUE); + camel_folder_summary_set_filename(s, path); + if (camel_folder_summary_header_load(s) != -1) { + unread = s->unread_count; + printf("loaded summary header unread = %d\n", unread); + } else { + printf("couldn't load summary header?\n"); + } + + g_free(storage_path); + g_free(folder_dir); + g_free(path); + + camel_object_unref(s); + } + + fi->unread_message_count = unread; +} + +static void get_folder_counts(CamelImapStore *imap_store, CamelFolderInfo *fi, CamelException *ex) { GSList *q; @@ -2393,13 +2435,8 @@ get_folder_counts(CamelImapStore *imap_store, CamelFolderInfo *fi, CamelExceptio CAMEL_SERVICE_UNLOCK (imap_store, connect_lock); } else { - /* since its cheap, get it if they're open */ - folder = camel_object_bag_get(CAMEL_STORE(imap_store)->folders, fi->full_name); - if (folder) { - fi->unread_message_count = camel_folder_get_unread_message_count(folder); - camel_object_unref(folder); - } else - fi->unread_message_count = -1; + /* since its cheap, get it if they're open/consult summary file */ + fill_fi((CamelStore *)imap_store, fi, 0); } if (fi->child) @@ -2636,6 +2673,8 @@ get_one_folder_offline (const char *physical_path, const char *path, gpointer da g_free(fi->url); fi->url = camel_url_to_string (url, 0); camel_url_free (url); + } else { + fill_fi((CamelStore *)imap_store, fi, 0); } g_ptr_array_add (folders, fi); } diff --git a/camel/providers/imap/camel-imap-summary.c b/camel/providers/imap/camel-imap-summary.c index dba1134fa1..bebc672866 100644 --- a/camel/providers/imap/camel-imap-summary.c +++ b/camel/providers/imap/camel-imap-summary.c @@ -35,7 +35,7 @@ #include "camel-imap-summary.h" #include "camel-file-utils.h" -#define CAMEL_IMAP_SUMMARY_VERSION (0x300) +#define CAMEL_IMAP_SUMMARY_VERSION (1) static int summary_header_load (CamelFolderSummary *, FILE *); static int summary_header_save (CamelFolderSummary *, FILE *); @@ -94,9 +94,6 @@ camel_imap_summary_init (CamelImapSummary *obj) /* subclasses need to set the right instance data sizes */ s->message_info_size = sizeof(CamelImapMessageInfo); s->content_info_size = sizeof(CamelImapMessageContentInfo); - - /* and a unique file version */ - s->version += CAMEL_IMAP_SUMMARY_VERSION; } /** @@ -125,7 +122,6 @@ camel_imap_summary_new (const char *filename) return summary; } - static int summary_header_load (CamelFolderSummary *s, FILE *in) { @@ -134,7 +130,22 @@ summary_header_load (CamelFolderSummary *s, FILE *in) if (camel_imap_summary_parent->summary_header_load (s, in) == -1) return -1; - return camel_file_util_decode_uint32 (in, &ims->validity); + /* Legacy version */ + if (s->version == 0x30c) + return camel_file_util_decode_uint32(in, &ims->validity); + + /* Version 1 */ + if (camel_file_util_decode_fixed_int32(in, &ims->version) == -1 + || camel_file_util_decode_fixed_int32(in, &ims->validity) == -1) + return -1; + + if (ims->version > CAMEL_IMAP_SUMMARY_VERSION) { + g_warning("Unkown summary version\n"); + errno = EINVAL; + return -1; + } + + return 0; } static int @@ -145,9 +156,10 @@ summary_header_save (CamelFolderSummary *s, FILE *out) if (camel_imap_summary_parent->summary_header_save (s, out) == -1) return -1; - return camel_file_util_encode_uint32 (out, ims->validity); -} + camel_file_util_encode_fixed_int32(out, CAMEL_IMAP_SUMMARY_VERSION); + return camel_file_util_encode_fixed_int32(out, ims->validity); +} static CamelMessageInfo * message_info_load (CamelFolderSummary *s, FILE *in) diff --git a/camel/providers/imap/camel-imap-summary.h b/camel/providers/imap/camel-imap-summary.h index 817e884408..fc54d8d0d8 100644 --- a/camel/providers/imap/camel-imap-summary.h +++ b/camel/providers/imap/camel-imap-summary.h @@ -55,6 +55,7 @@ typedef struct _CamelImapMessageInfo { struct _CamelImapSummary { CamelFolderSummary parent; + guint32 version; guint32 validity; }; |