Bug 651848 - Disable deleting news articles by default (pref-off); r=bienvenu
authorMark Banner <bugzilla@standard8.plus.com>
Sat, 07 May 2011 10:34:42 +0100
changeset 7722 6f0e51f510aac8c16890ad073357ee304a3e0755
parent 7721 10cdb94a0d26d233706c14ff7a3e23045ee01148
child 7723 5e78e1fa3fa0e481f40fe606bc58a0c9619d8324
push idunknown
push userunknown
push dateunknown
reviewersbienvenu
bugs651848
Bug 651848 - Disable deleting news articles by default (pref-off); r=bienvenu
mail/base/content/messageWindow.js
mailnews/mailnews.js
mailnews/news/src/nsNewsFolder.cpp
mailnews/news/src/nsNewsFolder.h
--- a/mail/base/content/messageWindow.js
+++ b/mail/base/content/messageWindow.js
@@ -804,22 +804,19 @@ var MessageWindowController =
         loadedFolder = gFolderDisplay.displayedFolder;
         if (!(loadedFolder && loadedFolder.server.canHaveFilters))
           return false;
       case "cmd_delete":
         UpdateDeleteCommand();
         // fall through
       case "button_delete":
         UpdateDeleteToolbarButton();
-        // fall through
+        return gFolderDisplay.getCommandStatus(nsMsgViewCommandType.deleteMsg);
       case "cmd_shiftDelete":
-        return gFolderDisplay.selectedMessage &&
-               gFolderDisplay.displayedFolder &&
-               (gFolderDisplay.displayedFolder.canDeleteMessages ||
-                gFolderDisplay.view.isNewsFolder);
+        return gFolderDisplay.getCommandStatus(nsMsgViewCommandType.deleteNoTrash);
       case "button_junk":
         UpdateJunkToolbarButton();
         // fall through
       case "cmd_markAsJunk":
       case "cmd_markAsNotJunk":
         return gFolderDisplay.getCommandStatus(nsMsgViewCommandType.junk);
       case "cmd_recalculateJunkScore":
         return gFolderDisplay.selectedMessage &&
--- a/mailnews/mailnews.js
+++ b/mailnews/mailnews.js
@@ -199,16 +199,17 @@ 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",        "");
--- a/mailnews/news/src/nsNewsFolder.cpp
+++ b/mailnews/news/src/nsNewsFolder.cpp
@@ -423,16 +423,32 @@ nsMsgNewsFolder::GetCanCompact(PRBool *a
 {
   NS_ENSURE_ARG_POINTER(aResult);
   *aResult = PR_FALSE;
   // you can't compact a news server or a news group
   return NS_OK;
 }
 
 NS_IMETHODIMP
+nsMsgNewsFolder::GetCanDeleteMessages(PRBool *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 = PR_FALSE;
+  prefBranch->GetBoolPref("news.allow_delete_with_no_undo", aResult);
+  return NS_OK;
+}
+
+NS_IMETHODIMP
 nsMsgNewsFolder::GetMessages(nsISimpleEnumerator **result)
 {
   nsresult rv = GetDatabase();
   *result = nsnull;
 
   if(NS_SUCCEEDED(rv))
     rv = mDatabase->EnumerateMessages(result);
 
--- a/mailnews/news/src/nsNewsFolder.h
+++ b/mailnews/news/src/nsNewsFolder.h
@@ -92,16 +92,17 @@ public:
                       nsIMsgCopyServiceListener* listener, PRBool allowUndo);
   NS_IMETHOD GetNewMessages(nsIMsgWindow *aWindow, nsIUrlListener *aListener);
 
   NS_IMETHOD GetCanSubscribe(PRBool *aResult);
   NS_IMETHOD GetCanFileMessages(PRBool *aResult);
   NS_IMETHOD GetCanCreateSubfolders(PRBool *aResult);
   NS_IMETHOD GetCanRename(PRBool *aResult);
   NS_IMETHOD GetCanCompact(PRBool *aResult);
+  NS_IMETHOD GetCanDeleteMessages(PRBool *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(PRInt32 *order);
   NS_IMETHOD SetSortOrder(PRInt32 order);