mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-02-13 03:24:26 +00:00
cking out bnesse at his request since he found conflicts with dougt's
checkin
This commit is contained in:
parent
d9687a5cd4
commit
f91231d808
@ -47,7 +47,7 @@
|
||||
|
||||
//////////// global constants ////////////////////
|
||||
|
||||
const nsIPrefBranch = Components.interfaces.nsIPrefBranch;
|
||||
const nsIPref = Components.interfaces.nsIPref;
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
//// class PrefUtils
|
||||
@ -58,40 +58,35 @@ var PrefUtils =
|
||||
|
||||
init: function()
|
||||
{
|
||||
var prefService = XPCU.getService("@mozilla.org/preferences-service;1", "nsIPrefService");
|
||||
this.mPrefs = prefService.getBranch(null);
|
||||
this.mPrefs = XPCU.getService("@mozilla.org/preferences;1", "nsIPref");
|
||||
},
|
||||
|
||||
addObserver: function(aDomain, aFunction)
|
||||
{
|
||||
if (!this.mPrefs) this.init();
|
||||
|
||||
var pbi = XPCU.QI(this.mPrefs, "nsIPrefBranchInternal");
|
||||
if (pbi)
|
||||
pbi.addObserver(aDomain, aFunction, false);
|
||||
this.mPrefs.addObserver(aDomain, aFunction);
|
||||
},
|
||||
|
||||
removeObserver: function(aDomain, aFunction)
|
||||
{
|
||||
if (!this.mPrefs) this.init();
|
||||
|
||||
var pbi = XPCU.QI(this.mPrefs, "nsIPrefBranchInternal");
|
||||
if (pbi)
|
||||
pbi.removeObserver(aDomain, aFunction);
|
||||
this.mPrefs.removeObserver(aDomain, aFunction);
|
||||
},
|
||||
|
||||
setPref: function(aName, aValue)
|
||||
{
|
||||
if (!this.mPrefs) this.init();
|
||||
|
||||
var type = this.mPrefs.getPrefType(aName);
|
||||
var type = this.mPrefs.GetPrefType(aName);
|
||||
try {
|
||||
if (type == nsIPrefBranch.PREF_STRING) {
|
||||
this.mPrefs.setComplexValue(aName, Components.interfaces.nsISupportsWString, aValue);
|
||||
} else if (type == nsIPrefBranch.PREF_BOOL) {
|
||||
this.mPrefs.setBoolPref(aName, aValue);
|
||||
} else if (type == nsIPrefBranch.PREF_INT) {
|
||||
this.mPrefs.setIntPref(aName, aValue);
|
||||
if (type == nsIPref.ePrefString) {
|
||||
this.mPrefs.SetUnicharPref(aName, aValue);
|
||||
} else if (type == nsIPref.ePrefBool) {
|
||||
this.mPrefs.SetBoolPref(aName, aValue);
|
||||
} else if (type == nsIPref.ePrefInt) {
|
||||
this.mPrefs.SetIntPref(aName, aValue);
|
||||
}
|
||||
} catch(ex) {
|
||||
debug("ERROR: Unable to write pref \"" + aName + "\".\n");
|
||||
@ -102,14 +97,14 @@ var PrefUtils =
|
||||
{
|
||||
if (!this.mPrefs) this.init();
|
||||
|
||||
var type = this.mPrefs.getPrefType(aName);
|
||||
var type = this.mPrefs.GetPrefType(aName);
|
||||
try {
|
||||
if (type == nsIPrefBranch.PREF_STRING) {
|
||||
return this.mPrefs.getComplexValue(aName, Components.interfaces.nsISupportsWString);
|
||||
} else if (type == nsIPrefBranch.PREF_BOOL) {
|
||||
return this.mPrefs.getBoolPref(aName);
|
||||
} else if (type == nsIPrefBranch.PREF_INT) {
|
||||
return this.mPrefs.getIntPref(aName);
|
||||
if (type == nsIPref.ePrefString) {
|
||||
return this.mPrefs.CopyUnicharPref(aName);
|
||||
} else if (type == nsIPref.ePrefBool) {
|
||||
return this.mPrefs.GetBoolPref(aName);
|
||||
} else if (type == nsIPref.ePrefInt) {
|
||||
return this.mPrefs.GetIntPref(aName);
|
||||
}
|
||||
} catch(ex) {
|
||||
debug("ERROR: Unable to read pref \"" + aName + "\".\n");
|
||||
|
@ -38,7 +38,6 @@
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsIObserver.h"
|
||||
#include "nsIPrefBranch.h"
|
||||
#include "nsIPrefBranchInternal.h"
|
||||
#include "nsIPrefLocalizedString.h"
|
||||
@ -52,7 +51,6 @@
|
||||
class nsPrefBranch : public nsIPrefBranch,
|
||||
public nsIPrefBranchInternal,
|
||||
public nsISecurityPref,
|
||||
public nsIObserver,
|
||||
public nsSupportsWeakReference
|
||||
{
|
||||
public:
|
||||
@ -60,7 +58,6 @@ public:
|
||||
NS_DECL_NSIPREFBRANCH
|
||||
NS_DECL_NSIPREFBRANCHINTERNAL
|
||||
NS_DECL_NSISECURITYPREF
|
||||
NS_DECL_NSIOBSERVER
|
||||
|
||||
nsPrefBranch(const char *aPrefRoot, PRBool aDefaultBranch);
|
||||
virtual ~nsPrefBranch();
|
||||
@ -72,7 +69,6 @@ protected:
|
||||
nsresult GetDefaultFromPropertiesFile(const char *aPrefName, PRUnichar **return_buf);
|
||||
const char *getPrefName(const char *aPrefName);
|
||||
nsresult getValidatedPrefName(const char *aPrefName, const char **_retval);
|
||||
void freeObserverList(void);
|
||||
|
||||
private:
|
||||
PRInt32 mPrefRootLength;
|
||||
|
Loading…
x
Reference in New Issue
Block a user