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

Changeset 9cedc0


Ignore:
Timestamp:
Sep 25, 2011, 9:23:06 PM (11 years ago)
Author:
rene <rene@…>
Branches:
ng_0.9
Children:
284956
Parents:
7666cb
Message:

compatibility for conversation plugin

Location:
chrome/content/v_identity
Files:
15 edited

Legend:

Unmodified
Added
Removed
  • chrome/content/v_identity/vI_Dialog.js

    r7666cb r9cedc0  
    3131
    3232    init : function(warning) {
     33        dump("warning.class=" + warning.class + "warning.class=" + warning.title + "warning.warning=" + warning.warning + "\n")
    3334        document.getElementById("vI_Dialog").setAttribute("class", warning.class);
    3435        Dialog.setDescription(document.getElementById("vI_Dialog_title"), warning.title);
  • chrome/content/v_identity/vI_account.js

    r7666cb r9cedc0  
    2424
    2525virtualIdentityExtension.ns(function() { with (virtualIdentityExtension.LIB) {
     26function prepareSendMsg(vid, msgType, identityData, baseIdentity, recipients) {
     27    var stringBundle = Services.strings.createBundle("chrome://v_identity/locale/v_identity.properties");
     28   
     29    var promptService = Components.classes["@mozilla.org/embedcomp/prompt-service;1"]
     30        .getService(Components.interfaces.nsIPromptService);
     31   
     32    var prefs = Components.classes["@mozilla.org/preferences-service;1"]
     33            .getService(Components.interfaces.nsIPrefService)
     34            .getBranch("extensions.virtualIdentity.");
     35   
     36    var AccountManager = Components.classes["@mozilla.org/messenger/account-manager;1"]
     37            .getService(Components.interfaces.nsIMsgAccountManager);
     38           
     39    if (vI.notificationBar) vI.notificationBar.dump("\n## prepareSendMsg " + msgType + " " + Components.interfaces.nsIMsgCompDeliverMode.Now + "\n");
     40   
     41    returnValue = {};
     42   
     43    if (msgType == Components.interfaces.nsIMsgCompDeliverMode.Now) {
     44        if ( (vid && prefs.getBoolPref("warn_virtual") &&
     45            !(promptService.confirm(window,"Warning",
     46                stringBundle.GetStringFromName("vident.sendVirtual.warning")))) ||
     47            (!vid && prefs.getBoolPref("warn_nonvirtual") &&
     48            !(promptService.confirm(window,"Warning",
     49                stringBundle.GetStringFromName("vident.sendNonvirtual.warning")))) ) {
     50            return { update : "abort", storedIdentity : null }; // completely abort sending
     51        }
     52        if (prefs.getBoolPref("storage") &&
     53                (!vI.statusmenu || vI.statusmenu.objStorageSaveMenuItem.getAttribute("checked") == "true")) {
     54            var localeDatasourceAccess = new vI.rdfDatasourceAccess();
     55            var returnValue = localeDatasourceAccess.storeVIdentityToAllRecipients(identityData, recipients)
     56            if ( returnValue.update == "abort" || returnValue.update == "takeover" ) {
     57                if (vI.notificationBar) vI.notificationBar.dump("## prepareSendMsg: sending aborted\n");
     58                return returnValue;
     59            }
     60        }
     61        else if (vI.notificationBar) vI.notificationBar.dump("## prepareSendMsg: storage deactivated\n");
     62    }
     63    if (vid) {
     64        vI.account.removeUsedVIAccount();
     65        vI.account.createAccount(identityData, baseIdentity);
     66    }
     67    return { update : "accept", storedIdentity : null };
     68};
     69
     70function finalCheck(virtualIdentityData, currentIdentity) {
     71    var stringBundle = Services.strings.createBundle("chrome://v_identity/locale/v_identity.properties");
     72
     73    // vI.identityData(email, fullName, id, smtp, extras, sideDescription, existingID)
     74    var currentIdentityData = new vI.identityData(currentIdentity.email, currentIdentity.fullName, null, currentIdentity.smtpServerKey, null, null, null);
     75   
     76    if (vI.notificationBar) vI.notificationBar.dump("\n## vI.identityData SendMessage Final Check\n");
     77    if (vI.notificationBar) vI.notificationBar.dump("## vI.identityData currentIdentity: fullName='" + currentIdentityData.fullName + "' email='" + currentIdentityData.email + "' smtp='" + currentIdentityData.smtp.key + "'\n");
     78    if (vI.notificationBar) vI.notificationBar.dump("## vI.identityData virtualIdentityData: fullName='" + virtualIdentityData.fullName + "' email='" + virtualIdentityData.email + "' smtp='" + virtualIdentityData.smtp.key + "'\n");
     79
     80    if  (currentIdentityData.fullName.toLowerCase() == virtualIdentityData.fullName.toLowerCase()   &&
     81        currentIdentityData.email.toLowerCase() == virtualIdentityData.email.toLowerCase()      &&
     82        virtualIdentityData.smtp.equal(currentIdentityData.smtp)    ) {
     83            return true
     84    }
     85    else {
     86        if (!(currentIdentityData.fullName.toLowerCase() == virtualIdentityData.fullName.toLowerCase())) vI.notificationBar.dump("\n## vI.identityData failed check for fullName.\n");
     87        if (!(currentIdentityData.email.toLowerCase() == virtualIdentityData.email.toLowerCase())) vI.notificationBar.dump("\n## vI.identityData failed check for email.\n");
     88        if (!(virtualIdentityData.smtp.equal(currentIdentityData.smtp))) vI.notificationBar.dump("\n## vI.identityData failed check for SMTP.\n");
     89        alert(stringBundle.getStringFromName("vident.genericSendMessage.error"));
     90        return false
     91    }   
     92};
     93
    2694var account = {
    2795    _account : null,
    2896   
     97    _baseIdentity : null,
     98
    2999    _AccountManager : Components.classes["@mozilla.org/messenger/account-manager;1"]
    30100        .getService(Components.interfaces.nsIMsgAccountManager),
     
    34104        .getBranch(null),
    35105
    36     _getBaseIdentity : function () {
    37         return account._AccountManager.getIdentity(vI.main.elements.Obj_MsgIdentity.value);
    38     },
    39 
     106    _pref : Components.classes["@mozilla.org/preferences-service;1"]
     107        .getService(Components.interfaces.nsIPrefService)
     108        .getBranch("extensions.virtualIdentity."),
     109   
     110    _unicodeConverter : Components.classes["@mozilla.org/intl/scriptableunicodeconverter"]
     111            .createInstance(Components.interfaces.nsIScriptableUnicodeConverter),
     112   
    40113    _copyBoolAttribute : function(name) {
    41114        account._account.defaultIdentity.setBoolAttribute(name,
    42                 account._getBaseIdentity().getBoolAttribute(name));
     115                account._baseIdentity.getBoolAttribute(name));
    43116    },
    44117   
    45118    _copyIntAttribute : function(name) {
    46119        account._account.defaultIdentity.setIntAttribute(name,
    47                 account._getBaseIdentity().getIntAttribute(name));
     120                account._baseIdentity.getIntAttribute(name));
    48121    },
    49122
    50123    _copyCharAttribute : function(name) {
    51124        account._account.defaultIdentity.setCharAttribute(name,
    52                 account._getBaseIdentity().getCharAttribute(name));
     125                account._baseIdentity.getCharAttribute(name));
    53126    },
    54127
    55128    _copyUnicharAttribute : function(name) {
    56129        account._account.defaultIdentity.setUnicharAttribute(name,
    57                 account._getBaseIdentity().getUnicharAttribute(name));
    58     },
    59 
    60     copyPreferences : function() {
    61         if (vI.main.preferences.getBoolPref("copySMIMESettings")) {
     130                account._baseIdentity.getUnicharAttribute(name));
     131    },
     132
     133    _copyPreferences : function() {
     134        if (account._pref.getBoolPref("copySMIMESettings")) {
    62135            // SMIME settings
    63136            vI.notificationBar.dump("## account: copy S/MIME settings\n")
     
    67140        }
    68141/*      seems not required, encryption happens before Virtual Identity account is created
    69         if (vI.main.preferences.getBoolPref("copyEnigmailSettings")) {
     142        if (account._pref.getBoolPref("copyEnigmailSettings")) {
    70143            // pgp/enigmail settings
    71144            vI.notificationBar.dump("## account: copy PGP settings\n")
     
    80153            account._copyIntAttribute("defaultEncryptionPolicy");
    81154        }   */
    82         if (vI.main.preferences.getBoolPref("copyAttachVCardSettings")) {
     155        if (account._pref.getBoolPref("copyAttachVCardSettings")) {
    83156            // attach vcard
    84157            vI.notificationBar.dump("## account: copy VCard settings\n")
     
    203276    },
    204277   
    205     createAccount : function()
     278    createAccount : function(identityData, baseIdentity)
    206279    {
    207280        if (account._account) {  // if the Account is still created, then leave all like it is
     
    209282            return;
    210283        }
     284        account._baseIdentity = baseIdentity;
    211285        /*
    212286        // the easiest way would be to get all requiered Attributes might be to duplicate the default account like this
     
    220294        account._account = account._AccountManager.createAccount();
    221295        account._prefroot.setBoolPref("mail.account." + account._account.key + ".vIdentity", true)
    222        
    223296        account._account.addIdentity(account._AccountManager.createIdentity());
    224    
    225297        // the new account uses the same incomingServer than the base one,
    226298        // it's especially required for NNTP cause incomingServer is used for sending newsposts.
    227299        // by pointing to the same incomingServer stored passwords can be reused
    228300        // the incomingServer has to be replaced before the account is removed, else it get removed ether
    229         var servers = account._AccountManager.GetServersForIdentity(account._getBaseIdentity());
     301        var servers = account._AccountManager.GetServersForIdentity(baseIdentity);
    230302        var server = servers.QueryElementAt(0, Components.interfaces.nsIMsgIncomingServer);
    231        
    232303        // we mark the server as invalid so that the account manager won't
    233304        // tell RDF about the new server - we don't need this server for long
     
    236307        account._account.incomingServer = server;
    237308        server.valid = true;
    238 
    239         account.copyMsgIdentityClone();
    240         account.copyPreferences();
    241         account.setupFcc();
    242         account.setupDraft();
    243         account.setupTemplates();
    244     },
    245    
    246     copyMsgIdentityClone : function() {
    247         var identityData = document.getElementById("msgIdentity_clone").identityData;
     309        account._copyIdentityData(identityData, baseIdentity);
     310        account._copyPreferences();
     311        account._unicodeConverter.charset = "UTF-8";
     312        account._setupFcc();
     313        account._setupDraft();
     314        account._setupTemplates();
     315    },
     316   
     317    _copyIdentityData : function(identityData, baseIdentity) {
    248318        account._account.defaultIdentity.setCharAttribute("useremail", identityData.email);
    249319        account._account.defaultIdentity.setUnicharAttribute("fullName", identityData.fullName);
    250320       
    251321        account._account.defaultIdentity.smtpServerKey = identityData.smtp.keyNice; // key with "" for vI.DEFAULT_SMTP_TAG
     322        if (account._account.defaultIdentity.smtpServerKey == virtualIdentityExtension.NO_SMTP_TAG)
     323            account._account.defaultIdentity.smtpServerKey = baseIdentity.smtpServerKey;
    252324
    253325        vI.notificationBar.dump("## account: Stored virtualIdentity (name "
     
    257329    },
    258330   
    259     setupFcc : function()
     331    _setupFcc : function()
    260332    {
    261         if (document.getElementById("fcc_switch").getAttribute("checked")) {
    262             switch (vI.main.preferences.getCharPref("fccFolderPickerMode"))
     333        // fcc_switch is only available in modified ComposeDialog.
     334        // XXXXX get rid of this Elem reference
     335        var doFcc = true;
     336        try { doFcc = document.getElementById("fcc_switch").getAttribute("checked") } catch(e) { }
     337        if (doFcc) {
     338            switch (account._pref.getCharPref("fccFolderPickerMode"))
    263339            {
    264340                case "2"  :
     
    271347                case "3"  :
    272348                vI.notificationBar.dump ("## account: preparing Fcc --- use Settings of Modified Account\n");
    273                 account._account.defaultIdentity.doFcc = account._getBaseIdentity().doFcc;
    274                 account._account.defaultIdentity.fccFolder = account._getBaseIdentity().fccFolder;
    275                 account._account.defaultIdentity.fccFolderPickerMode = account._getBaseIdentity().fccFolderPickerMode;
    276                 account._account.defaultIdentity.fccReplyFollowsParent = account._getBaseIdentity().fccReplyFollowsParent;
     349                account._account.defaultIdentity.doFcc = account._baseIdentity.doFcc;
     350                account._account.defaultIdentity.fccFolder = account._baseIdentity.fccFolder;
     351                account._account.defaultIdentity.fccFolderPickerMode = account._baseIdentity.fccFolderPickerMode;
     352                account._account.defaultIdentity.fccReplyFollowsParent = account._baseIdentity.fccReplyFollowsParent;
    277353                break;
    278354                default  :
    279355                vI.notificationBar.dump ("## account: preparing Fcc --- use Virtual Identity Settings\n");
    280356                account._account.defaultIdentity.doFcc
    281                     = vI.main.preferences.getBoolPref("doFcc");
     357                    = account._pref.getBoolPref("doFcc");
    282358                account._account.defaultIdentity.fccFolder
    283                     = vI.main.unicodeConverter.ConvertToUnicode(vI.main.preferences.getCharPref("fccFolder"));
     359                    = account._unicodeConverter.ConvertToUnicode(account._pref.getCharPref("fccFolder"));
    284360                account._account.defaultIdentity.fccFolderPickerMode
    285                     = vI.main.preferences.getCharPref("fccFolderPickerMode");
    286                 account._account.defaultIdentity.fccReplyFollowsParent = vI.main.preferences.getBoolPref("fccReplyFollowsParent");
     361                    = account._pref.getCharPref("fccFolderPickerMode");
     362                account._account.defaultIdentity.fccReplyFollowsParent = account._pref.getBoolPref("fccReplyFollowsParent");
    287363
    288364                break;
     
    296372            account._account.defaultIdentity.fccFolder + " fccFolderPickerMode " +
    297373            account._account.defaultIdentity.fccFolderPickerMode + "(" +
    298             vI.main.preferences.getCharPref("fccFolderPickerMode") + "))\n");
    299     },
    300    
    301     setupDraft : function() {
    302         switch (vI.main.preferences.getCharPref("draftFolderPickerMode"))
     374            account._pref.getCharPref("fccFolderPickerMode") + "))\n");
     375    },
     376   
     377    _setupDraft : function()    {
     378        switch (account._pref.getCharPref("draftFolderPickerMode"))
    303379        {
    304380            case "2"  :
     
    309385            case "3"  :
    310386            vI.notificationBar.dump ("## account: preparing Draft --- use Settings of Modified Account\n");
    311             account._account.defaultIdentity.draftFolder = account._getBaseIdentity().draftFolder;
    312             account._account.defaultIdentity.draftsFolderPickerMode = account._getBaseIdentity().draftsFolderPickerMode;
     387            account._account.defaultIdentity.draftFolder = account._baseIdentity.draftFolder;
     388            account._account.defaultIdentity.draftsFolderPickerMode = account._baseIdentity.draftsFolderPickerMode;
    313389            break;
    314390            default  :
    315391            vI.notificationBar.dump ("## account: preparing Draft --- use Virtual Identity Settings\n");
    316392            account._account.defaultIdentity.draftFolder
    317                 = vI.main.unicodeConverter.ConvertToUnicode(vI.main.preferences.getCharPref("draftFolder"));
     393                = account._unicodeConverter.ConvertToUnicode(account._pref.getCharPref("draftFolder"));
    318394            account._account.defaultIdentity.draftsFolderPickerMode
    319                 = vI.main.preferences.getCharPref("draftFolderPickerMode");
     395                = account._pref.getCharPref("draftFolderPickerMode");
    320396            break;
    321397        }
     
    323399            account._account.defaultIdentity.draftFolder + " draftsFolderPickerMode " +
    324400            account._account.defaultIdentity.draftsFolderPickerMode + "(" +
    325             vI.main.preferences.getCharPref("draftFolderPickerMode") + "))\n");
    326     },
    327    
    328     setupTemplates : function() {
    329         switch (vI.main.preferences.getCharPref("stationeryFolderPickerMode"))
     401            account._pref.getCharPref("draftFolderPickerMode") + "))\n");
     402    },
     403   
     404    _setupTemplates : function()    {
     405        switch (account._pref.getCharPref("stationeryFolderPickerMode"))
    330406        {
    331407            case "2"  :
     
    336412            case "3"  :
    337413            vI.notificationBar.dump ("## account: preparing Templates --- use Settings of Modified Account\n");
    338             account._account.defaultIdentity.stationeryFolder = account._getBaseIdentity().stationeryFolder;
    339             account._account.defaultIdentity.tmplFolderPickerMode = account._getBaseIdentity().tmplFolderPickerMode;
     414            account._account.defaultIdentity.stationeryFolder = account._baseIdentity.stationeryFolder;
     415            account._account.defaultIdentity.tmplFolderPickerMode = account._baseIdentity.tmplFolderPickerMode;
    340416            break;
    341417            default  :
    342418            vI.notificationBar.dump ("## account: preparing Templates --- use Virtual Identity Settings\n");
    343419            account._account.defaultIdentity.stationeryFolder
    344                 = vI.main.unicodeConverter.ConvertToUnicode(vI.main.preferences.getCharPref("stationeryFolder"));
     420                = account._unicodeConverter.ConvertToUnicode(account._pref.getCharPref("stationeryFolder"));
    345421            account._account.defaultIdentity.tmplFolderPickerMode
    346                 = vI.main.preferences.getCharPref("stationeryFolderPickerMode");
     422                = account._pref.getCharPref("stationeryFolderPickerMode");
    347423            break;
    348424        }
     
    350426            account._account.defaultIdentity.stationeryFolder + " tmplFolderPickerMode " +
    351427            account._account.defaultIdentity.tmplFolderPickerMode + "(" +
    352             vI.main.preferences.getCharPref("stationeryFolderPickerMode") + "))\n");
     428            account._pref.getCharPref("stationeryFolderPickerMode") + "))\n");
    353429    }
    354430}
    355431vI.account = account;
     432vI.prepareSendMsg = prepareSendMsg;
     433vI.finalCheck = finalCheck;
    356434}});
  • chrome/content/v_identity/vI_getHeader.js

    r7666cb r9cedc0  
    4040
    4141virtualIdentityExtension.ns(function() { with (virtualIdentityExtension.LIB) {
     42// var storedHeaders = { };
    4243var getHeader = {
    4344    messenger: null,
     
    9091        // create array to count the header
    9192        var currentHeadersCounter = [];
     93//      storedHeaders = { };
    9294       
    9395        var listId = false; var received = false; var content_base = false;
     
    99101            if (!listId && headerName == "list-id") {
    100102                hdr.setStringProperty("vI_list-id","found"); listId = true;
     103//              storedHeaders["vI_list-id"] = "found";
    101104                vI.notificationBar.dump("## getHeader: found header: list-id  ...stored to recognize mailing-list\n");
    102105//              continue;
     
    106109            if (!received && headerName == "received") {
    107110                hdr.setStringProperty("vI_received","found"); received = true;
     111//              storedHeaders["vI_received"] = "found";
    108112                vI.notificationBar.dump("## getHeader: found header: received  ...stored to recognize received mail\n");
    109113//              continue;
     
    113117            if (!content_base && headerName == "content-base") {
    114118                hdr.setStringProperty("vI_content_base","found"); content_base = true;
     119//              storedHeaders["vI_content_base"] = "found";
    115120                vI.notificationBar.dump("## getHeader: found header: content-base  ...stored to recognize blog/news-feed\n");
    116121//              continue;
     
    130135                        ", " + value;
    131136                    hdr.setStringProperty(getHeader.headerToSearch[index].headerNameToStore,getHeader.unicodeConverter.ConvertFromUnicode(value) + getHeader.unicodeConverter.Finish());
     137                   
     138//                  storedHeaders[getHeader.headerToSearch[index].headerNameToStore] = getHeader.unicodeConverter.ConvertFromUnicode(value) + getHeader.unicodeConverter.Finish();
    132139
    133140                    var storedValue = hdr.getProperty(getHeader.headerToSearch[index].headerNameToStore)
     
    136143                        "[:" + currentHeadersCounter[headerName] + "] - stored as '" +
    137144                        storedConvValue + "'\n");
     145/*                  vI.notificationBar.dump("## getHeader: additional stored header: " + getHeader.headerToSearch[index].headerNameToStore +
     146                        " '" + storedHeaders[getHeader.headerToSearch[index].headerNameToStore] + "'\n");*/
    138147                    if (!found) {
    139148                        subtitle = getHeader.strings.getString("vident.getHeader.headerFound");
     
    376385window.addEventListener("load", function(e) { prepareHeader.init(); }, false);
    377386window.addEventListener("unload", function(e) { prepareHeader.cleanup(); }, false);
     387// vI.storedHeaders = storedHeaders;
    378388}});
  • chrome/content/v_identity/vI_identityData.js

    r7666cb r9cedc0  
    3030    this.id = new idObj(id);
    3131    this.smtp = new smtpObj(smtp);
    32     this.extras = extras?extras:new vI.storageExtras();
     32    if (extras) this.extras = extras;
     33    else if (typeof(vI.storageExtras)=='function') this.extras = new vI.storageExtras();
    3334    this.comp = {   // holds the results of the last comparison for later creation of a compareMatrix
    3435        compareID : null,
     
    3839    if (existingID) this.existingID = existingID;
    3940    else if (this.id.value) this.sideDescription = " - " + this.id.value;
    40     this.stringBundle = document.getElementById("vIdentBundle");
     41    this.stringBundle = Components.classes["@mozilla.org/intl/stringbundle;1"]
     42                        .getService(Components.interfaces.nsIStringBundleService)
     43                        .createBundle("chrome://v_identity/locale/v_identity.properties");
    4144}
    4245identityData.prototype = {
     46    _prefroot : Components.classes["@mozilla.org/preferences-service;1"]
     47        .getService(Components.interfaces.nsIPrefService)
     48        .getBranch(null),
     49
     50    _pref : Components.classes["@mozilla.org/preferences-service;1"]
     51        .getService(Components.interfaces.nsIPrefService)
     52        .getBranch("extensions.virtualIdentity."),
     53
    4354    _email : null,          // internal email-field might contain combinedName (until first queried via email)
    4455    _fullName : null,
     
    99110    get combinedNameHtml() { return this.__makeHtml(this.combinedName); },
    100111
    101     get idLabel() { return this.stringBundle.getString("vident.identityData.baseID") },
    102     get smtpLabel() { return this.stringBundle.getString("vident.identityData.SMTP") },
    103     get fullNameLabel() { return this.stringBundle.getString("vident.identityData.Name") },
    104     get emailLabel() { return this.stringBundle.getString("vident.identityData.Address") },
     112    get idLabel() { return this.stringBundle.GetStringFromName("vident.identityData.baseID") },
     113    get smtpLabel() { return this.stringBundle.GetStringFromName("vident.identityData.SMTP") },
     114    get fullNameLabel() { return this.stringBundle.GetStringFromName("vident.identityData.Name") },
     115    get emailLabel() { return this.stringBundle.GetStringFromName("vident.identityData.Address") },
    105116
    106117    // creates an Duplicate of the current IdentityData, cause usually we are working with a pointer
    107118    getDuplicate : function() {
    108         return new identityData(this.email, this.fullName, this.id.key, this.smtp.key, this.extras.getDuplicate(), this.sideDescription, this.existingID);
     119        return new identityData(this.email, this.fullName, this.id.key, this.smtp.key, this.extras?this.extras.getDuplicate():null, this.sideDescription, this.existingID);
    109120    },
    110121
     
    116127        this.smtp.key = identityData.smtp.key;
    117128        this.sideDescription = identityData.sideDescription;
    118         this.extras.copy(identityData.extras);
     129        if (this.extras) this.extras.copy(identityData.extras);
    119130    },
    120131
     
    125136
    126137        var ignoreFullNameMatchKey = null;
    127 
    128         var accounts = queryISupportsArray(gAccountManager.accounts, Components.interfaces.nsIMsgAccount);
    129         for (var i in accounts) {
    130             // skip possible active VirtualIdentity Accounts
    131             try { vI.account._prefroot.getBoolPref("mail.account."+accounts[i].key+".vIdentity"); continue; } catch (e) { };
    132    
    133             var identities = queryISupportsArray(accounts[i].identities, Components.interfaces.nsIMsgIdentity);
    134             for (var j in identities) {
    135 //              vI.notificationBar.dump("## identityData comp: fullName.toLowerCase()='" + identities[j].fullName.toLowerCase() + "' email.toLowerCase()='" + identities[j].email.toLowerCase() + "' smtp='" + identities[j].smtpServerKey + "'\n");
     138        var AccountManager = Components.classes["@mozilla.org/messenger/account-manager;1"]
     139            .getService(Components.interfaces.nsIMsgAccountManager);
     140        for (let i = 0; i < AccountManager.accounts.Count(); i++) {
     141            var account = AccountManager.accounts.QueryElementAt(i, Components.interfaces.nsIMsgAccount);
     142            try { this._prefroot.getBoolPref("mail.account."+account.key+".vIdentity"); continue; } catch (e) { };
     143            for (let j = 0; j < account.identities.Count(); j++) {
     144                var identity = account.identities.QueryElementAt(j, Components.interfaces.nsIMsgIdentity);
     145//              vI.notificationBar.dump("## identityData comp: fullName.toLowerCase()='" + identity.fullName.toLowerCase() + "' email.toLowerCase()='" + identity.email.toLowerCase() + "' smtp='" + identity.smtpServerKey + "'\n");
    136146                var email = this.email?this.email:"";               // might be null if no identity is set
    137                 var idEmail = identities[j].email?identities[j].email:"";   // might be null if no identity is set
     147                var idEmail = identity.email?identity.email:""; // might be null if no identity is set
    138148                if (    (email.toLowerCase() == idEmail.toLowerCase()) &&
    139                     this.smtp.equal(new smtpObj(identities[j].smtpServerKey))   ) {
     149                    this.smtp.equal(new smtpObj(identity.smtpServerKey))    ) {
    140150                        // if fullName matches, than this is a final match
    141                         if ( this.fullName.toLowerCase() == identities[j].fullName.toLowerCase() ) {
    142                             vI.notificationBar.dump("## identityData: isExistingIdentity: " + this.combinedName + " found, id='" + identities[j].key + "'\n");
    143                             return identities[j].key; // return key and stop searching
     151                        if ( this.fullName.toLowerCase() == identity.fullName.toLowerCase() ) {
     152                            vI.notificationBar.dump("## identityData: isExistingIdentity: " + this.combinedName + " found, id='" + identity.key + "'\n");
     153                            return identity.key; // return key and stop searching
    144154                        }
    145155                        // if fullNames don't match, remember the key but continue to search for full match
    146                         else if (!ignoreFullNameMatchKey) ignoreFullNameMatchKey = identities[j].key;
     156                        else if (!ignoreFullNameMatchKey) ignoreFullNameMatchKey = identity.key;
    147157                }
    148158            }
     
    168178
    169179        this.comp.equals.id = this.id.equal(compareIdentityData.id);
    170         this.comp.equals.extras = this.extras.equal(compareIdentityData.extras);
     180        this.comp.equals.extras = this.extras?this.extras.equal(compareIdentityData.extras):true;
    171181       
    172182        return (this.comp.equals.fullName && this.comp.equals.email && this.comp.equals.smtp && this.comp.equals.id && this.comp.equals.extras);
    173183    },
    174184
    175     equalsCurrentIdentity : function(getCompareMatrix) {
    176         var equal = this.equals(document.getElementById("msgIdentity_clone").identityData);
     185    equalsIdentity : function(compareIdentityData, getCompareMatrix) {
     186        var equal = this.equals(compareIdentityData);
    177187        var compareMatrix = null;
    178188        // generate CompareMatrix only if asked and non-equal
     
    184194        const Items = Array("fullName", "email", "smtp", "id");
    185195        var string = "";       
    186         var saveBaseId = (vI.statusmenu.objSaveBaseIDMenuItem.getAttribute("checked") == "true")
    187         var saveSMTP = (vI.statusmenu.objSaveSMTPMenuItem.getAttribute("checked") == "true")
     196        var saveBaseId = (!vI.statusmenu && this._pref.getBoolPref("storage_store_base_id")
     197                || vI.statusmenu.objSaveBaseIDMenuItem.getAttribute("checked") == "true")
     198        var saveSMTP = (!vI.statusmenu && this._pref.getBoolPref("storage_store_SMTP")
     199                || vI.statusmenu.objSaveSMTPMenuItem.getAttribute("checked") == "true")
    188200        for each (let item in Items) {
    189201            var classEqual = (this.comp.equals[item])?"equal":"unequal";
     
    195207                "</tr>"
    196208        }
    197         string += this.extras.getCompareMatrix();
     209        string += this.extras?this.extras.getCompareMatrix():"";
    198210        return string;
    199211    },
     
    205217            string += "<tr><td class='col1'>" + this[item+"Label"] + ":</td>" +
    206218                "<td class='col2'>" + this[item+"Html"] + "</td></tr>"
    207         string += this.extras.getMatrix();
     219        string += this.extras?this.extras.getMatrix():"";
    208220        return string;     
    209221    }
     
    233245
    234246    addWithoutDuplicates : function(identityData) {
     247        if (!identityData) return;
    235248        for (var index = 0; index < this.number; index++) {
    236249            if (this.identityDataCollection[index].email == identityData.email &&
     
    274287function smtpObj(key) {
    275288    this._key = key;
    276     this.DEFAULT_TAG = document.getElementById("bundle_messenger").getString("defaultServerTag");
     289    this.DEFAULT_TAG =  Components.classes["@mozilla.org/intl/stringbundle;1"]
     290                        .getService(Components.interfaces.nsIStringBundleService)
     291                        .createBundle("chrome://messenger/locale/messenger.properties").
     292                            GetStringFromName("defaultServerTag");
    277293}
    278294smtpObj.prototype = {
  • chrome/content/v_identity/vI_msgIdentityCloneTools.js

    r7666cb r9cedc0  
    2424virtualIdentityExtension.ns(function() { with (virtualIdentityExtension.LIB) {
    2525var msgIdentityCloneTools = {   
     26    _pref : Components.classes["@mozilla.org/preferences-service;1"]
     27        .getService(Components.interfaces.nsIPrefService)
     28        .getBranch("extensions.virtualIdentity."),
     29
    2630    copySelectedIdentity : function(id_key) {
    2731        vI.notificationBar.dump("## msgIdentityCloneTools: copySelectedIdentity\n");
     
    4650            vI.notificationBar.dump("## msgIdentityCloneTools: signatureSwitch hide/remove signatures\n");
    4751            // code to hide the text signature
    48             try { if (vI.main.preferences.getBoolPref("hide_signature") && ss_signature.length == 0) {
     52            try { if (msgIdentityCloneTools._pref.getBoolPref("hide_signature") && ss_signature.length == 0) {
    4953                vI.notificationBar.dump("## msgIdentityCloneTools: hide text/html signature");
    5054                ss_main.signatureSwitch()
     
    5256            } } catch(vErr) { vI.notificationBar.dump(" -- missing signatureSwitch extension?\n"); };
    5357            // code to hide the sMime signature
    54             try { if (vI.main.preferences.getBoolPref("hide_sMime_messageSignature")) {
     58            try { if (msgIdentityCloneTools._pref.getBoolPref("hide_sMime_messageSignature")) {
    5559                var element = document.getElementById("menu_securitySign1");
    5660                if (element.getAttribute("checked") == "true") {
     
    6266            } catch(vErr) { };
    6367            // code to hide the openGPG signature
    64             try { if (vI.main.preferences.getBoolPref("hide_openPGP_messageSignature")) {
     68            try { if (msgIdentityCloneTools._pref.getBoolPref("hide_openPGP_messageSignature")) {
    6569                var element = document.getElementById("enigmail_signed_send");
    6670                if (element.getAttribute("checked") == "true") {
  • chrome/content/v_identity/vI_prefDialog.js

    r7666cb r9cedc0  
    4242        var panelIndex = (tabpanel)?tabpanel:document.getElementById('prefTabbox').selectedIndex
    4343        var prefTree = document.getElementById('prefTabbox').selectedPanel.getElementsByAttribute("class", "vIprefTree")[0];
    44         var currentVersion = document.getElementById("extVersion").getAttribute("value").split(/\./);
     44        var currentVersion = document.getElementById("virtualIdentityExtension_extVersion").getAttribute("value").split(/\./);
    4545        var extVersion = currentVersion[0] + "." + currentVersion[1];
    4646        var url = "https://www.absorb.it/virtual-id/wiki/docs/" + extVersion + "/tab" + panelIndex + "/tree" + prefTree.currentIndex;
  • chrome/content/v_identity/vI_prefDialog.xul

    r7666cb r9cedc0  
    739739</tabbox>
    740740<browserbox id="vI_remoteBrowserBox" class="vI_remoteBrowserBox" localCss="localDoc.css" flex="1" hidden="true" type="content" />
    741 <label id="extVersion" value="&vident.version;" hidden="true" />
     741<label id="virtualIdentityExtension_extVersion" value="&vident.version;" hidden="true" />
    742742</hbox>
    743743<!--
  • chrome/content/v_identity/vI_rdfDatasource.js

    r7666cb r9cedc0  
    2929    if (this._rdfFileName) this.init();
    3030    if (!dontRegisterObserver) this.AccountManagerObserver.register();
     31    let window = Components.classes['@mozilla.org/appshell/window-mediator;1']
     32        .getService(Components.interfaces.nsIWindowMediator)
     33        .getMostRecentWindow("mail:3pane");
     34    this._extVersion = window.virtualIdentityExtension.extensionVersion;
    3135}
    3236
    3337rdfDatasource.prototype = {
     38    _extVersion :       null,
    3439    _rdfVersion :       "0.0.5",
    3540    _rdfService :       Components.classes["@mozilla.org/rdf/rdf-service;1"]
     
    6772            .createInstance(Components.interfaces.nsIRDFContainer),
    6873   
     74    _pref : Components.classes["@mozilla.org/preferences-service;1"]
     75        .getService(Components.interfaces.nsIPrefService)
     76        .getBranch("extensions.virtualIdentity."),
     77
    6978    getContainer : function (type) {
    7079        switch (type) {
     
    153162        var versionChecker = Components.classes["@mozilla.org/xpcom/version-comparator;1"]
    154163            .getService(Components.interfaces.nsIVersionComparator);
    155         // seamonkey doesn't have a extensionmanager, so read version of extension from hidden version-label
    156         // var extVersion = this.extensionManager.getItemForID(this._virtualIdentityID).version
    157         var extVersion = document.getElementById("extVersion").getAttribute("value");
    158         return (!oldExtVersion || versionChecker.compare(oldExtVersion, extVersion) < 0)   
     164        return (!oldExtVersion || versionChecker.compare(oldExtVersion, this._extVersion) < 0) 
    159165    },
    160166    // **************    RDF UPGRADE CODE    ****************************************************
     
    315321   
    316322    storeExtVersion: function() {
    317         // seamonkey doesn't have a extensionmanager, so read version of extension from hidden version-label
    318         // var extVersion = this.extensionManager.getItemForID(this._virtualIdentityID).version
    319         var extVersion = document.getElementById("extVersion").getAttribute("value");
    320323        this._setRDFValue(
    321             this._rdfService.GetResource(this._rdfNS + "virtualIdentity"), "version", extVersion)
     324            this._rdfService.GetResource(this._rdfNS + "virtualIdentity"), "version", this._extVersion)
    322325        this._flush();
    323326    },
     
    584587        this._unsetRDFValue(resource, "name", this._getRDFValue(resource, "name"))
    585588       
    586         var extras = new vI.storageExtras(this, resource);
    587         extras.loopForRDF(this, resource, "unset");
     589        var extras = (typeof(vI.storageExtras)=='function')?new vI.storageExtras(this, resource):null;
     590        if (extras) extras.loopForRDF(this, resource, "unset");
    588591        this.getContainer(recType).RemoveElement(resource, true);
    589592    },
     
    614617            var smtp = this._getRDFValue(resource, "smtp")
    615618            if (!smtp) smtp = vI.NO_SMTP_TAG;
    616             var extras = new vI.storageExtras(this, resource);
     619            var extras = (typeof(vI.storageExtras)=='function')?new vI.storageExtras(this, resource):null;
    617620           
    618621            var localIdentityData = new vI.identityData(email, fullName, id, smtp, extras)
     
    621624    },
    622625   
    623     findMatchingFilter : function (recDescription) {
     626    __getDescriptionAndType : function (recipient, recipientType) {
     627        if (recipientType == "addr_newsgroups") return { recDesc : recipient, recType : "newsgroup" }
     628        else if (this.__isMailingList(recipient)) {
     629            vI.notificationBar.dump("## __getDescriptionAndType: '" + recipient + "' is MailList\n");
     630            return { recDesc : this.__getMailListName(recipient), recType : "maillist" }
     631        }
     632        else {
     633            vI.notificationBar.dump("## __getDescriptionAndType: '" + recipient + "' is no MailList\n");
     634            var localIdentityData = new vI.identityData(recipient, null, null, null, null, null, null);
     635            return { recDesc : localIdentityData.combinedName, recType : "email" }
     636        }
     637    },
     638   
     639    // --------------------------------------------------------------------
     640    // check if recipient is a mailing list.
     641    // Similiar to Thunderbird, if there are muliple cards with the same displayName the mailinglist is preferred
     642    // see also https://bugzilla.mozilla.org/show_bug.cgi?id=408575
     643    __isMailingList: function(recipient) {
     644        let abManager = Components.classes["@mozilla.org/abmanager;1"]
     645            .getService(Components.interfaces.nsIAbManager);
     646        let allAddressBooks = abManager.directories;
     647        while (allAddressBooks.hasMoreElements()) {
     648            let ab = allAddressBooks.getNext();
     649            if (ab instanceof Components.interfaces.nsIAbDirectory && !ab.isRemote) {
     650                let abdirectory = abManager.getDirectory(ab.URI +
     651                    "?(and(DisplayName,=," + encodeURIComponent(this.__getMailListName(recipient)) + ")(IsMailList,=,TRUE))");
     652                if (abdirectory) {
     653                    try {   // just try, sometimes there are no childCards at all...
     654                        let cards = abdirectory.childCards;
     655                        if (cards.hasMoreElements()) return true;   // only interested if there is at least one element...
     656                    } catch(e) { }
     657                }
     658            }
     659        }
     660        return false;
     661    }, 
     662   
     663    // --------------------------------------------------------------------
     664   
     665    __getMailListName : function(recipient) {
     666        if (recipient.match(/<[^>]*>/) || recipient.match(/$/)) {
     667            var mailListName = RegExp.leftContext + RegExp.rightContext
     668            mailListName = mailListName.replace(/^\s+|\s+$/g,"")
     669        }
     670        return mailListName;
     671    },
     672
     673    findMatchingFilter : function (recipient, recipientType) {
     674        var recDescription = this.__getDescriptionAndType(recipient, recipientType).recDesc;
    624675        if (vI.notificationBar) vI.notificationBar.dump("## rdfDatasource: findMatchingFilter for " + recDescription + ".\n");
    625676        var enumerator = this._filterContainer.GetElements();
     
    660711    },
    661712   
    662     readVIdentityFromRDF : function (recDescription, recType) {
     713    readVIdentityFromRDF : function (recipient, recipientType) {
     714        var storedRecipient = this.__getDescriptionAndType(recipient, recipientType);
    663715        var email = this._rdfService.GetResource(this._rdfNS + "rdf#email");
    664         var resource = this._getRDFResourceForVIdentity(recDescription, recType);
     716        var resource = this._getRDFResourceForVIdentity(storedRecipient.recDesc, storedRecipient.recType);
    665717        if (!resource) return null;
    666718        if (!this._rdfDataSource.hasArcOut(resource, email)) {
     
    684736            "' fullName='" + fullName + "' id='" + id + "' smtp='" + smtp + "'\n");
    685737       
    686         var extras = new vI.storageExtras(this, resource);
    687         if (vI.notificationBar) vI.notificationBar.dump("## rdfDatasource: extras:" + extras.status() + "\n");
     738        var extras = (typeof(vI.storageExtras)=='function')?new vI.storageExtras(this, resource):null;
     739        var extras_status = (typeof(vI.storageExtras)=='function')?extras.status():" not used";
     740        if (vI.notificationBar) vI.notificationBar.dump("## rdfDatasource: extras:" + extras_status + "\n");
    688741       
    689742        var localIdentityData = new vI.identityData(email, fullName, id, smtp, extras)
     
    699752    },
    700753   
    701     updateRDFFromVIdentity : function(recDescription, recType) {
    702         this.updateRDF(recDescription, recType,
    703             document.getElementById("msgIdentity_clone").identityData,
    704             (vI.statusmenu.objSaveBaseIDMenuItem.getAttribute("checked") == "true"),
    705             (vI.statusmenu.objSaveSMTPMenuItem.getAttribute("checked") == "true"),
     754    updateRDFFromVIdentity : function(identityData, recipientName, recipientType) {
     755        var recipient = this.__getDescriptionAndType(recipientName, recipientType)
     756        this.updateRDF(recipient.recDesc, recipient.recType, identityData,
     757            (!vI.statusmenu && this._pref.getBoolPref("storage_store_base_id")
     758                || vI.statusmenu.objSaveBaseIDMenuItem.getAttribute("checked") == "true"),
     759            (!vI.statusmenu && this._pref.getBoolPref("storage_store_SMTP")
     760                || vI.statusmenu.objSaveSMTPMenuItem.getAttribute("checked") == "true"),
    706761            null, null);
    707762    },
     
    745800        this._setRDFValue(resource, "name", recDescription);
    746801 
    747         localIdentityData.extras.loopForRDF(this, resource, "set");
     802        if (localIdentityData.extras) localIdentityData.extras.loopForRDF(this, resource, "set");
    748803       
    749804        if (vI.notificationBar) vI.notificationBar.dump("## rdfDatasource: updateRDF add " + resource.ValueUTF8 + " at position " + position + ".\n");
     
    765820        return value;
    766821    },
    767    
    768     //  code adapted from http://xulsolutions.blogspot.com/2006/07/creating-uninstall-script-for.html
     822
     823    //  code adapted from http://xulsolutions.blogspot.com/2006/07/creating-uninstall-script-for.html
    769824    AccountManagerObserver : {
    770825        _uninstall : false,
     
    795850}
    796851
     852
     853function rdfDatasourceAccess() {
     854    this._rdfDataSource = new rdfDatasource("virtualIdentity.rdf", false);
     855    this.stringBundle = Services.strings.createBundle("chrome://v_identity/locale/v_identity.properties");
     856}
     857
     858rdfDatasourceAccess.prototype = {
     859    _rdfDataSource : null,
     860    stringBundle : null,
     861   
     862    _pref : Components.classes["@mozilla.org/preferences-service;1"]
     863        .getService(Components.interfaces.nsIPrefService)
     864        .getBranch("extensions.virtualIdentity."),
     865   
     866    clean : function() {
     867        this._rdfDataSource.clean();
     868    },
     869   
     870    updateVIdentityFromStorage : function(recipientName, recipientType, currentIdentity, currentIdentityIsVid, isNotFirstInputElement) {
     871        var localIdentities = new vI.identityCollection();
     872        localIdentities.addWithoutDuplicates(this._rdfDataSource.readVIdentityFromRDF(recipientName, recipientType));
     873        if (localIdentities.number == 1) vI.notificationBar.dump("## rdfDatasourceAccess: using data from direct match\n");
     874        localIdentities.addWithoutDuplicates(this._rdfDataSource.findMatchingFilter(recipientName, recipientType));
     875       
     876        var returnValue = {}; returnValue.identityCollection = localIdentities;
     877        if (localIdentities.number == 0) {
     878            vI.notificationBar.dump("## rdfDatasourceAccess: updateVIdentityFromStorage no usable Storage-Data found.\n");
     879        }
     880        else {
     881            vI.notificationBar.dump("## rdfDatasourceAccess: compare with current Identity\n");
     882            if (this._pref.getBoolPref("storage_getOneOnly") &&     // if requested to retrieve only storageID for first recipient entered
     883                isNotFirstInputElement &&                           // and it is now not the first recipient entered
     884                !localIdentities.identityDataCollection[0].equalsIdentity(currentIdentity, false).equal) {      // and this id is different than the current used one
     885                    vI.notificationBar.setNote(
     886                        this.stringBundle.GetStringFromName("vident.smartIdentity.vIStorageCollidingIdentity"), // than drop the potential changes
     887                        "storage_notification");
     888                    returnValue.result = "drop";
     889            }
     890            // only update fields if new Identity is different than old one.
     891            else {
     892                vI.notificationBar.dump("## rdfDatasourceAccess: updateVIdentityFromStorage check if storage-data matches current Identity.\n");
     893                var compResult = localIdentities.identityDataCollection[0].equalsIdentity(currentIdentity, true);
     894                if (!compResult.equal) {
     895                    var warning = this.__getWarning("replaceVIdentity", recipientName, compResult.compareMatrix);
     896                    if (    !currentIdentityIsVid ||
     897                        !this._pref.getBoolPref("storage_warn_vI_replace") ||
     898                        (this.__askWarning(warning) == "accept")) {
     899                            returnValue.result = "accept";
     900                    }
     901                }
     902                else {
     903                    returnValue.result = "equal";
     904                }
     905            }
     906        }
     907        return returnValue;
     908    },
     909   
     910    storeVIdentityToAllRecipients : function(identityData, recipients) {
     911        var multipleRecipients = (recipients.length > 1);
     912        var dontUpdateMultipleNoEqual = (this._pref.getBoolPref("storage_dont_update_multiple") && multipleRecipients)
     913        vI.notificationBar.dump("## rdfDatasource: storeVIdentityToAllRecipients dontUpdateMultipleNoEqual='" + dontUpdateMultipleNoEqual + "'\n")
     914       
     915        for (var j = 0; j < recipients.length; j++) {
     916            var returnValue = this.__updateStorageFromVIdentity(identityData, recipients[j].recipient, recipients[j].recipientType, dontUpdateMultipleNoEqual);
     917            if (returnValue.update != "accept")  break;
     918        }
     919        return returnValue;
     920    },
     921
     922    getVIdentityFromAllRecipients : function(allIdentities, recipients) {
     923        var initnumber = allIdentities.number;
     924        for (var j = 0; j < recipients.length; j++) {
     925            allIdentities.addWithoutDuplicates(this._rdfDataSource.readVIdentityFromRDF(recipients[j].recipient, recipients[j].recipientType));
     926            allIdentities.addWithoutDuplicates(this._rdfDataSource.findMatchingFilter(recipients[j].recipient, recipients[j].recipientType));
     927        }
     928        vI.notificationBar.dump("## storage: found " + (allIdentities.number-initnumber) + " address(es)\n")
     929    },
     930
     931    __updateStorageFromVIdentity : function(identityData, recipient, recipientType, dontUpdateMultipleNoEqual) {
     932        vI.notificationBar.dump("## rdfDatasource: __updateStorageFromVIdentity.\n")
     933        var storageDataByType = this._rdfDataSource.readVIdentityFromRDF(recipient, recipientType);
     934        var storageDataByFilter = this._rdfDataSource.findMatchingFilter(recipient, recipientType);
     935       
     936        // update (storing) of data by type is required if there is
     937        // no data stored by type (or different data stored) and no equal filter found
     938        var storageDataByTypeCompResult = storageDataByType?storageDataByType.equalsIdentity(identityData, true):null;
     939        var storageDataByTypeEqual = (storageDataByType && storageDataByTypeCompResult.equal);
     940        var storageDataByFilterEqual = (storageDataByFilter && storageDataByFilter.equalsIdentity(identityData, false).equal);
     941       
     942        var doUpdate = "accept";
     943        if (    (!storageDataByType && !storageDataByFilterEqual) ||
     944            (!storageDataByTypeEqual && !storageDataByFilterEqual && !dontUpdateMultipleNoEqual) ) {
     945            vI.notificationBar.dump("## storage: __updateStorageFromVIdentity updating\n")
     946            if (storageDataByType && !storageDataByTypeEqual && this._pref.getBoolPref("storage_warn_update")) {
     947                vI.notificationBar.dump("## storage: __updateStorageFromVIdentity overwrite warning\n");
     948                doUpdate = this.__askWarning(this.__getWarning("updateStorage", recipient, storageDataByTypeCompResult.compareMatrix));
     949            }
     950        }
     951        if (doUpdate == "accept") this._rdfDataSource.updateRDFFromVIdentity(identityData, recipient, recipientType);
     952        return { update : doUpdate, storedIdentity : storageDataByType };
     953    },
     954   
     955    __getWarning : function(warningCase, recipient, compareMatrix) {
     956        var warning = { title: null, recLabel : null, recipient : null, warning : null, css: null, query : null, class : null };
     957        warning.title = this.stringBundle.GetStringFromName("vident." + warningCase + ".title")
     958        warning.recLabel = this.stringBundle.GetStringFromName("vident." + warningCase + ".recipient") + ":";
     959        warning.recipient = recipient;
     960        warning.warning =
     961            "<table class='" + warningCase + "'><thead><tr><th class='col1'/>" +
     962                "<th class='col2'>" + this.stringBundle.GetStringFromName("vident." + warningCase + ".currentIdentity") + "</th>" +
     963                "<th class='col3'>" + this.stringBundle.GetStringFromName("vident." + warningCase + ".storedIdentity") + "</th>" +
     964            "</tr></thead>" +
     965            "<tbody>" + compareMatrix + "</tbody>" +
     966            "</table>"
     967        warning.css = "vI.DialogBrowser.css";
     968        warning.query = this.stringBundle.GetStringFromName("vident." + warningCase + ".query");
     969        warning.class = warningCase;
     970        return warning;
     971    },
     972
     973    __askWarning : function(warning) {
     974        var retVar = { returnValue: null };
     975        var answer = window.openDialog("chrome://v_identity/content/vI_Dialog.xul","",
     976                    "chrome, dialog, modal, alwaysRaised, resizable=yes",
     977                     warning, retVar)
     978        dump("retVar.returnValue=" + retVar.returnValue + "\n")
     979        return retVar.returnValue;
     980    },
     981}
     982
     983
    797984// create with name of the file to import into
    798985function rdfDatasourceImporter(rdfFileName) {
     
    9491136                    var smtp = this._rdfImportDataSource._getRDFValue(resource, "smtp")
    9501137                    smtp = (smtp && smtp != vI.DEFAULT_SMTP_TAG)?relevantSMTPs[smtp].smtp:smtp
    951                     var extras = new vI.storageExtras(this._rdfImportDataSource, resource);
     1138                    var extras = (typeof(vI.storageExtras)=='function')?new vI.storageExtras(this._rdfImportDataSource, resource):null;
    9521139                    var localIdentityData = new vI.identityData(email, fullName, id, smtp, extras)
    9531140                   
     
    9801167}
    9811168vI.rdfDatasource = rdfDatasource;
     1169vI.rdfDatasourceAccess = rdfDatasourceAccess;
    9821170vI.rdfDatasourceImporter = rdfDatasourceImporter;
    9831171}});
  • chrome/content/v_identity/vI_smartIdentity.js

    r7666cb r9cedc0  
    2424
    2525virtualIdentityExtension.ns(function() { with (virtualIdentityExtension.LIB) {
    26 var smartIdentity = {
     26
     27   
     28function smartIdentityCollection(msgHdr, preseletedID, currentIDisVID, newsgroup, recipients) {
     29    this._IDisVID = currentIDisVID;
     30    this._preselectedID = preseletedID;
     31    this._msgHdr = msgHdr;
     32    this._newsgroup = newsgroup;
     33    this._unicodeConverter.charset = "UTF-8";
     34    this._recipients = recipients;
     35    this._rdfDatasourceAccess = new vI.rdfDatasourceAccess();
     36    this._allIdentities = new vI.identityCollection();
     37};
     38
     39smartIdentityCollection.prototype = {
    2740    messenger : Components.classes["@mozilla.org/messenger;1"].createInstance()
    2841        .QueryInterface(Components.interfaces.nsIMessenger),
    29        
    30     smartIdentity_BaseIdentity : null,
    31 
    32     clean : function() {
    33         smartIdentity.smartIdentity_BaseIdentity = null;
    34     },
    35    
    36     // After Loading the MessageComposeDialog, check if smartIdentity is needed
    37     init : function() {
    38         var type = gMsgCompose.type;
    39         var msgComposeType = Components.interfaces.nsIMsgCompType;
    40         vI.notificationBar.dump("## smartIdentity: msgComposeType = " + type + "\n");
    41        
    42         switch (type) {
    43             case msgComposeType.ForwardAsAttachment:
    44             case msgComposeType.ForwardInline:
    45             case msgComposeType.Reply:
    46             case msgComposeType.ReplyAll:
    47             case msgComposeType.ReplyToGroup: // reply to a newsgroup, would possibly be stopped later
    48             case msgComposeType.ReplyToSender:
    49             case msgComposeType.ReplyToSenderAndGroup: // reply to a newsgroup, would possibly be stopped later
    50             case msgComposeType.ReplyWithTemplate:
    51             case msgComposeType.ReplyToList:
    52                 smartIdentity.Reply(); break;
    53             case msgComposeType.Draft:
    54             case msgComposeType.Template:
    55                 smartIdentity.Draft(); break;
    56             case msgComposeType.New:
    57             case msgComposeType.NewsPost:
    58             case msgComposeType.MailToUrl:
    59                 smartIdentity.NewMail(); break;
    60             }
    61     },
    62        
     42    _pref : Components.classes["@mozilla.org/preferences-service;1"]
     43            .getService(Components.interfaces.nsIPrefService)
     44            .getBranch("extensions.virtualIdentity."),
     45    _unicodeConverter : Components.classes["@mozilla.org/intl/scriptableunicodeconverter"]
     46            .createInstance(Components.interfaces.nsIScriptableUnicodeConverter),
     47    _headerParser : Components.classes["@mozilla.org/messenger/headerparser;1"]
     48            .getService(Components.interfaces.nsIMsgHeaderParser),
     49
     50    _msgComposeTypeReference : Components.interfaces.nsIMsgCompType,
     51   
     52    _IDisVID : false,
     53    _preselectedID : null,
     54    _allIdentities : null,
     55    _selectedValue : null,
     56    _newsgroup : null,
     57    _rdfDatasourceAccess : null,
     58
    6359    // this function adds a timestamp to the current sender
    6460    __autoTimestamp : function() {
    65         vI.notificationBar.dump("## smartIdentity: __autoTimestamp()\n");
    66         if (document.getElementById("msgIdentity_clone").vid) {
    67             vI.notificationBar.dump("## smartIdentity: Virtual Identity in use, aborting\n");
     61        if (vI.notificationBar) vI.notificationBar.dump("## smartIdentity: __autoTimestamp()\n");
     62        if (this._IDisVID) {
     63            if (vI.notificationBar) vI.notificationBar.dump("## smartIdentity: Virtual Identity in use, aborting\n");
    6864            return;
    6965        }
    7066
    71         var current_email = getCurrentIdentity().email.split("@");
     67        var current_email = this._preselectedID.email.split("@");
    7268        var localpart = current_email[0];
    7369        var domain = current_email[1];
    7470       
    75         vI.notificationBar.dump("## smartIdentity: current email: " + current_email[0] + "@" + current_email[1] + "\n");
    76        
    77         var autoString = vI.main.preferences.getCharPref("autoString");
    78         var formatString = vI.main.preferences.getCharPref("autoTimeFormat");
     71        if (vI.notificationBar) vI.notificationBar.dump("## smartIdentity: current email: " + current_email[0] + "@" + current_email[1] + "\n");
     72       
     73        var autoString = this._pref.getCharPref("autoString");
     74        var formatString = this._pref.getCharPref("autoTimeFormat");
    7975       
    8076        var dateObj = new Date(); var dateString = "";
     
    8581       
    8682        var new_email = autoString.replace(/%l/g, localpart).replace(/%d/g, domain).replace(/%t/g,dateString);
    87         vI.notificationBar.dump("## smartIdentity: new email: " + new_email + "\n");
    88 
    89         vI.notificationBar.setNote(vI.main.elements.strings.getString("vident.smartIdentity.vIUsage") + ".",
    90                     "smart_reply_notification");
    91 
    92         document.getElementById("msgIdentity_clone").email = new_email;
     83        if (vI.notificationBar) vI.notificationBar.dump("## smartIdentity: new email: " + new_email + "\n");
     84
     85        var newIdentity = new vI.identityData(new_email,
     86            this._preselectedID.fullName, this._preselectedID.key, this._preselectedID.smtpServerKey, null, null)
     87
     88        this._allIdentities.addWithoutDuplicates(newIdentity);
     89        this._selectedValue = 0;
    9390    },
    9491   
    9592    __ignoreID : function() {
    96         vI.notificationBar.dump("## smartIdentity: checking " + vI.main.preferences.getCharPref("idSelection_ignoreIDs") + " against " + vI.main.elements.Obj_MsgIdentity.value + "\n")
     93        if (vI.notificationBar) vI.notificationBar.dump("## smartIdentity: checking " + this._pref.getCharPref("idSelection_ignoreIDs") + " against " + this._preselectedID.key + "\n")
    9794        // check if usage if virtual Identities should be used at all for the currently selected ID
    98         if (vI.main.preferences.getCharPref("idSelection_ignoreIDs").indexOf(":" + vI.main.elements.Obj_MsgIdentity.value + ":") != -1) {
    99             vI.notificationBar.dump("## smartIdentity: not using virtual Identites for ID " + vI.main.elements.Obj_MsgIdentity.value + "\n");
     95        if (this._pref.getCharPref("idSelection_ignoreIDs").indexOf(":" + this._preselectedID.key + ":") != -1) {
     96            if (vI.notificationBar) vI.notificationBar.dump("## smartIdentity: not using virtual Identites for ID " + this._preselectedID.key + "\n");
    10097            return true;
    10198        }
     
    104101   
    105102    NewMail : function() {
    106         if (smartIdentity.__ignoreID()) return;
    107        
    108         var storageIdentities = new vI.identityCollection();
    109         vI.storage.getVIdentityFromAllRecipients(storageIdentities);
    110        
    111         if (storageIdentities.number > 0) smartIdentity.__smartIdentitySelection(storageIdentities, false)
    112         else if (vI.main.preferences.getBoolPref("autoTimestamp")) smartIdentity.__autoTimestamp();
    113     },
    114    
    115     ReplyOnSent : function(hdr) {
    116         vI.notificationBar.dump("## smartIdentity: ReplyOnSent() (rules like SmartDraft)\n");
    117        
    118         var allIdentities = new vI.identityCollection();
    119 
    120         smartIdentity.__SmartDraftOrReplyOnSent(hdr, allIdentities);
    121         var storageIdentities = new vI.identityCollection();
    122         vI.storage.getVIdentityFromAllRecipients(storageIdentities);
    123        
    124         allIdentities.mergeWithoutDuplicates(storageIdentities);
    125            
    126         if (allIdentities.number > 0) smartIdentity.__smartIdentitySelection(allIdentities, true);
    127 
     103        if (vI.notificationBar) vI.notificationBar.dump("## smartIdentity: NewMail()\n");
     104        if (this.__ignoreID()) return;
     105        this._rdfDatasourceAccess.getVIdentityFromAllRecipients(this._allIdentities, this._recipients);
     106        if (this._allIdentities.number == 0 && this._pref.getBoolPref("autoTimestamp")) this.__autoTimestamp();
     107    },
     108   
     109    _foundExistingIdentity : function() {
     110        /* compare with existing Identities                                     */
     111        for (var index = 0; index < this._allIdentities.number; index++) {
     112            var existingID = this._allIdentities.identityDataCollection[index].isExistingIdentity(false);
     113            if (existingID) {
     114                this._allIdentities.identityDataCollection[index].id.key = existingID;  // set found identity
     115                // reorder list of Identities to prefer it on autoselect
     116                // has to be done before Identities are added to the Menu
     117                if (vI.notificationBar) vI.notificationBar.dump("## smartIdentity: found existing Identity, reorder to prefer this one.\n");
     118                var firstIdentity = this._allIdentities.identityDataCollection[index];
     119                for (var i = index; index > 0; index--) {
     120                    this._allIdentities.identityDataCollection[index] = this._allIdentities.identityDataCollection[index-1];
     121                }
     122                this._allIdentities.identityDataCollection[0] = firstIdentity;
     123                return { key: index };
     124            }
     125        }
     126        return null;
     127    },
     128   
     129    ReplyOnSent : function() {
     130        if (vI.notificationBar) vI.notificationBar.dump("## smartIdentity: ReplyOnSent() (rules like SmartDraft)\n");
     131        this.__SmartDraftOrReplyOnSent();
     132        this._rdfDatasourceAccess.getVIdentityFromAllRecipients(this._allIdentities, this._recipients);
    128133    },
    129134
    130135    Draft : function() {
    131         vI.notificationBar.dump("## smartIdentity: Draft()\n");
    132        
    133         var allIdentities = new vI.identityCollection();
    134 
    135         var draftHdr = smartIdentity.messenger.
    136             messageServiceFromURI(gMsgCompose.originalMsgURI).messageURIToMsgHdr(gMsgCompose.originalMsgURI);
    137         // fails with seamonkey 1.1.11, so just try to read to draft id
    138         try { draftHdr = smartIdentity.messenger.
    139             messageServiceFromURI(gMsgCompose.compFields.draftId).messageURIToMsgHdr(gMsgCompose.compFields.draftId);
    140         } catch (ex) { };
    141 
    142         smartIdentity.__SmartDraftOrReplyOnSent(draftHdr, allIdentities);
    143         var storageIdentities = new vI.identityCollection();
    144         vI.storage.getVIdentityFromAllRecipients(storageIdentities);
    145        
    146         allIdentities.mergeWithoutDuplicates(storageIdentities);
    147            
    148         if (allIdentities.number > 0) smartIdentity.__smartIdentitySelection(allIdentities, true);
    149     },
    150    
    151     __parseHeadersWithArray: function(hdr, allIdentities) {
     136        if (vI.notificationBar) vI.notificationBar.dump("## smartIdentity: Draft()\n");
     137       
     138        this.__SmartDraftOrReplyOnSent();
     139        this._rdfDatasourceAccess.getVIdentityFromAllRecipients(this._allIdentities, this._recipients);
     140    },
     141   
     142    __parseHeadersWithArray: function(header, identityCollection) {
    152143        var emails = {}; var fullNames = {}; var combinedNames = {};
    153         var number = vI.main.headerParser.parseHeadersWithArray(hdr, emails, fullNames, combinedNames);
     144        var number = this._headerParser.parseHeadersWithArray(header, emails, fullNames, combinedNames);
    154145        for (var index = 0; index < number; index++) {
    155146            var newIdentity = new vI.identityData(emails.value[index], fullNames.value[index],
    156147                null, vI.NO_SMTP_TAG, null, null);
    157             allIdentities.addWithoutDuplicates(newIdentity);
     148            identityCollection.addWithoutDuplicates(newIdentity);
    158149        }
    159150    },
    160151
    161152    // this function checks if we have a draft-case and Smart-Draft should replace the Identity
    162     __SmartDraftOrReplyOnSent : function(hdr, allIdentities) {
    163         if (!vI.main.preferences.getBoolPref("smart_draft"))
    164             { vI.notificationBar.dump("## smartIdentity: SmartDraft deactivated\n"); return; }
    165 
    166         vI.notificationBar.dump("## smartIdentity: __SmartDraftOrReplyOnSent()\n");
    167 
    168         if (hdr) {
    169             smartIdentity.__parseHeadersWithArray(hdr.author, allIdentities)
    170             vI.notificationBar.dump("## smartIdentity: sender '" + allIdentities.identityDataCollection[0].combinedName + "'\n");
    171         }
    172         else vI.notificationBar.dump("## smartIdentity: __SmartDraftOrReplyOnSent: No Header found, shouldn't happen\n");
    173     },
    174    
    175     __filterAddresses : function(smartIdentities) {
     153    __SmartDraftOrReplyOnSent : function() {
     154        if (!this._pref.getBoolPref("smart_draft"))
     155            { if (vI.notificationBar) vI.notificationBar.dump("## smartIdentity: SmartDraft deactivated\n"); return; }
     156
     157        if (vI.notificationBar) vI.notificationBar.dump("## smartIdentity: __SmartDraftOrReplyOnSent()\n");
     158
     159        if (this._msgHdr) {
     160            this.__parseHeadersWithArray(this._msgHdr.author, this._allIdentities)
     161            if (vI.notificationBar) vI.notificationBar.dump("## smartIdentity: sender '" + this._allIdentities.identityDataCollection[0].combinedName + "'\n");
     162        }
     163        else if (vI.notificationBar) vI.notificationBar.dump("## smartIdentity: __SmartDraftOrReplyOnSent: No Header found, shouldn't happen\n");
     164    },
     165   
     166    __filterAddresses : function() {
    176167        var returnIdentities = new vI.identityCollection();
    177168       
    178169        var filterList  =
    179             vI.main.unicodeConverter.ConvertToUnicode(vI.main.preferences.getCharPref("smart_reply_filter")).split(/\n/)
     170            this._unicodeConverter.ConvertToUnicode(this._pref.getCharPref("smart_reply_filter")).split(/\n/)
    180171        if (filterList.length == 0) filterList[0] == ""
    181172       
     
    184175            var recentfilterType; var skipRegExp = false;
    185176            if (filterList.length <= 1 && filterList[0] == "")
    186                 { vI.notificationBar.dump("## smartIdentity: no filters configured\n"); recentfilterType = filterType.None; }
     177                { if (vI.notificationBar) vI.notificationBar.dump("## smartIdentity: no filters configured\n"); recentfilterType = filterType.None; }
    187178            else if (/^[+-]?\/(.*)\/$/.exec(filterList[i]))
    188                 { vI.notificationBar.dump("## smartIdentity: filter emails with RegExp '"
     179                { if (vI.notificationBar) vI.notificationBar.dump("## smartIdentity: filter emails with RegExp '"
    189180                    + filterList[i].replace(/\\/g,"\\\\") + "'\n"); recentfilterType = filterType.RegExp; }
    190             else    { vI.notificationBar.dump("## smartIdentity: filter emails, compare with '"
     181            else    { if (vI.notificationBar) vI.notificationBar.dump("## smartIdentity: filter emails, compare with '"
    191182                    + filterList[i] + "'\n"); recentfilterType = filterType.StrCmp; }
    192             for (var j = 0; j < smartIdentities.number; j++) { // check if recent email-address (pre-choosen identity) is found in
     183            for (var j = 0; j < this._allIdentities.number; j++) { // check if recent email-address (pre-choosen identity) is found in
    193184            // copied and adapted from correctIdentity, thank you for the RegExp-idea!
    194185                var add_addr = false;
     
    200191                        try {   /^[+-]?\/(.*)\/$/.exec(filterList[i]);
    201192                            if ( filterList[i][0] == "-" ) {
    202                                 if (smartIdentities.identityDataCollection[j].email.match(new RegExp(RegExp.$1,"i")))
    203                                     smartIdentities.dropIdentity(j--);
     193                                if (this._allIdentities.identityDataCollection[j].email.match(new RegExp(RegExp.$1,"i")))
     194                                    this._allIdentities.dropIdentity(j--);
    204195                            } else
    205                                 add_addr = (smartIdentities.identityDataCollection[j].email.match(new RegExp(RegExp.$1,"i")));
     196                                add_addr = (this._allIdentities.identityDataCollection[j].email.match(new RegExp(RegExp.$1,"i")));
    206197                        }
    207198                        catch(vErr) {
    208                             vI.notificationBar.addNote(
     199                            if (vI.notificationBar) vI.notificationBar.addNote(
    209200                                vI.main.elements.strings.getString("vident.smartIdentity.ignoreRegExp") +
    210201                                +filterList[i].replace(/\\/g,"\\\\") + " .",
     
    213204                        break;
    214205                    case filterType.StrCmp:
    215                         add_addr = ( smartIdentities.identityDataCollection[j].email.toLowerCase().indexOf(filterList[i].toLowerCase()) != -1)
     206                        add_addr = ( this._allIdentities.identityDataCollection[j].email.toLowerCase().indexOf(filterList[i].toLowerCase()) != -1)
    216207                        break;
    217208                }
    218                 if (add_addr)   returnIdentities.addWithoutDuplicates(smartIdentities.identityDataCollection[j])
    219             }
    220         }
    221         smartIdentities.takeOver(returnIdentities);
    222     },
    223    
    224     __smartReplyCollectAddresses : function(hdr, allIdentities) {
     209                if (add_addr)   returnIdentities.addWithoutDuplicates(this._allIdentities.identityDataCollection[j])
     210            }
     211        }
     212        this._allIdentities.takeOver(returnIdentities);
     213    },
     214   
     215    __smartReplyCollectAddresses : function() {
    225216        // add emails from selected headers (stored by vI_getHeader.xul/js)
    226         var reply_headers = vI.main.unicodeConverter.ConvertToUnicode(vI.main.preferences.getCharPref("smart_reply_headers")).split(/\n/)
     217        var reply_headers = this._unicodeConverter.ConvertToUnicode(this._pref.getCharPref("smart_reply_headers")).split(/\n/)
    227218                   
    228219        for (var index = 0; index < reply_headers.length; index++) {
     
    243234           
    244235            // if mailing-list ignore to-header (usually the mailing list address)
    245             if (replyHeaderNameToRead == "to" && hdr.getStringProperty("vI_list-id")) {
    246                 vI.notificationBar.dump("## smartIdentity: header 'list-id' found (mailinglist), skipping header 'to'\n");
     236            if (replyHeaderNameToRead == "to" && this._msgHdr.getStringProperty("vI_list-id")) {
     237                if (vI.notificationBar) vI.notificationBar.dump("## smartIdentity: header 'list-id' found (mailinglist), skipping header 'to'\n");
    247238                continue;
    248239            }
    249240           
    250241            // ------------- read the stored header -------------------------------
    251             var value = vI.main.unicodeConverter.ConvertToUnicode(hdr.getStringProperty("vI_" + replyHeaderNameToRead))
    252             vI.notificationBar.dump("## smartIdentity: reading header '" +
     242            var value = this._unicodeConverter.ConvertToUnicode(this._msgHdr.getStringProperty("vI_" + replyHeaderNameToRead))
     243/*          let window3pane =  Components.classes['@mozilla.org/appshell/window-mediator;1']
     244                 .getService(Components.interfaces.nsIWindowMediator)
     245                 .getMostRecentWindow("mail:3pane");
     246           
     247            if (vI.notificationBar) vI.notificationBar.dump("## smartIdentity: found stored header '" +
     248                replyHeaderNameToRead + "': '" + window3pane.virtualIdentityExtension.storedHeaders["vI_" + replyHeaderNameToRead] + "'\n");*/
     249           
     250            if (vI.notificationBar) vI.notificationBar.dump("## smartIdentity: reading header '" +
    253251                replyHeaderNameToRead + "': '" + value + "'\n");
    254252           
    255253            // ------------- parse address-string to get a field of single email-addresses
    256254            var splitted = new vI.identityCollection();
    257             smartIdentity.__parseHeadersWithArray(value, splitted);
    258            
    259             // move found addresses step by step to allIdentities, and change values if requested
     255            this.__parseHeadersWithArray(value, splitted);
     256           
     257            // move found addresses step by step to this._allIdentities, and change values if requested
    260258            for (var i = 0; i < splitted.number; i++) {
    261259                // if there is no email than it makes no sense to use it as a sender
    262260                if (!splitted.identityDataCollection[i].email.match(/^.*@.*$/)) {
    263                     vI.notificationBar.dump("## smartIdentity:   skipping '" +
     261                    if (vI.notificationBar) vI.notificationBar.dump("## smartIdentity:   skipping '" +
    264262                    splitted.identityDataCollection[i].email + "', no email\n")
    265263                    continue;
     
    268266                if (replyHeaderEmptyFullNames) splitted.identityDataCollection[i].fullName = ""
    269267
    270                 allIdentities.addWithoutDuplicates(splitted.identityDataCollection[i]);
    271 
    272                 vI.notificationBar.dump("## smartIdentity:   found '" +
     268                this._allIdentities.addWithoutDuplicates(splitted.identityDataCollection[i]);
     269
     270                if (vI.notificationBar) vI.notificationBar.dump("## smartIdentity:   found '" +
    273271                    splitted.identityDataCollection[i].combinedName + "'\n")
    274272            }
     
    277275   
    278276    Reply : function() {
    279         var hdr = smartIdentity.messenger.
    280             messageServiceFromURI(gMsgCompose.originalMsgURI).messageURIToMsgHdr(gMsgCompose.originalMsgURI);
    281 
    282         vI.notificationBar.dump("## smartIdentity: Reply()\n");
    283 
    284         if (hdr && !gMsgCompose.compFields.newsgroups && !hdr.getStringProperty("vI_content_base")) {
     277        if (vI.notificationBar) vI.notificationBar.dump("## smartIdentity: Reply()\n");
     278
     279        if (this._msgHdr && this._newsgroup && !this._msgHdr.getStringProperty("vI_content_base")) {
    285280        //  RFC 2821 (http://www.ietf.org/rfc/rfc2821.txt) says:
    286281        //  "4.4 Trace Information
     
    292287        //  hidden option smart_detectByReceivedHeader will act as a switch for not RFC-compliant servers
    293288            // RFC-compliant
    294             if (vI.main.preferences.getBoolPref("smart_detectByReceivedHeader")) {
    295                 if (!hdr.getStringProperty("vI_received")) { // mail was not received
    296                     vI.notificationBar.dump("## smartIdentity: reply on non-received (sent?) mail. Using SmartDraft. \n");
    297                     smartIdentity.ReplyOnSent(hdr);
     289            if (this._pref.getBoolPref("smart_detectByReceivedHeader")) {
     290                if (!this._msgHdr.getStringProperty("vI_received")) { // mail was not received
     291                    if (vI.notificationBar) vI.notificationBar.dump("## smartIdentity: reply on non-received (sent?) mail. Using SmartDraft. \n");
     292                    this.ReplyOnSent();
    298293                    return;
    299294                }
     
    304299                const MSG_FOLDER_FLAG_SENTMAIL = 0x0200;
    305300
    306                 if (hdr && (hdr.folder.flags & MSG_FOLDER_FLAG_SENTMAIL)) {
    307                     vI.notificationBar.dump("## smartIdentity: reply from Sent folder.");
    308                     if (hdr.folder.flags & MSG_FOLDER_FLAG_INBOX)
    309                         vI.notificationBar.dump(" Folder is INBOX, assuming Reply-Case. \n");
     301                if (this._msgHdr && (this._msgHdr.folder.flags & MSG_FOLDER_FLAG_SENTMAIL)) {
     302                    if (vI.notificationBar) vI.notificationBar.dump("## smartIdentity: reply from Sent folder.");
     303                    if (this._msgHdr.folder.flags & MSG_FOLDER_FLAG_INBOX)
     304                        if (vI.notificationBar) vI.notificationBar.dump(" Folder is INBOX, assuming Reply-Case. \n");
    310305                    else {
    311                         vI.notificationBar.dump(" Using SmartDraft. \n");
    312                         smartIdentity.ReplyOnSent(hdr);
     306                        if (vI.notificationBar) vI.notificationBar.dump(" Using SmartDraft. \n");
     307                        this.ReplyOnSent();
    313308                        return;
    314309                    }
     
    317312        }
    318313       
    319         if (smartIdentity.__ignoreID()) return;
     314        if (this.__ignoreID()) return;
    320315       
    321316        var storageIdentities = new vI.identityCollection();
    322         vI.storage.getVIdentityFromAllRecipients(storageIdentities);
    323        
    324         var smartIdentities = new vI.identityCollection();
    325         if (storageIdentities.number == 0 || !vI.main.preferences.getBoolPref("idSelection_storage_ignore_smart_reply"))
    326             smartIdentity.__SmartReply(hdr, smartIdentities);
    327         else vI.notificationBar.dump("## smartIdentity: SmartReply skipped, Identities in Storage found.\n");
     317        this._rdfDatasourceAccess.getVIdentityFromAllRecipients(storageIdentities, this._recipients);
     318       
     319        if (storageIdentities.number == 0 || !this._pref.getBoolPref("idSelection_storage_ignore_smart_reply"))
     320            this.__SmartReply();
     321        else if (vI.notificationBar) vI.notificationBar.dump("## smartIdentity: SmartReply skipped, Identities in Storage found.\n");
    328322
    329323        // merge SmartReply-Identities and Storage-Identites
    330         if (vI.main.preferences.getBoolPref("idSelection_storage_prefer_smart_reply"))
    331             { smartIdentities.mergeWithoutDuplicates(storageIdentities); var allIdentities = smartIdentities; }
    332         else
    333             { storageIdentities.mergeWithoutDuplicates(smartIdentities); var allIdentities = storageIdentities; }
    334        
    335         vI.notificationBar.dump("## smartIdentity: merged SmartReply & Storage, " + allIdentities.number + " address(es) left\n")
    336        
    337         if (allIdentities.number > 0) smartIdentity.__smartIdentitySelection(allIdentities, false);
     324        if (this._pref.getBoolPref("idSelection_storage_prefer_smart_reply"))
     325            { this._allIdentities.mergeWithoutDuplicates(storageIdentities); }
     326        else {
     327            var smartIdentities = this._allIdentities;
     328            this._allIdentities = storageIdentities;       
     329            this._allIdentities.mergeWithoutDuplicates(smartIdentities);
     330        }
     331       
     332        if (vI.notificationBar) vI.notificationBar.dump("## smartIdentity: merged SmartReply & Storage, " + this._allIdentities.number + " address(es) left\n")
    338333    },
    339334   
    340335    // this function checks if we have a reply-case and Smart-Reply should replace the Identity
    341     __SmartReply : function(hdr, smartIdentities) {
    342         if (!vI.main.preferences.getBoolPref("smart_reply"))
    343             { vI.notificationBar.dump("## smartIdentity: SmartReply deactivated\n"); return; }
    344         if (gMsgCompose.compFields.newsgroups && !vI.main.preferences.getBoolPref("smart_reply_for_newsgroups")) {
    345             vI.notificationBar.dump("## smartIdentity: SmartReply, answering to a newsgroup, aborting\n");
     336    __SmartReply : function() {
     337        if (!this._pref.getBoolPref("smart_reply"))
     338            { if (vI.notificationBar) vI.notificationBar.dump("## smartIdentity: SmartReply deactivated\n"); return; }
     339        if (this._newsgroup && !this._pref.getBoolPref("smart_reply_for_newsgroups")) {
     340            if (vI.notificationBar) vI.notificationBar.dump("## smartIdentity: SmartReply, answering to a newsgroup, aborting\n");
    346341            return;
    347342        }
    348343
    349         vI.notificationBar.dump("## smartIdentity: __SmartReply()\n");
    350         vI.notificationBar.dump("## smartIdentity: ----------------------------------------------------------\n")
    351         if (hdr) {
     344        if (vI.notificationBar) vI.notificationBar.dump("## smartIdentity: __SmartReply()\n");
     345        if (vI.notificationBar) vI.notificationBar.dump("## smartIdentity: ----------------------------------------------------------\n")
     346        if (this._msgHdr) {
    352347            /* first step: collect addresses */
    353             smartIdentity.__smartReplyCollectAddresses(hdr, smartIdentities);
    354             vI.notificationBar.dump("## smartIdentity: " + smartIdentities.number + " address(es) after parsing, before filtering\n")
     348            this.__smartReplyCollectAddresses();
     349            if (vI.notificationBar) vI.notificationBar.dump("## smartIdentity: " + this._allIdentities.number + " address(es) after parsing, before filtering\n")
    355350           
    356351            /* second step: filter (and sort) addresses */
    357             smartIdentity.__filterAddresses(smartIdentities);
    358            
    359             vI.notificationBar.dump("## smartIdentity: filtering done, " + smartIdentities.number + " address(es) left\n")
     352            this.__filterAddresses();
     353           
     354            if (vI.notificationBar) vI.notificationBar.dump("## smartIdentity: filtering done, " + this._allIdentities.number + " address(es) left\n")
    360355           
    361356            /* set default FullName */
    362             var smart_reply_defaultFullName = vI.main.unicodeConverter.ConvertToUnicode(vI.main.preferences.getCharPref("smart_reply_defaultFullName"))
     357            var smart_reply_defaultFullName = this._unicodeConverter.ConvertToUnicode(this._pref.getCharPref("smart_reply_defaultFullName"))
    363358            if (smart_reply_defaultFullName != "") {
    364                 for (var index = 0; index < smartIdentities.number; index++) {
    365                     if (smartIdentities.identityDataCollection[index].fullName == "") {
    366                         smartIdentities.identityDataCollection[index].fullName = smart_reply_defaultFullName
    367                         vI.notificationBar.dump("## smartIdentity: added default FullName '" +
    368                             smart_reply_defaultFullName + "' to '" + smartIdentities.identityDataCollection[index].email + "'\n")
     359                for (var index = 0; index < this._allIdentities.number; index++) {
     360                    if (this._allIdentities.identityDataCollection[index].fullName == "") {
     361                        this._allIdentities.identityDataCollection[index].fullName = smart_reply_defaultFullName
     362                        if (vI.notificationBar) vI.notificationBar.dump("## smartIdentity: added default FullName '" +
     363                            smart_reply_defaultFullName + "' to '" + this._allIdentities.identityDataCollection[index].email + "'\n")
    369364                    }
    370365                }
     
    374369            /* if match replace FullName with existing one, keep identity in list by now        */
    375370            /* will not be added to the menu but probably choosen with __smartIdentitySelection     */
    376             if (vI.main.preferences.getBoolPref("smart_reply_ignoreFullName")) {
    377                 vI.notificationBar.dump("## smartIdentity: compare with existing Identities (ignoring FullNames).\n")
    378            
    379                 for (var index = 0; index < smartIdentities.number; index++) {
    380                     var idKey = smartIdentities.identityDataCollection[index].isExistingIdentity(true);
     371            if (this._pref.getBoolPref("smart_reply_ignoreFullName")) {
     372                if (vI.notificationBar) vI.notificationBar.dump("## smartIdentity: compare with existing Identities (ignoring FullNames).\n")
     373           
     374                for (var index = 0; index < this._allIdentities.number; index++) {
     375                    var idKey = this._allIdentities.identityDataCollection[index].isExistingIdentity(true);
    381376                    if (idKey) {
    382377                        var newFullName = gAccountManager.getIdentity(idKey).fullName;
    383                         smartIdentities.identityDataCollection[index].fullName = newFullName;
    384                         vI.notificationBar.dump("## smartIdentity: replaced Fullname of '" + smartIdentities.identityDataCollection[index].email + "' with '" + newFullName + "' \n");
     378                        this._allIdentities.identityDataCollection[index].fullName = newFullName;
     379                        if (vI.notificationBar) vI.notificationBar.dump("## smartIdentity: replaced Fullname of '" + this._allIdentities.identityDataCollection[index].email + "' with '" + newFullName + "' \n");
    385380                    }
    386381                }
    387382            }
    388383        }
    389         else vI.notificationBar.dump("## smartIdentity: SmartReply skipped. No Header-information found.\n");
    390        
    391         vI.notificationBar.dump("## smartIdentity: ----------------------------------------------------------\n")
    392     },
    393    
    394     __smartIdentitySelection : function(allIdentities, autocreate) {
    395         /* compare with existing Identities                                     */
    396         for (var index = 0; index < allIdentities.number; index++) {
    397             var existingID = allIdentities.identityDataCollection[index].isExistingIdentity(true);
    398             if (existingID) {
    399                 allIdentities.identityDataCollection[index].id.key = existingID;    // set found identity
    400                 // if 'preferExisting' than select it and return
    401                 if (vI.main.preferences.getBoolPref("idSelection_preferExisting")) {
    402                     vI.notificationBar.dump("## smartIdentity: found existing Identity, use without interaction.\n");
    403                     // add all Indentities to Clone Menu before selecting and leaving the function
    404                     document.getElementById("msgIdentity_clone").addIdentitiesToCloneMenu(allIdentities);
    405                     smartIdentity.changeIdentityToSmartIdentity(allIdentities, index);
    406                     return;
    407                 }
    408                 // else reorder list of Identities to prefer it on autoselect
    409                 // has to be done before Identities are added to the Menu
    410                 vI.notificationBar.dump("## smartIdentity: found existing Identity, prefer this one.\n");
    411                 var firstIdentity = allIdentities.identityDataCollection[index];
    412                 for (var i = index; index > 0; index--) {
    413                     allIdentities.identityDataCollection[index] = allIdentities.identityDataCollection[index-1];
    414                 }
    415                 allIdentities.identityDataCollection[0] = firstIdentity;
    416                 break;
    417             }
    418         }
    419        
    420         document.getElementById("msgIdentity_clone").addIdentitiesToCloneMenu(allIdentities);
    421 
    422         if (!autocreate && vI.main.preferences.getBoolPref("idSelection_ask") &&
    423             ((allIdentities.number == 1 && vI.main.preferences.getBoolPref("idSelection_ask_always"))
    424                 || allIdentities.number > 1)) {
    425             for (var index = 0; index < allIdentities.number; index++) {
    426                 vI.notificationBar.dump("## smartIdentityReplyDialog index=" + index + ": '" + allIdentities.identityDataCollection[index].combinedName + "' "
    427                     + "(" + allIdentities.identityDataCollection[index].id.value + "," + allIdentities.identityDataCollection[index].smtp.value + ")\n");
     384        else if (vI.notificationBar) vI.notificationBar.dump("## smartIdentity: SmartReply skipped. No Header-information found.\n");
     385       
     386        if (vI.notificationBar) vI.notificationBar.dump("## smartIdentity: ----------------------------------------------------------\n")
     387    },
     388   
     389
     390};
     391
     392var smartIdentity = {
     393    _pref : Components.classes["@mozilla.org/preferences-service;1"]
     394        .getService(Components.interfaces.nsIPrefService)
     395        .getBranch("extensions.virtualIdentity."),
     396
     397    messenger : Components.classes["@mozilla.org/messenger;1"].createInstance()
     398        .QueryInterface(Components.interfaces.nsIMessenger),
     399   
     400    _smartIdentityCollection : null,
     401       
     402    // After Loading the MessageComposeDialog, check if smartIdentity is needed
     403    init : function() {
     404        var msgHdr;
     405        var msgComposeTypeReference = Components.interfaces.nsIMsgCompType;
     406        var newsgroup = gMsgCompose.compFields.newsgroups;
     407        var autocreate = false;
     408        if (vI.notificationBar) vI.notificationBar.dump("## smartIdentityCollection: msgComposeTypeReference = " + gMsgCompose.type + "\n");
     409        switch (gMsgCompose.type) {
     410            case msgComposeTypeReference.ForwardAsAttachment:
     411            case msgComposeTypeReference.ForwardInline:
     412            case msgComposeTypeReference.Reply:
     413            case msgComposeTypeReference.ReplyAll:
     414            case msgComposeTypeReference.ReplyToGroup: // reply to a newsgroup, would possibly be stopped later
     415            case msgComposeTypeReference.ReplyToSender:
     416            case msgComposeTypeReference.ReplyToSenderAndGroup: // reply to a newsgroup, would possibly be stopped later
     417            case msgComposeTypeReference.ReplyWithTemplate:
     418            case msgComposeTypeReference.ReplyToList:
     419                if (vI.notificationBar) vI.notificationBar.dump("## smartIdentityCollection: Reply\n");
     420                msgHdr = smartIdentity.messenger.
     421                    messageServiceFromURI(gMsgCompose.originalMsgURI).messageURIToMsgHdr(gMsgCompose.originalMsgURI);
     422                smartIdentity._smartIdentityCollection = new smartIdentityCollection(msgHdr, getCurrentIdentity(), document.getElementById("msgIdentity_clone").vid, newsgroup, this._getRecipients());
     423                smartIdentity._smartIdentityCollection.Reply();
     424                autocreate = false; break;
     425            case msgComposeTypeReference.Draft:
     426            case msgComposeTypeReference.Template:
     427                if (vI.notificationBar) vI.notificationBar.dump("## smartIdentityCollection: Draft\n");
     428                msgHdr = smartIdentity.messenger.
     429                    messageServiceFromURI(gMsgCompose.compFields.draftId).messageURIToMsgHdr(gMsgCompose.compFields.draftId);
     430                smartIdentity._smartIdentityCollection = new smartIdentityCollection(msgHdr, getCurrentIdentity(), document.getElementById("msgIdentity_clone").vid, newsgroup, this._getRecipients());
     431                smartIdentity._smartIdentityCollection.Draft();
     432                autocreate = false; break;
     433            case msgComposeTypeReference.New:
     434            case msgComposeTypeReference.NewsPost:
     435            case msgComposeTypeReference.MailToUrl:
     436                if (vI.notificationBar) vI.notificationBar.dump("## smartIdentityCollection: New Mail\n");
     437                smartIdentity._smartIdentityCollection = new smartIdentityCollection(null, getCurrentIdentity(), document.getElementById("msgIdentity_clone").vid, newsgroup, this._getRecipients());   
     438                // to enable composing new email with new identity: identity is hidden in subject line
     439                // used for instance from conversation addon
     440                var subject = gMsgCompose.compFields.subject.split(/\n/);
     441                if (subject.length > 1 && subject[1] == "virtualIdentityExtension") {
     442                    if (vI.notificationBar) vI.notificationBar.dump("## smartIdentity: NewMail() found stored identity preset: " + subject[2] + "\n");
     443                    smartIdentity._smartIdentityCollection.__parseHeadersWithArray(subject[2], smartIdentity._smartIdentityCollection._allIdentities);
     444                    gMsgCompose.compFields.subject = subject[0];
     445                    document.getElementById("msgSubject").value = subject[0];
     446                }
     447                else smartIdentity._smartIdentityCollection.NewMail();
     448                autocreate = true; break;
     449        }
     450        if (smartIdentity._smartIdentityCollection._allIdentities.number > 0) smartIdentity.__smartIdentitySelection(autocreate);
     451    },
     452   
     453    _getRecipients : function() {
     454        var recipients = [];
     455        for (var row = 1; row <= top.MAX_RECIPIENTS; row ++) {
     456            var recipientType = awGetPopupElement(row).selectedItem.getAttribute("value");
     457            if (recipientType == "addr_reply" || recipientType == "addr_followup" ||
     458                vI.storage.__isDoBcc(row) || awGetInputElement(row).value.match(/^\s*$/) ) continue;
     459            recipients.push( { recipient: awGetInputElement(row).value, recipientType : recipientType } );
     460        }
     461        return recipients;
     462    },
     463   
     464    __smartIdentitySelection : function(autocreate) {
     465        if (vI.notificationBar) vI.notificationBar.dump("## __smartIdentitySelection autocreate=" + autocreate + "\n");
     466       
     467        if (smartIdentity._pref.getBoolPref("idSelection_preferExisting")) {
     468            var existingIDIndex = smartIdentity._smartIdentityCollection._foundExistingIdentity();
     469            if (existingIDIndex) {
     470                if (vI.notificationBar) vI.notificationBar.dump("## smartIdentity: found existing Identity, use without interaction.\n");
     471                // add all Indentities to Clone Menu before selecting and leaving the function
     472                document.getElementById("msgIdentity_clone").addIdentitiesToCloneMenu(smartIdentity._smartIdentityCollection._allIdentities);
     473                smartIdentity.changeIdentityToSmartIdentity(smartIdentity._smartIdentityCollection._allIdentities, existingIDIndex.key);
     474                return;
     475            }
     476        }
     477       
     478        document.getElementById("msgIdentity_clone").addIdentitiesToCloneMenu(smartIdentity._smartIdentityCollection._allIdentities);
     479        if (vI.notificationBar) vI.notificationBar.dump("## __smartIdentitySelection smartIdentity._smartIdentityCollection._allIdentities.number=" +
     480                smartIdentity._smartIdentityCollection._allIdentities.number +
     481                " smartIdentity._pref.getBoolPref('idSelection_ask_always')=" +
     482                smartIdentity._pref.getBoolPref("idSelection_ask_always") +
     483                " smartIdentity._pref.getBoolPref('idSelection_ask')=" +
     484                smartIdentity._pref.getBoolPref("idSelection_ask") + "\n");
     485        if (!autocreate && smartIdentity._pref.getBoolPref("idSelection_ask") &&
     486            ((smartIdentity._smartIdentityCollection._allIdentities.number == 1 && smartIdentity._pref.getBoolPref("idSelection_ask_always"))
     487                || smartIdentity._smartIdentityCollection._allIdentities.number > 1)) {
     488            for (var index = 0; index < smartIdentity._smartIdentityCollection._allIdentities.number; index++) {
     489                if (vI.notificationBar) vI.notificationBar.dump("## smartIdentityReplyDialog index=" + index + ": '" + smartIdentity._smartIdentityCollection._allIdentities.identityDataCollection[index].combinedName + "' "
     490                    + "(" + smartIdentity._smartIdentityCollection._allIdentities.identityDataCollection[index].id.value + "," + smartIdentity._smartIdentityCollection._allIdentities.identityDataCollection[index].smtp.value + ")\n");
    428491            }
    429492            window.openDialog("chrome://v_identity/content/vI_smartReplyDialog.xul",0,
    430493                    "chrome, dialog, modal, alwaysRaised, resizable=yes",
    431                      allIdentities,
     494                     smartIdentity._smartIdentityCollection._allIdentities,
    432495                    /* callback: */ smartIdentity.changeIdentityToSmartIdentity).focus();
    433496        }
    434         else if (autocreate || vI.main.preferences.getBoolPref("idSelection_autocreate")) {
    435             smartIdentity.changeIdentityToSmartIdentity(allIdentities, 0);
     497        else if (autocreate || smartIdentity._pref.getBoolPref("idSelection_autocreate")) {
     498            smartIdentity.changeIdentityToSmartIdentity(smartIdentity._smartIdentityCollection._allIdentities, 0);
    436499        }   
    437500    },
    438501   
    439502    changeIdentityToSmartIdentity : function(allIdentities, selectedValue) {
    440         vI.notificationBar.dump("## changeIdentityToSmartIdentity selectedValue=" + selectedValue + ": '" + allIdentities.identityDataCollection[selectedValue].combinedName + "' "
     503        if (vI.notificationBar) vI.notificationBar.dump("## changeIdentityToSmartIdentity selectedValue=" + selectedValue + " from " + allIdentities.number + "\n");
     504        if (vI.notificationBar) vI.notificationBar.dump("## changeIdentityToSmartIdentity selectedValue=" + selectedValue + ": '" + allIdentities.identityDataCollection[selectedValue].combinedName + "' "
    441505            + "(" + allIdentities.identityDataCollection[selectedValue].id.value + "," + allIdentities.identityDataCollection[selectedValue].smtp.value + ")\n");
    442506        document.getElementById("msgIdentity_clone").selectedMenuItem = allIdentities.menuItems[selectedValue];
     
    445509            if (allIdentities.number > 1) label += " "
    446510                + vI.main.elements.strings.getString("vident.smartIdentity.moreThanOne");
    447             vI.notificationBar.addNote(label + ".", "smart_reply_notification");
     511            if (vI.notificationBar) vI.notificationBar.addNote(label + ".", "smart_reply_notification");
    448512        }
    449513        smartIdentity.__removeSmartIdentityFromRecipients(allIdentities, selectedValue);
     
    451515   
    452516    __removeSmartIdentityFromRecipients : function(allIdentities, index) {
    453         if (!vI.main.preferences.getBoolPref("idSelection_removeSmartIdentityFromRecipients")) return;
     517        if (!smartIdentity._pref.getBoolPref("idSelection_removeSmartIdentityFromRecipients")) return;
    454518       
    455519        // check if selected email is defined as doBcc address. If so, it should not be removed.
     
    488552                    awSetInputAndPopupValue(input, "", popup, "addr_to", -1);
    489553                    awCleanupRows()
    490                     vI.notificationBar.addNote(" " +
     554                    if (vI.notificationBar) vI.notificationBar.addNote(" " +
    491555                        vI.main.elements.strings.getString("vident.smartIdentity.remRecipient"),
    492556                        "smart_reply_notification");
     
    497561}
    498562vI.smartIdentity = smartIdentity;
     563vI.smartIdentityCollection = smartIdentityCollection;
    499564}});
  • chrome/content/v_identity/vI_storage.js

    r7666cb r9cedc0  
    3030virtualIdentityExtension.ns(function() { with (virtualIdentityExtension.LIB) {
    3131var storage = {
    32     multipleRecipients : null,
    3332    focusedElement : null,
     33    _pref : Components.classes["@mozilla.org/preferences-service;1"]
     34        .getService(Components.interfaces.nsIPrefService)
     35        .getBranch("extensions.virtualIdentity."),
    3436   
    3537    lastCheckedEmail : {},  // array of last checked emails per row,
    3638                // to prevent ugly double dialogs and time-consuming double-checks
    3739   
    38     rdfService : Components.classes["@mozilla.org/rdf/rdf-service;1"]
    39             .getService(Components.interfaces.nsIRDFService),
    40 
    41     prefroot : Components.classes["@mozilla.org/preferences-service;1"]
    42             .getService(Components.interfaces.nsIPrefService)
    43             .getBranch(null).QueryInterface(Components.interfaces.nsIPrefBranch2),
    44    
    45     rdfDatasource : null,    // local storage
     40    _rdfDatasourceAccess : null,    // local storage
    4641
    4742    clean: function() {
     
    5146        storage.firstUsedInputElement = null;
    5247        awSetInputAndPopupValue = storage.original_functions.awSetInputAndPopupValue;
    53         if (storage.rdfDatasource) storage.rdfDatasource.clean();
     48        if (storage._rdfDatasourceAccess) storage._rdfDatasourceAccess.clean();
    5449    },
    5550   
     
    9085    init: function() {
    9186        if (!storage.initialized) {
    92             storage.rdfDatasource = new vI.rdfDatasource("virtualIdentity.rdf");
     87            storage._rdfDatasourceAccess = new vI.rdfDatasourceAccess();
    9388
    9489            // better approach would be to use te onchange event, but this one is not fired in any change case
     
    130125   
    131126    firstUsedInputElement : null,   // this stores the first Element for which a Lookup in the Storage was successfull
    132     updateVIdentityFromStorage: function(inputElement) {       
    133         if (!vI.main.preferences.getBoolPref("storage"))
     127    updateVIdentityFromStorage: function(inputElement) {
     128        if (!storage._pref.getBoolPref("storage"))
    134129            { vI.notificationBar.dump("## storage: Storage deactivated\n"); return; }
    135130        vI.notificationBar.dump("## storage: updateVIdentityFromStorage()\n");
     
    155150        }
    156151        storage.lastCheckedEmail[row] = inputElement.value;
    157         var recipient = storage.__getDescriptionAndType(inputElement.value, recipientType);
    158 
    159         var matchResults = { storageData : {}, menuItem : {} };
    160         matchResults.storageData[0] = storage.rdfDatasource.readVIdentityFromRDF(recipient.recDesc, recipient.recType);
    161         matchResults.storageData[1] = storage.rdfDatasource.findMatchingFilter(recipient.recDesc);
    162 
    163         vI.notificationBar.dump("## storage: updateVIdentityFromStorage add found Identities to CloneMenu.\n");
    164         var matchIndex = null;
    165         for (var i = 0; i <= 1; i++) {
    166             if (matchResults.storageData[i]) {          // check if there is a result in direct match or filter
    167                 if (matchIndex == null) matchIndex = i;     // prefer direct match instead of filter
    168                 matchResults.menuItem[i] = document.getElementById("msgIdentity_clone")
    169                                 .addIdentityToCloneMenu(matchResults.storageData[i]);
    170             }
    171         }
    172         if (matchIndex == null) {
    173             vI.notificationBar.dump("## storage: updateVIdentityFromStorage no usable Storage-Data found.\n");
    174             return;
    175         }
    176         else {
    177             vI.notificationBar.dump("## storage: using data from " + ((matchIndex == 0)?"direct":"filter") + " match\n");
    178         }
     152       
     153        // firstUsedInputElement was set before and we are not editing the same
     154        var isNotFirstInputElement = (storage.firstUsedInputElement && storage.firstUsedInputElement != inputElement)
     155        var currentIdentity = document.getElementById("msgIdentity_clone").identityData
     156        var storageResult = storage._rdfDatasourceAccess.updateVIdentityFromStorage(inputElement.value, recipientType,
     157            currentIdentity, document.getElementById("msgIdentity_clone").vid, isNotFirstInputElement);
     158       
     159        if (storageResult.identityCollection.number == 0) return; // return if there was no match
     160        vI.notificationBar.dump("## storage: updateVIdentityFromStorage result: " + storageResult.result + "\n");
    179161        // found storageData, so store InputElement
    180162        if (!storage.firstUsedInputElement) storage.firstUsedInputElement = inputElement;
    181163       
    182         vI.notificationBar.dump("## storage: compare with current Identity\n");
    183         if (vI.main.preferences.getBoolPref("storage_getOneOnly") &&                    // if requested to retrieve only storageID for first recipient entered
    184             storage.firstUsedInputElement &&                        // and the request for the first recipient was already done
    185             storage.firstUsedInputElement != inputElement &&                // and it's not the same element we changed now
    186             !matchResults.storageData[matchIndex].equalsCurrentIdentity(false).equal)   // and this id is different than the current used one
    187                 vI.notificationBar.setNote(vI.main.elements.strings
    188                     .getString("vident.smartIdentity.vIStorageCollidingIdentity"),  // than drop the potential changes
    189                     "storage_notification");
    190         // only update fields if new Identity is different than old one.
    191         else {
    192             vI.notificationBar.dump("## storage: updateVIdentityFromStorage check if storage-data matches current Identity.\n");
    193             var compResult = matchResults.storageData[matchIndex].equalsCurrentIdentity(true);
    194             if (!compResult.equal) {
    195                 var warning = storage.__getWarning("replaceVIdentity", recipient, compResult.compareMatrix);
    196                 var msgIdentityCloneElem = document.getElementById("msgIdentity_clone")
    197                 if (    !msgIdentityCloneElem.vid ||
    198                     !vI.main.preferences.getBoolPref("storage_warn_vI_replace") ||
    199                     (storage.__askWarning(warning) == "accept")) {
    200                         msgIdentityCloneElem.selectedMenuItem = matchResults.menuItem[matchIndex];
    201                         if (msgIdentityCloneElem.vid)
    202                             vI.notificationBar.setNote(vI.main.elements.strings.getString("vident.smartIdentity.vIStorageUsage") + ".",
    203                             "storage_notification");
    204                 }
    205             }
    206             else {
    207                 vI.notificationBar.dump("## storage: updateVIdentityFromStorage doing nothing - equals current Identity.\n");
     164        var selectedMenuItem;
     165        if (storageResult.result != "equal") {
     166            for (var j = 0; j < storageResult.identityCollection.number; j++) {
     167                vI.notificationBar.dump("## storage: updateVIdentityFromStorage adding: " + storageResult.identityCollection.identityDataCollection[j].combinedName + "\n");
     168                selectedMenuItem = document.getElementById("msgIdentity_clone").addIdentityToCloneMenu(storageResult.identityCollection.identityDataCollection[j])
    208169            }
    209170        }
    210     },
    211    
    212     __getDescriptionAndType : function (recipient, recipientType) {
    213         if (recipientType == "addr_newsgroups") return { recDesc : recipient, recType : "newsgroup" }
    214         else if (storage.__isMailingList(recipient)) {
    215             vI.notificationBar.dump("## __getDescriptionAndType: '" + recipient + "' is MailList\n");
    216             return { recDesc : storage.__getMailListName(recipient), recType : "maillist" }
     171        if (storageResult.result == "accept") {
     172            vI.notificationBar.dump("## storage: updateVIdentityFromStorage selecting: " + storageResult.identityCollection.identityDataCollection[0].combinedName + "\n");
     173            document.getElementById("msgIdentity_clone").selectedMenuItem = selectedMenuItem;
     174            if (document.getElementById("msgIdentity_clone").vid)
     175                vI.notificationBar.setNote(vI.main.elements.strings.getString("vident.smartIdentity.vIStorageUsage") + ".",
     176                    "storage_notification");
    217177        }
    218         else {
    219             vI.notificationBar.dump("## __getDescriptionAndType: '" + recipient + "' is no MailList\n");
    220             var localIdentityData = new vI.identityData(recipient, null, null, null, null, null, null);
    221             return { recDesc : localIdentityData.combinedName, recType : "email" }
    222         }
    223     },
    224        
    225     storeVIdentityToAllRecipients : function(msgType) {
    226         if (msgType != nsIMsgCompDeliverMode.Now) return true;
    227         vI.notificationBar.dump("## storage: ----------------------------------------------------------\n")
    228         if (!vI.main.preferences.getBoolPref("storage"))
    229             { vI.notificationBar.dump("## storage: Storage deactivated\n"); return true; }
    230        
    231         if (vI.statusmenu.objStorageSaveMenuItem.getAttribute("checked") != "true") {
    232             vI.notificationBar.dump("## storage: SaveMenuItem not checked.\n")
    233             return true;
    234         }
    235        
    236         vI.notificationBar.dump("## storage: storeVIdentityToAllRecipients()\n");
    237        
    238         // check if there are multiple recipients
    239         storage.multipleRecipients = false;
    240         var recipients = 0;
    241         for (var row = 1; row <= top.MAX_RECIPIENTS; row ++) {
    242             var recipientType = awGetPopupElement(row).selectedItem.getAttribute("value");
    243             if (recipientType == "addr_reply" || recipientType == "addr_followup" ||
    244                 storage.__isDoBcc(row) || awGetInputElement(row).value.match(/^\s*$/) ) continue;
    245             if (recipients++ == 1) {
    246                 storage.multipleRecipients = true
    247                 vI.notificationBar.dump("## storage: multiple recipients found.\n")
    248                 break;
    249             }
    250         }           
    251        
    252         for (var row = 1; row <= top.MAX_RECIPIENTS; row ++) {
    253             var recipientType = awGetPopupElement(row).selectedItem.getAttribute("value");
    254             if (recipientType == "addr_reply" || recipientType == "addr_followup" ||
    255                 storage.__isDoBcc(row) || awGetInputElement(row).value.match(/^\s*$/) ) continue;
    256             if (!storage.__updateStorageFromVIdentity(awGetInputElement(row).value, recipientType)) {
    257                 vI.notificationBar.dump("## storage: --------------  aborted  ---------------------------------\n")
    258                 return false; // abort sending
    259             }
    260         }
    261         vI.notificationBar.dump("## storage: ----------------------------------------------------------\n");
    262         return true;
    263     },
    264    
    265     __getWarning : function(warningCase, recipient, compareMatrix) {
    266         var warning = { title: null, recLabel : null, recipient : null, warning : null, css: null, query : null, class : null };
    267         warning.title = vI.main.elements.strings.getString("vident." + warningCase + ".title")
    268         warning.recLabel = vI.main.elements.strings.getString("vident." + warningCase + ".recipient") + " (" + recipient.recType + "):"
    269         warning.recipient = recipient.recDesc;
    270         warning.warning =
    271             "<table class='" + warningCase + "'><thead><tr><th class='col1'/>" +
    272                 "<th class='col2'>" + vI.main.elements.strings.getString("vident." + warningCase + ".currentIdentity") + "</th>" +
    273                 "<th class='col3'>" + vI.main.elements.strings.getString("vident." + warningCase + ".storedIdentity") + "</th>" +
    274             "</tr></thead>" +
    275             "<tbody>" + compareMatrix + "</tbody>" +
    276             "</table>"
    277         warning.css = "vI.DialogBrowser.css";
    278         warning.query = vI.main.elements.strings.getString("vident." + warningCase + ".query");
    279         warning.class = warningCase;
    280         return warning;
    281     },
    282 
    283     __askWarning : function(warning) {
    284         var retVar = { returnValue: null };
    285         var answer = window.openDialog("chrome://v_identity/content/vI_Dialog.xul","",
    286                     "chrome, dialog, modal, alwaysRaised, resizable=yes",
    287                      warning, retVar)
    288         return retVar.returnValue;
    289     },
    290    
    291     __updateStorageFromVIdentity : function(recipient, recipientType) {
    292         vI.notificationBar.dump("## storage: __updateStorageFromVIdentity.\n")
    293         var dontUpdateMultipleNoEqual = (vI.main.preferences.getBoolPref("storage_dont_update_multiple") &&
    294                     storage.multipleRecipients)
    295         vI.notificationBar.dump("## storage: __updateStorageFromVIdentity dontUpdateMultipleNoEqual='" + dontUpdateMultipleNoEqual + "'\n")
    296         recipient = storage.__getDescriptionAndType(recipient, recipientType);
    297 
    298         var storageDataByType = storage.rdfDatasource.readVIdentityFromRDF(recipient.recDesc, recipient.recType);
    299         var storageDataByFilter = storage.rdfDatasource.findMatchingFilter(recipient.recDesc);
    300        
    301         // update (storing) of data by type is required if there is
    302         // no data stored by type (or different data stored) and no equal filter found
    303         var storageDataByTypeCompResult = storageDataByType?storageDataByType.equalsCurrentIdentity(true):null;
    304         var storageDataByTypeEqual = (storageDataByType && storageDataByTypeCompResult.equal);
    305         var storageDataByFilterEqual = (storageDataByFilter && storageDataByFilter.equalsCurrentIdentity(false).equal);
    306        
    307         var doUpdate = "";
    308         if (    (!storageDataByType && !storageDataByFilterEqual) ||
    309             (!storageDataByTypeEqual && !storageDataByFilterEqual && !dontUpdateMultipleNoEqual) ) {
    310             vI.notificationBar.dump("## storage: __updateStorageFromVIdentity updating\n")
    311             var doUpdate = "accept";
    312             if (storageDataByType && !storageDataByTypeEqual && vI.main.preferences.getBoolPref("storage_warn_update")) {
    313                 vI.notificationBar.dump("## storage: __updateStorageFromVIdentity overwrite warning\n");
    314                 doUpdate = storage.__askWarning(storage.__getWarning("updateStorage", recipient, storageDataByTypeCompResult.compareMatrix));
    315                 if (doUpdate == "takeover") {
    316                     var msgIdentityCloneElem = document.getElementById("msgIdentity_clone");
    317                     msgIdentityCloneElem.selectedMenuItem = msgIdentityCloneElem.addIdentityToCloneMenu(storageDataByType);
    318                     return false;
    319                 }
    320                 if (doUpdate == "abort") return false;
    321             }
    322         }
    323         if (doUpdate == "accept") storage.rdfDatasource.updateRDFFromVIdentity(recipient.recDesc, recipient.recType);
    324         return true;
    325     },
    326        
    327     // --------------------------------------------------------------------
    328     // check if recipient is a mailing list.
    329     // Similiar to Thunderbird, if there are muliple cards with the same displayName the mailinglist is preferred
    330     // see also https://bugzilla.mozilla.org/show_bug.cgi?id=408575
    331     __isMailingList: function(recipient) {
    332         let abManager = Components.classes["@mozilla.org/abmanager;1"]
    333             .getService(Components.interfaces.nsIAbManager);
    334         let allAddressBooks = abManager.directories;
    335         while (allAddressBooks.hasMoreElements()) {
    336             let ab = allAddressBooks.getNext();
    337             if (ab instanceof Components.interfaces.nsIAbDirectory && !ab.isRemote) {
    338                 let abdirectory = abManager.getDirectory(ab.URI +
    339                     "?(and(DisplayName,=," + encodeURIComponent(storage.__getMailListName(recipient)) + ")(IsMailList,=,TRUE))");
    340                 if (abdirectory) {
    341                     try {   // just try, sometimes there are no childCards at all...
    342                         let cards = abdirectory.childCards;
    343                         if (cards.hasMoreElements()) return true;   // only interested if there is at least one element...
    344                     } catch(e) { }
    345                 }
    346             }
    347         }
    348         return false;
    349     }, 
    350    
    351     // --------------------------------------------------------------------
    352    
    353     __getMailListName : function(recipient) {
    354         if (recipient.match(/<[^>]*>/) || recipient.match(/$/)) {
    355             var mailListName = RegExp.leftContext + RegExp.rightContext
    356             mailListName = mailListName.replace(/^\s+|\s+$/g,"")
    357         }
    358         return mailListName;
    359178    },
    360179   
     
    373192        }       
    374193        return false
    375     },
    376 
    377     getVIdentityFromAllRecipients : function(allIdentities) {
    378         if (!vI.main.preferences.getBoolPref("storage"))
    379             { vI.notificationBar.dump("## storage: Storage deactivated\n"); return; }
    380         vI.notificationBar.dump("## storage: getVIdentityFromAllRecipients()\n");
    381 
    382         for (var row = 1; row <= top.MAX_RECIPIENTS; row ++) {
    383             var recipientType = awGetPopupElement(row).selectedItem.getAttribute("value");
    384             if (recipientType == "addr_reply" || recipientType == "addr_followup" || storage.__isDoBcc(row)) continue;
    385             storage.lastCheckedEmail[row] = awGetInputElement(row).value;
    386             var recipient = storage.__getDescriptionAndType(awGetInputElement(row).value, recipientType);
    387             var storageData = storage.rdfDatasource.readVIdentityFromRDF(recipient.recDesc, recipient.recType);
    388             if (storageData) allIdentities.addWithoutDuplicates(storageData);
    389             storageData = storage.rdfDatasource.findMatchingFilter(recipient.recDesc);
    390             if (storageData) allIdentities.addWithoutDuplicates(storageData);
    391         }
    392         vI.notificationBar.dump("## storage: found " + allIdentities.number + " address(es)\n")
    393194    }
    394195}
  • chrome/content/v_identity/vI_upgrade.js

    r7666cb r9cedc0  
    5959            nextVersion += parseInt(currentVersion[2])
    6060        else nextVersion += parseInt(currentVersion[2]) + 1
    61         var extVersion = document.getElementById("extVersion").getAttribute("value");
    62                
     61           
     62        let window = Cc['@mozilla.org/appshell/window-mediator;1']
     63            .getService(Ci.nsIWindowMediator)
     64            .getMostRecentWindow("mail:3pane");
     65        var extVersion = window.virtualIdentityExtension.extensionVersion;
     66       
    6367        // don't show the dialog if we do a one-step upgrade
    6468        if (upgrade.versionChecker.compare(extVersion, nextVersion) <= 0) {
  • chrome/content/v_identity/vI_upgradeOverlay.js

    r7666cb r9cedc0  
    5858        });
    5959       
     60        const virtualIdentity_ID="{dddd428e-5ac8-4a81-9f78-276c734f75b8}"
     61        AddonManager.getAddonByID(virtualIdentity_ID, function(addon) {
     62            if (addon) vI.extensionVersion = addon.version;
     63        });
    6064       
    6165        if (prefroot.getBoolPref("extensions.virtualIdentity.error_console")) {
  • chrome/content/v_identity/vI_upgradeOverlay.xul

    r7666cb r9cedc0  
    4141    <script type="application/x-javascript" src="chrome://v_identity/content/vI_account.js" />
    4242    <script type="application/x-javascript" src="chrome://v_identity/content/vI_rdfDatasource.js" />
    43     <script type="application/x-javascript" src="chrome://v_identity/content/vI_storageExtras.js" />
    4443    <script type="application/x-javascript" src="chrome://v_identity/content/vI_upgradeOverlay.js" />
    4544
    46     // include following scripts to enable quick_upgrade
     45    <!-- include following scripts to enable quick_upgrade -->
    4746    <script type="application/x-javascript" src="chrome://v_identity/content/vI_upgrade.js" />
    4847    <script type="application/x-javascript" src="chrome://v_identity/content/vI_storage.js" />
    4948    <script type="application/x-javascript" src="chrome://v_identity/content/vI_identityData.js" />
    5049    <script type="application/x-javascript" src="chrome://v_identity/content/vI_helper.js" />
     50    <!-- include following script to enable conversation plugin -->
     51    <script type="application/x-javascript" src="chrome://v_identity/content/vI_smartIdentity.js" />
    5152
    5253    <vbox id="messagepanebox" >
    53         <!-- following element just stores the Ext-Version, seamonkey has no extensionmanager -->
    54         <label id="extVersion" value="&vident.version;" hidden="true" />
    5554        <splitter id="vIErrorBoxSplitter" hidden="true" />
    5655        <vbox id="vIErrorBox" context="ConsoleContext" sortOrder="reverse" hidden="true" />
    57 
    5856    </vbox>
    5957</overlay>
  • chrome/content/v_identity/v_identity.js

    r7666cb r9cedc0  
    3434    unicodeConverter : Components.classes["@mozilla.org/intl/scriptableunicodeconverter"]
    3535                .createInstance(Components.interfaces.nsIScriptableUnicodeConverter),
     36                           
     37    accountManager : Components.classes["@mozilla.org/messenger/account-manager;1"]
     38            .getService(Components.interfaces.nsIMsgAccountManager),
     39       
    3640
    3741    gMsgCompose : null, // to store the global gMsgCompose after MsgComposeDialog is closed
     
    8084        FillIdentityList: function(menulist) {
    8185            vI.notificationBar.dump("## v_identity: mod. FillIdentityList\n");
    82             var mgr = Components.classes["@mozilla.org/messenger/account-manager;1"]
    83                                 .getService(Components.interfaces.nsIMsgAccountManager);
    84             var accounts = queryISupportsArray(mgr.accounts,
     86            var accounts = queryISupportsArray(main.accountManager.accounts,
    8587                                     Components.interfaces.nsIMsgAccount);
    8688
     
    8890            accounts = accounts.filter(function isNonSuckyAccount(a) { return !!a.incomingServer; });
    8991            function sortAccounts(a, b) {
    90                 if (a.key == mgr.defaultAccount.key)
     92                if (a.key == main.accountManager.defaultAccount.key)
    9193                return -1;
    92                 if (b.key == mgr.defaultAccount.key)
     94                if (b.key == main.accountManager.defaultAccount.key)
    9395                return 1;
    9496                var aIsNews = a.incomingServer.type == "nntp";
     
    133135            vI.storage.awOnBlur(vI.storage.focusedElement);
    134136
    135             var promptService = Components.classes["@mozilla.org/embedcomp/prompt-service;1"]
    136                 .getService(Components.interfaces.nsIPromptService);
    137137            vI.notificationBar.dump("\n## v_identity: VIdentity_GenericSendMessage\n");
    138138           
     139            if (msgType == Components.interfaces.nsIMsgCompDeliverMode.Now) { vI.msgIdentityCloneTools.addReplyToSelf(); }
     140
    139141            var vid = document.getElementById("msgIdentity_clone").vid
    140 
    141             if (msgType == nsIMsgCompDeliverMode.Now) {
    142                 if ( (vid && main.preferences.getBoolPref("warn_virtual") &&
    143                     !(promptService.confirm(window,"Warning",
    144                         main.elements.strings.getString("vident.sendVirtual.warning")))) ||
    145                   (!vid && main.preferences.getBoolPref("warn_nonvirtual") &&
    146                     !(promptService.confirm(window,"Warning",
    147                         main.elements.strings.getString("vident.sendNonvirtual.warning")))) ) {
     142            var virtualIdentityData = document.getElementById("msgIdentity_clone").identityData;
     143           
     144            returnValue = vI.prepareSendMsg(    vid, msgType, virtualIdentityData,
     145                            main.accountManager.getIdentity(main.elements.Obj_MsgIdentity.value),
     146                            main._getRecipients() );
     147            if (returnValue.update == "abort") {
     148                main.replacement_functions.GenericSendMessageInProgress = false;
     149                vI.notificationBar.dump("## sending: --------------  aborted  ---------------------------------\n")
     150                return;
     151            }
     152            else if (returnValue.update == "takeover") {
     153                    var msgIdentityCloneElem = document.getElementById("msgIdentity_clone");
     154                    msgIdentityCloneElem.selectedMenuItem = msgIdentityCloneElem.addIdentityToCloneMenu(returnValue.storedIdentity);
    148155                    main.replacement_functions.GenericSendMessageInProgress = false;
     156                    vI.notificationBar.dump("## sending: --------------  aborted  ---------------------------------\n")
    149157                    return;
    150                 }
    151                 if (!vI.storage.storeVIdentityToAllRecipients(msgType)) {
    152 //                  vI.notificationBar.dump("## v_identity: sending aborted\n");
    153                     main.replacement_functions.GenericSendMessageInProgress = false;
    154                     return;
    155                 }
    156                 vI.msgIdentityCloneTools.addReplyToSelf();
    157             }
    158             if (vid) main.prepareAccount();
     158            }
     159           
     160            if (vid) main.addVirtualIdentityToMsgIdentityMenu();
     161           
     162            // final check if eyerything is nice before we handover to the real sending...
     163            if (vI.finalCheck(virtualIdentityData, getCurrentIdentity())) {
     164                main.replacement_functions.GenericSendMessageInProgress = false;
     165                main.original_functions.GenericSendMessage(msgType);
     166            }
     167            else    main.Cleanup();
    159168            main.replacement_functions.GenericSendMessageInProgress = false;
    160 //          vI.notificationBar.dump("## v_identity: original_functions.GenericSendMessage\n");
    161 
    162             // final check if eyerything is nice before we handover to the real sending...
    163             var virtualIdentityData = document.getElementById("msgIdentity_clone").identityData;
    164 
    165             var currentIdentity = getCurrentIdentity();
    166             //                          vI.identityData(email, fullName, id, smtp, extras, sideDescription, existingID)
    167             var currentIdentityData = new vI.identityData(currentIdentity.email, currentIdentity.fullName, null, currentIdentity.smtpServerKey, null, null, null);
    168            
    169             vI.notificationBar.dump("\n## vI.identityData GenericSendMessage Final Check\n");
    170             vI.notificationBar.dump("## vI.identityData currentIdentity: fullName='" + currentIdentityData.fullName + "' email='" + currentIdentityData.email + "' smtp='" + currentIdentityData.smtp.key + "'\n");
    171             vI.notificationBar.dump("## vI.identityData virtualIdentityData: fullName='" + virtualIdentityData.fullName + "' email='" + virtualIdentityData.email + "' smtp='" + virtualIdentityData.smtp.key + "'\n");
    172 
    173             if  (currentIdentityData.fullName.toLowerCase() == virtualIdentityData.fullName.toLowerCase()   &&
    174                 currentIdentityData.email.toLowerCase() == virtualIdentityData.email.toLowerCase()      &&
    175                 virtualIdentityData.smtp.equal(currentIdentityData.smtp)    ) {
    176                     main.original_functions.GenericSendMessage(msgType);
    177             }
    178             else {
    179                 if (!(currentIdentityData.fullName.toLowerCase() == virtualIdentityData.fullName.toLowerCase())) vI.notificationBar.dump("\n## vI.identityData failed check for fullName.\n");
    180                 if (!(currentIdentityData.email.toLowerCase() == virtualIdentityData.email.toLowerCase())) vI.notificationBar.dump("\n## vI.identityData failed check for email.\n");
    181                 if (!(virtualIdentityData.smtp.equal(currentIdentityData.smtp))) vI.notificationBar.dump("\n## vI.identityData failed check for SMTP.\n");
    182                 alert(main.elements.strings.getString("vident.genericSendMessage.error"));
    183                 main.Cleanup();
    184             }
    185 //          vI.notificationBar.dump("## v_identity: original_functions.GenericSendMessage done\n");
     169            //          vI.notificationBar.dump("## v_identity: original_functions.GenericSendMessage done\n");
    186170        },
    187171       
     
    199183        main.Cleanup();
    200184        vI.storage.clean();
     185    },
     186
     187    _getRecipients : function(row) {
     188        var recipients = [];
     189        for (var row = 1; row <= top.MAX_RECIPIENTS; row ++) {
     190            var recipientType = awGetPopupElement(row).selectedItem.getAttribute("value");
     191            if (recipientType == "addr_reply" || recipientType == "addr_followup" ||
     192                main._recipientIsDoBcc(row) || awGetInputElement(row).value.match(/^\s*$/) ) continue;
     193            recipients.push( { recipient: awGetInputElement(row).value, recipientType : recipientType } );
     194        }
     195        return recipients;
     196    },
     197   
     198    _recipientIsDoBcc : function(row) {
     199        var recipientType = awGetPopupElement(row).selectedItem.getAttribute("value");
     200        if (recipientType != "addr_bcc" || !getCurrentIdentity().doBcc) return false
     201
     202        var doBccArray = gMsgCompose.compFields.splitRecipients(getCurrentIdentity().doBccList, false, {});
     203
     204        for (var index = 0; index < doBccArray.count; index++ ) {
     205            if (doBccArray.StringAt(index) == awGetInputElement(row).value) {
     206                vI.notificationBar.dump("## main _recipientIsDoBcc: ignoring doBcc field '" +
     207                    doBccArray.StringAt(index) + "'.\n");
     208                return true;
     209            }
     210        }       
     211        return false
    201212    },
    202213
     
    231242        document.getElementById("msgIdentity_clone").init();
    232243        vI.statusmenu.init();
     244        vI.notificationBar.dump("## v_identity: initSystemStage1 done.\n")
    233245    },
    234246   
     
    238250        vI.storage.init();
    239251        vI.smartIdentity.init();
     252        vI.notificationBar.dump("## v_identity: initSystemStage2 done.\n")
    240253    },
    241254   
     
    286299        // clean all elements
    287300        document.getElementById("msgIdentity_clone").clean();
    288         vI.smartIdentity.clean();
    289301        vI.notificationBar.dump("## v_identity: everything cleaned.\n")
    290302       
     
    356368    prepareAccount : function() {
    357369        main.Cleanup(); // just to be sure that nothing is left (maybe last time sending was irregularily stopped)
    358         vI.account.createAccount();
     370        vI.account.createAccount(document.getElementById("msgIdentity_clone").identityData,
     371                                 main.accountManager.getIdentity(main.elements.Obj_MsgIdentity.value));
    359372        main.addVirtualIdentityToMsgIdentityMenu();
    360373    },
  • chrome/content/v_identity/v_identity.xul

    r7666cb r9cedc0  
    5252    <stringbundle id="vIdentBundle" src="chrome://v_identity/locale/v_identity.properties" />
    5353    <stringbundle id="vIStorageExtrasBundle" src="chrome://v_identity/locale/vI_storageExtras.properties" />
    54     <stringbundle id="bundle_messenger" src="chrome://messenger/locale/messenger.properties" />
    5554  </stringbundleset>
    5655
Note: See TracChangeset for help on using the changeset viewer.