Landing PrefAPI refactoring bug 46863. r=valeski, sr=alecf, a=blizzard.

This commit is contained in:
bnesse%netscape.com 2001-04-19 22:21:39 +00:00
Родитель d8b4161a64
Коммит 6a048b1a8f
33 изменённых файлов: 923 добавлений и 1972 удалений

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

@ -2039,7 +2039,7 @@ nsScriptSecurityManager::SavePrincipal(nsIPrincipal* aToSave)
mSecurityPrefs->SecurityClearUserPref(idPrefName);
mIsWritingPrefs = PR_FALSE;
return mPrefs->SavePrefFile();
return mPrefs->SavePrefFile(nsnull);
}
static nsDOMProp

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

@ -1437,7 +1437,7 @@ function BuildRecentMenu(savePrefs)
}
// Force saving to file so next file opened finds these values
if (savePrefs)
gPrefs.SavePrefFile();
gPrefs.savePrefFile(null);
// Disable menu item if no entries
DisableItem("menu_RecentFiles", disableMenu);

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

@ -153,7 +153,7 @@ function onSaveDefault()
prefs.SetBoolPref("editor.hrule.shading", shading);
// Write the prefs out NOW!
prefs.SavePrefFile();
prefs.savePrefFile(null);
}
}
}

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

@ -635,7 +635,7 @@ EmbedPrivate::StartupProfile(void)
sPrefs = pref.get();
NS_ADDREF(sPrefs);
sPrefs->ResetPrefs();
sPrefs->ReadUserPrefs();
sPrefs->ReadUserPrefs(nsnull);
}
return NS_OK;
}
@ -645,7 +645,6 @@ void
EmbedPrivate::ShutdownProfile(void)
{
if (sPrefs) {
sPrefs->ShutDown();
NS_RELEASE(sPrefs);
sPrefs = 0;
}

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

@ -209,7 +209,7 @@ CBrowserApp::~CBrowserApp()
nsresult rv;
NS_WITH_SERVICE(nsIPref, prefs, NS_PREF_CONTRACTID, &rv);
if (NS_SUCCEEDED(rv) && prefs)
prefs->SavePrefFile();
prefs->SavePrefFile(nsnull);
NS_TermEmbedding();
}
@ -482,7 +482,7 @@ nsresult CBrowserApp::InitializePrefs()
prefs->SetIntPref("font.size.fixed.x-western", 12);
rv = prefs->SetBoolPref("ppbrowser.prefs_inited", PR_TRUE);
if (NS_SUCCEEDED(rv))
rv = prefs->SavePrefFile();
rv = prefs->SavePrefFile(nsnull);
}
}

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

@ -363,7 +363,7 @@ void CMfcEmbedApp::OnEditPreferences()
prefs->SetIntPref("browser.startup.page", m_iStartupPage);
rv = prefs->SetCharPref("browser.startup.homepage", m_strHomePage);
if (NS_SUCCEEDED(rv))
rv = prefs->SavePrefFile();
rv = prefs->SavePrefFile(nsnull);
}
else
NS_ASSERTION(PR_FALSE, "Could not get preferences service");
@ -428,7 +428,7 @@ nsresult CMfcEmbedApp::InitializePrefs()
prefs->SetIntPref("font.size.fixed.x-western", 13);
rv = prefs->SetBoolPref("mfcbrowser.prefs_inited", PR_TRUE);
if (NS_SUCCEEDED(rv))
rv = prefs->SavePrefFile();
rv = prefs->SavePrefFile(nsnull);
}
else
{

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

@ -315,7 +315,7 @@ SI_SetCharPref(const char * prefname, const char * prefvalue) {
if (!NS_FAILED(ret)) {
ret = pPrefService->SetCharPref(prefname, prefvalue);
if (!NS_FAILED(ret)) {
ret = pPrefService->SavePrefFile();
ret = pPrefService->SavePrefFile(nsnull);
}
}
}
@ -338,7 +338,7 @@ SI_SetBoolPref(const char * prefname, PRBool prefvalue) {
if (!NS_FAILED(ret)) {
ret = pPrefService->SetBoolPref(prefname, prefvalue);
if (!NS_FAILED(ret)) {
ret = pPrefService->SavePrefFile();
ret = pPrefService->SavePrefFile(nsnull);
}
}
}

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

@ -161,7 +161,7 @@ SI_SetBoolPref(const char * prefname, PRBool prefvalue) {
if (!NS_FAILED(ret)) {
ret = pPrefService->SetBoolPref(prefname, prefvalue);
if (!NS_FAILED(ret)) {
ret = pPrefService->SavePrefFile();
ret = pPrefService->SavePrefFile(nsnull);
}
}
}
@ -187,7 +187,7 @@ SI_SetCharPref(const char * prefname, const char * prefvalue) {
if (!NS_FAILED(ret)) {
ret = pPrefService->SetCharPref(prefname, prefvalue);
if (!NS_FAILED(ret)) {
ret = pPrefService->SavePrefFile();
ret = pPrefService->SavePrefFile(nsnull);
}
}
}

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

@ -288,16 +288,16 @@ nsPresContext::GetUserPreferences()
// * document colors
PRBool usePrefColors = PR_TRUE;
PRUint32 colorPref;
PRInt32 colorPref;
PRBool boolPref;
if (NS_SUCCEEDED(mPrefs->GetBoolPref("browser.display.use_system_colors", &boolPref))) {
usePrefColors = !boolPref;
}
if (usePrefColors) {
if (NS_SUCCEEDED(mPrefs->GetColorPrefDWord("browser.display.foreground_color", &colorPref))) {
if (NS_SUCCEEDED(mPrefs->GetIntPref("browser.display.foreground_color", &colorPref))) {
mDefaultColor = (nscolor)colorPref;
}
if (NS_SUCCEEDED(mPrefs->GetColorPrefDWord("browser.display.background_color", &colorPref))) {
if (NS_SUCCEEDED(mPrefs->GetIntPref("browser.display.background_color", &colorPref))) {
mDefaultBackgroundColor = (nscolor)colorPref;
}
}
@ -320,10 +320,10 @@ nsPresContext::GetUserPreferences()
if (NS_SUCCEEDED(mPrefs->GetBoolPref("browser.underline_anchors", &boolPref))) {
mUnderlineLinks = boolPref;
}
if (NS_SUCCEEDED(mPrefs->GetColorPrefDWord("browser.anchor_color", &colorPref))) {
if (NS_SUCCEEDED(mPrefs->GetIntPref("browser.anchor_color", &colorPref))) {
mLinkColor = (nscolor)colorPref;
}
if (NS_SUCCEEDED(mPrefs->GetColorPrefDWord("browser.visited_color", &colorPref))) {
if (NS_SUCCEEDED(mPrefs->GetIntPref("browser.visited_color", &colorPref))) {
mVisitedLinkColor = (nscolor)colorPref;
}
@ -332,10 +332,10 @@ nsPresContext::GetUserPreferences()
mUseFocusColors = boolPref;
mFocusTextColor = mDefaultColor;
mFocusBackgroundColor = mDefaultBackgroundColor;
if (NS_SUCCEEDED(mPrefs->GetColorPrefDWord("browser.display.focus_text_color", &colorPref))) {
if (NS_SUCCEEDED(mPrefs->GetIntPref("browser.display.focus_text_color", &colorPref))) {
mFocusTextColor = (nscolor)colorPref;
}
if (NS_SUCCEEDED(mPrefs->GetColorPrefDWord("browser.display.focus_background_color", &colorPref))) {
if (NS_SUCCEEDED(mPrefs->GetIntPref("browser.display.focus_background_color", &colorPref))) {
mFocusBackgroundColor = (nscolor)colorPref;
}
}

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

@ -288,16 +288,16 @@ nsPresContext::GetUserPreferences()
// * document colors
PRBool usePrefColors = PR_TRUE;
PRUint32 colorPref;
PRInt32 colorPref;
PRBool boolPref;
if (NS_SUCCEEDED(mPrefs->GetBoolPref("browser.display.use_system_colors", &boolPref))) {
usePrefColors = !boolPref;
}
if (usePrefColors) {
if (NS_SUCCEEDED(mPrefs->GetColorPrefDWord("browser.display.foreground_color", &colorPref))) {
if (NS_SUCCEEDED(mPrefs->GetIntPref("browser.display.foreground_color", &colorPref))) {
mDefaultColor = (nscolor)colorPref;
}
if (NS_SUCCEEDED(mPrefs->GetColorPrefDWord("browser.display.background_color", &colorPref))) {
if (NS_SUCCEEDED(mPrefs->GetIntPref("browser.display.background_color", &colorPref))) {
mDefaultBackgroundColor = (nscolor)colorPref;
}
}
@ -320,10 +320,10 @@ nsPresContext::GetUserPreferences()
if (NS_SUCCEEDED(mPrefs->GetBoolPref("browser.underline_anchors", &boolPref))) {
mUnderlineLinks = boolPref;
}
if (NS_SUCCEEDED(mPrefs->GetColorPrefDWord("browser.anchor_color", &colorPref))) {
if (NS_SUCCEEDED(mPrefs->GetIntPref("browser.anchor_color", &colorPref))) {
mLinkColor = (nscolor)colorPref;
}
if (NS_SUCCEEDED(mPrefs->GetColorPrefDWord("browser.visited_color", &colorPref))) {
if (NS_SUCCEEDED(mPrefs->GetIntPref("browser.visited_color", &colorPref))) {
mVisitedLinkColor = (nscolor)colorPref;
}
@ -332,10 +332,10 @@ nsPresContext::GetUserPreferences()
mUseFocusColors = boolPref;
mFocusTextColor = mDefaultColor;
mFocusBackgroundColor = mDefaultBackgroundColor;
if (NS_SUCCEEDED(mPrefs->GetColorPrefDWord("browser.display.focus_text_color", &colorPref))) {
if (NS_SUCCEEDED(mPrefs->GetIntPref("browser.display.focus_text_color", &colorPref))) {
mFocusTextColor = (nscolor)colorPref;
}
if (NS_SUCCEEDED(mPrefs->GetColorPrefDWord("browser.display.focus_background_color", &colorPref))) {
if (NS_SUCCEEDED(mPrefs->GetIntPref("browser.display.focus_background_color", &colorPref))) {
mFocusBackgroundColor = (nscolor)colorPref;
}
}

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

@ -412,7 +412,7 @@ nsresult DIR_ShutDown() /* FEs should call this when the app is shutting down.
NS_WITH_SERVICE(nsIPref, pPref, kPrefCID, &rv);
if (NS_FAILED(rv) || !pPref)
return NS_ERROR_FAILURE;
pPref->SavePrefFile();
pPref->SavePrefFile(nsnull);
if (dir_ServerList)
{
@ -487,7 +487,7 @@ nsresult DIR_AddNewAddressBook(const PRUnichar *dirName, const char *fileName, P
NS_WITH_SERVICE(nsIPref, pPref, kPrefCID, &rv);
if (NS_FAILED(rv) || !pPref)
return NS_ERROR_FAILURE;
pPref->SavePrefFile();
pPref->SavePrefFile(nsnull);
return NS_OK;
}
@ -2009,7 +2009,7 @@ nsresult DIR_DeleteServerFromList(DIR_Server *server)
NS_WITH_SERVICE(nsIPref, pPref, kPrefCID, &rv);
if (NS_FAILED(rv) || !pPref)
return NS_ERROR_FAILURE;
pPref->SavePrefFile();
pPref->SavePrefFile(nsnull);
return NS_OK;
}

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

@ -148,7 +148,7 @@ function onOk() {
// hack hack - save the prefs file NOW in case we crash
try {
var prefs = Components.classes["@mozilla.org/preferences;1"].getService(Components.interfaces.nsIPref);
prefs.SavePrefFile();
prefs.savePrefFile(null);
} catch (ex) {
dump("Error saving prefs!\n");
}

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

@ -224,7 +224,7 @@ function FinishAccount() {
// hack hack - save the prefs file NOW in case we crash
try {
var prefs = Components.classes["@mozilla.org/preferences;1"].getService(Components.interfaces.nsIPref);
prefs.SavePrefFile();
prefs.savePrefFile(null);
} catch (ex) {
dump("Error saving prefs!\n");
dump("ex = " + ex + "\n");

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

@ -676,7 +676,7 @@ nsMessengerMigrator::UpgradePrefs()
if (NS_FAILED(rv)) return rv;
// we're done migrating, let's save the prefs
rv = m_prefs->SavePrefFile();
rv = m_prefs->SavePrefFile(nsnull);
if (NS_FAILED(rv)) return rv;
// remove the temporary identity we used for migration purposes

Двоичные данные
modules/libpref/macbuild/libpref.mcp

Двоичный файл не отображается.

Двоичные данные
modules/libpref/macbuild/libprefIDL.mcp

Двоичный файл не отображается.

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

@ -3,4 +3,4 @@
#
nsIPref.idl
nsISecurityPref.idl
nsIPrefBranch.idl

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

@ -28,7 +28,14 @@ include $(DEPTH)/config/autoconf.mk
MODULE = pref
XPIDLSRCS = nsIPref.idl nsISecurityPref.idl
XPIDLSRCS = \
nsIPref.idl \
nsIPrefBranch.idl \
nsIPrefBranchInternal.idl \
nsIPrefLocalizedString.idl \
nsIPrefService.idl \
nsISecurityPref.idl \
$(NULL)
EXPORTS = prefldap.h
EXPORTS := $(addprefix $(srcdir)/, $(EXPORTS))

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

@ -24,7 +24,14 @@ MODULE=pref
DEPTH=..\..\..
EXPORTS=prefldap.h
XPIDLSRCS = .\nsIPref.idl .\nsISecurityPref.idl
XPIDLSRCS = \
.\nsIPref.idl \
.\nsIPrefBranch.idl \
.\nsIPrefBranchInternal.idl \
.\nsIPrefLocalizedString.idl \
.\nsIPrefService.idl \
.\nsISecurityPref.idl \
$(NULL)
include <$(DEPTH)\config\config.mak>
include <$(DEPTH)\config\rules.mak>

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

@ -1,4 +1,4 @@
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*-
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape Public
* License Version 1.1 (the "License"); you may not use this file
@ -20,12 +20,17 @@
* Contributor(s):
*/
#include "nsISupports.idl"
#include "nsIPrefService.idl"
#include "nsIFile.idl"
#include "nsIFileSpec.idl"
#include "nsILocalFile.idl"
#include "nsIObserver.idl"
#include "nsIPrefBranch.idl"
#include "nsIPrefBranchInternal.idl"
/**
* @status UNDER_REVIEW
/*
* This entire interface is depricated and should not be used.
* See nsIPrefService and nsIPrefBranch for the new implementations.
*/
%{C++
@ -52,111 +57,191 @@ typedef void (*PrefEnumerationFunc)(const char *, void *);
native PrefChangedFunc(PrefChangedFunc);
native PrefEnumerationFunc(PrefEnumerationFunc);
interface nsIFileSpec;
[scriptable, uuid(a22ad7b0-ca86-11d1-a9a4-00805f8a7ac4)]
interface nsIPref : nsISupports {
const long ePrefInvalid = 0;
const long ePrefLocked = 1;
const long ePrefUserset = 2;
const long ePrefConfig = 4;
const long ePrefRemote = 8;
const long ePrefLilocal = 16;
const long ePrefString = 32;
const long ePrefInt = 64;
const long ePrefBool = 128;
const long ePrefValuetypeMask = (ePrefString | ePrefInt | ePrefBool);
// Initialize/shutdown
void StartUp();
void ReadUserPrefs();
void ReadUserPrefsFrom(in nsIFileSpec spec);
void ResetUserPrefs();
/*
* These are the the Prefs Service methods we will support for now
*/
/*
* readConfigFile
*
* identify and read the configuration (.cfg) file
*/
void readConfigFile();
/*
* readUserPrefs
*
* read a user preference file, pass in null for default file
*/
void readUserPrefs(in nsIFile aFile);
/*
* resetPrefs
*
* completely flush and reload the preferences system
*/
void ResetPrefs();
void ShutDown();
// Config file input
void SavePrefFileAs(in nsIFileSpec filename);
/*
* resetUserPrefs
*
* flush all current user prefrences (reset all preferences to the default values)
*/
void ResetUserPrefs();
/* Getters */
long GetPrefType(in string pref);
long GetIntPref(in string pref);
boolean GetBoolPref(in string pref);
[noscript] void GetBinaryPref(in string pref, in voidPtr buf,
inout long buf_length);
/*
* savePrefFile
*
* write current preferences state to a file, pass in null for default file
*/
void savePrefFile(in nsIFile aFile);
unsigned long GetColorPrefDWord(in string pref);
/* set preferences */
void SetCharPref(in string pref, in string value);
void SetUnicharPref(in string pref, in wstring value);
void SetIntPref(in string pref, in long value);
void SetBoolPref(in string pref, in boolean value);
[noscript] void SetBinaryPref(in string pref, in voidPtr value,
in unsigned long size);
/*
* branch operations
*/
void ClearUserPref(in string pref_name);
/* get defaults */
long GetDefaultIntPref(in string pref);
boolean GetDefaultBoolPref(in string pref);
[noscript] void GetDefaultBinaryPref(in string pref, in voidPtr value,
out long length);
nsIPrefBranch getBranch(in string aPrefRoot);
nsIPrefBranch getDefaultBranch(in string aPrefRoot);
/* set defaults */
void SetDefaultCharPref(in string pref, in string value);
void SetDefaultUnicharPref(in string pref, in wstring value);
void SetDefaultIntPref(in string pref, in long value);
void SetDefaultBoolPref(in string pref, in boolean value);
[noscript] void SetDefaultBinaryPref(in string pref, in voidPtr value,
in unsigned long size);
// these are eventually changing from Copy->get
string CopyCharPref(in string pref);
wstring CopyUnicharPref(in string pref);
[noscript] voidPtr CopyBinaryPref(in string pref, out long size);
// "localized" prefs - stored in the properties files
wstring getLocalizedUnicharPref(in string pref);
wstring getDefaultLocalizedUnicharPref(in string pref);
string CopyDefaultCharPref(in string pref);
wstring CopyDefaultUnicharPref(in string pref);
[noscript] voidPtr CopyDefaultBinaryPref(in string pref, out long size);
nsIFileSpec GetFilePref(in string pref);
void SetFilePref(in string pref, in nsIFileSpec value, in boolean setDefault);
nsILocalFile getFileXPref(in string pref);
void setFileXPref(in string pref, in nsILocalFile value);
/*
* These are the the Prefs Branch methods we will support for now
*/
/* pref attributes */
boolean PrefIsLocked(in string pref);
const long ePrefInvalid = 0;
const long ePrefLocked = 1;
const long ePrefUserset = 2;
const long ePrefConfig = 4;
const long ePrefRemote = 8;
const long ePrefLilocal = 16;
const long ePrefString = 32;
const long ePrefInt = 64;
const long ePrefBool = 128;
const long ePrefValuetypeMask = (ePrefString | ePrefInt | ePrefBool);
/* save pref values */
void SavePrefFile();
/*
* the root of this branch, such as "browser."
*/
readonly attribute string root;
/*
* standard methods for accessing preferences
*/
long GetPrefType(in string aPrefName);
boolean GetBoolPref(in string aPrefName);
void SetBoolPref(in string aPrefName, in long aValue);
string GetCharPref(in string aPrefName);
void SetCharPref(in string aPrefName, in string aValue);
long GetIntPref(in string aPrefName);
void SetIntPref(in string aPrefName, in long aValue);
/*
* methods for accessing complex preferences (i.e. items beyond the simple bool, char, and int)
*/
void getComplexValue(in string aPrefName, in nsIIDRef aType, [iid_is(aType), retval] out nsQIResult aValue);
void setComplexValue(in string aPrefName, in nsIIDRef aType, in nsISupports aValue);
/*
* methods for preference state manipulation
*/
void ClearUserPref(in string aPrefName);
boolean PrefIsLocked(in string aPrefName);
void lockPref(in string aPrefName);
void unlockPref(in string aPrefName);
/*
* branch-level operations
*/
/*
* resetBranch
*
* clears all user preferences starting at the given preference prefix
* pass in null or "" to clear this branch
*/
void resetBranch(in string aStartingAt);
/*
* deleteBranch
*
* removes all preferences starting at the given preference prefix
* pass in null or "" to remove this branch
*/
void DeleteBranch(in string aStartingAt);
/*
* getChildList
*
* Returns an array of strings representing the child preferences of the branch root
*
* @param startingAt pass in null or "" to enumerate the entire branch
* @param count Receives the number of elements in the array.
* @param childArray Receives the array of child preferences.
*/
void getChildList(in string aStartingAt,
out unsigned long aCount,
[array, size_is(aCount), retval] out string aChildArray);
/*
* Listeners
*/
/* callbacks */
[noscript] void RegisterCallback(in string domain,
in PrefChangedFunc callback,
in voidPtr closure);
[noscript] void UnregisterCallback(in string domain,
in PrefChangedFunc callback,
in voidPtr closure);
/*
* The observers have their |Observe| methods called with
* ([the observer], "nsPref:changed", [pref name]).
*/
void addObserver(in string domain, in nsIObserver observer);
void removeObserver(in string domain, in nsIObserver observer);
void addObserver(in string aDomain, in nsIObserver aObserver);
void removeObserver(in string aDomain, in nsIObserver aObserver);
/*
* Finally some depricated methods
*/
/* void CopyPrefsTree(in string srcRoot, in string destRoot); */
void DeleteBranch(in string branchName);
// these are changing from Copy->get
string CopyCharPref(in string pref);
string CopyDefaultCharPref(in string pref);
/* get & set defaults */
boolean GetDefaultBoolPref(in string pref);
long GetDefaultIntPref(in string pref);
void SetDefaultBoolPref(in string pref, in boolean value);
void SetDefaultCharPref(in string pref, in string value);
void SetDefaultIntPref(in string pref, in long value);
/* unichar & localized unichar prefs */
wstring CopyUnicharPref(in string pref);
wstring CopyDefaultUnicharPref(in string pref);
void SetUnicharPref(in string pref, in wstring value);
void SetDefaultUnicharPref(in string pref, in wstring value);
wstring getLocalizedUnicharPref(in string pref);
wstring getDefaultLocalizedUnicharPref(in string pref);
/* file & filespec prefs */
nsIFileSpec GetFilePref(in string pref);
void SetFilePref(in string pref, in nsIFileSpec value, in boolean setDefault);
nsILocalFile getFileXPref(in string pref);
void setFileXPref(in string pref, in nsILocalFile value);
/* callbacks */
[noscript] void RegisterCallback(in string domain, in PrefChangedFunc callback, in voidPtr closure);
[noscript] void UnregisterCallback(in string domain, in PrefChangedFunc callback, in voidPtr closure);
void CreateChildList(in string parent_node,out string childList);
[noscript] string NextChild(in string child_list, inout short index);
/**
* EnumerateChildren
*
@ -167,7 +252,5 @@ interface nsIPref : nsISupports {
* @param callback A function to call back for each matching preference
* @param data A piece of data to pass on to the callback
*/
[noscript] void EnumerateChildren(in string parent,
in PrefEnumerationFunc callback,
in voidPtr data);
[noscript] void EnumerateChildren(in string parent, in PrefEnumerationFunc callback, in voidPtr data);
};

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

@ -35,7 +35,11 @@ include $(topsrcdir)/config/config.mk
CSRCS = prefapi.c
CPPSRCS = nsPref.cpp
CPPSRCS = nsPref.cpp \
nsPrefBranch.cpp \
nsPrefService.cpp \
nsPrefsFactory.cpp \
$(NULL)
PREF_JS_EXPORTS = \
$(srcdir)/initpref.js \

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

@ -72,6 +72,9 @@ LLIBS = \
OBJS = \
.\$(OBJDIR)\prefapi.obj \
.\$(OBJDIR)\nsPref.obj \
.\$(OBJDIR)\nsPrefBranch.obj \
.\$(OBJDIR)\nsPrefService.obj \
.\$(OBJDIR)\nsPrefsFactory.obj \
$(NULL)
#//------------------------------------------------------------------------

Разница между файлами не показана из-за своего большого размера Загрузить разницу

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

@ -74,7 +74,7 @@ nsPrefService::nsPrefService()
NS_INIT_REFCNT();
rootBranch = new nsPrefBranch("", FALSE);
rootBranch = new nsPrefBranch("", PR_FALSE);
mRootBranch = (nsIPrefBranch *)rootBranch;
}
@ -323,10 +323,11 @@ static nsresult openPrefFileSpec(nsIFileSpec* aFilespec, PRBool aIsErrorFatal, P
nsresult rv;
char* readBuf;
// TODO: Validate this entire function, I seriously doubt it does what it is supposed to.
// Note for instance that gErrorOpeningUserPrefs will only be set if the evaluation
// of the config script fails AND aIsErrorFatal is set TRUE... the readBuf test is
// irrelavent because it will bail at the GetFileContents call if it fails.
// TODO: Validate this entire function, I seriously doubt it does what it is
// supposed to. Note for instance that gErrorOpeningUserPrefs will only
// be set if the evaluation of the config script fails AND aIsErrorFatal
// is set to PR_TRUE... the readBuf test is irrelavent because it will
// bail at the GetFileContents call if it fails.
// TODO: Convert the rest of this code to nsIFile and avoid this conversion to nsIFileSpec
rv = aFilespec->ResolveSymlink();
@ -706,7 +707,6 @@ extern "C" JSBool pref_InitInitialObjects()
}
}
done:
JS_MaybeGC(gMochaContext);
return JS_TRUE;
}
@ -724,7 +724,7 @@ extern "C" JSRuntime* PREF_GetJSRuntime()
return rt;
}
}
NS_ASSERTION(NS_SUCCEEDED(rv), "nsJSRuntimeService is missing");
NS_WARNING("nsJSRuntimeService is missing");
return nsnull;
}

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

@ -27,7 +27,7 @@
#include "nsIPref.h"
// remove this when nsPref goes away
extern "C" nsresult nsPrefConstructor(nsISupports *aOuter, REFNSIID aIID, void **aResult);
extern "C" NS_IMETHODIMP nsPrefConstructor(nsISupports *aOuter, REFNSIID aIID, void **aResult);
NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(nsPrefService, Init)

42
netwerk/cache/src/nsCacheService.cpp поставляемый
Просмотреть файл

@ -37,7 +37,9 @@
#include "nsIEventQueue.h"
#include "nsProxiedService.h"
#include "nsIObserverService.h"
#include "nsIPref.h"
#include "nsIPrefService.h"
#include "nsIPrefBranch.h"
#include "nsIPrefBranchInternal.h"
static NS_DEFINE_CID(kEventQueueServiceCID, NS_EVENTQUEUESERVICE_CID);
static NS_DEFINE_CID(kProxyObjectManagerCID, NS_PROXYEVENT_MANAGER_CID);
@ -82,19 +84,25 @@ nsresult
nsCachePrefObserver::Install()
{
nsresult rv, rv2;
nsCOMPtr<nsIPref> prefs = do_GetService(NS_PREF_CONTRACTID, &rv);
nsCOMPtr<nsIPrefService> prefs = do_GetService(NS_PREFSERVICE_CONTRACTID, &rv);
if (NS_FAILED(rv)) return rv;
rv = prefs->AddObserver(ENABLE_MEMORY_CACHE_PREF, this);
nsCOMPtr<nsIPrefBranchInternal> prefInternal = do_QueryInterface(prefs, &rv);
if (NS_FAILED(rv)) return rv;
rv = prefInternal->AddObserver(ENABLE_MEMORY_CACHE_PREF, this);
if (NS_FAILED(rv)) rv2 = rv;
rv = prefs->AddObserver(ENABLE_DISK_CACHE_PREF, this);
rv = prefInternal->AddObserver(ENABLE_DISK_CACHE_PREF, this);
if (NS_FAILED(rv)) rv2 = rv;
rv = prefs->GetBoolPref(ENABLE_DISK_CACHE_PREF, &mDiskCacheEnabled);
nsCOMPtr<nsIPrefBranch> prefBranch = do_QueryInterface(prefs, &rv);
if (NS_FAILED(rv)) return rv;
rv = prefBranch->GetBoolPref(ENABLE_DISK_CACHE_PREF, &mDiskCacheEnabled);
if (NS_FAILED(rv)) rv2 = rv;
rv = prefs->GetBoolPref(ENABLE_MEMORY_CACHE_PREF, &mMemoryCacheEnabled);
rv = prefBranch->GetBoolPref(ENABLE_MEMORY_CACHE_PREF, &mMemoryCacheEnabled);
// if (NS_FAILED(rv)) rv2 = rv;
if (NS_SUCCEEDED(rv)) rv = rv2;
@ -107,11 +115,14 @@ nsCachePrefObserver::Remove()
{
nsresult rv, rv2;
nsCOMPtr<nsIPref> prefs = do_GetService(NS_PREF_CONTRACTID, &rv);
nsCOMPtr<nsIPrefService> prefs = do_GetService(NS_PREFSERVICE_CONTRACTID, &rv);
if (NS_FAILED(rv)) return rv;
rv = prefs->RemoveObserver(ENABLE_DISK_CACHE_PREF, this);
rv2 = prefs->RemoveObserver(ENABLE_MEMORY_CACHE_PREF, this);
nsCOMPtr<nsIPrefBranchInternal> prefInternal = do_QueryInterface(prefs, &rv);
if (NS_FAILED(rv)) return rv;
rv = prefInternal->RemoveObserver(ENABLE_DISK_CACHE_PREF, this);
rv2 = prefInternal->RemoveObserver(ENABLE_MEMORY_CACHE_PREF, this);
if (NS_SUCCEEDED(rv)) rv = rv2;
return rv;
@ -126,7 +137,7 @@ nsCachePrefObserver::Observe(nsISupports * subject,
nsresult rv;
if (NS_LITERAL_STRING("nsPref:changed").Equals(topic)) {
nsCOMPtr<nsIPref> prefs = do_QueryInterface(subject, &rv);
nsCOMPtr<nsIPrefBranch> prefs = do_QueryInterface(subject, &rv);
if (NS_FAILED(rv)) return rv;
// which preference changed?
@ -211,11 +222,14 @@ nsCacheService::Init()
rv = mActiveEntries.Init();
if (NS_FAILED(rv)) goto error;
{ // scope nsCOMPtr<nsIPref>
nsCOMPtr<nsIPref> prefs = do_GetService(NS_PREF_CONTRACTID, &rv);
{ // scope nsCOMPtr<nsIPrefService> and nsCOMPtr<nsIPrefBranch>
nsCOMPtr<nsIPrefService> prefs = do_GetService(NS_PREFSERVICE_CONTRACTID, &rv);
if (NS_FAILED(rv)) return rv;
nsCOMPtr<nsIPrefBranch> prefBranch = do_QueryInterface(prefs, &rv);
if (NS_SUCCEEDED(rv)) {
rv = prefs->GetBoolPref(ENABLE_DISK_CACHE_PREF, &mEnableDiskDevice);
rv = prefs->GetBoolPref(ENABLE_MEMORY_CACHE_PREF, &mEnableMemoryDevice);
rv = prefBranch->GetBoolPref(ENABLE_DISK_CACHE_PREF, &mEnableDiskDevice);
rv = prefBranch->GetBoolPref(ENABLE_MEMORY_CACHE_PREF, &mEnableMemoryDevice);
// ignore errors
}
}

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

@ -585,7 +585,7 @@ nsPrefMigration::ProcessPrefsCallback(const char* oldProfilePathStr, const char
nsCOMPtr<nsIFileSpec> newIMAPLocalMailPath;
nsCOMPtr<nsIFileSpec> oldNewsPath;
nsCOMPtr<nsIFileSpec> newNewsPath;
nsCOMPtr<nsIFileSpec> newPrefsFile;
nsCOMPtr<nsILocalFile> newPrefsFile;
#ifdef HAVE_MOVEMAIL
nsCOMPtr<nsIFileSpec> oldMOVEMAILMailPath;
nsCOMPtr<nsIFileSpec> newMOVEMAILMailPath;
@ -694,14 +694,16 @@ nsPrefMigration::ProcessPrefsCallback(const char* oldProfilePathStr, const char
tempPrefsFile += PREF_FILE_NAME_IN_4x;
//Create the m_prefsFile fileSpec for use in ReadUserPrefsFrom
rv = NS_NewFileSpecWithSpec(tempPrefsFile, getter_AddRefs(m_prefsFile));
if (NS_FAILED(rv)) return rv;
// rv = NS_NewFileSpecWithSpec(tempPrefsFile, getter_AddRefs(m_prefsFile));
// if (NS_FAILED(rv)) return rv;
NS_NewLocalFile((const char *)tempPrefsFile, PR_TRUE, getter_AddRefs(m_prefsFile));
//Clear the prefs in case a previous set was read in.
m_prefs->ResetPrefs();
//Now read the prefs from the prefs file in the system directory
m_prefs->ReadUserPrefsFrom(m_prefsFile);
m_prefs->ReadUserPrefs(m_prefsFile);
//
// Start computing the sizes required for migration
@ -1171,13 +1173,15 @@ nsPrefMigration::ProcessPrefsCallback(const char* oldProfilePathStr, const char
if (NS_FAILED(rv)) return rv;
PR_FREEIF(popServerName);
NS_NewFileSpec(getter_AddRefs(newPrefsFile));
newPrefsFile->FromFileSpec(newProfilePath);
nsXPIDLCString path;
rv = newPrefsFile->AppendRelativeUnixPath(PREF_FILE_NAME_IN_5x);
newProfilePath->GetNativePath(getter_Copies(path));
NS_NewLocalFile(path, PR_TRUE, getter_AddRefs(newPrefsFile));
rv = newPrefsFile->Append(PREF_FILE_NAME_IN_5x);
if (NS_FAILED(rv)) return rv;
rv=m_prefs->SavePrefFileAs(newPrefsFile);
rv=m_prefs->SavePrefFile(newPrefsFile);
if (NS_FAILED(rv)) return rv;
rv=m_prefs->ResetPrefs();
if (NS_FAILED(rv)) return rv;

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

@ -151,7 +151,7 @@ class nsPrefMigration: public nsIPrefMigration
nsresult getPrefService();
nsCOMPtr<nsIPref> m_prefs;
nsCOMPtr<nsIFileSpec> m_prefsFile;
nsCOMPtr<nsILocalFile> m_prefsFile;
nsCOMPtr<nsIDOMWindowInternal> m_parentWindow;
nsCOMPtr<nsIXULWindow> mPMProgressWindow;
};

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

@ -1616,7 +1616,7 @@ nsresult nsProfile::LoadNewProfilePrefs()
if (NS_FAILED(rv)) return rv;
prefs->ResetUserPrefs();
prefs->ReadUserPrefs();
prefs->ReadUserPrefs(nsnull);
return NS_OK;
}

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

@ -3276,7 +3276,7 @@ nsBrowserWindow::ToggleBoolPrefAndRefresh(const char * aPrefName)
PRBool value;
prefs->GetBoolPref(aPrefName,&value);
prefs->SetBoolPref(aPrefName,!value);
prefs->SavePrefFile();
prefs->SavePrefFile(nsnull);
ForceRefresh();
}
@ -3293,7 +3293,7 @@ nsBrowserWindow::SetBoolPref(const char * aPrefName, PRBool aValue)
if (prefs && nsnull != aPrefName)
{
prefs->SetBoolPref(aPrefName, aValue);
prefs->SavePrefFile();
prefs->SavePrefFile(nsnull);
}
}
@ -3307,7 +3307,7 @@ nsBrowserWindow::SetStringPref(const char * aPrefName, const nsString& aValue)
{
char * prefStr = aValue.ToNewCString();
prefs->SetCharPref(aPrefName, prefStr);
prefs->SavePrefFile();
prefs->SavePrefFile(nsnull);
delete [] prefStr;
}
@ -3652,7 +3652,7 @@ nsBrowserWindow::SetCompatibilityMode(PRUint32 aMode)
prefInt = eCompatibility_NavQuirks;
}
pref->SetIntPref("nglayout.compatibility.mode", prefInt);
pref->SavePrefFile();
pref->SavePrefFile(nsnull);
}
}

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

@ -184,7 +184,6 @@ nsViewerApp::Destroy()
}
if (nsnull != mPrefs) {
mPrefs->ShutDown();
NS_RELEASE(mPrefs);
}
}
@ -320,8 +319,7 @@ nsViewerApp::Initialize(int argc, char** argv)
if (NS_OK != rv) {
return rv;
}
mPrefs->StartUp();
mPrefs->ReadUserPrefs();
mPrefs->ReadUserPrefs(nsnull);
// Load Fullcircle Talkback crash-reporting mechanism.
// http://www.fullcirclesoftware.com for more details.

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

@ -593,7 +593,7 @@ static nsresult DoOnShutdown()
nsCOMPtr<nsIPref> prefs(do_GetService(NS_PREF_CONTRACTID, &rv));
NS_ASSERTION(NS_SUCCEEDED(rv), "failed to get prefs, so unable to save them");
if (NS_SUCCEEDED(rv))
prefs->SavePrefFile();
prefs->SavePrefFile(nsnull);
}
// at this point, all that is on the clipboard is a proxy object, but that object
@ -766,7 +766,7 @@ static nsresult InitializeProfileService(nsICmdLineService *cmdLineArgs)
rv = prefs->ResetPrefs();
if (NS_FAILED(rv)) return rv;
rv = prefs->ReadUserPrefs();
rv = prefs->ReadUserPrefs(nsnull);
if (NS_FAILED(rv)) return rv;
}
else

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

@ -244,7 +244,7 @@ nsPrefWindow.prototype =
}
}
}
this.pref.SavePrefFile();
this.pref.savePrefFile(null);
},
switchPage: