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

Ignore:
Timestamp:
Nov 3, 2014, 12:35:40 PM (8 years ago)
Author:
rene <rene@…>
Branches:
ng_0.9
Children:
7204cb
Parents:
3c9c29
Message:

code formatting (no code changes)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • modules/plugins/conversations.js

    r3c9c29 r509348  
    2222    Contributor(s):
    2323 * ***** END LICENSE BLOCK ***** */
    24  
     24
    2525var EXPORTED_SYMBOLS = [];
    2626
    27 const {classes: Cc, interfaces: Ci, utils: Cu, results : Cr} = Components;
     27const {
     28  classes: Cc,
     29  interfaces: Ci,
     30  utils: Cu,
     31  results: Cr
     32} = Components;
    2833
    2934Cu.import("resource://v_identity/vI_log.js");
     
    3843const AccountManager = Cc["@mozilla.org/messenger/account-manager;1"]
    3944  .getService(Components.interfaces.nsIMsgAccountManager);
    40  
     45
    4146const HeaderParser = Cc["@mozilla.org/messenger/headerparser;1"]
    4247  .getService(Ci.nsIMsgHeaderParser);
     
    4954let _rdfDatasourceAccess;
    5055
    51 let changeIdentityToSmartIdentity = function(allIdentities, index) {
     56let changeIdentityToSmartIdentity = function (allIdentities, index) {
    5257  _changeIdentityToSmartIdentity(allIdentities.identityDataCollection[index]);
    5358};
    5459
    55 let _changeIdentityToSmartIdentity = function(identityData) {
     60let _changeIdentityToSmartIdentity = function (identityData) {
    5661  Log.debug("changeIdentityToSmartIdentity");
    57  
    58   if ( identityData.id.key != null ) {
     62
     63  if (identityData.id.key != null) {
    5964    currentParams.identity = AccountManager.getIdentity(identityData.id.key);
    6065    Log.debug("changed base identity to ", identityData.id.key);
     
    7378  onComposeSessionChanged: function _virtualIdentityHook_onComposeSessionChanged(aComposeSession, aMessage, aAddress) {
    7479    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.
    7783    let identity = aComposeSession.params.identity;
    78    
    79     if (typeof(this._AccountManager.getServersForIdentity) == 'function') { // new style
    80         let server = this._AccountManager.getServersForIdentity(identity).queryElementAt(0, Components.interfaces.nsIMsgIncomingServer);
     84
     85    if (typeof (this._AccountManager.getServersForIdentity) == 'function') { // new style
     86      let server = this._AccountManager.getServersForIdentity(identity).queryElementAt(0, Components.interfaces.nsIMsgIncomingServer);
    8187    } else {
    82         let server = this._AccountManager.GetServersForIdentity(identity).QueryElementAt(0, Components.interfaces.nsIMsgIncomingServer);
     88      let server = this._AccountManager.GetServersForIdentity(identity).QueryElementAt(0, Components.interfaces.nsIMsgIncomingServer);
    8389    }
    8490
    8591    currentIdentityData = new identityData(identity.email, identity.fullName, identity.key,
    86                                                                     identity.smtpServerKey, null, server.prettyName, true)
     92      identity.smtpServerKey, null, server.prettyName, true)
    8793    currentIdSenderName = currentIdentityData.combinedName;
    8894    virtualIdInUse = false;
    89    
    90     let recipients = []; var combinedNames = {}; var number;
     95
     96    let recipients = [];
     97    var combinedNames = {};
     98    var number;
    9199    number = HeaderParser.parseHeadersWithArray(toAddrList.join(", "), {}, {}, combinedNames);
    92100    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
    99110    if (localSmartIdentityCollection._allIdentities.number == 0)
    100111      return;
    101  
     112
    102113    if (vIprefs.get("idSelection_preferExisting")) {
    103114      var existingIDIndex = localSmartIdentityCollection._foundExistingIdentity();
     
    109120    }
    110121
    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"))
    124134      changeIdentityToSmartIdentity(localSmartIdentityCollection._allIdentities, 0);
    125135  },
    126  
     136
    127137  onMessageBeforeSendOrPopout_canceled: function _enigmailHook_onMessageBeforeSendOrPopout_canceledy(aAddress, aEditor, aStatus, aPopout) {
    128138    Log.debug("onMessageBeforeSendOrPopout_canceled");
     
    141151    let toAddrList = aAddress.to.concat(aAddress.cc);
    142152    Log.debug("onMessageBeforeSendOrPopup_early");
    143    
     153
    144154    if (virtualIdInUse) {
    145155      if (!aPopout) {
    146         let recipients = []; var combinedNames = {}; var number;
     156        let recipients = [];
     157        var combinedNames = {};
     158        var number;
    147159        number = HeaderParser.parseHeadersWithArray(toAddrList.join(", "), {}, {}, combinedNames);
    148160        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
    151166        let recentWindow = Cc["@mozilla.org/appshell/window-mediator;1"]
    152167          .getService(Ci.nsIWindowMediator)
    153168          .getMostRecentWindow("mail:3pane");
    154          
     169
    155170        returnValue = vIaccount_prepareSendMsg(virtualIdInUse, Ci.nsIMsgCompDeliverMode.Now,
    156171          currentIdentityData, aAddress.params.identity, recipients, recentWindow);
    157172        Log.debug("returnValue.update:", returnValue.update);
    158        
     173
    159174        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;
    161181        }
    162         else if (returnValue.update == "takeover") {
    163           _changeIdentityToSmartIdentity(returnValue.storedIdentity);
    164           aStatus.canceled = true; return aStatus;
    165         }
    166        
     182
    167183        aAddress.params.identity = get_vIaccount().defaultIdentity;
    168184        if (!vIaccount_finalCheck(currentIdentityData, aAddress.params.identity)) {
    169185          vIaccount_removeUsedVIAccount();
    170           aStatus.canceled = true; return aStatus;
     186          aStatus.canceled = true;
     187          return aStatus;
    171188        }
    172       }
    173       else {
     189      } else {
    174190        // code virtual Identity into subject - this will be decoded by smartIdentity - newMail
    175191        aAddress.params.subject = aAddress.params.subject + "\nvirtualIdentityExtension\n" + currentIdSenderName;
     
    180196    return aStatus;
    181197  },
    182  
     198
    183199  onStopSending: function _virtualIdentityHook_onStopSending(aMsgID, aStatus, aMsg, aReturnFile) {
    184200    vIaccount_removeUsedVIAccount();
     
    195211    var isNotFirstInputElement = !(aType == "to" && aCount == 0);
    196212    Log.debug("onRecipientAdded isNotFirstInputElement", isNotFirstInputElement);
    197    
     213
    198214    if (!_rdfDatasourceAccess) _rdfDatasourceAccess = new rdfDatasourceAccess();
    199215    else _rdfDatasourceAccess.clean();
    200216
    201217    let recentWindow = Cc["@mozilla.org/appshell/window-mediator;1"]
    202           .getService(Ci.nsIWindowMediator)
    203           .getMostRecentWindow("mail:3pane");
     218      .getService(Ci.nsIWindowMediator)
     219      .getMostRecentWindow("mail:3pane");
    204220
    205221    var storageResult = _rdfDatasourceAccess.updateVIdentityFromStorage(aData.data, "addr_to",
    206222      currentIdentityData, virtualIdInUse, isNotFirstInputElement, recentWindow);
    207    
     223
    208224    if (storageResult.identityCollection.number == 0) return; // return if there was no match
    209225    if (storageResult.result != "accept") return; // return if we don't like the resulting id
    210    
     226
    211227    changeIdentityToSmartIdentity(storageResult.identityCollection, 0);
    212228  }
     
    222238    registerHook(virtualIdentityHook);
    223239  }, false);
    224 }
    225 catch(e) {
     240} catch (e) {
    226241  Log.debug("virtualIdentity is ready for conversations, but you don't use it");
    227242}
Note: See TracChangeset for help on using the changeset viewer.