Bug 1140640 Make From: header editable per-message r=IanN a=IanN
authorNeil Rashbrook <neil@parkwaycc.co.uk>
Thu, 19 Mar 2015 01:15:58 +0000
changeset 25805 9c3f366c9961a4578bc07d0244a94e2419093313
parent 25804 360bca7e702638bf5cd0c3f3d3f97f57b6b8cb44
child 25806 2947dd6c9e500ae202747a6da880d31acf81999d
push id1850
push userclokep@gmail.com
push dateWed, 08 Mar 2017 19:29:12 +0000
treeherdercomm-esr52@028df196b2d9 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersIanN, IanN
bugs1140640
Bug 1140640 Make From: header editable per-message r=IanN a=IanN
suite/mailnews/compose/MsgComposeCommands.js
suite/mailnews/compose/messengercompose.xul
--- a/suite/mailnews/compose/MsgComposeCommands.js
+++ b/suite/mailnews/compose/MsgComposeCommands.js
@@ -942,17 +942,20 @@ function ComposeStartup(recycled, aParam
   if (!params.identity || params.identity.identityName == " <>") {
     // no pre selected identity, so use the default account
     var identities = gAccountManager.defaultAccount.identities;
     if (identities.length == 0)
       identities = gAccountManager.allIdentities;
     params.identity = identities.queryElementAt(0, Components.interfaces.nsIMsgIdentity);
   }
 
-  identityList.value = params.identity.key;
+  identityList.selectedItem =
+    identityList.getElementsByAttribute("identitykey", params.identity.key)[0];
+  if (params.composeFields.from)
+    identityList.value = params.composeFields.from;
   LoadIdentity(true);
   if (sMsgComposeService)
   {
     // Get the <editor> element to startup an editor
     var editorElement = GetCurrentEditorElement();
     gMsgCompose = sMsgComposeService.initCompose(params, window,
                                                  editorElement.docShell);
     if (gMsgCompose)
@@ -1269,16 +1272,17 @@ function DoSpellCheckBeforeSend()
 function GenericSendMessage( msgType )
 {
   if (gMsgCompose != null)
   {
     var msgCompFields = gMsgCompose.compFields;
     if (msgCompFields)
     {
       Recipients2CompFields(msgCompFields);
+      msgCompFields.from = GetMsgIdentityElement().value;
       var subject = GetMsgSubjectElement().value;
       msgCompFields.subject = subject;
       Attachments2CompFields(msgCompFields);
 
       if (msgType == nsIMsgCompDeliverMode.Now ||
           msgType == nsIMsgCompDeliverMode.Later ||
           msgType == nsIMsgCompDeliverMode.Background)
       {
@@ -1888,47 +1892,54 @@ function FillIdentityList(menulist)
                                          Components.interfaces.nsIMsgIdentity));
 
     if (identities.length == 0)
       continue;
 
     for (let i = 0; i < identities.length; i++)
     {
       let identity = identities[i];
-      let item = menulist.appendItem(identity.identityName, identity.key,
+      let item = menulist.appendItem(identity.identityName,
+                                     identity.identityName,
                                      account.incomingServer.prettyName);
+      item.setAttribute("identitykey", identity.key);
       item.setAttribute("accountkey", account.key);
       if (i == 0)
       {
         // Mark the first identity as default.
         item.setAttribute("default", "true");
       }
     }
   }
 }
 
-function getCurrentIdentity()
-{
-  // fill in Identity combobox
-  var identityKey = GetMsgIdentityElement().value;
-  return gAccountManager.getIdentity(identityKey);
-}
-
 function getCurrentAccountKey()
 {
     // get the accounts key
     var identityList = GetMsgIdentityElement();
     return identityList.selectedItem.getAttribute("accountkey");
 }
 
+function getCurrentIdentityKey()
+{
+    // get the identity key
+    var identityList = GetMsgIdentityElement();
+    return identityList.selectedItem.getAttribute("identitykey");
+}
+
 function getIdentityForKey(key)
 {
     return gAccountManager.getIdentity(key);
 }
 
+function getCurrentIdentity()
+{
+  return getIdentityForKey(getCurrentIdentityKey());
+}
+
 function AdjustFocus()
 {
   var element = awGetInputElement(awGetNumberOfRecipients());
   if (element.value == "") {
       awSetFocus(awGetNumberOfRecipients(), element);
   }
   else
   {
@@ -2364,17 +2375,17 @@ function DetermineConvertibility()
 }
 
 function LoadIdentity(startup)
 {
     var identityElement = GetMsgIdentityElement();
     var prevIdentity = gCurrentIdentity;
 
     if (identityElement) {
-        var idKey = identityElement.value;
+        var idKey = identityElement.selectedItem.getAttribute("identitykey");
         gCurrentIdentity = gAccountManager.getIdentity(idKey);
 
         let accountKey = null;
         if (identityElement.selectedItem)
           accountKey = identityElement.selectedItem.getAttribute("accountkey");
 
         let maxRecipients = awGetMaxRecipients();
         for (let i = 1; i <= maxRecipients; i++)
--- a/suite/mailnews/compose/messengercompose.xul
+++ b/suite/mailnews/compose/messengercompose.xul
@@ -547,17 +547,18 @@
              flex="1"
              grippytooltiptext="&addressBar.tooltip;"
              nowindowdrag="true">
       <hbox id="msgheaderstoolbar-box" flex="1">
         <vbox id="addresses-box" flex="1">
           <hbox align="center">
             <label value="&fromAddr.label;" accesskey="&fromAddr.accesskey;" control="msgIdentity"/>
             <menulist id="msgIdentity"
-                      type="description"
+                      editable="true"
+                      disableautoselect="true"
                       flex="1"
                       oncommand="LoadIdentity(false);">
               <menupopup id="msgIdentityPopup"/>
             </menulist>
           </hbox>
           <listbox id="addressingWidget" flex="1"/>
           <hbox align="center">
             <label value="&subject.label;" accesskey="&subject.accesskey;" control="msgSubject"/>