Changeset 1e908e


Ignore:
Timestamp:
Oct 2, 2011, 3:00:46 PM (9 years ago)
Author:
rene <rene@…>
Branches:
ng_0.9
Children:
1ddff2
Parents:
18554f
Message:

update of conversation plugin

File:
1 edited

Legend:

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

    r18554f r1e908e  
    99  .getBranch("extensions.virtualIdentity.");
    1010
    11 const gHeaderParser = Cc["@mozilla.org/messenger/headerparser;1"]
     11const AccountManager = Cc["@mozilla.org/messenger/account-manager;1"]
     12  .getService(Components.interfaces.nsIMsgAccountManager);
     13 
     14const HeaderParser = Cc["@mozilla.org/messenger/headerparser;1"]
    1215  .getService(Ci.nsIMsgHeaderParser);
    1316
     
    2528function _changeIdentityToSmartIdentity(identityData) {
    2629  Log.debug("## changeIdentityToSmartIdentity\n");
     30  // add code to set stored base identity
     31  if ( identityData.id.key != null ) {
     32    currentParams.identity = AccountManager.getIdentity(identityData.id.key);
     33    Log.debug("## changed base identity to ", identityData.id.key);
     34    virtualSenderNameElem.text(virtualIdSenderName);
     35  }
    2736  virtualIdInUse = !(identityData.isExistingIdentity(false));
    2837  Log.debug("## changeIdentityToSmartIdentity virtualIdInUse=" + virtualIdInUse + "\n");
    2938  if (virtualIdInUse) {
    3039    virtualIdentityData = identityData;
    31     virtualIdSenderName = gHeaderParser.makeFullAddress(virtualIdentityData.fullName, virtualIdentityData.email)
    32     virtualSenderNameElem.text(virtualIdSenderName);
     40    virtualIdSenderName = virtualIdentityData.combinedName;
    3341  }
     42  virtualSenderNameElem.text(identityData.combinedName); // change this also to reflect changes of base id
    3443}
    3544
    3645let conversationHook = {
    37   onComposePrepared: function (aMsgHdr, gComposeParams, senderNameElem, ExternalLog) {
     46  onComposeSessionConstructDone: function (params, match, senderNameElem, ExternalLog) {
     47    // this.params = { identity: ???, msgHdr: ???, subject: ??? };
    3848    Log = ExternalLog;
     49
     50    currentParams = params; virtualSenderNameElem = senderNameElem; // to enable access from out of this class.
    3951    virtualIdentityData = null; virtualIdInUse = false; virtualIdSenderName = "";
    40     virtualSenderNameElem = senderNameElem;
    4152   
    42     let recipients = [];
    43     for each (let [i, { name, email }] in Iterator(gComposeParams.to))
    44       recipients.push( { recipient: gHeaderParser.makeFullAddress(name, email), recipientType: "addr_to" } )
    45     for each (let [i, { name, email }] in Iterator(gComposeParams.cc))
    46       recipients.push( { recipient: gHeaderParser.makeFullAddress(name, email), recipientType: "addr_to" } )
     53   
     54    let recipientString = params.msgHdr.mime2DecodedRecipients;
     55    if (params.identity.doCc) recipientString += "," + params.identity.doCcList;
     56    recipientString += "," + params.msgHdr.ccList;
     57   
     58    let recipients = []; var combinedNames = {}; var number;
     59    number = HeaderParser.parseHeadersWithArray(recipientString, {}, {}, combinedNames);
     60    for (var index = 0; index < number; index++)
     61      recipients.push( { recipient: combinedNames.value[index], recipientType: "addr_to" } )
    4762 
    48     var localSmartIdentityCollection = new vI.smartIdentityCollection(aMsgHdr, gComposeParams.identity, false, false, recipients);
    49     localSmartIdentityCollection.Reply();
    50  
     63/*    match({
     64      reply: function (aMessage, aReplyType) {
     65        if (aReplyType == "replyAll") { // if we reply to all then take care of all the recipients
     66
     67          Log.debug("replyAll - adding cc recipients too");
     68          number = HeaderParser.parseHeadersWithArray(params.msgHdr.ccList, {}, {}, combinedNames);
     69          for (var index = 0; index < number; index++)
     70            recipients.push( { recipient: combinedNames.value[index], recipientType: "addr_to" } )
     71        }
     72      },
     73      draft: function ({ msgUri }) { Log.debug("match draft - currently not used", msgUri); }
     74    });*/
     75     
     76    var localSmartIdentityCollection = new vI.smartIdentityCollection(params.msgHdr, params.identity, false, false, recipients);
     77    localSmartIdentityCollection.Reply();   // we can always use the reply-case, msgHdr is set the right way
     78   
    5179    if (localSmartIdentityCollection._allIdentities.number == 0) return;
    5280 
     
    7199  },
    72100 
    73   onUIupdated: function() {
    74     virtualSenderNameElem.text(virtualIdSenderName);
    75     Log.debug("onUIupdated done");
    76   },
    77 
    78   onSendMessage: function(gComposeParams, toVal, ccVal, popOut, ExternalLog) {
     101  onMessageBeforeSendOrPopup: function(gComposeParams, recipientString, popOut, aStatus, ExternalLog) {
    79102    Log = ExternalLog;
    80     Log.debug("toVal='" + toVal + "' ccVal='" + ccVal + "' gComposeParams.to='" + gComposeParams.to + "'\n" );
    81 
     103    Log.debug("## onMessageBeforeSendOrPopup", recipientString);
     104   
    82105    if (virtualIdInUse) {
    83106      if (!popOut) {
    84107        let recipients = []; var combinedNames = {}; var number;
    85         number = gHeaderParser.parseHeadersWithArray(toVal + "," + ccVal, {}, {}, combinedNames);
     108        number = HeaderParser.parseHeadersWithArray(recipientString, {}, {}, combinedNames);
    86109        for (var index = 0; index < number; index++)
    87110          recipients.push( { recipient: combinedNames.value[index], recipientType: "addr_to" } )
     
    91114        Log.debug("returnValue.update:", returnValue.update);
    92115       
    93         if (returnValue.update == "abort") return false;
     116        if (returnValue.update == "abort") {
     117          aStatus.canceled = true; return aStatus;
     118        }
    94119        else if (returnValue.update == "takeover") {
    95120          _changeIdentityToSmartIdentity(returnValue.storedIdentity);
    96           return false;
     121          aStatus.canceled = true; return aStatus;
    97122        }
    98123       
     
    100125        if (!vI.finalCheck(virtualIdentityData, gComposeParams.identity)) {
    101126          vI.account.removeUsedVIAccount();
    102           return false
     127          aStatus.canceled = true; return aStatus;
    103128        }
    104129      }
     
    110135    }
    111136    Log.debug("onSendMessage done");
    112     return true;
     137    return aStatus;
    113138  },
    114139 
     
    126151
    127152    // if we are editing the "cc" or not the first recipient, recognize this.
    128     var isNotFirstInputElement = (recipientType != "to" || count == 0);
     153    var isNotFirstInputElement = !(recipientType == "to" && count == 0);
     154    Log.debug("onRecipientAdded isNotFirstInputElement", isNotFirstInputElement);
    129155   
    130156    if (!_rdfDatasourceAccess) _rdfDatasourceAccess = new vI.rdfDatasourceAccess();
Note: See TracChangeset for help on using the changeset viewer.