This is just some static backup of the original site, don't expect every link to work!

Changeset 623401


Ignore:
Timestamp:
Nov 9, 2011, 2:08:14 PM (11 years ago)
Author:
rene <rene@…>
Branches:
ng_0.9
Children:
184c6c
Parents:
5d26a6
Message:

cleanup and change for new conversation plugin

File:
1 edited

Legend:

Unmodified
Added
Removed
  • chrome/content/v_identity/modules/plugins/conversation.js

    r5d26a6 r623401  
    1515  .getService(Ci.nsIMsgHeaderParser);
    1616
    17 let virtualIdentityData;
    18 let virtualIdSenderName;
     17let currentIdentityData;
     18let currentIdSenderName;
    1919let virtualIdInUse;
    2020let virtualSenderNameElem;
     
    2828let _changeIdentityToSmartIdentity = function(identityData) {
    2929  Log.debug("## changeIdentityToSmartIdentity\n");
    30   // add code to set stored base identity
     30 
    3131  if ( identityData.id.key != null ) {
    3232    currentParams.identity = AccountManager.getIdentity(identityData.id.key);
    3333    Log.debug("## changed base identity to ", identityData.id.key);
    34     virtualSenderNameElem.text(virtualIdSenderName);
     34    virtualSenderNameElem.text(currentIdSenderName);
    3535  }
    3636  virtualIdInUse = !(identityData.isExistingIdentity(false));
    3737  Log.debug("## changeIdentityToSmartIdentity virtualIdInUse=" + virtualIdInUse + "\n");
    3838  if (virtualIdInUse) {
    39     virtualIdentityData = identityData;
    40     virtualIdSenderName = virtualIdentityData.combinedName;
     39    currentIdentityData = identityData;
     40    currentIdSenderName = currentIdentityData.combinedName;
    4141  }
    4242  virtualSenderNameElem.text(identityData.combinedName); // change this also to reflect changes of base id
     
    4444
    4545let conversationHook = {
    46   onComposeSessionConstructDone: function (recipientString, params, senderNameElem, ExternalLog) {
    47     // this.params = { identity: ???, msgHdr: ???, subject: ??? };
     46  onComposeSessionChanged: function (aComposeSession, aAddress, ExternalLog) {
    4847    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;
    5258   
    5359    let recipients = []; var combinedNames = {}; var number;
    54     number = HeaderParser.parseHeadersWithArray(recipientString, {}, {}, combinedNames);
     60    number = HeaderParser.parseHeadersWithArray(toAddrList.join(", "), {}, {}, combinedNames);
    5561    for (var index = 0; index < number; index++)
    5662      recipients.push( { recipient: combinedNames.value[index], recipientType: "addr_to" } )
    5763     
    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);
    5966    localSmartIdentityCollection.Reply();   // we can always use the reply-case, msgHdr is set the right way
    6067   
    61     if (localSmartIdentityCollection._allIdentities.number == 0) return;
     68    if (localSmartIdentityCollection._allIdentities.number == 0)
     69      return;
    6270 
    6371    if (pref.getBoolPref("idSelection_preferExisting")) {
     
    7886          /* callback: */ changeIdentityToSmartIdentity).focus();
    7987      }
    80     else if (pref.getBoolPref("idSelection_autocreate")) changeIdentityToSmartIdentity(localSmartIdentityCollection._allIdentities, 0);
     88    else if (pref.getBoolPref("idSelection_autocreate"))
     89      changeIdentityToSmartIdentity(localSmartIdentityCollection._allIdentities, 0);
    8190  },
    8291 
    83   onMessageBeforeSendOrPopup: function(gComposeParams, recipientString, popOut, aStatus, ExternalLog) {
     92  onMessageBeforeSendOrPopout: function(aAddress, aStatus, aPopout, ExternalLog) {
    8493    Log = ExternalLog;
    85     Log.debug("## onMessageBeforeSendOrPopup", recipientString);
     94    let toAddrList = aAddress.to.concat(aAddress.cc);
     95    Log.debug("## onMessageBeforeSendOrPopup");
    8696   
    8797    if (virtualIdInUse) {
    88       if (!popOut) {
     98      if (!aPopout) {
    8999        let recipients = []; var combinedNames = {}; var number;
    90         number = HeaderParser.parseHeadersWithArray(recipientString, {}, {}, combinedNames);
     100        number = HeaderParser.parseHeadersWithArray(toAddrList.join(", "), {}, {}, combinedNames);
    91101        for (var index = 0; index < number; index++)
    92102          recipients.push( { recipient: combinedNames.value[index], recipientType: "addr_to" } )
    93103
    94104        returnValue = vI.prepareSendMsg(virtualIdInUse, Ci.nsIMsgCompDeliverMode.Now,
    95           virtualIdentityData, gComposeParams.identity, recipients );
     105          currentIdentityData, aAddress.params.identity, recipients );
    96106        Log.debug("returnValue.update:", returnValue.update);
    97107       
     
    104114        }
    105115       
    106         gComposeParams.identity = vI.account._account.defaultIdentity
    107         if (!vI.finalCheck(virtualIdentityData, gComposeParams.identity)) {
     116        aAddress.params.identity = vI.account._account.defaultIdentity
     117        if (!vI.finalCheck(currentIdentityData, aAddress.params.identity)) {
    108118          vI.account.removeUsedVIAccount();
    109119          aStatus.canceled = true; return aStatus;
     
    112122      else {
    113123        // 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);
    116126      }
    117127    }
     
    125135  },
    126136
    127   onRecipientAdded: function onRecipientAdded(recipient, recipientType, count, ExternalLog) {
     137  onRecipientAdded: function onRecipientAdded(aData, aType, aCount, ExternalLog) {
    128138    Log = ExternalLog;
    129     Log.debug("onRecipientAdded", recipient, recipientType, count);
     139   
     140    Log.debug("onRecipientAdded", aData.data, aType, aCount);
    130141    if (!pref.getBoolPref("storage")) return;
    131     if (recipientType == "bcc") return;
    132     if (recipient == "") return;
     142    if (aType == "bcc") return;
     143    if (aData.data == "") return;
    133144
    134145    // 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);
    136147    Log.debug("onRecipientAdded isNotFirstInputElement", isNotFirstInputElement);
    137148   
     
    139150    else _rdfDatasourceAccess.clean();
    140151   
    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);
    143154   
    144155    if (storageResult.identityCollection.number == 0) return; // return if there was no match
Note: See TracChangeset for help on using the changeset viewer.