aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDan Winship <danw@src.gnome.org>2001-09-27 03:28:14 +0800
committerDan Winship <danw@src.gnome.org>2001-09-27 03:28:14 +0800
commit3bf97142fa10290a91deeae010aa08a95b0661d3 (patch)
tree9ff7f1072c079579e1b7e505be33bcc610b07833
parentcca7709e68452fe2eef30f8f068badebea44dfe1 (diff)
downloadgsoc2013-evolution-3bf97142fa10290a91deeae010aa08a95b0661d3.tar.gz
gsoc2013-evolution-3bf97142fa10290a91deeae010aa08a95b0661d3.tar.zst
gsoc2013-evolution-3bf97142fa10290a91deeae010aa08a95b0661d3.zip
Add a big comment explaining unread message counts so no one can mess them
* mail-folder-cache.c: Add a big comment explaining unread message counts so no one can mess them up again in the future. :-) (update_1folder): If info->unread_message_count is -1, don't do anything. * component-factory.c (component_factory_init): warn and exit if oaf_active_server_register returns OAF_REG_ALREADY_ACTIVE. svn path=/trunk/; revision=13155
-rw-r--r--mail/ChangeLog10
-rw-r--r--mail/component-factory.c3
-rw-r--r--mail/mail-folder-cache.c31
3 files changed, 41 insertions, 3 deletions
diff --git a/mail/ChangeLog b/mail/ChangeLog
index e31194af32..df2e021409 100644
--- a/mail/ChangeLog
+++ b/mail/ChangeLog
@@ -1,3 +1,13 @@
+2001-09-26 Dan Winship <danw@ximian.com>
+
+ * mail-folder-cache.c: Add a big comment explaining unread message
+ counts so no one can mess them up again in the future. :-)
+ (update_1folder): If info->unread_message_count is -1, don't do
+ anything.
+
+ * component-factory.c (component_factory_init): warn and exit if
+ oaf_active_server_register returns OAF_REG_ALREADY_ACTIVE.
+
2001-09-26 Jeffrey Stedfast <fejj@ximian.com>
* mail-config.c (config_read): Oops, translate the fake account
diff --git a/mail/component-factory.c b/mail/component-factory.c
index 5019702e3a..4696351613 100644
--- a/mail/component-factory.c
+++ b/mail/component-factory.c
@@ -844,6 +844,9 @@ component_factory_init (void)
e_notice (NULL, GNOME_MESSAGE_BOX_ERROR,
_("Cannot initialize Evolution's mail component."));
exit (1);
+ } else if (result == OAF_REG_ALREADY_ACTIVE) {
+ g_warning ("evolution-mail is already running");
+ exit (1);
}
/* FIXME these don't check for errors. */
diff --git a/mail/mail-folder-cache.c b/mail/mail-folder-cache.c
index b29b1e9fc4..f6db9e6024 100644
--- a/mail/mail-folder-cache.c
+++ b/mail/mail-folder-cache.c
@@ -69,12 +69,35 @@ struct _store_info {
static GHashTable *stores;
+/* This is how unread counts work (and don't work):
+ *
+ * camel_folder_unread_message_count() only gives a correct answer if
+ * the store is paying attention to the folder. (Some stores always
+ * pay attention to all folders, but IMAP can only pay attention to
+ * one folder at a time.) But it doesn't have any way to know when
+ * it's lying, so it's only safe to call it when you know for sure
+ * that the store is paying attention to the folder, such as when it's
+ * just been created, or you get a folder_changed or message_changed
+ * signal on it.
+ *
+ * camel_store_get_folder_info() always gives correct answers for the
+ * folders it checks, but it can also return -1 for a folder, meaning
+ * it didn't check, and so you should stick with your previous answer.
+ *
+ * update_1folder is called from three places: with info == NULL when
+ * the folder is created, with info == NULL when a changed event is
+ * emitted, or with info != NULL when doing a get_folder_info. So if
+ * info is NULL, camel_folder_unread_message_count is correct, and
+ * if it's not NULL and its unread_message_count isn't -1, then it's
+ * correct.
+ */
+
static void
update_1folder(struct _folder_info *mfi, CamelFolderInfo *info)
{
struct _store_info *si;
CamelFolder *folder;
- int unread = 0;
+ int unread = -1;
CORBA_Environment ev;
extern CamelFolder *outbox_folder;
@@ -87,13 +110,15 @@ update_1folder(struct _folder_info *mfi, CamelFolderInfo *info)
unread = camel_folder_get_message_count(folder);
} else {
if (info)
- unread = (info->unread_message_count == -1) ? 0 : info->unread_message_count;
+ unread = info->unread_message_count;
else
unread = camel_folder_get_unread_message_count (folder);
}
} else if (info)
- unread = (info->unread_message_count==-1)?0:info->unread_message_count;
+ unread = info->unread_message_count;
UNLOCK(info_lock);
+ if (unread == -1)
+ return;
if (si->storage == NULL) {
d(printf("Updating existing (local) folder: %s (%d unread) folder=%p\n", mfi->path, unread, folder));