Bug 761720 - Port |Bug 474721 - messagereader: message header should not prefer the address book over the message headers as a source of display names| r/moa=mnyromyr
authorIan Neal <iann_cvs@blueyonder.co.uk>
Sat, 09 Jun 2012 23:40:29 +0100
changeset 10405 172686daec1064e15c8860f71231e17ba92e7c48
parent 10404 0d2ec5a8ce0ea16e9ba3a23d7cb09c426db90ee8
child 10406 51f43f28c12489a1957fb6b968de71931472ed9a
push id7871
push useriann_cvs@blueyonder.co.uk
push dateSat, 09 Jun 2012 22:40:44 +0000
treeherdercomm-central@81cae5edbac8 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs761720, 474721
Bug 761720 - Port |Bug 474721 - messagereader: message header should not prefer the address book over the message headers as a source of display names| r/moa=mnyromyr
suite/locales/en-US/chrome/mailnews/addressbook/abCardOverlay.dtd
suite/mailnews/addrbook/abCardOverlay.js
suite/mailnews/addrbook/abCardOverlay.xul
suite/mailnews/msgHdrViewOverlay.js
--- a/suite/locales/en-US/chrome/mailnews/addressbook/abCardOverlay.dtd
+++ b/suite/locales/en-US/chrome/mailnews/addressbook/abCardOverlay.dtd
@@ -26,16 +26,18 @@
 <!ENTITY NameField1.label               "First:">
 <!ENTITY NameField1.accesskey           "F">
 <!ENTITY NameField2.label               "Last:">
 <!ENTITY NameField2.accesskey           "L">
 <!ENTITY PhoneticField1.label           "Phonetic:">
 <!ENTITY PhoneticField2.label           "Phonetic:">
 <!ENTITY DisplayName.label              "Display:">
 <!ENTITY DisplayName.accesskey          "D">
+<!ENTITY preferDisplayName.label        "Always prefer display name over message header">
+<!ENTITY preferDisplayName.accesskey    "A">
 <!ENTITY NickName.label                 "Nickname:">
 <!ENTITY NickName.accesskey             "N">
 
 <!ENTITY PrimaryEmail.label             "Email:">
 <!ENTITY PrimaryEmail.accesskey         "E">
 <!ENTITY SecondEmail.label              "Additional Email:">
 <!ENTITY SecondEmail.accesskey          "i">
 <!ENTITY PreferMailFormat.label         "Prefers to receive messages formatted as:">
--- a/suite/mailnews/addrbook/abCardOverlay.js
+++ b/suite/mailnews/addrbook/abCardOverlay.js
@@ -1,16 +1,16 @@
 /* -*- Mode: Java; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 const kNonVcardFields =
         ["nickNameContainer", "secondaryEmailContainer", "screenNameContainer",
-         "customFields", "allowRemoteContent"];
+         "customFields", "allowRemoteContent", "preferDisplayName"];
 
 const kPhoneticFields =
         ["PhoneticLastName", "PhoneticLabel1", "PhoneticSpacer1",
          "PhoneticFirstName", "PhoneticLabel2", "PhoneticSpacer2"];
 
 // Item is |[dialogField, cardProperty]|.
 const kVcardFields =
         [ // Contact > Name
@@ -265,16 +265,19 @@ function OnLoadEditCard()
         // And the phonetic fields
         document.getElementById(kPhoneticFields[0]).readOnly = true;
         document.getElementById(kPhoneticFields[3]).readOnly = true;
 
         // Also disable the mail format popup and allow remote content items.
         document.getElementById("PreferMailFormatPopup").disabled = true;
         document.getElementById("allowRemoteContent").disabled = true;
 
+        // And the "prefer display name" checkbox.
+        document.getElementById("preferDisplayName").disabled = true;
+
         document.documentElement.buttons = "accept";
         document.documentElement.removeAttribute("ondialogaccept");
       }
 
       // hide remote content in HTML field for remote directories
       if (directory.isRemote)
         document.getElementById('allowRemoteContent').hidden = true;
     }
@@ -434,16 +437,21 @@ function GetCardValues(cardproperty, doc
   if (popup)
     popup.value = cardproperty.getProperty("PreferMailFormat", "");
 
   var allowRemoteContentEl = document.getElementById("allowRemoteContent");
   if (allowRemoteContentEl)
     // getProperty may return a "1" or "0" string, we want a boolean
     allowRemoteContentEl.checked = cardproperty.getProperty("AllowRemoteContent", false) != false;
 
+  var preferDisplayNameEl = document.getElementById("preferDisplayName");
+  if (preferDisplayNameEl)
+    // getProperty may return a "1" or "0" string, we want a boolean
+    preferDisplayNameEl.checked = cardproperty.getProperty("PreferDisplayName", true) != false;
+
   // get phonetic fields if exist
   try {
     doc.getElementById("PhoneticFirstName").value = cardproperty.getProperty("PhoneticFirstName", "");
     doc.getElementById("PhoneticLastName").value = cardproperty.getProperty("PhoneticLastName", "");
   }
   catch (ex) {}
 
   // Store the original photo URI and update the photo
@@ -521,16 +529,20 @@ function CheckAndSetCardValues(cardprope
   var popup = document.getElementById("PreferMailFormatPopup");
   if (popup)
     cardproperty.setProperty("PreferMailFormat", popup.value);
 
   var allowRemoteContentEl = document.getElementById("allowRemoteContent");
   if (allowRemoteContentEl)
     cardproperty.setProperty("AllowRemoteContent", allowRemoteContentEl.checked);
 
+  var preferDisplayNameEl = document.getElementById("preferDisplayName");
+  if (preferDisplayNameEl)
+    cardproperty.setProperty("PreferDisplayName", preferDisplayNameEl.checked);
+
   // set phonetic fields if exist
   try {
     cardproperty.setProperty("PhoneticFirstName", doc.getElementById("PhoneticFirstName").value);
     cardproperty.setProperty("PhoneticLastName", doc.getElementById("PhoneticLastName").value);
   }
   catch (ex) {}
 
   var type = document.getElementById("PhotoType").value;
--- a/suite/mailnews/addrbook/abCardOverlay.xul
+++ b/suite/mailnews/addrbook/abCardOverlay.xul
@@ -87,16 +87,25 @@
               <spacer flex="1"/>
               <label control="DisplayName" value="&DisplayName.label;"
                      accesskey="&DisplayName.accesskey;" />
               <hbox class="CardEditWidth">
                 <textbox id="DisplayName" flex="1"
                          oninput="DisplayNameChanged()"/>
               </hbox>
             </hbox>
+            <hbox align="center">
+              <spacer flex="1"/>
+              <hbox class="CardEditWidth">
+                <checkbox id="preferDisplayName"
+                          label="&preferDisplayName.label;"
+                          accesskey="&preferDisplayName.accesskey;"/>
+              </hbox>
+            </hbox>
+
             <hbox id="nickNameContainer" align="center">
               <spacer flex="1"/>
               <label control="NickName" value="&NickName.label;"
                      accesskey="&NickName.accesskey;"/>
               <hbox class="CardEditWidth">
                 <textbox id="NickName" flex="1"/>
               </hbox>
             </hbox>
--- a/suite/mailnews/msgHdrViewOverlay.js
+++ b/suite/mailnews/msgHdrViewOverlay.js
@@ -1165,17 +1165,22 @@ function UpdateEmailNodeDetails(aEmailAd
   var parentElementId = aDocumentNode.parentNode.parentNode.parentNode.id;
   // Don't condense the address for the from and reply-to fields.
   // Ids: "collapsedfromValue", "expandedfromBox", "expandedreply-toBox".
   if (/^(collapsedfromValue|expanded(from|reply-to)Box)$/.test(parentElementId))
     condense = false;
 
   var displayName = "";
   if (condense && cardDetails.card)
-    displayName = cardDetails.card.displayName;
+  {
+    if (cardDetails.card.getProperty("PreferDisplayName", true) != true)
+      displayName = aDocumentNode.getAttribute("displayName");
+    if (!displayName)
+      displayName = cardDetails.card.displayName;
+  }
 
   if (displayName)
   {
     aDocumentNode.setAttribute("tooltiptext", aEmailAddress);
   }
   else
   {
     aDocumentNode.removeAttribute("tooltiptext");