Bug 677905 - Add menuitem to "show all body parts" (followup to bug 564423, port bug 602718) r=IanN sr=Mnyromyr ui-r=Neil
authorTony Mechelynck <antoine.mechelynck@gmail.com>
Sun, 14 Aug 2011 07:40:00 +0200
changeset 8297 498b0870ae9f40eb91e5852b296dd1b1bdff1df6
parent 8296 34b76e16e129b222b5796d0117b1767f2003a388
child 8298 2f4de0b727c865cbbd858cffca4919ecd38a43c2
push id6378
push userjh@junetz.de
push dateSun, 14 Aug 2011 18:25:02 +0000
treeherdercomm-central@498b0870ae9f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersIanN, Mnyromyr, Neil
bugs677905, 564423, 602718
Bug 677905 - Add menuitem to "show all body parts" (followup to bug 564423, port bug 602718) r=IanN sr=Mnyromyr ui-r=Neil
suite/locales/en-US/chrome/mailnews/messenger.dtd
suite/mailnews/mailWindowOverlay.js
suite/mailnews/mailWindowOverlay.xul
--- a/suite/locales/en-US/chrome/mailnews/messenger.dtd
+++ b/suite/locales/en-US/chrome/mailnews/messenger.dtd
@@ -247,16 +247,18 @@
 <!ENTITY bodyMenu.label "Message Body As">
 <!ENTITY bodyMenu.accesskey "B">
 <!ENTITY bodyAllowHTML.label "Original HTML">
 <!ENTITY bodyAllowHTML.accesskey "H">
 <!ENTITY bodySanitized.label "Simple HTML">
 <!ENTITY bodySanitized.accesskey "S">
 <!ENTITY bodyAsPlaintext.label "Plain Text">
 <!ENTITY bodyAsPlaintext.accesskey "P">
+<!ENTITY bodyAllParts.label "All Body Parts">
+<!ENTITY bodyAllParts.accesskey "A">
 
 <!ENTITY bodyMenuFeed.label "Feed Message Body As">
 <!ENTITY bodyMenuFeed.accesskey "B">
 <!ENTITY viewFeedWebPage.label "Web Page">
 <!ENTITY viewFeedWebPage.accesskey "W">
 <!ENTITY viewFeedSummary.label "Summary">
 <!ENTITY viewFeedSummary.accesskey "m">
 <!ENTITY viewFeedSummaryFeedPropsPref.label "Default Format">
--- a/suite/mailnews/mailWindowOverlay.js
+++ b/suite/mailnews/mailWindowOverlay.js
@@ -1,9 +1,10 @@
 /* -*- Mode: javascript; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* vim: set ts=2 sw=2 sts=2 et :*/
 /* ***** BEGIN LICENSE BLOCK *****
  * Version: MPL 1.1/GPL 2.0/LGPL 2.1
  *
  * The contents of this file are subject to the Mozilla Public License Version
  * 1.1 (the "License"); you may not use this file except in compliance with
  * the License. You may obtain a copy of the License at
  * http://www.mozilla.org/MPL/
  *
@@ -464,17 +465,18 @@ function InitViewHeadersMenu()
 function InitViewBodyMenu()
 {
   var html_as = 0;
   var prefer_plaintext = false;
   var disallow_classes = 0;
   var isFeed = gFolderDisplay.selectedMessageIsFeed;
   const defaultIDs = ["bodyAllowHTML",
                       "bodySanitized",
-                      "bodyAsPlaintext"];
+                      "bodyAsPlaintext",
+                      "bodyAllParts"];
   const rssIDs = ["bodyFeedSummaryAllowHTML",
                   "bodyFeedSummarySanitized",
                   "bodyFeedSummaryAsPlaintext"];
   var menuIDs = isFeed ? rssIDs : defaultIDs;
   try
   {
     // Get prefs
     if (isFeed) {
@@ -496,26 +498,35 @@ function InitViewBodyMenu()
   catch (ex)
   {
     dump("failed to get the body plaintext vs. HTML prefs\n");
   }
 
   var AllowHTML_menuitem = document.getElementById(menuIDs[0]);
   var Sanitized_menuitem = document.getElementById(menuIDs[1]);
   var AsPlaintext_menuitem = document.getElementById(menuIDs[2]);
+  var AllBodyParts_menuitem;
+  if (!isFeed) {
+    AllBodyParts_menuitem = document.getElementById(menuIDs[3]);
+    AllBodyParts_menuitem.hidden =
+      !pref.getBoolPref("mailnews.display.show_all_body_parts_menu");
+  }
 
   if (!prefer_plaintext && !html_as && !disallow_classes &&
       AllowHTML_menuitem)
     AllowHTML_menuitem.setAttribute("checked", true);
   else if (!prefer_plaintext && html_as == 3 && disallow_classes > 0 &&
       Sanitized_menuitem)
     Sanitized_menuitem.setAttribute("checked", true);
   else if (prefer_plaintext && html_as == 1 && disallow_classes > 0 &&
       AsPlaintext_menuitem)
     AsPlaintext_menuitem.setAttribute("checked", true);
+  else if (!prefer_plaintext && html_as == 4 && !disallow_classes &&
+      AllBodyParts_menuitem)
+    AllBodyParts_menuitem.setAttribute("checked", true);
   // else (the user edited prefs/user.js) check none of the radio menu items
 
   if (isFeed) {
     AllowHTML_menuitem.hidden = !gShowFeedSummary;
     Sanitized_menuitem.hidden = !gShowFeedSummary;
     AsPlaintext_menuitem.hidden = !gShowFeedSummary;
     document.getElementById("viewFeedSummarySeparator").hidden = !gShowFeedSummary;
   }
@@ -2007,16 +2018,25 @@ function MsgBodyAsPlaintext()
     gPrefBranch.setBoolPref("mailnews.display.prefer_plaintext", true);
     gPrefBranch.setIntPref("mailnews.display.html_as", 1);
     gPrefBranch.setIntPref("mailnews.display.disallow_mime_handlers",
                            disallow_classes_no_html);
     ReloadMessage();
     return true;
 }
 
+function MsgBodyAllParts()
+{
+  gPrefBranch.setBoolPref("mailnews.display.prefer_plaintext", false);
+  gPrefBranch.setIntPref("mailnews.display.html_as", 4);
+  gPrefBranch.setIntPref("mailnews.display.disallow_mime_handlers", 0);
+  ReloadMessage();
+  return true;
+}
+
 function MsgFeedBodyRenderPrefs(plaintext, html, mime)
 {
   gPrefBranch.setBoolPref("rss.display.prefer_plaintext", plaintext);
   gPrefBranch.setIntPref("rss.display.html_as", html);
   gPrefBranch.setIntPref("rss.display.disallow_mime_handlers", mime);
   // Reload only if showing rss summary; menuitem hidden if web page..
   ReloadMessage();
 }
--- a/suite/mailnews/mailWindowOverlay.xul
+++ b/suite/mailnews/mailWindowOverlay.xul
@@ -1283,16 +1283,22 @@
                     accesskey="&bodySanitized.accesskey;"
                     oncommand="MsgBodySanitized()"/>
           <menuitem id="bodyAsPlaintext"
                     type="radio"
                     name="bodyPlaintextVsHTMLPref"
                     label="&bodyAsPlaintext.label;"
                     accesskey="&bodyAsPlaintext.accesskey;"
                     oncommand="MsgBodyAsPlaintext()"/>
+          <menuitem id="bodyAllParts"
+                    type="radio"
+                    name="bodyPlaintextVsHTMLPref"
+                    label="&bodyAllParts.label;"
+                    accesskey="&bodyAllParts.accesskey;"
+                    oncommand="MsgBodyAllParts();"/>
         </menupopup>
       </menu>
       <menu id="viewFeedSummary" 
             label="&bodyMenuFeed.label;" 
             accesskey="&bodyMenuFeed.accesskey;">
         <menupopup id="viewFeedSummaryPopupMenu" 
                    onpopupshowing="InitViewBodyMenu()">
           <menuitem id="bodyFeedSummaryAllowHTML"