зеркало из https://github.com/mozilla/gecko-dev.git
cking out bnesse at his request since he found conflicts with dougt's
checkin
This commit is contained in:
Родитель
d9687a5cd4
Коммит
f91231d808
|
@ -47,7 +47,7 @@
|
||||||
|
|
||||||
//////////// global constants ////////////////////
|
//////////// global constants ////////////////////
|
||||||
|
|
||||||
const nsIPrefBranch = Components.interfaces.nsIPrefBranch;
|
const nsIPref = Components.interfaces.nsIPref;
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////
|
||||||
//// class PrefUtils
|
//// class PrefUtils
|
||||||
|
@ -58,40 +58,35 @@ var PrefUtils =
|
||||||
|
|
||||||
init: function()
|
init: function()
|
||||||
{
|
{
|
||||||
var prefService = XPCU.getService("@mozilla.org/preferences-service;1", "nsIPrefService");
|
this.mPrefs = XPCU.getService("@mozilla.org/preferences;1", "nsIPref");
|
||||||
this.mPrefs = prefService.getBranch(null);
|
|
||||||
},
|
},
|
||||||
|
|
||||||
addObserver: function(aDomain, aFunction)
|
addObserver: function(aDomain, aFunction)
|
||||||
{
|
{
|
||||||
if (!this.mPrefs) this.init();
|
if (!this.mPrefs) this.init();
|
||||||
|
|
||||||
var pbi = XPCU.QI(this.mPrefs, "nsIPrefBranchInternal");
|
this.mPrefs.addObserver(aDomain, aFunction);
|
||||||
if (pbi)
|
|
||||||
pbi.addObserver(aDomain, aFunction, false);
|
|
||||||
},
|
},
|
||||||
|
|
||||||
removeObserver: function(aDomain, aFunction)
|
removeObserver: function(aDomain, aFunction)
|
||||||
{
|
{
|
||||||
if (!this.mPrefs) this.init();
|
if (!this.mPrefs) this.init();
|
||||||
|
|
||||||
var pbi = XPCU.QI(this.mPrefs, "nsIPrefBranchInternal");
|
this.mPrefs.removeObserver(aDomain, aFunction);
|
||||||
if (pbi)
|
|
||||||
pbi.removeObserver(aDomain, aFunction);
|
|
||||||
},
|
},
|
||||||
|
|
||||||
setPref: function(aName, aValue)
|
setPref: function(aName, aValue)
|
||||||
{
|
{
|
||||||
if (!this.mPrefs) this.init();
|
if (!this.mPrefs) this.init();
|
||||||
|
|
||||||
var type = this.mPrefs.getPrefType(aName);
|
var type = this.mPrefs.GetPrefType(aName);
|
||||||
try {
|
try {
|
||||||
if (type == nsIPrefBranch.PREF_STRING) {
|
if (type == nsIPref.ePrefString) {
|
||||||
this.mPrefs.setComplexValue(aName, Components.interfaces.nsISupportsWString, aValue);
|
this.mPrefs.SetUnicharPref(aName, aValue);
|
||||||
} else if (type == nsIPrefBranch.PREF_BOOL) {
|
} else if (type == nsIPref.ePrefBool) {
|
||||||
this.mPrefs.setBoolPref(aName, aValue);
|
this.mPrefs.SetBoolPref(aName, aValue);
|
||||||
} else if (type == nsIPrefBranch.PREF_INT) {
|
} else if (type == nsIPref.ePrefInt) {
|
||||||
this.mPrefs.setIntPref(aName, aValue);
|
this.mPrefs.SetIntPref(aName, aValue);
|
||||||
}
|
}
|
||||||
} catch(ex) {
|
} catch(ex) {
|
||||||
debug("ERROR: Unable to write pref \"" + aName + "\".\n");
|
debug("ERROR: Unable to write pref \"" + aName + "\".\n");
|
||||||
|
@ -102,14 +97,14 @@ var PrefUtils =
|
||||||
{
|
{
|
||||||
if (!this.mPrefs) this.init();
|
if (!this.mPrefs) this.init();
|
||||||
|
|
||||||
var type = this.mPrefs.getPrefType(aName);
|
var type = this.mPrefs.GetPrefType(aName);
|
||||||
try {
|
try {
|
||||||
if (type == nsIPrefBranch.PREF_STRING) {
|
if (type == nsIPref.ePrefString) {
|
||||||
return this.mPrefs.getComplexValue(aName, Components.interfaces.nsISupportsWString);
|
return this.mPrefs.CopyUnicharPref(aName);
|
||||||
} else if (type == nsIPrefBranch.PREF_BOOL) {
|
} else if (type == nsIPref.ePrefBool) {
|
||||||
return this.mPrefs.getBoolPref(aName);
|
return this.mPrefs.GetBoolPref(aName);
|
||||||
} else if (type == nsIPrefBranch.PREF_INT) {
|
} else if (type == nsIPref.ePrefInt) {
|
||||||
return this.mPrefs.getIntPref(aName);
|
return this.mPrefs.GetIntPref(aName);
|
||||||
}
|
}
|
||||||
} catch(ex) {
|
} catch(ex) {
|
||||||
debug("ERROR: Unable to read pref \"" + aName + "\".\n");
|
debug("ERROR: Unable to read pref \"" + aName + "\".\n");
|
||||||
|
|
|
@ -38,7 +38,6 @@
|
||||||
* ***** END LICENSE BLOCK ***** */
|
* ***** END LICENSE BLOCK ***** */
|
||||||
|
|
||||||
#include "nsCOMPtr.h"
|
#include "nsCOMPtr.h"
|
||||||
#include "nsIObserver.h"
|
|
||||||
#include "nsIPrefBranch.h"
|
#include "nsIPrefBranch.h"
|
||||||
#include "nsIPrefBranchInternal.h"
|
#include "nsIPrefBranchInternal.h"
|
||||||
#include "nsIPrefLocalizedString.h"
|
#include "nsIPrefLocalizedString.h"
|
||||||
|
@ -52,7 +51,6 @@
|
||||||
class nsPrefBranch : public nsIPrefBranch,
|
class nsPrefBranch : public nsIPrefBranch,
|
||||||
public nsIPrefBranchInternal,
|
public nsIPrefBranchInternal,
|
||||||
public nsISecurityPref,
|
public nsISecurityPref,
|
||||||
public nsIObserver,
|
|
||||||
public nsSupportsWeakReference
|
public nsSupportsWeakReference
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
@ -60,7 +58,6 @@ public:
|
||||||
NS_DECL_NSIPREFBRANCH
|
NS_DECL_NSIPREFBRANCH
|
||||||
NS_DECL_NSIPREFBRANCHINTERNAL
|
NS_DECL_NSIPREFBRANCHINTERNAL
|
||||||
NS_DECL_NSISECURITYPREF
|
NS_DECL_NSISECURITYPREF
|
||||||
NS_DECL_NSIOBSERVER
|
|
||||||
|
|
||||||
nsPrefBranch(const char *aPrefRoot, PRBool aDefaultBranch);
|
nsPrefBranch(const char *aPrefRoot, PRBool aDefaultBranch);
|
||||||
virtual ~nsPrefBranch();
|
virtual ~nsPrefBranch();
|
||||||
|
@ -72,7 +69,6 @@ protected:
|
||||||
nsresult GetDefaultFromPropertiesFile(const char *aPrefName, PRUnichar **return_buf);
|
nsresult GetDefaultFromPropertiesFile(const char *aPrefName, PRUnichar **return_buf);
|
||||||
const char *getPrefName(const char *aPrefName);
|
const char *getPrefName(const char *aPrefName);
|
||||||
nsresult getValidatedPrefName(const char *aPrefName, const char **_retval);
|
nsresult getValidatedPrefName(const char *aPrefName, const char **_retval);
|
||||||
void freeObserverList(void);
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
PRInt32 mPrefRootLength;
|
PRInt32 mPrefRootLength;
|
||||||
|
|
Загрузка…
Ссылка в новой задаче