From 1ceb4cd764fbdd89a3b67903251dc89ad3e7d723 Mon Sep 17 00:00:00 2001 From: Not Zed Date: Mon, 16 Feb 2004 09:38:24 +0000 Subject: ** See bug #51045. 2004-02-16 Not Zed ** 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 --- camel/providers/nntp/camel-nntp-summary.c | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) (limited to 'camel/providers/nntp/camel-nntp-summary.c') diff --git a/camel/providers/nntp/camel-nntp-summary.c b/camel/providers/nntp/camel-nntp-summary.c index 2fa753bef1..6c9c7e54b8 100644 --- a/camel/providers/nntp/camel-nntp-summary.c +++ b/camel/providers/nntp/camel-nntp-summary.c @@ -48,7 +48,7 @@ extern int camel_verbose_debug; #define dd(x) (camel_verbose_debug?(x):0) -#define CAMEL_NNTP_SUMMARY_VERSION (0x200) +#define CAMEL_NNTP_SUMMARY_VERSION (1) static int xover_setup(CamelNNTPSummary *cns, CamelException *ex); static int add_range_xover(CamelNNTPSummary *cns, unsigned int high, unsigned int low, CamelFolderChangeInfo *changes, CamelException *ex); @@ -191,8 +191,25 @@ summary_header_load(CamelFolderSummary *s, FILE *in) { CamelNNTPSummary *cns = CAMEL_NNTP_SUMMARY(s); - if (((CamelFolderSummaryClass *)camel_nntp_summary_parent)->summary_header_load(s, in) == -1 - || camel_file_util_decode_fixed_int32(in, &cns->high) == -1 + if (((CamelFolderSummaryClass *)camel_nntp_summary_parent)->summary_header_load(s, in) == -1) + return -1; + + /* Legacy version */ + if (s->version == 0x20c) { + camel_file_util_decode_fixed_int32(in, &cns->high); + return camel_file_util_decode_fixed_int32(in, &cns->low); + } + + if (camel_file_util_decode_fixed_int32(in, &cns->version) == -1) + return -1; + + if (cns->version > CAMEL_NNTP_SUMMARY_VERSION) { + g_warning("Unknown NNTP summary version"); + errno = EINVAL; + return -1; + } + + if (camel_file_util_decode_fixed_int32(in, &cns->high) == -1 || camel_file_util_decode_fixed_int32(in, &cns->low) == -1) return -1; @@ -205,6 +222,7 @@ summary_header_save(CamelFolderSummary *s, FILE *out) CamelNNTPSummary *cns = CAMEL_NNTP_SUMMARY(s); if (((CamelFolderSummaryClass *)camel_nntp_summary_parent)->summary_header_save(s, out) == -1 + || camel_file_util_encode_fixed_int32(out, CAMEL_NNTP_SUMMARY_VERSION) == -1 || camel_file_util_encode_fixed_int32(out, cns->high) == -1 || camel_file_util_encode_fixed_int32(out, cns->low) == -1) return -1; -- cgit v1.2.3