Bug 232186 Remove deprecated nsIPref usage from PKI chrome moa=kaie r=caillon sr=brendan

This commit is contained in:
neil%parkwaycc.co.uk 2004-01-31 21:11:27 +00:00
Родитель fe7960ecb6
Коммит 521d560df7
5 изменённых файлов: 53 добавлений и 47 удалений

Просмотреть файл

@ -24,12 +24,11 @@ const nsPKIParamBlock = "@mozilla.org/security/pkiparamblock;1";
const nsIPKIParamBlock = Components.interfaces.nsIPKIParamBlock;
const nsIX509Cert = Components.interfaces.nsIX509Cert;
const nsICRLInfo = Components.interfaces.nsICRLInfo;
const nsIPref = Components.interfaces.nsIPref;
const nsIPrefService = Components.interfaces.nsIPrefService
var pkiParams;
var cert;
var crl;
var prefs;
function onLoad()
{
@ -60,16 +59,17 @@ function onLoad()
var orgUnit = document.getElementById("orgUnitText");
orgUnit.setAttribute("value", crl.organizationalUnit);
prefs = Components.classes["@mozilla.org/preferences;1"].getService(nsIPref);
var autoupdateEnabledString = "security.crl.autoupdate.enable." + crl.nameInDb;
var updateEnabled = false;
try {
updateEnabled = prefs.GetBoolPref(autoupdateEnabledString);
var prefService = Components.classes["@mozilla.org/preferences-service;1"].getService(nsIPrefService);
var prefBranch = prefService.getBranch(null);
updateEnabled = prefBranch.getBoolPref(autoupdateEnabledString);
if(updateEnabled) {
var autoupdateURLString = "security.crl.autoupdate.url." + crl.nameInDb;
prefs.SetCharPref(autoupdateURLString,crl.lastFetchURL);
prefs.savePrefFile(null);
prefBranch.setCharPref(autoupdateURLString, crl.lastFetchURL);
prefService.savePrefFile(null);
}
}catch(exception){}

Просмотреть файл

@ -26,11 +26,12 @@ const nsICRLInfo = Components.interfaces.nsICRLInfo;
const nsISupportsArray = Components.interfaces.nsISupportsArray;
const nsIPKIParamBlock = Components.interfaces.nsIPKIParamBlock;
const nsPKIParamBlock = "@mozilla.org/security/pkiparamblock;1";
const nsIPref = Components.interfaces.nsIPref;
const nsIPrefService = Components.interfaces.nsIPrefService;
var crlManager;
var crls;
var prefs;
var prefService;
var prefBranch;
var autoupdateEnabledBaseString = "security.crl.autoupdate.enable.";
var autoupdateTimeTypeBaseString = "security.crl.autoupdate.timingType.";
@ -47,8 +48,9 @@ function onLoad()
var i;
crlManager = Components.classes[nsCRLManager].getService(nsICRLManager);
prefs = Components.classes["@mozilla.org/preferences;1"].getService(nsIPref);
crls = crlManager.getCrls();
prefService = Components.classes["@mozilla.org/preferences-service;1"].getService(nsIPrefService);
prefBranch = prefService.getBranch(null);
var bundle = srGetStrBundle("chrome://pippki/locale/pippki.properties");
var autoupdateEnabledString;
var autoupdateErrCntString;
@ -65,12 +67,12 @@ function onLoad()
var enabledStr = bundle.GetStringFromName("crlAutoupdateNotEnabled");
var status = "";
try{
enabled = prefs.GetBoolPref(autoupdateEnabledString)
enabled = prefBranch.getBoolPref(autoupdateEnabledString)
if(enabled){
enabledStr = bundle.GetStringFromName("crlAutoupdateEnabled");
}
var cnt;
cnt = prefs.GetIntPref(autoupdateErrCntString);
cnt = prefBranch.getIntPref(autoupdateErrCntString);
if(cnt > 0){
status = bundle.GetStringFromName("crlAutoupdateFailed");
} else {
@ -116,18 +118,18 @@ function DeleteCrlSelected() {
//First, check if autoupdate was enabled for this crl
try {
autoupdateEnabled = prefs.GetBoolPref(autoupdateEnabledBaseString + id);
autoupdateEnabled = prefBranch.getBoolPref(autoupdateEnabledBaseString + id);
//Note, if the pref is not present, we get an exception right here,
//and autoupdateEnabled remains false
autoupdateParamAvailable = true;
prefs.ClearUserPref(autoupdateEnabledBaseString + id);
prefs.ClearUserPref(autoupdateTimeTypeBaseString + id);
prefs.ClearUserPref(autoupdateTimeBaseString + id);
prefs.ClearUserPref(autoupdateURLBaseString + id);
prefs.ClearUserPref(autoupdateDayCntString + id);
prefs.ClearUserPref(autoupdateFreqCntString + id);
prefs.ClearUserPref(autoupdateErrCntBaseString + id);
prefs.ClearUserPref(autoupdateErrDetailBaseString + id);
prefBranch.clearUserPref(autoupdateEnabledBaseString + id);
prefBranch.clearUserPref(autoupdateTimeTypeBaseString + id);
prefBranch.clearUserPref(autoupdateTimeBaseString + id);
prefBranch.clearUserPref(autoupdateURLBaseString + id);
prefBranch.clearUserPref(autoupdateDayCntString + id);
prefBranch.clearUserPref(autoupdateFreqCntString + id);
prefBranch.clearUserPref(autoupdateErrCntBaseString + id);
prefBranch.clearUserPref(autoupdateErrDetailBaseString + id);
} catch(Exception){}
//Once we have deleted the prefs that can be deleted, we save the
@ -135,7 +137,7 @@ function DeleteCrlSelected() {
//in doind that, we try to delete the crl
try{
if(autoupdateParamAvailable){
prefs.savePrefFile(null);
prefService.savePrefFile(null);
}
if(autoupdateEnabled){

Просмотреть файл

@ -36,15 +36,17 @@
*
* ***** END LICENSE BLOCK ***** */
var gPrefs = null;
var gPrefService = null;
var gPrefBranch = null;
function onLoad() {
doSetOKCancel(doOK, doCancel);
// Set checkboxes from prefs
const nsIPref = Components.interfaces.nsIPref;
const nsIPrefService = Components.interfaces.nsIPrefService;
gPrefs = Components.classes["@mozilla.org/preferences;1"].getService(nsIPref);
gPrefService = Components.classes["@mozilla.org/preferences-service;1"].getService(nsIPrefService);
gPrefBranch = gPrefService.getBranch(null);
// Enumerate each checkbox on this page and set value
var prefElements = document.getElementsByAttribute("prefstring", "*");
@ -54,12 +56,12 @@ function onLoad() {
var prefValue = false;
try {
prefValue = gPrefs.GetBoolPref(prefString);
prefValue = gPrefBranch.getBoolPref(prefString);
} catch(e) { /* Put debug output here */ }
element.setAttribute("checked", prefValue);
// disable xul element if the pref is locked.
if (gPrefs.PrefIsLocked(prefString)) {
if (gPrefBranch.prefIsLocked(prefString)) {
element.disabled=true;
}
}
@ -85,10 +87,10 @@ function doOK() {
prefValue = (prefValue == "true");
}
gPrefs.SetBoolPref(prefString, prefValue);
gPrefBranch.setBoolPref(prefString, prefValue);
}
gPrefs.savePrefFile(null);
gPrefService.savePrefFile(null);
} catch(e) { }
window.close();

Просмотреть файл

@ -24,11 +24,12 @@ const nsICRLManager = Components.interfaces.nsICRLManager;
const nsCRLManager = "@mozilla.org/security/crlmanager;1";
const nsIPKIParamBlock = Components.interfaces.nsIPKIParamBlock;
const nsICRLInfo = Components.interfaces.nsICRLInfo;
const nsIPref = Components.interfaces.nsIPref;
const nsIPrefService = Components.interfaces.nsIPrefService;
var crl;
var bundle;
var prefs;
var prefService;
var prefBranch;
var updateTypeRadio;
var enabledCheckBox;
var timeBasedRadio;
@ -61,7 +62,8 @@ function onLoad()
autoupdateErrDetailString = autoupdateErrDetailString + crl.nameInDb;
bundle = srGetStrBundle("chrome://pippki/locale/pippki.properties");
prefs = Components.classes["@mozilla.org/preferences;1"].getService(nsIPref);
prefService = Components.classes["@mozilla.org/preferences-service;1"].getService(nsIPrefService);
prefBranch = prefService.getBranch(null);
updateTypeRadio = document.getElementById("autoUpdateType");
enabledCheckBox = document.getElementById("enableCheckBox");
@ -95,7 +97,7 @@ function initializeSelection()
var advertisedMenuNode;
try {
var isEnabled = prefs.GetBoolPref(autoupdateEnabledString);
var isEnabled = prefBranch.getBoolPref(autoupdateEnabledString);
enabledCheckBox.checked = isEnabled;
} catch(exception){
enabledCheckBox.checked = false;
@ -114,7 +116,7 @@ function initializeSelection()
//Set up the initial selections based on defaults and prefs, if any
try{
var timingPref = prefs.GetIntPref(autoupdateTimeTypeString);
var timingPref = prefBranch.getIntPref(autoupdateTimeTypeString);
if(timingPref != null) {
if(timingPref == crlManager.TYPE_AUTOUPDATE_TIME_BASED) {
if(hasNextUpdate){
@ -144,7 +146,7 @@ function initializeSelection()
//Now, retrieving the day count
var timeBasedBox = document.getElementById("nextUpdateDay");
try {
var dayCnt = prefs.GetCharPref(autoupdateDayCntString);
var dayCnt = prefBranch.getCharPref(autoupdateDayCntString);
//alert(dayCnt);
if(dayCnt != null){
timeBasedBox.value = dayCnt;
@ -157,7 +159,7 @@ function initializeSelection()
var freqBasedBox = document.getElementById("nextUpdateFreq");
try {
var freqCnt = prefs.GetCharPref(autoupdateFreqCntString);
var freqCnt = prefBranch.getCharPref(autoupdateFreqCntString);
//alert(freqCnt);
if(freqCnt != null){
freqBasedBox.value = freqCnt;
@ -173,8 +175,8 @@ function initializeSelection()
var cnt = 0;
var text;
try{
cnt = prefs.GetIntPref(autoupdateErrCntString);
txt = prefs.GetCharPref(autoupdateErrDetailString);
cnt = prefBranch.getIntPref(autoupdateErrCntString);
txt = prefBranch.getCharPref(autoupdateErrDetailString);
}catch(exception){}
if( cnt > 0 ){
@ -204,10 +206,10 @@ function onAccept()
return false;
//set enable pref
prefs.SetBoolPref(autoupdateEnabledString, enabledCheckBox.checked );
prefBranch.setBoolPref(autoupdateEnabledString, enabledCheckBox.checked );
//set URL TYPE and value prefs - always to last fetch url - till we have anything else available
prefs.SetCharPref(autoupdateURLString,crl.lastFetchURL);
prefBranch.setCharPref(autoupdateURLString, crl.lastFetchURL);
var timingTypeId = updateTypeRadio.selectedItem.id;
var updateTime;
@ -215,20 +217,20 @@ function onAccept()
var freqCnt = (document.getElementById("nextUpdateFreq")).value;
if(timingTypeId == "timeBasedRadio"){
prefs.SetIntPref(autoupdateTimeTypeString,crlManager.TYPE_AUTOUPDATE_TIME_BASED);
prefBranch.setIntPref(autoupdateTimeTypeString, crlManager.TYPE_AUTOUPDATE_TIME_BASED);
updateTime = crlManager.computeNextAutoUpdateTime(crl, crlManager.TYPE_AUTOUPDATE_TIME_BASED, dayCnt);
} else {
prefs.SetIntPref(autoupdateTimeTypeString,crlManager.TYPE_AUTOUPDATE_FREQ_BASED);
prefBranch.setIntPref(autoupdateTimeTypeString, crlManager.TYPE_AUTOUPDATE_FREQ_BASED);
updateTime = crlManager.computeNextAutoUpdateTime(crl, crlManager.TYPE_AUTOUPDATE_FREQ_BASED, freqCnt);
}
//alert(updateTime);
prefs.SetCharPref(autoupdateTimeString,updateTime);
prefs.SetCharPref(autoupdateDayCntString,dayCnt);
prefs.SetCharPref(autoupdateFreqCntString,freqCnt);
prefBranch.setCharPref(autoupdateTimeString, updateTime);
prefBranch.setCharPref(autoupdateDayCntString, dayCnt);
prefBranch.setCharPref(autoupdateFreqCntString, freqCnt);
//Save Now
prefs.savePrefFile(null);
prefService.savePrefFile(null);
crlManager.rescheduleCRLAutoUpdate();
//Close dialog by returning true

Просмотреть файл

@ -53,9 +53,9 @@ function resetPassword()
var token = pk11db.findTokenByName(tokenName);
token.reset();
var pref = Components.classes['@mozilla.org/preferences;1'];
var pref = Components.classes['@mozilla.org/preferences-service;1'].getService(Components.interfaces.nsIPrefService);
if (pref) {
pref = pref.getService(Components.interfaces.nsIPrefBranch);
pref = pref.getBranch(null);
try {
if (pref.getBoolPref("wallet.crypto")) {
// data in wallet is encrypted, clear it