Bug 1018960 - Make the message about cleaning out Trash or Junk show which folder will actually be cleaned. ui-r=Josiah, r=mkmelin
authoraceman <acelists@atlas.sk>
Fri, 11 Jul 2014 12:47:24 +0100
changeset 16481 a708826c1bf8e1f0492501c44a184e2bf8f30cef
parent 16480 dfcf4dadeaafbcd96dd2aa4b1c4d693eea1677c5
child 16482 ef74c5454b5d2f26e4ec4bba4cc4738258aaf446
push id10260
push usermbanner@mozilla.com
push dateFri, 11 Jul 2014 11:56:13 +0000
treeherdercomm-central@2e7786b176ff [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersJosiah, mkmelin
bugs1018960
Bug 1018960 - Make the message about cleaning out Trash or Junk show which folder will actually be cleaned. ui-r=Josiah, r=mkmelin
mail/base/content/folderPane.js
mail/locales/en-US/chrome/messenger/messenger.properties
--- a/mail/base/content/folderPane.js
+++ b/mail/base/content/folderPane.js
@@ -2422,52 +2422,61 @@ let gFolderTreeController = {
         return;
     }
 
     let array = toXPCOMArray([folder], Ci.nsIMutableArray);
     folder.parent.deleteSubFolders(array, msgWindow);
   },
 
   /**
-   * Prompts the user to confirm and empties the trash for the selected folder
+   * Prompts the user to confirm and empties the trash for the selected folder.
+   * The folder and its children are only emptied if it has the proper Trash flag.
    *
    * @param aFolder (optional)  the trash folder to empty
    * @note Calling this function on a non-trash folder will result in strange
    *       behavior!
    */
   emptyTrash: function ftc_emptyTrash(aFolder) {
     let folder = aFolder || gFolderTreeView.getSelectedFolders()[0];
 
-    if (this._checkConfirmationPrompt("emptyTrash")) {
+    if (!folder)
+      return;
+
+    if (!this._checkConfirmationPrompt("emptyTrash", folder))
+      return;
+
       // Check if this is a top-level smart folder. If so, we're going
       // to empty all the trash folders.
       if (folder.server.hostName == "smart mailboxes" &&
           folder.parent.isServer) {
         let subFolders = gFolderTreeView
                            ._allFoldersWithFlag(gFolderTreeView._sortedAccounts(),
                             nsMsgFolderFlags.Trash, false);
-        for each (let trash in subFolders)
+        for (let trash of subFolders)
           trash.emptyTrash(msgWindow, null);
       }
       else {
         folder.emptyTrash(msgWindow, null);
       }
-    }
   },
 
   /**
-   * Deletes everything (folders and messages) in this folder
+   * Deletes everything (folders and messages) in the selected folder.
+   * The folder is only emptied if it has the proper Junk flag.
    *
    * @param aFolder (optional)  the folder to empty
    */
   emptyJunk: function ftc_emptyJunk(aFolder) {
     const Ci = Components.interfaces;
     let folder = aFolder || gFolderTreeView.getSelectedFolders()[0];
 
-    if (!this._checkConfirmationPrompt("emptyJunk"))
+    if (!folder || !folder.getFlag(nsMsgFolderFlags.Junk))
+      return;
+
+    if (!this._checkConfirmationPrompt("emptyJunk", folder))
       return;
 
     // Delete any subfolders this folder might have
     let iter = folder.subFolders;
     while (iter.hasMoreElements())
       folder.propagateDelete(iter.getNext(), true, msgWindow);
 
     // Now delete the messages
@@ -2561,30 +2570,37 @@ let gFolderTreeController = {
   searchMessages: function ftc_searchMessages(aFolder) {
     MsgSearchMessages(aFolder || gFolderTreeView.getSelectedFolders()[0]);
   },
 
   /**
    * Prompts for confirmation, if the user hasn't already chosen the "don't ask
    * again" option.
    *
-   * @param aCommand - the command to prompt for
+   * @param aCommand  the command to prompt for
+   * @param aFolder   The folder for which the confirmation is requested.
    */
-  _checkConfirmationPrompt: function ftc_confirm(aCommand) {
+  _checkConfirmationPrompt: function ftc_confirm(aCommand, aFolder) {
+    // If no folder was specified, reject the operation.
+    if (!aFolder)
+      return false;
+
     let showPrompt = true;
     try {
       showPrompt = !Services.prefs.getBoolPref("mailnews." + aCommand + ".dontAskAgain");
     } catch (ex) {}
 
     if (showPrompt) {
       let checkbox = {value:false};
       let bundle = document.getElementById("bundle_messenger");
+      let title = bundle.getFormattedString(aCommand + "FolderTitle", [aFolder.prettyName]);
+      let msg = bundle.getString(aCommand + "FolderMessage");
       let ok = Services.prompt.confirmEx(window,
-                                         bundle.getString(aCommand + "Title"),
-                                         bundle.getString(aCommand + "Message"),
+                                         title,
+                                         msg,
                                          Services.prompt.STD_YES_NO_BUTTONS,
                                          null, null, null,
                                          bundle.getString(aCommand + "DontAsk"),
                                          checkbox) == 0;
       if (checkbox.value)
         Services.prefs.setBoolPref("mailnews." + aCommand + ".dontAskAgain", true);
       if (!ok)
         return false;
--- a/mail/locales/en-US/chrome/messenger/messenger.properties
+++ b/mail/locales/en-US/chrome/messenger/messenger.properties
@@ -533,21 +533,21 @@ copyToFolderAgainAccessKey=t
 alwaysLoadRemoteContentForSender2= Always load remote content from %1$S
 
 #LOCALIZATION NOTE(mdnBarMessageNormal) %1$S is the name of the sender
 mdnBarMessageNormal=%1$S has asked to be notified when you read this message.
 #LOCALIZATION NOTE(mdnBarMessageAddressDiffers) %1$S is the name of the sender, %2$S is the address(es) to send return receipt to
 mdnBarMessageAddressDiffers=%1$S has asked to be notified (on %2$S) when you read this message.
 
 # mailCommands.js
-emptyJunkTitle=Confirm
-emptyJunkMessage=Are you sure you want to permanently delete all messages and subfolders in the Junk folder?
+emptyJunkFolderTitle=Empty "%S"
+emptyJunkFolderMessage=Delete all messages and subfolders in the Junk folder?
 emptyJunkDontAsk=Don't ask me again.
-emptyTrashTitle=Confirm
-emptyTrashMessage=Are you sure you want to permanently delete all messages and subfolders in the Trash folder?
+emptyTrashFolderTitle=Empty "%S"
+emptyTrashFolderMessage=Delete all messages and subfolders in the Trash folder?
 emptyTrashDontAsk=Don't ask me again.
 
 # junkCommands.js
 junkAnalysisPercentComplete=Junk analysis %S complete
 processingJunkMessages=Processing Junk Messages
 
 # Messenger bootstrapping messages
 fileNotFoundTitle = File Not Found