Changeset 623401
- Timestamp:
- Nov 9, 2011, 2:08:14 PM (11 years ago)
- Branches:
- ng_0.9
- Children:
- 184c6c
- Parents:
- 5d26a6
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
chrome/content/v_identity/modules/plugins/conversation.js
r5d26a6 r623401 15 15 .getService(Ci.nsIMsgHeaderParser); 16 16 17 let virtualIdentityData;18 let virtualIdSenderName;17 let currentIdentityData; 18 let currentIdSenderName; 19 19 let virtualIdInUse; 20 20 let virtualSenderNameElem; … … 28 28 let _changeIdentityToSmartIdentity = function(identityData) { 29 29 Log.debug("## changeIdentityToSmartIdentity\n"); 30 // add code to set stored base identity30 31 31 if ( identityData.id.key != null ) { 32 32 currentParams.identity = AccountManager.getIdentity(identityData.id.key); 33 33 Log.debug("## changed base identity to ", identityData.id.key); 34 virtualSenderNameElem.text( virtualIdSenderName);34 virtualSenderNameElem.text(currentIdSenderName); 35 35 } 36 36 virtualIdInUse = !(identityData.isExistingIdentity(false)); 37 37 Log.debug("## changeIdentityToSmartIdentity virtualIdInUse=" + virtualIdInUse + "\n"); 38 38 if (virtualIdInUse) { 39 virtualIdentityData = identityData;40 virtualIdSenderName = virtualIdentityData.combinedName;39 currentIdentityData = identityData; 40 currentIdSenderName = currentIdentityData.combinedName; 41 41 } 42 42 virtualSenderNameElem.text(identityData.combinedName); // change this also to reflect changes of base id … … 44 44 45 45 let conversationHook = { 46 onComposeSessionConstructDone: function (recipientString, params, senderNameElem, ExternalLog) { 47 // this.params = { identity: ???, msgHdr: ???, subject: ??? }; 46 onComposeSessionChanged: function (aComposeSession, aAddress, ExternalLog) { 48 47 Log = ExternalLog; 49 50 currentParams = params; virtualSenderNameElem = senderNameElem; // to enable access from out of this class. 51 virtualIdentityData = null; virtualIdInUse = false; virtualIdSenderName = ""; 48 let toAddrList = aAddress.to.concat(aAddress.cc); 49 50 currentParams = aComposeSession.params; virtualSenderNameElem = aComposeSession.senderNameElem; // to enable access from out of this class. 51 let identity = aComposeSession.params.identity; 52 53 let server = AccountManager.GetServersForIdentity(identity).QueryElementAt(0, Components.interfaces.nsIMsgIncomingServer); 54 currentIdentityData = new virtualIdentityExtension.identityData(identity.email, identity.fullName, identity.key, 55 identity.smtpServerKey, null, server.prettyName, true) 56 currentIdSenderName = currentIdentityData.combinedName; 57 virtualIdInUse = false; 52 58 53 59 let recipients = []; var combinedNames = {}; var number; 54 number = HeaderParser.parseHeadersWithArray( recipientString, {}, {}, combinedNames);60 number = HeaderParser.parseHeadersWithArray(toAddrList.join(", "), {}, {}, combinedNames); 55 61 for (var index = 0; index < number; index++) 56 62 recipients.push( { recipient: combinedNames.value[index], recipientType: "addr_to" } ) 57 63 58 var localSmartIdentityCollection = new vI.smartIdentityCollection(params.msgHdr, params.identity, false, false, recipients); 64 var localSmartIdentityCollection = new vI.smartIdentityCollection(aComposeSession.params.msgHdr, identity, 65 false, false, recipients); 59 66 localSmartIdentityCollection.Reply(); // we can always use the reply-case, msgHdr is set the right way 60 67 61 if (localSmartIdentityCollection._allIdentities.number == 0) return; 68 if (localSmartIdentityCollection._allIdentities.number == 0) 69 return; 62 70 63 71 if (pref.getBoolPref("idSelection_preferExisting")) { … … 78 86 /* callback: */ changeIdentityToSmartIdentity).focus(); 79 87 } 80 else if (pref.getBoolPref("idSelection_autocreate")) changeIdentityToSmartIdentity(localSmartIdentityCollection._allIdentities, 0); 88 else if (pref.getBoolPref("idSelection_autocreate")) 89 changeIdentityToSmartIdentity(localSmartIdentityCollection._allIdentities, 0); 81 90 }, 82 91 83 onMessageBeforeSendOrPop up: function(gComposeParams, recipientString, popOut, aStatus, ExternalLog) {92 onMessageBeforeSendOrPopout: function(aAddress, aStatus, aPopout, ExternalLog) { 84 93 Log = ExternalLog; 85 Log.debug("## onMessageBeforeSendOrPopup", recipientString); 94 let toAddrList = aAddress.to.concat(aAddress.cc); 95 Log.debug("## onMessageBeforeSendOrPopup"); 86 96 87 97 if (virtualIdInUse) { 88 if (! popOut) {98 if (!aPopout) { 89 99 let recipients = []; var combinedNames = {}; var number; 90 number = HeaderParser.parseHeadersWithArray( recipientString, {}, {}, combinedNames);100 number = HeaderParser.parseHeadersWithArray(toAddrList.join(", "), {}, {}, combinedNames); 91 101 for (var index = 0; index < number; index++) 92 102 recipients.push( { recipient: combinedNames.value[index], recipientType: "addr_to" } ) 93 103 94 104 returnValue = vI.prepareSendMsg(virtualIdInUse, Ci.nsIMsgCompDeliverMode.Now, 95 virtualIdentityData, gComposeParams.identity, recipients );105 currentIdentityData, aAddress.params.identity, recipients ); 96 106 Log.debug("returnValue.update:", returnValue.update); 97 107 … … 104 114 } 105 115 106 gComposeParams.identity = vI.account._account.defaultIdentity107 if (!vI.finalCheck( virtualIdentityData, gComposeParams.identity)) {116 aAddress.params.identity = vI.account._account.defaultIdentity 117 if (!vI.finalCheck(currentIdentityData, aAddress.params.identity)) { 108 118 vI.account.removeUsedVIAccount(); 109 119 aStatus.canceled = true; return aStatus; … … 112 122 else { 113 123 // code virtual Identity into subject - this will be decoded by smartIdentity - newMail 114 gComposeParams.subject = gComposeParams.subject + "\nvirtualIdentityExtension\n" + virtualIdSenderName;115 Log.debug("coding virtualIdentity into subject:", gComposeParams.subject);124 aAddress.params.subject = aAddress.params.subject + "\nvirtualIdentityExtension\n" + currentIdSenderName; 125 Log.debug("coding virtualIdentity into subject:", aAddress.params.subject); 116 126 } 117 127 } … … 125 135 }, 126 136 127 onRecipientAdded: function onRecipientAdded( recipient, recipientType, count, ExternalLog) {137 onRecipientAdded: function onRecipientAdded(aData, aType, aCount, ExternalLog) { 128 138 Log = ExternalLog; 129 Log.debug("onRecipientAdded", recipient, recipientType, count); 139 140 Log.debug("onRecipientAdded", aData.data, aType, aCount); 130 141 if (!pref.getBoolPref("storage")) return; 131 if ( recipientType == "bcc") return;132 if ( recipient== "") return;142 if (aType == "bcc") return; 143 if (aData.data == "") return; 133 144 134 145 // if we are editing the "cc" or not the first recipient, recognize this. 135 var isNotFirstInputElement = !( recipientType == "to" && count == 0);146 var isNotFirstInputElement = !(aType == "to" && aCount == 0); 136 147 Log.debug("onRecipientAdded isNotFirstInputElement", isNotFirstInputElement); 137 148 … … 139 150 else _rdfDatasourceAccess.clean(); 140 151 141 var storageResult = _rdfDatasourceAccess.updateVIdentityFromStorage( recipient, "addr_to",142 virtualIdentityData, virtualIdInUse, isNotFirstInputElement);152 var storageResult = _rdfDatasourceAccess.updateVIdentityFromStorage(aData.data, "addr_to", 153 currentIdentityData, virtualIdInUse, isNotFirstInputElement); 143 154 144 155 if (storageResult.identityCollection.number == 0) return; // return if there was no match
Note: See TracChangeset
for help on using the changeset viewer.