2000-06-01 10:35:57 +04:00
|
|
|
|
|
|
|
/**
|
2001-10-27 09:39:25 +04:00
|
|
|
* nsPreferences - a wrapper around nsIPrefService. Provides built in
|
2000-06-01 10:35:57 +04:00
|
|
|
* exception handling to make preferences access simpler.
|
|
|
|
**/
|
|
|
|
var nsPreferences = {
|
|
|
|
get mPrefService()
|
|
|
|
{
|
2001-10-27 09:39:25 +04:00
|
|
|
return Components.classes["@mozilla.org/preferences-service;1"]
|
|
|
|
.getService(Components.interfaces.nsIPrefBranch);
|
2000-06-01 10:35:57 +04:00
|
|
|
},
|
|
|
|
|
|
|
|
setBoolPref: function (aPrefName, aPrefValue)
|
|
|
|
{
|
|
|
|
try
|
|
|
|
{
|
2001-10-27 09:39:25 +04:00
|
|
|
this.mPrefService.setBoolPref(aPrefName, aPrefValue);
|
2000-06-01 10:35:57 +04:00
|
|
|
}
|
|
|
|
catch(e)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
getBoolPref: function (aPrefName, aDefVal)
|
|
|
|
{
|
|
|
|
try
|
|
|
|
{
|
2001-10-27 09:39:25 +04:00
|
|
|
return this.mPrefService.getBoolPref(aPrefName);
|
2000-06-01 10:35:57 +04:00
|
|
|
}
|
|
|
|
catch(e)
|
|
|
|
{
|
|
|
|
return aDefVal != undefined ? aDefVal : null;
|
|
|
|
}
|
2000-09-07 23:47:39 +04:00
|
|
|
return null; // quiet warnings
|
2000-06-01 10:35:57 +04:00
|
|
|
},
|
|
|
|
|
|
|
|
setUnicharPref: function (aPrefName, aPrefValue)
|
|
|
|
{
|
|
|
|
try
|
|
|
|
{
|
2001-10-27 09:39:25 +04:00
|
|
|
var str = Components.classes["@mozilla.org/supports-wstring;1"]
|
|
|
|
.createInstance(Components.interfaces.nsISupportsWString);
|
|
|
|
str.data = aPrefValue;
|
|
|
|
this.mPrefService.setComplexValue(aPrefName,
|
|
|
|
Components.interfaces.nsISupportsWString, str);
|
2000-06-01 10:35:57 +04:00
|
|
|
}
|
|
|
|
catch(e)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
copyUnicharPref: function (aPrefName, aDefVal)
|
|
|
|
{
|
|
|
|
try
|
|
|
|
{
|
2001-10-27 09:39:25 +04:00
|
|
|
return this.mPrefService.getComplexValue(aPrefName,
|
2001-10-31 03:13:06 +03:00
|
|
|
Components.interfaces.nsISupportsWString).data;
|
2000-06-01 10:35:57 +04:00
|
|
|
}
|
|
|
|
catch(e)
|
|
|
|
{
|
|
|
|
return aDefVal != undefined ? aDefVal : null;
|
|
|
|
}
|
2000-09-07 23:47:39 +04:00
|
|
|
return null; // quiet warnings
|
2000-06-01 10:35:57 +04:00
|
|
|
},
|
|
|
|
|
|
|
|
setIntPref: function (aPrefName, aPrefValue)
|
|
|
|
{
|
|
|
|
try
|
|
|
|
{
|
2001-10-27 09:39:25 +04:00
|
|
|
this.mPrefService.setIntPref(aPrefName, aPrefValue);
|
2000-06-01 10:35:57 +04:00
|
|
|
}
|
|
|
|
catch(e)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
getIntPref: function (aPrefName, aDefVal)
|
|
|
|
{
|
|
|
|
try
|
|
|
|
{
|
2001-10-27 09:39:25 +04:00
|
|
|
return this.mPrefService.getIntPref(aPrefName);
|
2000-06-01 10:35:57 +04:00
|
|
|
}
|
|
|
|
catch(e)
|
|
|
|
{
|
|
|
|
return aDefVal != undefined ? aDefVal : null;
|
|
|
|
}
|
2000-09-07 23:47:39 +04:00
|
|
|
return null; // quiet warnings
|
2000-06-01 10:35:57 +04:00
|
|
|
},
|
2000-09-01 08:40:00 +04:00
|
|
|
|
|
|
|
getLocalizedUnicharPref: function (aPrefName, aDefVal)
|
|
|
|
{
|
|
|
|
try
|
|
|
|
{
|
2001-10-27 09:39:25 +04:00
|
|
|
return this.mPrefService.getComplexValue(aPrefName,
|
2001-10-31 03:13:06 +03:00
|
|
|
Components.interfaces.nsIPrefLocalizedString).data;
|
2000-09-01 08:40:00 +04:00
|
|
|
}
|
|
|
|
catch(e)
|
|
|
|
{
|
|
|
|
return aDefVal != undefined ? aDefVal : null;
|
|
|
|
}
|
2000-09-07 23:47:39 +04:00
|
|
|
return null; // quiet warnings
|
2000-09-08 01:48:48 +04:00
|
|
|
}
|
2000-09-01 08:40:00 +04:00
|
|
|
};
|
|
|
|
|