Changeset d8fb13


Ignore:
Timestamp:
Oct 11, 2014, 3:00:35 PM (7 years ago)
Author:
rene <rene@…>
Branches:
ng_0.9
Children:
25edf9
Parents:
5866ad
Message:

cleanup leftover account prefs, fix for:
https://bugzilla.mozilla.org/show_bug.cgi?id=485839
https://bugzilla.mozilla.org/show_bug.cgi?id=875675

File:
1 edited

Legend:

Unmodified
Added
Removed
  • modules/vI_account.js

    r5866ad rd8fb13  
    214214        Log.debug("checking for leftover VirtualIdentity accounts ...")
    215215        var accounts = getAccountsArray();
     216//         Log.debug("number of currently used accounts = " + accounts.length);
     217
     218        for (let acc = 0; acc < accounts.length; acc++) {
     219            let checkAccount = accounts[acc];
     220            if (account.__isVIdentityAccount(checkAccount)) {
     221                account.__removeAccount(checkAccount);
     222            }
     223            // replace account with key, required for next check
     224            accounts[acc] = accounts[acc].key;
     225//             Log.debug("current account = " + accounts[acc]);
     226        }
     227       
     228//         var usedAccounts = prefroot.getCharPref("mail.accountmanager.accounts");
     229        var lastAccountKey = prefroot.getIntPref("mail.account.lastKey");
     230//         Log.debug("number of last AccountKey = " + lastAccountKey);
     231        for (let key = 0; key <= lastAccountKey; key++) {
     232            if (accounts.indexOf("account" + key) > -1) continue;
     233            account.__removeAccountPrefs("account" + key);
     234        }
     235       
    216236        for (let acc = 0; acc < accounts.length; acc++) {
    217237            let checkAccount = accounts[acc];
     
    234254    },
    235255   
    236     __removeAccount : function(checkAccount) {
     256    __removeAccountPrefs : function(key) {
     257        // remove the additional tagging-pref
     258        try {
     259            prefroot.clearUserPref("mail.account." + key + ".vIdentity");
     260            // prevent useless increasing of lastKey https://bugzilla.mozilla.org/show_bug.cgi?id=485839
     261            var lastAccountKey = prefroot.getIntPref("mail.account.lastKey");
     262            if ("account" + lastAccountKey == key)
     263                prefroot.setIntPref("mail.account.lastKey", lastAccountKey - 1);
     264        }
     265        catch (e) { };
     266        try {
     267            // account-prefs are not removed, grrrr --> https://bugzilla.mozilla.org/show_bug.cgi?id=875675
     268            prefroot.clearUserPref("mail.account." + key + ".server");
     269        }
     270        catch (e) { };
     271        try {
     272            // account-prefs are not removed, grrrr --> https://bugzilla.mozilla.org/show_bug.cgi?id=875675
     273            prefroot.clearUserPref("mail.account." + key + ".identities");
     274        }
     275        catch (e) { };
     276    },
     277
     278    __removeAccount : function(checkAccount) {
    237279        Log.debug("__removeAccount")
    238280        // in new (post 0.5.0) Virtual Identity accounts the incomingServer of the account
     
    254296        // remove the account
    255297        account._AccountManager.removeAccount(checkAccount);
    256         // remove the additional tagging-pref
    257         try { prefroot.clearUserPref("mail.account." + key + ".vIdentity"); }
    258         catch (e) { };
     298       
     299        account.__removeAccountPrefs(key);
    259300    },
    260301   
     
    296337        prefroot.setBoolPref("mail.account." + account._account.key + ".vIdentity", true)
    297338        account._account.addIdentity(account._AccountManager.createIdentity());
     339       
     340        Log.debug("createAccount create Identity based on baseIdentity (" + baseIdentity.key + ") " + baseIdentity.fullName + " <" + baseIdentity.email + ">");
    298341        // the new account uses the same incomingServer than the base one,
    299342        // it's especially required for NNTP cause incomingServer is used for sending newsposts.
Note: See TracChangeset for help on using the changeset viewer.