After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 336074 - Check for mail only in active folders.
Check for mail only in active folders.
Status: RESOLVED FIXED
Product: evolution
Classification: Applications
Component: Mailer
2.6.x (obsolete)
Other All
: Normal enhancement
: Future
Assigned To: evolution-mail-maintainers
Evolution QA team
: 481247 (view as bug list)
Depends on:
Blocks:
 
 
Reported: 2006-03-26 13:05 UTC by David Woodhouse
Modified: 2010-01-20 17:56 UTC
See Also:
GNOME target: ---
GNOME version: Unversioned Enhancement


Attachments
e-d-s patch (4.03 KB, patch)
2006-03-26 13:06 UTC, David Woodhouse
rejected Details | Review
evo patch (757 bytes, patch)
2006-03-26 13:06 UTC, David Woodhouse
rejected Details | Review
Older patch for e-d-s 1.2, for reference. (6.32 KB, patch)
2006-03-26 13:08 UTC, David Woodhouse
none Details | Review
proposed eds patch (15.47 KB, patch)
2007-11-08 12:41 UTC, Milan Crha
none Details | Review
proposed evo patch (1.83 KB, patch)
2007-11-08 12:43 UTC, Milan Crha
none Details | Review
proposed eex patch (7.29 KB, patch)
2007-11-08 12:47 UTC, Milan Crha
none Details | Review
proposed eds patch ][ (15.09 KB, patch)
2007-12-10 18:36 UTC, Milan Crha
committed Details | Review
proposed evo patch ][ (1.85 KB, patch)
2007-12-10 18:49 UTC, Milan Crha
committed Details | Review
proposed eex patch ][ (7.17 KB, patch)
2007-12-10 19:01 UTC, Milan Crha
committed Details | Review
proposed eds patch (4.84 KB, patch)
2008-07-01 17:26 UTC, Milan Crha
committed Details | Review

Description David Woodhouse 2006-03-26 13:05:39 UTC
Evolution allows us to check for mail in _all_ folders, or only in the inbox.

Because of the amount of time it takes to check all folders in a large IMAP
store, it would be much more useful if Evolution were capable of checking mail
only in _active_ folders. It doesn't need to repeatedly check the last few years
of archived mail to see if anything new has been delivered -- we _know_ it will
find nothing interesting there.

In IMAP, the meaning if 'subscribed' folders is ambiguous. It means only
'active' according to the IMAP RFC. 

Some people use subscription to mark the folders which should be displayed, but
that doesn't make sense when you use a dedicated IMAP server/store instead of
wu-imapd just exporting the whole home directory.

I use subscription status to mark 'active' folders, where 'active' means that
mail gets delivered to them and the MUA should check for new mail there. My
inbox and mailing list folders are 'active', while last year's archives are not.

I find it extremely useful for Evolution to be able to check for mail only in
these active folders, because it's fairly much unusable unless I do that -- it
takes far too long doing the 'background' check for new mail when starting up,
especially on GPRS.

Ideally we'd have an option in the mail config which goes:

 Check for mail: { No folders / INBOX only / Subscribed folders / All folders }

The camel config stuff doesn't allow that though, so I've implemented it here as
another boolean.
Comment 1 David Woodhouse 2006-03-26 13:06:15 UTC
Created attachment 62033 [details] [review]
e-d-s patch
Comment 2 David Woodhouse 2006-03-26 13:06:52 UTC
Created attachment 62034 [details] [review]
evo patch
Comment 3 David Woodhouse 2006-03-26 13:08:35 UTC
Created attachment 62035 [details] [review]
Older patch for e-d-s 1.2, for reference.

In e-d-s 1.2 it was different, and didn't need any changes in Evolution itself. The code for checking folders seems to have got messier since then.
Comment 4 Jeffrey Stedfast 2006-05-09 19:31:47 UTC
this is not the way to do it. this patch sucks.
Comment 5 Jesse Keating 2006-05-09 19:34:49 UTC
*sigh* If the patch sucks, help to come up with a new one, don't just close it as WONTFIX.  This is a valid problem not to be confused with what you may think is an invalid fix.
Comment 6 Jeffrey Stedfast 2006-05-10 14:20:20 UTC
1. the patch would break current user setups as it changes the meaning of the use_lsub URI property.

2. the way this should be done is to have a folder property (accessable via File->Folder Properties or via right-click on folder) specifying whether or not the folder should be checked for new mail.

None of this hack-job stuff.
Comment 7 Milan Crha 2007-11-08 12:38:09 UTC
Hi Jeff, what do you think about this?
My patches below are partially based on your above comment, partially on a hint from mail-send-recv.c (see evo's patch), partially on patches above and with help from pvanhoof, which pointed me to right direction when I observed one issue with this (and after chat with him I realized that it is not an issue at all).

The patches below add new property for imap and exchange folders, "Always check for new mail in this folder" which is accessible via Folder->Properties, or in popup over such folder. When user doesn't have checked "Check for new messages in all folders", then it will determine if check or not check in a folder based on this new property.

The pity thing about this patch is that I did what was as a TODO in mail-send-recv.c, even not completely as was suggested there. I added new virtual function to the CamelStore, named camel_store_can_refresh_folder, which, by default, permit refresh of all Inbox folders. Each provider/store should determine if this is sufficient for him or not. For imap and exchange it is not sufficient.

Because I changed the size of CamelStore structure, then everything subclassing this structure (or any descendant) should be recompiled against new camel, otherwise one can see a warning like this on console:
(evolution:2596): camel-WARNING **: camel_type_register: 'CamelExchangeStore' has smaller class size than parent 'CamelOfflineStore'.
Comment 8 Milan Crha 2007-11-08 12:41:34 UTC
Created attachment 98764 [details] [review]
proposed eds patch

for evolution-data-server;
Comment 9 Milan Crha 2007-11-08 12:43:47 UTC
Created attachment 98765 [details] [review]
proposed evo patch

for evolution;
Comment 10 Milan Crha 2007-11-08 12:47:14 UTC
Created attachment 98766 [details] [review]
proposed eex patch

for evolution-exchange;
Comment 11 Srinivasa Ragavan 2007-11-22 17:59:01 UTC
Fejj, you got some time to review this?
Comment 12 Srinivasa Ragavan 2007-12-03 16:54:50 UTC
Sankar/Matt, I think this needs to be pushed asap to trunk. Can one of you review/approve this?
Comment 13 Jeffrey Stedfast 2007-12-10 17:50:32 UTC
a couple of comments for the e-d-s patch (I'll review each patch in a new comment so I don't have to worry about ff crashing and losing all my comments):

+static gboolean
+can_refresh_folder (CamelStore *store, CamelFolderInfo *info, CamelException *ex)
+{
+	g_return_val_if_fail (store != NULL, FALSE);
+	g_return_val_if_fail (info != NULL, FALSE);
+

those g_return checks are not needed there as they are checked in the public API (camel_store_can_refresh_folder)

+static gboolean
+imap_can_refresh_folder (CamelStore *store, CamelFolderInfo *info, CamelException *ex)
+{
+	gboolean res;
+
+	g_return_val_if_fail (store != NULL, FALSE);
+	g_return_val_if_fail (info != NULL, FALSE);

these checks aren't needed either, for the same reason.

+	if (!res && CAMEL_EXCEPTION_NONE == camel_exception_get_id (ex)) {

evolution style would be:

if (!res && !camel_exception_is_set (ex))

fwiw, evolution style prefers that the variable is on the left and the value on the right, e.g: camel_exception_get_id (ex) == CAMEL_EXCEPTION_NONE

+			res = CAMEL_IMAP_FOLDER (folder)->check_folder != 0;

That could be simplified to:

res = CAMEL_IMAP_FOLDER (folder)->check_folder;

Comment 14 Jeffrey Stedfast 2007-12-10 18:08:12 UTC
evolution patch review:

static void
get_folders (CamelStore *store, GPtrArray *folders, CamelFolderInfo *info)
{
	while (info) {
		CamelException ex;

		camel_exception_init (&ex);
		if (camel_store_can_refresh_folder (store, info, &ex))
			g_ptr_array_add (folders, g_strdup (info->uri));
		camel_exception_clear (&ex);

		get_folders (store, folders, info->child);
		info = info->next;
	}
}


I think this could be better such that you don't re-init CamelException more than you need to:

static void
get_folders (CamelStore *store, GPtrArray *folders, CamelFolderInfo *info)
{
	CamelException ex;
	
	camel_exception_init (&ex);
	
	while (info) {
		if (camel_store_can_refresh_folder (store, info, &ex))
			g_ptr_array_add (folders, g_strdup (info->uri));
		camel_exception_clear (&ex);

		get_folders (store, folders, info->child);
		info = info->next;
	}
}



camel_store_can_refresh_folder() has to instantiate a CamelFolder object for at least all IMAP folders (granted, it's shortcutted for local folders and nntp folders), so I wonder:

Would it be better to make this code work more like this?:

static void
get_folders (CamelStore *store, GPtrArray *folders, CamelFolderInfo *info)
{
	CamelException ex;
	
	camel_exception_init (&ex);
	
	while (info) {
		if ((folder = camel_store_get_folder (store, ..., &ex)) &&
		    camel_folder_should_refresh (folder))
			g_ptr_array_add (folders, folder);
		camel_exception_clear (&ex);

		get_folders (store, folders, info->child);
		info = info->next;
	}
}


The reason I wonder, is because camel_store_get_folder() could be an expensive operation, especially for IMAP. The problem with doing it my way, however, is that we definitely incur more overhead for local folders (as well as nntp, and nntp are probably no less expensive than IMAP and if there are a lot of them, this could be bad?).

Anyways... I don't really know the performance implications of either approach, just thoughts.

That said, I'm happy with Milan's current approach for now. I think that my approach would be better if/when Camel changes to support CamelFolder::open()/::close() functionality such that camel_store_get_folder() becomes really cheap, but until then - it might just be that Milan's approach would have less overall overhead.
Comment 15 Jeffrey Stedfast 2007-12-10 18:10:49 UTC
evolution-exchange patch review:

same comments as for the e-d-s patch



That said, once Milan makes the cosmetic changes I suggested, I think it's ok to commit (barring any objections from the current mail maintainers, of course).
Comment 16 Srinivasa Ragavan 2007-12-10 18:11:31 UTC
Thanks a lot for your review and thoughts Fejj.
Comment 17 Jeffrey Stedfast 2007-12-10 18:13:09 UTC
David: have you tried these patches? Do they solve your problem? How about my performance concerns - are they actually a problem?
Comment 18 Milan Crha 2007-12-10 18:36:10 UTC
Created attachment 100705 [details] [review]
proposed eds patch ][

for evolution-data-server;

From my point of view, double check is better than no check. But as you wish.
The check_folder != 0, I thought about different type sizes, it was the only reason why used here in this way.
Comment 19 Milan Crha 2007-12-10 18:49:27 UTC
Created attachment 100706 [details] [review]
proposed evo patch ][

for evolution;

I do not see there any difference between your and mine solution (the folders and performance you mentioned), because the folder has been instantiated before and here we got one from cache, so no big performance overhead, I guess (I tested on IMAP, actually, and I didn't notice any difference).
Comment 20 Milan Crha 2007-12-10 19:01:48 UTC
Created attachment 100708 [details] [review]
proposed eex patch ][

for evolution-exchange;
Comment 21 Jeffrey Stedfast 2007-12-10 19:04:43 UTC
> I do not see there any difference between your and mine solution (the folders
> and performance you mentioned), because the folder has been instantiated before
> and here we got one from cache, so no big performance overhead,

If that's the case, then it's not a problem which is good :)
Comment 22 Srinivasa Ragavan 2007-12-11 06:49:55 UTC
Thanks Fejj. Milan please commit.
Comment 23 Milan Crha 2007-12-11 08:49:15 UTC
eds part committed to trunk. Committed revision 8288.
evo part committed to trunk. Committed revision 34688.
eex part committed to trunk. Committed revision 1517.
Comment 24 David Woodhouse 2008-03-06 00:13:41 UTC
Sorry, I've only just got round to installing the latest Evolution and testing. 

How do I make it do the right thing, checking for mail only in the folders which are marked as 'active' on the IMAP server? The only thing I've worked out how to do is manually go through each folder with the mouse. On each computer from which I use Evolution. That's obviously not a viable solution.
Comment 25 Milan Crha 2008-03-06 09:16:04 UTC
I guess you've turned off "Check in all folders" in your account preferences, which is right. Now right click on the folder and choose in Properties "Always check for new mail in this folder". It works only for remote folders.
Comment 26 David Woodhouse 2008-03-06 10:01:11 UTC
OK, thanks. This is useful progress but still not as useful as what I had before. Keeping the list in sync manually, with the mouse, on all instances of Evolution, isn't really what I had in mind. It's much easier to simply mark the folders as 'active' on the server and for that status to be interpreted by Evolution as 'should be checked for new mail'.
Comment 27 Milan Crha 2008-07-01 16:50:12 UTC
OK, reopening because of the discussion with David. As he reminded me, we have "Show only subscribed folders" option, thus in case this is unchecked, we can use the subscribed flag to distinguish whether update the folder or not.

There will be new option in "Receiving Options" tab "Check for new messages in subscribed folders only" and will be enabled only if not checked "in all folders" and not checked "Show only subscribed folders". The new option will be shown only when both options are shown (thus not in exchange, for example).
Comment 28 Milan Crha 2008-07-01 17:26:20 UTC
Created attachment 113793 [details] [review]
proposed eds patch

for evolution-data-server;

Hmm, this is available for IMAP only, and there is no way to have there such nice enabling of items as I describe in previous comment, so you can check them all or none or any as you wish. Can be confusing a bit, but not so much I guess.
Comment 29 Srinivasa Ragavan 2008-07-27 18:49:53 UTC
Seems fine to me. Announce string/ui change.
Comment 30 Milan Crha 2008-07-28 07:11:34 UTC
Committed to trunk. Committed revision 9202.
Comment 31 Milan Crha 2008-11-14 12:37:36 UTC
As I was told by abharath, changes here make evo startup awfully slow for new accounts (no local cache) when the account has unchecked "check for new message in all folders". It's very visible with eex.
Comment 32 Milan Crha 2008-11-18 13:40:25 UTC
To not reopen this one, I'll try to fix it in bug #558883
Comment 33 Milan Crha 2010-01-20 17:56:22 UTC
*** Bug 481247 has been marked as a duplicate of this bug. ***