merging from SMARTUPDATE_BRANCH

This commit is contained in:
dveditz 1998-06-07 09:23:42 +00:00
Родитель d1ad7f818d
Коммит f8633f6bea
10 изменённых файлов: 480 добавлений и 20 удалений

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

@ -8697,6 +8697,32 @@ JAR container files")
ResDef(CAPS_TARGET_URL_JAR_PACKAGER, (CAPS_MSG_BASE + 192), "\
#JARPackager")
ResDef(CAPS_TARGET_DESC_UNINSTALL, (CAPS_MSG_BASE + 193), "\
Uninstall software")
ResDef(CAPS_TARGET_DETAIL_DESC_UNINSTALL, (CAPS_MSG_BASE + 194), "\
Access required for automatic removal of previously installed software.")
ResDef(CAPS_TARGET_URL_UNINSTALL, (CAPS_MSG_BASE + 195), "\
#Uninstall")
ResDef(CAPS_TARGET_DESC_SOFTWAREINSTALL, (CAPS_MSG_BASE + 196), "\
Installing and running software on your computer")
ResDef(CAPS_TARGET_DETAIL_DESC_SOFTWAREINSTALL, (CAPS_MSG_BASE + 197), "\
Installing software on your computer's main hard disk, potentially deleting other files on the hard disk. Each time a program that has this form of access attempts to install software, it must display a dialog box that lets you choose whether to go ahead with the installation. If you go ahead, the installation program can execute any software on your computer. This potentially dangerous form of access is typically requested by an installation program after you have downloaded new software or a new version of software that you have previously installed. You should not grant this form of access unless you are installing or updating software from a reliable source.")
ResDef(CAPS_TARGET_URL_SOFTWAREINSTALL, (CAPS_MSG_BASE + 198), "\
#SoftwareInstall")
ResDef(CAPS_TARGET_DESC_SILENTINSTALL, (CAPS_MSG_BASE + 199), "\
Installing and running software without warning you")
ResDef(CAPS_TARGET_DETAIL_DESC_SILENTINSTALL, (CAPS_MSG_BASE + 200), "\
Installing software on your computer's main hard disk without giving you any warning, potentially deleting other files on the hard disk. Any software on the hard disk may be executed in the process. This is an extremely dangerous form of access. It should be granted by system administrators only.")
ResDef(CAPS_TARGET_URL_SILENTINSTALL, (CAPS_MSG_BASE + 201), "\
#SilentInstall")
END_STR(mcom_include_xp_msg_i_strings)

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

@ -8697,6 +8697,32 @@ JAR container files")
ResDef(CAPS_TARGET_URL_JAR_PACKAGER, (CAPS_MSG_BASE + 192), "\
#JARPackager")
ResDef(CAPS_TARGET_DESC_UNINSTALL, (CAPS_MSG_BASE + 193), "\
Uninstall software")
ResDef(CAPS_TARGET_DETAIL_DESC_UNINSTALL, (CAPS_MSG_BASE + 194), "\
Access required for automatic removal of previously installed software.")
ResDef(CAPS_TARGET_URL_UNINSTALL, (CAPS_MSG_BASE + 195), "\
#Uninstall")
ResDef(CAPS_TARGET_DESC_SOFTWAREINSTALL, (CAPS_MSG_BASE + 196), "\
Installing and running software on your computer")
ResDef(CAPS_TARGET_DETAIL_DESC_SOFTWAREINSTALL, (CAPS_MSG_BASE + 197), "\
Installing software on your computer's main hard disk, potentially deleting other files on the hard disk. Each time a program that has this form of access attempts to install software, it must display a dialog box that lets you choose whether to go ahead with the installation. If you go ahead, the installation program can execute any software on your computer. This potentially dangerous form of access is typically requested by an installation program after you have downloaded new software or a new version of software that you have previously installed. You should not grant this form of access unless you are installing or updating software from a reliable source.")
ResDef(CAPS_TARGET_URL_SOFTWAREINSTALL, (CAPS_MSG_BASE + 198), "\
#SoftwareInstall")
ResDef(CAPS_TARGET_DESC_SILENTINSTALL, (CAPS_MSG_BASE + 199), "\
Installing and running software without warning you")
ResDef(CAPS_TARGET_DETAIL_DESC_SILENTINSTALL, (CAPS_MSG_BASE + 200), "\
Installing software on your computer's main hard disk without giving you any warning, potentially deleting other files on the hard disk. Any software on the hard disk may be executed in the process. This is an extremely dangerous form of access. It should be granted by system administrators only.")
ResDef(CAPS_TARGET_URL_SILENTINSTALL, (CAPS_MSG_BASE + 201), "\
#SilentInstall")
END_STR(mcom_include_xp_msg_i_strings)

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

@ -370,6 +370,12 @@ ET_SetDecoderStream(MWContext * context, NET_StreamClass *stream,
extern void
ET_SetNestingUrl(MWContext * context, char * szUrl);
/*
** Set up the principals for an upcoming softupdate script.
*/
extern void
ET_StartSoftUpdate(MWContext * pContext, char *codebase);
/*
** Remember the current language version in the MochaDecoder
*/

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

@ -213,6 +213,7 @@ NET_LoadNetHelpTopic(MWContext *pContext, const char *topic);
#define HELP_PREFS_ADVANCED_CACHE "navigatr:PREFERENCES_ADVANCED_CACHE"
#define HELP_PREFS_ADVANCED_PROXIES "navigatr:PREFERENCES_ADVANCED_PROXIES"
#define HELP_PREFS_ADVANCED_DISK_SPACE "navigatr:PREFERENCES_ADVANCED_DISK_SPACE"
#define HELP_PREFS_ADVANCED_SMARTUPDATE "navigatr:PREFERENCES_ADVANCED_SMARTUPDATE"
/* Main Preferences: Conference */

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

@ -1293,6 +1293,61 @@ ET_SetDecoderStream(MWContext * pContext, NET_StreamClass *stream,
/**********************************************************************/
typedef struct {
ETEvent ce;
char *codebase;
} StartSoftUpdateStruct;
PR_STATIC_CALLBACK(void)
et_startsoftupdate_handler(StartSoftUpdateStruct *e)
{
ET_BEGIN_EVENT_HANDLER(e);
/* This decoder should have just been created to do the softupdate,
* so it shouldn't have any principals yet. */
XP_ASSERT(decoder->principals == NULL);
decoder->principals = LM_NewJSPrincipals(NULL, NULL, e->codebase);
if (decoder->principals == NULL)
return;
JSPRINCIPALS_HOLD(decoder->js_context, decoder->principals);
ET_END_EVENT_HANDLER(e);
}
PR_STATIC_CALLBACK(void)
et_startsoftupdate_destructor(StartSoftUpdateStruct *e)
{
XP_FREE(e->codebase);
XP_FREE(e);
}
/*
*/
void
ET_StartSoftUpdate(MWContext *pContext, char *codebase)
{
/* create our event object */
StartSoftUpdateStruct *pEvent = XP_NEW_ZAP(StartSoftUpdateStruct);
if (pEvent == NULL)
return;
/* do a PR_InitEvent on the event structure */
PR_InitEvent(&pEvent->ce.event, pContext,
(PRHandleEventProc)et_startsoftupdate_handler,
(PRDestroyEventProc)et_startsoftupdate_destructor);
/* fill in the non-PR fields we care about */
pEvent->ce.context = pContext;
pEvent->codebase = codebase;
/* add the event to the event queue */
et_event_to_mocha(&pEvent->ce);
}
/**********************************************************************/
PR_STATIC_CALLBACK(void)
et_clearstream_handler(DecoderStreamStruct * e)
{

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

@ -971,7 +971,8 @@ canExtendTrust(JSContext *cx, void *from, void *to)
if (from == NULL || to == NULL) {
return JS_FALSE;
}
return (JSBool)netscape_security_PrivilegeManager_canExtendTrust(
return (from == to) ||
(JSBool)netscape_security_PrivilegeManager_canExtendTrust(
env,
getPrivilegeManager(env),
from,
@ -2003,6 +2004,10 @@ LM_RegisterPrincipals(MochaDecoder *decoder, JSPrincipals *principals,
return principals;
}
if (inner == container) {
if (containerData->signedness == HAS_NO_SCRIPTS) {
lm_SetContainerPrincipals(cx, container, principals);
return principals;
}
/*
* Intersect principals and container principals,
* modifying the container principals.

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

@ -27,7 +27,7 @@
#include "lm.h"
#include "prefapi.h"
#include "VerReg.h"
#ifdef JAVA
#ifdef MOZ_SMARTUPDATE
#include "softupdt.h"
#endif
#include "gui.h" /* XP_AppPlatform */
@ -203,22 +203,19 @@ JSBool PR_CALLBACK asd_get_version
JSBool PR_CALLBACK asd_start_update
(JSContext *cx, JSObject *obj, uint argc, jsval *argv, jsval *rval)
{
*rval = BOOLEAN_TO_JSVAL(JS_FALSE);
#ifdef MOZ_SMARTUPDATE
if (argc >= 2 && JSVAL_IS_STRING(argv[0]) &&
JSVAL_IS_INT(argv[1])) {
char* url = JS_GetStringBytes(JSVAL_TO_STRING(argv[0]));
/* Bookmarks is a hack, you should really get some SmartUpdate context */
MWContext* cx = XP_FindContextOfType(NULL, MWContextBookmarks);
#ifdef JAVA
MWContext* cx = FE_GetInitContext();
XP_Bool result = SU_StartSoftwareUpdate( cx, url,
NULL, NULL, NULL, JSVAL_TO_INT(argv[1]) );
#else
XP_Bool result = FALSE;
#endif
*rval = BOOLEAN_TO_JSVAL(result);
return JS_TRUE;
}
*rval = BOOLEAN_TO_JSVAL(JS_FALSE);
#endif
return JS_TRUE;
}
@ -233,7 +230,11 @@ JSBool PR_CALLBACK asd_conditional_update
(JSContext *cx, JSObject *obj, uint argc, jsval *argv, jsval *rval)
{
REGERR status = 0;
if (argc >= 4 && JSVAL_IS_STRING(argv[0]) &&
*rval = BOOLEAN_TO_JSVAL(JS_FALSE); /*INT_TO_JSVAL(status);*/
#ifdef MOZ_SMARTUPDATE
if (argc >= 4 && JSVAL_IS_STRING(argv[0]) &&
JSVAL_IS_STRING(argv[1]) &&
JSVAL_IS_OBJECT(argv[2]) &&
JSVAL_IS_INT(argv[3]))
@ -248,20 +249,15 @@ JSBool PR_CALLBACK asd_conditional_update
asd_objToVers(cx, versObj, &req_vers);
if ( asd_compareVersion(&req_vers, &curr_vers) > 0 ) {
char* url = JS_GetStringBytes(JSVAL_TO_STRING(argv[0]));
MWContext* cx = XP_FindContextOfType(NULL, MWContextBookmarks);
#ifdef JAVA
MWContext* cx = FE_GetInitContext();
XP_Bool result = SU_StartSoftwareUpdate( cx, url,
NULL, NULL, NULL, JSVAL_TO_INT(argv[3]) );
#else
XP_Bool result = FALSE;
#endif
*rval = BOOLEAN_TO_JSVAL(result);
return JS_TRUE;
}
}
}
*rval = BOOLEAN_TO_JSVAL(JS_FALSE); /*INT_TO_JSVAL(status);*/
#endif
return JS_TRUE;
}
@ -270,7 +266,7 @@ JSBool PR_CALLBACK asd_alert
{
if (argc >= 1 && JSVAL_IS_STRING(argv[0])) {
char* msg = JS_GetStringBytes(JSVAL_TO_STRING(argv[0]));
MWContext* ctx = XP_FindSomeContext();
MWContext* ctx = FE_GetInitContext();
if (ctx)
FE_Alert(ctx, msg);

344
lib/plugin/nsjvm.cpp Normal file
Просмотреть файл

@ -0,0 +1,344 @@
/* -*- 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.
*/
////////////////////////////////////////////////////////////////////////////////
// Plugin Manager Methods to support the JVM Plugin API
////////////////////////////////////////////////////////////////////////////////
#include "npglue.h"
#include "prefapi.h"
#include "xp_str.h"
#include "libmocha.h"
#include "nsjvm.h"
#if 0 // XXX for now
static int PR_CALLBACK
JavaPrefChanged(const char *prefStr, void* data)
{
nsPluginManager* mgr = (nsPluginManager*)data;
PRBool prefBool;
PREF_GetBoolPref(prefStr, &prefBool);
mgr->SetJVMEnabled(prefBool);
return 0;
}
void
nsPluginManager::EnsurePrefCallbackRegistered(void)
{
if (fRegisteredJavaPrefChanged != PR_TRUE) {
fRegisteredJavaPrefChanged = PR_TRUE;
PREF_RegisterCallback("security.enable_java", JavaPrefChanged, this);
JavaPrefChanged("security.enable_java", this);
}
}
PRBool
nsPluginManager::GetJVMEnabled(void)
{
EnsurePrefCallbackRegistered();
return fJVM->GetJVMEnabled();
}
void
nsPluginManager::SetJVMEnabled(PRBool enable)
{
return fJVM->SetJVMEnabled(enable);
}
JVMStatus
nsPluginManager::GetJVMStatus(void)
{
EnsurePrefCallbackRegistered();
return fJVM->GetJVMStatus();
}
////////////////////////////////////////////////////////////////////////////////
// Should be in a header; must solve build-order problem first
extern void SU_Initialize(JRIEnv * env);
JVMStatus
nsPluginManager::StartupJVM()
{
// Be sure to check the prefs first before asking java to startup.
if (GetJVMStatus() == JVMStatus_Disabled) {
return JVMStatus_Disabled;
}
JVMStatus status = fJVM->StartupJVM();
if (status == JVMStatus_Ok) {
JRIEnv* env = fJVM->EnsureExecEnv();
/* initialize VersionRegistry native routines */
/* it is not an error that prevents java from starting if this stuff throws exceptions */
#ifdef MOZ_SMARTUPDATE
SU_Initialize(env);
if (JRI_ExceptionOccurred(env)) {
#if DEBUG
fJVM->PrintToConsole("LJ: SU_Initialize failed. Bugs to atotic.\n");
#endif
goto error;
}
#endif /* MOZ_SMARTUPDATE */
}
return status;
error:
#if DEBUG
JRI_ExceptionDescribe(env);
#endif
JRI_ExceptionClear(env);
ShutdownJVM();
return JVMStatus_JavaError;
}
JVMStatus
nsPluginManager::ShutdownJVM(PRBool fullShutdown = PR_TRUE)
{
return fJVM->ShutdownJVM();
}
#endif // 0
////////////////////////////////////////////////////////////////////////////////
void NP_LOADDS
nsPluginManager::BeginWaitCursor(void)
{
if (fWaiting == 0) {
#ifdef XP_PC
fOldCursor = (void*)GetCursor();
HCURSOR newCursor = LoadCursor(NULL, IDC_WAIT);
if (newCursor)
SetCursor(newCursor);
#endif
#ifdef XP_MAC
startAsyncCursors();
#endif
}
fWaiting++;
}
void NP_LOADDS
nsPluginManager::EndWaitCursor(void)
{
fWaiting--;
if (fWaiting == 0) {
#ifdef XP_PC
if (fOldCursor)
SetCursor((HCURSOR)fOldCursor);
#endif
#ifdef XP_MAC
stopAsyncCursors();
#endif
fOldCursor = NULL;
}
}
////////////////////////////////////////////////////////////////////////////////
const char* NP_LOADDS
nsPluginManager::GetProgramPath(void)
{
return fProgramPath;
}
const char* NP_LOADDS
nsPluginManager::GetTempDirPath(void)
{
// XXX I don't need a static really, the browser holds the tempDir name
// as a static string -- it's just the XP_TempDirName that strdups it.
static const char* tempDirName = NULL;
if (tempDirName == NULL)
tempDirName = XP_TempDirName();
return tempDirName;
}
nsresult NP_LOADDS
nsPluginManager::GetFileName(const char* fn, FileNameType type,
char* resultBuf, PRUint32 bufLen)
{
// XXX This should be rewritten so that we don't have to malloc the name.
XP_FileType filetype;
if (type == SIGNED_APPLET_DBNAME)
filetype = xpSignedAppletDB;
else if (type == TEMP_FILENAME)
filetype = xpTemporary;
else
return NS_ERROR_ILLEGAL_VALUE;
char* tempName = WH_FileName(fn, filetype);
if (tempName != NULL) return NS_ERROR_OUT_OF_MEMORY;
XP_STRNCPY_SAFE(resultBuf, tempName, bufLen);
XP_FREE(tempName);
return NS_OK;
}
nsresult NP_LOADDS
nsPluginManager::NewTempFileName(const char* prefix, char* resultBuf, PRUint32 bufLen)
{
// XXX This should be rewritten so that we don't have to malloc the name.
char* tempName = WH_TempName(xpTemporary, prefix);
if (tempName != NULL) return NS_ERROR_OUT_OF_MEMORY;
XP_STRNCPY_SAFE(resultBuf, tempName, bufLen);
XP_FREE(tempName);
return NS_OK;
}
PRBool NP_LOADDS
nsPluginManager::HandOffJSLock(PRThread* oldOwner, PRThread* newOwner)
{
return LM_HandOffJSLock(oldOwner, newOwner);
}
////////////////////////////////////////////////////////////////////////////
// Debugger Stuff
extern "C" HWND FindNavigatorHiddenWindow(void);
PRBool NP_LOADDS
nsPluginManager::SetDebugAgentPassword(PRInt32 pwd)
{
#if defined(XP_PC) && defined(_WIN32)
HWND win = FindNavigatorHiddenWindow();
HANDLE sem;
long err;
/* set up by aHiddenFrameClass in CNetscapeApp::InitInstance */
err = SetWindowLong(win, 0, pwd);
if (err == 0) {
// PR_LOG(NSJAVA, PR_LOG_ALWAYS,
// ("SetWindowLong returned %ld (err=%d)\n", err, GetLastError()));
/* continue so that we try to wake up the debugger */
}
sem = OpenSemaphore(SEMAPHORE_MODIFY_STATE, FALSE, "Netscape-Symantec Debugger");
if (sem) {
ReleaseSemaphore(sem, 1, NULL);
CloseHandle(sem);
}
return PR_TRUE;
#else
return PR_FALSE;
#endif
}
////////////////////////////////////////////////////////////////////////////////
#if 0 // XXX for now
PRBool
nsPluginManager::StartDebugger(JVMDebugPort port)
{
JVMError err = fJVM->StartDebugger(port);
if (err != JVMError_NoError) {
JRIEnv* env = fJVM->EnsureJNIEnv();
ReportJVMError(env, err);
return PR_FALSE;
}
return PR_TRUE;
}
void
nsPluginManager::ReportJVMError(JRIEnv* env, JVMError err)
{
MWContext* cx = XP_FindSomeContext();
char *s;
switch (err) {
case LJStartupError_NoClasses: {
const char* cp = CLASSPATH();
cp = lj_ConvertToPlatformPathList(cp);
s = PR_smprintf(XP_GetString(XP_JAVA_NO_CLASSES),
lj_jar_name, lj_jar_name,
(cp ? cp : "<none>"));
free((void*)cp);
break;
}
case LJStartupError_JavaError: {
const char* msg = GetJavaErrorString(env);
#ifdef DEBUG
JRI_ExceptionDescribe(env);
#endif
s = PR_smprintf(XP_GetString(XP_JAVA_STARTUP_FAILED),
(msg ? msg : ""));
if (msg) free((void*)msg);
break;
}
case LJStartupError_NoDebugger: {
s = PR_smprintf(XP_GetString(XP_JAVA_DEBUGGER_FAILED));
break;
}
default:
return; /* don't report anything */
}
if (s) {
FE_Alert(cx, s);
free(s);
}
}
/* stolen from java_lang_Object.h (jri version) */
#define classname_java_lang_Object "java/lang/Object"
#define name_java_lang_Object_toString "toString"
#define sig_java_lang_Object_toString "()Ljava/lang/String;"
const char*
nsPluginManager::GetJavaErrorString(JRIEnv* env)
{
/* XXX javah is a pain wrt mixing JRI and JDK native methods.
Since we need to call a method on Object, we'll do it the hard way
to avoid using javah for this.
Maybe we need a new JRI entry point for toString. Yikes! */
const char* msg;
struct java_lang_Class* classObject;
JRIMethodID toString;
struct java_lang_String* excString;
struct java_lang_Throwable* exc = JRI_ExceptionOccurred(env);
if (exc == NULL) {
return strdup(""); /* XXX better "no error" message? */
}
/* Got to do this before trying to find a class (like Object).
This is because the runtime refuses to do this with a pending
exception! I think it's broken. */
JRI_ExceptionClear(env);
classObject = (struct java_lang_Class*)
JRI_FindClass(env, classname_java_lang_Object);
toString = JRI_GetMethodID(env, classObject,
name_java_lang_Object_toString,
sig_java_lang_Object_toString);
excString = (struct java_lang_String *)
JRI_CallMethod(env)(env, JRI_CallMethod_op,
(struct java_lang_Object*)exc, toString);
/* XXX change to JRI_GetStringPlatformChars */
msg = JRI_GetStringPlatformChars(env, excString, NULL, 0);
if (msg == NULL) return NULL;
return strdup(msg);
}
#endif // 0
////////////////////////////////////////////////////////////////////////////////

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

@ -222,6 +222,7 @@ localDefPref("news.directory", "");
localDefPref("security.directory", "");
pref("autoupdate.enabled", true);
pref("autoupdate.confirm_install", false);
pref("imap.io.mac.logging", false);

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

@ -42,7 +42,7 @@ XP_BEGIN_PROTOS
typedef void * pw_ptr;
typedef enum {
typedef enum _PW_WindowType {
pwApplicationModal,
pwStandard
} PW_WindowType;