Made prefapi.h private and removed all #includes of it outside of libpref. r=norris

This commit is contained in:
mstoltz%netscape.com 2000-04-15 03:43:09 +00:00
Родитель b5188c5d2d
Коммит a4b2043dcb
23 изменённых файлов: 554 добавлений и 967 удалений

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

@ -58,13 +58,13 @@
#include "nsIServiceManager.h"
#include "nsIPref.h"
#include "prefapi.h"
#include "nsISessionHistory.h"
#include "nsXULAtoms.h"
#include "nsIDOMXULDocument.h"
#include "nsIDOMXULCommandDispatcher.h"
#include "nsIObserverService.h"
#include "prlog.h"
//we will use key binding by default now. this wil lbreak viewer for now
#define NON_KEYBINDING 0

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

@ -29,7 +29,6 @@
#include "nsIServiceManager.h"
#include "nsIPref.h"
#include "prefapi.h"
static NS_DEFINE_CID(kPrefCID, NS_PREF_CID);
@ -86,7 +85,7 @@ static int NavAlgorithmPrefChangedCallback(const char * name, void * closure)
if (NS_SUCCEEDED(rv) && prefs) {
prefs->GetBoolPref(name, &gNavAlgorithmPref);
}
return PREF_NOERROR;
return 0;
}

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

@ -29,7 +29,6 @@
#include "nsIServiceManager.h"
#include "nsIPref.h"
#include "prefapi.h"
static NS_DEFINE_CID(kPrefCID, NS_PREF_CID);
@ -86,7 +85,7 @@ static int NavAlgorithmPrefChangedCallback(const char * name, void * closure)
if (NS_SUCCEEDED(rv) && prefs) {
prefs->GetBoolPref(name, &gNavAlgorithmPref);
}
return PREF_NOERROR;
return 0;
}

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

@ -37,8 +37,8 @@
#include "nsVoidArray.h"
#include "nsIPref.h"
#include "prefapi.h"
#include "nsTextFormatter.h"
#include "xp_core.h"
extern "C" {
#include "prmon.h"
@ -942,7 +942,7 @@ cookie_BehaviorPrefChanged(const char * newpref, void * data) {
n = COOKIE_Accept;
}
cookie_SetBehaviorPref((COOKIE_BehaviorEnum)n);
return PREF_NOERROR;
return 0;
}
MODULE_PRIVATE int PR_CALLBACK
@ -954,7 +954,7 @@ cookie_WarningPrefChanged(const char * newpref, void * data) {
x = PR_FALSE;
}
cookie_SetWarningPref(x);
return PREF_NOERROR;
return 0;
}
/* cookie utility functions */
@ -988,7 +988,7 @@ image_BehaviorPrefChanged(const char * newpref, void * data) {
} else {
image_SetBehaviorPref((COOKIE_BehaviorEnum)n);
}
return PREF_NOERROR;
return 0;
}
MODULE_PRIVATE int PR_CALLBACK
@ -1000,7 +1000,7 @@ image_WarningPrefChanged(const char * newpref, void * data) {
x = PR_FALSE;
}
image_SetWarningPref(x);
return PREF_NOERROR;
return 0;
}
MODULE_PRIVATE int PR_CALLBACK
@ -1012,7 +1012,7 @@ cookie_LifetimeOptPrefChanged(const char * newpref, void * data) {
n = COOKIE_Normal;
}
cookie_SetLifetimePref((COOKIE_LifetimeEnum)n);
return PREF_NOERROR;
return 0;
}
MODULE_PRIVATE int PR_CALLBACK
@ -1023,7 +1023,7 @@ cookie_LifetimeLimitPrefChanged(const char * newpref, void * data) {
if (!NS_FAILED(prefs->GetIntPref(cookie_lifetimeValue, &n))) {
cookie_SetLifetimeLimit(n);
}
return PREF_NOERROR;
return 0;
}
/*

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

@ -58,13 +58,13 @@
#include "nsIServiceManager.h"
#include "nsIPref.h"
#include "prefapi.h"
#include "nsISessionHistory.h"
#include "nsXULAtoms.h"
#include "nsIDOMXULDocument.h"
#include "nsIDOMXULCommandDispatcher.h"
#include "nsIObserverService.h"
#include "prlog.h"
//we will use key binding by default now. this wil lbreak viewer for now
#define NON_KEYBINDING 0

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

@ -29,7 +29,6 @@
#include "nsIServiceManager.h"
#include "nsIPref.h"
#include "prefapi.h"
static NS_DEFINE_CID(kPrefCID, NS_PREF_CID);
@ -86,7 +85,7 @@ static int NavAlgorithmPrefChangedCallback(const char * name, void * closure)
if (NS_SUCCEEDED(rv) && prefs) {
prefs->GetBoolPref(name, &gNavAlgorithmPref);
}
return PREF_NOERROR;
return 0;
}

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

@ -29,7 +29,6 @@
#include "nsIServiceManager.h"
#include "nsIPref.h"
#include "prefapi.h"
static NS_DEFINE_CID(kPrefCID, NS_PREF_CID);
@ -86,7 +85,7 @@ static int NavAlgorithmPrefChangedCallback(const char * name, void * closure)
if (NS_SUCCEEDED(rv) && prefs) {
prefs->GetBoolPref(name, &gNavAlgorithmPref);
}
return PREF_NOERROR;
return 0;
}

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

@ -35,7 +35,6 @@
#include "plstr.h"
#include "prmem.h"
#include "prefapi.h"
#include "libi18n.h"
static NS_DEFINE_CID(kPrefCID, NS_PREF_CID);
@ -44,6 +43,7 @@ static NS_DEFINE_CID(kCharsetConverterManagerCID, NS_ICHARSETCONVERTERMANAGER_CI
#define LDAP_PORT 389
#define LDAPS_PORT 636
#define PREF_NOERROR 0
/* This format suffix is being defined here because it is needed by the FEs in their
file operation routines */
@ -3293,7 +3293,7 @@ nsresult DIR_GetServerPreferences(nsVoidArray** list)
pPref->SetIntPref(PREF_LDAP_VERSION_NAME, kCurrentListVersion);
/* Look to see if there's an old-style "ldap_1" tree in prefs */
if (PREF_OK == pPref->CreateChildList("ldap_1", &oldChildren))
if (PREF_NOERROR == pPref->CreateChildList("ldap_1", &oldChildren))
{
if (PL_strlen(oldChildren))
{

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

@ -26,7 +26,6 @@
#include "mimeobj.h"
#include "modlmime.h"
#include "mimei.h"
#include "prefapi.h"
#include "mimebuf.h"
#include "mimemoz2.h"
#include "mimemsg.h"

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

@ -27,7 +27,6 @@
#include "modmime.h"
#include "prmem.h"
#include "plstr.h"
#include "prefapi.h"
#include "mimebuf.h"
#include "mimemoz2.h"
#include "nsIMimeEmitter.h"

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

@ -57,7 +57,6 @@
/* SUPPORTED VIA PLUGIN | | |--------- MimeInlineTextCalendar */
#include "nsIPref.h"
#include "prefapi.h"
#include "mimeiimg.h" /* | |--- MimeInlineImage */
#include "mimeeobj.h" /* | |--- MimeExternalObject */
#include "mimeebod.h" /* |--- MimeExternalBody */

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

@ -4,5 +4,4 @@
#[installed by xpidl] nsIPref.h
prefapi.h
prefldap.h

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

@ -30,7 +30,7 @@ MODULE = pref
XPIDLSRCS = nsIPref.idl
EXPORTS = prefapi.h prefldap.h
EXPORTS = prefldap.h
EXPORTS := $(addprefix $(srcdir)/, $(EXPORTS))
include $(topsrcdir)/config/rules.mk

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

@ -22,7 +22,7 @@
MODULE=pref
DEPTH=..\..\..
EXPORTS=prefapi.h prefldap.h
EXPORTS=prefldap.h
XPIDLSRCS = .\nsIPref.idl

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

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

@ -69,6 +69,7 @@
#include "nsQuickSort.h"
#include "nsXPIDLString.h"
#include "nsScriptSecurityManager.h"
#ifdef _WIN32
#include "windows.h"
@ -79,6 +80,11 @@
#define INITIAL_MAX_DEFAULT_PREF_FILES 10
// Preferences that start with this string are subject to a security check
#define PREF_SECURITY_PREFIX "security."
// Cabability which must be enabled to access preferences starting with PREF_SECURITY_PREFIX
#define PREF_SECURITY_ACCESS_CAPABILITY "SecurityPreferenceAccess"
#include "prefapi_private_data.h"
#if defined(DEBUG_mcafee)
@ -86,6 +92,7 @@
#endif
static NS_DEFINE_CID(kFileLocatorCID, NS_FILELOCATOR_CID);
static NS_DEFINE_CID(kSecurityManagerCID, NS_SCRIPTSECURITYMANAGER_CID);
//========================================================================================
class nsPref: public nsIPref
@ -121,6 +128,8 @@ protected:
nsresult useDefaultPrefFile();
nsresult useUserPrefFile();
nsresult SecurePrefCheck(const char* aPrefName);
static nsPref *gInstance;
nsIFileSpec* mFileSpec;
@ -262,6 +271,27 @@ nsPref* nsPref::GetInstance()
return gInstance;
} // nsPref::GetInstance
//----------------------------------------------------------------------------------------
nsresult nsPref::SecurePrefCheck(const char* aPrefName)
//----------------------------------------------------------------------------------------
{
/* This will be uncommented very soon. For now, leave it alone. -mstoltz
static const char securityPrefix[] = PREF_SECURITY_PREFIX;
if (PL_strnstr(aPrefName, securityPrefix, sizeof(securityPrefix)) == 0)
return NS_OK;
// XXX: Need error reporting somehow.
nsresult rv;
NS_WITH_SERVICE(nsIScriptSecurityManager, secMan, kSecurityManagerCID, &rv);
if (NS_FAILED(rv)) return NS_ERROR_FAILURE;
PRBool enabled;
rv = secMan->IsCapabilityEnabled(PREF_SECURITY_ACCESS_CAPABILITY, &enabled);
if (NS_FAILED(rv) || !enabled)
return NS_ERROR_FAILURE;
*/
return NS_OK;
}
NS_IMPL_THREADSAFE_ISUPPORTS(nsPref, NS_GET_IID(nsIPref));
//========================================================================================
@ -450,17 +480,20 @@ NS_IMETHODIMP nsPref::GetPrefType(const char *pref, PRInt32 * return_type)
NS_IMETHODIMP nsPref::GetIntPref(const char *pref, PRInt32 * return_int)
{
if (NS_FAILED(SecurePrefCheck(pref))) return NS_ERROR_FAILURE;
return _convertRes(PREF_GetIntPref(pref, return_int));
}
NS_IMETHODIMP nsPref::GetBoolPref(const char *pref, PRBool * return_val)
{
if (NS_FAILED(SecurePrefCheck(pref))) return NS_ERROR_FAILURE;
return _convertRes(PREF_GetBoolPref(pref, return_val));
}
NS_IMETHODIMP nsPref::GetBinaryPref(const char *pref,
void * return_val, int * buf_length)
{
if (NS_FAILED(SecurePrefCheck(pref))) return NS_ERROR_FAILURE;
return _convertRes(PREF_GetBinaryPref(pref, return_val, buf_length));
}
@ -468,6 +501,7 @@ NS_IMETHODIMP nsPref::GetBinaryPref(const char *pref,
NS_IMETHODIMP nsPref::GetColorPref(const char *pref,
PRUint8 *red, PRUint8 *green, PRUint8 *blue)
{
if (NS_FAILED(SecurePrefCheck(pref))) return NS_ERROR_FAILURE;
return _convertRes(PREF_GetColorPref(pref, red, green, blue));
}
#endif
@ -475,6 +509,7 @@ NS_IMETHODIMP nsPref::GetColorPref(const char *pref,
NS_IMETHODIMP nsPref::GetColorPrefDWord(const char *pref,
PRUint32 *colorref)
{
if (NS_FAILED(SecurePrefCheck(pref))) return NS_ERROR_FAILURE;
return _convertRes(PREF_GetColorPrefDWord(pref, colorref));
}
@ -483,6 +518,7 @@ NS_IMETHODIMP nsPref::GetRectPref(const char *pref,
PRInt16 *left, PRInt16 *top,
PRInt16 *right, PRInt16 *bottom)
{
if (NS_FAILED(SecurePrefCheck(pref))) return NS_ERROR_FAILURE;
return _convertRes(PREF_GetRectPref(pref, left, top, right, bottom));
}
#endif
@ -493,11 +529,13 @@ NS_IMETHODIMP nsPref::GetRectPref(const char *pref,
NS_IMETHODIMP nsPref::SetCharPref(const char *pref,const char* value)
{
if (NS_FAILED(SecurePrefCheck(pref))) return NS_ERROR_FAILURE;
return _convertRes(PREF_SetCharPref(pref, value));
}
NS_IMETHODIMP nsPref::SetUnicharPref(const char *pref, const PRUnichar *value)
{
if (NS_FAILED(SecurePrefCheck(pref))) return NS_ERROR_FAILURE;
nsresult rv;
nsAutoString str(value);
@ -513,16 +551,19 @@ NS_IMETHODIMP nsPref::SetUnicharPref(const char *pref, const PRUnichar *value)
NS_IMETHODIMP nsPref::SetIntPref(const char *pref,PRInt32 value)
{
if (NS_FAILED(SecurePrefCheck(pref))) return NS_ERROR_FAILURE;
return _convertRes(PREF_SetIntPref(pref, value));
}
NS_IMETHODIMP nsPref::SetBoolPref(const char *pref,PRBool value)
{
if (NS_FAILED(SecurePrefCheck(pref))) return NS_ERROR_FAILURE;
return _convertRes(PREF_SetBoolPref(pref, value));
}
NS_IMETHODIMP nsPref::SetBinaryPref(const char *pref,void * value, PRUint32 size)
{
if (NS_FAILED(SecurePrefCheck(pref))) return NS_ERROR_FAILURE;
return _convertRes(PREF_SetBinaryPref(pref, value, size));
}
@ -530,6 +571,7 @@ NS_IMETHODIMP nsPref::SetBinaryPref(const char *pref,void * value, PRUint32 size
NS_IMETHODIMP nsPref::SetColorPref(const char *pref,
PRUint8 red, PRUint8 green, PRUint8 blue)
{
if (NS_FAILED(SecurePrefCheck(pref))) return NS_ERROR_FAILURE;
return _convertRes(PREF_SetColorPref(pref, red, green, blue));
}
#endif
@ -538,6 +580,7 @@ NS_IMETHODIMP nsPref::SetColorPref(const char *pref,
NS_IMETHODIMP nsPref::SetColorPrefDWord(const char *pref,
PRUint32 value)
{
if (NS_FAILED(SecurePrefCheck(pref))) return NS_ERROR_FAILURE;
return _convertRes(PREF_SetColorPrefDWord(pref, value));
}
#endif
@ -547,6 +590,7 @@ NS_IMETHODIMP nsPref::SetRectPref(const char *pref,
PRInt16 left, PRInt16 top,
PRInt16 right, PRInt16 bottom)
{
if (NS_FAILED(SecurePrefCheck(pref))) return NS_ERROR_FAILURE;
return _convertRes(PREF_SetRectPref(pref, left, top, right, bottom));
}
#endif
@ -558,12 +602,14 @@ NS_IMETHODIMP nsPref::SetRectPref(const char *pref,
NS_IMETHODIMP nsPref::GetDefaultIntPref(const char *pref,
PRInt32 * return_int)
{
if (NS_FAILED(SecurePrefCheck(pref))) return NS_ERROR_FAILURE;
return _convertRes(PREF_GetDefaultIntPref(pref, return_int));
}
NS_IMETHODIMP nsPref::GetDefaultBoolPref(const char *pref,
PRBool * return_val)
{
if (NS_FAILED(SecurePrefCheck(pref))) return NS_ERROR_FAILURE;
return _convertRes(PREF_GetDefaultBoolPref(pref, return_val));
}
@ -571,6 +617,7 @@ NS_IMETHODIMP nsPref::GetDefaultBinaryPref(const char *pref,
void * return_val,
int * buf_length)
{
if (NS_FAILED(SecurePrefCheck(pref))) return NS_ERROR_FAILURE;
return _convertRes(PREF_GetDefaultBinaryPref(pref, return_val, buf_length));
}
@ -579,6 +626,7 @@ NS_IMETHODIMP nsPref::GetDefaultColorPref(const char *pref,
PRUint8 *red, PRUint8 *green,
PRUint8 *blue)
{
if (NS_FAILED(SecurePrefCheck(pref))) return NS_ERROR_FAILURE;
return _convertRes(PREF_GetDefaultColorPref(pref, red, green, blue));
}
#endif
@ -587,6 +635,7 @@ NS_IMETHODIMP nsPref::GetDefaultColorPref(const char *pref,
NS_IMETHODIMP nsPref::GetDefaultColorPrefDWord(const char *pref,
PRUint32 *colorref)
{
if (NS_FAILED(SecurePrefCheck(pref))) return NS_ERROR_FAILURE;
return _convertRes(PREF_GetDefaultColorPrefDWord(pref, colorref));
}
#endif
@ -596,6 +645,7 @@ NS_IMETHODIMP nsPref::GetDefaultRectPref(const char *pref,
PRInt16 *left, PRInt16 *top,
PRInt16 *right, PRInt16 *bottom)
{
if (NS_FAILED(SecurePrefCheck(pref))) return NS_ERROR_FAILURE;
return _convertRes(PREF_GetDefaultRectPref(pref,
left, top, right, bottom));
}
@ -607,12 +657,14 @@ NS_IMETHODIMP nsPref::GetDefaultRectPref(const char *pref,
NS_IMETHODIMP nsPref::SetDefaultCharPref(const char *pref,const char* value)
{
if (NS_FAILED(SecurePrefCheck(pref))) return NS_ERROR_FAILURE;
return _convertRes(PREF_SetDefaultCharPref(pref, value));
}
NS_IMETHODIMP nsPref::SetDefaultUnicharPref(const char *pref,
const PRUnichar *value)
{
if (NS_FAILED(SecurePrefCheck(pref))) return NS_ERROR_FAILURE;
nsresult rv;
nsAutoString str(value);
@ -628,17 +680,20 @@ NS_IMETHODIMP nsPref::SetDefaultUnicharPref(const char *pref,
NS_IMETHODIMP nsPref::SetDefaultIntPref(const char *pref,PRInt32 value)
{
if (NS_FAILED(SecurePrefCheck(pref))) return NS_ERROR_FAILURE;
return _convertRes(PREF_SetDefaultIntPref(pref, value));
}
NS_IMETHODIMP nsPref::SetDefaultBoolPref(const char *pref, PRBool value)
{
if (NS_FAILED(SecurePrefCheck(pref))) return NS_ERROR_FAILURE;
return _convertRes(PREF_SetDefaultBoolPref(pref, value));
}
NS_IMETHODIMP nsPref::SetDefaultBinaryPref(const char *pref,
void * value, PRUint32 size)
{
if (NS_FAILED(SecurePrefCheck(pref))) return NS_ERROR_FAILURE;
return _convertRes(PREF_SetDefaultBinaryPref(pref, value, size));
}
@ -646,6 +701,7 @@ NS_IMETHODIMP nsPref::SetDefaultBinaryPref(const char *pref,
NS_IMETHODIMP nsPref::SetDefaultColorPref(const char *pref,
PRUint8 red, PRUint8 green, PRUint8 blue)
{
if (NS_FAILED(SecurePrefCheck(pref))) return NS_ERROR_FAILURE;
return _convertRes(PREF_SetDefaultColorPref(pref, red, green, blue));
}
#endif
@ -655,12 +711,14 @@ NS_IMETHODIMP nsPref::SetDefaultRectPref(const char *pref,
PRInt16 left, PRInt16 top,
PRInt16 right, PRInt16 bottom)
{
if (NS_FAILED(SecurePrefCheck(pref))) return NS_ERROR_FAILURE;
return _convertRes(PREF_SetDefaultRectPref(pref, left, top, right, bottom));
}
#endif
NS_IMETHODIMP nsPref::ClearUserPref(const char *pref_name)
{
if (NS_FAILED(SecurePrefCheck(pref_name))) return NS_ERROR_FAILURE;
return _convertRes(PREF_ClearUserPref(pref_name));
}
@ -670,6 +728,7 @@ NS_IMETHODIMP nsPref::ClearUserPref(const char *pref_name)
NS_IMETHODIMP nsPref::CopyCharPref(const char *pref, char ** return_buf)
{
if (NS_FAILED(SecurePrefCheck(pref))) return NS_ERROR_FAILURE;
return _convertRes(PREF_CopyCharPref(pref, return_buf));
}
@ -682,6 +741,7 @@ static const PRUnichar unicodeFormatter[] = {
NS_IMETHODIMP nsPref::CopyUnicharPref(const char *pref, PRUnichar ** return_buf)
{
if (NS_FAILED(SecurePrefCheck(pref))) return NS_ERROR_FAILURE;
nsresult rv;
// get the UTF8 string for conversion
@ -713,18 +773,21 @@ nsPref::convertUTF8ToUnicode(const char *utf8String, PRUnichar ** aResult)
NS_IMETHODIMP nsPref::CopyBinaryPref(const char *pref,
int *size, void ** return_value)
{
if (NS_FAILED(SecurePrefCheck(pref))) return NS_ERROR_FAILURE;
return _convertRes(PREF_CopyBinaryPref(pref, return_value, size));
}
NS_IMETHODIMP nsPref::CopyDefaultCharPref( const char *pref,
char ** return_buffer )
{
if (NS_FAILED(SecurePrefCheck(pref))) return NS_ERROR_FAILURE;
return _convertRes(PREF_CopyDefaultCharPref(pref, return_buffer));
}
NS_IMETHODIMP nsPref::CopyDefaultUnicharPref( const char *pref,
PRUnichar ** return_buf)
{
if (NS_FAILED(SecurePrefCheck(pref))) return NS_ERROR_FAILURE;
nsresult rv;
nsXPIDLCString utf8String;
@ -737,6 +800,7 @@ NS_IMETHODIMP nsPref::CopyDefaultUnicharPref( const char *pref,
NS_IMETHODIMP nsPref::CopyDefaultBinaryPref(const char *pref,
int * size, void ** return_val)
{
if (NS_FAILED(SecurePrefCheck(pref))) return NS_ERROR_FAILURE;
return _convertRes(PREF_CopyDefaultBinaryPref(pref, return_val, size));
}
@ -749,6 +813,7 @@ NS_IMETHODIMP nsPref::CopyDefaultBinaryPref(const char *pref,
NS_IMETHODIMP nsPref::CopyPathPref(const char *pref, char ** return_buf)
//----------------------------------------------------------------------------------------
{
if (NS_FAILED(SecurePrefCheck(pref))) return NS_ERROR_FAILURE;
return _convertRes(PREF_CopyPathPref(pref, return_buf));
}
@ -757,6 +822,7 @@ NS_IMETHODIMP nsPref::SetPathPref(const char *pref,
const char *path, PRBool set_default)
//----------------------------------------------------------------------------------------
{
if (NS_FAILED(SecurePrefCheck(pref))) return NS_ERROR_FAILURE;
return _convertRes(PREF_SetPathPref(pref, path, set_default));
}
#endif
@ -766,7 +832,8 @@ NS_IMETHODIMP nsPref::GetFilePref(const char *pref_name, nsIFileSpec** value)
//----------------------------------------------------------------------------------------
{
if (!value)
return NS_ERROR_NULL_POINTER;
return NS_ERROR_NULL_POINTER;
if (NS_FAILED(SecurePrefCheck(pref_name))) return NS_ERROR_FAILURE;
nsresult rv = nsComponentManager::CreateInstance(
(const char*)NS_FILESPEC_PROGID,
@ -799,7 +866,8 @@ NS_IMETHODIMP nsPref::SetFilePref(const char *pref_name,
//----------------------------------------------------------------------------------------
{
if (!value)
return NS_ERROR_NULL_POINTER;
return NS_ERROR_NULL_POINTER;
if (NS_FAILED(SecurePrefCheck(pref_name))) return NS_ERROR_FAILURE;
nsresult rv = NS_OK;
if (!Exists(value))
{
@ -841,6 +909,7 @@ NS_IMETHODIMP nsPref::PrefIsLocked(const char *pref, PRBool *res)
{
if (res == NULL)
return NS_ERROR_INVALID_POINTER;
if (NS_FAILED(SecurePrefCheck(pref))) return NS_ERROR_FAILURE;
*res = PREF_PrefIsLocked(pref);
return NS_OK;

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

@ -20,19 +20,6 @@
* Contributor(s):
*/
/** USAGE NOTE:
<font color=red>
This file (prefapi.c) is being obsoleted, and functions previously declared
here are migrating to preffunc.cpp in this module. If you make changes
in this file, please be sure to check preffunc.cpp to ensure that similar
changes are made in that file.
Currently Windows uses preffunc.cpp and the other platforms use prefapi.c.
</font>
**/
#include "prefapi.h"
#include "jsapi.h"

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

@ -20,19 +20,6 @@
* Contributor(s):
*/
/** USAGE NOTE:
<font color=red>
This file (prefapi.c) is being obsoleted, and functions previously declared
here are migrating to preffunc.cpp in this module. If you make changes
in this file, please be sure to check preffunc.cpp to ensure that similar
changes are made in that file.
Currently Windows uses preffunc.cpp and the other platforms use prefapi.c.
</font>
**/
#include "prefapi.h"
#include "jsapi.h"

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

@ -0,0 +1,464 @@
/* -*- 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.1 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
*/
/*
// <pre>
*/
#ifndef PREFAPI_H
#define PREFAPI_H
#include "xp_core.h"
#include "prtypes.h"
#include "jscompat.h"
#include "jspubtd.h"
#ifdef XP_WIN
#include "plhash.h"
#endif
#define NEW_PREF_ARCH
#if defined(VMS)
/* Deal with case naming conflicts */
#define pref_CopyCharPref prefl_CopyCharPref
#define pref_GetBoolPref prefl_GetBoolPref
#define pref_GetCharPref prefl_GetCharPref
#define pref_GetIntPref prefl_GetIntPref
#define pref_LockPref prefl_LockPref
#endif /* VMS */
NSPR_BEGIN_EXTERN_C
/*
// <font color=blue>
// Error codes
// </font>
*/
typedef int PROFILE_ERROR;
/* Error numbers between -100 and -999 are reserved for individual stores */
/* Error numbers less than -1000 are reserved for the profile manager */
/* IMPORTANT: if you add error codes to this, make sure you update convertRes() in
* nsPref.cpp, otherwise the error won't get turned into the right nsresult value
*/
typedef enum {
PREF_DEFAULT_VALUE_NOT_INITIALIZED = -13,
PREF_BAD_PASSWORD = -12,
PREF_CANT_DELETE_NET_PROFILE = -11,
PREF_NETPROFILE_DIR_EXISTS = -10,
PREF_PROFILE_DIR_EXISTS = -9,
PREF_PROFILE_EXISTS = -8,
PREF_BAD_PARAMETER = -7,
PREF_DOES_NOT_EXIST = -6,
PREF_OUT_OF_MEMORY = -5,
PREF_TYPE_CHANGE_ERR = -4,
PREF_NOT_INITIALIZED = -3,
PREF_BAD_LOCKFILE = -2,
PREF_ERROR = -1,
PREF_NOERROR = 0,
PREF_OK = 0, /* same as PREF_NOERROR */
PREF_VALUECHANGED = 1,
PREF_PROFILE_UPGRADE = 2
} PrefResult;
/*
// <font color=blue>
// The Init function sets up of the JavaScript preference context and creates
// the basic preference and pref_array objects:
// It also takes the filename of the preference file to use. This allows the
// module to create its own pref file if that is so desired. If a filename isn't
// passed, the pref module will either use the current name and file (if known) or
// will call (FE_GetPrefFileName() ?) to have a module prompt the user to determine
// which user it is (on a mulit-user system). In general, the FE should pass the
// filename and the sub-modules should pass NULL
//
// At the moment, the Init function is defining 3 JavaScript functions that can be
// called in arbitrary JavaScript (like that passed to the EvaluateJS function below).
// This may increase in the future...
//
// pref(pref_name,default_value) : Setup the initial preference storage and default
// user_pref(pref_name, user_value) : Set a user preference
// lock_pref(pref_name) : Lock a preference (prevent it from being modifyed by user)
// </font>
*/
PR_EXTERN(PrefResult)
PREF_ReadUserJSFile(const char *filename);
PR_EXTERN(PrefResult)
PREF_ReadLIJSFile(const char *filename);
#if defined (XP_PC) || defined (XP_MAC)
/* PREF_Init actually returns a profile object */
PR_EXTERN(void *)
PREF_InitProfile(void);
PR_EXTERN(void *)
PREF_GetCurrentProfile(void);
#endif
PR_EXTERN(PRBool)
PREF_Init(const char *filename);
PR_EXTERN(PrefResult)
PREF_LockPref(const char *key);
PR_EXTERN(PrefResult)
PREF_GetConfigContext(JSContext **js_context);
PR_EXTERN(PrefResult)
PREF_GetGlobalConfigObject(JSObject **js_object);
PR_EXTERN(PrefResult)
PREF_GetPrefConfigObject(JSObject **js_object);
/*
// Cleanup should be called at program exit to free the
// list of registered callbacks.
*/
PR_EXTERN(void)
PREF_Cleanup();
PR_EXTERN(void)
PREF_CleanupPrefs();
/*
// <font color=blue>
// Given a path to a local Lock file, unobscures the file (not implemented yet)
// and verifies the MD5 hash. Returns PREF_BAD_LOCKFILE if hash failed;
// otherwise, evaluates the contents of the file as a JS buffer.
// </font>
*/
PR_EXTERN(PrefResult)
PREF_ReadLockFile(const char *filename);
#if 0 /* OBSOLETE */
PR_EXTERN(JSBool) PREF_EvaluateJSBuffer(const char * js_buffer, size_t length);
PR_EXTERN(JSBool) PREF_QuietEvaluateJSBuffer(const char * js_buffer, size_t length);
/* Like the above but does not generate callbacks. */
PR_EXTERN(JSBool) PREF_QuietEvaluateJSBufferWithGlobalScope(const char * js_buffer, size_t length);
/* Like the above but does not generate callbacks and executes in scope of global config object */
#endif /* OBSOLETE */
PR_EXTERN(JSBool)
PREF_EvaluateConfigScript(const char * js_buffer, size_t length,
const char* filename, PRBool bGlobalContext, PRBool bCallbacks,
PRBool skipFirstLine);
/*
// This routine is newer than the above which are not being called externally,
// as far as I know. The following is used from mkautocf to evaluate a
// config URL file with callbacks.
// <font color=blue>
// Pass an arbitrary JS buffer to be evaluated in the Preference context.
// On startup modules will want to set up their preferences with reasonable
// defaults. For example netlib might call with a buffer of:
//
// pref("network.tcpbufsize",4096);
// pref("network.max_connections", 4);
// pref("network.proxy.http_host", "");
// pref("network.proxy.http_port". 0);
// ...etc...
//
// This routine generates callbacks to functions registered with
// PREF_RegisterCallback() for any user values that have changed.
// </font>
*/
/*
// <font color=blue>
// Actions that can be passed to various functions to perform an operation on a pref key
// </font>
*/
typedef enum { PREF_SETDEFAULT, PREF_SETUSER,
PREF_LOCK, PREF_SETCONFIG
#ifdef MOZ_OLD_LI_STUFF
,PREF_SETLI
#endif
} PrefAction;
/*
// <font color=blue>
// Preference flags, including the native type of the preference
// </font>
*/
typedef enum { PREF_INVALID = 0,
PREF_LOCKED = 1, PREF_USERSET = 2, PREF_CONFIG = 4, PREF_REMOTE = 8,
PREF_LILOCAL = 16, PREF_STRING = 32, PREF_INT = 64, PREF_BOOL = 128,
PREF_VALUETYPE_MASK = (PREF_STRING | PREF_INT | PREF_BOOL)
} PrefType;
/*
// <font color=blue>
// Set the various types of preferences. These functions take a dotted
// notation of the preference name (e.g. "browser.startup.homepage").
// Note that this will cause the preference to be saved to the file if
// it is different from the default. In other words, these are used
// to set the _user_ preferences.
// Each set returns PREF_VALUECHANGED if the user value changed
// (triggering a callback), or PREF_NOERROR if the value was unchanged.
// </font>
*/
PR_EXTERN(PrefResult) PREF_SetCharPref(const char *pref,const char* value);
PR_EXTERN(PrefResult) PREF_SetIntPref(const char *pref,PRInt32 value);
PR_EXTERN(PrefResult) PREF_SetBoolPref(const char *pref,PRBool value);
PR_EXTERN(PrefResult) PREF_SetBinaryPref(const char *pref,void * value, long size);
PR_EXTERN(PrefResult) PREF_SetColorPref(const char *pref_name, PRUint8 red, PRUint8 green, PRUint8 blue);
PR_EXTERN(PrefResult) PREF_SetColorPrefDWord(const char *pref_name, PRUint32 colorref);
PR_EXTERN(PrefResult) PREF_SetRectPref(const char *pref_name, PRInt16 left, PRInt16 top, PRInt16 right, PRInt16 bottom);
/*
// <font color=blue>
// Set the default for various types of preferences. These functions take a dotted
// notation of the preference name (e.g. "browser.startup.homepage")
// This will only affect the program behavior if the user does not have a value
// saved over it for the particular preference. In addition, these will never
// be saved out to disk.
// </font>
*/
PR_EXTERN(PrefResult) PREF_SetDefaultCharPref(const char *pref,const char* value);
PR_EXTERN(PrefResult) PREF_SetDefaultIntPref(const char *pref,PRInt32 value);
PR_EXTERN(PrefResult) PREF_SetDefaultBoolPref(const char *pref,PRBool value);
PR_EXTERN(PrefResult) PREF_SetDefaultBinaryPref(const char *pref,void * value, long size);
PR_EXTERN(PrefResult) PREF_SetDefaultColorPref(const char *pref_name, PRUint8 red, PRUint8 green, PRUint8 blue);
PR_EXTERN(PrefResult) PREF_SetDefaultRectPref(const char *pref_name, PRInt16 left, PRInt16 top, PRInt16 right, PRInt16 bottom);
/*
// <font color=blue>
// Get the various types of preferences. These functions take a dotted
// notation of the preference name (e.g. "browser.startup.homepage")
//
// They also take a pointer to fill in with the return value and return an
// error value. At the moment, this is simply an int but it may
// be converted to an enum once the global error strategy is worked out.
// In addition, the GetChar and GetBinary versions take an (int *) which
// should contain the length of the buffer which is passed to be filled
// in. If the length passed in is 0, the function will not copy the
// preference but will instead return the length necessary for the buffer,
// including null terminator.
//
// They will perform conversion if the type doesn't match what was requested.
// (if it is reasonably possible)
// </font>
*/
PR_EXTERN(PrefResult) PREF_GetCharPref(const char *pref, char * return_buf, int * buf_length);
PR_EXTERN(PrefResult) PREF_GetIntPref(const char *pref, PRInt32 * return_int);
PR_EXTERN(PrefResult) PREF_GetBoolPref(const char *pref, PRBool * return_val);
PR_EXTERN(PrefResult) PREF_GetBinaryPref(const char *pref, void * return_val, int * buf_length);
PR_EXTERN(PrefResult) PREF_GetColorPref(const char *pref_name, PRUint8 *red, PRUint8 *green, PRUint8 *blue);
PR_EXTERN(PrefResult) PREF_GetColorPrefDWord(const char *pref_name, PRUint32 *colorref);
PR_EXTERN(PrefResult) PREF_GetRectPref(const char *pref_name, PRInt16 *left, PRInt16 *top, PRInt16 *right, PRInt16 *bottom);
/*
// <font color=blue>
// These functions are similar to the above "Get" version with the significant
// difference that the preference module will alloc the memory (e.g. XP_STRDUP) and
// the caller will need to be responsible for freeing it...
// </font>
*/
PR_EXTERN(PrefResult) PREF_CopyCharPref(const char *pref, char ** return_buf);
PR_EXTERN(PrefResult) PREF_CopyBinaryPref(const char *pref_name, void ** return_value, int *size);
PR_EXTERN(PrefResult) PREF_CopyDefaultCharPref( const char *pref_name, char ** return_buffer );
PR_EXTERN(PrefResult) PREF_CopyDefaultBinaryPref(const char *pref, void ** return_val, int * size);
/*
// <font color=blue>
// Get and set encoded full file/directory pathname strings
// (i.e. file URLs without the file:// part).
// On Windows and Unix, these are just stored as string preferences.
// On Mac, paths should be stored as aliases. These calls convert
// between paths and aliases flattened into binary strings.
// </font>
*/
PR_EXTERN(PrefResult) PREF_CopyPathPref(const char *pref, char ** return_buf);
PR_EXTERN(PrefResult) PREF_SetPathPref(const char *pref_name, const char *path, PRBool set_default);
/*
// <font color=blue>
// Same as the previous "Get" functions but will always return the
// default value regardless of what the user has set. These are designed
// to be used by functions which "reset" the preferences
//
// </font>
*/
PR_EXTERN(PrefResult) PREF_GetDefaultCharPref(const char *pref, char * return_buf, int * buf_length);
PR_EXTERN(PrefResult) PREF_GetDefaultIntPref(const char *pref, PRInt32 * return_int);
PR_EXTERN(PrefResult) PREF_GetDefaultBoolPref(const char *pref, PRBool * return_val);
PR_EXTERN(PrefResult) PREF_GetDefaultBinaryPref(const char *pref, void * return_val, int * buf_length);
PR_EXTERN(PrefResult) PREF_GetDefaultColorPref(const char *pref_name, PRUint8 *red, PRUint8 *green, PRUint8 *blue);
PR_EXTERN(PrefResult) PREF_GetDefaultColorPrefDWord(const char *pref_name, PRUint32 *colorref);
PR_EXTERN(PrefResult) PREF_GetDefaultRectPref(const char *pref_name, PRInt16 *left, PRInt16 *top, PRInt16 *right, PRInt16 *bottom);
/*
// <font color=blue>
// Administration Kit support
//
// These fetch a given configuration parameter.
// If the parameter is not defined, an error code will be returned;
// a JavaScript error will not be generated (unlike the above Get routines).
//
// IndexConfig fetches an indexed button or menu string, e.g.
// PREF_CopyIndexConfigString( "menu.help.item", 3, "label", &buf );
// to fetch the label of Help menu item 3.
// The caller is responsible for freeing the returned string.
// </font>
*/
PR_EXTERN(PrefResult) PREF_CopyConfigString(const char *obj_name, char **return_buffer);
PR_EXTERN(PrefResult) PREF_CopyIndexConfigString(const char *obj_name, int indx,
const char *field, char **return_buffer);
PR_EXTERN(PrefResult) PREF_GetConfigInt(const char *obj_name, PRInt32 *return_int);
PR_EXTERN(PrefResult) PREF_GetConfigBool(const char *obj_name, PRBool *return_bool);
/* OLD:: */PR_EXTERN(PrefResult) PREF_GetConfigString(const char *obj_name, char * return_buffer, int size,
int indx, const char *field);
/*
* Listpref API
*/
PR_EXTERN(PrefResult) PREF_GetListPref(const char *pref_name, char*** list);
PR_EXTERN(PrefResult) PREF_SetListPref(const char *pref_name, char** list);
PR_EXTERN(PrefResult) PREF_AppendListPref(const char *pref_name, const char *value);
PR_EXTERN(PrefResult) PREF_FreeListPref(char*** list);
/*
// <font color=blue>
// PRBool function that returns whether or not the preference is locked and therefore
// cannot be changed.
// </font>
*/
PR_EXTERN(PRBool) PREF_PrefIsLocked(const char *pref_name);
PR_EXTERN(PrefType) PREF_GetPrefType(const char *pref_name);
/*
// <font color=blue>
// Cause the preference file to be written to disk
// </font>
*/
PR_EXTERN(PrefResult) PREF_SavePrefFile(void);
PR_EXTERN(PrefResult) PREF_SavePrefFileAs(const char *filename);
/* LI_STUFF */
#ifdef MOZ_OLD_UI_STUFF
PR_EXTERN(PrefResult) PREF_SaveLIPrefFile(const char *filename);
#endif /* MOZ_OLD_UI_STUFF */
/*
* Called to handle the "about:config" command.
* Currently dumps out some debugging information.
*/
PR_EXTERN(char *) PREF_AboutConfig();
/*
* Delete a branch of the tree
*/
PR_EXTERN(PrefResult) PREF_DeleteBranch(const char *branch_name);
/*
* Clears the given pref (reverts it to its default value)
*/
PR_EXTERN(PrefResult) PREF_ClearUserPref(const char *pref_name);
/*
* Creates an iterator over the children of a node. Sample code:
char* children;
if ( PREF_CreateChildList("mime", &children) == 0 )
{
int indx = 0;
while (char* child = PREF_NextChild(children, &indx)) {
...
}
XP_FREE(children);
}
* e.g. subsequent calls to Next() return
* "mime.image_gif", then
* "mime.image_jpeg", etc.
*/
PR_EXTERN(PrefResult) PREF_CreateChildList(const char* parent_node, char **child_list);
PR_EXTERN(char*) PREF_NextChild(char *child_list, int *indx);
/* The following function parts of the hierarchy from one root to another.
* For example, PREF_CopyPrefsTree("mail","newmail") copies all
* the "mail." prefs to "newmail." prefs. It does not delete the
* source tree; you should do that yourself.
*
* Either srcRoot or destRoot can be empty strings, to denote
* the root of the entire tree, but cannot be NULL.
*/
PR_EXTERN(PrefResult) PREF_CopyPrefsTree(const char *srcRoot, const char *destRoot);
/*
// <font color=blue>
// The callback function will get passed the pref_node which triggered the call
// and the void * instance_data which was passed to the register callback function.
// Return a non-zero result (a PrefResult enumerated value) to pass an error up to the caller.
// </font>
*/
/* 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 __gen_nsIPref_h__
typedef int (*PrefChangedFunc) (const char *, void *);
#endif /* __gen_nsIPref_h__ */
/*
// <font color=blue>
// Register a callback. This takes a node in the preference tree and will
// call the callback function if anything below that node is modified.
// Unregister returns PREF_NOERROR if a callback was found that
// matched all the parameters; otherwise it returns PREF_ERROR.
// </font>
*/
PR_EXTERN(void) PREF_RegisterCallback( const char* domain,
PrefChangedFunc callback, void* instance_data );
PR_EXTERN(PrefResult) PREF_UnregisterCallback( const char* domain,
PrefChangedFunc callback, void* instance_data );
/*
// Front ends implement to determine whether AutoAdmin library is installed.
*/
PR_EXTERN(PRBool) PREF_IsAutoAdminEnabled(void);
#ifdef XP_UNIX
struct fe_icon_data;
typedef void* XmStringPtr;
typedef void* KeySymPtr;
/* PR_EXTERN(void) PREF_AlterSplashIcon(struct fe_icon_data*); */
PR_EXTERN(PRBool) PREF_GetLabelAndMnemonic(char*, char**, XmStringPtr xmstring, KeySymPtr keysym);
PR_EXTERN(PRBool) PREF_GetUrl(char*, char**);
PR_EXTERN(void) PREF_SetCallbacksStatus(PRBool status);
PR_EXTERN(PrefResult) PREF_LoadLDAPPrefs(void);
#endif
NSPR_END_EXTERN_C
#endif

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

@ -1,909 +0,0 @@
/* -*- 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.1 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
*/
#ifndef npglue_h__
#define npglue_h__
#if defined(__cplusplus)
extern "C" {
#endif
#include "net.h"
#include "np.h"
#include "nppg.h"
#include "client.h"
#include "xpassert.h"
#include "ntypes.h"
#include "fe_proto.h"
#include "cvactive.h"
#include "gui.h" /* For XP_AppCodeName */
#include "merrors.h"
#include "xpgetstr.h"
#include "nsICapsManager.h"
#ifdef JAVA
#include "java.h"
#endif
#include "nppriv.h"
#include "shist.h"
#include "prefapi.h"
#include "proto.h"
#include "libmocha.h"
#include "libevent.h"
#include "layout.h" /* XXX From ../layout */
#ifdef LAYERS
#include "layers.h"
#endif /* LAYERS */
#include "nsplugin.h"
#include "nsAgg.h" /* nsPluginManager aggregates nsJVMManager */
#ifdef OJI
#include "nsjvm.h"
#else /* OJI */
/* Just define a dummy struct for nsIJVMManager. In the
plugin code, it is never actually dereferenced outside of an
`#ifdef OJI'. */
struct nsIJVMManager;
class nsHashtable;
#endif /* OJI */
#include "plstr.h"
extern int XP_PLUGIN_LOADING_PLUGIN;
extern int MK_BAD_CONNECT;
extern int XP_PLUGIN_NOT_FOUND;
extern int XP_PLUGIN_CANT_LOAD_PLUGIN;
extern int XP_PROGRESS_STARTING_JAVA;
#define NP_LOCK 1
#define NP_UNLOCK 0
#define NPTRACE(n, msg) TRACEMSG(msg)
#define RANGE_EQUALS "bytes="
/* @@@@ steal the private call from netlib */
extern void NET_SetCallNetlibAllTheTime(MWContext *context, char *caller);
extern void NET_ClearCallNetlibAllTheTime(MWContext *context, char *caller);
#if defined(XP_WIN) || defined(XP_OS2)
/* Can't include FEEMBED.H because it's full of C++ */
extern NET_StreamClass *EmbedStream(int iFormatOut, void *pDataObj, URL_Struct *pUrlData, MWContext *pContext);
extern void EmbedUrlExit(URL_Struct *pUrl, int iStatus, MWContext *pContext);
#endif
extern void NET_RegisterAllEncodingConverters(char* format_in, FO_Present_Types format_out);
/* Internal prototypes */
void
NPL_EmbedURLExit(URL_Struct *urls, int status, MWContext *cx);
void
NPL_URLExit(URL_Struct *urls, int status, MWContext *cx);
void
np_streamAsFile(np_stream* stream);
NPError
np_switchHandlers(np_instance* instance,
np_handle* newHandle,
np_mimetype* newMimeType,
char* requestedType);
NET_StreamClass*
np_newstream(URL_Struct *urls, np_handle *handle, np_instance *instance);
void
np_findPluginType(NPMIMEType type, void* pdesc, np_handle** outHandle, np_mimetype** outMimetype);
void
np_enablePluginType(np_handle* handle, np_mimetype* mimetype, XP_Bool enabled);
void
np_bindContext(NPEmbeddedApp* app, MWContext* cx);
void
np_unbindContext(NPEmbeddedApp* app, MWContext* cx);
void
np_deleteapp(MWContext* cx, NPEmbeddedApp* app);
np_instance*
np_newinstance(np_handle *handle, MWContext *cx, NPEmbeddedApp *app,
np_mimetype *mimetype, char *requestedType);
void
np_delete_instance(np_instance *instance);
void
np_recover_mochaWindow(JRIEnv * env, np_instance * instance);
XP_Bool
np_FakeHTMLStream(URL_Struct* urls, MWContext* cx, char * fakehtml);
/* Navigator plug-in API function prototypes */
/*
* Use this macro before each exported function
* (between the return address and the function
* itself), to ensure that the function has the
* right calling conventions on Win16.
*/
#ifdef XP_WIN16
#define NP_EXPORT __export
#elif defined(XP_OS2)
#define NP_EXPORT _System
#else
#define NP_EXPORT
#endif
NPError NP_EXPORT
npn_requestread(NPStream *pstream, NPByteRange *rangeList);
NPError NP_EXPORT
npn_geturlnotify(NPP npp, const char* relativeURL, const char* target, void* notifyData);
NPError NP_EXPORT
npn_getvalue(NPP npp, NPNVariable variable, void *r_value);
NPError NP_EXPORT
npn_setvalue(NPP npp, NPPVariable variable, void *r_value);
NPError NP_EXPORT
npn_geturl(NPP npp, const char* relativeURL, const char* target);
NPError NP_EXPORT
npn_posturlnotify(NPP npp, const char* relativeURL, const char *target,
uint32 len, const char *buf, NPBool file, void* notifyData);
NPError NP_EXPORT
npn_posturl(NPP npp, const char* relativeURL, const char *target, uint32 len,
const char *buf, NPBool file);
NPError
np_geturlinternal(NPP npp, const char* relativeURL, const char* target,
const char* altHost, const char* referer, PRBool forceJSEnabled,
NPBool notify, void* notifyData);
NPError
np_posturlinternal(NPP npp, const char* relativeURL, const char *target,
const char* altHost, const char* referer, PRBool forceJSEnabled,
uint32 len, const char *buf, NPBool file, NPBool notify, void* notifyData);
NPError NP_EXPORT
npn_newstream(NPP npp, NPMIMEType type, const char* window, NPStream** pstream);
int32 NP_EXPORT
npn_write(NPP npp, NPStream *pstream, int32 len, void *buffer);
NPError NP_EXPORT
npn_destroystream(NPP npp, NPStream *pstream, NPError reason);
void NP_EXPORT
npn_status(NPP npp, const char *message);
void NP_EXPORT
npn_registerwindow(nsIEventHandler* handler, nsPluginPlatformWindowRef window);
void NP_EXPORT
npn_unregisterwindow(nsIEventHandler* handler, nsPluginPlatformWindowRef window);
#if 0
int16 NP_EXPORT
npn_allocateMenuID(NPP npp, XP_Bool isSubmenu);
#endif
#if defined(XP_MAC) && !defined(powerc)
#pragma pointers_in_D0
#endif
const char* NP_EXPORT
npn_useragent(NPP npp);
#if defined(XP_MAC) && !defined(powerc)
#pragma pointers_in_A0
#endif
#if defined(XP_MAC) && !defined(powerc)
#pragma pointers_in_D0
#endif
void* NP_EXPORT
npn_memalloc (uint32 size);
#if defined(XP_MAC) && !defined(powerc)
#pragma pointers_in_A0
#endif
void NP_EXPORT
npn_memfree (void *ptr);
uint32 NP_EXPORT
npn_memflush(uint32 size);
void NP_EXPORT
npn_reloadplugins(NPBool reloadPages);
void NP_EXPORT
npn_invalidaterect(NPP npp, NPRect *invalidRect);
void NP_EXPORT
npn_invalidateregion(NPP npp, NPRegion invalidRegion);
void NP_EXPORT
npn_forceredraw(NPP npp);
#if defined(XP_MAC) && !defined(powerc)
#pragma pointers_in_D0
#endif
#if defined(OJI)
JNIEnv* NP_EXPORT
npn_getJavaEnv(void);
#else
JRIEnv* NP_EXPORT
npn_getJavaEnv(void);
#endif
#if defined(XP_MAC) && !defined(powerc)
#pragma pointers_in_A0
#endif
#if defined(XP_MAC) && !defined(powerc)
#pragma pointers_in_D0
#endif
jref NP_EXPORT
npn_getJavaPeer(NPP npp);
#if defined(XP_MAC) && !defined(powerc)
#pragma pointers_in_A0
#endif
extern NPError
npn_SetWindowSize(np_instance* instance, NPSize* pnpsz);
/* End of function prototypes */
/* this is a hack for now */
#define NP_MAXBUF (0xE000)
////////////////////////////////////////////////////////////////////////////////
class nsPluginManager : public nsIPluginManager2
{
public:
////////////////////////////////////////////////////////////////////////////
// from nsIPluginManager:
NS_IMETHOD
GetValue(nsPluginManagerVariable variable, void *value);
// (Corresponds to NPN_ReloadPlugins.)
NS_IMETHOD
ReloadPlugins(PRBool reloadPages);
// (Corresponds to NPN_UserAgent.)
NS_IMETHOD
UserAgent(const char* *result);
#ifdef NEW_PLUGIN_STREAM_API
NS_IMETHOD
GetURL(nsISupports* pluginInst,
const char* url,
const char* target = NULL,
nsIPluginStreamListener* streamListener = NULL,
nsPluginStreamType streamType = nsPluginStreamType_Normal,
const char* altHost = NULL,
const char* referrer = NULL,
PRBool forceJSEnabled = PR_FALSE);
NS_IMETHOD
PostURL(nsISupports* pluginInst,
const char* url,
PRUint32 postDataLen,
const char* postData,
PRBool isFile = PR_FALSE,
const char* target = NULL,
nsIPluginStreamListener* streamListener = NULL,
nsPluginStreamType streamType = nsPluginStreamType_Normal,
const char* altHost = NULL,
const char* referrer = NULL,
PRBool forceJSEnabled = PR_FALSE,
PRUint32 postHeadersLength = 0,
const char* postHeaders = NULL);
#else // !NEW_PLUGIN_STREAM_API
NS_IMETHOD
GetURL(nsISupports* peer, const char* url, const char* target,
void* notifyData = NULL, const char* altHost = NULL,
const char* referrer = NULL, PRBool forceJSEnabled = PR_FALSE);
NS_IMETHOD
PostURL(nsISupports* peer, const char* url, const char* target,
PRUint32 postDataLen, const char* postData,
PRBool isFile = PR_FALSE, void* notifyData = NULL,
const char* altHost = NULL, const char* referrer = NULL,
PRBool forceJSEnabled = PR_FALSE,
PRUint32 postHeadersLength = 0, const char* postHeaders = NULL);
#endif // !NEW_PLUGIN_STREAM_API
////////////////////////////////////////////////////////////////////////////
// from nsIPluginManager2:
NS_IMETHOD
BeginWaitCursor(void);
NS_IMETHOD
EndWaitCursor(void);
NS_IMETHOD
SupportsURLProtocol(const char* protocol, PRBool *result);
// This method may be called by the plugin to indicate that an error has
// occurred, e.g. that the plugin has failed or is shutting down spontaneously.
// This allows the browser to clean up any plugin-specific state.
NS_IMETHOD
NotifyStatusChange(nsIPlugin* plugin, nsresult errorStatus);
NS_IMETHOD
FindProxyForURL(const char* url, char* *result);
////////////////////////////////////////////////////////////////////////////
// New top-level window handling calls for Mac:
NS_IMETHOD
RegisterWindow(nsIEventHandler* handler, nsPluginPlatformWindowRef window);
NS_IMETHOD
UnregisterWindow(nsIEventHandler* handler, nsPluginPlatformWindowRef window);
// Menu ID allocation calls for Mac:
NS_IMETHOD
AllocateMenuID(nsIEventHandler* handler, PRBool isSubmenu, PRInt16 *result);
NS_IMETHOD
DeallocateMenuID(nsIEventHandler* handler, PRInt16 menuID);
/**
* Indicates whether this event handler has allocated the given menu ID.
*/
NS_IMETHOD
HasAllocatedMenuID(nsIEventHandler* handler, PRInt16 menuID, PRBool *result);
#if 0
// On the mac (and most likely win16), network activity can
// only occur on the main thread. Therefore, we provide a hook
// here for the case that the main thread needs to tickle itself.
// In this case, we make sure that we give up the monitor so that
// the tickle code can notify it without freezing.
NS_IMETHOD
ProcessNextEvent(PRBool *bEventHandled);
#endif
////////////////////////////////////////////////////////////////////////////
// nsPluginManager specific methods:
NS_DECL_AGGREGATED
static NS_METHOD
Create(nsISupports* outer, const nsIID& aIID, void* *aInstancePtr);
protected:
nsPluginManager(nsISupports* outer);
virtual ~nsPluginManager(void);
// aggregated interfaces:
nsIJVMManager* GetJVMMgr(const nsIID& aIID);
nsICapsManager* GetCapsManager(const nsIID& aIID);
#ifdef OJI
nsILiveconnect* GetLiveconnect(const nsIID& aIID);
#endif /* OJI */
nsISupports* fJVMMgr;
nsISupports* fMalloc;
nsISupports* fFileUtils;
PRUint16 fWaiting;
void* fOldCursor;
nsHashtable* fAllocatedMenuIDs;
nsISupports* fCapsManager;
nsISupports* fLiveconnect;
};
extern nsPluginManager* thePluginManager;
////////////////////////////////////////////////////////////////////////////////
class nsFileUtilities : public nsIFileUtilities {
public:
////////////////////////////////////////////////////////////////////////////
// from nsIFileUtilities:
NS_IMETHOD
GetProgramPath(const char* *result);
NS_IMETHOD
GetTempDirPath(const char* *result);
NS_IMETHOD
NewTempFileName(const char* prefix, PRUint32 bufLen, char* resultBuf);
////////////////////////////////////////////////////////////////////////////
// nsFileUtilities specific methods:
nsFileUtilities(nsISupports* outer);
virtual ~nsFileUtilities(void);
NS_DECL_AGGREGATED
static NS_METHOD
Create(nsISupports* outer, const nsIID& aIID, void* *aInstancePtr);
void SetProgramPath(const char* path) { fProgramPath = path; }
protected:
const char* fProgramPath;
};
////////////////////////////////////////////////////////////////////////////////
typedef struct JSContext JSContext;
class nsPluginTagInfo;
class nsPluginInstancePeer : public nsIPluginInstancePeer,
public nsILiveConnectPluginInstancePeer,
public nsIWindowlessPluginInstancePeer
{
public:
////////////////////////////////////////////////////////////////////////////
// from nsIPluginInstancePeer:
NS_IMETHOD
GetValue(nsPluginInstancePeerVariable variable, void *value);
// (Corresponds to NPP_New's MIMEType argument.)
NS_IMETHOD
GetMIMEType(nsMIMEType *result);
// (Corresponds to NPP_New's mode argument.)
NS_IMETHOD
GetMode(nsPluginMode *result);
// (Corresponds to NPN_NewStream.)
NS_IMETHOD
NewStream(nsMIMEType type, const char* target, nsIOutputStream* *result);
// (Corresponds to NPN_Status.)
NS_IMETHOD
ShowStatus(const char* message);
NS_IMETHOD
SetWindowSize(PRUint32 width, PRUint32 height);
////////////////////////////////////////////////////////////////////////////
// from nsIJRILiveConnectPluginInstancePeer:
// (Corresponds to NPN_GetJavaPeer.)
NS_IMETHOD
GetJavaPeer(jobject *result);
////////////////////////////////////////////////////////////////////////////
// from nsIWindowlessPluginInstancePeer:
// (Corresponds to NPN_InvalidateRect.)
NS_IMETHOD
InvalidateRect(nsPluginRect *invalidRect);
// (Corresponds to NPN_InvalidateRegion.)
NS_IMETHOD
InvalidateRegion(nsPluginRegion invalidRegion);
// (Corresponds to NPN_ForceRedraw.)
NS_IMETHOD
ForceRedraw(void);
////////////////////////////////////////////////////////////////////////////
// nsPluginInstancePeer specific methods:
nsPluginInstancePeer(NPP npp);
virtual ~nsPluginInstancePeer(void);
NS_DECL_ISUPPORTS
void SetPluginInstance(nsIPluginInstance* inst);
nsIPluginInstance* GetPluginInstance(void);
NPP GetNPP(void);
JSContext *GetJSContext(void);
MWContext *GetMWContext(void);
protected:
// NPP is the old plugin structure. If we were implementing this
// from scratch we wouldn't use it, but for now we're calling the old
// npglue.c routines wherever possible.
NPP fNPP;
nsIPluginInstance* fPluginInst;
nsPluginTagInfo* fTagInfo;
};
#define NS_PLUGININSTANCEPEER_CID \
{ /* 766432d0-01ba-11d2-815b-006008119d7a */ \
0x766432d0, \
0x01ba, \
0x11d2, \
{0x81, 0x5b, 0x00, 0x60, 0x08, 0x11, 0x9d, 0x7a} \
}
////////////////////////////////////////////////////////////////////////////////
class nsPluginTagInfo : public nsIPluginTagInfo2 {
public:
////////////////////////////////////////////////////////////////////////////
// from nsIPluginTagInfo:
// Get a ptr to the paired list of attribute names and values,
// returns the length of the array.
//
// Each name or value is a null-terminated string.
//
NS_IMETHOD
GetAttributes(PRUint16& n, const char*const*& names, const char*const*& values);
// Get the value for the named attribute. Returns null
// if the attribute was not set.
NS_IMETHOD
GetAttribute(const char* name, const char* *result);
////////////////////////////////////////////////////////////////////////////
// from nsIPluginTagInfo2:
// Get the type of the HTML tag that was used ot instantiate this
// plugin. Currently supported tags are EMBED, OBJECT and APPLET.
NS_IMETHOD
GetTagType(nsPluginTagType *result);
// Get the complete text of the HTML tag that was
// used to instantiate this plugin
NS_IMETHOD
GetTagText(const char * *result);
// Get a ptr to the paired list of parameter names and values,
// returns the length of the array.
//
// Each name or value is a null-terminated string.
NS_IMETHOD
GetParameters(PRUint16& n, const char*const*& names, const char*const*& values);
// Get the value for the named parameter. Returns null
// if the parameter was not set.
NS_IMETHOD
GetParameter(const char* name, const char* *result);
NS_IMETHOD
GetDocumentBase(char* *result);
// Return an encoding whose name is specified in:
// http://java.sun.com/products/jdk/1.1/docs/guide/intl/intl.doc.html#25303
NS_IMETHOD
GetDocumentEncoding(const char* *result);
NS_IMETHOD
GetAlignment(const char* *result);
NS_IMETHOD
GetWidth(PRUint32 *result);
NS_IMETHOD
GetHeight(PRUint32 *result);
NS_IMETHOD
GetBorderVertSpace(PRUint32 *result);
NS_IMETHOD
GetBorderHorizSpace(PRUint32 *result);
// Returns a unique id for the current document on which the
// plugin is displayed.
NS_IMETHOD
GetUniqueID(PRUint32 *result);
////////////////////////////////////////////////////////////////////////////
// nsPluginTagInfo specific methods:
nsPluginTagInfo(NPP npp);
virtual ~nsPluginTagInfo(void);
NS_DECL_AGGREGATED
protected:
LO_CommonPluginStruct* GetLayoutElement(void)
{
np_instance* instance = (np_instance*) npp->ndata;
NPEmbeddedApp* app = instance->app;
np_data* ndata = (np_data*) app->np_data;
return (LO_CommonPluginStruct*)ndata->lo_struct;
}
// aggregated interfaces:
nsISupports* fJVMPluginTagInfo;
NPP npp;
PRUint32 fUniqueID;
};
////////////////////////////////////////////////////////////////////////////////
class nsPluginManagerStream : public nsIOutputStream {
public:
////////////////////////////////////////////////////////////////////////////
// from nsIBaseStream:
NS_DECL_NSIBASESTREAM
NS_IMETHOD
Close(void);
////////////////////////////////////////////////////////////////////////////
// from nsIOutputStream:
/** Write data into the stream.
* @param aBuf the buffer into which the data is read
* @param aOffset the start offset of the data
* @param aCount the maximum number of bytes to read
* @return number of bytes read or an error if < 0
*/
NS_IMETHOD
Write(const char* aBuf, PRInt32 aCount, PRInt32 *resultingCount);
NS_IMETHOD Flush() {
return NS_OK;
}
////////////////////////////////////////////////////////////////////////////
// nsPluginManagerStream specific methods:
nsPluginManagerStream(NPP npp, NPStream* pstr);
virtual ~nsPluginManagerStream(void);
NS_DECL_ISUPPORTS
protected:
NPP npp;
NPStream* pstream;
};
////////////////////////////////////////////////////////////////////////////////
#ifdef NEW_PLUGIN_STREAM_API
#include "nsIPluginInputStream2.h"
class nsPluginInputStream;
// stored in the fe_data of the URL_Struct:
struct nsPluginURLData {
NPEmbeddedApp* app;
nsIPluginStreamListener* listener;
nsPluginInputStream* inStr;
};
class nsPluginInputStream : public nsIPluginInputStream2 {
public:
NS_DECL_ISUPPORTS
////////////////////////////////////////////////////////////////////////////
// from nsIBaseStream:
/** Close the stream. */
NS_IMETHOD
Close(void);
////////////////////////////////////////////////////////////////////////////
// from nsIInputStream:
/** Return the number of bytes in the stream
* @param aLength out parameter to hold the length
* of the stream. if an error occurs, the length
* will be undefined
* @return error status
*/
NS_IMETHOD
GetLength(PRInt32 *aLength);
/** Read data from the stream.
* @param aErrorCode the error code if an error occurs
* @param aBuf the buffer into which the data is read
* @param aOffset the start offset of the data
* @param aCount the maximum number of bytes to read
* @param aReadCount out parameter to hold the number of
* bytes read, eof if 0. if an error occurs, the
* read count will be undefined
* @return error status
*/
NS_IMETHOD
Read(char* aBuf, PRInt32 aOffset, PRInt32 aCount, PRInt32 *aReadCount);
////////////////////////////////////////////////////////////////////////////
// from nsIPluginInputStream:
// (Corresponds to NPStream's lastmodified field.)
NS_IMETHOD
GetLastModified(PRUint32 *result);
NS_IMETHOD
RequestRead(nsByteRange* rangeList);
////////////////////////////////////////////////////////////////////////////
// from nsIPluginInputStream2:
NS_IMETHOD
GetContentLength(PRUint32 *result);
NS_IMETHOD
GetHeaderFields(PRUint16& n, const char*const*& names, const char*const*& values);
NS_IMETHOD
GetHeaderField(const char* name, const char* *result);
////////////////////////////////////////////////////////////////////////////
// nsPluginInputStream specific methods:
nsPluginInputStream(nsIPluginStreamListener* listener,
nsPluginStreamType streamType);
virtual ~nsPluginInputStream(void);
nsIPluginStreamListener* GetListener(void) { return mListener; }
nsPluginStreamType GetStreamType(void) { return mStreamType; }
PRBool IsClosed(void) { return mClosed; }
void SetStreamInfo(URL_Struct* urls, np_stream* stream) {
mUrls = urls;
mStream = stream;
}
nsresult ReceiveData(const char* buffer, PRUint32 offset, PRUint32 len);
void Cleanup(void);
protected:
nsIPluginStreamListener* mListener;
nsPluginStreamType mStreamType;
URL_Struct* mUrls;
np_stream* mStream;
struct BufferElement {
BufferElement* next;
char* segment;
PRUint32 offset;
PRUint32 length;
};
BufferElement* mBuffer;
PRBool mClosed;
// PRUint32 mReadCursor;
// PRUint32 mBufferLength;
// PRUint32 mAmountRead;
};
#else // !NEW_PLUGIN_STREAM_API
class nsPluginStreamPeer : public nsIPluginStreamPeer2,
public nsISeekablePluginStreamPeer
{
public:
////////////////////////////////////////////////////////////////////////////
// from nsIPluginStreamPeer:
// (Corresponds to NPStream's url field.)
NS_IMETHOD
GetURL(const char* *result);
// (Corresponds to NPStream's end field.)
NS_IMETHOD
GetEnd(PRUint32 *result);
// (Corresponds to NPStream's lastmodified field.)
NS_IMETHOD
GetLastModified(PRUint32 *result);
// (Corresponds to NPStream's notifyData field.)
NS_IMETHOD
GetNotifyData(void* *result);
// (Corresponds to NPP_DestroyStream's reason argument.)
NS_IMETHOD
GetReason(nsPluginReason *result);
// (Corresponds to NPP_NewStream's MIMEType argument.)
NS_IMETHOD
GetMIMEType(nsMIMEType *result);
////////////////////////////////////////////////////////////////////////////
// from nsIPluginStreamPeer2:
NS_IMETHOD
GetContentLength(PRUint32 *result);
NS_IMETHOD
GetHeaderFieldCount(PRUint32 *result);
NS_IMETHOD
GetHeaderFieldKey(PRUint32 index, const char* *result);
NS_IMETHOD
GetHeaderField(PRUint32 index, const char* *result);
////////////////////////////////////////////////////////////////////////////
// from nsISeekablePluginStreamPeer:
// (Corresponds to NPN_RequestRead.)
NS_IMETHOD
RequestRead(nsByteRange* rangeList);
////////////////////////////////////////////////////////////////////////////
// nsPluginStreamPeer specific methods:
nsPluginStreamPeer(URL_Struct *urls, np_stream *stream);
virtual ~nsPluginStreamPeer(void);
NS_DECL_ISUPPORTS
nsIPluginStream* GetUserStream(void) {
return userStream;
}
void SetUserStream(nsIPluginStream* str) {
userStream = str;
}
void SetReason(nsPluginReason r) {
reason = r;
}
protected:
nsIPluginStream* userStream;
URL_Struct *urls;
np_stream *stream;
nsPluginReason reason;
};
#endif // !NEW_PLUGIN_STREAM_API
////////////////////////////////////////////////////////////////////////////////
#if defined(__cplusplus)
} /* extern "C" */
#endif
#endif /* npglue_h__ */

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

@ -42,7 +42,6 @@
#include "nsGtkUtils.h" // for nsGtkUtils::gdk_keyboard_get_modifiers()
#include "nsIPref.h"
#include "prefapi.h"
#include "nsGtkIMEHelper.h"
static NS_DEFINE_CID(kLookAndFeelCID, NS_LOOKANDFEEL_CID);
@ -3212,7 +3211,7 @@ static int debugWindowPrefChanged (const char *newpref, void *data)
}
}
}
return PREF_NOERROR;
return 0;
}
static void debugRegisterCallback (void)

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

@ -41,7 +41,6 @@
#include "nsWindow.h"
#include "nsIPref.h"
#include "prefapi.h"
#include "nsPhWidgetLog.h"
#include <errno.h>

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

@ -32,7 +32,6 @@
#ifdef NS_DEBUG
#include "nsIServiceManager.h"
#include "nsIPref.h"
#include "prefapi.h"
static void debug_RegisterPrefCallbacks();
@ -952,7 +951,7 @@ debug_PrefChangedCallback(const char * name,void * closure)
NS_RELEASE(prefs);
}
return PREF_NOERROR;
return 0;
}
//////////////////////////////////////////////////////////////
/* static */ void