diff options
author | Michael Zucci <zucchi@src.gnome.org> | 2001-09-21 11:05:03 +0800 |
---|---|---|
committer | Michael Zucci <zucchi@src.gnome.org> | 2001-09-21 11:05:03 +0800 |
commit | 7d17dc2230c4a3b650849ad6e2dcdc5ebf6cb47e (patch) | |
tree | 233272ab1dd5d9923f4d2e57d9a0e594fe10efff | |
parent | f21fc37e3c2025f2a6b4ed3a24123d2a7fd5eed4 (diff) | |
download | gsoc2013-evolution-7d17dc2230c4a3b650849ad6e2dcdc5ebf6cb47e.tar gsoc2013-evolution-7d17dc2230c4a3b650849ad6e2dcdc5ebf6cb47e.tar.gz gsoc2013-evolution-7d17dc2230c4a3b650849ad6e2dcdc5ebf6cb47e.tar.bz2 gsoc2013-evolution-7d17dc2230c4a3b650849ad6e2dcdc5ebf6cb47e.tar.lz gsoc2013-evolution-7d17dc2230c4a3b650849ad6e2dcdc5ebf6cb47e.tar.xz gsoc2013-evolution-7d17dc2230c4a3b650849ad6e2dcdc5ebf6cb47e.tar.zst gsoc2013-evolution-7d17dc2230c4a3b650849ad6e2dcdc5ebf6cb47e.zip |
New function to just load the summary. Not much use yet, until unread
* camel-folder-summary.c (camel_folder_summary_header_load): New
function to just load the summary. Not much use yet, until unread
counts are stored in the summary (which now looks like too much
work!).
* camel-mime-utils.c (header_decode_mailbox): Crappy fix for
stupid mailers. If we get 'name b. name <foo>' then treat it as
'"name b. name" <foo>'. See 8147.
(header_decode_mailbox): Another fix for really broken mailers
that have things that look like addresses followed by <address>
bits.
(rfc2047_encode_word): Escape ??= to avoid some bizarre warning
about trigraphs.
(scan_dir): If we dont have the folder open, then scan the 'new'
and 'cur' folders for new and unread messages to count instead.
svn path=/trunk/; revision=13040
-rw-r--r-- | camel/ChangeLog | 16 | ||||
-rw-r--r-- | camel/camel-folder-summary.c | 30 | ||||
-rw-r--r-- | camel/camel-folder-summary.h | 3 | ||||
-rw-r--r-- | camel/camel-mime-utils.c | 19 | ||||
-rw-r--r-- | camel/providers/local/camel-maildir-store.c | 29 |
5 files changed, 96 insertions, 1 deletions
diff --git a/camel/ChangeLog b/camel/ChangeLog index 5d8203658b..c624a6fc90 100644 --- a/camel/ChangeLog +++ b/camel/ChangeLog @@ -1,5 +1,19 @@ 2001-09-20 <NotZed@Ximian.com> + * camel-folder-summary.c (camel_folder_summary_header_load): New + function to just load the summary. Not much use yet, until unread + counts are stored in the summary (which now looks like too much + work!). + + * camel-mime-utils.c (header_decode_mailbox): Crappy fix for + stupid mailers. If we get 'name b. name <foo>' then treat it as + '"name b. name" <foo>'. See 8147. + (header_decode_mailbox): Another fix for really broken mailers + that have things that look like addresses followed by <address> + bits. + (rfc2047_encode_word): Escape ??= to avoid some bizarre warning + about trigraphs. + * providers/local/camel-local-folder.c (camel_local_folder_construct): Setup unread count properly, and also setup the url properly. @@ -9,6 +23,8 @@ (scan_dir): Dont include empty host part in url for folder. (scan_dir): Lookup folder counts for any folders we currenty have open. + (scan_dir): If we dont have the folder open, then scan the 'new' + and 'cur' folders for new and unread messages to count instead. * 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-folder-summary.c b/camel/camel-folder-summary.c index ac525dd619..f5f2131fa2 100644 --- a/camel/camel-folder-summary.c +++ b/camel/camel-folder-summary.c @@ -658,6 +658,36 @@ camel_folder_summary_save(CamelFolderSummary *s) return 0; } +/** + * camel_folder_summary_header_load: + * @s: Summary object. + * + * Only load the header information from the summary, + * keep the rest on disk. This should only be done on + * a fresh summary object. + * + * Return value: -1 on error. + **/ +int camel_folder_summary_header_load(CamelFolderSummary *s) +{ + FILE *in; + int ret; + + g_assert(s->summary_path); + + in = fopen(s->summary_path, "r"); + if (in == NULL) + return -1; + + CAMEL_SUMMARY_LOCK(s, io_lock); + ret = ((CamelFolderSummaryClass *)(CAMEL_OBJECT_GET_CLASS(s)))->summary_header_load(s, in); + CAMEL_SUMMARY_UNLOCK(s, io_lock); + + fclose(in); + s->flags &= ~CAMEL_SUMMARY_DIRTY; + return ret; +} + static void summary_assign_uid(CamelFolderSummary *s, CamelMessageInfo *info) { diff --git a/camel/camel-folder-summary.h b/camel/camel-folder-summary.h index 5fc675b5fd..fddba046b2 100644 --- a/camel/camel-folder-summary.h +++ b/camel/camel-folder-summary.h @@ -219,6 +219,9 @@ void camel_folder_summary_set_uid (CamelFolderSummary *s, guint32 uid); int camel_folder_summary_load(CamelFolderSummary *); int camel_folder_summary_save(CamelFolderSummary *); +/* only load the header */ +int camel_folder_summary_header_load(CamelFolderSummary *); + /* set the dirty bit on the summary */ void camel_folder_summary_touch(CamelFolderSummary *s); diff --git a/camel/camel-mime-utils.c b/camel/camel-mime-utils.c index 6bbf21cd5f..e1f483023d 100644 --- a/camel/camel-mime-utils.c +++ b/camel/camel-mime-utils.c @@ -1194,7 +1194,7 @@ rfc2047_encode_word(GString *outstring, const char *in, int len, const char *typ proclen = 0; p = inptr; i = 0; - while (p < (in+len) && convlen < (75 - strlen("=?utf-8?q??="))) { + while (p < (in+len) && convlen < (75 - strlen("=?utf-8?q\?\?="))) { unsigned char c = *p++; if (c >= 0xc0) @@ -2313,12 +2313,21 @@ header_decode_mailbox(const char **in) } else { name = g_string_append_c(name, ' '); } + } else { + /* Fix for stupidly-broken-mailers that like to put '.''s in names unquoted */ + /* see bug #8147 */ + if (*inptr && *inptr != '<') { + g_warning("Working around stupid mailer bug #5: unescaped characters in names"); + name = g_string_append_c(name, *inptr++); + pre = header_decode_word(&inptr); + } } g_free(last); } header_decode_lwsp(&inptr); if (*inptr == '<') { closeme = TRUE; + try_address_again: inptr++; header_decode_lwsp(&inptr); if (*inptr == '@') { @@ -2375,6 +2384,14 @@ header_decode_mailbox(const char **in) addr = g_string_append(addr, dom); g_free(dom); } else { + /* If we get a <, the address was probably a name part, lets try again shall we? */ + /* Another fix for seriously-broken-mailers */ + if (name == NULL && *inptr == '<') { + name = addr; + addr = g_string_new(""); + closeme = TRUE; + goto try_address_again; + } w(g_warning("invalid address, no '@' domain part at %c: %s", *inptr, *in)); } diff --git a/camel/providers/local/camel-maildir-store.c b/camel/providers/local/camel-maildir-store.c index b0d4c072f8..d6392b5ac2 100644 --- a/camel/providers/local/camel-maildir-store.c +++ b/camel/providers/local/camel-maildir-store.c @@ -279,6 +279,33 @@ static int scan_dir(CamelStore *store, GHashTable *visited, char *root, const ch else unread = 0; CAMEL_STORE_UNLOCK(store, cache_lock); + + /* if we dont have a folder, then scan the directory and get the unread + count from there, which is reasonably cheap (on decent filesystem) */ + /* Well we could get this from the summary, but this is more accurate */ + if (folder == NULL) { + unread = 0; + dir = opendir(new); + if (dir) { + /* we assume that all files here are unread ones */ + while ( (d = readdir(dir)) ) { + if (d->d_name[0] != '.') + unread++; + } + closedir(dir); + } + dir = opendir(cur); + if (dir) { + /* any files with flags but not the 'S' (seen) flag are unread */ + while ( (d = readdir(dir)) ) { + char *p = strstr(d->d_name, ":2,"); + + if (p && strchr(p, 'S') == NULL) + unread++; + } + closedir(dir); + } + } fi = camel_folder_info_new(uri, path, base, unread); @@ -294,6 +321,8 @@ 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)) { dir = opendir(name); |