зеркало из https://github.com/mozilla/gecko-dev.git
Prefs API refactoring. Bug #46863. r=valeski, sr=alecf.
This commit is contained in:
Родитель
ceb82b1286
Коммит
000d1011d5
|
@ -2020,7 +2020,7 @@ nsScriptSecurityManager::SavePrincipal(nsIPrincipal* aToSave)
|
|||
mSecurityPrefs->SecurityClearUserPref(idPrefName);
|
||||
|
||||
mIsWritingPrefs = PR_FALSE;
|
||||
return mPrefs->SavePrefFile();
|
||||
return mPrefs->SavePrefFile(nsnull);
|
||||
}
|
||||
|
||||
static nsDOMProp
|
||||
|
|
|
@ -1420,7 +1420,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;
|
||||
}
|
||||
|
|
|
@ -213,7 +213,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();
|
||||
}
|
||||
|
@ -515,7 +515,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);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -421,7 +421,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");
|
||||
|
@ -486,7 +486,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
|
||||
{
|
||||
|
|
|
@ -280,7 +280,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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -303,7 +303,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/libpref.mcp
Двоичный файл не отображается.
Двоичные данные
modules/libpref/macbuild/libprefIDL.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,18 +20,26 @@
|
|||
* 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++
|
||||
|
||||
|
||||
#ifndef have_PrefChangedFunc_typedef
|
||||
typedef int (*PR_CALLBACK PrefChangedFunc)(const char *, void *);
|
||||
#define have_PrefChangedFunc_typedef
|
||||
#endif
|
||||
typedef void (*PrefEnumerationFunc)(const char *, void *);
|
||||
|
||||
#define NS_PREF_CID \
|
||||
|
@ -52,10 +60,61 @@ typedef void (*PrefEnumerationFunc)(const char *, void *);
|
|||
native PrefChangedFunc(PrefChangedFunc);
|
||||
native PrefEnumerationFunc(PrefEnumerationFunc);
|
||||
|
||||
interface nsIFileSpec;
|
||||
|
||||
[scriptable, uuid(a22ad7b0-ca86-11d1-a9a4-00805f8a7ac4)]
|
||||
interface nsIPref : nsISupports {
|
||||
|
||||
/*
|
||||
* 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();
|
||||
|
||||
/*
|
||||
* resetUserPrefs
|
||||
*
|
||||
* flush all current user prefrences (reset all preferences to the default values)
|
||||
*/
|
||||
void ResetUserPrefs();
|
||||
|
||||
/*
|
||||
* savePrefFile
|
||||
*
|
||||
* write current preferences state to a file, pass in null for default file
|
||||
*/
|
||||
void savePrefFile(in nsIFile aFile);
|
||||
|
||||
/*
|
||||
* branch operations
|
||||
*/
|
||||
|
||||
nsIPrefBranch getBranch(in string aPrefRoot);
|
||||
nsIPrefBranch getDefaultBranch(in string aPrefRoot);
|
||||
|
||||
|
||||
/*
|
||||
* These are the the Prefs Branch methods we will support for now
|
||||
*/
|
||||
|
||||
const long ePrefInvalid = 0;
|
||||
const long ePrefLocked = 1;
|
||||
const long ePrefUserset = 2;
|
||||
|
@ -67,96 +126,125 @@ interface nsIPref : nsISupports {
|
|||
const long ePrefBool = 128;
|
||||
const long ePrefValuetypeMask = (ePrefString | ePrefInt | ePrefBool);
|
||||
|
||||
// Initialize/shutdown
|
||||
void StartUp();
|
||||
void ReadUserPrefs();
|
||||
void ReadUserPrefsFrom(in nsIFileSpec spec);
|
||||
void ResetUserPrefs();
|
||||
void ResetPrefs();
|
||||
void ShutDown();
|
||||
/*
|
||||
* the root of this branch, such as "browser."
|
||||
*/
|
||||
readonly attribute string root;
|
||||
|
||||
// Config file input
|
||||
void SavePrefFileAs(in nsIFileSpec filename);
|
||||
/*
|
||||
* standard methods for accessing preferences
|
||||
*/
|
||||
long GetPrefType(in string aPrefName);
|
||||
|
||||
/* 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);
|
||||
boolean GetBoolPref(in string aPrefName);
|
||||
void SetBoolPref(in string aPrefName, in long aValue);
|
||||
|
||||
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);
|
||||
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);
|
||||
|
||||
|
||||
void ClearUserPref(in string pref_name);
|
||||
/*
|
||||
* branch-level operations
|
||||
*/
|
||||
|
||||
/* get defaults */
|
||||
long GetDefaultIntPref(in string pref);
|
||||
boolean GetDefaultBoolPref(in string pref);
|
||||
[noscript] void GetDefaultBinaryPref(in string pref, in voidPtr value,
|
||||
out long length);
|
||||
/*
|
||||
* resetBranch
|
||||
*
|
||||
* clears all user preferences starting at the given preference prefix
|
||||
* pass in null or "" to clear this branch
|
||||
*/
|
||||
void resetBranch(in string aStartingAt);
|
||||
|
||||
/* 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);
|
||||
/*
|
||||
* deleteBranch
|
||||
*
|
||||
* removes all preferences starting at the given preference prefix
|
||||
* pass in null or "" to remove this branch
|
||||
*/
|
||||
void DeleteBranch(in string aStartingAt);
|
||||
|
||||
// these are eventually changing from Copy->get
|
||||
/*
|
||||
* 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
|
||||
*/
|
||||
|
||||
/*
|
||||
* The observers have their |Observe| methods called with
|
||||
* ([the observer], "nsPref:changed", [pref name]).
|
||||
*/
|
||||
void addObserver(in string aDomain, in nsIObserver aObserver);
|
||||
void removeObserver(in string aDomain, in nsIObserver aObserver);
|
||||
|
||||
|
||||
/*
|
||||
* Finally some depricated methods
|
||||
*/
|
||||
|
||||
|
||||
// these are changing from Copy->get
|
||||
string CopyCharPref(in string pref);
|
||||
wstring CopyUnicharPref(in string pref);
|
||||
[noscript] voidPtr CopyBinaryPref(in string pref, out long size);
|
||||
string CopyDefaultCharPref(in string pref);
|
||||
|
||||
// "localized" prefs - stored in the properties files
|
||||
/* 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);
|
||||
|
||||
string CopyDefaultCharPref(in string pref);
|
||||
wstring CopyDefaultUnicharPref(in string pref);
|
||||
[noscript] voidPtr CopyDefaultBinaryPref(in string pref, out long size);
|
||||
|
||||
/* 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);
|
||||
|
||||
/* pref attributes */
|
||||
boolean PrefIsLocked(in string pref);
|
||||
|
||||
/* save pref values */
|
||||
void SavePrefFile();
|
||||
|
||||
/* 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 CopyPrefsTree(in string srcRoot, in string destRoot); */
|
||||
void DeleteBranch(in string branchName);
|
||||
[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 +255,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)
|
||||
|
||||
#//------------------------------------------------------------------------
|
||||
|
|
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
|
@ -24,7 +24,6 @@
|
|||
#include "nsPrefService.h"
|
||||
#include "jsapi.h"
|
||||
#include "nsIObserverService.h"
|
||||
#include "nsIProfileChangeStatus.h"
|
||||
#include "nsISignatureVerifier.h"
|
||||
#include "nsPrefBranch.h"
|
||||
#include "nsXPIDLString.h"
|
||||
|
|
|
@ -386,9 +386,10 @@ PrefResult PREF_CopyPrefsTree(const char *srcRoot, const char *destRoot);
|
|||
** file. The two types need to be in sync for now. Certain
|
||||
** compilers were having problems with multiple definitions.
|
||||
*/
|
||||
#ifndef __gen_nsIPref_h__
|
||||
#ifndef have_PrefChangedFunc_typedef
|
||||
typedef int (*PrefChangedFunc) (const char *, void *);
|
||||
#endif /* __gen_nsIPref_h__ */
|
||||
#define have_PrefChangedFunc_typedef
|
||||
#endif
|
||||
|
||||
/*
|
||||
// <font color=blue>
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -3317,7 +3317,7 @@ nsBrowserWindow::ToggleBoolPrefAndRefresh(const char * aPrefName)
|
|||
PRBool value;
|
||||
prefs->GetBoolPref(aPrefName,&value);
|
||||
prefs->SetBoolPref(aPrefName,!value);
|
||||
prefs->SavePrefFile();
|
||||
prefs->SavePrefFile(nsnull);
|
||||
|
||||
ForceRefresh();
|
||||
}
|
||||
|
@ -3334,7 +3334,7 @@ nsBrowserWindow::SetBoolPref(const char * aPrefName, PRBool aValue)
|
|||
if (prefs && nsnull != aPrefName)
|
||||
{
|
||||
prefs->SetBoolPref(aPrefName, aValue);
|
||||
prefs->SavePrefFile();
|
||||
prefs->SavePrefFile(nsnull);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -3348,7 +3348,7 @@ nsBrowserWindow::SetStringPref(const char * aPrefName, const nsString& aValue)
|
|||
{
|
||||
char * prefStr = aValue.ToNewCString();
|
||||
prefs->SetCharPref(aPrefName, prefStr);
|
||||
prefs->SavePrefFile();
|
||||
prefs->SavePrefFile(nsnull);
|
||||
delete [] prefStr;
|
||||
}
|
||||
|
||||
|
@ -3693,7 +3693,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:
|
||||
|
|
Загрузка…
Ссылка в новой задаче