From ce49a43a527ee533a9c697b36760d8bfa481e0aa Mon Sep 17 00:00:00 2001 From: Jeffrey Stedfast Date: Sat, 9 Sep 2000 19:33:36 +0000 Subject: Use the CamelUIDCache so that we only retrieve *new* messages and also 2000-09-09 Jeffrey Stedfast * mail-ops.c (do_fetch_mail): Use the CamelUIDCache so that we only retrieve *new* messages and also send notes to the status bar telling it which message we're downloading so that Ettore can sleep at night ;-) svn path=/trunk/; revision=5290 --- mail/ChangeLog | 7 +++++++ mail/mail-ops.c | 28 +++++++++++++++++++++++++++- 2 files changed, 34 insertions(+), 1 deletion(-) (limited to 'mail') diff --git a/mail/ChangeLog b/mail/ChangeLog index d932e9bd33..8acbdb1d88 100644 --- a/mail/ChangeLog +++ b/mail/ChangeLog @@ -1,3 +1,10 @@ +2000-09-09 Jeffrey Stedfast + + * mail-ops.c (do_fetch_mail): Use the CamelUIDCache so that we + only retrieve *new* messages and also send notes to the status bar + telling it which message we're downloading so that Ettore can + sleep at night ;-) + 2000-09-09 Jeffrey Stedfast * mail-ops.c (do_fetch_mail): Updated to not send hook/unhook data diff --git a/mail/mail-ops.c b/mail/mail-ops.c index 271fc578bb..a0b4b00437 100644 --- a/mail/mail-ops.c +++ b/mail/mail-ops.c @@ -26,6 +26,7 @@ #include #include +#include #include "mail.h" #include "mail-threads.h" #include "mail-tools.h" @@ -138,11 +139,13 @@ do_fetch_mail (gpointer in_data, gpointer op_data, CamelException *ex) if (camel_folder_get_message_count (folder) == 0) { data->empty = TRUE; } else { + CamelUIDCache *cache; gchar *userrules; gchar *systemrules; FilterContext *fc; FilterDriver *filter; - GPtrArray *uids; + GPtrArray *uids, *new_uids; + char *url, *p, *filename; int i; userrules = g_strdup_printf ("%s/filters.xml", evolution_dir); @@ -161,11 +164,34 @@ do_fetch_mail (gpointer in_data, gpointer op_data, CamelException *ex) camel_folder_freeze (input->destination); uids = camel_folder_get_uids (folder); + + /* get the mail source's uid cache file */ + url = camel_url_to_string (CAMEL_SERVICE (folder->parent_store)->url, FALSE); + for (p = url; *p; p++) { + if (!isascii ((unsigned char)*p) || strchr (" /'\"`&();|<>${}!", *p)) + *p = '_'; + } + + filename = g_strdup_printf ("%s/config/cache-%s", evolution_dir, url); + g_free (url); + + cache = camel_uid_cache_new (filename); + + if (cache) { + /* determine the new uids */ + new_uids = camel_uid_cache_get_new_uids (cache, uids); + camel_folder_free_uids (folder, uids); + uids = new_uids; + } + + /* get/filter the new messages */ for (i = 0; i < uids->len; i++) { CamelMimeMessage *message; CamelMessageInfo *info; gboolean free_info; + mail_op_set_message ("Retrieving message %d of %d", i + 1, uids->len); + message = camel_folder_get_message (folder, uids->pdata[i], ex); if (camel_exception_is_set (ex)) continue; -- cgit v1.2.3