Last Comment Bug 451995 - implement archive method for auto-saving mail
: implement archive method for auto-saving mail
Status: RESOLVED FIXED
:
Product: Thunderbird
Classification: Client Software
Component: Mail Window Front End (show other bugs)
: Trunk
: All All
: -- enhancement (vote)
: Thunderbird 3.0b2
Assigned To: David :Bienvenu
:
:
Mentors:
https://wiki.mozilla.org/Thunderbird:...
Depends on: 470269 473439 474848
Blocks: TB2SM msgreadertracker
  Show dependency treegraph
 
Reported: 2008-08-24 14:40 PDT by Bryan Clark (DevTools PM) [:clarkbw]
Modified: 2009-07-12 01:31 PDT (History)
20 users (show)
mozilla: blocking‑thunderbird3-
See Also:
Crash Signature:
(edit)
QA Whiteboard:
Iteration: ---
Points: ---


Attachments
Account-Settings-Copies-Folders.png (94.42 KB, image/png)
2008-11-11 12:18 PST, Bryan Clark (DevTools PM) [:clarkbw]
no flags Details
WIP-ao.patch (21.69 KB, patch)
2008-11-11 12:22 PST, Bryan Clark (DevTools PM) [:clarkbw]
no flags Details | Diff | Splinter Review
WIP patch for archiving behavior itself (13.02 KB, patch)
2008-11-18 23:06 PST, David Ascher (:davida)
no flags Details | Diff | Splinter Review
wip (57.46 KB, patch)
2008-12-17 20:23 PST, David :Bienvenu
no flags Details | Diff | Splinter Review
add archives folder flag, archives folder property to identity, and localized Archives folder name (11.77 KB, patch)
2008-12-30 14:57 PST, David :Bienvenu
no flags Details | Diff | Splinter Review
snapshotting current work (55.91 KB, patch)
2009-01-01 15:01 PST, David :Bienvenu
no flags Details | Diff | Splinter Review
use GetDefaultCopiesAndFoldersPrefsToServer (11.80 KB, patch)
2009-01-02 13:37 PST, David :Bienvenu
standard8: review-
neil: superreview+
Details | Diff | Splinter Review
add prefs ui to pick an archive folder. (10.47 KB, patch)
2009-01-06 15:37 PST, David :Bienvenu
standard8: review-
neil: superreview+
Details | Diff | Splinter Review
TB front end archive work (13.50 KB, patch)
2009-01-06 16:00 PST, David :Bienvenu
standard8: review-
Details | Diff | Splinter Review
cumulative fix (37.15 KB, patch)
2009-01-08 09:58 PST, David :Bienvenu
standard8: review+
Details | Diff | Splinter Review
configure new archive folders for offline download (647 bytes, patch)
2009-01-10 11:53 PST, David :Bienvenu
standard8: review+
standard8: superreview+
Details | Diff | Splinter Review

Description Bryan Clark (DevTools PM) [:clarkbw] 2008-08-24 14:40:00 PDT
In mockups related to bug 449691 ( improved message reader ) we have been using an Archive button for "processing" or moving messages from the Inbox to an archive folder.  To make this action a reality we need the backend bits implemented.

I've included the wiki page with the Archive designs.
https://wiki.mozilla.org/Thunderbird:Message_Archive

Initial implementation should 
* Have a default Archive folder selected on the remote system
* create the Archive folder upon the first use of the Archive button.
* Provide at least a status bar message notification of the message move

I think our first use, where the folder is created, might require an extra explanation to the user of what is happening vs. routine usage of the archive button.  I'm not sure what the best method for notification of the first usage should be, however it is probably the optimum time to do something.
Comment 1 Magnus Melin 2008-09-03 09:37:57 PDT
xref bug 93094.
Comment 2 Wayne Mery (:wsmwk, NI for questions) 2008-09-16 11:39:44 PDT
In my own usage, a more typical scenario to archive mail from an arbitrary folder which is the target of a filter, i.e. not from inbox folder, and I wouldn't want that mail to archive where inbox gets archived.
Comment 3 Bryan Clark (DevTools PM) [:clarkbw] 2008-09-16 20:26:22 PDT
I think initial versions of the Archive will likely just be simple moving mail from the Inbox to an Archive folder.  Once we've settled the user experience issues that come along with the simple end we can add in filtering / scripting to the archive button such that it becomes more of a "process mail" button than just archive.  This should work well for people who want to archive from any folder or archive mail into mail specific folders.

And it looks like we should have someone lined up to work on this very soon, hopefully he'll make a comment or two about his approach.
Comment 4 Bartosz Barcicki 2008-09-18 15:48:20 PDT
I am interested in working on this project. Initially I plan on doing what Bryan suggested with the simple moving of the mail and add more complexity in future iterations.
Comment 5 ovidiu 2008-09-18 19:50:06 PDT
Consider the people that are using a strong folder structure under inbox or such. Out of view doesn't mean out of structure ..  

Archive should remember that in order to be useful to them or they'll not use it. Either by reproducing the folder structure under it or by having some metadata/tag, which may lead to same thing.. I do not use that much so I cannot give clear scenario and wish, but you know many people use that.

[Or this idea may just be the opposite of the archive concept you propose ..]
Comment 6 Bryan Clark (DevTools PM) [:clarkbw] 2008-09-18 19:59:48 PDT
An idea I had discussed a week ago or so was that by using Gloda we can know where the rest of a conversation exists even though it's buried in folders.  So if a person files one message in a certain folder we can implement the archive in such a way that it places the next message in that conversation in the same folder.  Could possibly solve this problem.

We'll have to figure out a way to inform the user of where the message will go when they archive it.  Some suggestions were something like this:

    ( Archive )
     /to Inbox->Biz->Mozilla/

Essentially providing some subtle text about where the Archive action will send your message.  Of course the initial version of Archive will have to stick to simply moving any message to a single folder.  Once the simple implementation is done we can move toward advanced setups.
Comment 7 Bryan Clark (DevTools PM) [:clarkbw] 2008-10-30 19:39:38 PDT
- updating platform flag -

Bartosz: any progress so far?  Feel free to email me with questions
Comment 8 Bryan Clark (DevTools PM) [:clarkbw] 2008-11-11 12:18:32 PST
Created attachment 347601 [details]
Account-Settings-Copies-Folders.png

Here's a screenshot of my initial WIP patch that should be coming
Comment 9 Bryan Clark (DevTools PM) [:clarkbw] 2008-11-11 12:22:55 PST
Created attachment 347602 [details] [diff] [review]
WIP-ao.patch

Here's the patch.  This adds initial support for the Archives folder Account Settings option.

Things that are left to do:
* Rename the msg flag from Unused3 to Archives (easy)
* Continue changing the msgDBFolder to follow the code paths for "drafts" (difficult)
Comment 10 Magnus Melin 2008-11-12 11:13:07 PST
Shouldn't that be "Archive" without the s?
Comment 11 Bryan Clark (DevTools PM) [:clarkbw] 2008-11-12 16:29:33 PST
> Shouldn't that be "Archive" without the s?

Ah, yes that should drop the trailing 's'.  good catch!
Comment 12 David Ascher (:davida) 2008-11-18 22:33:21 PST
To clarify the last comment after OOB chat w/ bryan: the flag name should be Archive, but the parent folder is supposed to be Archives.
Comment 13 David Ascher (:davida) 2008-11-18 23:06:08 PST
Created attachment 348935 [details] [diff] [review]
WIP patch for archiving behavior itself

This WIP adds an Archive menuitem to the Message menu, and an "archive" button to the message reader.  They both work.

This patch ignores bryan's patch, and just puts stuff in a toplevel Archives folder based on the first message.  The two patches should be merged at some point.

A few things to note before I forget:

0) I don't currently do anything on "first archive", but it should be relatively easy to handle that, as long as we know what it is we want to do.  I'd suggest we defer that discussion until the Activity Manager & super status bar has landed.

1) this patch should be tweaked to chunk up patches based on server as well as month, in case the set of selected messages spans servers.

2) this patch doesn't deal well with IMAP servers for which every folder needs to be a child of INBOX unless the IMAP personal namespace is set (bienvenu seemed to think this was a bug that should be handled at a lower level.

3) I deliberately didn't use the "traditional" SetNextMessageAfterDelete() mechanism the "standard" way because that mechanism doesn't deal well with single UI operations that result in several IMAP moves.  Specifically, if multiple messages spanning multiple destination archive folders were selected, then the DBview was telling the front-end to select messages that the next batch was already moving away, resulting in error dialogs.  Also, it was slowing things down a lot.  The approach I used here is to call SetNextMessageAfterDelete() to figure out what message we want, then reset that global (ugh) so that the DBview doesn't result in any selection updates, and then do the selection setting myself at the end of the last copy operation.  That last bit needs to be changed to be done at the end of _all_ copy operations, as I wouldn't be surprised if the last copy operation started isn't necessary the last one to finish.  This makes archiving quite responsive compared to the alternative -- I'd like to know what problems aren't handled, given that I'm deliberately bypassing an existing mechanism which appears horribly tricky.

4) I don't set the Archive bit on newly created Archive folder.  TBD.

5) the structure of the archives folder (figured out with various people in mountain view) is:

  Archives/2008/2008-04

(for april 2008, for example).  The reasons for this were:

  - to not end up with neither too small nor too huge folders, for IMAP health as well as for MSF performance.  Monthly seems a reasonable best guess.
  - to sort well on disk

To note about this directory structure in particular:

 - the plan is to localize the presentation of the archives folder, not its structure on disk.  So it will say April 2008 in en-US, Avril 2008 in fr-FR, etc.

 - the plan is to leverage the JS folder pane to provide archive-specific UI for those folders, particularly suited to the tasks that people do when managing their archives.  

These last two points should likely be the topic of another bug having to do with the UI of the archive folder.

  - we need to figure out a way to properly treat Archive-flagged folders so that they get synced appropriately for IMAP -- we're archiving messages in folders corresponding to the From header of the message, and so it is possible to archive a message that's been sitting in an inbox for months in an "old" folder.  At the same time, we want other Thunderbird installations pointing at the same IMAP server to detect the new messages, but we don't want Thunderbird to auto-sync every archive folder too frequently.
Comment 14 David Ascher (:davida) 2008-11-18 23:09:58 PST
Oh, and I should add that something that I expect to do at some point is to open my 100,000 Archive folder, select all and hit A.  It'd be good to test that before I (or anyone else) does it with real mail. =)
Comment 15 Dan Mosedale (:dmose) 2008-11-19 10:53:56 PST
Does BatchMessageMover want to be its own service or JS module, rather than living directly in the chrome?
Comment 16 David Ascher (:davida) 2008-11-19 11:24:05 PST
(In reply to comment #15)
> Does BatchMessageMover want to be its own service or JS module, rather than
> living directly in the chrome?

Good idea.  One thing that could make sense is to split the stuff that interacts with the view (figuring out selected messages, managing selection when done) from the creation of batch moves.  I'll need to do that anyway when implementing archive on conversations.

In general, I think we need to do a higher level review of the APIs having to do with the view & message handling.  There's way too much tying together of logic with view stuff.
Comment 17 David :Bienvenu 2008-12-10 13:06:09 PST
I'll drive this into the tree, as it were.

One thing Davida pointed out over IRC - we probably want to treat archive in GMail accounts specially - they shouldn't create the per-month archive folders, and should just do whatever gmail does when you archive a message, or the imap equivalent thereof.
Comment 18 Bryan Clark (DevTools PM) [:clarkbw] 2008-12-11 12:39:19 PST
Right, for GMail actually want to delete the message, without moving it to the trash.  This will remove it from the Inbox but the message remains in [GMail]/All Mail.  

See the GMail IMAP actions table for other actions: http://mail.google.com/support/bin/answer.py?answer=77657&ctx=sibling
Comment 19 David :Bienvenu 2008-12-17 11:47:28 PST
I've un-bitrotted this patch, and started to make the initial imap folder creation work. I'll be fixing some core issues this patch has brought up, including bug 470011, and the fact that creating an imap folder at the root level doesn't pay attention to the personal namespace (e.g., make the folder a child of the INBOX for servers where the personal namespace is "INBOX.")
Comment 20 David :Bienvenu 2008-12-17 15:18:13 PST
we seem to be creating a different folder for every hour of the day, which seems a bit excessive :-)

I've gotten the two patches to work together, such that we use the identity's idea of the archive folder. But I believe we really want to archive imap messages in the imap account instead of using the default local folders account, by default.

I'm having a lot of fun with the folders not showing up in the UI until a restart.  This feature is quite the stress test on a bunch of different code :-)
Comment 21 David :Bienvenu 2008-12-17 20:23:38 PST
Created attachment 353616 [details] [diff] [review]
wip

this is what I have so far - it contains some diffs that are in patches in separate spin-off bugs, which I'll land first.
Comment 22 David :Bienvenu 2008-12-18 09:18:52 PST
this should get into b2
Comment 23 Bryan Clark (DevTools PM) [:clarkbw] 2008-12-23 10:21:38 PST
(In reply to comment #20)
> I've gotten the two patches to work together, such that we use the identity's
> idea of the archive folder. But I believe we really want to archive imap
> messages in the imap account instead of using the default local folders
> account, by default.

Yes, this is just a fault of my not understanding all the code for the Drafts folder implementation.  We really do want to default to the IMAP account instead of the Local Folders.
Comment 24 Bryan Clark (DevTools PM) [:clarkbw] 2008-12-23 10:25:40 PST
Also, just to note that I think we can handle the GMail case in a follow up patch.  This is a large enough change that I think it's important that we get some good testing started ASAP.  For GMail users that are testing they will get some labels created that they don't want but no harm will really be done.
Comment 25 David :Bienvenu 2008-12-26 11:25:47 PST
it's a bit tricky to default to a non-existent folder on a server (we don't have any defaults that behave that way now), though I'm sure I can figure out a way.

I also need to make it so the Archives folder name is displayed localized, though I think I'll make the folder name on the server be "Archives".
Comment 26 David :Bienvenu 2008-12-30 14:57:38 PST
Created attachment 354888 [details] [diff] [review]
add archives folder flag,  archives folder property to identity, and localized Archives folder name

this is some plumbing work to support an Archives folder.

I've changed getFolderPref to fall back on the default folder on the server, if possible, and then the default folder on the local folders account. This allows us to have a default on the current server, which wasn't easy before. Currently, we default to the local folders account for things like drafts, but we don't want to do that for Archives.
Comment 27 David :Bienvenu 2008-12-30 14:58:41 PST
none of this code should currently get exercised, until more of this work lands.
Comment 28 neil@parkwaycc.co.uk 2009-01-01 09:21:12 PST
(In reply to comment #26)
> I've changed getFolderPref to fall back on the default folder on the server, if
> possible, and then the default folder on the local folders account. This allows
> us to have a default on the current server, which wasn't easy before.
> Currently, we default to the local folders account for things like drafts, but
> we don't want to do that for Archives.
I thought Drafts, Templates, Sent, Trash and Junk always defaulted to the server, not local folders.
Comment 29 neil@parkwaycc.co.uk 2009-01-01 09:37:04 PST
I guess someone must set them up during account creation?
Comment 30 David :Bienvenu 2009-01-01 15:01:43 PST
Created attachment 355059 [details] [diff] [review]
snapshotting current work
Comment 31 David :Bienvenu 2009-01-01 15:16:48 PST
yes, the account wizard and copies dialog both seem to do that:

http://mxr.mozilla.org/comm-central/source/mailnews/base/prefs/resources/content/am-copies.js#356

http://mxr.mozilla.org/comm-central/source/mailnews/base/prefs/resources/content/AccountWizard.js#650

http://mxr.mozilla.org/comm-central/source/mailnews/base/prefs/resources/content/AccountWizard.js#678

So that's an alternative to what I've done - I didn't know about/remember the allows_specialfolders_usage server attribute
Comment 32 David :Bienvenu 2009-01-02 08:58:49 PST
Comment on attachment 354888 [details] [diff] [review]
add archives folder flag,  archives folder property to identity, and localized Archives folder name

oh, yes, the reason I did it this way is so that existing profiles will automatically get their archives folder on the imap server. Also, at least for TB, the account wizard is getting replaced, so that would be one less piece of logic I'd need to redo for the new account wizard. So I think I'll just tweak the nsMsgIdentity::getFolderPref code to check that allows_specialfolders_usage server attribute.
Comment 33 David :Bienvenu 2009-01-02 13:37:24 PST
Created attachment 355157 [details] [diff] [review]
use GetDefaultCopiesAndFoldersPrefsToServer
Comment 34 neil@parkwaycc.co.uk 2009-01-03 15:40:18 PST
Comment on attachment 355157 [details] [diff] [review]
use GetDefaultCopiesAndFoldersPrefsToServer

>+archiveFolderName=Archives
This was just the most obvious example of the archive/archives mix but you've been horribly inconsistent throughout this patch; pick one and stick to it!

> PRUnichar *nsMsgDBFolder::kLocalizedUnsentName;
> PRUnichar *nsMsgDBFolder::kLocalizedJunkName;
> PRUnichar *nsMsgDBFolder::kLocalizedBrandShortName;
>+PRUnichar *nsMsgDBFolder::kLocalizedArchivesName;
Nit: Brand should come last, or better still, separated with a blank line.
(Same goes for the NS_Free section; the init code is already separated.)

>+  nsCOMPtr<nsISupportsArray> servers;
>+  rv = accountManager->GetServersForIdentity(this, getter_AddRefs(servers));
>+  NS_ENSURE_SUCCESS(rv,rv);
>+  PRUint32 cnt = 0;
>+  servers->Count(&cnt);
>+  if (cnt > 0)
>+  {
>+    nsCOMPtr<nsIMsgIncomingServer> server(do_QueryElementAt(servers, 0, &rv));
>+    if (NS_SUCCEEDED(rv))
You probably don't have to count them first, as this will fail anyway.
[And you didn't check the rv for Count ;-) ]

>+      retval.Append("/");
>+      retval.Append(folderName);
Is it worth changing the macro to prepend the "/" automatically i.e.
rv = getFolderPref(_prefname, folderPref, "/" _foldername, _flag); \
[Otherwise use retval.Append('/'); instead]
Comment 35 David :Bienvenu 2009-01-03 18:01:14 PST
re Archive vs. Archives - that was a decision that I inherited, not one that I originated. The decision was to call the folder flag "Archive", but the folder "Archives".  Perhaps I should go back and edit all the patch to call all the vars "Archive" and leave the folder name "Archives" so that the only inconsistency would be the display name.
Comment 36 Magnus Melin 2009-01-04 04:18:57 PST
(In reply to comment #13)
> 5) the structure of the archives folder (figured out with various people in
> mountain view) is:
> 
>   Archives/2008/2008-04

This hierarchy seems to be unncessarily deep. Why do we need the extra year subdir? 

Actually I'd prefer there not to be a month at all as I don't think the amount of archived mail per month folder will be large on average. Then we also wouldn't have to bother with month names which will cause the folders to be sorted non-chronologically (and folder name loclizations).
Comment 37 Igor Velkov 2009-01-04 11:24:24 PST
Month basis can be need for the most users, not deletes mails with multimedia. I see a lot of "folder is larger 2 gb size" problem for less than a year.

I am using mail archiving, and not use month level - but I remove all large attachements.

Maybe, there can be an option, and archiver can propose more optimal way depending on inbox size and message count?
Comment 38 Magnus Melin 2009-01-04 11:53:46 PST
I dare say if you need to archive over 2 or 4 GB of mail per month, you're mailing habits are highly unusual. Of all the bugs re the max 4GB / folder I don't recall anyone ever complaining about the limit for folders - except for the Inbox. (And Trash, when people don't know they must compact folder once in a while.)
Comment 39 Magnus Melin 2009-01-04 11:57:59 PST
If it's about the "never throw away anything" policy Gmail tried, even Gmail had to add the delete button. Big surprise deletion *is* on of the most powerful labeling mechanisms, especially with the amount of junk (non-spam) you get...
Comment 40 Igor Velkov 2009-01-04 13:09:48 PST
I didn't say about "2 GIG per month", I said about "per year". But have 2-3 gig in one file os not comfortable.

This issue created for help users, that not toss mail by boxes. This issue created as a decision for people who not keep in mind that inbox can have any limits, who don't know about email really have a volume, and inbox and trash need to be purged time to time.

I often fix broken mail systems of that people, and please, don't tell to **me**, how to **right** use  email. Tell it to all email users of all ages - from 5 to 85 years.

Computer must work without any harrasements to users, without any user-made "housekeeping".

This issue is one more step to computers that "just works", and should perform this task.
Comment 41 David Ascher (:davida) 2009-01-04 15:05:52 PST
(In reply to comment #36)

> This hierarchy seems to be unncessarily deep. Why do we need the extra year
> subdir? 
> 
> Actually I'd prefer there not to be a month at all as I don't think the amount
> of archived mail per month folder will be large on average. Then we also
> wouldn't have to bother with month names which will cause the folders to be
> sorted non-chronologically (and folder name loclizations).

The primary criterion for picking a monthly folder structure was that we'll need to periodically open the corresponding MSF files for autosync, and it really hurts to open huge MSF files.  Also, Bryan and I felt that years and months are concepts that people understand really well, and which correspond to common searches, meaning that the file structure will likely map normal organizational patterns.

Archive folders are intended to be displayed with custom logic, which can take into account l10n issues.  It makes sense for me to use numbers on the server, as long as the UI uses appropriate l10n names.
Comment 42 David :Bienvenu 2009-01-04 15:25:51 PST
the time it takes to open a .msf file is miniscule compared to the time it takes to do an imap sync of a large folder - I don't think the .msf opening time is really an issue.
Comment 43 David Ascher (:davida) 2009-01-04 15:32:20 PST
(In reply to comment #42)
> the time it takes to open a .msf file is miniscule compared to the time it
> takes to do an imap sync of a large folder - I don't think the .msf opening
> time is really an issue.

I knew i had my argument for keeping file sizes down wrong.  thanks for correcting the record.
Comment 44 David :Bienvenu 2009-01-06 15:37:06 PST
Created attachment 355672 [details] [diff] [review]
add prefs ui to pick an archive folder.

this adds the archive folder to the copies sheet - I'm assuming that SeaMonkey is going to want some sort of Archive feature, though perhaps not exactly the same as TB, so I've left this in SM. Let me know if I should #ifdef MOZ_THUNDERBIRD this...
Comment 45 David :Bienvenu 2009-01-06 16:00:25 PST
Created attachment 355674 [details] [diff] [review]
TB front end archive work

this is the TB front end work to make the archive command work, and to add an archive button to the message header area.

I think all the work is now in patches attached to this bug.
Comment 46 neil@parkwaycc.co.uk 2009-01-07 03:22:18 PST
(In reply to comment #10)
> Shouldn't that be "Archive" without the s?
I disagree. Drafts and Templates have an s, and so should Archives.

As a result of the mix up, attachment 355672 [details] [diff] [review] has entity name mismatches!
Comment 47 neil@parkwaycc.co.uk 2009-01-07 03:26:39 PST
Comment on attachment 355672 [details] [diff] [review]
add prefs ui to pick an archive folder.

>+    SaveFolderSettings( gArchiveRadioElemChoice, 
>+                        "messageArchive",
>+                        gArchiveFolderWithDelim, 
>+                        "msgArchiveAccountPicker", 
This was the worst spot for copied trailing spaces, but git-apply claims there are 18 whitespace errors in all.

>+        <label value="&keepArchive.label;" control="messageArchive"/>
Archives.

>+                     value="0" label="&archiveFolderOn.label;"
>+                     accesskey="&archiveFolderOn.accesskey;"/>
Archives. Archives! </rant>
Comment 48 David :Bienvenu 2009-01-07 08:15:55 PST
A single message in a drafts folder is a draft. Is a single message in an Archive folder an archive? I'm happy to make it all Archives other than the folder flag and if someone doesn't like that, they can change it themselves :-)
Comment 49 Mark Banner (:standard8, afk until Dec) 2009-01-08 04:21:15 PST
Comment on attachment 355157 [details] [diff] [review]
use GetDefaultCopiesAndFoldersPrefsToServer


>@@ -102,6 +102,7 @@
>   attribute ACString fccFolderPickerMode;
>   attribute boolean fccReplyFollowsParent;
>   attribute ACString draftsFolderPickerMode;
>+  attribute ACString archivesFolderPickerMode;
>   attribute ACString tmplFolderPickerMode;  

I think it would be worth adding some documentation (just one-liners probably) as to what these folder picker modes relate to. It certainly took me a bit of digging to realise.

>   attribute ACString draftFolder;
>+  attribute ACString archiveFolder;
>   attribute ACString stationeryFolder;

Again, this needs a little documentation I think just to say it will set/return the name of the folder to use for the identity.

>diff --git a/mailnews/base/public/nsMsgFolderFlags.idl b/mailnews/base/public/nsMsgFolderFlags.idl
>--- a/mailnews/base/public/nsMsgFolderFlags.idl
>+++ b/mailnews/base/public/nsMsgFolderFlags.idl
>@@ -98,8 +98,8 @@
>   const nsMsgFolderFlagType Inbox           = 0x00001000;
>   /// Whether this folder on online IMAP
>   const nsMsgFolderFlagType ImapBox         = 0x00002000;
>-  /// Used to be for category container
>-  const nsMsgFolderFlagType Unused3         = 0x00004000;
>+  /// Whether this is an archive folder
>+  const nsMsgFolderFlagType Archive         = 0x00004000;
>   /// This is a virtual newsgroup
>   const nsMsgFolderFlagType ProfileGroup    = 0x00008000;

This file should probably have a uuid bump

r=me with those fixed.
Comment 50 Mark Banner (:standard8, afk until Dec) 2009-01-08 05:28:50 PST
Comment on attachment 355672 [details] [diff] [review]
add prefs ui to pick an archive folder.

Something is causing the achiveFolderPickerMode not to be save or restored - it always comes up on "Other" whenever I open the account settings dialog. The archive folder pref does seem to be set correctly though.

>+    SaveFolderSettings( gArchiveRadioElemChoice, 
>+                        "messageArchive",
>+                        gArchiveFolderWithDelim, 
>+                        "msgArchiveAccountPicker", 
>+                        "msgArchiveFolderPicker",
>+                        "identity.archiveFolder",
>+                        "identity.archiveFolderPickerMode" );
>+                        

nit: some of these lines of blank space on the end, and the last line has whitespace on it when it doesn't need to (ditto with other lines you've added).

>+      <hbox align="center">
>+        <label value="&keepArchive.label;" control="messageArchive"/>
>+      </hbox>

This doesn't match the strings.

>+              <radio id="archive_selectAccount" 
>+                     oncommand="setPickersState('msgArchiveAccountPicker', 'msgArchiveFolderPicker', event)"
>+                     value="0" label="&archiveFolderOn.label;"
>+                     accesskey="&archiveFolderOn.accesskey;"/>

nor do these two.

>+ 	      <menulist id="msgArchiveAccountPicker" 
>+  	      <menulist id="msgArchiveFolderPicker"

There's a tab on these lines.
Comment 51 Mark Banner (:standard8, afk until Dec) 2009-01-08 06:08:41 PST
Comment on attachment 355157 [details] [diff] [review]
use GetDefaultCopiesAndFoldersPrefsToServer

>+++ b/mail/locales/en-US/chrome/messenger/messenger.properties
>+archiveFolderName=Archives

>+  bundle->GetStringFromName(NS_LITERAL_STRING("archivesFolderName").get(),
>+                            &kLocalizedArchivesName);

>+++ b/suite/locales/en-US/chrome/mailnews/messenger.properties
>+archiveFolderName=Archives

I've just tested all these patches together. These don't match, and so we then crash (because kLocalizedArchivesName is null and nsDependentString doesn't like that).
Comment 52 Mark Banner (:standard8, afk until Dec) 2009-01-08 06:37:23 PST
Comment on attachment 355674 [details] [diff] [review]
TB front end archive work

messenger.properties didn't seem to apply, but I expect that's because its diff is already in one of the other patches.

Should Bryan be doing ui-review on this patch and the account manager?

Probably follow-up bugs, but I'll mention them here, please make sure they get filed if you aren't addressing them:

- IMAP folders don't get tagged for offline use when they are created. Is that expected, should that happen?
- No archive option in context menu (especially useful/expected for multiple messages)
- Should the archive button/menu option really be displayed/enabled when you are viewing a message in an archive folder?
- Archive button is displayed for RSS messages, but does nothing.

>diff --git a/mail/base/content/mailWidgets.xml b/mail/base/content/mailWidgets.xml
>--- a/mail/base/content/mailWidgets.xml
>+++ b/mail/base/content/mailWidgets.xml
>@@ -2098,7 +2098,10 @@
>        <xul:button anonid="hdrForwardButton" label="&forwardButton.label;"
>                    oncommand="MsgForwardMessage(event);"
>                    observes="button_forward" class="msgHeaderView-button hdrForwardButton"/>
>-       <xul:button anonid="hdrJunkButton" label="&junkButton.label;"
>+       <xul:button anonid="archiveButton" label="&archiveButton.label;"
>+                oncommand="MsgArchiveSelectedMessages(event);" observes="button_archive"
>+                class="msgHeaderView-button hdrArchiveButton"/>

Seeing as you're observing/setting up button_archive, why not goDoCommand('button_archive') as well?

>+        <xul:button anonid="hdrJunkButton" label="&junkButton.label;"

nit: no need to change this line (indent is now wrong).

>+    // subtle:
>+    SetNextMessageAfterDelete(); // we're just pretending
>+    this.messageToSelectAfterWereDone = gNextMessageViewIndexAfterDelete;
>+    gNextMessageViewIndexAfterDelete = -2;
>+    

nit: whitespace on blank lines again.

>+      let msgHdr = messenger.msgHdrFromURI(selectedMsgUris[i]);
>+  
>+      let rootFolder = msgHdr.folder.server.rootFolder;
>+      //if (rootFolder instanceof Components.interfaces.nsIMsgFolder)
>+        //dump("Found root folder for archiving: " + rootFolder);
>+  
>+      let msgDate = new Date(msgHdr.date / 1000);  // convert date to JS date object
>+      //dump("msgDate = " + msgDate.toString() + '\n');
>+      let msgYear = msgDate.getFullYear().toString();
>+      //dump("msgYear = " + msgYear + '\n');
>+      let monthFolderName = msgDate.toLocaleFormat("%Y-%m")
>+      //dump("monthFolderName= " + monthFolderName + '\n');
>+      let dstFolderName = monthFolderName;
>+      //dump("dstFolderName= " + dstFolderName + '\n');

I think we can probably remove these commented out lines (in multiple places)

>+      if (!subfolder.containsChildNamed(dstFolderName))
>+      {
>+        //dump("Creating month folder\n");
>+        subfolder = subfolder.addSubfolder(dstFolderName);
>+        dump("create folder " + subfolder.URI + '\n');

we shouldn't really need this now should we?

>+  OnStopCopy: function(aStatus)
>+  {
>+    try {
...
>+    } catch (e) {
>+      dump("Exc: " + e + '\n');
>+    }

Why do we need this try/catch? I'd prefer if it wasn't there or at least not over the whole function - it is very easy to mask errors otherwise.
Comment 53 Peter Lairo 2009-01-08 07:03:02 PST
(In reply to comment #52)
> - No archive option in context menu (especially useful/expected for multiple
> messages)

And in the context menus of folders? (e.g., for archiving a completed project)
Comment 54 David :Bienvenu 2009-01-08 09:58:14 PST
Created attachment 356010 [details] [diff] [review]
cumulative fix

this accumulates the various patches into one, for review. I've addressed most of your comments, except for a couple:

I don't believe we need to change uuids for new constants
Using go_doCommand('button_archive') does not work - there's a downstream error that I don't quite understand, but the code that's there does work :-)

Re the bugs you noticed, I'll file those, but I'd like to get the basic stuff in sooner rather than later. The one that worries me a bit more is not configuring the archive for offline - I think I know why that is, and it should be easy to fix.
Comment 55 David :Bienvenu 2009-01-10 11:53:39 PST
Created attachment 356339 [details] [diff] [review]
configure new archive folders for offline download

this makes new archive folders get configured for offline use, by default.
Comment 56 Mark Banner (:standard8, afk until Dec) 2009-01-12 02:55:22 PST
Comment on attachment 356010 [details] [diff] [review]
cumulative fix

nit: there are still a few whitespace issues (http://beaufour.dk/jst-review/?patch=356010&file=)

>+  // URI for the fcc (Sent) folder
>   attribute ACString fccFolder;

nit: doxygen requires /// for single-line comments.

>+  // these attributes control whether the special folder pickers for
>+  // fcc, drafts,archives, and templates are set to pick between servers
>+  // (e.g., Sent on accountName) or to pick any folder on any account.
>+  // "0" means choose between servers; "1" means use the full folder picker.
>   attribute ACString fccFolderPickerMode;
>-  attribute boolean fccReplyFollowsParent;
>   attribute ACString draftsFolderPickerMode;
>+  attribute ACString archivesFolderPickerMode;
>   attribute ACString tmplFolderPickerMode;  

nit: if you make this:

/**
 * @{
 * <the comments>
 */
attribute 
attribute ...
/** @} */

Doxygen can then pick this up as a group comment and will apply it to all of the attributes

This also applies to the special folder attributes.

r=me with those fixed.
Comment 57 David :Bienvenu 2009-01-12 13:08:22 PST
fix checked in - I'll file followup bugs on these:

- No archive option in context menu (especially useful/expected for multiple
messages) (though I don't know why anyone would use a context menu when there's a single key shortcut available)
- Hide or disable the archive button when viewing a message in an archive folder.
- Either fix or hide the Archive button for RSS messages
Comment 58 David :Bienvenu 2009-01-12 13:11:27 PST
Bug 473212 is the tracking bug for remaining issues.

Note You need to log in before you can comment on or make changes to this bug.