Changeset 509348 for modules/plugins/conversations.js
- Timestamp:
- Nov 3, 2014, 12:35:40 PM (8 years ago)
- Branches:
- ng_0.9
- Children:
- 7204cb
- Parents:
- 3c9c29
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
modules/plugins/conversations.js
r3c9c29 r509348 22 22 Contributor(s): 23 23 * ***** END LICENSE BLOCK ***** */ 24 24 25 25 var EXPORTED_SYMBOLS = []; 26 26 27 const {classes: Cc, interfaces: Ci, utils: Cu, results : Cr} = Components; 27 const { 28 classes: Cc, 29 interfaces: Ci, 30 utils: Cu, 31 results: Cr 32 } = Components; 28 33 29 34 Cu.import("resource://v_identity/vI_log.js"); … … 38 43 const AccountManager = Cc["@mozilla.org/messenger/account-manager;1"] 39 44 .getService(Components.interfaces.nsIMsgAccountManager); 40 45 41 46 const HeaderParser = Cc["@mozilla.org/messenger/headerparser;1"] 42 47 .getService(Ci.nsIMsgHeaderParser); … … 49 54 let _rdfDatasourceAccess; 50 55 51 let changeIdentityToSmartIdentity = function (allIdentities, index) {56 let changeIdentityToSmartIdentity = function (allIdentities, index) { 52 57 _changeIdentityToSmartIdentity(allIdentities.identityDataCollection[index]); 53 58 }; 54 59 55 let _changeIdentityToSmartIdentity = function (identityData) {60 let _changeIdentityToSmartIdentity = function (identityData) { 56 61 Log.debug("changeIdentityToSmartIdentity"); 57 58 if ( identityData.id.key != null) {62 63 if (identityData.id.key != null) { 59 64 currentParams.identity = AccountManager.getIdentity(identityData.id.key); 60 65 Log.debug("changed base identity to ", identityData.id.key); … … 73 78 onComposeSessionChanged: function _virtualIdentityHook_onComposeSessionChanged(aComposeSession, aMessage, aAddress) { 74 79 let toAddrList = aAddress.to.concat(aAddress.cc); 75 76 currentParams = aComposeSession.params; virtualSenderNameElem = aComposeSession.senderNameElem; // to enable access from out of this class. 80 81 currentParams = aComposeSession.params; 82 virtualSenderNameElem = aComposeSession.senderNameElem; // to enable access from out of this class. 77 83 let identity = aComposeSession.params.identity; 78 79 if (typeof (this._AccountManager.getServersForIdentity) == 'function') { // new style80 84 85 if (typeof (this._AccountManager.getServersForIdentity) == 'function') { // new style 86 let server = this._AccountManager.getServersForIdentity(identity).queryElementAt(0, Components.interfaces.nsIMsgIncomingServer); 81 87 } else { 82 88 let server = this._AccountManager.GetServersForIdentity(identity).QueryElementAt(0, Components.interfaces.nsIMsgIncomingServer); 83 89 } 84 90 85 91 currentIdentityData = new identityData(identity.email, identity.fullName, identity.key, 86 92 identity.smtpServerKey, null, server.prettyName, true) 87 93 currentIdSenderName = currentIdentityData.combinedName; 88 94 virtualIdInUse = false; 89 90 let recipients = []; var combinedNames = {}; var number; 95 96 let recipients = []; 97 var combinedNames = {}; 98 var number; 91 99 number = HeaderParser.parseHeadersWithArray(toAddrList.join(", "), {}, {}, combinedNames); 92 100 for (var index = 0; index < number; index++) 93 recipients.push( { recipient: combinedNames.value[index], recipientType: "addr_to" } ) 94 95 var localSmartIdentityCollection = new smartIdentityCollection(aComposeSession.params.msgHdr, identity, 96 false, false, recipients); 97 localSmartIdentityCollection.Reply(); // we can always use the reply-case, msgHdr is set the right way 98 101 recipients.push({ 102 recipient: combinedNames.value[index], 103 recipientType: "addr_to" 104 }) 105 106 var localSmartIdentityCollection = new smartIdentityCollection(aComposeSession.params.msgHdr, identity, 107 false, false, recipients); 108 localSmartIdentityCollection.Reply(); // we can always use the reply-case, msgHdr is set the right way 109 99 110 if (localSmartIdentityCollection._allIdentities.number == 0) 100 111 return; 101 112 102 113 if (vIprefs.get("idSelection_preferExisting")) { 103 114 var existingIDIndex = localSmartIdentityCollection._foundExistingIdentity(); … … 109 120 } 110 121 111 if (vIprefs.get("idSelection_ask") && 112 ((localSmartIdentityCollection._allIdentities.number == 1 && vIprefs.get("idSelection_ask_always")) 113 || localSmartIdentityCollection._allIdentities.number > 1)) { 114 recentWindow = Cc["@mozilla.org/appshell/window-mediator;1"] 115 .getService(Ci.nsIWindowMediator) 116 .getMostRecentWindow("mail:3pane"); 117 118 recentWindow.openDialog("chrome://v_identity/content/vI_smartReplyDialog.xul",0, 119 "chrome, dialog, modal, alwaysRaised, resizable=yes", 120 localSmartIdentityCollection._allIdentities, 121 /* callback: */ changeIdentityToSmartIdentity).focus(); 122 } 123 else if (vIprefs.get("idSelection_autocreate")) 122 if (vIprefs.get("idSelection_ask") && 123 ((localSmartIdentityCollection._allIdentities.number == 1 && vIprefs.get("idSelection_ask_always")) || localSmartIdentityCollection._allIdentities.number > 1)) { 124 recentWindow = Cc["@mozilla.org/appshell/window-mediator;1"] 125 .getService(Ci.nsIWindowMediator) 126 .getMostRecentWindow("mail:3pane"); 127 128 recentWindow.openDialog("chrome://v_identity/content/vI_smartReplyDialog.xul", 0, 129 "chrome, dialog, modal, alwaysRaised, resizable=yes", 130 localSmartIdentityCollection._allIdentities, 131 /* callback: */ 132 changeIdentityToSmartIdentity).focus(); 133 } else if (vIprefs.get("idSelection_autocreate")) 124 134 changeIdentityToSmartIdentity(localSmartIdentityCollection._allIdentities, 0); 125 135 }, 126 136 127 137 onMessageBeforeSendOrPopout_canceled: function _enigmailHook_onMessageBeforeSendOrPopout_canceledy(aAddress, aEditor, aStatus, aPopout) { 128 138 Log.debug("onMessageBeforeSendOrPopout_canceled"); … … 141 151 let toAddrList = aAddress.to.concat(aAddress.cc); 142 152 Log.debug("onMessageBeforeSendOrPopup_early"); 143 153 144 154 if (virtualIdInUse) { 145 155 if (!aPopout) { 146 let recipients = []; var combinedNames = {}; var number; 156 let recipients = []; 157 var combinedNames = {}; 158 var number; 147 159 number = HeaderParser.parseHeadersWithArray(toAddrList.join(", "), {}, {}, combinedNames); 148 160 for (var index = 0; index < number; index++) 149 recipients.push( { recipient: combinedNames.value[index], recipientType: "addr_to" } ) 150 161 recipients.push({ 162 recipient: combinedNames.value[index], 163 recipientType: "addr_to" 164 }) 165 151 166 let recentWindow = Cc["@mozilla.org/appshell/window-mediator;1"] 152 167 .getService(Ci.nsIWindowMediator) 153 168 .getMostRecentWindow("mail:3pane"); 154 169 155 170 returnValue = vIaccount_prepareSendMsg(virtualIdInUse, Ci.nsIMsgCompDeliverMode.Now, 156 171 currentIdentityData, aAddress.params.identity, recipients, recentWindow); 157 172 Log.debug("returnValue.update:", returnValue.update); 158 173 159 174 if (returnValue.update == "abort") { 160 aStatus.canceled = true; return aStatus; 175 aStatus.canceled = true; 176 return aStatus; 177 } else if (returnValue.update == "takeover") { 178 _changeIdentityToSmartIdentity(returnValue.storedIdentity); 179 aStatus.canceled = true; 180 return aStatus; 161 181 } 162 else if (returnValue.update == "takeover") { 163 _changeIdentityToSmartIdentity(returnValue.storedIdentity); 164 aStatus.canceled = true; return aStatus; 165 } 166 182 167 183 aAddress.params.identity = get_vIaccount().defaultIdentity; 168 184 if (!vIaccount_finalCheck(currentIdentityData, aAddress.params.identity)) { 169 185 vIaccount_removeUsedVIAccount(); 170 aStatus.canceled = true; return aStatus; 186 aStatus.canceled = true; 187 return aStatus; 171 188 } 172 } 173 else { 189 } else { 174 190 // code virtual Identity into subject - this will be decoded by smartIdentity - newMail 175 191 aAddress.params.subject = aAddress.params.subject + "\nvirtualIdentityExtension\n" + currentIdSenderName; … … 180 196 return aStatus; 181 197 }, 182 198 183 199 onStopSending: function _virtualIdentityHook_onStopSending(aMsgID, aStatus, aMsg, aReturnFile) { 184 200 vIaccount_removeUsedVIAccount(); … … 195 211 var isNotFirstInputElement = !(aType == "to" && aCount == 0); 196 212 Log.debug("onRecipientAdded isNotFirstInputElement", isNotFirstInputElement); 197 213 198 214 if (!_rdfDatasourceAccess) _rdfDatasourceAccess = new rdfDatasourceAccess(); 199 215 else _rdfDatasourceAccess.clean(); 200 216 201 217 let recentWindow = Cc["@mozilla.org/appshell/window-mediator;1"] 202 203 218 .getService(Ci.nsIWindowMediator) 219 .getMostRecentWindow("mail:3pane"); 204 220 205 221 var storageResult = _rdfDatasourceAccess.updateVIdentityFromStorage(aData.data, "addr_to", 206 222 currentIdentityData, virtualIdInUse, isNotFirstInputElement, recentWindow); 207 223 208 224 if (storageResult.identityCollection.number == 0) return; // return if there was no match 209 225 if (storageResult.result != "accept") return; // return if we don't like the resulting id 210 226 211 227 changeIdentityToSmartIdentity(storageResult.identityCollection, 0); 212 228 } … … 222 238 registerHook(virtualIdentityHook); 223 239 }, false); 224 } 225 catch(e) { 240 } catch (e) { 226 241 Log.debug("virtualIdentity is ready for conversations, but you don't use it"); 227 242 }
Note: See TracChangeset
for help on using the changeset viewer.