зеркало из https://github.com/mozilla/pjs.git
make nsIPref scriptable, and turn on XPIDL compiling on unix
(windows is on the way)
This commit is contained in:
Родитель
155264dfb0
Коммит
4c0c45e2d6
|
@ -22,9 +22,11 @@ VPATH = @srcdir@
|
|||
|
||||
include $(DEPTH)/config/autoconf.mk
|
||||
|
||||
XPIDLSRCS = nsIPref.idl
|
||||
|
||||
MODULE = pref
|
||||
|
||||
EXPORTS = prefapi.h prefldap.h nsIPref.h
|
||||
EXPORTS = prefapi.h prefldap.h
|
||||
EXPORTS := $(addprefix $(srcdir)/, $(EXPORTS))
|
||||
|
||||
include $(topsrcdir)/config/rules.mk
|
||||
|
|
|
@ -1,191 +0,0 @@
|
|||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
#ifndef nsIPref_h__
|
||||
#define nsIPref_h__
|
||||
|
||||
#include "jsapi.h"
|
||||
#include "nsISupports.h"
|
||||
|
||||
class nsFileSpec;
|
||||
|
||||
/* Temporarily conditionally compile PrefChangedFunc typedef.
|
||||
** During migration from old libpref to nsIPref we need it in
|
||||
** both header files. Eventually prefapi.h will become a private
|
||||
** file. The two types need to be in sync for now. Certain
|
||||
** compilers were having problems with multiple definitions.
|
||||
*/
|
||||
#ifndef PREFAPI_H
|
||||
typedef int (*PrefChangedFunc) (const char *, void *);
|
||||
#endif /* PREFAPI_H */
|
||||
|
||||
#define NS_IPREF_IID \
|
||||
{ /* {a22ad7b0-ca86-11d1-a9a4-00805f8a7ac4} */ \
|
||||
0xa22ad7b0, \
|
||||
0xca86, \
|
||||
0x11d1, \
|
||||
{ 0xa9, 0xa4, 0x00, 0x80, 0x5f, 0x8a, 0x7a, 0xc4 } \
|
||||
}
|
||||
|
||||
#define NS_PREF_CID \
|
||||
{ /* {dc26e0e0-ca94-11d1-a9a4-00805f8a7ac4} */ \
|
||||
0xdc26e0e0, \
|
||||
0xca94, \
|
||||
0x11d1, \
|
||||
{ 0xa9, 0xa4, 0x00, 0x80, 0x5f, 0x8a, 0x7a, 0xc4 } \
|
||||
}
|
||||
|
||||
/*
|
||||
* Return values
|
||||
*/
|
||||
|
||||
#define NS_PREF_VALUE_CHANGED 1
|
||||
|
||||
class nsIPref: public nsISupports {
|
||||
public:
|
||||
|
||||
NS_DEFINE_STATIC_IID_ACCESSOR(NS_IPREF_IID)
|
||||
|
||||
#ifdef PREF_SUPPORT_OLD_PATH_STRINGS
|
||||
nsresult Shutdown() { return ShutDown(); }
|
||||
nsresult Startup(void*) { return StartUp(); }
|
||||
NS_IMETHOD ReadUserJSFile(const char *filename) = 0; // deprecated
|
||||
NS_IMETHOD ReadLIJSFile(const char *filename) = 0; // deprecated
|
||||
NS_IMETHOD EvaluateConfigScript(const char * js_buffer, size_t length,
|
||||
const char* filename,
|
||||
PRBool bGlobalContext,
|
||||
PRBool bCallbacks) = 0; // deprecated
|
||||
NS_IMETHOD SavePrefFileAs(const char *filename) = 0;
|
||||
NS_IMETHOD SaveLIPrefFile(const char *filename) = 0;
|
||||
|
||||
// Path prefs
|
||||
NS_IMETHOD CopyPathPref(const char *pref, char ** return_buf) = 0;
|
||||
NS_IMETHOD SetPathPref(const char *pref_name,
|
||||
const char *path, PRBool set_default) = 0;
|
||||
#endif
|
||||
// Initialize/shut down
|
||||
NS_IMETHOD StartUp() = 0;
|
||||
NS_IMETHOD StartUpWith(const nsFileSpec& inSpec) = 0;
|
||||
NS_IMETHOD ShutDown() = 0;
|
||||
|
||||
// Config file input
|
||||
NS_IMETHOD ReadUserJSFile(const nsFileSpec& inSpec) = 0;
|
||||
NS_IMETHOD ReadLIJSFile(const nsFileSpec& inSpec) = 0;
|
||||
|
||||
NS_IMETHOD EvaluateConfigScript(const char * js_buffer, size_t length,
|
||||
PRBool bGlobalContext,
|
||||
PRBool bCallbacks) = 0;
|
||||
NS_IMETHOD EvaluateConfigScriptFile(const char * js_buffer, size_t length,
|
||||
const nsFileSpec& inSpec,
|
||||
PRBool bGlobalContext,
|
||||
PRBool bCallbacks) = 0;
|
||||
|
||||
NS_IMETHOD SavePrefFileAs(const nsFileSpec& inSpec) = 0;
|
||||
NS_IMETHOD SaveLIPrefFile(const nsFileSpec& inSpec) = 0;
|
||||
|
||||
// JS stuff
|
||||
NS_IMETHOD GetConfigContext(JSContext **js_context) = 0;
|
||||
NS_IMETHOD GetGlobalConfigObject(JSObject **js_object) = 0;
|
||||
NS_IMETHOD GetPrefConfigObject(JSObject **js_object) = 0;
|
||||
|
||||
// Getters
|
||||
NS_IMETHOD GetCharPref(const char *pref,
|
||||
char * return_buf, int * buf_length) = 0;
|
||||
NS_IMETHOD GetIntPref(const char *pref, PRInt32 * return_int) = 0;
|
||||
NS_IMETHOD GetBoolPref(const char *pref, PRBool *return_val) = 0;
|
||||
NS_IMETHOD GetBinaryPref(const char *pref,
|
||||
void * return_val, int * buf_length) = 0;
|
||||
NS_IMETHOD GetColorPref(const char *pref_name,
|
||||
uint8 *red, uint8 *green, uint8 *blue) = 0;
|
||||
NS_IMETHOD GetColorPrefDWord(const char *pref_name, PRUint32 *colorref) = 0;
|
||||
NS_IMETHOD GetRectPref(const char *pref_name,
|
||||
PRInt16 *left, PRInt16 *top,
|
||||
PRInt16 *right, PRInt16 *bottom) = 0;
|
||||
|
||||
// Setters
|
||||
NS_IMETHOD SetCharPref(const char *pref,const char* value) = 0;
|
||||
NS_IMETHOD SetIntPref(const char *pref,PRInt32 value) = 0;
|
||||
NS_IMETHOD SetBoolPref(const char *pref,PRBool value) = 0;
|
||||
NS_IMETHOD SetBinaryPref(const char *pref,void * value, long size) = 0;
|
||||
NS_IMETHOD SetColorPref(const char *pref_name,
|
||||
uint8 red, uint8 green, uint8 blue) = 0;
|
||||
NS_IMETHOD SetColorPrefDWord(const char *pref_name, PRUint32 colorref) = 0;
|
||||
NS_IMETHOD SetRectPref(const char *pref_name,
|
||||
PRInt16 left, PRInt16 top, PRInt16 right, PRInt16 bottom) = 0;
|
||||
NS_IMETHOD ClearUserPref(const char *pref_name) = 0;
|
||||
|
||||
// Get Defaults
|
||||
NS_IMETHOD GetDefaultCharPref(const char *pref,
|
||||
char * return_buf, int * buf_length) = 0;
|
||||
NS_IMETHOD GetDefaultIntPref(const char *pref, PRInt32 * return_int) = 0;
|
||||
NS_IMETHOD GetDefaultBoolPref(const char *pref, PRBool *return_val) = 0;
|
||||
NS_IMETHOD GetDefaultBinaryPref(const char *pref,
|
||||
void * return_val, int * buf_length) = 0;
|
||||
NS_IMETHOD GetDefaultColorPref(const char *pref_name,
|
||||
uint8 *red, uint8 *green, uint8 *blue) = 0;
|
||||
NS_IMETHOD GetDefaultColorPrefDWord(const char *pref_name,
|
||||
PRUint32 *colorref) = 0;
|
||||
NS_IMETHOD GetDefaultRectPref(const char *pref_name,
|
||||
PRInt16 *left, PRInt16 *top,
|
||||
PRInt16 *right, PRInt16 *bottom) = 0;
|
||||
|
||||
// Set defaults
|
||||
NS_IMETHOD SetDefaultCharPref(const char *pref,const char* value) = 0;
|
||||
NS_IMETHOD SetDefaultIntPref(const char *pref,PRInt32 value) = 0;
|
||||
NS_IMETHOD SetDefaultBoolPref(const char *pref,PRBool value) = 0;
|
||||
NS_IMETHOD SetDefaultBinaryPref(const char *pref,
|
||||
void * value, long size) = 0;
|
||||
NS_IMETHOD SetDefaultColorPref(const char *pref_name,
|
||||
uint8 red, uint8 green, uint8 blue) = 0;
|
||||
NS_IMETHOD SetDefaultRectPref(const char *pref_name,
|
||||
PRInt16 left, PRInt16 top,
|
||||
PRInt16 right, PRInt16 bottom) = 0;
|
||||
|
||||
// Copy prefs
|
||||
NS_IMETHOD CopyCharPref(const char *pref, char ** return_buf) = 0;
|
||||
NS_IMETHOD CopyBinaryPref(const char *pref_name,
|
||||
void ** return_value, int *size) = 0;
|
||||
|
||||
NS_IMETHOD CopyDefaultCharPref( const char
|
||||
*pref_name, char ** return_buffer ) = 0;
|
||||
NS_IMETHOD CopyDefaultBinaryPref(const char *pref,
|
||||
void ** return_val, int * size) = 0;
|
||||
|
||||
NS_IMETHOD GetFilePref(const char* pref, nsFileSpec* value) = 0;
|
||||
NS_IMETHOD SetFilePref(
|
||||
const char* pref, const nsFileSpec* value, PRBool setDefault) = 0;
|
||||
|
||||
// Pref info
|
||||
NS_IMETHOD PrefIsLocked(const char *pref_name, PRBool *res) = 0;
|
||||
|
||||
// Save pref files
|
||||
NS_IMETHOD SavePrefFile() = 0;
|
||||
|
||||
// Callbacks
|
||||
NS_IMETHOD RegisterCallback( const char* domain,
|
||||
PrefChangedFunc callback,
|
||||
void* instance_data ) = 0;
|
||||
NS_IMETHOD UnregisterCallback( const char* domain,
|
||||
PrefChangedFunc callback,
|
||||
void* instance_data ) = 0;
|
||||
|
||||
NS_IMETHOD CopyPrefsTree(const char *srcRoot, const char *destRoot) = 0;
|
||||
NS_IMETHOD DeleteBranch(const char *branchName) = 0;
|
||||
};
|
||||
|
||||
#endif /* nsIPref_h__ */
|
|
@ -0,0 +1,146 @@
|
|||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
#include "nsISupports.idl"
|
||||
|
||||
%{C++
|
||||
#include "jsapi.h"
|
||||
|
||||
|
||||
typedef int (*PrefChangedFunc) (const char *, void *);
|
||||
|
||||
#define NS_PREF_CID \
|
||||
{ /* {dc26e0e0-ca94-11d1-a9a4-00805f8a7ac4} */ \
|
||||
0xdc26e0e0, \
|
||||
0xca94, \
|
||||
0x11d1, \
|
||||
{ 0xa9, 0xa4, 0x00, 0x80, 0x5f, 0x8a, 0x7a, 0xc4 } \
|
||||
}
|
||||
|
||||
class nsFileSpec;
|
||||
|
||||
#define NS_PREF_VALUE_CHANGED 1
|
||||
%}
|
||||
[ptr] native JSContext(JSContext);
|
||||
[ptr] native JSObject(JSObject);
|
||||
native PrefChangedFunc(PrefChangedFunc);
|
||||
[ptr] native nsFileSpec(nsFileSpec);
|
||||
|
||||
[object, uuid(a22ad7b0-ca86-11d1-a9a4-00805f8a7ac4)]
|
||||
interface nsIPref : nsISupports {
|
||||
|
||||
void StartUp();
|
||||
void StartUpWith(in nsFileSpec spec);
|
||||
void ShutDown();
|
||||
|
||||
void ReadUserJSFile(in nsFileSpec filename);
|
||||
void ReadLIJSFile(in nsFileSpec filename);
|
||||
|
||||
void EvaluateConfigScript(in string js_buffer, in PRUint32 length,
|
||||
in boolean bGlobalContext,
|
||||
in boolean bCallbacks);
|
||||
|
||||
void EvaluateConfigScriptFile(in string js_buffer, in PRUint32 length,
|
||||
in nsFileSpec filename,
|
||||
in boolean bGlobalContext,
|
||||
in boolean bCallbacks);
|
||||
|
||||
void SavePrefFileAs(in nsFileSpec filename);
|
||||
void SaveLIPrefFile(in nsFileSpec filename);
|
||||
|
||||
/* JS Stuff - don't allow this to be scriptable */
|
||||
[noscript] readonly attribute JSContext configContext;
|
||||
[noscript] readonly attribute JSObject globalConfigObject;
|
||||
[noscript] readonly attribute JSObject prefConfigObject;
|
||||
|
||||
/* Getters */
|
||||
long GetIntPref(in string pref);
|
||||
boolean GetBoolPref(in string pref);
|
||||
void GetBinaryPref(in string pref, in voidStar buf, inout long buf_length);
|
||||
void GetColorPref(in string pref, out octet red, out octet green, out octet blue);
|
||||
|
||||
unsigned long GetColorPrefDWord(in string pref);
|
||||
void GetRectPref(in string pref,
|
||||
out short left, out short top,
|
||||
out short right, out short bottom);
|
||||
|
||||
/* set preferences */
|
||||
void SetCharPref(in string pref, in string value);
|
||||
void SetIntPref(in string pref, in long value);
|
||||
void SetBoolPref(in string pref, in boolean value);
|
||||
void SetBinaryPref(in string pref, in voidStar value, in unsigned long size);
|
||||
void SetColorPref(in string pref,in octet red, in octet green,in octet blue);
|
||||
void SetColorPrefDWord(in string pref, in unsigned long colorref);
|
||||
|
||||
void SetRectPref(in string pref,
|
||||
in short left, in short top,
|
||||
in short right, in short bottom);
|
||||
void ClearUserPref(in string pref_name);
|
||||
|
||||
/* get defaults */
|
||||
long GetDefaultIntPref(in string pref);
|
||||
boolean GetDefaultBoolPref(in string pref);
|
||||
void GetDefaultBinaryPref(in string pref, in voidStar value,
|
||||
out long length);
|
||||
void GetDefaultColorPref(in string pref,
|
||||
out octet red, out octet green, out octet blue);
|
||||
|
||||
unsigned long GetDefaultColorPrefDWord(in string pref);
|
||||
void GetDefaultRectPref(in string pref,
|
||||
out short left, out short top,
|
||||
out short right, out short bottom);
|
||||
|
||||
/* set defaults */
|
||||
void SetDefaultCharPref(in string pref, in string value);
|
||||
void SetDefaultIntPref(in string pref, in long value);
|
||||
void SetDefaultBoolPref(in string pref, in boolean value);
|
||||
void SetDefaultBinaryPref(in string pref, in voidStar value, in unsigned long size);
|
||||
void SetDefaultColorPref(in string pref,in octet red, in octet green,in octet blue);
|
||||
|
||||
void SetDefaultRectPref(in string pref,
|
||||
in short left, in short top,
|
||||
in short right, in short bottom);
|
||||
|
||||
/* copy versions of getters */
|
||||
string CopyCharPref(in string pref);
|
||||
voidStar CopyBinaryPref(in string pref, out long size);
|
||||
|
||||
string CopyDefaultCharPref(in string pref);
|
||||
voidStar CopyDefaultBinaryPref(in string pref, out long size);
|
||||
|
||||
nsFileSpec GetFilePref(in string pref);
|
||||
void SetFilePref(in string pref, in nsFileSpec value, in boolean setDefault);
|
||||
|
||||
/* pref attributes */
|
||||
boolean PrefIsLocked(in string pref);
|
||||
|
||||
void SavePrefFile();
|
||||
|
||||
void RegisterCallback(in string domain,
|
||||
in PrefChangedFunc callback,
|
||||
in voidStar closure);
|
||||
void UnregisterCallback(in string domain,
|
||||
in PrefChangedFunc callback,
|
||||
in voidStar closure);
|
||||
|
||||
void CopyPrefsTree(in string srcRoot, in string destRoot);
|
||||
void DeleteBranch(in string branchName);
|
||||
|
||||
};
|
||||
|
||||
|
|
@ -42,12 +42,6 @@ EXTRA_LIBS = $(DIST)/lib/js$(MOZ_BITS)$(VERSION_NUMBER).lib \
|
|||
$(NULL)
|
||||
endif
|
||||
|
||||
ifdef USE_XPIDL
|
||||
#temporary hack - eventually nsIPref should live in public
|
||||
#but put it here for now so we don't auto-generate the header and loose it
|
||||
IDLSRCS = nsIPref.idl
|
||||
endif
|
||||
|
||||
CSRCS += prefapi.c
|
||||
|
||||
CPPSRCS += nsPref.cpp
|
||||
|
|
|
@ -86,23 +86,23 @@ public:
|
|||
#endif
|
||||
// Initialize/shutdown
|
||||
NS_IMETHOD StartUp();
|
||||
NS_IMETHOD StartUpWith(const nsFileSpec& inSpec);
|
||||
NS_IMETHOD StartUpWith(nsFileSpec* inSpec);
|
||||
NS_IMETHOD ShutDown();
|
||||
|
||||
// Config file input
|
||||
NS_IMETHOD ReadUserJSFile(const nsFileSpec& inSpec);
|
||||
NS_IMETHOD ReadLIJSFile(const nsFileSpec& inSpec);
|
||||
NS_IMETHOD ReadUserJSFile(nsFileSpec* inSpec);
|
||||
NS_IMETHOD ReadLIJSFile(nsFileSpec* inSpec);
|
||||
|
||||
NS_IMETHOD EvaluateConfigScript(const char * js_buffer, size_t length,
|
||||
PRBool bGlobalContext,
|
||||
PRBool bCallbacks);
|
||||
NS_IMETHOD EvaluateConfigScriptFile(const char * js_buffer, size_t length,
|
||||
const nsFileSpec& inSpec,
|
||||
nsFileSpec* inSpec,
|
||||
PRBool bGlobalContext,
|
||||
PRBool bCallbacks);
|
||||
|
||||
NS_IMETHOD SavePrefFileAs(const nsFileSpec& inSpec);
|
||||
NS_IMETHOD SaveLIPrefFile(const nsFileSpec& inSpec);
|
||||
NS_IMETHOD SavePrefFileAs(nsFileSpec* inSpec);
|
||||
NS_IMETHOD SaveLIPrefFile(nsFileSpec* inSpec);
|
||||
|
||||
// JS stuff
|
||||
NS_IMETHOD GetConfigContext(JSContext **js_context);
|
||||
|
@ -110,12 +110,10 @@ public:
|
|||
NS_IMETHOD GetPrefConfigObject(JSObject **js_object);
|
||||
|
||||
// Getters
|
||||
NS_IMETHOD GetCharPref(const char *pref,
|
||||
char * return_buf, int * buf_length);
|
||||
NS_IMETHOD GetIntPref(const char *pref, PRInt32 * return_int);
|
||||
NS_IMETHOD GetBoolPref(const char *pref, PRBool * return_val);
|
||||
NS_IMETHOD GetBinaryPref(const char *pref,
|
||||
void * return_val, int * buf_length);
|
||||
void * return_val, PRInt32 * buf_length);
|
||||
NS_IMETHOD GetColorPref(const char *pref,
|
||||
uint8 *red, uint8 *green, uint8 *blue);
|
||||
NS_IMETHOD GetColorPrefDWord(const char *pref, PRUint32 *colorref);
|
||||
|
@ -127,7 +125,7 @@ public:
|
|||
NS_IMETHOD SetCharPref(const char *pref,const char* value);
|
||||
NS_IMETHOD SetIntPref(const char *pref,PRInt32 value);
|
||||
NS_IMETHOD SetBoolPref(const char *pref,PRBool value);
|
||||
NS_IMETHOD SetBinaryPref(const char *pref,void * value, long size);
|
||||
NS_IMETHOD SetBinaryPref(const char *pref,void * value, PRUint32 size);
|
||||
NS_IMETHOD SetColorPref(const char *pref,
|
||||
uint8 red, uint8 green, uint8 blue);
|
||||
NS_IMETHOD SetColorPrefDWord(const char *pref, PRUint32 colorref);
|
||||
|
@ -137,14 +135,12 @@ public:
|
|||
NS_IMETHOD ClearUserPref(const char *pref);
|
||||
|
||||
// Get Defaults
|
||||
NS_IMETHOD GetDefaultCharPref(const char *pref,
|
||||
char * return_buf, int * buf_length);
|
||||
NS_IMETHOD GetDefaultIntPref(const char *pref, PRInt32 * return_int);
|
||||
NS_IMETHOD GetDefaultBoolPref(const char *pref, PRBool * return_val);
|
||||
NS_IMETHOD GetDefaultBinaryPref(const char *pref,
|
||||
void * return_val, int * buf_length);
|
||||
NS_IMETHOD GetDefaultColorPref(const char *pref,
|
||||
uint8 *red, uint8 *green, uint8 *blue);
|
||||
PRUint8 *red, PRUint8 *green, PRUint8 *blue);
|
||||
NS_IMETHOD GetDefaultColorPrefDWord(const char *pref,
|
||||
PRUint32 *colorref);
|
||||
NS_IMETHOD GetDefaultRectPref(const char *pref,
|
||||
|
@ -156,9 +152,9 @@ public:
|
|||
NS_IMETHOD SetDefaultIntPref(const char *pref,PRInt32 value);
|
||||
NS_IMETHOD SetDefaultBoolPref(const char *pref,PRBool value);
|
||||
NS_IMETHOD SetDefaultBinaryPref(const char *pref,
|
||||
void * value, long size);
|
||||
void * value, PRUint32 size);
|
||||
NS_IMETHOD SetDefaultColorPref(const char *pref,
|
||||
uint8 red, uint8 green, uint8 blue);
|
||||
PRUint8 red, PRUint8 green, PRUint8 blue);
|
||||
NS_IMETHOD SetDefaultRectPref(const char *pref,
|
||||
PRInt16 left, PRInt16 top,
|
||||
PRInt16 right, PRInt16 bottom);
|
||||
|
@ -166,15 +162,15 @@ public:
|
|||
// Copy prefs
|
||||
NS_IMETHOD CopyCharPref(const char *pref, char ** return_buf);
|
||||
NS_IMETHOD CopyBinaryPref(const char *pref,
|
||||
void ** return_value, int *size);
|
||||
int *size, void ** return_value);
|
||||
|
||||
NS_IMETHOD CopyDefaultCharPref( const char
|
||||
*pref, char ** return_buffer );
|
||||
NS_IMETHOD CopyDefaultBinaryPref(const char *pref,
|
||||
void ** return_val, int * size);
|
||||
int * size, void ** return_val);
|
||||
|
||||
NS_IMETHOD GetFilePref(const char* pref, nsFileSpec* value);
|
||||
NS_IMETHOD SetFilePref(const char* pref, const nsFileSpec* value, PRBool setDefault);
|
||||
NS_IMETHOD GetFilePref(const char* pref, nsFileSpec** value);
|
||||
NS_IMETHOD SetFilePref(const char* pref, nsFileSpec* value, PRBool setDefault);
|
||||
|
||||
// Pref info
|
||||
NS_IMETHOD PrefIsLocked(const char *pref, PRBool *res);
|
||||
|
@ -266,7 +262,7 @@ void nsPref::useDefaultPrefFile()
|
|||
nsServiceManager::ReleaseService(kFileLocatorCID, locator);
|
||||
}
|
||||
if (prefsFile.Exists()) {
|
||||
rv = StartUpWith(prefsFile);
|
||||
rv = StartUpWith(&prefsFile);
|
||||
}
|
||||
else {
|
||||
// no prefs file. make a stub of one
|
||||
|
@ -277,7 +273,7 @@ void nsPref::useDefaultPrefFile()
|
|||
}
|
||||
|
||||
if (prefsFile.Exists()) {
|
||||
rv = StartUpWith(prefsFile);
|
||||
rv = StartUpWith(&prefsFile);
|
||||
|
||||
// sspitzer: eventually this code should be moved into the profile manager
|
||||
// that code should be setting up the prefs based on the what the user enters.
|
||||
|
@ -374,10 +370,10 @@ NS_IMETHODIMP nsPref::StartUp()
|
|||
}
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
NS_IMETHODIMP nsPref::StartUpWith(const nsFileSpec& inFile)
|
||||
NS_IMETHODIMP nsPref::StartUpWith(nsFileSpec* inFile)
|
||||
//----------------------------------------------------------------------------------------
|
||||
{
|
||||
if (mFileSpec == inFile)
|
||||
if (mFileSpec == *inFile)
|
||||
return NS_OK;
|
||||
|
||||
PRBool ok = PR_TRUE;
|
||||
|
@ -389,7 +385,7 @@ NS_IMETHODIMP nsPref::StartUpWith(const nsFileSpec& inFile)
|
|||
if (!gHashTable)
|
||||
return PR_FALSE;
|
||||
|
||||
mFileSpec = inFile;
|
||||
mFileSpec = *inFile;
|
||||
|
||||
if (!gMochaTaskState)
|
||||
gMochaTaskState = JS_Init((PRUint32) 0xffffffffL);
|
||||
|
@ -538,18 +534,18 @@ NS_IMETHODIMP nsPref::SetPathPref(const char *pref_name, const char *path, PRBoo
|
|||
#endif /* PREF_SUPPORT_OLD_PATH_STRINGS */
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
NS_IMETHODIMP nsPref::ReadUserJSFile(const nsFileSpec& fileSpec)
|
||||
NS_IMETHODIMP nsPref::ReadUserJSFile(nsFileSpec* fileSpec)
|
||||
//----------------------------------------------------------------------------------------
|
||||
{
|
||||
return pref_OpenFileSpec(fileSpec, PR_FALSE, PR_FALSE, PR_TRUE, PR_FALSE);
|
||||
return pref_OpenFileSpec(*fileSpec, PR_FALSE, PR_FALSE, PR_TRUE, PR_FALSE);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
NS_IMETHODIMP nsPref::ReadLIJSFile(const nsFileSpec& fileSpec)
|
||||
NS_IMETHODIMP nsPref::ReadLIJSFile(nsFileSpec* fileSpec)
|
||||
//----------------------------------------------------------------------------------------
|
||||
{
|
||||
mLIFileSpec = fileSpec;
|
||||
return pref_OpenFileSpec(fileSpec, PR_FALSE, PR_FALSE, PR_FALSE, PR_FALSE);
|
||||
mLIFileSpec = *fileSpec;
|
||||
return pref_OpenFileSpec(*fileSpec, PR_FALSE, PR_FALSE, PR_FALSE, PR_FALSE);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
|
@ -570,34 +566,34 @@ NS_IMETHODIMP nsPref::EvaluateConfigScript(const char * js_buffer,
|
|||
//----------------------------------------------------------------------------------------
|
||||
NS_IMETHODIMP nsPref::EvaluateConfigScriptFile(const char * js_buffer,
|
||||
size_t length,
|
||||
const nsFileSpec& fileSpec,
|
||||
nsFileSpec* fileSpec,
|
||||
PRBool bGlobalContext,
|
||||
PRBool bCallbacks)
|
||||
//----------------------------------------------------------------------------------------
|
||||
{
|
||||
return _convertRes(PREF_EvaluateConfigScript(js_buffer,
|
||||
length,
|
||||
fileSpec.GetCString(), // bad, but not used for parsing.
|
||||
fileSpec->GetCString(), // bad, but not used for parsing.
|
||||
bGlobalContext,
|
||||
bCallbacks,
|
||||
PR_TRUE));
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
NS_IMETHODIMP nsPref::SavePrefFileAs(const nsFileSpec& fileSpec)
|
||||
NS_IMETHODIMP nsPref::SavePrefFileAs(nsFileSpec* fileSpec)
|
||||
//----------------------------------------------------------------------------------------
|
||||
{
|
||||
return _convertRes(PREF_SavePrefFileSpecWith(fileSpec, (PLHashEnumerator)pref_savePref));
|
||||
return _convertRes(PREF_SavePrefFileSpecWith(*fileSpec, (PLHashEnumerator)pref_savePref));
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
NS_IMETHODIMP nsPref::SaveLIPrefFile(const nsFileSpec& fileSpec)
|
||||
NS_IMETHODIMP nsPref::SaveLIPrefFile(nsFileSpec* fileSpec)
|
||||
//----------------------------------------------------------------------------------------
|
||||
{
|
||||
if (!gHashTable)
|
||||
return PREF_NOT_INITIALIZED;
|
||||
PREF_SetSpecialPrefsLocal();
|
||||
return _convertRes(PREF_SavePrefFileSpecWith(fileSpec, (PLHashEnumerator)pref_saveLIPref));
|
||||
return _convertRes(PREF_SavePrefFileSpecWith(*fileSpec, (PLHashEnumerator)pref_saveLIPref));
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
|
@ -636,12 +632,6 @@ NS_IMETHODIMP nsPref::GetPrefConfigObject(JSObject **js_object)
|
|||
* Getters
|
||||
*/
|
||||
|
||||
NS_IMETHODIMP nsPref::GetCharPref(const char *pref,
|
||||
char * return_buf, int * buf_length)
|
||||
{
|
||||
return _convertRes(PREF_GetCharPref(pref, return_buf, buf_length));
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsPref::GetIntPref(const char *pref, PRInt32 * return_int)
|
||||
{
|
||||
return _convertRes(PREF_GetIntPref(pref, return_int));
|
||||
|
@ -659,7 +649,7 @@ NS_IMETHODIMP nsPref::GetBinaryPref(const char *pref,
|
|||
}
|
||||
|
||||
NS_IMETHODIMP nsPref::GetColorPref(const char *pref,
|
||||
uint8 *red, uint8 *green, uint8 *blue)
|
||||
PRUint8 *red, PRUint8 *green, PRUint8 *blue)
|
||||
{
|
||||
return _convertRes(PREF_GetColorPref(pref, red, green, blue));
|
||||
}
|
||||
|
@ -696,13 +686,13 @@ NS_IMETHODIMP nsPref::SetBoolPref(const char *pref,PRBool value)
|
|||
return _convertRes(PREF_SetBoolPref(pref, value));
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsPref::SetBinaryPref(const char *pref,void * value, long size)
|
||||
NS_IMETHODIMP nsPref::SetBinaryPref(const char *pref,void * value, PRUint32 size)
|
||||
{
|
||||
return _convertRes(PREF_SetBinaryPref(pref, value, size));
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsPref::SetColorPref(const char *pref,
|
||||
uint8 red, uint8 green, uint8 blue)
|
||||
PRUint8 red, PRUint8 green, PRUint8 blue)
|
||||
{
|
||||
return _convertRes(PREF_SetColorPref(pref, red, green, blue));
|
||||
}
|
||||
|
@ -724,13 +714,6 @@ NS_IMETHODIMP nsPref::SetRectPref(const char *pref,
|
|||
* Get Defaults
|
||||
*/
|
||||
|
||||
NS_IMETHODIMP nsPref::GetDefaultCharPref(const char *pref,
|
||||
char * return_buf,
|
||||
int * buf_length)
|
||||
{
|
||||
return _convertRes(PREF_GetDefaultCharPref(pref, return_buf, buf_length));
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsPref::GetDefaultIntPref(const char *pref,
|
||||
PRInt32 * return_int)
|
||||
{
|
||||
|
@ -751,8 +734,8 @@ NS_IMETHODIMP nsPref::GetDefaultBinaryPref(const char *pref,
|
|||
}
|
||||
|
||||
NS_IMETHODIMP nsPref::GetDefaultColorPref(const char *pref,
|
||||
uint8 *red, uint8 *green,
|
||||
uint8 *blue)
|
||||
PRUint8 *red, PRUint8 *green,
|
||||
PRUint8 *blue)
|
||||
{
|
||||
return _convertRes(PREF_GetDefaultColorPref(pref, red, green, blue));
|
||||
}
|
||||
|
@ -791,13 +774,13 @@ NS_IMETHODIMP nsPref::SetDefaultBoolPref(const char *pref, PRBool value)
|
|||
}
|
||||
|
||||
NS_IMETHODIMP nsPref::SetDefaultBinaryPref(const char *pref,
|
||||
void * value, long size)
|
||||
void * value, PRUint32 size)
|
||||
{
|
||||
return _convertRes(PREF_SetDefaultBinaryPref(pref, value, size));
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsPref::SetDefaultColorPref(const char *pref,
|
||||
uint8 red, uint8 green, uint8 blue)
|
||||
PRUint8 red, PRUint8 green, PRUint8 blue)
|
||||
{
|
||||
return _convertRes(PREF_SetDefaultColorPref(pref, red, green, blue));
|
||||
}
|
||||
|
@ -824,7 +807,7 @@ NS_IMETHODIMP nsPref::CopyCharPref(const char *pref, char ** return_buf)
|
|||
}
|
||||
|
||||
NS_IMETHODIMP nsPref::CopyBinaryPref(const char *pref,
|
||||
void ** return_value, int *size)
|
||||
int *size, void ** return_value)
|
||||
{
|
||||
return _convertRes(PREF_CopyBinaryPref(pref, return_value, size));
|
||||
}
|
||||
|
@ -836,7 +819,7 @@ NS_IMETHODIMP nsPref::CopyDefaultCharPref( const char *pref,
|
|||
}
|
||||
|
||||
NS_IMETHODIMP nsPref::CopyDefaultBinaryPref(const char *pref,
|
||||
void ** return_val, int * size)
|
||||
int * size, void ** return_val)
|
||||
{
|
||||
return _convertRes(PREF_CopyDefaultBinaryPref(pref, return_val, size));
|
||||
}
|
||||
|
@ -863,7 +846,7 @@ NS_IMETHODIMP nsPref::SetPathPref(const char *pref,
|
|||
#endif
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
NS_IMETHODIMP nsPref::GetFilePref(const char *pref_name, nsFileSpec* value)
|
||||
NS_IMETHODIMP nsPref::GetFilePref(const char *pref_name, nsFileSpec** value)
|
||||
//----------------------------------------------------------------------------------------
|
||||
{
|
||||
if (!value)
|
||||
|
@ -877,13 +860,15 @@ NS_IMETHODIMP nsPref::GetFilePref(const char *pref_name, nsFileSpec* value)
|
|||
nsPersistentFileDescriptor descriptor;
|
||||
stream >> descriptor;
|
||||
PR_Free(encodedString); // Allocated by PREF_CopyCharPref
|
||||
*value = descriptor;
|
||||
*value = new nsFileSpec(descriptor);
|
||||
if (!value)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
NS_IMETHODIMP nsPref::SetFilePref(const char *pref_name,
|
||||
const nsFileSpec* value, PRBool set_default)
|
||||
nsFileSpec* value, PRBool set_default)
|
||||
//----------------------------------------------------------------------------------------
|
||||
{
|
||||
if (!value)
|
||||
|
@ -1073,7 +1058,10 @@ extern "C" NS_EXPORT nsresult NSRegisterSelf(nsISupports* aServMgr, const char *
|
|||
(nsISupports**)&compMgr);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
rv = compMgr->RegisterComponent(kPrefCID, NULL, NULL, path,
|
||||
rv = compMgr->RegisterComponent(kPrefCID,
|
||||
"Preferences Service",
|
||||
"component://netscape/preferences",
|
||||
path,
|
||||
PR_TRUE, PR_TRUE);
|
||||
|
||||
(void)servMgr->ReleaseService(kComponentManagerCID, compMgr);
|
||||
|
|
|
@ -386,12 +386,15 @@ nsresult nsPrefsCore::InitializeOneWidget(
|
|||
// Check the subtree first, then the real tree.
|
||||
// If the preference value is not set at all, let the HTML
|
||||
// determine the setting.
|
||||
nsFileSpec specVal;
|
||||
if (NS_SUCCEEDED(mPrefs->GetFilePref(tempPrefName, &specVal))
|
||||
|| NS_SUCCEEDED(mPrefs->GetFilePref(inPrefName, &specVal)))
|
||||
{
|
||||
nsString newValue = specVal.GetCString();
|
||||
nsFileSpec *specVal;
|
||||
nsresult rv = mPrefs->GetFilePref(tempPrefName, &specVal);
|
||||
if (NS_FAILED(rv))
|
||||
rv = mPrefs->GetFilePref(inPrefName, &specVal);
|
||||
|
||||
if NS_SUCCEEDED(rv) {
|
||||
nsString newValue = specVal->GetCString();
|
||||
inElement->SetValue(newValue);
|
||||
delete specVal;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче