Bug 883485 - Allow deletion of news posts by default (with a prompt!); r=jcranmer, a=callek for CLOSED TREE
authorJim Porter <jporter@mozilla.com>
Sat, 22 Jun 2013 22:30:33 -0500
changeset 12639 0eca3fec431a6b7ec744082b5532c07bc442a1ab
parent 12638 645be9e5edaf50a3efe4d0235196fa96fa36a93f
child 12640 72a3ee809ec794ed08fb91a0ccae7f20aa7cbdef
push id9280
push usersquibblyflabbetydoo@gmail.com
push dateMon, 24 Jun 2013 02:35:45 +0000
treeherdercomm-central@0eca3fec431a [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjcranmer, callek
bugs883485
Bug 883485 - Allow deletion of news posts by default (with a prompt!); r=jcranmer, a=callek for CLOSED TREE
mail/locales/en-US/chrome/messenger/messenger.properties
mailnews/base/src/nsMsgDBView.cpp
mailnews/mailnews.js
mailnews/news/src/nsNewsFolder.cpp
mailnews/news/src/nsNewsFolder.h
suite/locales/en-US/chrome/mailnews/messenger.properties
--- a/mail/locales/en-US/chrome/messenger/messenger.properties
+++ b/mail/locales/en-US/chrome/messenger/messenger.properties
@@ -588,17 +588,17 @@ addonLocalError-1=This add-on could not 
 addonLocalError-2=This add-on could not be installed because it does not match the add-on #3 expected.
 addonLocalError-3=This add-on could not be installed because it appears to be corrupt.
 addonLocalError-4=#1 could not be installed because #3 cannot modify the needed file.
 addonErrorIncompatible=#1 could not be installed because it is not compatible with #3 #4.
 addonErrorBlocklisted=#1 could not be installed because it has a high risk of causing stability or security problems.
 
 confirmMsgDelete.title=Confirm Deletion
 confirmMsgDelete.collapsed.desc=This will delete messages in collapsed threads. Are you sure you want to continue?
-confirmMsgDelete.shiftDel.desc=This will delete messages immediately, without saving a copy to Trash. Are you sure you want to continue?
+confirmMsgDelete.deleteNoTrash.desc=This will delete messages immediately, without saving a copy to Trash. Are you sure you want to continue?
 confirmMsgDelete.dontAsk.label=Don't ask me again.
 confirmMsgDelete.delete.label=Delete
 
 mailServerLoginFailedTitle=Login Failed
 # LOCALIZATION NOTE (mailServerLoginFailedTitle): Insert "%S" in your
 # translation where you wish to display the hostname of the server to which
 # login failed.
 mailServerLoginFailed=Login to server %S failed.
--- a/mailnews/base/src/nsMsgDBView.cpp
+++ b/mailnews/base/src/nsMsgDBView.cpp
@@ -3058,74 +3058,83 @@ nsresult nsMsgDBView::DeleteMessages(nsI
   nsresult rv;
   nsCOMPtr<nsIMutableArray> messageArray(do_CreateInstance(NS_ARRAY_CONTRACTID, &rv));
   NS_ENSURE_SUCCESS(rv, rv);
   rv = GetHeadersFromSelection(indices, numIndices, messageArray);
   NS_ENSURE_SUCCESS(rv, rv);
   uint32_t numMsgs;
   messageArray->GetLength(&numMsgs);
 
-  int32_t warnType = 0;
   const char *warnCollapsedPref = "mail.warn_on_collapsed_thread_operation";
   const char *warnShiftDelPref = "mail.warn_on_shift_delete";
+  const char *warnNewsPref = "news.warn_on_delete";
+  const char *activePref = nullptr;
   nsCOMPtr<nsIPrefBranch> prefBranch(do_GetService(NS_PREFSERVICE_CONTRACTID, &rv));
   NS_ENSURE_SUCCESS(rv, rv);
 
   if (uint32_t(numIndices) != numMsgs)
   {
     bool pref = false;
     prefBranch->GetBoolPref(warnCollapsedPref, &pref);
     if (pref)
-      warnType = 1;
-  }
-
-  if (warnType == 0 && deleteStorage)
+      activePref = warnCollapsedPref;
+  }
+
+  if (!activePref && deleteStorage)
   {
     bool pref = false;
     prefBranch->GetBoolPref(warnShiftDelPref, &pref);
     if (pref)
-      warnType = 2;
-  }
-
-  if (warnType)
+      activePref = warnShiftDelPref;
+  }
+
+  if (!activePref && mIsNews)
+  {
+    bool pref = false;
+    prefBranch->GetBoolPref(warnNewsPref, &pref);
+    if (pref)
+      activePref = warnNewsPref;
+  }
+
+  if (activePref)
   {
     nsCOMPtr<nsIPrompt> dialog;
 
     nsCOMPtr<nsIWindowWatcher> wwatch(do_GetService(NS_WINDOWWATCHER_CONTRACTID, &rv));
     NS_ENSURE_SUCCESS(rv, rv);
 
     rv = wwatch->GetNewPrompter(0, getter_AddRefs(dialog));
     NS_ENSURE_SUCCESS(rv, rv);
     bool dontAsk = false; // "Don't ask..." - unchecked by default.
     PRInt32 buttonPressed = 0;
 
     nsString dialogTitle;
     nsString confirmString;
     nsString checkboxText;
     nsString buttonApplyNowText;
     dialogTitle.Adopt(GetString(NS_LITERAL_STRING("confirmMsgDelete.title").get()));
-    if (warnType == 1)
-      confirmString.Adopt(GetString(NS_LITERAL_STRING("confirmMsgDelete.collapsed.desc").get()));
-    else
-      confirmString.Adopt(GetString(NS_LITERAL_STRING("confirmMsgDelete.shiftDel.desc").get()));
     checkboxText.Adopt(GetString(NS_LITERAL_STRING("confirmMsgDelete.dontAsk.label").get()));
     buttonApplyNowText.Adopt(GetString(NS_LITERAL_STRING("confirmMsgDelete.delete.label").get()));
 
+    if (activePref == warnCollapsedPref)
+      confirmString.Adopt(GetString(NS_LITERAL_STRING("confirmMsgDelete.collapsed.desc").get()));
+    else // if (activePref == warnShiftDelPref || activePref == warnNewsPref)
+      confirmString.Adopt(GetString(NS_LITERAL_STRING("confirmMsgDelete.deleteNoTrash.desc").get()));
+
     const PRUint32 buttonFlags =
       (nsIPrompt::BUTTON_TITLE_IS_STRING * nsIPrompt::BUTTON_POS_0) +
       (nsIPrompt::BUTTON_TITLE_CANCEL * nsIPrompt::BUTTON_POS_1);
     rv = dialog->ConfirmEx(dialogTitle.get(), confirmString.get(), buttonFlags,
                            buttonApplyNowText.get(), nullptr, nullptr,
                            checkboxText.get(), &dontAsk, &buttonPressed);
     NS_ENSURE_SUCCESS(rv, rv);
     if (buttonPressed)
       return NS_ERROR_FAILURE;
     if (dontAsk)
-      prefBranch->SetBoolPref(warnType == 1 ? warnCollapsedPref :
-                              warnShiftDelPref, false);
+      prefBranch->SetBoolPref(activePref, false);
   }
 
   if (mDeleteModel != nsMsgImapDeleteModels::IMAPDelete)
     m_deletingRows = true;
 
   if (m_deletingRows)
     mIndicesToNoteChange.AppendElements(indices, numIndices);
 
--- a/mailnews/mailnews.js
+++ b/mailnews/mailnews.js
@@ -171,17 +171,16 @@ pref("mail.dsn.request_on_success_on", t
 pref("mail.dsn.request_on_failure_on", true);          // DSN request is sent with FAILURE option
 pref("mail.dsn.request_on_delay_on", true);            // DSN request is sent with DELAY option
 pref("mail.dsn.request_never_on", false);              // DSN request is not sent with NEVER option
 pref("mail.dsn.ret_full_on", true);                    // DSN request is sent with RET FULL option
 
 pref("news.show_size_in_lines",             true);
 pref("news.update_unread_on_expand",        true);
 pref("news.get_messages_on_select",         true);
-pref("news.allow_delete_with_no_undo",      false);
 
 pref("mailnews.wraplength",                 72);
 pref("mail.compose.wrap_to_window_width",   false);
 
 // 0=no header, 1="<author> wrote:", 2="On <date> <author> wrote:", 3="<author> wrote On <date>:", 4=user specified
 pref("mailnews.reply_header_type",          1);
 // locale which affects date format, set empty string to use application default locale
 pref("mailnews.reply_header_locale",        "");
@@ -197,16 +196,17 @@ pref("mailnews.reply_to_self_check_all_i
 
 pref("mailnews.reply_quoting_selection",               true);
 pref("mailnews.reply_quoting_selection.only_if_chars", "");
 pref("mailnews.reply_quoting_selection.multi_word",    true);
 
 pref("mail.operate_on_msgs_in_collapsed_threads", false);
 pref("mail.warn_on_collapsed_thread_operation", true);
 pref("mail.warn_on_shift_delete", true);
+pref("news.warn_on_delete", true);
 pref("mail.purge_threshhold_mb", 20);
 pref("mail.prompt_purge_threshhold",       true);
 pref("mail.purge.ask",                     true);
 
 pref("mailnews.offline_sync_mail",         false);
 pref("mailnews.offline_sync_news",         false);
 pref("mailnews.offline_sync_send_unsent",  true);
 pref("mailnews.offline_sync_work_offline", false);
--- a/mailnews/news/src/nsNewsFolder.cpp
+++ b/mailnews/news/src/nsNewsFolder.cpp
@@ -444,32 +444,16 @@ nsMsgNewsFolder::GetCanCompact(bool *aRe
 {
   NS_ENSURE_ARG_POINTER(aResult);
   *aResult = false;
   // you can't compact a news server or a news group
   return NS_OK;
 }
 
 NS_IMETHODIMP
-nsMsgNewsFolder::GetCanDeleteMessages(bool *aResult)
-{
-  NS_ENSURE_ARG_POINTER(aResult);
-
-  nsresult rv;
-  nsCOMPtr<nsIPrefBranch> prefBranch =
-    do_GetService(NS_PREFSERVICE_CONTRACTID, &rv);
-  NS_ENSURE_SUCCESS(rv, rv);
-
-  // Don't allow delete by default
-  *aResult = false;
-  prefBranch->GetBoolPref("news.allow_delete_with_no_undo", aResult);
-  return NS_OK;
-}
-
-NS_IMETHODIMP
 nsMsgNewsFolder::GetMessages(nsISimpleEnumerator **result)
 {
   nsresult rv = GetDatabase();
   *result = nullptr;
 
   if(NS_SUCCEEDED(rv))
     rv = mDatabase->EnumerateMessages(result);
 
--- a/mailnews/news/src/nsNewsFolder.h
+++ b/mailnews/news/src/nsNewsFolder.h
@@ -60,17 +60,16 @@ public:
                       nsIMsgCopyServiceListener* listener, bool allowUndo);
   NS_IMETHOD GetNewMessages(nsIMsgWindow *aWindow, nsIUrlListener *aListener);
 
   NS_IMETHOD GetCanSubscribe(bool *aResult);
   NS_IMETHOD GetCanFileMessages(bool *aResult);
   NS_IMETHOD GetCanCreateSubfolders(bool *aResult);
   NS_IMETHOD GetCanRename(bool *aResult);
   NS_IMETHOD GetCanCompact(bool *aResult);
-  NS_IMETHOD GetCanDeleteMessages(bool *aResult);
   NS_IMETHOD OnReadChanged(nsIDBChangeListener * aInstigator);
 
   NS_IMETHOD DownloadMessagesForOffline(nsIArray *messages, nsIMsgWindow *window);
   NS_IMETHOD Compact(nsIUrlListener *aListener, nsIMsgWindow *aMsgWindow);
   NS_IMETHOD DownloadAllForOffline(nsIUrlListener *listener, nsIMsgWindow *msgWindow);
   NS_IMETHOD GetSortOrder(int32_t *order);
   NS_IMETHOD SetSortOrder(int32_t order);
 
--- a/suite/locales/en-US/chrome/mailnews/messenger.properties
+++ b/suite/locales/en-US/chrome/mailnews/messenger.properties
@@ -420,17 +420,17 @@ tabs.closeWarningPromptMe=Warn me when c
 
 # Messenger bootstrapping messages
 fileNotFoundTitle = File Not Found
 #LOCALIZATION NOTE(fileNotFoundMsg): %S is the filename
 fileNotFoundMsg = The file %S does not exist.
 
 confirmMsgDelete.title=Confirm Deletion
 confirmMsgDelete.collapsed.desc=This will delete messages in collapsed threads. Are you sure you want to continue?
-confirmMsgDelete.shiftDel.desc=This will delete messages immediately, without saving a copy to Trash. Are you sure you want to continue?
+confirmMsgDelete.deleteNoTrash.desc=This will delete messages immediately, without saving a copy to Trash. Are you sure you want to continue?
 confirmMsgDelete.dontAsk.label=Don't ask me again.
 confirmMsgDelete.delete.label=Delete
 
 mailServerLoginFailedTitle=Login Failed
 # LOCALIZATION NOTE (mailServerLoginFailedTitle): Insert "%S" in your
 # translation where you wish to display the hostname of the server to which
 # login failed.
 mailServerLoginFailed=Login to server %S failed.