merging in changes from Classic branch. Not part of SeaMonkey build (yet)

This commit is contained in:
dveditz%netscape.com 1999-01-14 23:08:21 +00:00
Родитель 85953825e2
Коммит 8be16c2bc1
37 изменённых файлов: 1595 добавлений и 1935 удалений

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

@ -19,6 +19,6 @@ DEPTH = ../../..
MODULE = softupdt
EXPORTS = softupdt.h su_folderspec.h gdiff.h nsTrigger.h nsFolderSpec.h nsVersionInfo.h nsInstallDelete.h nsVersionRegistry.h nsInstallExecute.h nsWinProfile.h nsInstallFile.h nsWinProfileItem.h nsInstallObject.h nsWinReg.h nsInstallPatch.h nsUninstallObject.h nsWinRegItem.h nsSUError.h nsWinRegValue.h nsSoftUpdateEnums.h nsSoftwareUpdate.h
EXPORTS = softupdt.h su_folderspec.h gdiff.h su_mocha.h nsFolderSpec.h nsVersionInfo.h nsInstallDelete.h nsInstallExecute.h nsWinProfile.h nsInstallFile.h nsWinProfileItem.h nsInstallObject.h nsWinReg.h nsInstallPatch.h nsUninstallObject.h nsWinRegItem.h nsSUError.h nsWinRegValue.h nsSoftUpdateEnums.h nsSoftwareUpdate.h
include $(DEPTH)/config/rules.mk

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

@ -24,7 +24,7 @@ include $(DEPTH)/config/autoconf.mk
MODULE = softupdt
EXPORTS = softupdt.h su_folderspec.h gdiff.h nsTrigger.h nsFolderSpec.h nsVersionInfo.h nsInstallDelete.h nsVersionRegistry.h nsInstallExecute.h nsWinProfile.h nsInstallFile.h nsWinProfileItem.h nsInstallObject.h nsWinReg.h nsInstallPatch.h nsUninstallObject.h nsWinRegItem.h nsSUError.h nsWinRegValue.h nsSoftUpdateEnums.h nsSoftwareUpdate.h
EXPORTS = softupdt.h su_folderspec.h gdiff.h su_mocha.h nsFolderSpec.h nsVersionInfo.h nsInstallDelete.h nsInstallExecute.h nsWinProfile.h nsInstallFile.h nsWinProfileItem.h nsInstallObject.h nsWinReg.h nsInstallPatch.h nsUninstallObject.h nsWinRegItem.h nsSUError.h nsWinRegValue.h nsSoftUpdateEnums.h nsSoftwareUpdate.h
EXPORTS := $(addprefix $(srcdir)/, $(EXPORTS))

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

@ -21,7 +21,7 @@ IGNORE_MANIFEST=1
DEPTH=..\..\..
MODULE=softupdt
EXPORTS=softupdt.h su_folderspec.h gdiff.h nsTrigger.h nsFolderSpec.h nsVersionInfo.h nsInstallDelete.h nsVersionRegistry.h nsInstallExecute.h nsWinProfile.h nsInstallFile.h nsWinProfileItem.h nsInstallObject.h nsWinReg.h nsInstallPatch.h nsUninstallObject.h nsWinRegItem.h nsSUError.h nsWinRegValue.h nsSoftUpdateEnums.h nsSoftwareUpdate.h
EXPORTS=softupdt.h su_folderspec.h gdiff.h su_mocha.h nsFolderSpec.h nsVersionInfo.h nsInstallDelete.h nsInstallExecute.h nsWinProfile.h nsInstallFile.h nsWinProfileItem.h nsInstallObject.h nsWinReg.h nsInstallPatch.h nsUninstallObject.h nsWinRegItem.h nsSUError.h nsWinRegValue.h nsSoftUpdateEnums.h nsSoftwareUpdate.h
#//------------------------------------------------------------------------
#//

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

@ -35,20 +35,20 @@ public:
nsInstallObject(struct nsSoftwareUpdate* inSoftUpdate) {softUpdate = inSoftUpdate; }
/* Override with your set-up action */
virtual char* Prepare();
virtual char* Prepare() = 0;
/* Override with your Completion action */
virtual char* Complete();
virtual char* Complete() = 0;
/* Override with an explanatory string for the progress dialog */
virtual char* toString();
virtual char* toString() = 0;
/* Override with your clean-up function */
virtual void Abort();
virtual void Abort() = 0;
/* should these be protected? */
virtual PRBool CanUninstall();
virtual PRBool RegisterPackageNode();
virtual PRBool CanUninstall() = 0;
virtual PRBool RegisterPackageNode() = 0;
private:

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

@ -20,48 +20,43 @@
#define nsSoftUpdateEnums_h__
typedef enum nsSoftUpdateError {
/* SoftwareUpdate Errors -200 to -300 */
#define SUERR_BAD_PACKAGE_NAME -200
#define SUERR_UNEXPECTED_ERROR -201
#define SUERR_ACCESS_DENIED -202
#define SUERR_TOO_MANY_CERTIFICATES -203 /* Installer file must have 1 certificate */
#define SUERR_NO_INSTALLER_CERTIFICATE -204 /* Installer file must have a certificate */
#define SUERR_NO_CERTIFICATE -205 /* Extracted file is not signed */
#define SUERR_NO_MATCHING_CERTIFICATE -206 /* Extracted file does not match installer certificate */
#define SUERR_UNKNOWN_JAR_FILE -207 /* JAR file has not been opened */
#define SUERR_INVALID_ARGUMENTS -208 /* Bad arguments to a function */
#define SUERR_ILLEGAL_RELATIVE_PATH -209 /* Illegal relative path */
#define SUERR_USER_CANCELLED -210 /* User cancelled */
#define SUERR_INSTALL_NOT_STARTED -211
#define SUERR_SILENT_MODE_DENIED -212
#define SUERR_NO_SUCH_COMPONENT -213 /* no such component in the registry. */
#define SUERR_FILE_DOES_NOT_EXIST -214 /* File cannot be deleted as it does not exist */
#define SUERR_FILE_READ_ONLY -215 /* File cannot be deleted as it is read only. */
#define SUERR_FILE_IS_DIRECTORY -216 /* File cannot be deleted as it is a directory */
#define SUERR_NETWORK_FILE_IS_IN_USE -217 /* File on the network is in-use */
#define SUERR_APPLE_SINGLE_ERR -218 /* error in AppleSingle unpacking */
#define SUERR_INVALID_PATH_ERR -219 /* GetFolder() did not like the folderID */
#define SUERR_PATCH_BAD_DIFF -220 /* error in GDIFF patch */
#define SUERR_PATCH_BAD_CHECKSUM_TARGET -221 /* source file doesn't checksum */
#define SUERR_PATCH_BAD_CHECKSUM_RESULT -222 /* final patched file fails checksum */
#define SUERR_UNINSTALL_FAILED -223 /* error while uninstalling a package */
#define SUERR_GESTALT_UNKNOWN_ERR -5550
#define SUERR_GESTALT_INVALID_ARGUMENT -5551
/* Errors -200 to -300 */
nsSoftUpdateError_BAD_PACKAGE_NAME = -200,
nsSoftUpdateError_UNEXPECTED_ERROR = -201,
nsSoftUpdateError_ACCESS_DENIED = -202,
nsSoftUpdateError_TOO_MANY_CERTIFICATES = -203, /* Installer file must have 1 certificate */
nsSoftUpdateError_NO_INSTALLER_CERTIFICATE = -204, /* Installer file must have a certificate */
nsSoftUpdateError_NO_CERTIFICATE = -205, /* Extracted file is not signed */
nsSoftUpdateError_NO_MATCHING_CERTIFICATE = -206, /* Extracted file does not match installer certificate */
nsSoftUpdateError_UNKNOWN_JAR_FILE = -207, /* JAR file has not been opened */
nsSoftUpdateError_INVALID_ARGUMENTS = -208, /* Bad arguments to a function */
nsSoftUpdateError_ILLEGAL_RELATIVE_PATH = -209, /* Illegal relative path */
nsSoftUpdateError_USER_CANCELLED = -210, /* User cancelled */
nsSoftUpdateError_INSTALL_NOT_STARTED = -211,
nsSoftUpdateError_SILENT_MODE_DENIED = -212,
nsSoftUpdateError_NO_SUCH_COMPONENT = -213, /* no such component in the registry. */
nsSoftUpdateError_FILE_DOES_NOT_EXIST = -214, /* File cannot be deleted as it does not exist */
nsSoftUpdateError_FILE_READ_ONLY = -215, /* File cannot be deleted as it is read only. */
nsSoftUpdateError_FILE_IS_DIRECTORY = -216, /* File cannot be deleted as it is a directory */
nsSoftUpdateError_NETWORK_FILE_IS_IN_USE = -217, /* File on the network is in-use */
nsSoftUpdateError_APPLE_SINGLE_ERR = -218, /* error in AppleSingle unpacking */
nsSoftUpdateError_INVALID_PATH_ERR = -219, /* GetFolder() did not like the folderID */
nsSoftUpdateError_PATCH_BAD_DIFF = -220, /* error in GDIFF patch */
nsSoftUpdateError_PATCH_BAD_CHECKSUM_TARGET = -221, /* source file doesn't checksum */
nsSoftUpdateError_PATCH_BAD_CHECKSUM_RESULT = -222, /* final patched file fails checksum */
nsSoftUpdateError_UNINSTALL_FAILED = -223, /* error while uninstalling a package */
nsSoftUpdateError_GESTALT_UNKNOWN_ERR = -5550,
nsSoftUpdateError_GESTALT_INVALID_ARGUMENT = -5551,
} nsSoftUpdateError;
#define SU_SUCCESS 0
#define SU_REBOOT_NEEDED 999
#define nsSoftwareUpdate_SUCCESS 0
#define nsSoftwareUpdate_REBOOT_NEEDED 999
/* install types */
#define SU_LIMITED_INSTALL 0
#define SU_FULL_INSTALL 1
#define SU_NO_STATUS_DLG 2
#define SU_NO_FINALIZE_DLG 4
typedef enum nsInstallType {
nsInstallType_LIMITED_INSTALL= 0,
nsInstallType_FULL_INSTALL = 1,
nsInstallType_NO_STATUS_DLG = 2,
nsInstallType_NO_FINALIZE_DLG = 4
} nsInstallType;
typedef enum nsVersionEnum {
nsVersionEnum_MAJOR_DIFF = 4,

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

@ -20,6 +20,7 @@
#define nsSoftwareUpdate_h__
#include "prtypes.h"
#include "jsapi.h"
#include "nsHashtable.h"
#include "nsVector.h"
@ -294,12 +295,16 @@ public:
char* subdir,
PRBool forceInstall,
char* *errorMsg);
JSObject* LoadStringObject(const char* filename);
/* Uninstall */
PRInt32 Uninstall(char* packageName, char* *errorMsg);
/*******************************
*
* progress window

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

@ -1,134 +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 nsTrigger_h__
#define nsTrigger_h__
#include "prtypes.h"
#include "nsVersionInfo.h"
/**
* DEFAULT_MODE has UI, triggers conditionally
* @see StartSoftwareUpdate flags argument
*
*/
static PRInt32 DEFAULT_MODE = 0;
/**
* FORCE_MODE will install the package regardless of what was installed previously
* @see StartSoftwareUpdate flags argument
*/
static PRInt32 FORCE_MODE = 1;
/**
* SILENT_MODE will not display the UI
*/
static PRInt32 SILENT_MODE = 2;
PR_BEGIN_EXTERN_C
struct nsTrigger {
public:
/* Public Fields */
/* Public Methods */
/**
* @return true if SmartUpdate is enabled
*/
static PRBool UpdateEnabled(void);
/**
* @param componentName version registry name of the component
* @return version of the package. null if not installed, or SmartUpdate disabled
*/
static nsVersionInfo* GetVersionInfo( char* componentName );
/**
* Unconditionally starts the software update
* @param url URL of the JAR file
* @param flags SmartUpdate modifiers (SILENT_INSTALL, FORCE_INSTALL)
* @return false if SmartUpdate did not trigger
*/
static PRBool StartSoftwareUpdate( char* url, PRInt32 flags );
static PRBool StartSoftwareUpdate( char* url );
/**
* Conditionally starts the software update
* @param url URL of JAR file
* @param componentName name of component in the registry to compare
* the version against. This doesn't have to be the
* registry name of the installed package but could
* instead be a sub-component -- useful because if a
* file doesn't exist then it triggers automatically.
* @param diffLevel Specifies which component of the version must be
* different. If not supplied BLD_DIFF is assumed.
* If the diffLevel is positive the install is triggered
* if the specified version is NEWER (higher) than the
* registered version. If the diffLevel is negative then
* the install is triggered if the specified version is
* OLDER than the registered version. Obviously this
* will only have an effect if FORCE_MODE is also used.
* @param version The version that must be newer (can be a VersionInfo
* object or a char* version
* @param flags Same flags as StartSoftwareUpdate (force, silent)
*/
static PRBool
ConditionalSoftwareUpdate( char* url,
char* componentName,
PRInt32 diffLevel,
nsVersionInfo* version,
PRInt32 flags);
static PRBool ConditionalSoftwareUpdate(char* url,
char* componentName,
char* version);
/**
* Validates existence and compares versions
*
* @param regName name of component in the registry to compare
* the version against. This doesn't have to be the
* registry name of an installed package but could
* instead be a sub-component. If the named item
* has a Path property the file must exist or a
* null version is used in the comparison.
* @param version The version to compare against
*/
static PRInt32 CompareVersion( char* regName, nsVersionInfo* version );
static PRInt32 CompareVersion( char* regName, char* version );
static PRInt32 CompareVersion( char* regName, PRInt32 maj, PRInt32 min, PRInt32 rel, PRInt32 bld );
private:
/* Private Fields */
/* Private Methods */
};
PR_END_EXTERN_C
#endif /* nsTrigger_h__ */

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

@ -32,7 +32,7 @@ public:
/* Public Methods */
nsVersionInfo(PRInt32 maj, PRInt32 min, PRInt32 rel, PRInt32 bld, PRInt32 checksum);
nsVersionInfo(PRInt32 maj, PRInt32 min, PRInt32 rel, PRInt32 bld);
nsVersionInfo(char* version);
~nsVersionInfo();
@ -59,7 +59,6 @@ private:
PRInt32 minor;
PRInt32 release;
PRInt32 build;
PRInt32 check;
/* Private Methods */

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

@ -1,189 +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 nsVersionRegistry_h__
#define nsVersionRegistry_h__
#include "prtypes.h"
#include "nsVersionInfo.h"
PR_BEGIN_EXTERN_C
struct nsVersionRegistry {
public:
/* Public Fields */
/* Public Methods */
/**
* Return the physical disk path for the specified component.
* @param component Registry path of the item to look up in the Registry
* @return The disk path for the specified component; NULL indicates error
* @see VersionRegistry#checkComponent
*/
static char* componentPath( char* component );
/**
* Return the version information for the specified component.
* @param component Registry path of the item to look up in the Registry
* @return A VersionInfo object for the specified component; NULL indicates error
* @see VersionRegistry#checkComponent
*/
static nsVersionInfo* componentVersion( char* component );
static char* getDefaultDirectory( char* component );
static PRInt32 setDefaultDirectory( char* component, char* directory );
static PRInt32 installComponent( char* name, char* path, nsVersionInfo* version );
static PRInt32 installComponent( char* name, char* path, nsVersionInfo* version, PRInt32 refCount );
/**
* Delete component and all sub-components.
* @param component Registry path of the item to delete
* @return Error code
*/
static PRInt32 deleteComponent( char* component );
/**
* Check the status of a named components.
* @param component Registry path of the item to check
* @return Error code. REGERR_OK means the named component was found in
* the registry, the filepath referred to an existing file, and the
* checksum matched the physical file. Other error codes can be used to
* distinguish which of the above was not true.
*/
static PRInt32 validateComponent( char* component );
/**
* verify that the named component is in the registry (light-weight
* version of validateComponent since it does no disk access).
* @param component Registry path of the item to verify
* @return Error code. REGERR_OK means it is in the registry.
* REGERR_NOFIND will usually be the result otherwise.
*/
static PRInt32 inRegistry( char* component );
/**
* Closes the registry file.
* @return Error code
*/
static PRInt32 close();
/**
* Returns an enumeration of the Version Registry contents. Use the
* enumeration methods of the returned object to fetch individual
* elements sequentially.
*/
static void* elements();
/**
* Set the refcount of a named component.
* @param component Registry path of the item to check
* @param refcount value to be set
* @return Error code
*/
static PRInt32 setRefCount( char* component, PRInt32 refcount );
/**
* Return the refcount of a named component.
* @param component Registry path of the item to check
* @return the value of refCount
*/
static PRInt32 getRefCount( char* component );
/**
* Creates a node for the item in the Uninstall list.
* @param regPackageName Registry name of the package we are installing
* @return userPackagename User-readable package name
* @return Error code
*/
static PRInt32 uninstallCreate( char* regPackageName, char* userPackageName );
static PRInt32 uninstallCreateNode( char* regPackageName, char* userPackageName );
/**
* Adds the file as a property of the Shared Files node under the appropriate
* packageName node in the Uninstall list.
* @param regPackageName Registry name of the package installed
* @param vrName registry name of the shared file
* @return Error code
*/
static PRInt32 uninstallAddFile( char* regPackageName, char* vrName );
static PRInt32 uninstallAddFileToList( char* regPackageName, char* vrName );
/**
* Checks if the shared file exists in the uninstall list of the package
* @param regPackageName Registry name of the package installed
* @param vrName registry name of the shared file
* @return true or false
*/
static PRInt32 uninstallFileExists( char* regPackageName, char* vrName );
static PRInt32 uninstallFileExistsInList( char* regPackageName, char* vrName );
static char* getUninstallUserName( char* regPackageName );
private:
/* Private Fields */
/* Private Methods */
/**
* This class is simply static function wrappers; don't "new" one
*/
nsVersionRegistry();
/**
* Replaces all '/' with '_',in the given char*.If an '_' already exists in the
* given char*, it is escaped by adding another '_' to it.
* @param regPackageName Registry name of the package we are installing
* @return modified char*
*/
static char* convertPackageName( char* regPackageName );
};
/* XXX: We should see whether we need the following class or not.
* Because there is no Enumerator class in C++
*/
struct VerRegEnumerator {
public:
PRBool hasMoreElements();
void* nextElement();
private:
char* path;
PRInt32 state;
char* regNext();
};
PR_END_EXTERN_C
#endif /* nsVersionRegistry_h__ */

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

@ -59,6 +59,8 @@ extern int32 SU_PatchFile( char* srcfile, XP_FileType srctype,
extern int32 SU_Uninstall(char *regPackageName);
extern XP_Bool SU_IsUpdateEnabled(void);
/* This method enumerates through the packages which can be uninstalled
* by finding the packages in the shared uninstall list and the packages
* in the current communicator uninstall list.

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

@ -103,14 +103,13 @@ XP_BEGIN_PROTOS
*/
char * FE_GetDirectoryPath( su_DirSpecID folderID );
int FE_ReplaceExistingFile(char *, XP_FileType, char *, XP_FileType, XP_Bool);
void PR_CALLBACK pickDirectoryCallback(void * a);
#ifdef WIN32
BOOL WFE_IsMoveFileExBroken();
#endif
PR_EXTERN(void)
pickDirectoryCallback(void * a);
/* Makes sure that the path ends with a slash (or other platform end character)
* @return alloc'd new path that ends with a slash
*/

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

@ -0,0 +1,115 @@
/* -*- 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 "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 Communicator client code,
* released March 31, 1998.
*
* 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.
*
* Contributors:
* Daniel Veditz <dveditz@netscape.com>
*/
#ifndef SU_MOCHA_H
#define SU_MOCHA_H
#include "VerReg.h"
/* trigger modes */
#define SU_DEFAULT_MODE 0
#define SU_FORCE_MODE 1
#define SU_SILENT_MODE 2
/* version compare values */
#define SU_EQUAL 0
#define SU_BLD_DIFF 1
#define SU_REL_DIFF 2
#define SU_MINOR_DIFF 3
#define SU_MAJOR_DIFF 4
/* StartInstall() modes */
#define SU_LIMITED_INSTALL 0
#define SU_FULL_INSTALL 1
#define SU_NO_STATUS_DLG 2
#define SU_NO_FINALIZE_DLG 4
/* SoftUpdate return values */
extern char su_BAD_PACKAGE_NAME_str[];
extern char su_UNEXPECTED_ERROR_str[];
extern char su_ACCESS_DENIED_str[];
extern char su_TOO_MANY_CERTIFICATES_str[];
extern char su_NO_INSTALLER_CERTIFICATE_str[];
extern char su_NO_CERTIFICATE_str[];
extern char su_NO_MATCHING_CERTIFICATE_str[];
extern char su_UNKNOWN_JAR_FILE_str[];
extern char su_INVALID_ARGUMENTS_str[];
extern char su_ILLEGAL_RELATIVE_PATH_str[];
extern char su_USER_CANCELLED_str[];
extern char su_INSTALL_NOT_STARTED_str[];
extern char su_SILENT_MODE_DENIED_str[];
extern char su_NO_SUCH_COMPONENT_str[];
extern char su_FILE_DOES_NOT_EXIST_str[];
extern char su_FILE_READ_ONLY_str[];
extern char su_FILE_IS_DIRECTORY_str[];
extern char su_NETWORK_FILE_IS_IN_USE_str[];
extern char su_APPLE_SINGLE_ERR_str[];
extern char su_INVALID_PATH_ERR_str[];
extern char su_PATCH_BAD_DIFF_str[];
extern char su_PATCH_BAD_CHECKSUM_TARGET_str[];
extern char su_PATCH_BAD_CHECKSUM_RESULT_str[];
extern char su_UNINSTALL_FAILED_str[];
extern char su_SUCCESS_str[];
extern char su_REBOOT_NEEDED_str[];
XP_BEGIN_PROTOS
extern char su_defaultMode_str[];
extern char su_forceMode_str[];
extern char su_silentMode_str[];
extern char su_equal_str[];
extern char su_bldDiff_str[];
extern char su_relDiff_str[];
extern char su_minorDiff_str[];
extern char su_majorDiff_str[];
extern char su_major_str[];
extern char su_minor_str[];
extern char su_release_str[];
extern char su_build_str[];
extern JSClass su_version_class;
/* create Software Update objects in given JS context */
extern JSBool SU_InitMochaClasses(JSContext *cx, JSObject *obj);
/* individual class definition, not public */
extern JSBool su_DefineInstall(JSContext *cx, JSObject *obj);
extern JSBool su_DefineTrigger(JSContext *cx, JSObject *obj);
extern JSBool su_DefineVersion(JSContext *cx, JSObject *obj);
/* convert character string to VERSION structure */
extern void su_strToVersion(char * verstr, VERSION* vers);
/* compare two VERSION structures */
int su_compareVersions(VERSION* vers1, VERSION* vers2);
/* converters between VERSION structures and InstallVersion objects */
void su_versToObj(JSContext *cx, VERSION* vers, JSObject* versObj);
void su_objToVers(JSContext *cx, JSObject* versObj, VERSION* vers);
XP_END_PROTOS
#endif /* SU_MOCHA_H */

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

@ -29,3 +29,12 @@ build_classes:
# $(NMAKE) -f makefile.win java$(VERSION_NUMBER).jar
# cd $(DEPTH)\cmd\winfe\mkfiles32
# $(NMAKE) -f mozilla.mak
blnk:
$(NMAKE) -f makefile.win
cd $(MOZ_SRC)\ns
$(NMAKE) -f client.mak build_client
lnk:
cd $(MOZ_SRC)\ns
$(NMAKE) -f client.mak build_client

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

@ -36,14 +36,13 @@ endif
CSRCS = \
softupdt.c \
su_trigger.c \
su_version.c \
su_patch.c \
su_folderspec.c \
su_instl.c \
vr_java.c \
nsFolderSpec.c \
nsVersionInfo.c \
nsInstallDelete.c \
nsVersionRegistry.c \
nsInstallExecute.c \
nsWinProfile.c \
nsInstallFile.c \
@ -54,14 +53,13 @@ CSRCS = \
nsWinRegItem.c \
nsSoftwareUpdate.c \
nsWinRegValue.c \
nsTrigger.c \
$(NULL)
ifneq ($(subst /,_,$(shell uname -s)),OS2)
CSRCS += su_unix.c
else
CSRCS += os2updt.c su_wjava.c
CPPSRCS += su_win.cpp nsFolderSpec.cpp nsVersionInfo.cpp nsInstallDelete.cpp nsVersionRegistry.cpp nsInstallExecute.cpp nsWinProfile.cpp nsInstallFile.cpp nsWinProfileItem.cpp nsInstallPatch.cpp nsWinReg.cpp nsSUError.cpp nsWinRegItem.cpp nsSoftwareUpdate.cpp nsWinRegValue.cpp nsTrigger.cpp
CPPSRCS += su_win.cpp su_mocha.cpp nsFolderSpec.cpp nsUninstallObject.cpp nsVersionInfo.cpp nsInstallDelete.cpp nsInstallExecute.cpp nsWinProfile.cpp nsInstallFile.cpp nsWinProfileItem.cpp nsInstallPatch.cpp nsWinReg.cpp nsSUError.cpp nsWinRegItem.cpp nsSoftwareUpdate.cpp nsWinRegValue.cpp
endif

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

@ -45,32 +45,32 @@ endif
CSRCS = softupdt.c \
su_trigger.c \
su_version.c \
su_patch.c \
su_folderspec.c \
su_instl.c \
vr_java.c \
su_mocha.c \
nsFolderSpec.c \
nsVersionInfo.c \
nsInstallDelete.c \
nsVersionRegistry.c \
nsInstallExecute.c \
nsWinProfile.c \
nsInstallFile.c \
nsWinProfileItem.c \
nsInstallPatch.c \
nsWinReg.c \
nsSUError.c \
nsWinRegItem.c \
nsSoftwareUpdate.c \
nsSUError.c \
nsUninstallObject.c \
nsVersionInfo.c \
nsWinProfile.c \
nsWinProfileItem.c \
nsWinReg.c \
nsWinRegItem.c \
nsWinRegValue.c \
nsTrigger.c \
$(NULL)
ifneq ($(subst /,_,$(shell uname -s)),OS2)
CSRCS += su_unix.c
else
CSRCS += os2updt.c su_wjava.c
CPPSRCS += su_win.cpp nsFolderSpec.cpp nsVersionInfo.cpp nsInstallDelete.cpp nsVersionRegistry.cpp nsInstallExecute.cpp nsWinProfile.cpp nsInstallFile.cpp nsWinProfileItem.cpp nsInstallPatch.cpp nsWinReg.cpp nsSUError.cpp nsWinRegItem.cpp nsSoftwareUpdate.cpp nsWinRegValue.cpp nsTrigger.cpp
CPPSRCS += su_win.cpp su_mocha.cpp nsFolderSpec.cpp nsVersionInfo.cpp nsInstallDelete.cpp nsInstallExecute.cpp nsWinProfile.cpp nsInstallFile.cpp nsWinProfileItem.cpp nsInstallPatch.cpp nsWinReg.cpp nsSUError.cpp nsWinRegItem.cpp nsSoftwareUpdate.cpp nsWinRegValue.cpp nsUninstallObject.cpp
endif

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

@ -59,27 +59,26 @@ PDBFILE=$(LIBNAME).pdb
OBJS= \
.\$(OBJDIR)\softupdt.obj \
.\$(OBJDIR)\su_trigger.obj \
.\$(OBJDIR)\su_version.obj \
.\$(OBJDIR)\su_patch.obj \
.\$(OBJDIR)\su_folderspec.obj \
.\$(OBJDIR)\su_instl.obj \
.\$(OBJDIR)\su_mocha.obj \
.\$(OBJDIR)\su_win.obj \
.\$(OBJDIR)\vr_java.obj \
.\$(OBJDIR)\su_wjava.obj \
.\$(OBJDIR)\nsFolderSpec.obj \
.\$(OBJDIR)\nsVersionInfo.obj \
.\$(OBJDIR)\nsInstallDelete.obj \
.\$(OBJDIR)\nsVersionRegistry.obj \
.\$(OBJDIR)\nsInstallExecute.obj \
.\$(OBJDIR)\nsWinProfile.obj \
.\$(OBJDIR)\nsInstallFile.obj \
.\$(OBJDIR)\nsWinProfileItem.obj \
.\$(OBJDIR)\nsInstallPatch.obj \
.\$(OBJDIR)\nsWinReg.obj \
.\$(OBJDIR)\nsSUError.obj \
.\$(OBJDIR)\nsWinRegItem.obj \
.\$(OBJDIR)\nsSoftwareUpdate.obj \
.\$(OBJDIR)\nsSUError.obj \
.\$(OBJDIR)\nsUninstallObject.obj \
.\$(OBJDIR)\nsVersionInfo.obj \
.\$(OBJDIR)\nsWinProfile.obj \
.\$(OBJDIR)\nsWinProfileItem.obj \
.\$(OBJDIR)\nsWinReg.obj \
.\$(OBJDIR)\nsWinRegItem.obj \
.\$(OBJDIR)\nsWinRegValue.obj \
.\$(OBJDIR)\nsTrigger.obj \
$(NULL)

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

@ -30,7 +30,10 @@
#include "prthread.h"
#include "nsFolderSpec.h"
#include "nsSUError.h"
extern "C" {
#include "su_folderspec.h"
}
#ifndef MAX_PATH
#if defined(XP_WIN) || defined(XP_OS2)
@ -125,7 +128,7 @@ char* nsFolderSpec::SetDirectoryPath(char* *errorMsg)
{
if ((folderID == NULL) || (versionRegistryPath == NULL)) {
*errorMsg = SU_GetErrorMsg3("Invalid arguments to the constructor",
nsSoftUpdateError_INVALID_ARGUMENTS);
SUERR_INVALID_ARGUMENTS);
return NULL;
}
@ -206,7 +209,7 @@ char* nsFolderSpec::PickDefaultDirectory(char* *errorMsg)
urlPath = NativePickDefaultDirectory();
if (urlPath == NULL)
*errorMsg = SU_GetErrorMsg3(folderID, nsSoftUpdateError_INVALID_PATH_ERR);
*errorMsg = SU_GetErrorMsg3(folderID, SUERR_INVALID_PATH_ERR);
return urlPath;
}
@ -229,7 +232,7 @@ int nsFolderSpec::NativeGetDirectoryPath()
switch (folderDirSpecID)
{
case eBadFolder:
return nsSoftUpdateError_INVALID_PATH_ERR;
return SUERR_INVALID_PATH_ERR;
case eCurrentUserFolder:
{
@ -260,7 +263,7 @@ int nsFolderSpec::NativeGetDirectoryPath()
return 0;
}
return nsSoftUpdateError_INVALID_PATH_ERR;
return SUERR_INVALID_PATH_ERR;
}
/* GetNativePath

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

@ -24,9 +24,8 @@
#include "softupdt.h"
#include "su_instl.h"
#include "nsInstallDelete.h"
#include "nsVersionRegistry.h"
#include "nsSUError.h"
#include "NSReg.h"
#include "VerReg.h"
#include "nsPrivilegeManager.h"
#include "nsTarget.h"
@ -55,13 +54,13 @@ nsInstallDelete::nsInstallDelete(nsSoftwareUpdate* inSoftUpdate,
registryName = NULL;
finalFile = NULL;
deleteStatus = DELETE_FILE;
FILE_DOES_NOT_EXIST = nsSoftUpdateError_FILE_DOES_NOT_EXIST;
FILE_READ_ONLY = nsSoftUpdateError_FILE_READ_ONLY;
FILE_IS_DIRECTORY = nsSoftUpdateError_FILE_IS_DIRECTORY;
FILE_DOES_NOT_EXIST = SUERR_FILE_DOES_NOT_EXIST;
FILE_READ_ONLY = SUERR_FILE_READ_ONLY;
FILE_IS_DIRECTORY = SUERR_FILE_IS_DIRECTORY;
if ((inFolder == NULL) || (inSoftUpdate == NULL)) {
*errorMsg = SU_GetErrorMsg3("Invalid arguments to the constructor",
nsSoftUpdateError_INVALID_ARGUMENTS);
SUERR_INVALID_ARGUMENTS);
return;
}
@ -81,13 +80,13 @@ nsInstallDelete::nsInstallDelete(nsSoftwareUpdate* inSoftUpdate,
{
finalFile = NULL;
deleteStatus = DELETE_COMPONENT;
FILE_DOES_NOT_EXIST = nsSoftUpdateError_FILE_DOES_NOT_EXIST;
FILE_READ_ONLY = nsSoftUpdateError_FILE_READ_ONLY;
FILE_IS_DIRECTORY = nsSoftUpdateError_FILE_IS_DIRECTORY;
FILE_DOES_NOT_EXIST = SUERR_FILE_DOES_NOT_EXIST;
FILE_READ_ONLY = SUERR_FILE_READ_ONLY;
FILE_IS_DIRECTORY = SUERR_FILE_IS_DIRECTORY;
if ((inRegistryName == NULL) || (inSoftUpdate == NULL)) {
*errorMsg = SU_GetErrorMsg3("Invalid arguments to the constructor",
nsSoftUpdateError_INVALID_ARGUMENTS);
SUERR_INVALID_ARGUMENTS);
return;
}
@ -119,7 +118,7 @@ char* nsInstallDelete::Complete()
if (softUpdate == NULL) {
return SU_GetErrorMsg3("Invalid arguments to the constructor",
nsSoftUpdateError_INVALID_ARGUMENTS);
SUERR_INVALID_ARGUMENTS);
}
nsPrivilegeManager* privMgr = nsPrivilegeManager::getPrivilegeManager();
@ -130,19 +129,19 @@ char* nsInstallDelete::Complete()
execTarget = nsTarget::findTarget(INSTALL_PRIV);
if (execTarget != NULL) {
if (!privMgr->enablePrivilege( execTarget, softUpdate->GetPrincipal(), 1 )) {
return SU_GetErrorMsg3("Permssion was denied", nsSoftUpdateError_ACCESS_DENIED);
return SU_GetErrorMsg3("Permssion was denied", SUERR_ACCESS_DENIED);
}
}
}
if (deleteStatus == DELETE_COMPONENT) {
err = nsVersionRegistry::deleteComponent(registryName);
err = VR_Remove( registryName );
}
char *msg = NULL;
if ((deleteStatus == DELETE_FILE) || (err == REGERR_OK)) {
if (finalFile != NULL) {
err = NativeComplete();
if ((err != 0) && (err != nsSoftUpdateError_FILE_DOES_NOT_EXIST)) {
if ((err != 0) && (err != SUERR_FILE_DOES_NOT_EXIST)) {
if (execTarget != NULL) {
privMgr->revertPrivilege( execTarget, 1 );
}
@ -189,7 +188,7 @@ void nsInstallDelete::processInstallDelete(char* *errorMsg)
if (target != NULL) {
/* XXX: we need a way to indicate that a dialog box should appear.*/
if (!privMgr->enablePrivilege( target, softUpdate->GetPrincipal(), 1 )) {
*errorMsg = SU_GetErrorMsg3("Permssion was denied", nsSoftUpdateError_ACCESS_DENIED);
*errorMsg = SU_GetErrorMsg3("Permssion was denied", SUERR_ACCESS_DENIED);
return;
}
}
@ -197,15 +196,23 @@ void nsInstallDelete::processInstallDelete(char* *errorMsg)
if (deleteStatus == DELETE_COMPONENT) {
/* Check if the component is in the registry */
err = nsVersionRegistry::inRegistry(registryName);
err = VR_InRegistry(registryName);
if (err != REGERR_OK) {
char *msg = NULL;
msg = SU_GetString1(SU_ERROR_NOT_IN_REGISTRY, registryName);
*errorMsg = SU_GetErrorMsg3(msg, nsSoftUpdateError_NO_SUCH_COMPONENT);
*errorMsg = SU_GetErrorMsg3(msg, SUERR_NO_SUCH_COMPONENT);
XP_FREEIF(msg);
return;
} else {
finalFile = nsVersionRegistry::componentPath(registryName);
}
else
{
finalFile = (char*)XP_CALLOC(MAXREGPATHLEN, sizeof(char));
err = VR_GetPath( registryName, MAXREGPATHLEN, finalFile );
if (err != REGERR_OK)
{
XP_FREEIF(finalFile);
finalFile=NULL;
}
}
}
@ -215,11 +222,11 @@ void nsInstallDelete::processInstallDelete(char* *errorMsg)
char *msg = NULL;
if (err == 0) {
/* System.out.println("File exists and is not read only" + finalFile);*/
} else if (err == nsSoftUpdateError_FILE_DOES_NOT_EXIST) {
msg = SU_GetString1(nsSoftUpdateError_FILE_DOES_NOT_EXIST, finalFile);
} else if (err == nsSoftUpdateError_FILE_READ_ONLY) {
} else if (err == SUERR_FILE_DOES_NOT_EXIST) {
msg = SU_GetString1(SUERR_FILE_DOES_NOT_EXIST, finalFile);
} else if (err == SUERR_FILE_READ_ONLY) {
msg = SU_GetString1(SU_ERROR_FILE_READ_ONLY, finalFile);
} else if (err == nsSoftUpdateError_FILE_IS_DIRECTORY) {
} else if (err == SUERR_FILE_IS_DIRECTORY) {
msg = SU_GetString1(SU_ERROR_FILE_IS_DIRECTORY, finalFile);
} else {
msg = SU_GetString1(SU_ERROR_UNEXPECTED, finalFile);
@ -259,7 +266,7 @@ int nsInstallDelete::NativeComplete()
{
#ifdef XP_PC
/* REMIND need to move function to generic XP file */
err = nsSoftwareUpdate_REBOOT_NEEDED;
err = SU_REBOOT_NEEDED;
su_DeleteOldFileLater( (char*)finalFile );
#endif
}

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

@ -54,7 +54,7 @@ nsInstallExecute::nsInstallExecute(nsSoftwareUpdate* inSoftUpdate,
if ((inArgs == NULL) || (inJarLocation == NULL) ||
(inSoftUpdate == NULL)) {
*errorMsg = SU_GetErrorMsg3("Invalid arguments to the constructor",
nsSoftUpdateError_INVALID_ARGUMENTS);
SUERR_INVALID_ARGUMENTS);
return;
}
@ -73,7 +73,7 @@ nsInstallExecute::nsInstallExecute(nsSoftwareUpdate* inSoftUpdate,
if (target != NULL) {
/* XXX: we need a way to indicate that a dialog box should appear.*/
if (!privMgr->enablePrivilege( target, softUpdate->GetPrincipal(), 1 )) {
*errorMsg = SU_GetErrorMsg3("Permssion was denied", nsSoftUpdateError_ACCESS_DENIED);
*errorMsg = SU_GetErrorMsg3("Permssion was denied", SUERR_ACCESS_DENIED);
return;
}
}
@ -101,7 +101,7 @@ char* nsInstallExecute::Prepare(void)
if (softUpdate == NULL) {
return SU_GetErrorMsg3("Invalid arguments to the constructor",
nsSoftUpdateError_INVALID_ARGUMENTS);
SUERR_INVALID_ARGUMENTS);
}
nsPrivilegeManager* privMgr = nsPrivilegeManager::getPrivilegeManager();
nsTarget* impersonation = nsTarget::findTarget(IMPERSONATOR);
@ -111,7 +111,7 @@ char* nsInstallExecute::Prepare(void)
execTarget = nsTarget::findTarget(INSTALL_PRIV);
if (execTarget != NULL) {
if (!privMgr->enablePrivilege( execTarget, softUpdate->GetPrincipal(), 1 )) {
return SU_GetErrorMsg3("Permssion was denied", nsSoftUpdateError_ACCESS_DENIED);
return SU_GetErrorMsg3("Permssion was denied", SUERR_ACCESS_DENIED);
}
}
}
@ -123,7 +123,7 @@ char* nsInstallExecute::Prepare(void)
}
if (tempFile == NULL) {
return SU_GetErrorMsg3("Extraction of JAR file failed", nsSoftUpdateError_ACCESS_DENIED);
return SU_GetErrorMsg3("Extraction of JAR file failed", SUERR_ACCESS_DENIED);
}
#ifdef XP_MAC
@ -149,7 +149,7 @@ char* nsInstallExecute::Complete(void)
if (softUpdate == NULL) {
return SU_GetErrorMsg3("Invalid arguments to the constructor",
nsSoftUpdateError_INVALID_ARGUMENTS);
SUERR_INVALID_ARGUMENTS);
}
nsPrivilegeManager* privMgr = nsPrivilegeManager::getPrivilegeManager();
nsTarget* impersonation = nsTarget::findTarget(IMPERSONATOR);
@ -159,7 +159,7 @@ char* nsInstallExecute::Complete(void)
execTarget = nsTarget::findTarget(INSTALL_PRIV);
if (execTarget != NULL) {
if (!privMgr->enablePrivilege( execTarget, softUpdate->GetPrincipal(), 1 )) {
return SU_GetErrorMsg3("Permssion was denied", nsSoftUpdateError_ACCESS_DENIED);
return SU_GetErrorMsg3("Permssion was denied", SUERR_ACCESS_DENIED);
}
}
}

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

@ -22,9 +22,8 @@
#include "su_instl.h"
#include "nsSoftUpdateEnums.h"
#include "NSReg.h"
#include "VerReg.h"
#include "nsInstallFile.h"
#include "nsVersionRegistry.h"
#include "nsSUError.h"
#include "nsPrivilegeManager.h"
@ -91,7 +90,7 @@ nsInstallFile::nsInstallFile(nsSoftwareUpdate* inSoftUpdate,
(folderSpec == NULL) || (inSoftUpdate == NULL) ||
(inVInfo == NULL)) {
*errorMsg = SU_GetErrorMsg3("Invalid arguments to the constructor",
nsSoftUpdateError_INVALID_ARGUMENTS);
SUERR_INVALID_ARGUMENTS);
return;
}
vrName = new nsString(inVRName);
@ -116,7 +115,7 @@ nsInstallFile::nsInstallFile(nsSoftwareUpdate* inSoftUpdate,
nsTarget* install_target = nsTarget::findTarget(INSTALL_PRIV);
if (install_target != NULL) {
if (!privMgr->enablePrivilege(install_target, softUpdate->GetPrincipal(), 1)) {
*errorMsg = SU_GetErrorMsg3("Permssion was denied", nsSoftUpdateError_ACCESS_DENIED);
*errorMsg = SU_GetErrorMsg3("Permssion was denied", SUERR_ACCESS_DENIED);
return;
}
}
@ -171,17 +170,17 @@ char* nsInstallFile::Prepare()
if (softUpdate == NULL) {
errorMsg = SU_GetErrorMsg3("nsSoftwareUpdate object is null",
nsSoftUpdateError_INVALID_ARGUMENTS);
SUERR_INVALID_ARGUMENTS);
return errorMsg;
}
if (jarLocation == NULL) {
errorMsg = SU_GetErrorMsg3("JAR file is null",
nsSoftUpdateError_INVALID_ARGUMENTS);
SUERR_INVALID_ARGUMENTS);
return errorMsg;
}
if (finalFile == NULL) {
errorMsg = SU_GetErrorMsg3("folderSpec's full path (finalFile) was null",
nsSoftUpdateError_INVALID_ARGUMENTS);
SUERR_INVALID_ARGUMENTS);
return errorMsg;
}
@ -194,7 +193,7 @@ char* nsInstallFile::Prepare()
if ((privMgr != NULL) && (impersonation != NULL)) {
PRBool allowed = privMgr->enablePrivilege(impersonation, 1);
if (allowed == PR_FALSE) {
errorMsg = SU_GetErrorMsg3("Permssion was denied", nsSoftUpdateError_ACCESS_DENIED);
errorMsg = SU_GetErrorMsg3("Permssion was denied", SUERR_ACCESS_DENIED);
return errorMsg;
}
@ -203,7 +202,7 @@ char* nsInstallFile::Prepare()
if (install_target != NULL) {
PRBool allowed = privMgr->enablePrivilege(install_target, softUpdate->GetPrincipal(), 1);
if (allowed == PR_FALSE) {
errorMsg = SU_GetErrorMsg3("Permssion was denied", nsSoftUpdateError_ACCESS_DENIED);
errorMsg = SU_GetErrorMsg3("Permssion was denied", SUERR_ACCESS_DENIED);
return errorMsg;
}
}
@ -238,15 +237,15 @@ char* nsInstallFile::Complete()
if (softUpdate == NULL) {
return SU_GetErrorMsg3("nsSoftwareUpdate object is null",
nsSoftUpdateError_INVALID_ARGUMENTS);
SUERR_INVALID_ARGUMENTS);
}
if (vrName == NULL) {
return SU_GetErrorMsg3("version registry name is null",
nsSoftUpdateError_INVALID_ARGUMENTS);
SUERR_INVALID_ARGUMENTS);
}
if (finalFile == NULL) {
return SU_GetErrorMsg3("folderSpec's full path (finalFile) is null",
nsSoftUpdateError_INVALID_ARGUMENTS);
SUERR_INVALID_ARGUMENTS);
}
/* Check the security for our target */
@ -266,7 +265,7 @@ char* nsInstallFile::Complete()
if (!privMgr->enablePrivilege(install_target,
softUpdate->GetPrincipal(), 1)) {
return SU_GetErrorMsg3("Permssion was denied",
nsSoftUpdateError_ACCESS_DENIED);
SUERR_ACCESS_DENIED);
}
}
}
@ -294,54 +293,78 @@ char* nsInstallFile::Complete()
// Register file and log for Uninstall
if ( 0 == err || nsSoftwareUpdate_REBOOT_NEEDED == err ) {
if ( 0 == err || SU_REBOOT_NEEDED == err ) {
// we ignore all registry errors because they're not
// important enough to abort an otherwise OK install.
if (!bChild) {
int found;
if (regPackageName) {
char *reg_package_name = regPackageName->ToNewCString();
found = nsVersionRegistry::uninstallFileExists(reg_package_name, vr_name);
found = VR_UninstallFileExistsInList( reg_package_name, vr_name );
delete reg_package_name;
} else {
found = nsVersionRegistry::uninstallFileExists("", vr_name);
found = VR_UninstallFileExistsInList( "", vr_name );
}
if (found != REGERR_OK)
bUpgrade = PR_FALSE;
else
bUpgrade = PR_TRUE;
} else if (REGERR_OK == nsVersionRegistry::inRegistry(vr_name)) {
} else if (REGERR_OK == VR_InRegistry(vr_name)) {
bUpgrade = PR_TRUE;
} else {
bUpgrade = PR_FALSE;
}
refCount = nsVersionRegistry::getRefCount(vr_name);
err = VR_GetRefCount( vr_name, &refCount );
if ( err != REGERR_OK )
{
refCount = 0;
}
if (!bUpgrade) {
if (refCount != 0) {
if (refCount != 0)
{
rc = 1 + refCount;
nsVersionRegistry::installComponent(vr_name, final_file, versionInfo, rc );
} else {
VR_Install( vr_name, final_file, versionInfo->toString(), PR_FALSE );
VR_SetRefCount( vr_name, rc );
}
else
{
if (replace)
nsVersionRegistry::installComponent(vr_name, final_file, versionInfo, 2);
{
VR_Install( vr_name, final_file, versionInfo->toString(), PR_FALSE);
VR_SetRefCount( vr_name, 2 );
}
else
nsVersionRegistry::installComponent(vr_name, final_file, versionInfo, 1);
{
VR_Install( vr_name, final_file, versionInfo->toString(), PR_FALSE );
VR_SetRefCount( vr_name, 1 );
}
}
} else if (bUpgrade) {
if (refCount == 0) {
nsVersionRegistry::installComponent(vr_name, final_file, versionInfo, 1);
} else {
nsVersionRegistry::installComponent(vr_name, final_file, versionInfo );
}
else if (bUpgrade)
{
if (refCount == 0)
{
VR_Install( vr_name, final_file, versionInfo->toString(), PR_FALSE );
VR_SetRefCount( vr_name, 1 );
}
else
{
VR_Install( vr_name, final_file, versionInfo->toString(), PR_FALSE );
VR_SetRefCount( vr_name, 0 );
}
}
if ( !bChild && !bUpgrade ) {
if (regPackageName) {
char *reg_package_name = regPackageName->ToNewCString();
nsVersionRegistry::uninstallAddFile(reg_package_name, vr_name);
VR_UninstallAddFileToList( reg_package_name, vr_name );
delete reg_package_name;
} else {
nsVersionRegistry::uninstallAddFile("", vr_name);
VR_UninstallAddFileToList( "", vr_name );
}
}
}
@ -446,7 +469,7 @@ int nsInstallFile::NativeComplete()
/* File already exists, need to remove the original */
result = FE_ReplaceExistingFile(currentName, xpURL, finalName, xpURL, force);
if ( result == nsSoftwareUpdate_REBOOT_NEEDED ) {
if ( result == SU_REBOOT_NEEDED ) {
#ifdef XP_WIN16
if (!utilityScheduled) {
utilityScheduled = PR_TRUE;

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

@ -32,12 +32,13 @@
#include "nsInstallPatch.h"
#include "nsSoftUpdateEnums.h"
#include "nsVersionRegistry.h"
#include "nsSUError.h"
#include "nsTarget.h"
#include "nsPrivilegeManager.h"
#include "VerReg.h"
extern int SU_ERROR_NO_SUCH_COMPONENT;
extern int SU_ERROR_INSTALL_FILE_UNEXPECTED;
extern int SU_ERROR_UNEXPECTED;
@ -61,6 +62,8 @@ nsInstallPatch::nsInstallPatch(nsSoftwareUpdate* inSoftUpdate,
char* inJarLocation,
char* *errorMsg) : nsInstallObject(inSoftUpdate)
{
int err;
vrName = NULL;
versionInfo = NULL;
jarLocation = NULL;
@ -70,16 +73,25 @@ nsInstallPatch::nsInstallPatch(nsSoftwareUpdate* inSoftUpdate,
*errorMsg = checkPrivileges();
if (*errorMsg != NULL)
return;
targetfile = nsVersionRegistry::componentPath( vrName );
targetfile = (char*)XP_CALLOC(MAXREGPATHLEN, sizeof(char));
err = VR_GetPath( vrName, MAXREGPATHLEN, targetfile );
if (err != REGERR_OK)
{
XP_FREEIF(targetfile);
targetfile = NULL;
}
if ( targetfile == NULL ) {
*errorMsg = SU_GetErrorMsg4(SU_ERROR_NO_SUCH_COMPONENT,
nsSoftUpdateError_NO_SUCH_COMPONENT);
SUERR_NO_SUCH_COMPONENT);
return;
}
if ((inVRName == NULL) || (inJarLocation == NULL)) {
*errorMsg = SU_GetErrorMsg3("Invalid arguments to the constructor",
nsSoftUpdateError_INVALID_ARGUMENTS);
SUERR_INVALID_ARGUMENTS);
return;
}
@ -106,7 +118,7 @@ nsInstallPatch::nsInstallPatch(nsSoftwareUpdate* inSoftUpdate,
if ((inVRName == NULL) || (inJarLocation == NULL) || (folderSpec == NULL)) {
*errorMsg = SU_GetErrorMsg3("Invalid arguments to the constructor",
nsSoftUpdateError_INVALID_ARGUMENTS);
SUERR_INVALID_ARGUMENTS);
return;
}
@ -147,7 +159,7 @@ char* nsInstallPatch::Prepare(void)
if ((softUpdate == NULL) || (jarLocation == NULL) || (targetfile == NULL)) {
return SU_GetErrorMsg3("Invalid arguments to the constructor",
nsSoftUpdateError_INVALID_ARGUMENTS);
SUERR_INVALID_ARGUMENTS);
}
nsPrivilegeManager* privMgr = nsPrivilegeManager::getPrivilegeManager();
@ -160,7 +172,7 @@ char* nsInstallPatch::Prepare(void)
priv = nsTarget::findTarget(INSTALL_PRIV);
if (priv != NULL) {
if (!privMgr->enablePrivilege( priv, softUpdate->GetPrincipal(), 1)) {
return SU_GetErrorMsg3("Permssion was denied", nsSoftUpdateError_ACCESS_DENIED);
return SU_GetErrorMsg3("Permssion was denied", SUERR_ACCESS_DENIED);
}
}
}
@ -181,17 +193,17 @@ char* nsInstallPatch::Prepare(void)
{
if ( XP_STAT_READONLY( statinfo ) )
{
errorMsg = SU_GetErrorMsg4(SU_ERROR_UNEXPECTED, nsSoftUpdateError_FILE_READ_ONLY);
errorMsg = SU_GetErrorMsg4(SU_ERROR_UNEXPECTED, SUERR_FILE_READ_ONLY);
}
else if (!S_ISDIR(statinfo.st_mode))
{
errorMsg = SU_GetErrorMsg4(SU_ERROR_UNEXPECTED, nsSoftUpdateError_FILE_IS_DIRECTORY);
errorMsg = SU_GetErrorMsg4(SU_ERROR_UNEXPECTED, SUERR_FILE_IS_DIRECTORY);
}
}
else
{
errorMsg = SU_GetErrorMsg4(SU_ERROR_UNEXPECTED, nsSoftUpdateError_FILE_DOES_NOT_EXIST);
errorMsg = SU_GetErrorMsg4(SU_ERROR_UNEXPECTED, SUERR_FILE_DOES_NOT_EXIST);
}
XP_FREEIF(targetfileURL);
@ -225,7 +237,7 @@ char* nsInstallPatch::Prepare(void)
softUpdate->patchList->Put( &ikey, patchedfile );
} else {
char *msg = XP_Cat(targetfile, " not patched");
errorMsg = SU_GetErrorMsg3(msg, nsSoftUpdateError_INVALID_ARGUMENTS);
errorMsg = SU_GetErrorMsg3(msg, SUERR_INVALID_ARGUMENTS);
}
if ( deleteOldSrc ) {
@ -247,7 +259,7 @@ char* nsInstallPatch::Complete(void)
if ((softUpdate == NULL) || (targetfile == NULL) ||
(patchedfile == NULL) || (vrName == NULL)) {
return SU_GetErrorMsg3("Invalid arguments to the complete method",
nsSoftUpdateError_INVALID_ARGUMENTS);
SUERR_INVALID_ARGUMENTS);
}
if ((errorMsg = checkPrivileges()) != NULL)
@ -261,9 +273,8 @@ char* nsInstallPatch::Complete(void)
err = NativeReplace( targetfile, patchedfile );
if ( 0 == err || nsSoftwareUpdate_REBOOT_NEEDED == err ) {
err = nsVersionRegistry::installComponent( vrName, targetfile, versionInfo);
if ( 0 == err || SU_REBOOT_NEEDED == err ) {
err = VR_Install( vrName, targetfile, versionInfo->toString(), PR_FALSE );
if ( err != 0 ) {
char *msg = XP_Cat("Install component failed ", targetfile);
errorMsg = SU_GetErrorMsg3(msg, err);
@ -325,7 +336,7 @@ char* nsInstallPatch::checkPrivileges(void)
priv = nsTarget::findTarget(INSTALL_PRIV);
if (priv != NULL) {
if (!privMgr->enablePrivilege( priv, softUpdate->GetPrincipal(), 1)) {
return SU_GetErrorMsg3("Permssion was denied", nsSoftUpdateError_ACCESS_DENIED);
return SU_GetErrorMsg3("Permssion was denied", SUERR_ACCESS_DENIED);
}
}
}
@ -369,7 +380,7 @@ char* nsInstallPatch::NativePatch( char* srcfile, char* diffURL, char* *errorMsg
err = SU_PatchFile( srcURL, xpURL, diffURL, xpURL, newfileURL, xpURL );
} else {
/* String conversions failed -- probably out of memory */
err = nsSoftUpdateError_INVALID_ARGUMENTS;
err = SUERR_INVALID_ARGUMENTS;
}
@ -416,7 +427,7 @@ int nsInstallPatch::NativeReplace( char* target, char* newfile )
/* file still exists */
err = FE_ReplaceExistingFile( pNew, xpURL, pTarget, xpURL, 0 );
#ifdef XP_WIN16
if ( err == nsSoftwareUpdate_REBOOT_NEEDED && !utilityScheduled) {
if ( err == SU_REBOOT_NEEDED && !utilityScheduled) {
utilityScheduled = TRUE;
FE_ScheduleRenameUtility();
}

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

@ -33,7 +33,6 @@
#include "nsInstallExecute.h"
#include "nsInstallPatch.h"
#include "nsUninstallObject.h"
#include "nsVersionRegistry.h"
#include "nsSUError.h"
#include "nsWinProfile.h"
#include "nsWinReg.h"
@ -49,7 +48,7 @@
#include "xpgetstr.h"
#include "pw_public.h"
#include "NSReg.h"
#include "VerReg.h"
#ifdef XP_MAC
#include "su_aplsn.h"
@ -83,15 +82,16 @@ extern int SU_INSTALLWIN_TITLE;
extern int SU_INSTALLWIN_UNPACKING;
extern int SU_INSTALLWIN_INSTALLING;
PR_BEGIN_EXTERN_C
static PRBool su_PathEndsWithSeparator(char* path, char* sep);
#ifdef XP_PC
extern char * WH_TempFileName(int type, const char * prefix,
const char * extension);
#endif
PR_BEGIN_EXTERN_C
static PRBool su_PathEndsWithSeparator(char* path, char* sep);
extern uint32 FE_DiskSpaceAvailable (MWContext *context, const char *lpszPath );
@ -246,6 +246,7 @@ nsFolderSpec* nsSoftwareUpdate::GetFolder(char* folderID, char* *errorMsg)
*/
nsFolderSpec* nsSoftwareUpdate::GetComponentFolder(char* component)
{
int err;
char* dir;
char* qualifiedComponent;
@ -258,10 +259,25 @@ nsFolderSpec* nsSoftwareUpdate::GetComponentFolder(char* component)
return NULL;
}
dir = nsVersionRegistry::getDefaultDirectory( qualifiedComponent );
dir = (char*)XP_CALLOC(MAXREGPATHLEN, sizeof(char));
err = VR_GetDefaultDirectory( qualifiedComponent, MAXREGPATHLEN, dir );
if (err != REGERR_OK)
{
XP_FREEIF(dir);
dir = NULL;
}
if ( dir == NULL )
{
dir = (char*)XP_CALLOC(MAXREGPATHLEN, sizeof(char));
err = VR_GetPath( qualifiedComponent, MAXREGPATHLEN, dir );
if (err != REGERR_OK)
{
XP_FREEIF(dir);
dir = NULL;
}
if ( dir == NULL ) {
dir = nsVersionRegistry::componentPath( qualifiedComponent );
if ( dir != NULL ) {
int i;
@ -379,7 +395,7 @@ char* nsSoftwareUpdate::ExtractJARFile(char* inJarLocation,
{
if (zigPtr == NULL) {
*errorMsg = SU_GetErrorMsg3("JAR file has not been opened",
nsSoftUpdateError_UNKNOWN_JAR_FILE );
SUERR_UNKNOWN_JAR_FILE );
return NULL;
}
@ -426,12 +442,12 @@ char* nsSoftwareUpdate::ExtractJARFile(char* inJarLocation,
if (!unsigned_jar_enabled) {
msg = PR_sprintf_append(msg, "Missing certificate for %s",
inJarLocation);
*errorMsg = SU_GetErrorMsg3(msg, nsSoftUpdateError_NO_CERTIFICATE);
*errorMsg = SU_GetErrorMsg3(msg, SUERR_NO_CERTIFICATE);
}
} else {
msg = PR_sprintf_append(msg, "Missing certificate for %s", inJarLocation);
*errorMsg = SU_GetErrorMsg3(msg,
nsSoftUpdateError_NO_MATCHING_CERTIFICATE);
SUERR_NO_MATCHING_CERTIFICATE);
}
PR_FREEIF(msg);
}
@ -453,11 +469,11 @@ void
nsSoftwareUpdate::ParseFlags(int flags)
{
if ((flags & nsInstallType_NO_STATUS_DLG) == nsInstallType_NO_STATUS_DLG)
if ((flags & SU_NO_STATUS_DLG) == SU_NO_STATUS_DLG)
{
bShowProgress = PR_FALSE;
}
if ((flags & nsInstallType_NO_FINALIZE_DLG) == nsInstallType_NO_FINALIZE_DLG)
if ((flags & SU_NO_FINALIZE_DLG) == SU_NO_FINALIZE_DLG)
{
bShowFinalize = PR_FALSE;
}
@ -487,7 +503,7 @@ PRInt32 nsSoftwareUpdate::StartInstall(char* vrPackageName,
PRInt32 flags,
char* *errorMsg)
{
int errcode= nsSoftwareUpdate_SUCCESS;
int errcode= SU_SUCCESS;
*errorMsg = NULL;
ResetError();
ParseFlags(flags);
@ -497,8 +513,8 @@ PRInt32 nsSoftwareUpdate::StartInstall(char* vrPackageName,
if ( vrPackageName == NULL )
{
*errorMsg = SU_GetErrorMsg4(SU_ERROR_BAD_PACKAGE_NAME,
nsSoftUpdateError_INVALID_ARGUMENTS );
return nsSoftUpdateError_INVALID_ARGUMENTS;
SUERR_INVALID_ARGUMENTS );
return SUERR_INVALID_ARGUMENTS;
}
packageName = GetQualifiedPackageName( vrPackageName );
@ -552,7 +568,16 @@ PRInt32 nsSoftwareUpdate::StartInstall(char* vrPackageName,
}
// set up default package folder, if any
char* path = nsVersionRegistry::getDefaultDirectory( packageName );
int err;
char* path = (char*)XP_CALLOC(MAXREGPATHLEN, sizeof(char));
err = VR_GetDefaultDirectory( packageName, MAXREGPATHLEN, path );
if (err != REGERR_OK)
{
XP_FREEIF(path);
path = NULL;
}
if ( path != NULL ) {
packageFolder = new nsFolderSpec("Installed", path, userPackageName);
XP_FREEIF(path);
@ -610,7 +635,7 @@ void nsSoftwareUpdate::UserApproved()
PRInt32 nsSoftwareUpdate::FinalizeInstall(char* *errorMsg)
{
PRBool rebootNeeded = PR_FALSE;
int result = nsSoftwareUpdate_SUCCESS;
int result = SU_SUCCESS;
*errorMsg = NULL;
@ -644,7 +669,7 @@ PRInt32 nsSoftwareUpdate::FinalizeInstall(char* *errorMsg)
confdlg = NULL;
if (userChoice != 1) {
AbortInstall();
return saveError(nsSoftUpdateError_USER_CANCELLED);
return saveError(SUERR_USER_CANCELLED);
}
}
@ -674,7 +699,7 @@ PRInt32 nsSoftwareUpdate::FinalizeInstall(char* *errorMsg)
if ( bUninstallPackage )
{
nsVersionRegistry::uninstallCreate(packageName, userPackageName);
VR_UninstallCreateNode( packageName, userPackageName );
}
PRUint32 i=0;
@ -685,27 +710,25 @@ PRInt32 nsSoftwareUpdate::FinalizeInstall(char* *errorMsg)
*errorMsg = ie->Complete();
if (*errorMsg != NULL) {
ie->Abort();
return nsSoftUpdateError_UNEXPECTED_ERROR;
return SUERR_UNEXPECTED_ERROR;
}
SetProgressDialogThermo(++count);
}
// add overall version for package
if ( (versionInfo != NULL) && (bRegisterPackage))
{
result = nsVersionRegistry::installComponent(packageName, NULL,
versionInfo);
result = VR_Install( packageName, NULL, versionInfo->toString(), PR_FALSE );
// Register default package folder if set
if ( packageFolder != NULL )
{
nsVersionRegistry::setDefaultDirectory( packageName, packageFolder->toString() );
VR_SetDefaultDirectory( packageName, packageFolder->toString() );
}
}
CleanUp();
if (result == nsSoftwareUpdate_SUCCESS && rebootNeeded)
result = nsSoftwareUpdate_REBOOT_NEEDED;
if (result == SU_SUCCESS && rebootNeeded)
result = SU_REBOOT_NEEDED;
saveError( result );
return result;
@ -804,20 +827,21 @@ PRInt32 nsSoftwareUpdate::AddSubcomponent(char* name,
char* *errorMsg)
{
nsInstallFile* ie;
int result = nsSoftwareUpdate_SUCCESS;
int result = SU_SUCCESS;
int err; /* does not get saved */
*errorMsg = NULL;
char *new_name;
if ( jarSource == NULL || (XP_STRLEN(jarSource) == 0) ) {
*errorMsg = SU_GetErrorMsg3("No Jar Source",
nsSoftUpdateError_INVALID_ARGUMENTS );
return nsSoftUpdateError_INVALID_ARGUMENTS;
SUERR_INVALID_ARGUMENTS );
return SUERR_INVALID_ARGUMENTS;
}
if ( folderSpec == NULL ) {
*errorMsg = SU_GetErrorMsg3("folderSpec is NULL ",
nsSoftUpdateError_INVALID_ARGUMENTS );
return nsSoftUpdateError_INVALID_ARGUMENTS;
SUERR_INVALID_ARGUMENTS );
return SUERR_INVALID_ARGUMENTS;
}
@ -839,7 +863,7 @@ PRInt32 nsSoftwareUpdate::AddSubcomponent(char* name,
if (*errorMsg != NULL)
{
return nsSoftUpdateError_BAD_PACKAGE_NAME;
return SUERR_BAD_PACKAGE_NAME;
}
if ( (relativePath == NULL) || (XP_STRLEN(relativePath) == 0) ) {
@ -851,9 +875,17 @@ PRInt32 nsSoftwareUpdate::AddSubcomponent(char* name,
PRBool versionNewer = PR_FALSE;
if ( (forceInstall == PR_FALSE ) &&
(version != NULL) &&
( nsVersionRegistry::validateComponent( new_name ) == 0 ) )
( VR_ValidateComponent( new_name ) == 0 ) )
{
nsVersionInfo* oldVersion = nsVersionRegistry::componentVersion(new_name);
VERSION versionStruct;
err = VR_GetVersion( new_name, &versionStruct );
nsVersionInfo* oldVersion = new nsVersionInfo(versionStruct.major,
versionStruct.minor,
versionStruct.release,
versionStruct.build);
if ( version->compareTo( oldVersion ) != nsVersionEnum_EQUAL )
versionNewer = PR_TRUE;
@ -876,7 +908,7 @@ PRInt32 nsSoftwareUpdate::AddSubcomponent(char* name,
}
}
if (*errorMsg != NULL) {
result = nsSoftUpdateError_UNEXPECTED_ERROR;
result = SUERR_UNEXPECTED_ERROR;
}
XP_FREEIF (new_name);
@ -891,7 +923,7 @@ PRInt32 nsSoftwareUpdate::AddSubcomponent(char* name,
*/
PRInt32 nsSoftwareUpdate::Execute(char* jarSource, char* *errorMsg, char* args)
{
int errcode = nsSoftwareUpdate_SUCCESS;
int errcode = SU_SUCCESS;
errcode = SanityCheck(errorMsg);
@ -904,11 +936,11 @@ PRInt32 nsSoftwareUpdate::Execute(char* jarSource, char* *errorMsg, char* args)
nsInstallExecute* ie = new nsInstallExecute(this, jarSource, errorMsg, args);
if (*errorMsg != NULL) {
errcode = nsSoftUpdateError_ACCESS_DENIED;
errcode = SUERR_ACCESS_DENIED;
} else {
*errorMsg = ScheduleForInstall( ie );
if (*errorMsg != NULL) {
errcode = nsSoftUpdateError_UNEXPECTED_ERROR;
errcode = SUERR_UNEXPECTED_ERROR;
}
}
@ -942,7 +974,7 @@ PRInt32 nsSoftwareUpdate::Gestalt(char* selectorStr, int* os_err,
if ((selectorStr == NULL) ||
(XP_STRLEN(selectorStr) != 4))
{
*os_err = nsSoftUpdateError_GESTALT_UNKNOWN_ERR; /* gestaltUnknownErr */
*os_err = SUERR_GESTALT_UNKNOWN_ERR; /* gestaltUnknownErr */
goto fail;
}
XP_MEMCPY(&selector, selectorStr, 4);
@ -952,7 +984,7 @@ PRInt32 nsSoftwareUpdate::Gestalt(char* selectorStr, int* os_err,
}
goto fail; /* Drop through to failure */
#else
*os_err = nsSoftUpdateError_GESTALT_INVALID_ARGUMENT;
*os_err = SUERR_GESTALT_INVALID_ARGUMENT;
goto fail;
#endif
@ -973,12 +1005,12 @@ PRInt32 nsSoftwareUpdate::Patch(char* regName,
char* patchname,
char* *errorMsg)
{
int errcode = nsSoftwareUpdate_SUCCESS;
int errcode = SU_SUCCESS;
if ( regName == NULL || patchname == NULL ) {
*errorMsg = SU_GetErrorMsg3("regName or patchName is NULL ",
nsSoftUpdateError_INVALID_ARGUMENTS );
return saveError( nsSoftUpdateError_INVALID_ARGUMENTS );
SUERR_INVALID_ARGUMENTS );
return saveError( SUERR_INVALID_ARGUMENTS );
}
errcode = SanityCheck(errorMsg);
@ -992,7 +1024,7 @@ PRInt32 nsSoftwareUpdate::Patch(char* regName,
char* rname = GetQualifiedRegName( regName, errorMsg);
if (*errorMsg != NULL)
{
errcode = nsSoftUpdateError_BAD_PACKAGE_NAME;
errcode = SUERR_BAD_PACKAGE_NAME;
saveError( errcode );
return errcode;
}
@ -1000,11 +1032,11 @@ PRInt32 nsSoftwareUpdate::Patch(char* regName,
nsInstallPatch* ip = new nsInstallPatch(this, rname, version, patchname,
errorMsg);
if (*errorMsg != NULL) {
errcode = nsSoftUpdateError_ACCESS_DENIED;
errcode = SUERR_ACCESS_DENIED;
} else {
*errorMsg = ScheduleForInstall( ip );
if (*errorMsg != NULL) {
errcode = nsSoftUpdateError_UNEXPECTED_ERROR;
errcode = SUERR_UNEXPECTED_ERROR;
}
}
XP_FREEIF( rname );
@ -1028,11 +1060,11 @@ PRInt32 nsSoftwareUpdate::Patch(char* regName,
if ( folder == NULL || regName == NULL ||
XP_STRLEN(regName) == 0 || patchname == NULL ) {
*errorMsg = SU_GetErrorMsg3("folder or regName or patchName is NULL ",
nsSoftUpdateError_INVALID_ARGUMENTS );
return saveError( nsSoftUpdateError_INVALID_ARGUMENTS );
SUERR_INVALID_ARGUMENTS );
return saveError( SUERR_INVALID_ARGUMENTS );
}
int errcode = nsSoftwareUpdate_SUCCESS;
int errcode = SU_SUCCESS;
errcode = SanityCheck(errorMsg);
@ -1045,7 +1077,7 @@ PRInt32 nsSoftwareUpdate::Patch(char* regName,
char* rname = GetQualifiedRegName( regName, errorMsg );
if (*errorMsg != NULL)
{
errcode = nsSoftUpdateError_BAD_PACKAGE_NAME;
errcode = SUERR_BAD_PACKAGE_NAME;
saveError( errcode );
return errcode;
}
@ -1055,11 +1087,11 @@ PRInt32 nsSoftwareUpdate::Patch(char* regName,
patchname, folder, filename,
errorMsg );
if (*errorMsg != NULL) {
errcode = nsSoftUpdateError_ACCESS_DENIED;
errcode = SUERR_ACCESS_DENIED;
} else {
*errorMsg = ScheduleForInstall( ip );
if (*errorMsg != NULL) {
errcode = nsSoftUpdateError_UNEXPECTED_ERROR;
errcode = SUERR_UNEXPECTED_ERROR;
}
}
XP_FREEIF ( rname );
@ -1077,7 +1109,7 @@ PRInt32 nsSoftwareUpdate::DeleteFile(nsFolderSpec* folder,
char* relativeFileName,
char* *errorMsg)
{
int errcode = nsSoftwareUpdate_SUCCESS;
int errcode = SU_SUCCESS;
errcode = SanityCheck(errorMsg);
@ -1090,16 +1122,16 @@ PRInt32 nsSoftwareUpdate::DeleteFile(nsFolderSpec* folder,
nsInstallDelete* id = new nsInstallDelete(this, folder, relativeFileName,
errorMsg);
if (*errorMsg != NULL) {
errcode = nsSoftUpdateError_ACCESS_DENIED;
errcode = SUERR_ACCESS_DENIED;
} else {
*errorMsg = ScheduleForInstall( id );
if (*errorMsg != NULL) {
errcode = nsSoftUpdateError_UNEXPECTED_ERROR;
errcode = SUERR_UNEXPECTED_ERROR;
}
}
/* XXX: who set FILE_DOES_NOT_EXIST errcode ?? */
if (errcode == nsSoftUpdateError_FILE_DOES_NOT_EXIST) {
errcode = nsSoftwareUpdate_SUCCESS;
if (errcode == SUERR_FILE_DOES_NOT_EXIST) {
errcode = SU_SUCCESS;
}
saveError( errcode );
return errcode;
@ -1115,7 +1147,7 @@ PRInt32 nsSoftwareUpdate::DeleteFile(nsFolderSpec* folder,
*/
PRInt32 nsSoftwareUpdate::DeleteComponent(char* registryName, char* *errorMsg)
{
int errcode = nsSoftwareUpdate_SUCCESS;
int errcode = SU_SUCCESS;
errcode = SanityCheck(errorMsg);
@ -1128,23 +1160,23 @@ PRInt32 nsSoftwareUpdate::DeleteComponent(char* registryName, char* *errorMsg)
char* rname = GetQualifiedRegName( registryName, errorMsg );
if (*errorMsg != NULL)
{
errcode = nsSoftUpdateError_UNEXPECTED_ERROR;
errcode = SUERR_UNEXPECTED_ERROR;
saveError( errcode );
return errcode;
}
nsInstallDelete* id = new nsInstallDelete(this, NULL, rname, errorMsg);
if (*errorMsg != NULL) {
errcode = nsSoftUpdateError_ACCESS_DENIED;
errcode = SUERR_ACCESS_DENIED;
} else {
*errorMsg = ScheduleForInstall( id );
if (*errorMsg != NULL) {
errcode = nsSoftUpdateError_UNEXPECTED_ERROR;
errcode = SUERR_UNEXPECTED_ERROR;
}
}
/* XXX: who set FILE_DOES_NOT_EXIST errcode ?? */
if (errcode == nsSoftUpdateError_FILE_DOES_NOT_EXIST) {
errcode = nsSoftwareUpdate_SUCCESS;
if (errcode == SUERR_FILE_DOES_NOT_EXIST) {
errcode = SU_SUCCESS;
}
XP_FREEIF (rname );
@ -1260,21 +1292,21 @@ PRInt32 nsSoftwareUpdate::AddDirectory(char* name,
char* *errorMsg)
{
nsInstallFile* ie = NULL;
int result = nsSoftwareUpdate_SUCCESS;
int result = SU_SUCCESS;
char *qualified_name = NULL;
*errorMsg = NULL;
if ( jarSource == NULL || XP_STRLEN(jarSource) == 0 || folderSpec == NULL ) {
*errorMsg = SU_GetErrorMsg3("folder or Jarsource is NULL ",
nsSoftUpdateError_INVALID_ARGUMENTS );
return saveError(nsSoftUpdateError_INVALID_ARGUMENTS);
SUERR_INVALID_ARGUMENTS );
return saveError(SUERR_INVALID_ARGUMENTS);
}
if (packageName == NULL) {
// probably didn't call StartInstall()
*errorMsg = SU_GetErrorMsg4(SU_ERROR_BAD_PACKAGE_NAME_AS,
nsSoftUpdateError_BAD_PACKAGE_NAME );
return saveError(nsSoftUpdateError_BAD_PACKAGE_NAME);
SUERR_BAD_PACKAGE_NAME );
return saveError(SUERR_BAD_PACKAGE_NAME);
}
if ((name == NULL) || (XP_STRLEN(name) == 0)) {
@ -1286,7 +1318,7 @@ PRInt32 nsSoftwareUpdate::AddDirectory(char* name,
if (*errorMsg != NULL)
{
return nsSoftUpdateError_BAD_PACKAGE_NAME;
return SUERR_BAD_PACKAGE_NAME;
}
@ -1314,14 +1346,23 @@ PRInt32 nsSoftwareUpdate::AddDirectory(char* name,
char* fullRegName = XP_Cat(qualified_name, "/", matchingFiles[i]);
if ( (forceInstall == PR_FALSE) && (version != NULL) &&
(nsVersionRegistry::validateComponent(fullRegName) == 0) ) {
(VR_ValidateComponent(fullRegName) == 0) )
{
// Only install if newer
nsVersionInfo* oldVer = nsVersionRegistry::componentVersion(fullRegName);
VERSION versionStruct;
VR_GetVersion( fullRegName, &versionStruct );
nsVersionInfo* oldVer = new nsVersionInfo(versionStruct.major,
versionStruct.minor,
versionStruct.release,
versionStruct.build);
bInstall = ( version->compareTo(oldVer) > 0 );
if (oldVer)
delete oldVer;
} else {
// file doesn't exist or "forced" install
bInstall = PR_TRUE;
@ -1360,7 +1401,7 @@ PRInt32 nsSoftwareUpdate::AddDirectory(char* name,
XP_FREEIF(subdir);
XP_FREEIF(qualified_name);
if (errorMsg != NULL) {
result = nsSoftUpdateError_UNEXPECTED_ERROR;
result = SUERR_UNEXPECTED_ERROR;
}
saveError( result );
@ -1370,7 +1411,7 @@ PRInt32 nsSoftwareUpdate::AddDirectory(char* name,
/* Uninstall */
PRInt32 nsSoftwareUpdate::Uninstall(char* packageName, char* *errorMsg)
{
int errcode = nsSoftwareUpdate_SUCCESS;
int errcode = SU_SUCCESS;
errcode = SanityCheck(errorMsg);
@ -1384,7 +1425,7 @@ PRInt32 nsSoftwareUpdate::Uninstall(char* packageName, char* *errorMsg)
nsUninstallObject* u = new nsUninstallObject( this, rname, errorMsg );
if (*errorMsg != NULL) {
errcode = nsSoftUpdateError_UNEXPECTED_ERROR;
errcode = SUERR_UNEXPECTED_ERROR;
} else {
ScheduleForInstall( u );
}
@ -1462,19 +1503,19 @@ PRInt32 nsSoftwareUpdate::InitializeInstallerCertificate(char* *errorMsg)
if ((prinArray == NULL) || (prinArray->GetSize() == 0)) {
if (!unsigned_jar_enabled) {
*errorMsg = SU_GetErrorMsg4(SU_ERROR_NO_CERTIFICATE,
nsSoftUpdateError_NO_INSTALLER_CERTIFICATE);
errcode = nsSoftUpdateError_NO_INSTALLER_CERTIFICATE;
SUERR_NO_INSTALLER_CERTIFICATE);
errcode = SUERR_NO_INSTALLER_CERTIFICATE;
}
} else if (prinArray->GetSize() > 1) {
*errorMsg = SU_GetErrorMsg4(SU_ERROR_TOO_MANY_CERTIFICATES,
nsSoftUpdateError_TOO_MANY_CERTIFICATES);
errcode = nsSoftUpdateError_TOO_MANY_CERTIFICATES;
SUERR_TOO_MANY_CERTIFICATES);
errcode = SUERR_TOO_MANY_CERTIFICATES;
} else {
prin = (nsPrincipal *)prinArray->Get(0);
if ((prin == NULL) && (!unsigned_jar_enabled)) {
*errorMsg = SU_GetErrorMsg4(SU_ERROR_NO_CERTIFICATE,
nsSoftUpdateError_NO_INSTALLER_CERTIFICATE);
errcode = nsSoftUpdateError_NO_INSTALLER_CERTIFICATE;
SUERR_NO_INSTALLER_CERTIFICATE);
errcode = SUERR_NO_INSTALLER_CERTIFICATE;
}
}
@ -1548,11 +1589,11 @@ PRInt32 nsSoftwareUpdate::RequestSecurityPrivileges(char* *errorMsg)
if (!ret_val) {
*errorMsg = "Permssion was denied";
return nsSoftUpdateError_ACCESS_DENIED;
return SUERR_ACCESS_DENIED;
} else {
*errorMsg = NULL;
}
return nsSoftwareUpdate_SUCCESS;
return SU_SUCCESS;
}
/**
@ -1560,7 +1601,7 @@ PRInt32 nsSoftwareUpdate::RequestSecurityPrivileges(char* *errorMsg)
*/
PRInt32 nsSoftwareUpdate::saveError(PRInt32 errcode)
{
if ( errcode != nsSoftwareUpdate_SUCCESS )
if ( errcode != SU_SUCCESS )
lastError = errcode;
return errcode;
}
@ -1651,7 +1692,7 @@ char* nsSoftwareUpdate::GetQualifiedRegName(char* name, char**errorMsg)
if (BadRegName(name))
{
*errorMsg = SU_GetErrorMsg4(nsSoftUpdateError_BAD_PACKAGE_NAME, nsSoftUpdateError_BAD_PACKAGE_NAME);
*errorMsg = SU_GetErrorMsg4(SUERR_BAD_PACKAGE_NAME, SUERR_BAD_PACKAGE_NAME);
name = NULL;
}
@ -1670,10 +1711,10 @@ char* nsSoftwareUpdate::VerifyJSObject(void* jsObj)
char *errorMsg = NULL;
/* Get the object's class, and verify that it is of class SoftUpdate
*/
#ifdef XXX
JSObject * jsobj;
JSClass * jsclass;
jsobj = (JSObject *) jsObj;
#ifdef XXX
/* jsobj = JSJ_ExtractInternalJSObject(env, (HObject*)a);*/
jsclass = JS_GetClass(jsobj);
/* XXX Fix it */
@ -1703,24 +1744,24 @@ PRInt32 nsSoftwareUpdate::OpenJARFile(char* *errorMsg)
if (!enabled) {
*errorMsg = SU_GetErrorMsg4(SU_ERROR_BAD_JS_ARGUMENT,
nsSoftUpdateError_INVALID_ARGUMENTS);
return nsSoftUpdateError_INVALID_ARGUMENTS;
SUERR_INVALID_ARGUMENTS);
return SUERR_INVALID_ARGUMENTS;
}
jarFile = jarName;
if (jarFile == NULL) {
/* error already signaled */
*errorMsg = SU_GetErrorMsg3("No Jar Source",
nsSoftUpdateError_INVALID_ARGUMENTS);
return nsSoftUpdateError_INVALID_ARGUMENTS;
SUERR_INVALID_ARGUMENTS);
return SUERR_INVALID_ARGUMENTS;
}
/* Open and initialize the JAR archive */
jarData = SOB_new();
if ( jarData == NULL ) {
*errorMsg = SU_GetErrorMsg3("No Jar Source",
nsSoftUpdateError_UNEXPECTED_ERROR);
return nsSoftUpdateError_UNEXPECTED_ERROR;
SUERR_UNEXPECTED_ERROR);
return SUERR_UNEXPECTED_ERROR;
}
err = SOB_pass_archive( ZIG_F_GUESS,
jarFile,
@ -1728,7 +1769,7 @@ PRInt32 nsSoftwareUpdate::OpenJARFile(char* *errorMsg)
jarData );
if ( err != 0 ) {
if (unsigned_jar_enabled)
return nsSoftwareUpdate_SUCCESS;
return SU_SUCCESS;
*errorMsg = SU_GetErrorMsg4(SU_ERROR_VERIFICATION_FAILED, err);
return err;
}
@ -1739,12 +1780,12 @@ PRInt32 nsSoftwareUpdate::OpenJARFile(char* *errorMsg)
(void**)&installerJarName, &installerJarNameLength);
if (err != 0) {
if (unsigned_jar_enabled)
return nsSoftwareUpdate_SUCCESS;
return SU_SUCCESS;
*errorMsg = SU_GetErrorMsg4(SU_ERROR_MISSING_INSTALLER, err);
return err;
}
zigPtr = jarData;
return nsSoftwareUpdate_SUCCESS;
return SU_SUCCESS;
}
void nsSoftwareUpdate::CloseJARFile()
@ -1803,7 +1844,7 @@ char* nsSoftwareUpdate::NativeExtractJARFile(char* inJarLocation,
if (jarPath == NULL) {
/* out-of-memory error already signaled */
*errorMsg = SU_GetErrorMsg4(SU_ERROR_OUT_OF_MEMORY,
nsSoftUpdateError_UNEXPECTED_ERROR);
SUERR_UNEXPECTED_ERROR);
return NULL;
}
@ -2165,16 +2206,16 @@ nsSoftwareUpdate::SanityCheck(char**errorMsg)
{
if ( packageName == NULL )
{
*errorMsg = SU_GetErrorMsg4(nsSoftUpdateError_INSTALL_NOT_STARTED, nsSoftUpdateError_INSTALL_NOT_STARTED);
return nsSoftUpdateError_INSTALL_NOT_STARTED;
*errorMsg = SU_GetErrorMsg4(SUERR_INSTALL_NOT_STARTED, SUERR_INSTALL_NOT_STARTED);
return SUERR_INSTALL_NOT_STARTED;
}
if (bUserCancelled)
{
AbortInstall();
saveError(nsSoftUpdateError_USER_CANCELLED);
*errorMsg = SU_GetErrorMsg4(nsSoftUpdateError_USER_CANCELLED, nsSoftUpdateError_USER_CANCELLED);
return nsSoftUpdateError_USER_CANCELLED;
saveError(SUERR_USER_CANCELLED);
*errorMsg = SU_GetErrorMsg4(SUERR_USER_CANCELLED, SUERR_USER_CANCELLED);
return SUERR_USER_CANCELLED;
}
return 0;
@ -2214,6 +2255,140 @@ nsSoftwareUpdate::BadRegName(char* regName)
return PR_FALSE;
}
static JSClass stringObject = {
"global", 0,
JS_PropertyStub, JS_PropertyStub, JS_PropertyStub, JS_PropertyStub,
JS_EnumerateStub, JS_ResolveStub, JS_ConvertStub, JS_FinalizeStub
};
JSObject*
nsSoftwareUpdate::LoadStringObject(const char* filename)
{
int err = 0;
XP_File fp;
XP_StatStruct stats;
long fileLength;
JSObject *stringObj = NULL;
MWContext *cx;
/* XXX FIX: We should use the context passed into nsSoftwareUpdate via the env var! dft */
cx = XP_FindContextOfType(NULL, MWContextJava);
stringObj = JS_NewObject(cx->mocha_context, &stringObject, NULL, NULL);
if (stringObj == NULL) return NULL;
/* Now lets open of the file and read it into a buffer */
stats.st_size = 0;
if ( stat(filename, (struct stat *) &stats) == -1 )
return NULL;
fileLength = stats.st_size;
if (fileLength <= 1)
return NULL;
fp = XP_FileOpen(filename, xpURL, "r");
if (fp)
{
char* readBuf = (char *) XP_ALLOC(fileLength * sizeof(char) + 1);
char* buffPtr;
char* buffEnd;
char* valuePtr;
char* tempPtr;
if (readBuf)
{
fileLength = XP_FileRead(readBuf, fileLength, fp);
readBuf[fileLength+1] = 0;
buffPtr = readBuf;
buffEnd = readBuf + fileLength;
while (buffPtr < buffEnd)
{
/* Loop until we come across a interesting char */
if (XP_IS_SPACE(*buffPtr))
{
buffPtr++;
}
else
{
/* cool we got something. lets find its value, and then add it to the js object */
valuePtr = XP_STRCHR(buffPtr, '=');
if (valuePtr != NULL)
{
/* lets check to see if we hit a new line prior to this = */
tempPtr = XP_STRCHR(buffPtr, '\n');
if (tempPtr == NULL || tempPtr > valuePtr)
{
*valuePtr = 0; /* null out the last char */
valuePtr++; /* point it pass the = sign */
/* Make sure that the Value is nullified. */
tempPtr = XP_STRCHR(valuePtr, CR);
if (tempPtr)
{
tempPtr = 0;
}
else
{
/* EOF? */
}
/* we found both the name and value, lets add it! */
JS_DefineProperty( cx->mocha_context,
stringObj,
buffPtr,
valuePtr?STRING_TO_JSVAL(JS_NewStringCopyZ(cx->mocha_context, valuePtr)):JSVAL_VOID,
NULL,
NULL,
JSPROP_ENUMERATE | JSPROP_READONLY);
/* set the buffPtr to the end of the value so that we can restart this loop */
if (tempPtr)
{
buffPtr= ++tempPtr;
}
}
else
{
/* we hit a return before hitting the =. Lets adjust the buffPtr, and continue */
buffPtr = XP_STRCHR(buffPtr, '\n');
if (buffPtr != NULL)
{
buffPtr++;
}
}
}
else
{
/* the resource file does look right - Line without an = */
/* what do we do? - lets just break*/
break;
}
}
}
XP_FREEIF(readBuf);
}
XP_FileClose(fp);
}
else
{
return NULL;
}
return stringObj;
}
PR_END_EXTERN_C

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

@ -1,219 +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.
*/
#include "prmem.h"
#include "prmon.h"
#include "prlog.h"
#include "xp.h"
#include "NSReg.h"
#include "softupdt.h"
#include "su_folderspec.h"
#define NEW_FE_CONTEXT_FUNCS
#include "net.h"
#include "libevent.h"
#include "prefapi.h"
#include "nsTrigger.h"
#include "nsVersionRegistry.h"
PR_BEGIN_EXTERN_C
/* PUBLIC METHODS */
/**
* @return true if SmartUpdate is enabled
*/
PRBool nsTrigger::UpdateEnabled(void)
{
XP_Bool enabled;
PREF_GetBoolPref( AUTOUPDATE_ENABLE_PREF, &enabled);
if (enabled)
return PR_TRUE;
else
return PR_FALSE;
}
/**
* @param componentName version registry name of the component
* @return version of the package. null if not installed, or
* SmartUpdate disabled
*/
nsVersionInfo* nsTrigger::GetVersionInfo( char* componentName )
{
if (UpdateEnabled())
return nsVersionRegistry::componentVersion( componentName );
else
return NULL;
}
/**
* Unconditionally starts the software update
* @param url URL of the JAR file
* @param flags SmartUpdate modifiers (SILENT_INSTALL, FORCE_INSTALL)
* @return false if SmartUpdate did not trigger
*/
PRBool nsTrigger::StartSoftwareUpdate( char* url, PRInt32 flags )
{
if (url != NULL) {
/* This is a potential problem */
/* We are grabbing any context, but we really need ours */
/* The problem is that Java does not have access to MWContext */
MWContext * cx;
cx = XP_FindSomeContext();
if (cx)
return SU_StartSoftwareUpdate(cx, url, NULL, NULL, NULL, flags);
else
return PR_FALSE;
}
return PR_FALSE;
}
PRBool nsTrigger::StartSoftwareUpdate( char* url )
{
return StartSoftwareUpdate( url, DEFAULT_MODE );
}
/**
* Conditionally starts the software update
* @param url URL of JAR file
* @param componentName name of component in the registry to compare
* the version against. This doesn't have to be the
* registry name of the installed package but could
* instead be a sub-component -- useful because if a
* file doesn't exist then it triggers automatically.
* @param diffLevel Specifies which component of the version must be
* different. If not supplied BLD_DIFF is assumed.
* If the diffLevel is positive the install is triggered
* if the specified version is NEWER (higher) than the
* registered version. If the diffLevel is negative then
* the install is triggered if the specified version is
* OLDER than the registered version. Obviously this
* will only have an effect if FORCE_MODE is also used.
* @param version The version that must be newer (can be a VersionInfo
* object or a char* version
* @param flags Same flags as StartSoftwareUpdate (force, silent)
*/
PRBool
nsTrigger::ConditionalSoftwareUpdate(char* url,
char* componentName,
PRInt32 diffLevel,
nsVersionInfo* versionInfo,
PRInt32 flags)
{
PRBool needJar = PR_FALSE;
if ((versionInfo == NULL) || (componentName == NULL))
needJar = PR_TRUE;
else {
int stat = nsVersionRegistry::validateComponent( componentName );
if ( stat == REGERR_NOFIND ||
stat == REGERR_NOFILE ) {
// either component is not in the registry or it's a file
// node and the physical file is missing
needJar = PR_TRUE;
} else {
nsVersionInfo* oldVer =
nsVersionRegistry::componentVersion( componentName );
if ( oldVer == NULL )
needJar = PR_TRUE;
else if ( diffLevel < 0 )
needJar = (versionInfo->compareTo( oldVer ) <= diffLevel);
else
needJar = (versionInfo->compareTo( oldVer ) >= diffLevel);
delete oldVer;
}
}
if (needJar)
return StartSoftwareUpdate( url, flags );
else
return PR_FALSE;
}
PRBool
nsTrigger::ConditionalSoftwareUpdate(char* url,
char* componentName,
char* version)
{
nsVersionInfo* versionInfo = new nsVersionInfo(version);
PRBool ret_val = ConditionalSoftwareUpdate( url,
componentName,
BLD_DIFF,
versionInfo,
DEFAULT_MODE );
delete versionInfo;
return ret_val;
}
/**
* Validates existence and compares versions
*
* @param regName name of component in the registry to compare
* the version against. This doesn't have to be the
* registry name of an installed package but could
* instead be a sub-component. If the named item
* has a Path property the file must exist or a
* null version is used in the comparison.
* @param version The version to compare against
*/
PRInt32 nsTrigger::CompareVersion( char* regName, nsVersionInfo* version )
{
PRInt32 ret_val;
if (!UpdateEnabled())
return EQUAL;
nsVersionInfo* regVersion = GetVersionInfo( regName );
if ( regVersion == NULL ||
nsVersionRegistry::validateComponent( regName ) == REGERR_NOFILE ) {
if (regVersion) delete regVersion;
regVersion = new nsVersionInfo(0,0,0,0,0);
}
PR_ASSERT(regVersion != NULL);
ret_val = regVersion->compareTo( version );
delete regVersion;
return ret_val;
}
PRInt32 nsTrigger::CompareVersion( char* regName, char* version )
{
nsVersionInfo* versionInfo = new nsVersionInfo( version );
PRInt32 ret_val = CompareVersion( regName, versionInfo );
delete versionInfo;
return ret_val;
}
PRInt32
nsTrigger::CompareVersion( char* regName, PRInt32 maj,
PRInt32 min, PRInt32 rel,
PRInt32 bld )
{
nsVersionInfo* versionInfo = new nsVersionInfo(maj, min, rel, bld, 0);
PRInt32 ret_val = CompareVersion( regName, versionInfo );
delete versionInfo;
return ret_val;
}
PR_END_EXTERN_C

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

@ -23,8 +23,8 @@
#include "prprf.h"
#include "xp.h"
#include "NSReg.h"
#include "VerReg.h"
#include "softupdt.h"
#include "nsVersionRegistry.h"
#include "nsPrivilegeManager.h"
#include "nsTarget.h"
#include "nsSUError.h"
@ -39,16 +39,18 @@ nsUninstallObject::nsUninstallObject(nsSoftwareUpdate* inSoftUpdate,
char* inRegName,
char* *errorMsg) : nsInstallObject(inSoftUpdate)
{
int err;
regName = NULL;
userName = NULL;
if ( (inRegName == NULL) || (XP_STRLEN(inRegName) == 0) ) {
*errorMsg = SU_GetErrorMsg3("RegName is NULL ", nsSoftUpdateError_INVALID_ARGUMENTS );
*errorMsg = SU_GetErrorMsg3("RegName is NULL ", SUERR_INVALID_ARGUMENTS );
return;
}
if (inSoftUpdate == NULL) {
*errorMsg = SU_GetErrorMsg3("SoftwareUpdate object is NULL ",
nsSoftUpdateError_INVALID_ARGUMENTS);
SUERR_INVALID_ARGUMENTS);
return;
}
@ -67,17 +69,25 @@ nsUninstallObject::nsUninstallObject(nsSoftwareUpdate* inSoftUpdate,
target = nsTarget::findTarget(INSTALL_PRIV);
if (target != NULL) {
if (!privMgr->enablePrivilege( target, softUpdate->GetPrincipal(), 1 )) {
*errorMsg = SU_GetErrorMsg3("Permssion was denied", nsSoftUpdateError_ACCESS_DENIED);
*errorMsg = SU_GetErrorMsg3("Permssion was denied", SUERR_ACCESS_DENIED);
return;
}
}
}
userName = nsVersionRegistry::getUninstallUserName( regName );
if ( userName == NULL ) {
userName = (char*)XP_CALLOC(MAXREGPATHLEN, sizeof(char));
err = VR_GetUninstallUserName( regName, userName, MAXREGPATHLEN );
if (err != REGERR_OK)
{
XP_FREEIF(userName);
userName = NULL;
}
if ( userName == NULL )
{
char *msg = NULL;
msg = PR_sprintf_append(msg, "No such component %s", regName);
*errorMsg = SU_GetErrorMsg3(msg, nsSoftUpdateError_NO_SUCH_COMPONENT);
*errorMsg = SU_GetErrorMsg3(msg, SUERR_NO_SUCH_COMPONENT);
PR_FREEIF(msg);
return;
}
@ -99,9 +109,8 @@ char* nsUninstallObject::Complete()
nsTarget* execTarget = NULL;
if ((softUpdate == NULL) || (regName == NULL)) {
*errorMsg = SU_GetErrorMsg3("Invalid arguments to UninstallObject ",
nsSoftUpdateError_INVALID_ARGUMENTS);
return;
return SU_GetErrorMsg3("Invalid arguments to UninstallObject ",
SUERR_INVALID_ARGUMENTS);
}
nsPrivilegeManager* privMgr = nsPrivilegeManager::getPrivilegeManager();
@ -115,7 +124,7 @@ char* nsUninstallObject::Complete()
execTarget = nsTarget::findTarget(INSTALL_PRIV);
if (execTarget != NULL) {
if (!privMgr->enablePrivilege( execTarget, softUpdate->GetPrincipal(), 1 )) {
return SU_GetErrorMsg3("Permssion was denied", nsSoftUpdateError_ACCESS_DENIED);
return SU_GetErrorMsg3("Permssion was denied", SUERR_ACCESS_DENIED);
}
}
}
@ -161,18 +170,18 @@ char* nsUninstallObject::NativeComplete(char* regname)
* UninstallObject() uninstall files,
* hence this function returns false.
*/
protected boolean CanUninstall()
PRBool nsUninstallObject::CanUninstall()
{
return false;
return PR_FALSE;
}
/* RegisterPackageNode
* UninstallObject() uninstalls files which no longer need to be registered,
* hence this function returns false.
*/
protected boolean RegisterPackageNode()
PRBool nsUninstallObject::RegisterPackageNode()
{
return false;
return PR_FALSE;
}
PR_END_EXTERN_C

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

@ -29,20 +29,22 @@ PR_BEGIN_EXTERN_C
/* Public Methods */
nsVersionInfo::nsVersionInfo(PRInt32 maj, PRInt32 min, PRInt32 rel, PRInt32 bld, PRInt32 checksum)
nsVersionInfo::nsVersionInfo(PRInt32 maj, PRInt32 min, PRInt32 rel, PRInt32 bld)
{
major = maj;
minor = min;
release = rel;
build = bld;
check = checksum;
}
nsVersionInfo::nsVersionInfo(char* versionArg)
{
PRInt32 errorCode;
major = minor = release = build = 0;
if (versionArg == NULL) {
versionArg = "0.0.0.0";
versionArg = "0";
}
nsString version(versionArg);
int dot = version.Find('.', 0);
@ -151,7 +153,7 @@ nsVersionEnum nsVersionInfo::compareTo(char* version)
nsVersionEnum nsVersionInfo::compareTo(PRInt32 maj, PRInt32 min, PRInt32 rel, PRInt32 bld)
{
nsVersionInfo* versionInfo = new nsVersionInfo(maj, min, rel, bld, 0);
nsVersionInfo* versionInfo = new nsVersionInfo(maj, min, rel, bld);
nsVersionEnum ret_val = compareTo(versionInfo);
delete versionInfo;
return ret_val;

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

@ -1,433 +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.
*/
#include "prtypes.h"
#include "prmem.h"
#include "xp_mcom.h"
#include "nsVersionRegistry.h"
#include "NSReg.h"
#include "VerReg.h"
#include "prefapi.h"
PR_BEGIN_EXTERN_C
/* PUBLIC METHODS */
/**
* Return the physical disk path for the specified component.
*
* Caller should free the returned string
*
* @param component Registry path of the item to look up in the Registry
* @return The disk path for the specified component; NULL indicates error
* @see VersionRegistry#checkComponent
*/
char* nsVersionRegistry::componentPath( char* component )
{
char pathbuf[MAXREGPATHLEN];
REGERR status;
char* ret_val = NULL;
/* If conversion is successful */
if ( component != NULL ) {
/* get component path from the registry */
status = VR_GetPath( component, MAXREGPATHLEN, pathbuf );
/* if we get a path */
if ( status == REGERR_OK ) {
ret_val = XP_STRDUP(pathbuf);
}
}
return ret_val;
}
/**
* Return the version information for the specified component.
* @param component Registry path of the item to look up in the Registry
* @return A VersionInfo object for the specified component;
* NULL indicates error
* @see VersionRegistry#checkComponent
*/
nsVersionInfo* nsVersionRegistry::componentVersion( char* component )
{
REGERR status;
VERSION cVersion;
nsVersionInfo* verInfo = NULL;
/* if conversion is successful */
if ( component != NULL ) {
/* get component version from the registry */
status = VR_GetVersion( component, &cVersion );
/* if we got the version */
if ( status == REGERR_OK ) {
verInfo = new nsVersionInfo(cVersion.major,
cVersion.minor,
cVersion.release,
cVersion.build,
cVersion.check);
}
}
return verInfo;
}
/**
* Return the default directory.
*
* Caller should free the returned string
*
*/
char* nsVersionRegistry::getDefaultDirectory( char* component )
{
char pathbuf[MAXREGPATHLEN];
REGERR status;
char* ret_val = NULL;
/* If conversion is successful */
if ( component != NULL ) {
/* get component path from the registry */
status = VR_GetDefaultDirectory( component, MAXREGPATHLEN, pathbuf );
/* if we get a path */
if ( status == REGERR_OK ) {
ret_val = XP_STRDUP(pathbuf);
}
}
return ret_val;
}
PRInt32 nsVersionRegistry::setDefaultDirectory( char* component,
char* directory )
{
REGERR status = REGERR_FAIL;
/* If conversion is successful */
if ( component != NULL && directory != NULL ) {
/* get component path from the registry */
status = VR_SetDefaultDirectory( component, directory );
}
return (status);
}
PRInt32 nsVersionRegistry::installComponent( char* component,
char* path,
nsVersionInfo* version )
{
char * szVersion = NULL;
REGERR status = REGERR_FAIL;
if (version != NULL) {
szVersion = version->toString();
}
if ( component != NULL ) {
/* call registry with converted data */
/* XXX need to allow Directory installs also, change in Java */
status = VR_Install( component, path, szVersion, 0 );
}
PR_FREEIF(szVersion);
return (status);
}
PRInt32 nsVersionRegistry::installComponent( char* name,
char* path,
nsVersionInfo* version,
PRInt32 refCount )
{
int err = installComponent( name, path, version );
if ( err == REGERR_OK )
err = setRefCount( name, refCount );
return err;
}
/**
* Delete component and all sub-components.
* @param component Registry path of the item to delete
* @return Error code
*/
PRInt32 nsVersionRegistry::deleteComponent( char* component )
{
REGERR status = REGERR_FAIL;
/* If conversion is successful */
if ( component != NULL ) {
/* delete entry from registry */
status = VR_Remove( component );
}
/* return status */
return (status);
}
/**
* Check the status of a named components.
* @param component Registry path of the item to check
* @return Error code. REGERR_OK means the named component was found in
* the registry, the filepath referred to an existing file, and the
* checksum matched the physical file. Other error codes can be used to
* distinguish which of the above was not true.
*/
PRInt32 nsVersionRegistry::validateComponent( char* component )
{
if ( component == NULL ) {
return REGERR_FAIL;
}
return ( VR_ValidateComponent( component ) );
}
/**
* verify that the named component is in the registry (light-weight
* version of validateComponent since it does no disk access).
* @param component Registry path of the item to verify
* @return Error code. REGERR_OK means it is in the registry.
* REGERR_NOFIND will usually be the result otherwise.
*/
PRInt32 nsVersionRegistry::inRegistry( char* component )
{
if ( component == NULL ) {
return REGERR_FAIL;
}
return ( VR_InRegistry( component ) );
}
/**
* Closes the registry file.
* @return Error code
*/
PRInt32 nsVersionRegistry::close()
{
return ( VR_Close() );
}
/**
* Returns an enumeration of the Version Registry contents. Use the
* enumeration methods of the returned object to fetch individual
* elements sequentially.
*/
void* nsVersionRegistry::elements()
{
/* XXX: This method is not called anywhere. Who uses it? */
PR_ASSERT(PR_FALSE);
return NULL;
}
/**
* Set the refcount of a named component.
* @param component Registry path of the item to check
* @param refcount value to be set
* @return Error code
*/
PRInt32 nsVersionRegistry::setRefCount( char* component, PRInt32 refcount )
{
if ( component == NULL ) {
return REGERR_FAIL;
}
return VR_SetRefCount( component, refcount );
}
/**
* Return the refcount of a named component.
* @param component Registry path of the item to check
* @return the value of refCount
*/
PRInt32 nsVersionRegistry::getRefCount( char* component )
{
REGERR status;
int cRefCount = 0;
if ( component != NULL ) {
status = VR_GetRefCount( component, &cRefCount );
if ( status != REGERR_OK ) {
cRefCount = 0;
}
}
return cRefCount;
}
/**
* Creates a node for the item in the Uninstall list.
* @param regPackageName Registry name of the package we are installing
* @return userPackagename User-readable package name
* @return Error code
*/
PRInt32 nsVersionRegistry::uninstallCreate( char* regPackageName,
char* userPackageName )
{
char* temp = convertPackageName(regPackageName);
regPackageName = temp;
PRInt32 ret_val = uninstallCreateNode(regPackageName, userPackageName);
XP_FREEIF(temp);
return ret_val;
}
PRInt32 nsVersionRegistry::uninstallCreateNode( char* regPackageName, char* userPackageName )
{
if ( regPackageName == NULL ) {
return REGERR_FAIL;
}
if ( userPackageName == NULL ) {
return REGERR_FAIL;
}
return VR_UninstallCreateNode( regPackageName, userPackageName );
}
/**
* Adds the file as a property of the Shared Files node under the appropriate
* packageName node in the Uninstall list.
* @param regPackageName Registry name of the package installed
* @param vrName registry name of the shared file
* @return Error code
*/
PRInt32 nsVersionRegistry::uninstallAddFile( char* regPackageName, char* vrName )
{
char* temp = convertPackageName(regPackageName);
regPackageName = temp;
PRInt32 ret_val = uninstallAddFileToList(regPackageName, vrName);
XP_FREEIF(temp);
return ret_val;
}
PRInt32 nsVersionRegistry::uninstallAddFileToList( char* regPackageName, char* vrName )
{
if ( regPackageName == NULL ) {
return REGERR_FAIL;
}
if ( vrName == NULL ) {
return REGERR_FAIL;
}
return VR_UninstallAddFileToList( regPackageName, vrName );
}
/**
* Checks if the shared file exists in the uninstall list of the package
* @param regPackageName Registry name of the package installed
* @param vrName registry name of the shared file
* @return true or false
*/
PRInt32 nsVersionRegistry::uninstallFileExists( char* regPackageName, char* vrName )
{
char* temp = convertPackageName(regPackageName);
regPackageName = temp;
PRInt32 ret_val = uninstallFileExistsInList(regPackageName, vrName);
XP_FREEIF(temp);
return ret_val;
}
PRInt32 nsVersionRegistry::uninstallFileExistsInList( char* regPackageName, char* vrName )
{
if ( regPackageName == NULL ) {
return REGERR_FAIL;
}
if ( vrName == NULL ) {
return REGERR_FAIL;
}
return VR_UninstallFileExistsInList( regPackageName, vrName );
}
char* nsVersionRegistry::getUninstallUserName( char* regName )
{
REGERR status = REGERR_FAIL;
char buf[MAXREGNAMELEN];
char* ret_val = NULL;
if ( regName != NULL ) {
status = VR_GetUninstallUserName( regName, buf, sizeof(buf) );
PR_ASSERT(PR_FALSE);
if ( status == REGERR_OK )
ret_val = XP_STRDUP(buf);
}
return ret_val;
}
/* PRIVATE METHODS */
/**
* This class is simply static function wrappers; don't "new" one
*/
nsVersionRegistry::nsVersionRegistry()
{
}
/**
* Replaces all '/' with '_',in the given char*.If an '_' already exists in the
* given char*, it is escaped by adding another '_' to it.
* @param regPackageName Registry name of the package we are installing
* @return modified char*
*/
char* nsVersionRegistry::convertPackageName( char* regPackageName )
{
if (regPackageName == NULL)
return regPackageName;
char* convertedPackageName;
PRBool bSharedUninstall = PR_FALSE;
PRUint32 i=0;
PRUint32 j= 0;
PRUint32 len = XP_STRLEN(regPackageName);
PRUint32 new_size;
if (regPackageName[0] == '/')
bSharedUninstall = PR_TRUE;
/* Count the number of '_' and then allocate that many extra characters */
for (i=0; i < len; i++) {
if (regPackageName[i] == '_')
j++;
}
new_size = len+j+1;
convertedPackageName = (char*)XP_CALLOC(new_size, sizeof(char));
i = j = 0;
for (i=0; i < len; i++) {
PR_ASSERT(j < new_size);
char c = regPackageName[i];
if (c == '/')
convertedPackageName[j] = '_';
else
convertedPackageName[j] = c;
j++;
if (regPackageName[i] == '_') {
PR_ASSERT(j < new_size);
convertedPackageName[j++] = '_';
}
}
PR_ASSERT(j == new_size);
if (bSharedUninstall) {
convertedPackageName[0] = '/';
}
return convertedPackageName;
}
PR_END_EXTERN_C

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

@ -40,7 +40,7 @@ extern int MK_OUT_OF_MEMORY;
/* xp_string defines */
extern int SU_LOW_DISK_SPACE_WARNING;
extern int SU_NOT_A_ENOUGH_SPACE;
extern int SU_NOT_ENOUGH_SPACE;
extern int SU_NOT_A_JAR_FILE;
extern int SU_SECURITY_CHECK;
extern int SU_INSTALL_FILE_HEADER;
@ -60,13 +60,13 @@ extern uint32 FE_DiskSpaceAvailable (MWContext *context, const char *lpszPath );
/* su_DownloadStream
* keeps track of all SU specific data needed for the stream
*/
typedef struct su_DownloadStream_struct {
XP_File fFile;
char * fJarFile; /* xpURL location of the downloaded file */
URL_Struct * fURL;
MWContext * fContext;
SoftUpdateCompletionFunction fCompletion;
void * fCompletionClosure;
typedef struct su_DownloadStream_struct {
XP_File fFile;
char * fJarFile; /* xpURL location of the downloaded file */
URL_Struct * fURL;
MWContext * fContext;
SoftUpdateCompletionFunction fCompletion;
void * fCompletionClosure;
int32 fFlags; /* download flags */
pw_ptr progress ;
} su_DownloadStream;
@ -368,7 +368,7 @@ void su_NetExitProc(URL_Struct* url, int result, MWContext * context)
if (context)
{
FE_Alert(context, XP_GetString(SU_NOT_A_ENOUGH_SPACE));
FE_Alert(context, XP_GetString(SU_NOT_ENOUGH_SPACE));
}
PR_ExitMonitor(su_monitor);
}
@ -391,6 +391,16 @@ void su_NetExitProc(URL_Struct* url, int result, MWContext * context)
#pragma export on
#endif
XP_Bool SU_IsUpdateEnabled(void)
{
XP_Bool enabled = FALSE;
PREF_GetBoolPref( AUTOUPDATE_ENABLE_PREF, &enabled);
return (enabled);
}
/* SU_StartSoftwareUpdate
* Main public interface to software update
*/
@ -789,7 +799,7 @@ void su_HandleCompleteJavaScript (su_DownloadStream* realStream)
/*
if (result != 0)
{
PR_snprintf(s, 255, XP_GetString(SU_NOT_A_ENOUGH_SPACE), installerJarName);
PR_snprintf(s, 255, XP_GetString(SU_NOT_ENOUGH_SPACE), installerJarName);
FE_Alert(realStream->fContext, s);
result = su_DiskSpaceError;
goto fail;
@ -910,7 +920,7 @@ void su_HandleCompleteJavaScript (su_DownloadStream* realStream)
if (result == ZIG_ERR_DISK)
{
PR_snprintf(s, 255, XP_GetString(SU_NOT_A_ENOUGH_SPACE), installerJarName);
PR_snprintf(s, 255, XP_GetString(SU_NOT_ENOUGH_SPACE), installerJarName);
FE_Alert(realStream->fContext, s);
result = su_DiskSpaceError;
goto fail;
@ -1554,7 +1564,6 @@ XP_Bool su_RegPackTime()
su_SetLastRegPackTime(nowSecInt);
return FALSE;
}
i = nowSecInt - lastRegPackTime;
if ((i > intervalSec) || (i < 0))
{

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

@ -57,8 +57,7 @@ extern int SU_INSTALL_ASK_FOR_DIRECTORY;
/* Makes sure that the path ends with a slash (or other platform end character)
* @return alloc'd new path that ends with a slash
*/
static char *
AppendSlashToDirPath(char * dirPath)
char *AppendSlashToDirPath(char * dirPath)
{
char pathSeparator; /* Gross, but harmless */
int32 newLen;
@ -108,8 +107,7 @@ GetDirectoryPathCallbackFunction(MWContext *context,
}
/* Callback for the timer set by FE_SetTimer */
PR_STATIC_CALLBACK(void)
pickDirectoryCallback(void * a)
void PR_CALLBACK pickDirectoryCallback(void * a)
{
su_PickDirTimer *t = (su_PickDirTimer *)a;
int err;
@ -131,7 +129,7 @@ pickDirectoryCallback(void * a)
* DirectoryTable holds the info about built-in directories:
* Text name, security level, enum
*/
static struct su_DirectoryTable DirectoryTable[] =
struct su_DirectoryTable DirectoryTable[] =
{
{"Plugins", ePluginFolder, TRUE},
{"Program", eProgramFolder, FALSE},
@ -172,7 +170,7 @@ static struct su_DirectoryTable DirectoryTable[] =
/* MapNameToEnum
* maps name from the directory table to its enum */
static su_DirSpecID MapNameToEnum(const char * name)
su_DirSpecID MapNameToEnum(const char * name)
{
int i = 0;
XP_ASSERT( name );

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

@ -22,7 +22,7 @@
#include "xp_mcom.h"
#define REBOOT_NEEDED 999
#define SU_REBOOT_NEEDED 999
#define SU_SUCCESS 0
XP_BEGIN_PROTOS

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

@ -0,0 +1,261 @@
/* -*- 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 "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 Communicator client code,
* released March 31, 1998.
*
* 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.
*
* Contributors:
* Daniel Veditz <dveditz@netscape.com>
*/
#include "xp.h"
#include "jsapi.h"
#include "su_mocha.h"
#include "nsSoftwareUpdate.h"
/**
* Outside modules call SU_InitMochaClasses() to add our classes to their JS
* context, generally anywhere JS_InitStandardClasses() is called.
*/
JSBool SU_InitMochaClasses(JSContext *cx, JSObject *obj)
{
if ( !su_DefineInstall(cx, obj) )
return JS_FALSE;
if ( !su_DefineTrigger(cx, obj) )
return JS_FALSE;
if ( !su_DefineVersion(cx, obj) )
return JS_FALSE;
return JS_TRUE;
}
//
// prototypes
//
static void PR_CALLBACK inst_destroy(JSContext *cx, JSObject *obj);
static JSBool PR_CALLBACK NewInstall(JSContext *cx, JSObject *obj, uint argc, jsval *argv, jsval *rval);
static JSBool PR_CALLBACK inst_abortInstall(JSContext *cx, JSObject *obj, uint argc, jsval *argv, jsval *rval);
static JSBool PR_CALLBACK inst_addDirectory(JSContext *cx, JSObject *obj, uint argc, jsval *argv, jsval *rval);
static JSBool PR_CALLBACK inst_addSubcomponent(JSContext *cx, JSObject *obj, uint argc, jsval *argv, jsval *rval);
static JSBool PR_CALLBACK inst_deleteComponent(JSContext *cx, JSObject *obj, uint argc, jsval *argv, jsval *rval);
static JSBool PR_CALLBACK inst_deleteFile(JSContext *cx, JSObject *obj, uint argc, jsval *argv, jsval *rval);
static JSBool PR_CALLBACK inst_diskSpaceAvailable(JSContext *cx, JSObject *obj, uint argc, jsval *argv, jsval *rval);
static JSBool PR_CALLBACK inst_execute(JSContext *cx, JSObject *obj, uint argc, jsval *argv, jsval *rval);
static JSBool PR_CALLBACK inst_finalizeInstall(JSContext *cx, JSObject *obj, uint argc, jsval *argv, jsval *rval);
static JSBool PR_CALLBACK inst_gestalt(JSContext *cx, JSObject *obj, uint argc, jsval *argv, jsval *rval);
static JSBool PR_CALLBACK inst_getComponentFolder(JSContext *cx, JSObject *obj, uint argc, jsval *argv, jsval *rval);
static JSBool PR_CALLBACK inst_getFolder(JSContext *cx, JSObject *obj, uint argc, jsval *argv, jsval *rval);
static JSBool PR_CALLBACK inst_getLastError(JSContext *cx, JSObject *obj, uint argc, jsval *argv, jsval *rval);
static JSBool PR_CALLBACK inst_getWinProfile(JSContext *cx, JSObject *obj, uint argc, jsval *argv, jsval *rval);
static JSBool PR_CALLBACK inst_getWinRegistry(JSContext *cx, JSObject *obj, uint argc, jsval *argv, jsval *rval);
static JSBool PR_CALLBACK inst_patch(JSContext *cx, JSObject *obj, uint argc, jsval *argv, jsval *rval);
static JSBool PR_CALLBACK inst_resetError(JSContext *cx, JSObject *obj, uint argc, jsval *argv, jsval *rval);
static JSBool PR_CALLBACK inst_setPackageFolder(JSContext *cx, JSObject *obj, uint argc, jsval *argv, jsval *rval);
static JSBool PR_CALLBACK inst_startInstall(JSContext *cx, JSObject *obj, uint argc, jsval *argv, jsval *rval);
static JSBool PR_CALLBACK inst_uninstall(JSContext *cx, JSObject *obj, uint argc, jsval *argv, jsval *rval);
//
// structures
//
static JSClass install_class = {
"Install", JSCLASS_HAS_PRIVATE,
JS_PropertyStub, JS_PropertyStub, JS_PropertyStub, JS_PropertyStub,
JS_EnumerateStub, JS_ResolveStub, JS_ConvertStub, inst_destroy
};
static JSFunctionSpec install_methods[] = {
{"AbortInstall", inst_abortInstall, 0},
{"AddDirectory", inst_addDirectory, 6},
{"AddSubcomponent", inst_addSubcomponent, 6},
{"DeleteComponent", inst_deleteComponent, 1},
{"DeleteFile", inst_deleteFile, 2},
{"DiskSpaceAvailable", inst_diskSpaceAvailable, 1},
{"Execute", inst_execute, 2},
{"FinalizeInstall", inst_finalizeInstall, 0},
{"Gestalt", inst_gestalt, 1},
{"GetComponentFolder", inst_getComponentFolder, 2},
{"GetFolder", inst_getFolder, 2},
{"GetLastError", inst_getLastError, 0},
{"GetWinProfile", inst_getWinProfile, 2},
{"GetWinRegistry", inst_getWinRegistry, 0},
{"Patch", inst_patch, 5},
{"ResetError", inst_resetError, 0},
{"SetPackageFolder", inst_setPackageFolder, 1},
{"StartInstall", inst_startInstall, 3},
{"Uninstall", inst_uninstall, 1},
{0}
};
//
// functions
//
JSBool su_DefineInstall(JSContext *cx, JSObject *obj)
{
JSObject *proto;
proto = JS_InitClass(cx, obj, NULL, &install_class, NewInstall, 2,
NULL, install_methods, NULL, NULL);
return (proto != NULL);
}
static JSBool PR_CALLBACK NewInstall(JSContext *cx, JSObject *obj, uint argc, jsval *argv, jsval *rval)
{
JSObject *install;
nsSoftwareUpdate *su;
// sanity checks
if ( argc < 2 )
return JS_FALSE;
if ( !JSVAL_IS_OBJECT(argv[0]) || !JSVAL_IS_STRING(argv[1]) )
return JS_FALSE;
// create the object
install = JS_NewObject(cx, &install_class, NULL, obj);
if ( install != NULL ) {
su = new nsSoftwareUpdate( JSVAL_TO_OBJECT(argv[0]),
JS_GetStringBytes(JSVAL_TO_STRING(argv[1])) );
if ( su != NULL ) {
if ( JS_SetPrivate( cx, install, su ) ) {
*rval = OBJECT_TO_JSVAL(install);
return JS_TRUE;
}
}
}
return JS_FALSE;
}
static void PR_CALLBACK inst_destroy(JSContext *cx, JSObject *obj)
{
}
static JSBool PR_CALLBACK inst_abortInstall(JSContext *cx, JSObject *obj, uint argc, jsval *argv, jsval *rval)
{
return JS_TRUE;
}
static JSBool PR_CALLBACK inst_addDirectory(JSContext *cx, JSObject *obj, uint argc, jsval *argv, jsval *rval)
{
return JS_TRUE;
}
static JSBool PR_CALLBACK inst_addSubcomponent(JSContext *cx, JSObject *obj, uint argc, jsval *argv, jsval *rval)
{
return JS_TRUE;
}
static JSBool PR_CALLBACK inst_deleteComponent(JSContext *cx, JSObject *obj, uint argc, jsval *argv, jsval *rval)
{
return JS_TRUE;
}
static JSBool PR_CALLBACK inst_deleteFile(JSContext *cx, JSObject *obj, uint argc, jsval *argv, jsval *rval)
{
return JS_TRUE;
}
static JSBool PR_CALLBACK inst_diskSpaceAvailable(JSContext *cx, JSObject *obj, uint argc, jsval *argv, jsval *rval)
{
return JS_TRUE;
}
static JSBool PR_CALLBACK inst_execute(JSContext *cx, JSObject *obj, uint argc, jsval *argv, jsval *rval)
{
return JS_TRUE;
}
static JSBool PR_CALLBACK inst_finalizeInstall(JSContext *cx, JSObject *obj, uint argc, jsval *argv, jsval *rval)
{
return JS_TRUE;
}
static JSBool PR_CALLBACK inst_gestalt(JSContext *cx, JSObject *obj, uint argc, jsval *argv, jsval *rval)
{
return JS_TRUE;
}
static JSBool PR_CALLBACK inst_getComponentFolder(JSContext *cx, JSObject *obj, uint argc, jsval *argv, jsval *rval)
{
return JS_TRUE;
}
static JSBool PR_CALLBACK inst_getFolder(JSContext *cx, JSObject *obj, uint argc, jsval *argv, jsval *rval)
{
return JS_TRUE;
}
static JSBool PR_CALLBACK inst_getLastError(JSContext *cx, JSObject *obj, uint argc, jsval *argv, jsval *rval)
{
return JS_TRUE;
}
static JSBool PR_CALLBACK inst_getWinProfile(JSContext *cx, JSObject *obj, uint argc, jsval *argv, jsval *rval)
{
return JS_TRUE;
}
static JSBool PR_CALLBACK inst_getWinRegistry(JSContext *cx, JSObject *obj, uint argc, jsval *argv, jsval *rval)
{
return JS_TRUE;
}
static JSBool PR_CALLBACK inst_patch(JSContext *cx, JSObject *obj, uint argc, jsval *argv, jsval *rval)
{
return JS_TRUE;
}
static JSBool PR_CALLBACK inst_resetError(JSContext *cx, JSObject *obj, uint argc, jsval *argv, jsval *rval)
{
return JS_TRUE;
}
static JSBool PR_CALLBACK inst_setPackageFolder(JSContext *cx, JSObject *obj, uint argc, jsval *argv, jsval *rval)
{
return JS_TRUE;
}
static JSBool PR_CALLBACK inst_startInstall(JSContext *cx, JSObject *obj, uint argc, jsval *argv, jsval *rval)
{
return JS_TRUE;
}
static JSBool PR_CALLBACK inst_uninstall(JSContext *cx, JSObject *obj, uint argc, jsval *argv, jsval *rval)
{
return JS_TRUE;
}

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

@ -1,20 +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.
*/
/*
* TODO: We need to delete this file
*/

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

@ -356,20 +356,20 @@ cleanup:
case GDIFF_ERR_BADDIFF:
case GDIFF_ERR_OPCODE:
case GDIFF_ERR_CHKSUMTYPE:
status = nsSoftUpdateError_PATCH_BAD_DIFF;
status = SUERR_PATCH_BAD_DIFF;
break;
case GDIFF_ERR_CHECKSUM_TARGET:
status = nsSoftUpdateError_PATCH_BAD_CHECKSUM_TARGET;
status = SUERR_PATCH_BAD_CHECKSUM_TARGET;
break;
case GDIFF_ERR_CHECKSUM_RESULT:
status = nsSoftUpdateError_PATCH_BAD_CHECKSUM_RESULT;
status = SUERR_PATCH_BAD_CHECKSUM_RESULT;
break;
case GDIFF_ERR_OLDFILE:
case GDIFF_ERR_ACCESS:
case GDIFF_ERR_MEM:
case GDIFF_ERR_UNKNOWN:
default:
status = nsSoftUpdateError_UNEXPECTED_ERROR;
status = SUERR_UNEXPECTED_ERROR;
break;
}

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

@ -1,26 +1,394 @@
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
/* -*- 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
* Version 1.0 (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 NPL is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the 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
* NPL.
* License.
*
* The Initial Developer of this code under the NPL is Netscape
* Communications Corporation. Portions created by Netscape are
* The Original Code is Mozilla Communicator client code,
* released March 31, 1998.
*
* 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.
*/
/* su_trigger.c
* TODO: we should delete this file.
*
* Contributors:
* Daniel Veditz <dveditz@netscape.com>
*/
#include "xp.h"
#include "jsapi.h"
#include "prefapi.h"
#include "VerReg.h"
#include "su_mocha.h"
#include "softupdt.h"
void SU_Initialize()
{
}
char su_defaultMode_str[] = "DEFAULT_MODE";
char su_forceMode_str[] = "FORCE_MODE";
char su_silentMode_str[] = "SILENT_MODE";
char su_equal_str[] = "EQUAL";
char su_bldDiff_str[] = "BLD_DIFF";
char su_relDiff_str[] = "REL_DIFF";
char su_minorDiff_str[] = "MINOR_DIFF";
char su_majorDiff_str[] = "MAJOR_DIFF";
/* prototypes */
static JSBool PR_CALLBACK compareVersion(JSContext *cx, JSObject *obj, uint argc, jsval *argv, jsval *rval);
static JSBool PR_CALLBACK conditionalSU(JSContext *cx, JSObject *obj, uint argc, jsval *argv, jsval *rval);
static JSBool PR_CALLBACK getVersion(JSContext *cx, JSObject *obj, uint argc, jsval *argv, jsval *rval);
static JSBool PR_CALLBACK startSU(JSContext *cx, JSObject *obj, uint argc, jsval *argv, jsval *rval);
static JSBool PR_CALLBACK suEnabled(JSContext *cx, JSObject *obj, uint argc, jsval *argv, jsval *rval);
static int compareRegWithVersion(char *regname, VERSION *version);
/* structures */
static JSClass trigger_class = {
"InstallTrigger",
0,
JS_PropertyStub, JS_PropertyStub, JS_PropertyStub, JS_PropertyStub,
JS_EnumerateStub, JS_ResolveStub, JS_ConvertStub, JS_FinalizeStub
};
static JSFunctionSpec trigger_static_methods[] = {
{"CompareVersion", compareVersion, 2},
{"ConditionalSoftwareUpdate", conditionalSU, 3},
{"GetVersionInfo", getVersion, 1},
{"StartSoftwareUpdate", startSU, 1},
{"UpdateEnabled", suEnabled, 0},
{0}
};
static JSConstDoubleSpec trigger_constants[] = {
{ SU_DEFAULT_MODE, su_defaultMode_str },
{ SU_FORCE_MODE, su_forceMode_str },
{ SU_SILENT_MODE, su_silentMode_str },
{ SU_EQUAL, su_equal_str },
{ SU_BLD_DIFF, su_bldDiff_str },
{ SU_REL_DIFF, su_relDiff_str },
{ SU_MINOR_DIFF, su_minorDiff_str },
{ SU_MAJOR_DIFF, su_majorDiff_str },
{0}
};
/* implementation */
/**
* Add InstallTrigger class to a JS context
*/
JSBool su_DefineTrigger(JSContext *cx, JSObject *obj)
{
JSObject *proto;
proto = JS_InitClass(cx, obj, NULL, &trigger_class, NULL, 0,
NULL, NULL, NULL, trigger_static_methods);
if ( proto != NULL )
if ( JS_DefineConstDoubles(cx, proto, trigger_constants) )
return JS_TRUE;
return JS_FALSE;
}
/**
* implements InstallTrigger.GetVersionInfo()
*/
static JSBool PR_CALLBACK getVersion(JSContext *cx, JSObject *obj, uint argc, jsval *argv, jsval *rval)
{
REGERR err;
VERSION version;
char *regname;
JSObject *verobj;
/* initialize in case of errors */
*rval = JSVAL_NULL;
/* don't give out any info if user has us turned off */
if ( !SU_IsUpdateEnabled() )
return JS_TRUE;
/* find the requested version */
if ( argc > 0 && JSVAL_IS_STRING(argv[0]) ) {
regname = JS_GetStringBytes( JSVAL_TO_STRING(argv[0]) );
err = VR_GetVersion( regname, &version );
if ( err == REGERR_OK ) {
verobj = JS_NewObject( cx, &su_version_class, NULL, NULL );
if ( verobj != NULL ) {
su_versToObj( cx, &version, verobj );
*rval = OBJECT_TO_JSVAL(verobj);
}
}
}
return JS_TRUE;
}
/**
* implements InstallTrigger.CompareVersion()
*/
static JSBool PR_CALLBACK compareVersion(JSContext *cx, JSObject *obj, uint argc, jsval *argv, jsval *rval)
{
char *regname;
VERSION compver;
int result = 0;
/* basic parameter error checking */
*rval = JSVAL_ZERO;
if ( !SU_IsUpdateEnabled() ) {
/* no further information given! */
return JS_TRUE;
}
if ( argc < 2 || !JSVAL_IS_STRING(argv[0]) ) {
/* XXX report this error -- bad params */
return JS_FALSE;
}
/* get registry version */
regname = JS_GetStringBytes( JSVAL_TO_STRING(argv[0]) );
/* convert remaining args into the other version */
compver.major = compver.minor = compver.release = compver.build = 0;
if ( JSVAL_IS_STRING(argv[1]) ) {
char *verstr = JS_GetStringBytes(JSVAL_TO_STRING(argv[1]));
su_strToVersion( verstr, &compver);
}
else if ( JSVAL_IS_OBJECT(argv[1]) ) {
/* check to make sure it's an InstallVersion first */
JSObject *argobj;
JSClass *argclass;
argobj = JSVAL_TO_OBJECT(argv[1]);
argclass = JS_GetClass(cx, argobj);
if ( argclass != &su_version_class ) {
/* XXX report error here */
return JS_FALSE;
}
su_objToVers( cx, argobj, &compver );
}
else {
if ( JSVAL_IS_INT(argv[1]) )
compver.major = JSVAL_TO_INT(argv[1]);
if ( argc > 2 && JSVAL_IS_INT(argv[2]) )
compver.minor = JSVAL_TO_INT(argv[2]);
if ( argc > 3 && JSVAL_IS_INT(argv[3]) )
compver.release = JSVAL_TO_INT(argv[3]);
if ( argc > 4 && JSVAL_IS_INT(argv[4]) )
compver.build = JSVAL_TO_INT(argv[4]);
}
/* finally, do the actual comparison */
result = compareRegWithVersion( regname, &compver );
*rval = INT_TO_JSVAL(result);
return JS_TRUE;
}
/**
* implements InstallTrigger.ConditionalSoftwareUpdate()
*
* This method has multiple versions (mode is always optional):
* String URL, String regname, InstallVersion version, int mode
* String URL, String regname, String version, int mode
* String URL, String regname, int difflevel, String version, int mode
*/
static JSBool PR_CALLBACK conditionalSU(JSContext *cx, JSObject *obj, uint argc, jsval *argv, jsval *rval)
{
char *url;
char *regname;
PRBool bTriggered;
PRBool bNeedJar = PR_FALSE;
MWContext *mwcx;
VERSION compver;
int flags = SU_DEFAULT_MODE;
int difflevel = SU_BLD_DIFF;
uint verarg = 2; /* version is usually argv[2] */
int compresult;
/* basic parameter validation */
*rval = JSVAL_FALSE;
if ( argc < 3 || !JSVAL_IS_STRING(argv[0]) || !JSVAL_IS_STRING(argv[1]) ) {
/* XXX return some error message */
return JS_TRUE;
}
if ( JSVAL_IS_INT(argv[2]) ) {
difflevel = JSVAL_TO_INT(argv[2]);
verarg = 3; /* version is argv[3] if there's a difflevel */
if ( argc < 4 ) {
/* XXX report this */
/* variants with a difflevel must also have a version */
return JS_TRUE;
}
}
/* get the URL and registry name */
url = JS_GetStringBytes( JSVAL_TO_STRING(argv[0]) );
regname = JS_GetStringBytes( JSVAL_TO_STRING(argv[1]) );
/* get the version to compare against */
if ( JSVAL_IS_STRING(argv[verarg]) ) {
char *verstr = JS_GetStringBytes(JSVAL_TO_STRING(argv[verarg]));
su_strToVersion( verstr, &compver);
}
else if ( JSVAL_IS_OBJECT(argv[verarg]) ) {
/* check to make sure it's an InstallVersion first */
JSObject *argobj;
JSClass *argclass;
argobj = JSVAL_TO_OBJECT(argv[verarg]);
argclass = JS_GetClass(cx, argobj);
if ( argclass != &su_version_class ) {
/* XXX report error here */
return JS_FALSE;
}
su_objToVers( cx, argobj, &compver );
}
/* get install mode, if any */
if ( argc > (verarg+1) && JSVAL_IS_INT(argv[verarg+1]) ) {
flags = JSVAL_TO_INT(argv[verarg+1]);
}
/* perform the comparison */
compresult = -(compareRegWithVersion( regname, &compver ));
if ( difflevel < 0 ) {
/* trigger if installed version is *higher* */
bNeedJar = (compresult <= difflevel);
}
else {
/* >= because default is BLD_DIFF, and you can
trigger on EQUAL if you want */
bNeedJar = (compresult >= difflevel);
}
if ( bNeedJar ) {
/* XXX This is a potential problem */
/* We are grabbing any context, but we really need ours */
/* talk to JS guys to see if we can get it from JS context */
mwcx = XP_FindSomeContext();
if (mwcx) {
bTriggered = SU_StartSoftwareUpdate(mwcx,url,NULL,NULL,NULL,flags);
*rval = BOOLEAN_TO_JSVAL( bTriggered );
}
}
return JS_TRUE;
}
/**
* implements InstallTrigger.StartSoftwareUpdate()
*/
static JSBool PR_CALLBACK startSU(JSContext *cx, JSObject *obj, uint argc, jsval *argv, jsval *rval)
{
char* url;
int flags = SU_DEFAULT_MODE;
MWContext *mwcx;
PRBool bTriggered;
if ( argc == 0 || !JSVAL_IS_STRING(argv[0]) ) {
/* XXX too few or invalid params */
return JS_FALSE;
}
if ( argc > 1 ) {
if ( JSVAL_IS_INT(argv[1]) )
flags = JSVAL_TO_INT(argv[1]);
else
return JS_FALSE;
}
/* XXX This is a potential problem */
/* We are grabbing any context, but we really need ours */
/* talk to JS guys to see if we can get it from JS context */
mwcx = XP_FindSomeContext();
if (mwcx) {
url = JS_GetStringBytes( JSVAL_TO_STRING(argv[0]) );
bTriggered = SU_StartSoftwareUpdate(mwcx,url,NULL,NULL,NULL,flags);
*rval = BOOLEAN_TO_JSVAL( bTriggered );
}
else
*rval = JSVAL_FALSE;
return JS_TRUE;
}
/**
* implements InstallTrigger.UpdateEnabled()
*/
static JSBool PR_CALLBACK suEnabled(JSContext *cx, JSObject *obj, uint argc, jsval *argv, jsval *rval)
{
*rval = BOOLEAN_TO_JSVAL( SU_IsUpdateEnabled() );
return JS_TRUE;
}
static int compareRegWithVersion(char *regname, VERSION *version)
{
REGERR err;
VERSION regver;
err = VR_ValidateComponent( regname );
if ( err == REGERR_OK || err == REGERR_NOPATH ) {
/* the component exists */
err = VR_GetVersion( regname, &regver );
}
if ( err != REGERR_OK ) {
regver.major = regver.minor = regver.release = regver.build = 0;
}
return (su_compareVersions( &regver, version ));
}

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

@ -0,0 +1,286 @@
/* -*- 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 "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 Communicator client code,
* released March 31, 1998.
*
* 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.
*
* Contributors:
* Daniel Veditz <dveditz@netscape.com>
*/
#include "xp.h"
#include "jsapi.h"
#include "prprf.h"
#include "su_mocha.h"
#include "softupdt.h"
/* prototypes */
static JSBool PR_CALLBACK NewVersion(JSContext *cx, JSObject *obj, uint argc, jsval *argv, jsval *rval);
static JSBool PR_CALLBACK su_versionCompareTo(JSContext *cx, JSObject *obj, uint argc, jsval *argv, jsval *rval);
static JSBool PR_CALLBACK su_verobjToString(JSContext *cx, JSObject *obj, uint argc, jsval *argv, jsval *rval);
/* structures */
char su_major_str[] = "major";
char su_minor_str[] = "minor";
char su_release_str[] = "release";
char su_build_str[] = "build";
JSClass su_version_class = {
"InstallVersion",
0,
JS_PropertyStub, JS_PropertyStub, JS_PropertyStub, JS_PropertyStub,
JS_EnumerateStub, JS_ResolveStub, JS_ConvertStub, JS_FinalizeStub
};
static JSFunctionSpec version_methods[] = {
{"compareTo", su_versionCompareTo, 1},
{"toString", su_verobjToString, 0},
{0}
};
static JSConstDoubleSpec version_constants[] = {
{ SU_EQUAL, su_equal_str },
{ SU_BLD_DIFF, su_bldDiff_str },
{ SU_REL_DIFF, su_relDiff_str },
{ SU_MINOR_DIFF, su_minorDiff_str },
{ SU_MAJOR_DIFF, su_majorDiff_str },
{0}
};
/* implementations */
/**
* adds the InstallVersion class to a JS context
*/
JSBool su_DefineVersion(JSContext *cx, JSObject *obj)
{
JSObject *su_version_proto;
su_version_proto = JS_InitClass(cx, obj, NULL, &su_version_class, NewVersion, 1,
NULL, version_methods, NULL, NULL);
if ( su_version_proto != NULL )
if ( JS_DefineConstDoubles(cx, su_version_proto, version_constants) )
return JS_TRUE;
return JS_FALSE;
}
/**
* InstallVersion constructor
*/
static JSBool PR_CALLBACK NewVersion(JSContext *cx, JSObject *obj, uint argc, jsval *argv, jsval *rval)
{
VERSION vers;
if ( argc > 0 && JSVAL_IS_STRING(argv[0]) ) {
su_strToVersion( JS_GetStringBytes(JSVAL_TO_STRING(argv[0])), &vers );
}
else {
vers.major = vers.minor = vers.release = vers.build = 0;
if ( argc > 0 && JSVAL_IS_INT(argv[0]) )
vers.major = JSVAL_TO_INT(argv[0]);
if ( argc > 1 && JSVAL_IS_INT(argv[1]) )
vers.minor = JSVAL_TO_INT(argv[1]);
if ( argc > 2 && JSVAL_IS_INT(argv[2]) )
vers.release = JSVAL_TO_INT(argv[2]);
if ( argc > 3 && JSVAL_IS_INT(argv[3]) )
vers.build = JSVAL_TO_INT(argv[3]);
}
su_versToObj(cx, &vers, obj);
return JS_TRUE;
}
/**
* implementation of InstallVersion.compareTo()
*/
static JSBool PR_CALLBACK su_versionCompareTo(JSContext *cx, JSObject *obj, uint argc, jsval *argv, jsval *rval)
{
int compval;
VERSION thisver, v;
if ( argc == 0 )
return JS_FALSE;
if ( JSVAL_IS_STRING(argv[0]) ) {
su_strToVersion( JS_GetStringBytes(JSVAL_TO_STRING(argv[0])), &v );
}
else if (JSVAL_IS_OBJECT(argv[0]) ) {
/* check to make sure it's an InstallVersion */
JSObject *argobj;
JSClass *argclass;
argobj = JSVAL_TO_OBJECT(argv[0]);
argclass = JS_GetClass(cx, argobj);
if ( argclass != &su_version_class ) {
/* XXX report error here */
return JS_FALSE;
}
su_objToVers( cx, argobj, &v );
}
else {
v.major = v.minor = v.release = v.build = 0;
if ( argc > 0 && JSVAL_IS_INT(argv[0]) )
v.major = JSVAL_TO_INT(argv[0]);
if ( argc > 1 && JSVAL_IS_INT(argv[1]) )
v.minor = JSVAL_TO_INT(argv[1]);
if ( argc > 2 && JSVAL_IS_INT(argv[2]) )
v.release = JSVAL_TO_INT(argv[2]);
if ( argc > 3 && JSVAL_IS_INT(argv[3]) )
v.build = JSVAL_TO_INT(argv[3]);
}
su_objToVers( cx, obj, &thisver );
compval = su_compareVersions( &thisver, &v );
*rval = INT_TO_JSVAL(compval);
return JS_TRUE;
}
/**
* implementation of InstallVersion.toString()
*/
static JSBool PR_CALLBACK su_verobjToString(JSContext *cx, JSObject *obj, uint argc, jsval *argv, jsval *rval)
{
char *str;
VERSION v;
su_objToVers(cx, obj, &v );
str = PR_smprintf("%d.%d.%d.%d", v.major, v.minor, v.release, v.build);
*rval = STRING_TO_JSVAL( JS_NewStringCopyZ(cx,str) );
PR_smprintf_free(str);
return JS_TRUE;
}
/* Convert VERSION type to Version JS object */
void su_versToObj(JSContext *cx, VERSION* vers, JSObject* versObj)
{
jsval val = INT_TO_JSVAL(vers->major);
JS_SetProperty(cx, versObj, su_major_str, &val);
val = INT_TO_JSVAL(vers->minor);
JS_SetProperty(cx, versObj, su_minor_str, &val);
val = INT_TO_JSVAL(vers->release);
JS_SetProperty(cx, versObj, su_release_str, &val);
val = INT_TO_JSVAL(vers->build);
JS_SetProperty(cx, versObj, su_build_str, &val);
}
/* Convert Version JS object to VERSION type */
void su_objToVers(JSContext *cx, JSObject* versObj, VERSION* vers)
{
jsval val;
JS_GetProperty(cx, versObj, su_major_str, &val);
vers->major = JSVAL_TO_INT(val);
JS_GetProperty(cx, versObj, su_minor_str, &val);
vers->minor = JSVAL_TO_INT(val);
JS_GetProperty(cx, versObj, su_release_str, &val);
vers->release = JSVAL_TO_INT(val);
JS_GetProperty(cx, versObj, su_build_str, &val);
vers->build = JSVAL_TO_INT(val);
}
/* Convert version string ("4.1.0.8743") to VERSION type */
void su_strToVersion(char * verstr, VERSION* vers)
{
char *p;
char *o = verstr;
vers->major = vers->minor = vers->release = vers->build = 0;
if ( o != NULL ) {
p = strchr(o, '.');
vers->major = atoi(o);
if ( p != NULL ) {
o = p+1;
p = strchr(o, '.');
vers->minor = atoi(o);
if ( p != NULL ) {
o = p+1;
p = strchr(o,'.');
vers->release = atoi(o);
if ( p != NULL ) {
o = p+1;
p = strchr(o,'.');
vers->build = atoi(o);
}
}
}
}
}
/*
* Returns 0 if versions are equal; < 0 if vers1 is older; > 0 if vers1 is newer
*/
int su_compareVersions(VERSION* vers1, VERSION* vers2)
{
int diff;
if (vers1 == NULL)
diff = -SU_MAJOR_DIFF;
else if (vers2 == NULL)
diff = SU_MAJOR_DIFF;
else if (vers1->major == vers2->major) {
if (vers1->minor == vers2->minor) {
if (vers1->release == vers2->release) {
if (vers1->build == vers2->build)
diff = SU_EQUAL;
else diff = (vers1->build > vers2->build) ? SU_BLD_DIFF: -SU_BLD_DIFF;
}
else diff = (vers1->release > vers2->release) ? SU_REL_DIFF: -SU_REL_DIFF;
}
else diff = (vers1->minor > vers2->minor) ? SU_MINOR_DIFF: -SU_MINOR_DIFF;
}
else diff = (vers1->major > vers2->major) ? SU_MAJOR_DIFF : -SU_MAJOR_DIFF;
return diff;
}

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

@ -392,7 +392,7 @@ int FE_ReplaceExistingFile(char *CurrentFname, XP_FileType ctype,
#endif /* XP_OS2 */
if ( NO_ERROR == err )
err = REBOOT_NEEDED;
err = SU_REBOOT_NEEDED;
}
} // (force || fe_FileNeedsUpdate( currentName, finalName ))
else {

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

@ -1,20 +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.
*/
/*
* TODO: We need to delete this file
*/

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

@ -1,598 +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.
*/
/*
* We need to convert Reg*.java files.
* TODO: delete this file.
*/
#include "xp_mcom.h"
#include "NSReg.h"
#include "VerReg.h"
#include "prefapi.h"
#ifdef NEVER
/* ------------------------------------------------------------------
* VerRegEnumerator native methods
* ------------------------------------------------------------------
*/
/*** private native regNext ()Ljava/lang/String; ***/
/*
* VerRegEnumerator::regNext
*/
JRIEnv* tmpEnv = NULL;
JRI_PUBLIC_API(struct java_lang_String *)
native_netscape_softupdate_VerRegEnumerator_regNext(
JRIEnv* env,
struct netscape_softupdate_VerRegEnumerator* self )
{
REGERR status = REGERR_FAIL;
char pathbuf[MAXREGPATHLEN+1] = {0};
char* pszPath = NULL;
struct java_lang_String* javaPath = NULL;
REGENUM state = 0;
tmpEnv = env;
/* convert path to C string */
pszPath = (char*)JRI_GetStringUTFChars( env,
get_netscape_softupdate_VerRegEnumerator_path( env, self ) );
state = get_netscape_softupdate_VerRegEnumerator_state( env, self );
if ( pszPath != NULL ) {
XP_STRCPY( pathbuf, pszPath );
/* Get next path from Registry */
status = VR_Enum( NULL, &state, pathbuf, MAXREGPATHLEN );
/* if we got a good path */
if (status == REGERR_OK) {
/* convert new path back to java */
javaPath = JRI_NewStringUTF( tmpEnv, pathbuf, XP_STRLEN(pathbuf) );
set_netscape_softupdate_VerRegEnumerator_state( env, self, state );
}
}
return (javaPath);
}
/* ------------------------------------------------------------------
* Registry native methods
* ------------------------------------------------------------------
*/
/*** private native nOpen ()I ***/
JRI_PUBLIC_API(jint)
native_netscape_softupdate_Registry_nOpen(
JRIEnv* env,
struct netscape_softupdate_Registry* self)
{
char* pFilename;
HREG hReg;
REGERR status = REGERR_FAIL;
struct java_lang_String *filename;
filename = get_netscape_softupdate_Registry_regName( env, self);
hReg = (HREG)get_netscape_softupdate_Registry_hReg( env, self );
/* Registry must not be already open */
if ( hReg == NULL ) {
pFilename = (char*)JRI_GetStringPlatformChars( env, filename, "", 0 );
if ( pFilename != NULL ) {
status = NR_RegOpen( pFilename, &hReg );
if ( REGERR_OK == status ) {
set_netscape_softupdate_Registry_hReg( env, self, (jint)hReg );
}
}
}
return (status);
}
/*** private native nClose ()I ***/
JRI_PUBLIC_API(jint)
native_netscape_softupdate_Registry_nClose(
JRIEnv* env,
struct netscape_softupdate_Registry* self)
{
REGERR status = REGERR_FAIL;
HREG hReg = (HREG)get_netscape_softupdate_Registry_hReg( env, self );
/* Registry must not be already closed */
if ( hReg != NULL) {
status = NR_RegClose( hReg );
if ( REGERR_OK == status ) {
set_netscape_softupdate_Registry_hReg( env, self, (jint)NULL );
}
}
return (status);
}
/*** private native nAddKey (ILjava/lang/String;)I ***/
JRI_PUBLIC_API(jint)
native_netscape_softupdate_Registry_nAddKey(
JRIEnv* env,
struct netscape_softupdate_Registry* self,
jint rootKey,
struct java_lang_String *keyName)
{
char* pKey;
REGERR status = REGERR_FAIL;
HREG hReg = (HREG)get_netscape_softupdate_Registry_hReg( env, self );
pKey = (char*)JRI_GetStringUTFChars( env, keyName );
if ( pKey != NULL ) {
status = NR_RegAddKey( hReg, rootKey, pKey, NULL );
}
return(status);
}
/*** private native nDeleteKey (ILjava/lang/String;)I ***/
JRI_PUBLIC_API(jint)
native_netscape_softupdate_Registry_nDeleteKey(
JRIEnv* env,
struct netscape_softupdate_Registry* self,
jint rootKey,
struct java_lang_String *keyName)
{
char* pKey;
REGERR status = REGERR_FAIL;
HREG hReg = (HREG)get_netscape_softupdate_Registry_hReg( env, self );
pKey = (char*)JRI_GetStringUTFChars( env, keyName );
if ( pKey != NULL ) {
status = NR_RegDeleteKey( hReg, rootKey, pKey );
}
return(status);
}
/*** private native nGetKey (ILjava/lang/String;)Ljava/lang/Object; ***/
JRI_PUBLIC_API(struct netscape_softupdate_RegistryNode *)
native_netscape_softupdate_Registry_nGetKey(
JRIEnv* env,
struct netscape_softupdate_Registry* self,
jint rootKey,
struct java_lang_String *keyName,
struct java_lang_String *target )
{
char* pKey;
HREG hReg;
RKEY newkey;
REGERR status = REGERR_FAIL;
struct netscape_softupdate_RegistryNode *regKey = NULL;
hReg = (HREG)get_netscape_softupdate_Registry_hReg( env, self );
pKey = (char*)JRI_GetStringUTFChars( env, keyName );
if ( pKey != NULL ) {
status = NR_RegGetKey( hReg, rootKey, pKey, &newkey );
if ( REGERR_OK == status ) {
regKey = netscape_softupdate_RegistryNode_new(
env,
class_netscape_softupdate_RegistryNode(env),
self,
newkey,
target);
}
else {
JRI_ThrowNew(env,
class_netscape_softupdate_RegistryException(env),
"");
}
}
return (regKey);
}
/*** private native nUserName ()Ljava/lang/String; ***/
JRI_PUBLIC_API(struct java_lang_String *)
native_netscape_softupdate_Registry_nUserName(
JRIEnv* env,
struct netscape_softupdate_Registry* self)
{
char* profName;
int err;
struct java_lang_String *jname = NULL;
err = PREF_CopyDefaultCharPref( "profile.name", &profName );
if (err == PREF_NOERROR ) {
jname = JRI_NewStringPlatform(env, profName, XP_STRLEN(profName),"",0);
}
return jname;
}
/* ------------------------------------------------------------------
* RegistryNode native methods
* ------------------------------------------------------------------
*/
/*** public native deleteEntry (Ljava/lang/String;)I ***/
JRI_PUBLIC_API(jint)
native_netscape_softupdate_RegistryNode_nDeleteEntry(
JRIEnv* env,
struct netscape_softupdate_RegistryNode* self,
struct java_lang_String *name)
{
char* pName;
HREG hReg;
RKEY key;
REGERR status = REGERR_FAIL;
struct netscape_softupdate_Registry *reg;
reg = get_netscape_softupdate_RegistryNode_reg( env, self );
hReg = (HREG)get_netscape_softupdate_Registry_hReg( env, reg );
key = get_netscape_softupdate_RegistryNode_key( env, self );
pName = (char*)JRI_GetStringUTFChars( env, name );
if ( pName != NULL && hReg != NULL ) {
status = NR_RegDeleteEntry( hReg, key, pName );
}
return status;
}
/*** public native setEntry (Ljava/lang/String;Ljava/lang/String;)I ***/
JRI_PUBLIC_API(jint)
native_netscape_softupdate_RegistryNode_setEntryS(
JRIEnv* env,
struct netscape_softupdate_RegistryNode* self,
struct java_lang_String *name,
struct java_lang_String *value)
{
char* pName;
char* pValue;
HREG hReg;
RKEY key;
REGERR status = REGERR_FAIL;
struct netscape_softupdate_Registry *reg;
reg = get_netscape_softupdate_RegistryNode_reg( env, self );
hReg = (HREG)get_netscape_softupdate_Registry_hReg( env, reg );
key = get_netscape_softupdate_RegistryNode_key( env, self );
pName = (char*)JRI_GetStringUTFChars( env, name );
pValue = (char*)JRI_GetStringUTFChars( env, value );
if ( pName != NULL && pValue != NULL && hReg != NULL ) {
status = NR_RegSetEntryString( hReg, key, pName, pValue );
}
return status;
}
/*** public native setEntry (Ljava/lang/String;[I)I ***/
JRI_PUBLIC_API(jint)
native_netscape_softupdate_RegistryNode_setEntryI(
JRIEnv* env,
struct netscape_softupdate_RegistryNode* self,
struct java_lang_String *name,
jintArray value)
{
char* pName;
char* pValue = NULL;
uint32 datalen;
HREG hReg;
RKEY key;
REGERR status = REGERR_FAIL;
struct netscape_softupdate_Registry *reg;
reg = get_netscape_softupdate_RegistryNode_reg( env, self );
hReg = (HREG)get_netscape_softupdate_Registry_hReg( env, reg );
key = get_netscape_softupdate_RegistryNode_key( env, self );
pName = (char*)JRI_GetStringUTFChars( env, name );
pValue = (char*)JRI_GetIntArrayElements( env, value );
if ( pName != NULL && pValue != NULL && hReg != NULL ) {
datalen = JRI_GetIntArrayLength( env, value ) * sizeof(jint);
status = NR_RegSetEntry( hReg, key, pName,
REGTYPE_ENTRY_INT32_ARRAY, pValue, datalen );
}
return status;
}
/*** public native setEntry (Ljava/lang/String;[B)I ***/
JRI_PUBLIC_API(jint)
native_netscape_softupdate_RegistryNode_setEntryB(
JRIEnv* env,
struct netscape_softupdate_RegistryNode* self,
struct java_lang_String *name,
jbyteArray value)
{
char* pName = NULL;
char* pValue = NULL;
uint32 datalen;
HREG hReg;
RKEY key;
REGERR status = REGERR_FAIL;
struct netscape_softupdate_Registry *reg;
reg = get_netscape_softupdate_RegistryNode_reg( env, self );
hReg = (HREG)get_netscape_softupdate_Registry_hReg( env, reg );
key = get_netscape_softupdate_RegistryNode_key( env, self );
pName = (char*)JRI_GetStringUTFChars( env, name );
pValue = (char*)JRI_GetByteArrayElements( env, value );
if ( pName != NULL && pValue != NULL && hReg != NULL ) {
datalen = JRI_GetByteArrayLength( env, value );
status = NR_RegSetEntry( hReg, key, pName,
REGTYPE_ENTRY_BYTES, pValue, datalen );
}
return status;
}
/*** public native getEntryType (Ljava/lang/String;)I ***/
JRI_PUBLIC_API(jint)
native_netscape_softupdate_RegistryNode_nGetEntryType(
JRIEnv* env,
struct netscape_softupdate_RegistryNode* self,
struct java_lang_String *name)
{
char* pName;
jint type;
HREG hReg;
RKEY key;
REGERR status = REGERR_FAIL;
REGINFO info;
struct netscape_softupdate_Registry *reg;
XP_ASSERT(REGTYPE_ENTRY_STRING_UTF == netscape_softupdate_Registry_TYPE_STRING);
XP_ASSERT(REGTYPE_ENTRY_INT32_ARRAY == netscape_softupdate_Registry_TYPE_INT_ARRAY);
XP_ASSERT(REGTYPE_ENTRY_BYTES == netscape_softupdate_Registry_TYPE_BYTES);
reg = get_netscape_softupdate_RegistryNode_reg( env, self );
hReg = (HREG)get_netscape_softupdate_Registry_hReg( env, reg );
key = get_netscape_softupdate_RegistryNode_key( env, self );
pName = (char*)JRI_GetStringUTFChars( env, name );
if ( pName != NULL && hReg != NULL )
{
info.size = sizeof(REGINFO);
status = NR_RegGetEntryInfo( hReg, key, pName, &info );
if ( REGERR_OK == status ) {
type = info.entryType;
}
}
if ( REGERR_OK == status )
return type;
else
return ( -status );
}
/*** public native getEntry (Ljava/lang/String;)Ljava/lang/Object; ***/
JRI_PUBLIC_API(struct java_lang_Object *)
native_netscape_softupdate_RegistryNode_nGetEntry(
JRIEnv* env,
struct netscape_softupdate_RegistryNode* self,
struct java_lang_String *name)
{
char* pName;
void* pValue;
uint32 size;
HREG hReg;
RKEY key;
REGINFO info;
REGERR status = REGERR_FAIL;
struct netscape_softupdate_Registry *reg;
struct java_lang_Object *valObj = NULL;
reg = get_netscape_softupdate_RegistryNode_reg( env, self );
hReg = (HREG)get_netscape_softupdate_Registry_hReg( env, reg );
key = get_netscape_softupdate_RegistryNode_key( env, self );
pName = (char*)JRI_GetStringUTFChars( env, name );
if ( pName != NULL && hReg != NULL )
{
info.size = sizeof(REGINFO);
status = NR_RegGetEntryInfo( hReg, key, pName, &info );
if ( REGERR_OK == status )
{
size = info.entryLength;
pValue = malloc(size);
if ( pValue != NULL )
{
status = NR_RegGetEntry( hReg, key, pName, pValue, &size );
if ( REGERR_OK == status )
{
switch ( info.entryType )
{
case REGTYPE_ENTRY_STRING_UTF:
valObj = (struct java_lang_Object *)JRI_NewStringUTF(
env,
(char*)pValue,
XP_STRLEN((char*)pValue) );
break;
case REGTYPE_ENTRY_INT32_ARRAY:
valObj = (struct java_lang_Object *)JRI_NewIntArray(
env,
size/sizeof(jint),
(char*)pValue );
break;
case REGTYPE_ENTRY_BYTES:
default: /* for unknown types we return raw bits */
valObj = (struct java_lang_Object *)JRI_NewByteArray(
env,
size,
(char*)pValue );
break;
case REGTYPE_ENTRY_FILE:
valObj = (struct java_lang_Object *)JRI_NewStringPlatform(
env,
(char*)pValue,
XP_STRLEN((char*)pValue), "", 0 );
break;
}
}
XP_FREE(pValue);
} /* pValue != NULL */
}
}
return valObj;
}
/* ------------------------------------------------------------------
* RegKeyEnumerator native methods
* ------------------------------------------------------------------
*/
/*** private native regNext ()Ljava/lang/String; ***/
JRI_PUBLIC_API(struct java_lang_String *)
native_netscape_softupdate_RegKeyEnumerator_regNext(
JRIEnv* env,
struct netscape_softupdate_RegKeyEnumerator* self,
jbool skip)
{
HREG hReg;
RKEY key;
REGERR status = REGERR_FAIL;
REGENUM state = 0;
uint32 style;
char pathbuf[MAXREGPATHLEN+1] = {0};
char* pPath = NULL;
struct netscape_softupdate_Registry *reg;
struct java_lang_String *path;
struct java_lang_String *javaPath = NULL;
reg = get_netscape_softupdate_RegKeyEnumerator_reg( env, self );
hReg = (HREG)get_netscape_softupdate_Registry_hReg( env, reg );
key = get_netscape_softupdate_RegKeyEnumerator_key( env, self );
state = get_netscape_softupdate_RegKeyEnumerator_state( env, self );
style = get_netscape_softupdate_RegKeyEnumerator_style( env, self );
/* convert path to C string */
path = get_netscape_softupdate_RegKeyEnumerator_path( env, self );
pPath = (char*)JRI_GetStringUTFChars( env, path );
if ( pPath != NULL ) {
XP_STRCPY( pathbuf, pPath );
/* Get next path from Registry */
status = NR_RegEnumSubkeys( hReg, key, &state, pathbuf,
sizeof(pathbuf), style );
/* if we got a good path */
if (status == REGERR_OK) {
/* convert new path back to java and save state */
javaPath = JRI_NewStringUTF( env, pathbuf, XP_STRLEN(pathbuf) );
if ( skip ) {
set_netscape_softupdate_RegKeyEnumerator_state( env, self, state );
}
}
}
return (javaPath);
}
/* ------------------------------------------------------------------
* RegEntryEnumerator native methods
* ------------------------------------------------------------------
*/
/*** private native regNext ()Ljava/lang/String; ***/
JRI_PUBLIC_API(struct java_lang_String *)
native_netscape_softupdate_RegEntryEnumerator_regNext(
JRIEnv* env,
struct netscape_softupdate_RegEntryEnumerator* self,
jbool skip)
{
HREG hReg;
RKEY key;
REGERR status = REGERR_FAIL;
REGENUM state = 0;
char namebuf[MAXREGPATHLEN+1] = {0};
char* pName = NULL;
struct netscape_softupdate_Registry *reg;
struct java_lang_String *name;
struct java_lang_String *javaName = NULL;
reg = get_netscape_softupdate_RegEntryEnumerator_reg( env, self );
hReg = (HREG)get_netscape_softupdate_Registry_hReg( env, reg );
key = get_netscape_softupdate_RegEntryEnumerator_key( env, self );
state = get_netscape_softupdate_RegEntryEnumerator_state( env, self );
/* convert name to C string */
name = get_netscape_softupdate_RegEntryEnumerator_name( env, self );
pName = (char*)JRI_GetStringUTFChars( env, name );
if ( pName != NULL ) {
XP_STRCPY( namebuf, pName );
/* Get next name from Registry */
status = NR_RegEnumEntries( hReg, key, &state, namebuf,
sizeof(namebuf), NULL );
/* if we got a good name */
if (status == REGERR_OK) {
/* convert new name back to java and save state */
javaName = JRI_NewStringUTF( env, namebuf, XP_STRLEN(namebuf) );
if (skip)
set_netscape_softupdate_RegEntryEnumerator_state( env, self, state );
}
}
return (javaName);
}
#endif /* NEVER */