Comment 52 for bug 885525

Revision history for this message
In , M-wada (m-wada) wrote :

Created attachment 704299
Test extention : Change arbitary IMAP folder to trashFolderName folder and SpecialUse=Trash folder by ToolBar button click

This test extension is for seeing Tb's behavior on "trash", and merely does following when customized ToolBar button-1 is clicked.

(1) Puts currently selected folder name to incomingServer.trashFolderName
    if IMAP account. (call ABC/DEF for later reference)
(1-A) Use string in msgFolder.URI instead of msgFolder.prettiestName
    for setting incomingServer.trashFolderName, in case of localized special
    folder name by localized Tb.
(1-B) Remove personalNamespace from string set in msgFolder.prettiestName,
    because Tb's current logic which uses mail.server.serverN.trash_folder_name
    requests "Mbox name without namespace" in trash_folder_name setting.
Note: This test extension doesn't care about "IMAP server directory:" of Server Settings/Advanced.

By (1), Tb automatically updates mail.server.serverN.trash_folder_name and is automatically reflected to trash folder selection UI at Server Settings.
This works very well, as far as problem of bug 831664 is bypassed by operation like "write very long text to Error Console".

(2) Request msgFolder.setflag(Trash) for selected folder of ABC/DEF
    and msgFolder.clearflag(Trash) for all other folders under the IMAP account.
    (this is opposite action to DiscoveryDone().)

By (2), icon of selected folder of ABC/DEF is changed to trash-can-icon, and trash-can-icon is removed from any other folder including [Gmail]/[Trash] of Gmail IMAP.

Even when Gmail IMAP, folder of ABC/DEF is used by Tb as "trash for Tb" when IMAP delete model of "Move to trash" and mails are moved to ABC/DEF when delete is requested, until collapse/re-expand, subscribe, unsubscribe etc. is executed,

When Gmail IMAP account is collapsed/re-expanded, following is observed.
  Upon re-expand, trash-can-icon is removed from ABC/DEF,
  and icon of [Gmail]/Trash is changed to trash-can-icon.
This is done by following.
> http://mxr.mozilla.org/comm-central/source/mail/base/content/folderPane.js#881
> 881 if (aExpandServer) {
> 882 if (folder.isServer)
> 883 folder.server.performExpand(msgWindow);
> http://mxr.mozilla.org/comm-central/source/mailnews/imap/src/nsImapIncomingServer.cpp#941
> 941 nsImapIncomingServer::PerformExpand(nsIMsgWindow *aMsgWindow)
> 962 rv = imapService->DiscoverAllFolders(rootMsgFolder,
> http://mxr.mozilla.org/comm-central/source/mailnews/imap/src/nsImapService.cpp#1811
> 1811 NS_IMETHODIMP nsImapService::DiscoverAllFolders(nsIMsgFolder *aImapMailFolder,
> 1834 urlSpec.Append("/discoverallboxes");
> 1838 rv = GetImapConnectionAndLoadUrl(imapUrl, nullptr, aURL);
After completion of the discoverallboxes request,
> http://mxr.mozilla.org/comm-central/source/mailnews/imap/src/nsImapIncomingServer.cpp#2331
> 2331 nsImapIncomingServer::OnStopRunningUrl(nsIURI *url, nsresult exitCode)
> 2350 case nsIImapUrl::nsImapDiscoverAllBoxesUrl:
> 2351 if (NS_SUCCEEDED(exitCode))
> 2352 DiscoveryDone();

Test result of (1) indicates possible new/easy trash selection for user,
  Context menu of "Use this folder as Trash".
although it's perhaps merely wasting of valuable context menu space.
Because this works only on existent folder, this way can do noting for "automatic folder creation of trash which is set in mail.server.serverN.trash_folder_name or default of it(==Trash)".

Because "trash for Tb" can be set by the test extension even when IMAP delete model of "Just mark it as deleted" or "Remove immediately", "Empty Trash after copy/move mail to [Gmail]/Trash for immediate/permanent removal of mails" is possible, even with "Just mark it as deleted" or "Remove immediately".
Because Tb currently doesn't change SpecialUse=Trash setting of any folder if "Just mark it as deleted" or "Remove immediately", this works even with Gmail IMAP and current Tb.