aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMilan Crha <mcrha@redhat.com>2010-06-15 02:15:55 +0800
committerMilan Crha <mcrha@redhat.com>2010-06-15 02:15:55 +0800
commitead63f16b2269325c1e4080b3dce8818bbafe189 (patch)
treed6d68efa2eb378311d6e57f4936e1399dd21d418
parent3f34eeab520965a14afbeb678b8f186c7a63e616 (diff)
downloadgsoc2013-evolution-ead63f16b2269325c1e4080b3dce8818bbafe189.tar
gsoc2013-evolution-ead63f16b2269325c1e4080b3dce8818bbafe189.tar.gz
gsoc2013-evolution-ead63f16b2269325c1e4080b3dce8818bbafe189.tar.bz2
gsoc2013-evolution-ead63f16b2269325c1e4080b3dce8818bbafe189.tar.lz
gsoc2013-evolution-ead63f16b2269325c1e4080b3dce8818bbafe189.tar.xz
gsoc2013-evolution-ead63f16b2269325c1e4080b3dce8818bbafe189.tar.zst
gsoc2013-evolution-ead63f16b2269325c1e4080b3dce8818bbafe189.zip
Bug #534369 - [new-mail-notify] Intermittent notifications
-rw-r--r--mail/e-mail-backend.c2
-rw-r--r--mail/mail-folder-cache.c16
2 files changed, 13 insertions, 5 deletions
diff --git a/mail/e-mail-backend.c b/mail/e-mail-backend.c
index a0453a963d..b2e22e397d 100644
--- a/mail/e-mail-backend.c
+++ b/mail/e-mail-backend.c
@@ -335,7 +335,7 @@ mail_backend_folder_changed_cb (MailFolderCache *folder_cache,
gint folder_type;
gint flags = 0;
- if (!mail_folder_cache_get_folder_from_uri (folder_cache, folder_uri, &folder))
+ if (mail_folder_cache_get_folder_from_uri (folder_cache, folder_uri, &folder))
if (folder && !mail_folder_cache_get_folder_info_flags (folder_cache, folder, &flags))
g_return_if_reached ();
diff --git a/mail/mail-folder-cache.c b/mail/mail-folder-cache.c
index a9726ea0db..094a046c38 100644
--- a/mail/mail-folder-cache.c
+++ b/mail/mail-folder-cache.c
@@ -301,7 +301,8 @@ folder_changed_cb (CamelFolder *folder,
CamelFolderChangeInfo *changes,
MailFolderCache *self)
{
- static time_t last_newmail = 0;
+ static GHashTable *last_newmail_per_folder = NULL;
+ time_t latest_received;
CamelFolder *local_drafts;
CamelFolder *local_outbox;
CamelFolder *local_sent;
@@ -318,6 +319,12 @@ folder_changed_cb (CamelFolder *folder,
full_name = camel_folder_get_full_name (folder);
parent_store = camel_folder_get_parent_store (folder);
+ if (!last_newmail_per_folder)
+ last_newmail_per_folder = g_hash_table_new (g_direct_hash, g_direct_equal);
+
+ /* it's fine to hash them by folder pointer here */
+ latest_received = GPOINTER_TO_INT (g_hash_table_lookup (last_newmail_per_folder, folder));
+
local_drafts = e_mail_local_get_folder (E_MAIL_FOLDER_DRAFTS);
local_outbox = e_mail_local_get_folder (E_MAIL_FOLDER_OUTBOX);
local_sent = e_mail_local_get_folder (E_MAIL_FOLDER_SENT);
@@ -336,7 +343,8 @@ folder_changed_cb (CamelFolder *folder,
if (((flags & CAMEL_MESSAGE_SEEN) == 0) &&
((flags & CAMEL_MESSAGE_JUNK) == 0) &&
((flags & CAMEL_MESSAGE_DELETED) == 0) &&
- (camel_message_info_date_received (info) > last_newmail)) {
+ (camel_message_info_date_received (info) > latest_received)) {
+ latest_received = camel_message_info_date_received (info);
new++;
if (new == 1) {
uid = g_strdup (camel_message_info_uid (info));
@@ -357,8 +365,8 @@ folder_changed_cb (CamelFolder *folder,
}
}
- if (new > 0 || !last_newmail)
- time (&last_newmail);
+ if (new > 0)
+ g_hash_table_insert (last_newmail_per_folder, folder, GINT_TO_POINTER (latest_received));
g_mutex_lock (self->priv->stores_mutex);
if (self->priv->stores != NULL