Merging 4.5 softupdate changes and converting Java code into C++ code and making smartupdate build when MOZ_SMARTUPDATE is defined

This commit is contained in:
raman%netscape.com 1998-09-02 19:09:53 +00:00
parent 2f45d24ca2
commit 12a50d30c6
36 changed files with 2740 additions and 3276 deletions

View File

@ -16,6 +16,6 @@
# Reserved.
DEPTH = ../..
DIRS = classes src include
DIRS = src include
include $(DEPTH)/config/rules.mk

View File

@ -22,6 +22,6 @@ srcdir = @srcdir@
include $(DEPTH)/config/autoconf.mk
DIRS = classes src include
DIRS = src include
include $(topsrcdir)/config/rules.mk

View File

@ -19,6 +19,6 @@ DEPTH = ../../..
MODULE = softupdt
EXPORTS = softupdt.h su_folderspec.h gdiff.h
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
include $(DEPTH)/config/rules.mk

View File

@ -24,7 +24,7 @@ include $(DEPTH)/config/autoconf.mk
MODULE = softupdt
EXPORTS = softupdt.h su_folderspec.h gdiff.h
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 := $(addprefix $(srcdir)/, $(EXPORTS))

View File

@ -88,8 +88,12 @@
* types
*------------------------------------*/
#ifndef AIX
#ifdef OSF1
#include <sys/types.h>
#else
typedef unsigned char uchar;
#endif
#endif
typedef struct _diffdata {
XP_File fSrc;

View File

@ -21,7 +21,7 @@ IGNORE_MANIFEST=1
DEPTH=..\..\..
MODULE=softupdt
EXPORTS=softupdt.h su_folderspec.h gdiff.h
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
#//------------------------------------------------------------------------
#//

View File

@ -86,40 +86,31 @@ typedef enum nsTriggerDiffLevelEnum {
} nsTriggerDiffLevelEnum;
typedef enum nsWinRegEnum {
/* not static because class is not public--users couldn't get to them */
HKEY_CLASSES_ROOT = 0x80000000,
HKEY_CURRENT_USER = 0x80000001,
HKEY_LOCAL_MACHINE = 0x80000002,
HKEY_USERS = 0x80000003,
CREATE = 1,
DELETE = 2,
DELETE_VAL = 3,
SET_VAL_STRING = 4,
SET_VAL = 5
NS_WIN_REG_CREATE = 1,
NS_WIN_REG_DELETE = 2,
NS_WIN_REG_DELETE_VAL = 3,
NS_WIN_REG_SET_VAL_STRING = 4,
NS_WIN_REG_SET_VAL = 5
} nsWinRegEnum;
typedef enum nsWinRegValueEnum {
REG_SZ = 1,
REG_EXPAND_SZ = 2,
REG_BINARY = 3,
REG_DWORD = 4,
REG_DWORD_LITTLE_ENDIAN = 4,
REG_DWORD_BIG_ENDIAN = 5,
REG_LINK = 6,
REG_MULTI_SZ = 7,
REG_RESOURCE_LIST = 8,
REG_FULL_RESOURCE_DESCRIPTOR = 9,
REG_RESOURCE_REQUIREMENTS_LIST = 10
NS_WIN_REG_SZ = 1,
NS_WIN_REG_EXPAND_SZ = 2,
NS_WIN_REG_BINARY = 3,
NS_WIN_REG_DWORD = 4,
NS_WIN_REG_DWORD_LITTLE_ENDIAN = 4,
NS_WIN_REG_DWORD_BIG_ENDIAN = 5,
NS_WIN_REG_LINK = 6,
NS_WIN_REG_MULTI_SZ = 7,
NS_WIN_REG_RESOURCE_LIST = 8,
NS_WIN_REG_FULL_RESOURCE_DESCRIPTOR = 9,
NS_WIN_REG_RESOURCE_REQUIREMENTS_LIST = 10
} nsWinRegValueEnum;
typedef enum nsRegistryErrorsEnum {
REGERR_BADUTF8 = 19,
REGERR_SECURITY = 99,
} nsRegistryErrorsEnum;
#endif /* nsSoftUpdateEnums_h__ */

View File

@ -22,6 +22,24 @@
#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 {
@ -30,25 +48,6 @@ public:
/* Public Fields */
/**
* 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;
/* Public Methods */
/**
* @return true if SmartUpdate is enabled

View File

@ -20,6 +20,10 @@
/* Public */
typedef void (*SoftUpdateCompletionFunction) (int result, void * closure);
#ifdef XP_WIN16
extern XP_Bool utilityScheduled = FALSE;
#endif
XP_BEGIN_PROTOS
/* Flags for start software update */
@ -46,18 +50,35 @@ extern XP_Bool SU_StartSoftwareUpdate(MWContext * context,
/* SU_NewStream
* Stream decoder for software updates
*/
NET_StreamClass * SU_NewStream (int format_out, void * registration,
URL_Struct * request, MWContext *context);
extern NET_StreamClass * SU_NewStream (int format_out, void * registration,
URL_Struct * request, MWContext *context);
int32 SU_PatchFile( char* srcfile, XP_FileType srctype,
char* patchfile, XP_FileType patchtype,
char* targfile, XP_FileType targtype );
extern int32 SU_PatchFile( char* srcfile, XP_FileType srctype,
char* patchfile, XP_FileType patchtype,
char* targfile, XP_FileType targtype );
int32 SU_Uninstall(char *regPackageName);
int32 SU_EnumUninstall(void** context, char* packageName,
int32 len1, char*regPackageName, int32 len2);
extern int32 SU_Uninstall(char *regPackageName);
/* 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.
* When SU_EnumUninstall is first called, *context should be null. Context
* keeps track of which list we are traversing, either shared or the current
* communicator list. If we are able to enumerate all packages without any
* errors, context is freed in the routine, otherwise you must XP_FREE it yourself.
* packageName - user readable package name (if this is blank you could use
* regPackageName as a substitute).
* len1 - sizeof(packageName)
* regPackageName - name of package name installed. This name is unique
* and is what should be passed to SU_Uninstall()
* len2 - sizeof(regPackageName)
*/
extern int32 SU_EnumUninstall(void** context, char* packageName,
int32 len1, char*regPackageName, int32 len2);
#define AUTOUPDATE_ENABLE_PREF "autoupdate.enabled"
#define AUTOUPDATE_CONFIRM_PREF "autoupdate.confirm_install"
#define CHARSET_HEADER "Charset"
#define CONTENT_ENCODING_HEADER "Content-encoding"
#define INSTALLER_HEADER "Install-Script"

View File

@ -0,0 +1,42 @@
#define AS_MAGIC_NUM 0x00051600 /* Magic start of the file */
#define AS_DEFAULT_CREATOR 'MPS '
#define AS_DEFAULT_TYPE '????'
/* entryIDs */
#define AS_DATA 1 /* data fork */
#define AS_RESOURCE 2 /* resource fork */
#define AS_REALNAME 3 /* File's name on home file system */
#define AS_COMMENT 4 /* standard Mac comment */
#define AS_ICONBW 5 /* Mac black & white icon */
#define AS_ICONCOLOR 6 /* Mac color icon */
/* 7 /* not used */
#define AS_FILEDATES 8 /* file dates; create, modify, etc */
#define AS_FINDERINFO 9 /* Mac Finder info & extended info */
#define AS_MACINFO 10 /* Mac file info, attributes, etc */
#define AS_PRODOSINFO 11 /* Pro-DOS file info, attrib., etc */
#define AS_MSDOSINFO 12 /* MS-DOS file info, attributes, etc */
#define AS_AFPNAME 13 /* Short name on AFP server */
#define AS_AFPINFO 14 /* AFP file info, attrib., etc */
#define AS_AFPDIRID 15 /* AFP directory ID */
/* Because it seems that 1 << AS_FINDER_INFO operation works unreliably, I'll just define these
as constants */
#define AS_DATA_BIT 0x0001
#define AS_RESOURCE_BIT 0x0002
#define AS_REALNAME_BIT 0x0004
#define AS_COMMENT_BIT 0x0008
#define AS_ICONBW_BIT 0x0010
#define AS_ICONCOLOR_BIT 0x0020
#define AS_FILEDATES_BIT 0x0080
#define AS_FINDERINFO_BIT 0x0100
#define AS_MACINFO_BIT 0x0200
#define AS_PRODOSINFO_BIT 0x0400
#define AS_MSDOSINFO_BIT 0x0800
#define AS_AFPNAME_BIT 0x1000
#define AS_AFPINFO_BIT 0x2000
#define AS_AFPDIRID_BIT 0x4000
#define AS_ALLENTRIES 0xFFFF

View File

@ -24,6 +24,19 @@
*/
#include "xp_mcom.h"
#include "prtypes.h"
#include "ntypes.h"
/* su_PickDirTimer
* keeps track of all SU specific data needed for the stream
*/
typedef struct su_PickDirTimer_struct {
MWContext * context;
char * fileName;
char * prompt;
XP_Bool done;
} su_PickDirTimer;
typedef enum su_DirSpecID {
@ -73,6 +86,15 @@ typedef enum su_SecurityLevel {
eAllFolderAccess
} su_SecurityLevel;
struct su_DirectoryTable
{
char * directoryName; /* The formal directory name */
su_SecurityLevel securityLevel; /* Security level */
su_DirSpecID folderEnum; /* Directory ID */
};
extern struct su_DirectoryTable DirectoryTable[];
XP_BEGIN_PROTOS
/* FE_GetDirectoryPath
@ -86,4 +108,16 @@ int FE_ReplaceExistingFile(char *, XP_FileType, char *, XP_FileType, XP_Bool)
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
*/
char * AppendSlashToDirPath(char * dirPath);
/* MapNameToEnum
* maps name from the directory table to its enum */
su_DirSpecID MapNameToEnum(const char * name);
XP_END_PROTOS

View File

@ -18,14 +18,14 @@
DEPTH=..\..
DIRS=classes src include
DIRS=src include
include <$(DEPTH)\config\rules.mak>
build_classes:
cd $(DEPTH)\modules\softupdt
$(NMAKE) -f makefile.win
cd $(DEPTH)\sun-java\classsrc
$(NMAKE) -f makefile.win java$(VERSION_NUMBER).jar
cd $(DEPTH)\cmd\winfe\mkfiles32
$(NMAKE) -f mozilla.mak
# cd $(DEPTH)\modules\softupdt
# $(NMAKE) -f makefile.win
# cd $(DEPTH)\sun-java\classsrc
# $(NMAKE) -f makefile.win java$(VERSION_NUMBER).jar
# cd $(DEPTH)\cmd\winfe\mkfiles32
# $(NMAKE) -f mozilla.mak

View File

@ -25,70 +25,47 @@ MODULE = softupdate
LIBRARY_NAME = softupdate
REQUIRES = softupdt js java net dbm nspr img util layer pref \
jar security lay style libreg network progress zlib
jar security lay style libreg network progress base xpcom caps zlib
INCLUDES += -I$(DEPTH)/base/src
ifeq ($(MOZ_OJI),1)
REQUIRES += oji npj
endif
ifeq ($(MOZ_JAVA),1)
REQUIRES += applet
endif
JRI_GEN = netscape.softupdate.FolderSpec \
netscape.softupdate.InstallDelete \
netscape.softupdate.InstallObject \
netscape.softupdate.InstallFile \
netscape.softupdate.InstallPatch \
netscape.softupdate.InstallExecute \
netscape.softupdate.Registry \
netscape.softupdate.RegistryNode \
netscape.softupdate.RegistryException \
netscape.softupdate.RegKeyEnumerator \
netscape.softupdate.RegEntryEnumerator \
netscape.softupdate.SoftwareUpdate \
netscape.softupdate.SoftUpdateException \
netscape.softupdate.Strings \
netscape.softupdate.Trigger \
netscape.softupdate.VersionInfo \
netscape.softupdate.VersionRegistry \
netscape.softupdate.VerRegEnumerator \
java.lang.Integer \
$(NULL)
CSRCS = softupdt.c \
CSRCS = \
softupdt.c \
su_trigger.c \
su_patch.c \
su_folderspec.c \
su_instl.c \
su_nodl.c \
vr_java.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 \
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
JRI_GEN += netscape.softupdate.WinReg netscape.softupdate.WinProfile netscape.softupdate.WinRegValue
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
endif
EXPORTS = ../include/softupdt.h \
$(JRI_GEN_DIR)/netscape_softupdate_InstallDelete.h \
$(JRI_GEN_DIR)/netscape_softupdate_InstallFile.h \
$(JRI_GEN_DIR)/netscape_softupdate_InstallObject.h \
$(JRI_GEN_DIR)/netscape_softupdate_SoftwareUpdate.h \
$(JRI_GEN_DIR)/netscape_softupdate_SoftUpdateException.h \
$(JRI_GEN_DIR)/netscape_softupdate_VersionInfo.h \
$(JRI_GEN_DIR)/netscape_softupdate_VersionRegistry.h \
$(JRI_GEN_DIR)/netscape_softupdate_VerRegEnumerator.h \
$(JRI_GEN_DIR)/netscape_softupdate_Registry.h \
$(JRI_GEN_DIR)/netscape_softupdate_RegistryNode.h \
$(JRI_GEN_DIR)/netscape_softupdate_RegistryException.h \
$(JRI_GEN_DIR)/netscape_softupdate_RegKeyEnumerator.h \
$(JRI_GEN_DIR)/netscape_softupdate_RegEntryEnumerator.h \
$(JRI_GEN_DIR)/netscape_softupdate_Strings.h \
$(JRI_GEN_DIR)/netscape_softupdate_Trigger.h \
$(JRI_GEN_DIR)/netscape_softupdate_FolderSpec.h \
$(NULL)
include $(DEPTH)/config/rules.mk
@ -96,29 +73,3 @@ include $(DEPTH)/config/rules.mk
ifeq ($(OS_ARCH),OS2)
INCLUDES += -I$(DEPTH)/cmd/os2fe/nfc/include -I$(DEPTH)/cmd/os2fe
endif
$(OBJDIR)/su_folderspec.o: $(JRI_GEN_DIR)/netscape_softupdate_FolderSpec.c \
$(JRI_GEN_DIR)/netscape_softupdate_SoftwareUpdate.h
$(OBJDIR)/su_instl.o: $(JRI_GEN_DIR)/netscape_softupdate_InstallFile.c \
$(JRI_GEN_DIR)/netscape_softupdate_InstallDelete.c \
$(JRI_GEN_DIR)/netscape_softupdate_InstallObject.c \
$(JRI_GEN_DIR)/netscape_softupdate_InstallExecute.c \
$(JRI_GEN_DIR)/netscape_softupdate_InstallPatch.c \
$(JRI_GEN_DIR)/netscape_softupdate_SoftwareUpdate.h \
$(JRI_GEN_DIR)/netscape_softupdate_SoftUpdateException.h \
$(JRI_GEN_DIR)/netscape_softupdate_Strings.h
$(OBJDIR)/su_trigger.o: $(JRI_GEN_DIR)/netscape_softupdate_Trigger.c \
$(JRI_GEN_DIR)/netscape_softupdate_SoftUpdateException.c \
$(JRI_GEN_DIR)/netscape_softupdate_SoftwareUpdate.c \
$(JRI_GEN_DIR)/netscape_softupdate_Strings.c
$(OBJDIR)/vr_java.o: $(JRI_GEN_DIR)/netscape_softupdate_VersionInfo.h \
$(JRI_GEN_DIR)/netscape_softupdate_VersionRegistry.h \
$(JRI_GEN_DIR)/netscape_softupdate_VerRegEnumerator.h \
$(JRI_GEN_DIR)/netscape_softupdate_Registry.h \
$(JRI_GEN_DIR)/netscape_softupdate_RegistryNode.h \
$(JRI_GEN_DIR)/netscape_softupdate_RegistryException.h \
$(JRI_GEN_DIR)/netscape_softupdate_RegKeyEnumerator.h \
$(JRI_GEN_DIR)/netscape_softupdate_RegEntryEnumerator.h

View File

@ -30,70 +30,47 @@ MODULE = softupdate
LIBRARY_NAME = softupdate
REQUIRES = softupdt js java net dbm nspr img util layer pref \
jar security lay style libreg network progress zlib
jar security lay style libreg network progress base xpcom caps zlib
INCLUDES += -I$(topsrcdir)/base/src
ifeq ($(MOZ_OJI),1)
REQUIRES += oji npj
endif
ifeq ($(MOZ_JAVA),1)
REQUIRES += applet
endif
JRI_GEN = netscape.softupdate.FolderSpec \
netscape.softupdate.InstallDelete \
netscape.softupdate.InstallObject \
netscape.softupdate.InstallFile \
netscape.softupdate.InstallPatch \
netscape.softupdate.InstallExecute \
netscape.softupdate.Registry \
netscape.softupdate.RegistryNode \
netscape.softupdate.RegistryException \
netscape.softupdate.RegKeyEnumerator \
netscape.softupdate.RegEntryEnumerator \
netscape.softupdate.SoftwareUpdate \
netscape.softupdate.SoftUpdateException \
netscape.softupdate.Strings \
netscape.softupdate.Trigger \
netscape.softupdate.VersionInfo \
netscape.softupdate.VersionRegistry \
netscape.softupdate.VerRegEnumerator \
java.lang.Integer \
$(NULL)
CSRCS = softupdt.c \
su_trigger.c \
su_patch.c \
su_folderspec.c \
su_instl.c \
su_nodl.c \
vr_java.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 \
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
JRI_GEN += netscape.softupdate.WinReg netscape.softupdate.WinProfile netscape.softupdate.WinRegValue
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
endif
EXPORTS = $(srcdir)/../include/softupdt.h \
$(JRI_GEN_DIR)/netscape_softupdate_InstallDelete.h \
$(JRI_GEN_DIR)/netscape_softupdate_InstallFile.h \
$(JRI_GEN_DIR)/netscape_softupdate_InstallObject.h \
$(JRI_GEN_DIR)/netscape_softupdate_SoftwareUpdate.h \
$(JRI_GEN_DIR)/netscape_softupdate_SoftUpdateException.h \
$(JRI_GEN_DIR)/netscape_softupdate_VersionInfo.h \
$(JRI_GEN_DIR)/netscape_softupdate_VersionRegistry.h \
$(JRI_GEN_DIR)/netscape_softupdate_VerRegEnumerator.h \
$(JRI_GEN_DIR)/netscape_softupdate_Registry.h \
$(JRI_GEN_DIR)/netscape_softupdate_RegistryNode.h \
$(JRI_GEN_DIR)/netscape_softupdate_RegistryException.h \
$(JRI_GEN_DIR)/netscape_softupdate_RegKeyEnumerator.h \
$(JRI_GEN_DIR)/netscape_softupdate_RegEntryEnumerator.h \
$(JRI_GEN_DIR)/netscape_softupdate_Strings.h \
$(JRI_GEN_DIR)/netscape_softupdate_Trigger.h \
$(JRI_GEN_DIR)/netscape_softupdate_FolderSpec.h \
$(NULL)
include $(topsrcdir)/config/rules.mk
@ -101,29 +78,3 @@ include $(topsrcdir)/config/rules.mk
ifeq ($(OS_ARCH),OS2)
INCLUDES += -I$(topsrcdir)/cmd/os2fe/nfc/include -I$(topsrcdir)/cmd/os2fe
endif
$(OBJDIR)/su_folderspec.o: $(JRI_GEN_DIR)/netscape_softupdate_FolderSpec.c \
$(JRI_GEN_DIR)/netscape_softupdate_SoftwareUpdate.h
$(OBJDIR)/su_instl.o: $(JRI_GEN_DIR)/netscape_softupdate_InstallFile.c \
$(JRI_GEN_DIR)/netscape_softupdate_InstallDelete.c \
$(JRI_GEN_DIR)/netscape_softupdate_InstallObject.c \
$(JRI_GEN_DIR)/netscape_softupdate_InstallExecute.c \
$(JRI_GEN_DIR)/netscape_softupdate_InstallPatch.c \
$(JRI_GEN_DIR)/netscape_softupdate_SoftwareUpdate.h \
$(JRI_GEN_DIR)/netscape_softupdate_SoftUpdateException.h \
$(JRI_GEN_DIR)/netscape_softupdate_Strings.h
$(OBJDIR)/su_trigger.o: $(JRI_GEN_DIR)/netscape_softupdate_Trigger.c \
$(JRI_GEN_DIR)/netscape_softupdate_SoftUpdateException.c \
$(JRI_GEN_DIR)/netscape_softupdate_SoftwareUpdate.c \
$(JRI_GEN_DIR)/netscape_softupdate_Strings.c
$(OBJDIR)/vr_java.o: $(JRI_GEN_DIR)/netscape_softupdate_VersionInfo.h \
$(JRI_GEN_DIR)/netscape_softupdate_VersionRegistry.h \
$(JRI_GEN_DIR)/netscape_softupdate_VerRegEnumerator.h \
$(JRI_GEN_DIR)/netscape_softupdate_Registry.h \
$(JRI_GEN_DIR)/netscape_softupdate_RegistryNode.h \
$(JRI_GEN_DIR)/netscape_softupdate_RegistryException.h \
$(JRI_GEN_DIR)/netscape_softupdate_RegKeyEnumerator.h \
$(JRI_GEN_DIR)/netscape_softupdate_RegEntryEnumerator.h

View File

@ -56,46 +56,33 @@ PDBFILE=$(LIBNAME).pdb
#// Define the files necessary to build the target (ie. OBJS)
#//
#//------------------------------------------------------------------------
OBJS= \
.\$(OBJDIR)\softupdt.obj \
.\$(OBJDIR)\su_folderspec.obj \
.\$(OBJDIR)\su_instl.obj \
.\$(OBJDIR)\su_trigger.obj \
.\$(OBJDIR)\su_patch.obj \
.\$(OBJDIR)\su_win.obj \
.\$(OBJDIR)\vr_java.obj \
!if "$(MOZ_BITS)" == "16"
.\$(OBJDIR)\su_nodl.obj \
!endif
.\$(OBJDIR)\su_wjava.obj \
$(NULL)
OBJS= \
.\$(OBJDIR)\softupdt.obj \
.\$(OBJDIR)\su_trigger.obj \
.\$(OBJDIR)\su_patch.obj \
.\$(OBJDIR)\su_folderspec.obj \
.\$(OBJDIR)\su_instl.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)\nsWinRegValue.obj \
.\$(OBJDIR)\nsTrigger.obj \
$(NULL)
JRI_GEN= \
java.lang.Integer \
netscape.softupdate.FolderSpec \
netscape.softupdate.InstallDelete \
netscape.softupdate.InstallObject \
netscape.softupdate.InstallFile \
netscape.softupdate.InstallPatch \
netscape.softupdate.InstallExecute \
netscape.softupdate.Registry \
netscape.softupdate.RegistryNode \
netscape.softupdate.RegistryException \
netscape.softupdate.RegKeyEnumerator \
netscape.softupdate.RegEntryEnumerator \
netscape.softupdate.SoftwareUpdate \
netscape.softupdate.SoftUpdateException \
netscape.softupdate.Strings \
netscape.softupdate.Trigger \
netscape.softupdate.VersionInfo \
netscape.softupdate.VersionRegistry \
netscape.softupdate.VerRegEnumerator \
netscape.softupdate.WinProfile \
netscape.softupdate.WinReg \
netscape.softupdate.WinRegValue \
$(NULL)
#//------------------------------------------------------------------------
#//
#// Define any Public Targets here (ie. PROGRAM, LIBRARY, DLL, ...)
@ -111,12 +98,13 @@ LIBRARY= .\$(OBJDIR)\$(LIBNAME).lib
#// (ie. LCFLAGS, LLFLAGS, LLIBS, LINCS)
#//
#//------------------------------------------------------------------------
LINCS= $(LINCS) -I_jri \
LINCS= $(LINCS) \
-I../include \
-I$(DEPTH)/lib/libnet \
-I$(DEPTH)/lib/layout \
-I$(DEPTH)/lib/libstyle \
-I$(DEPTH)/cmd/winfe \
-I$(DEPTH)/base/src \
$(NULL)
#//
@ -130,23 +118,24 @@ LINCS= $(LINCS) \
#if defined(MOZ_OJI)
-I$(PUBLIC)/oji \
-I$(PUBLIC)/npj \
#elseif defined(MOZ_JAVA)
-I$(PUBLIC)/applet \
#endif
-I$(PUBLIC)/java \
-I$(PUBLIC)/nspr \
-I$(PUBLIC)/js \
-I$(PUBLIC)/dbm \
-I$(PUBLIC)/security \
-I$(PUBLIC)/jar \
-I$(PUBLIC)/jar \
-I$(PUBLIC)/pref \
-I$(PUBLIC)/progress \
-I$(PUBLIC)/progress \
-I$(PUBLIC)/base \
-I$(PUBLIC)/xpcom \
-I$(PUBLIC)/caps \
-I$(PUBLIC)/libfont \
-I$(PUBLIC)/jtools \
-I$(PUBLIC)/winfont \
-I$(PUBLIC)/rdf \
-I$(PUBLIC)/network \
-I$(PUBLIC)/zlib \
-I$(PUBLIC)/zlib \
$(NULL)
!endif
@ -166,60 +155,10 @@ PUBLIC_HEADER_DIR=$(PUBLIC)\win16
!endif
export::
$(MAKE_INSTALL) _jri\netscape_softupdate_InstallObject.h $(PUBLIC_HEADER_DIR)
$(MAKE_INSTALL) _jri\netscape_softupdate_InstallFile.h $(PUBLIC_HEADER_DIR)
$(MAKE_INSTALL) _jri\netscape_softupdate_InstallExecute.h $(PUBLIC_HEADER_DIR)
$(MAKE_INSTALL) _jri\netscape_softupdate_InstallDelete.h $(PUBLIC_HEADER_DIR)
$(MAKE_INSTALL) _jri\netscape_softupdate_InstallPatch.h $(PUBLIC_HEADER_DIR)
$(MAKE_INSTALL) _jri\netscape_softupdate_Registry.h $(PUBLIC_HEADER_DIR)
$(MAKE_INSTALL) _jri\netscape_softupdate_RegistryNode.h $(PUBLIC_HEADER_DIR)
$(MAKE_INSTALL) _jri\netscape_softupdate_RegistryException.h $(PUBLIC_HEADER_DIR)
$(MAKE_INSTALL) _jri\netscape_softupdate_RegKeyEnumerator.h $(PUBLIC_HEADER_DIR)
$(MAKE_INSTALL) _jri\netscape_softupdate_RegEntryEnumerator.h $(PUBLIC_HEADER_DIR)
$(MAKE_INSTALL) _jri\netscape_softupdate_SoftwareUpdate.h $(PUBLIC_HEADER_DIR)
$(MAKE_INSTALL) _jri\netscape_softupdate_SoftUpdateException.h $(PUBLIC_HEADER_DIR)
$(MAKE_INSTALL) _jri\netscape_softupdate_Strings.h $(PUBLIC_HEADER_DIR)
$(MAKE_INSTALL) _jri\netscape_softupdate_Trigger.h $(PUBLIC_HEADER_DIR)
$(MAKE_INSTALL) _jri\netscape_softupdate_FolderSpec.h $(PUBLIC_HEADER_DIR)
$(MAKE_INSTALL) _jri\netscape_softupdate_VersionRegistry.h $(PUBLIC_HEADER_DIR)
$(MAKE_INSTALL) _jri\netscape_softupdate_VersionInfo.h $(PUBLIC_HEADER_DIR)
$(MAKE_INSTALL) _jri\netscape_softupdate_VerRegEnumerator.h $(PUBLIC_HEADER_DIR)
$(MAKE_INSTALL) _jri\netscape_softupdate_WinProfile.h $(PUBLIC_HEADER_DIR)
$(MAKE_INSTALL) _jri\netscape_softupdate_WinReg.h $(PUBLIC_HEADER_DIR)
$(MAKE_INSTALL) _jri\netscape_softupdate_WinRegValue.h $(PUBLIC_HEADER_DIR)
$(MAKE_INSTALL) _jri\java_lang_Integer.h $(PUBLIC)\libreg
install:: $(LIBRARY)
$(MAKE_INSTALL) $(LIBRARY) $(DIST)\lib
clobber::
$(RM_R) _jri
.\$(OBJDIR)\su_folderspec.obj: \
$(JRI_GEN_DIR)\netscape_softupdate_FolderSpec.c \
$(JRI_GEN_DIR)/netscape_softupdate_SoftwareUpdate.h \
\$(OBJDIR)\su_instl.obj: \
$(JRI_GEN_DIR)\netscape_softupdate_InstallDelete.c \
$(JRI_GEN_DIR)\netscape_softupdate_InstallFile.c \
$(JRI_GEN_DIR)\netscape_softupdate_InstallExecute.c \
$(JRI_GEN_DIR)\netscape_softupdate_InstallObject.c \
$(JRI_GEN_DIR)\netscape_softupdate_InstallPatch.c \
$(JRI_GEN_DIR)\netscape_softupdate_SoftwareUpdate.h \
$(JRI_GEN_DIR)\netscape_softupdate_SoftUpdateException.h \
$(JRI_GEN_DIR)\netscape_softupdate_Strings.c \
$(JRI_GEN_DIR)\netscape_softupdate_Strings.h
.\$(OBJDIR)\su_trigger.obj: \
$(JRI_GEN_DIR)\netscape_softupdate_Trigger.c \
$(JRI_GEN_DIR)\netscape_softupdate_SoftUpdateException.c \
$(JRI_GEN_DIR)\netscape_softupdate_SoftwareUpdate.c \
$(JRI_GEN_DIR)\netscape_softupdate_Strings.c
.\$(OBJDIR)\su_wjava.obj: \
$(JRI_GEN_DIR)\netscape_softupdate_WinProfile.c \
$(JRI_GEN_DIR)\netscape_softupdate_WinReg.c \
$(JRI_GEN_DIR)\netscape_softupdate_WinRegValue.c

View File

@ -22,6 +22,7 @@
#include "prprf.h"
#include "xp.h"
#include "softupdt.h"
#include "su_instl.h"
#include "nsInstallDelete.h"
#include "nsVersionRegistry.h"
#include "nsSUError.h"

View File

@ -34,6 +34,9 @@ extern int SU_ERROR_INSTALL_FILE_UNEXPECTED;
extern int SU_DETAILS_REPLACE_FILE_MSG_ID;
extern int SU_DETAILS_INSTALL_FILE_MSG_ID;
#ifdef XP_WIN16
XP_Bool utilityScheduled = FALSE;
#endif
PR_BEGIN_EXTERN_C
@ -256,13 +259,13 @@ char* nsInstallFile::Complete()
/* XXX: Fix it. memeory leak */
found = nsVersionRegistry::uninstallFileExists(regPackageName->ToNewCString(), vrName->ToNewCString());
if (found != REGERR_OK)
bUpgrade = false;
bUpgrade = PR_FALSE;
else
bUpgrade = true;
bUpgrade = PR_TRUE;
} else if (REGERR_OK == nsVersionRegistry::inRegistry(vrName->ToNewCString())) {
bUpgrade = true;
bUpgrade = PR_TRUE;
} else {
bUpgrade = false;
bUpgrade = PR_FALSE;
}
refCount = nsVersionRegistry::getRefCount(vrName->ToNewCString());

View File

@ -147,10 +147,10 @@ char* nsInstallPatch::Prepare(void)
IntegerKey ikey(PL_HashString(targetfile));
srcname = (char *)softUpdate->patchList->Get( &ikey );
if (srcname != NULL) {
deleteOldSrc = true;
deleteOldSrc = PR_TRUE;
} else {
srcname = targetfile;
deleteOldSrc = false;
deleteOldSrc = PR_FALSE;
}
patchedfile = NativePatch( srcname, patchURL, &errorMsg );

View File

@ -34,6 +34,7 @@
#include "nsInstallPatch.h"
#include "nsVersionRegistry.h"
#include "nsSUError.h"
#include "nsWinProfile.h"
#include "nsWinReg.h"
#include "nsPrivilegeManager.h"
#include "nsTarget.h"
@ -87,11 +88,6 @@ static PRBool su_PathEndsWithSeparator(char* path, char* sep);
extern char * WH_TempFileName(int type, const char * prefix, const char * extension);
#endif
extern void FolderSpecInitialize(JRIEnv * env);
extern void InstallFileInitialize(JRIEnv * env);
extern void SU_Reg_Initialize(JRIEnv *env );
extern void SUWinSpecificInit( JRIEnv *env );
extern uint32 FE_DiskSpaceAvailable (MWContext *context, const char *lpszPath );
@ -275,7 +271,7 @@ void* nsSoftwareUpdate::GetWinProfile(nsFolderSpec* folder, char* file, char* *e
*errorMsg = SU_GetErrorMsg4(SU_ERROR_WIN_PROFILE_MUST_CALL_START, nsSoftUpdateError_INSTALL_NOT_STARTED );
return NULL;
}
profile = new nsWinProfile(this, folder, file, errorMsg);
profile = new nsWinProfile(this, folder, file);
return profile;
#else
@ -296,7 +292,7 @@ void* nsSoftwareUpdate::GetWinRegistry(char* *errorMsg)
*errorMsg = SU_GetErrorMsg4(SU_ERROR_WIN_PROFILE_MUST_CALL_START, nsSoftUpdateError_INSTALL_NOT_STARTED );
return NULL;
}
registry = new nsWinReg(this, errorMsg);
registry = new nsWinReg(this);
return registry;
#else
return NULL;
@ -351,11 +347,11 @@ char* nsSoftwareUpdate::ExtractJARFile(char* inJarLocation, char* finalFile, cha
for (i=0; i < noOfPrins; i++) {
nsPrincipal* prin = (nsPrincipal*)prinArray->Get(i);
if (installPrincipal->equals( prin )) {
haveMatch = true;
haveMatch = PR_TRUE;
break;
}
}
if (haveMatch == false) {
if (haveMatch == PR_FALSE) {
char *msg = NULL;
msg = PR_sprintf_append(msg, "Missing certificate for %s", inJarLocation);
*errorMsg = SU_GetErrorMsg3(msg, nsSoftUpdateError_NO_MATCHING_CERTIFICATE);
@ -481,7 +477,7 @@ void nsSoftwareUpdate::UserApproved()
*/
PRInt32 nsSoftwareUpdate::FinalizeInstall(char* *errorMsg)
{
PRBool rebootNeeded = false;
PRBool rebootNeeded = PR_FALSE;
int result = nsSoftwareUpdate_SUCCESS;
SetProgressDialogItem(""); // blank the "current item" line
@ -539,8 +535,8 @@ PRInt32 nsSoftwareUpdate::FinalizeInstall(char* *errorMsg)
ie = (nsInstallObject*)ve->Get(i);
if (ie == NULL)
continue;
ie->Complete(errorMsg);
if (errorMsg != NULL) {
*errorMsg = ie->Complete();
if (*errorMsg != NULL) {
ie->Abort();
return nsSoftUpdateError_UNEXPECTED_ERROR;
}

View File

@ -19,6 +19,7 @@
#include "prmem.h"
#include "prmon.h"
#include "prlog.h"
#include "xp.h"
#include "prefapi.h"
#include "prprf.h"
#include "nsVersionInfo.h"

View File

@ -16,8 +16,10 @@
* Reserved.
*/
#include "nsVersionRegistry.h"
#include "prtypes.h"
#include "prmem.h"
#include "xp_mcom.h"
#include "nsVersionRegistry.h"
#include "NSReg.h"
#include "VerReg.h"
#include "prefapi.h"
@ -370,7 +372,7 @@ nsVersionRegistry::nsVersionRegistry()
char* nsVersionRegistry::convertPackageName( char* regPackageName )
{
char* convertedPackageName;
PRBool bSharedUninstall = false;
PRBool bSharedUninstall = PR_FALSE;
PRUint32 i=0;
PRUint32 j= 0;
PRUint32 len = XP_STRLEN(regPackageName);

View File

@ -16,10 +16,11 @@
* Reserved.
*/
#include "softupdt.h"
#include "su_instl.h"
#include "su_folderspec.h"
#define NEW_FE_CONTEXT_FUNCS
#include "zig.h"
#include "net.h"
#include "zig.h"
#include "libevent.h"
#include "prefapi.h"
#include "prprf.h"
@ -31,12 +32,13 @@
#include "pw_public.h"
#include "NSReg.h"
#include "VerReg.h"
#include "libi18n.h"
extern int MK_OUT_OF_MEMORY;
extern REGERR fe_DeleteOldFileLater(char * filename);
#define MOCHA_CONTEXT_PREFIX "autoinstall:"
#define REG_SOFTUPDT_DIR "Netscape/Communicator/SoftwareUpdate/"
#define LAST_REGPACK_TIME "LastRegPackTime"
/* error codes */
#define su_ErrInvalidArgs -1
@ -50,6 +52,12 @@ extern int SU_NOT_A_JAR_FILE;
extern int SU_SECURITY_CHECK;
extern int SU_INSTALL_FILE_HEADER;
extern int SU_INSTALL_FILE_MISSING;
extern int SU_PROGRESS_DOWNLOAD_TITLE;
extern int SU_PROGRESS_DOWNLOAD_LINE1;
extern int REGPACK_PROGRESS_TITLE;
extern int REGPACK_PROGRESS_LINE1;
extern int REGPACK_PROGRESS_LINE2;
/* structs */
@ -76,7 +84,7 @@ typedef struct su_URLFeData_struct {
int32 fFlags; /* download flags */
} su_URLFeData;
static char * EncodeSoftUpJSArgs(const char * fileName, XP_Bool silent, XP_Bool force);
static char * EncodeSoftUpJSArgs(const char * fileName, XP_Bool silent, XP_Bool force, const char* charset);
/* Stream callbacks */
int su_HandleProcess (NET_StreamClass *stream, const char *buffer, int32 buffLen);
@ -94,6 +102,12 @@ void su_CompleteSoftwareUpdate(MWContext * context,
void su_NetExitProc(URL_Struct* url, int result, MWContext * context);
void su_HandleCompleteJavaScript (su_DownloadStream* realStream);
int su_GetLastRegPackTime(int32 *lastRegPackTime);
int su_SetLastRegPackTime(int32 lastRegPackTime);
XP_Bool su_RegPackTime(void);
void su_RegPackCallback(void *userData, int32 bytes, int32 totalBytes);
int su_PackRegistry();
/* Handles cancel of progress dialog by user */
void cancelProgressDlg(void * closure)
@ -104,6 +118,7 @@ void cancelProgressDlg(void * closure)
}
}
/* Completion routine for SU_StartSoftwareUpdate */
void su_CompleteSoftwareUpdate(MWContext * context,
@ -162,7 +177,6 @@ typedef struct su_UninstallContext_struct {
XP_Bool bShared;
} su_UninstallContext;
XP_Bool DnLoadInProgress = FALSE;
PRMonitor * su_monitor = NULL;
@ -308,12 +322,11 @@ done:
void su_NetExitProc(URL_Struct* url, int result, MWContext * context)
{
su_startCallback * c;
if (result != MK_CHANGING_CONTEXT)
{
PR_EnterMonitor(su_monitor);
c = QGetItem();
if (c != NULL)
if ((c = QGetItem()) != NULL)
{
FE_SetTimeout( su_FE_timer_callback, c, 1 );
}
@ -411,6 +424,7 @@ NET_StreamClass * SU_NewStream (int format_out, void * registration,
XP_Bool isJar;
pw_ptr prg = NULL;
MWContext *fContext;
/* char path[256]; */
/* Initialize the stream data by data passed in the URL*/
fe_data = (su_URLFeData *) request->fe_data;
@ -460,16 +474,14 @@ NET_StreamClass * SU_NewStream (int format_out, void * registration,
result = MK_OUT_OF_MEMORY;
goto fail;
}
prg = PW_Create(context, pwApplicationModal);
fContext = PW_CreateProgressContext();
PW_AssociateWindowWithContext(fContext, prg);
fContext->url = request->address;
NET_SetNewContext(request, fContext, su_NetExitProc);
PW_SetWindowTitle(streamData->progress, "SmartUpdate");
PW_Show(prg);
stream = NET_NewStream (NULL,
stream = NET_NewStream ("SmartUpdate",
su_HandleProcess,
su_HandleComplete,
su_HandleAbort,
@ -512,7 +524,17 @@ NET_StreamClass * SU_NewStream (int format_out, void * registration,
}
PW_SetCancelCallback(streamData->progress, cancelProgressDlg, streamData);
PW_SetWindowTitle(streamData->progress, "SmartUpdate");
PW_SetWindowTitle(streamData->progress, XP_GetString(SU_PROGRESS_DOWNLOAD_TITLE));
/*
PR_snprintf(path, 256, XP_GetString(SU_PROGRESS_DOWNLOAD_LINE1), streamData->fURL->address);
PW_SetLine1(streamData->progress, path);
*/
PW_SetLine1(streamData->progress, streamData->fURL->address);
PW_SetLine2(streamData->progress, NULL);
#ifndef XP_UNIX
PW_Show(prg);
#endif
/* return the stream */
return stream;
@ -547,7 +569,9 @@ void su_HandleAbort (NET_StreamClass *stream, int reason)
/* Close the files */
if (realStream->fFile)
XP_FileClose(realStream->fFile);
#ifndef XP_UNIX
PW_Hide((pw_ptr)(realStream->progress));
#endif
/* Report the result */
su_CompleteSoftwareUpdate(realStream->fContext,
realStream->fCompletion, realStream->fCompletionClosure, reason, realStream);
@ -568,7 +592,9 @@ void su_HandleComplete (NET_StreamClass *stream)
if (realStream->fFile)
XP_FileClose(realStream->fFile);
#ifndef XP_UNIX
PW_Hide((pw_ptr)(realStream->progress));
#endif
su_HandleCompleteJavaScript( realStream );
}
@ -640,29 +666,40 @@ fail:
/* Encodes the args in the format
* MOCHA_CONTEXT_PREFIX<File>CR<silent>CR<force>
* Booleans are encoded as T or F.
* DecodeSoftUpJSArgs is in lm_softup.c
* DecodeSoftUpJSArgs is in lm_supdt.c
*/
static char *
EncodeSoftUpJSArgs(const char * fileName, XP_Bool force, XP_Bool silent )
EncodeSoftUpJSArgs(const char * fileName, XP_Bool force, XP_Bool silent,const char* charset )
{
char * s;
int32 length;
if (fileName == NULL)
return NULL;
length = XP_STRLEN(fileName) +
XP_STRLEN(MOCHA_CONTEXT_PREFIX) + 5; /* 2 booleans and a CR */
length = XP_STRLEN(MOCHA_CONTEXT_PREFIX) +
XP_STRLEN(fileName) +
6 + /* 2 booleans and 3 CR and one NULL*/
XP_STRLEN(charset);
s = XP_ALLOC(length);
if (s != NULL)
{
int32 tempLen;
s[0] = 0;
XP_STRCAT(s, MOCHA_CONTEXT_PREFIX);
XP_STRCAT(s, fileName);
s[length - 5] = CR;
s[length - 4] = silent ? 'T' : 'F';
s[length - 3] = CR;
s[length - 2] = force ? 'T' : 'F';
s[length - 1] = 0;
XP_STRCAT(s, fileName); /* Prefix and Name */
tempLen = XP_STRLEN(s); /* CR */
s[tempLen] = CR;
s[tempLen + 1] = silent ? 'T' : 'F'; /* Silent */
s[tempLen + 2] = CR; /* CR */
s[tempLen + 3] = force ? 'T' : 'F'; /* Force */
s[tempLen + 4] = CR; /* CR */
s[tempLen + 5] = 0;
XP_STRCAT(&(s[tempLen + 5]), charset); /* charset */
}
return s;
}
@ -681,14 +718,20 @@ void su_HandleCompleteJavaScript (su_DownloadStream* realStream)
char * codebase = NULL;
int32 urlLen;
unsigned long fileNameLength;
char * charset = NULL;
unsigned long charsetLen;
ZIG * jarData = NULL;
char s[255];
char * jsScope = NULL;
ETEvalStuff * stuff = NULL;
Chrome chrome;
char * jsScope = NULL;
char * nativeJar;
Chrome chrome;
MWContext * context;
JSPrincipals * principals = NULL;
ETEvalStuff * stuff = NULL;
char * jarCharset = NULL;
unsigned long jarCharsetLen;
/* Initialize the JAR file */
jarData = SOB_new();
@ -707,7 +750,7 @@ void su_HandleCompleteJavaScript (su_DownloadStream* realStream)
if (result < 0)
{
char *errMsg = SOB_get_error(result);
char *errMsg = SOB_get_error(result); /* do not free, bug 157209 */
PR_snprintf(s, 255, XP_GetString(SU_SECURITY_CHECK), (errMsg?errMsg:"") );
FE_Alert(realStream->fContext, s);
@ -736,7 +779,47 @@ void su_HandleCompleteJavaScript (su_DownloadStream* realStream)
result = su_JarError;
goto fail;
}
/* extract the character set info, if any */
result = SOB_get_metainfo( jarData, installerJarName, CHARSET_HEADER, (void**)&charset, &charsetLen);
if ((result < 0) || (INTL_CharSetNameToID(charset) == CS_UNKNOWN))
{
if (charset)
{
/*
* if you hit this assert, that means that your jar
* file has a bad charset name in it
*/
XP_ASSERT(0);
XP_FREE(charset);
}
charset = XP_STRDUP((const char *) INTL_CsidToCharsetNamePt(FE_DefaultDocCharSetID(realStream->fContext)));
}
/* extract the character set info for the Jar File, if any */
result = SOB_get_metainfo( jarData, NULL, CHARSET_HEADER, (void**)&jarCharset, &jarCharsetLen);
if ((result < 0) || (INTL_CharSetNameToID(jarCharset) == CS_UNKNOWN))
{
if (jarCharset)
{
/*
* if you hit this assert, that means that your jar
* file has a bad charset name in it
*/
XP_ASSERT(0);
XP_FREE(jarCharset);
}
jarCharset = XP_STRDUP((const char *) INTL_CsidToCharsetNamePt(FE_DefaultDocCharSetID(realStream->fContext)));
}
/* Extract the script out */
result = SOB_verified_extract( jarData, installerJarName, installerFileNameURL);
@ -765,16 +848,24 @@ void su_HandleCompleteJavaScript (su_DownloadStream* realStream)
SOB_destroy( jarData);
jarData = NULL;
/* add installer .JAR to the classpath */
nativeJar = WH_FileName( realStream->fJarFile, xpURL );
if ( nativeJar != NULL ) {
LJ_AddToClassPath( nativeJar );
XP_FREE( nativeJar );
}
/* For security reasons, installer JavaScript has to execute inside a
special context. This context is created by ET_EvaluateBuffer as a JS object
of type SoftUpdate. the arguments to the object are passed in the string,
jsScope
*/
jsScope = EncodeSoftUpJSArgs(realStream->fJarFile,
((realStream->fFlags & FORCE_INSTALL) != 0),
((realStream->fFlags & SILENT_INSTALL) != 0));
if (jsScope == NULL)
goto fail;
jsScope = EncodeSoftUpJSArgs(realStream->fJarFile,
((realStream->fFlags & FORCE_INSTALL) != 0),
((realStream->fFlags & SILENT_INSTALL) != 0),
jarCharset);
if (jsScope == NULL)
goto fail;
XP_BZERO(&chrome, sizeof(Chrome));
chrome.location_is_chrome = TRUE;
@ -785,44 +876,45 @@ void su_HandleCompleteJavaScript (su_DownloadStream* realStream)
We need a different solution for int'l content encoding on macs */
chrome.type = MWContextBrowser;
#endif
chrome.l_hint = -3000;
chrome.t_hint = -3000;
context = FE_MakeNewWindow(realStream->fContext, NULL, NULL, &chrome);
if (context == NULL)
goto fail;
chrome.l_hint = -3000;
chrome.t_hint = -3000;
context = FE_MakeNewWindow(realStream->fContext, NULL, NULL, &chrome);
if (context == NULL)
goto fail;
urlLen = XP_STRLEN(realStream->fURL->address);
codebase = XP_ALLOC( urlLen + XP_STRLEN(installerJarName) + 2 );
if (codebase == NULL) {
goto fail;
}
XP_STRCPY( codebase, realStream->fURL->address );
codebase[urlLen] = '/';
XP_STRCPY( codebase+urlLen+1, installerJarName );
urlLen = XP_STRLEN(realStream->fURL->address);
codebase = XP_ALLOC( urlLen + XP_STRLEN(installerJarName) + 2 );
if ( codebase == NULL) {
goto fail;
}
XP_STRCPY( codebase, realStream->fURL->address );
codebase[urlLen] = '/';
XP_STRCPY( codebase+urlLen+1, installerJarName );
principals = LM_NewJSPrincipals(realStream->fURL, installerJarName, codebase);
if (principals == NULL)
goto fail;
principals = LM_NewJSPrincipals(realStream->fURL, installerJarName, codebase );
if (principals == NULL) {
goto fail;
}
ET_StartSoftUpdate(context, codebase);
ET_StartSoftUpdate(context, codebase);
/* Execute the mocha script, result will be reported in the callback */
realStream->fContext = context;
/* Execute the mocha script, result will be reported in the callback */
realStream->fContext = context;
stuff = (ETEvalStuff *) XP_NEW_ZAP(ETEvalStuff);
if (!stuff) {
FE_DestroyWindow(context);
goto fail;
}
stuff = (ETEvalStuff *) XP_NEW_ZAP(ETEvalStuff);
if (!stuff) {
FE_DestroyWindow(context);
goto fail;
}
stuff->len = bufferSize;
stuff->line_no = 1;
stuff->scope_to = jsScope;
stuff->want_result = JS_TRUE;
stuff->data = realStream;
stuff->version = JSVERSION_DEFAULT;
stuff->principals = principals;
stuff->len = bufferSize;
stuff->line_no = 1;
stuff->scope_to = jsScope;
stuff->want_result = JS_TRUE;
stuff->data = realStream;
stuff->version = JSVERSION_DEFAULT;
stuff->principals = principals;
/* TODO: The following member doesn't exist
stuff->charset = charset;
*/
ET_EvaluateScript(context, buffer, stuff, su_mocha_eval_exit_fn);
@ -835,15 +927,27 @@ fail:
realStream->fCompletion, realStream->fCompletionClosure, result, realStream );
/* drop through */
done:
XP_FREEIF(jsScope);
/* Don't free 'codebase', the event destructor will! */
/* XP_FREEIF(codebase); */
if ( installerFileNameURL )
XP_FREE( installerFileNameURL );
/* Don't free the following, they are freed in the mocha event destructor!
XP_FREEIF(jsScope);
XP_FREEIF(codebase);
XP_FREEIF(charset);
*/
XP_FREEIF( installerFileNameURL );
XP_FREEIF( installerJarName );
XP_FREEIF( jarCharset );
/* Should we purge stuff from the disk cache here? */
}
#ifdef XP_MAC
#pragma export reset
#endif
int su_UninstallDeleteFile(char *fileNamePlatform)
{
char * fileName;
@ -872,7 +976,7 @@ int su_UninstallDeleteFile(char *fileNamePlatform)
{
#ifdef XP_PC
/* REMIND need to move function to generic XP file */
fe_DeleteOldFileLater( (char*)fileNamePlatform );
su_DeleteOldFileLater( (char*)fileNamePlatform );
#endif
}
@ -1056,7 +1160,6 @@ PUBLIC int SU_Startup()
/* check to see that we have a valid registry */
if (REGERR_OK == NR_RegOpen("", &reg))
{
#ifdef XP_PC
XP_StatStruct stat;
XP_Bool removeFromList;
RKEY key;
@ -1155,7 +1258,6 @@ PUBLIC int SU_Startup()
NR_RegDeleteKey(reg, ROOTKEY_PRIVATE, REG_REPLACE_LIST_KEY);
}
}
#endif /* XP_PC */
NR_RegClose(reg);
}
@ -1165,11 +1267,170 @@ PUBLIC int SU_Startup()
int SU_Shutdown()
{
if (su_RegPackTime())
{
su_PackRegistry();
}
SU_DestroyMonitor();
NR_ShutdownRegistry();
return 0;
}
int su_GetLastRegPackTime(int32 *lastRegPackTime)
{
HREG reg;
REGERR err = REGERR_OK;
RKEY key;
char pathbuf[MAXREGPATHLEN+1] = {0};
char lrptstr[MAXREGNAMELEN];
*lastRegPackTime = 0;
err = NR_RegOpen("", &reg);
if (REGERR_OK == err)
{
err = NR_RegGetKey( reg, ROOTKEY_PRIVATE, REG_SOFTUPDT_DIR, &key);
if (err == REGERR_OK)
{
err = NR_RegGetEntryString( reg, key, LAST_REGPACK_TIME, lrptstr, sizeof(lrptstr) );
if (err == REGERR_OK)
{
*lastRegPackTime = XP_ATOI( lrptstr );
}
}
NR_RegClose(reg);
}
return err;
}
int su_SetLastRegPackTime(int32 lastRegPackTime)
{
HREG reg;
REGERR err = REGERR_OK;
RKEY key;
char pathbuf[MAXREGPATHLEN+1] = {0};
char lrptstr[MAXREGNAMELEN];
err = NR_RegOpen("", &reg);
if (REGERR_OK == err)
{
XP_STRCPY(pathbuf, REG_SOFTUPDT_DIR);
err = NR_RegAddKey( reg, ROOTKEY_PRIVATE, pathbuf, &key);
if (err == REGERR_OK)
{
*lrptstr = '\0';
PR_snprintf(lrptstr, MAXREGNAMELEN, "%d", lastRegPackTime);
if ( lrptstr != NULL && *lrptstr != '\0' ) {
/* Add "LastRegPackTime" */
err = NR_RegSetEntryString( reg, key, LAST_REGPACK_TIME, lrptstr);
}
}
NR_RegClose(reg);
}
return err;
}
XP_Bool su_RegPackTime()
{
int32 lastRegPackTime = 0;
int32 nowSecInt = 0;
int32 intervalDays = 0;
int32 intervalSec = 0;
int32 i;
int64 bigNumber;
REGERR err;
int64 now;
int64 nowSec;
LL_I2L(now, 0);
LL_I2L(nowSec, 0);
LL_I2L(bigNumber, 1000000);
PREF_GetIntPref("autoupdate.regpack_interval", &intervalDays);
intervalSec = intervalDays*24*60*60;
err = su_GetLastRegPackTime(&lastRegPackTime);
now = PR_Now();
LL_DIV(nowSec, now, bigNumber);
LL_L2I(nowSecInt, nowSec);
i = nowSecInt - lastRegPackTime;
if ((i > intervalSec) || (i < 0))
{
return TRUE;
}
else
{
return FALSE;
}
}
void su_RegPackCallback(void *userData, int32 bytes, int32 totalBytes)
{
int32 value;
pw_ptr prg = (pw_ptr)userData;
char valueStr[256];
static XP_Bool rangeSet = FALSE;
if (totalBytes)
{
if (!rangeSet)
{
PW_SetProgressRange(prg, 0, totalBytes);
PW_SetProgressValue(prg, 0);
/* Need to do this to force the progressMeter to work */
value = (int32) (5 * (((double)totalBytes) /((double)100)));
PW_SetProgressValue(prg, value);
rangeSet = TRUE;
}
PR_snprintf(valueStr, 256, XP_GetString(REGPACK_PROGRESS_LINE2), bytes, totalBytes);
PW_SetProgressValue(prg, bytes);
PW_SetLine2(prg, valueStr);
}
}
int su_PackRegistry()
{
int64 bigNumber;
int32 nowSecInt = 0;
REGERR err = REGERR_OK;
pw_ptr prg;
int64 now;
int64 nowSec;
LL_I2L(now, 0);
LL_I2L(nowSec, 0);
LL_I2L(bigNumber, 1000000);
prg = PW_Create(NULL, pwApplicationModal);
PW_SetWindowTitle(prg, XP_GetString(REGPACK_PROGRESS_TITLE));
PW_SetLine2(prg, NULL);
PW_Show(prg);
PW_SetLine1(prg, XP_GetString(REGPACK_PROGRESS_LINE1));;
err = VR_PackRegistry((void *)prg, su_RegPackCallback);
/* We ignore all errors from PackRegistry. Later, we will check for an error
which is is called if the cancel button of the progress dialog is clicked,
in which case we will not set the lastRegPackTime.
*/
now = PR_Now();
LL_DIV(nowSec, now, bigNumber);
LL_L2I(nowSecInt, nowSec);
su_SetLastRegPackTime(nowSecInt);
PW_Destroy(prg);
return err;
}
#ifdef XP_MAC
#pragma export reset
#endif

File diff suppressed because it is too large Load Diff

View File

@ -15,23 +15,50 @@
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
* Reserved.
*/
/* su_aplsn.h */
/* SU_DecodeAppleSingle
* Decodes an AppleSingle disk file
* Arguments:
* src - file path in XP_FILE_URL_PATH format
* dst - returns the path of the extracted file. NULL if err
* Returns an error on failure
*/
#ifndef APSINGLE_H
#define APSINGLE_H
#ifdef __cplusplus
extern "C" {
#endif
#include "xp_core.h"
#include "su_applsn_defines.h"
#include <Files.h>
#define APPLESINGLE_MIME_TYPE "application/applefile"
XP_BEGIN_PROTOS
//int
//convert_apsingle_file(const char *inFile, int inflags, const char *outFile, int outflags, int *bin);
int SU_DecodeAppleSingle(const char * inSrc, char ** dst);
/* Decodes
* Arguments:
* inFile - name of the AppleSingle file
* outSpec - destination. If destination is renamed (as part of decoding of realName)
* the outSpec is modified to represent the new name
* wantedEntries - a bitmask what entries do we want decoded. Bit positions correspond to entryIDs
*/
int
SU_DecodeAppleSingle( const char * inSrc, char ** dst );
/*
* Arguments:
* inSpec - file to be encoded
* outSpec - destination. If an error occurs during decoding, destination will be deleted!
* wantedEntries - a bitmask what entries do we want encoded. Bit positions correspond to entryIDs
*/
int
SU_EncodeAppleSingle( const char * inSpec, const char * outFile);
XP_END_PROTOS
#ifdef __cplusplus
}
#endif
#endif /* APSINGLE_H */

View File

@ -15,13 +15,8 @@
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
* Reserved.
*/
/* su_trigger.c
* netscape.softupdate.FolderSpec.java
* native methods
* created by atotic, 1/6/97
*/
#include "xp_mcom.h"
#include "jri.h"
#include "su_folderspec.h"
/* #include "prthread.h" */
@ -35,17 +30,6 @@
#include "fe_proto.h"
#include "xpgetstr.h"
#define IMPLEMENT_netscape_softupdate_FolderSpec
#define IMPLEMENT_netscape_softupdate_SoftwareUpdate
#ifndef XP_MAC
#include "_jri/netscape_softupdate_FolderSpec.c"
#include "_jri/netscape_softupdate_SoftwareUpdate.h"
#else
#include "n_softupdate_FolderSpec.c"
#include "n_softupdate_SoftwareUpdate.h"
#endif
#ifndef MAX_PATH
#if defined(XP_WIN) || defined(XP_OS2)
#define MAX_PATH _MAX_PATH
@ -75,17 +59,10 @@
extern int SU_INSTALL_ASK_FOR_DIRECTORY;
/* Standard Java initialization for native classes */
void
FolderSpecInitialize(JRIEnv * env)
{
use_netscape_softupdate_FolderSpec( env );
}
/* 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 *
char *
AppendSlashToDirPath(char * dirPath)
{
char pathSeparator; /* Gross, but harmless */
@ -115,16 +92,6 @@ AppendSlashToDirPath(char * dirPath)
return newPath;
}
/* su_PickDirTimer
* keeps track of all SU specific data needed for the stream
*/
typedef struct su_PickDirTimer_struct {
MWContext * context;
char * fileName;
char * prompt;
XP_Bool done;
} su_PickDirTimer;
/* Callback for FE_PromptForFileName */
PR_STATIC_CALLBACK(void)
@ -146,7 +113,7 @@ GetDirectoryPathCallbackFunction(MWContext *context,
}
/* Callback for the timer set by FE_SetTimer */
PR_STATIC_CALLBACK(void)
PR_EXTERN(void)
pickDirectoryCallback(void * a)
{
su_PickDirTimer *t = (su_PickDirTimer *)a;
@ -162,106 +129,57 @@ pickDirectoryCallback(void * a)
t->done = TRUE;
}
/* NativePickDefaultDirectory
* Asks the user where he'd like to install the package
*/
JRI_PUBLIC_API(struct java_lang_String *)
native_netscape_softupdate_FolderSpec_NativePickDefaultDirectory(
JRIEnv* env,
struct netscape_softupdate_FolderSpec* self)
{
struct java_lang_String * jPackageName, * newName= NULL;
su_PickDirTimer callback;
char * packageName;
char prompt[200];
callback.context = XP_FindSomeContext();
callback.fileName = NULL;
callback.done = FALSE;
/* Get the name of the package to prompt for */
jPackageName = get_netscape_softupdate_FolderSpec_userPackageName( env, self);
packageName = (char*)JRI_GetStringPlatformChars( env, jPackageName, "", 0 );
if (packageName)
{
/* In Java thread now, and need to call FE_PromptForFileName
* from the main thread
* post an event on a timer, and busy-wait until it completes.
*/
PR_snprintf(prompt, 200, XP_GetString(SU_INSTALL_ASK_FOR_DIRECTORY), packageName);
callback.prompt = prompt;
FE_SetTimeout( pickDirectoryCallback, &callback, 1 );
while (!callback.done) /* Busy loop for now */
PR_Sleep(PR_INTERVAL_NO_WAIT); /* java_lang_Thread_yield(WHAT?); */
}
if (callback.fileName != NULL)
{
newName = JRI_NewStringPlatform(env, callback.fileName, XP_STRLEN( callback.fileName), "", 0);
XP_FREE( callback.fileName);
}
return newName;
}
/*
*Directory manipulation
*/
/* Entry for the DirectoryTable[] */
struct su_DirectoryTable
{
char * directoryName; /* The formal directory name */
su_SecurityLevel securityLevel; /* Security level */
su_DirSpecID folderEnum; /* Directory ID */
};
/* DirectoryTable holds the info about built-in directories:
* Text name, security level, enum
*/
static struct su_DirectoryTable DirectoryTable[] =
struct su_DirectoryTable DirectoryTable[] =
{
{"Plugins", eAllFolderAccess, ePluginFolder},
{"Program", eAllFolderAccess, eProgramFolder},
{"Communicator", eAllFolderAccess, eCommunicatorFolder},
{"User Pick", eAllFolderAccess, ePackageFolder},
{"Temporary", eAllFolderAccess, eTemporaryFolder},
{"Installed", eAllFolderAccess, eInstalledFolder},
{"Current User", eAllFolderAccess, eCurrentUserFolder},
{"Plugins", ePluginFolder, TRUE},
{"Program", eProgramFolder, FALSE},
{"Communicator", eCommunicatorFolder, FALSE},
{"User Pick", ePackageFolder, FALSE},
{"Temporary", eTemporaryFolder, FALSE},
{"Installed", eInstalledFolder, FALSE},
{"Current User", eCurrentUserFolder, FALSE},
{"NetHelp", eAllFolderAccess, eNetHelpFolder},
{"OS Drive", eAllFolderAccess, eOSDriveFolder},
{"File URL", eAllFolderAccess, eFileURLFolder},
{"NetHelp", eNetHelpFolder, FALSE},
{"OS Drive", eOSDriveFolder, FALSE},
{"File URL", eFileURLFolder, FALSE},
{"Netscape Java Bin", eAllFolderAccess, eJavaBinFolder},
{"Netscape Java Classes", eAllFolderAccess, eJavaClassesFolder},
{"Java Download", eOneFolderAccess, eJavaDownloadFolder},
{"Netscape Java Bin", eJavaBinFolder, FALSE},
{"Netscape Java Classes", eJavaClassesFolder, TRUE},
{"Java Download", eJavaDownloadFolder, TRUE},
{"Win System", eAllFolderAccess, eWin_SystemFolder},
{"Win System16", eAllFolderAccess, eWin_System16Folder},
{"Windows", eAllFolderAccess, eWin_WindowsFolder},
{"Win System", eWin_SystemFolder, FALSE},
{"Win System16", eWin_System16Folder, FALSE},
{"Windows", eWin_WindowsFolder, FALSE},
{"Mac System", eAllFolderAccess, eMac_SystemFolder},
{"Mac Desktop", eAllFolderAccess, eMac_DesktopFolder},
{"Mac Trash", eAllFolderAccess, eMac_TrashFolder},
{"Mac Startup", eAllFolderAccess, eMac_StartupFolder},
{"Mac Shutdown", eAllFolderAccess, eMac_ShutdownFolder},
{"Mac Apple Menu", eAllFolderAccess, eMac_AppleMenuFolder},
{"Mac Control Panel", eAllFolderAccess, eMac_ControlPanelFolder},
{"Mac Extension", eAllFolderAccess, eMac_ExtensionFolder},
{"Mac Fonts", eAllFolderAccess, eMac_FontsFolder},
{"Mac Preferences", eAllFolderAccess, eMac_PreferencesFolder},
{"Mac System", eMac_SystemFolder, FALSE},
{"Mac Desktop", eMac_DesktopFolder, FALSE},
{"Mac Trash", eMac_TrashFolder, FALSE},
{"Mac Startup", eMac_StartupFolder, FALSE},
{"Mac Shutdown", eMac_ShutdownFolder, FALSE},
{"Mac Apple Menu", eMac_AppleMenuFolder, FALSE},
{"Mac Control Panel", eMac_ControlPanelFolder, FALSE},
{"Mac Extension", eMac_ExtensionFolder, FALSE},
{"Mac Fonts", eMac_FontsFolder, FALSE},
{"Mac Preferences", eMac_PreferencesFolder, FALSE},
{"Unix Local", eAllFolderAccess, eUnix_LocalFolder},
{"Unix Lib", eAllFolderAccess, eUnix_LibFolder},
{"Unix Local", eUnix_LocalFolder, FALSE},
{"Unix Lib", eUnix_LibFolder, FALSE},
{"", eAllFolderAccess, eBadFolder} /* Termination line */
{"", eBadFolder, FALSE} /* Termination */
};
/* 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 );
@ -277,110 +195,3 @@ static su_DirSpecID MapNameToEnum(const char * name)
return eBadFolder;
}
/**
* GetNativePickPath -- return a native path equivalent of a XP path
*/
JRI_PUBLIC_API(struct java_lang_String *)
native_netscape_softupdate_FolderSpec_GetNativePath (JRIEnv* env,
struct netscape_softupdate_FolderSpec* self,
struct java_lang_String *a)
{
struct java_lang_String * nativePath = NULL;
char *xpPath, *p;
char pathSeparator;
#define XP_PATH_SEPARATOR '/'
#ifdef XP_WIN
pathSeparator = '\\';
#elif defined(XP_MAC)
pathSeparator = ':';
#else /* XP_UNIX */
pathSeparator = '/';
#endif
p = xpPath = (char *) JRI_GetStringUTFChars (env, a); /* UTF OK */
/*
* Traverse XP path and replace XP_PATH_SEPARATOR with
* the platform native equivalent
*/
if ( p == NULL )
{
xpPath = "";
}
else
{
while ( *p )
{
if ( *p == XP_PATH_SEPARATOR )
*p = pathSeparator;
++p;
}
}
nativePath = JRI_NewStringUTF(env, xpPath, XP_STRLEN( xpPath)); /* UTF OK */
return nativePath;
}
/*
* NativeGetDirectoryPath
*/
JRI_PUBLIC_API(jint)
native_netscape_softupdate_FolderSpec_NativeGetDirectoryPath(JRIEnv* env,
struct netscape_softupdate_FolderSpec* self)
{
su_DirSpecID folderID;
char * folderName;
char * folderPath = NULL;
struct java_lang_String * jFolderName;
/* Get the name of the package to prompt for */
jFolderName = get_netscape_softupdate_FolderSpec_folderID( env, self);
folderName = (char*)JRI_GetStringUTFChars( env, jFolderName ); /* UTF OK */
folderID = MapNameToEnum(folderName);
switch (folderID)
{
case eBadFolder:
return netscape_softupdate_FolderSpec_INVALID_PATH_ERR;
case eCurrentUserFolder:
{
char dir[MAX_PATH];
int len = MAX_PATH;
if ( PREF_GetCharPref("profile.directory", dir, &len) == PREF_NOERROR)
{
char * platformDir = WH_FileName(dir, xpURL);
if (platformDir)
folderPath = AppendSlashToDirPath(platformDir);
XP_FREEIF(platformDir);
}
}
break;
default:
/* Get the FE path */
folderPath = FE_GetDirectoryPath( folderID);
break;
}
/* Store it in the object */
if (folderPath != NULL)
{
struct java_lang_String * jFolderPath;
jFolderPath = JRI_NewStringPlatform(env, folderPath, strlen( folderPath), "", 0);
if ( jFolderPath != NULL)
set_netscape_softupdate_FolderSpec_urlPath(env, self, jFolderPath);
XP_FREE(folderPath);
return 0;
}
return netscape_softupdate_FolderSpec_INVALID_PATH_ERR;
}

View File

@ -23,65 +23,6 @@
/* The following two includes are unnecessary, but prevent
* IS_LITTLE_ENDIAN warnings */
#include "xp_mcom.h"
#include "jri.h"
#define IMPLEMENT_netscape_softupdate_InstallFile
#ifndef XP_MAC
#include "_jri/netscape_softupdate_InstallFile.c"
#else
#include "n_softupdate_InstallFile.c"
#endif
#define IMPLEMENT_netscape_softupdate_InstallExecute
#ifndef XP_MAC
#include "_jri/netscape_softupdate_InstallExecute.c"
#else
#include "n_softupdate_InstallExecute.c"
#endif
#define IMPLEMENT_netscape_softupdate_InstallPatch
#ifndef XP_MAC
#include "_jri/netscape_softupdate_InstallPatch.c"
#else
#include "n_softupdate_InstallPatch.c"
#endif
#define IMPLEMENT_netscape_softupdate_SoftUpdateException
#ifndef XP_MAC
#include "_jri/netscape_softupdate_SoftUpdateException.h"
#else
#include "n_s_SoftUpdateException.h"
#endif
#define IMPLEMENT_netscape_softupdate_Strings
#ifndef XP_MAC
#include "_jri/netscape_softupdate_Strings.h"
#else
#include "netscape_softupdate_Strings.h"
#endif
#define IMPLEMENT_netscape_softupdate_InstallDelete
#ifndef XP_MAC
#include "_jri/netscape_softupdate_InstallDelete.c"
#else
#include "n_softupdate_InstallDelete.c"
#endif
#define IMPLEMENT_netscape_softupdate_SoftwareUpdate
#ifndef XP_MAC
#include "_jri/netscape_softupdate_SoftwareUpdate.h"
#else
#include "n_softupdate_SoftwareUpdate.h"
#endif
#include "fe_proto.h"
#include "zig.h"
@ -105,567 +46,40 @@ static XP_Bool utilityScheduled = FALSE;
#endif
#define NO_ERROR 0
extern REGERR fe_DeleteOldFileLater(char * filename);
/* Standard Java initialization for native methods classes
*/
void InstallFileInitialize(JRIEnv * env)
REGERR su_DeleteOldFileLater(char * filename)
{
use_netscape_softupdate_InstallFile( env );
use_netscape_softupdate_InstallExecute( env );
use_netscape_softupdate_InstallDelete( env );
use_netscape_softupdate_InstallPatch( env );
}
/* NativeComplete
* copies the file to its final location
* Tricky, we need to create the directories
*/
JRI_PUBLIC_API(jint)
native_netscape_softupdate_InstallFile_NativeComplete(JRIEnv* env,
struct netscape_softupdate_InstallFile* self)
{
char * currentName;
char * finalName = NULL;
char * finalNamePlatform;
struct java_lang_String * currentNameJava;
struct java_lang_String * finalNameJava;
int result;
/* Get the names */
currentNameJava = get_netscape_softupdate_InstallFile_tempFile( env, self);
currentName = (char*)JRI_GetStringPlatformChars( env, currentNameJava, "", 0);
finalNameJava = get_netscape_softupdate_InstallFile_finalFile( env, self);
finalNamePlatform = (char*)JRI_GetStringPlatformChars( env, finalNameJava, "", 0);
finalName = XP_PlatformFileToURL(finalNamePlatform);
if ( finalName == NULL || currentName == NULL ) {
/* memory or JRI problems */
XP_FREEIF(finalName);
return -1;
}
else {
/* convert finalName name to xpURL form by stripping "file://" */
char *temp = XP_STRDUP(&finalName[7]);
XP_FREE(finalName);
finalName = temp;
}
if (finalName != NULL)
{
if ( XP_STRCMP(finalName, currentName) == 0 ) {
/* No need to rename, they are the same */
result = 0;
}
else {
XP_StatStruct s;
if ( XP_Stat( finalName, &s, xpURL ) != 0 ) {
/* Target file doesn't exist, try to rename file */
result = XP_FileRename(currentName, xpURL, finalName, xpURL);
}
else {
/* Target exists, can't trust XP_FileRename--do platform
* specific stuff in FE_ReplaceExistingFile()
*/
result = -1;
}
}
}
else {
/* memory problem */
return -1;
}
if (result != 0)
{
XP_StatStruct s;
if ( XP_Stat( finalName, &s, xpURL ) == 0 )
/* File already exists, need to remove the original */
{
XP_Bool force = get_netscape_softupdate_InstallFile_force(env, self);
result = FE_ReplaceExistingFile(currentName, xpURL, finalName, xpURL, force);
if ( result == REBOOT_NEEDED ) {
#ifdef XP_WIN16
if (!utilityScheduled) {
utilityScheduled = TRUE;
FE_ScheduleRenameUtility();
}
#endif
}
}
else
/* Directory might not exist, check and create if necessary */
{
char separator;
char * end;
separator = '/';
end = XP_STRRCHR(finalName, separator);
if (end)
{
end[0] = 0;
result = XP_MakeDirectoryR( finalName, xpURL);
end[0] = separator;
if ( 0 == result )
result = XP_FileRename(currentName, xpURL, finalName, xpURL);
}
}
#ifdef XP_UNIX
/* Last try, can't rename() across file systems on UNIX */
if ( -1 == result )
{
result = FE_CopyFile(currentName, finalName);
}
#endif
}
XP_FREEIF(finalName);
return result;
}
/* Removes the temporary file */
JRI_PUBLIC_API(void)
native_netscape_softupdate_InstallFile_NativeAbort(JRIEnv* env,
struct netscape_softupdate_InstallFile* self)
{
char * currentName;
struct java_lang_String * currentNameJava;
int result;
/* Get the names */
currentNameJava = get_netscape_softupdate_InstallFile_tempFile( env, self);
currentName = (char*)JRI_GetStringPlatformChars( env, currentNameJava, "", 0);
result = XP_FileRemove(currentName, xpURL);
XP_ASSERT(result != 0); /* need to fe_deletefilelater() or something */
}
/* Finds out if the file exists
*/
JRI_PUBLIC_API(jbool)
native_netscape_softupdate_InstallFile_NativeDoesFileExist(JRIEnv* env,
struct netscape_softupdate_InstallFile* self)
{
char * fileName;
char * fileNamePlatform;
struct java_lang_String * fileNameJava;
int32 err;
XP_StatStruct statinfo;
XP_Bool replace = FALSE;
fileNameJava = get_netscape_softupdate_InstallFile_finalFile( env, self);
fileNamePlatform = (char*)JRI_GetStringPlatformChars( env, fileNameJava, "", 0);
fileName = XP_PlatformFileToURL(fileNamePlatform);
if (fileName != NULL)
{
char * temp = XP_STRDUP(&fileName[7]);
XP_FREEIF(fileName);
fileName = temp;
if (fileName)
{
err = XP_Stat(fileName, &statinfo, xpURL);
if (err != -1)
{
replace = TRUE;
}
}
}
XP_FREEIF(fileName);
return replace;
}
/*---------------------------------------
*
* InstallExecute native methods
*
*---------------------------------------*/
/* Executes the extracted binary
*/
JRI_PUBLIC_API(void)
native_netscape_softupdate_InstallExecute_NativeComplete(JRIEnv* env,
struct netscape_softupdate_InstallExecute* self)
{
char * cmdline;
char * filename;
int32 err;
filename = (char*)JRI_GetStringPlatformChars(
env,
get_netscape_softupdate_InstallExecute_tempFile( env, self ),
"",
0 );
cmdline = (char*)JRI_GetStringPlatformChars(
env,
get_netscape_softupdate_InstallExecute_cmdline( env, self ),
"",
0 );
err = FE_ExecuteFile( filename, cmdline );
XP_ASSERT( err == 0 );
if ( err != 0 )
{
struct netscape_softupdate_SoftUpdateException* e;
struct java_lang_String * errStr;
errStr = netscape_softupdate_Strings_error_0005fUnexpected(env,
class_netscape_softupdate_Strings(env));
e = netscape_softupdate_SoftUpdateException_new( env,
class_netscape_softupdate_SoftUpdateException(env),
errStr,
err);
return;
}
}
/* Removes the temporary file */
JRI_PUBLIC_API(void)
native_netscape_softupdate_InstallExecute_NativeAbort(JRIEnv* env,
struct netscape_softupdate_InstallExecute* self)
{
char * currentName;
struct java_lang_String * currentNameJava;
int result;
/* Get the names */
currentNameJava = get_netscape_softupdate_InstallExecute_tempFile(env,self);
currentName = (char*)JRI_GetStringPlatformChars(env, currentNameJava,"",0);
result = XP_FileRemove(currentName, xpURL);
XP_ASSERT(result == 0);
}
/*---------------------------------------
*
* InstallDelete native methods
*
*---------------------------------------*/
/* Executes the extracted binary
*/
JRI_PUBLIC_API(jint)
native_netscape_softupdate_InstallDelete_NativeComplete(JRIEnv* env,
struct netscape_softupdate_InstallDelete* self)
{
char * fileName;
char * fileNamePlatform;
struct java_lang_String * fileNameJava;
int32 err;
XP_StatStruct statinfo;
int deleteStatus;
deleteStatus = get_netscape_softupdate_InstallDelete_deleteStatus( env, self);
fileNameJava = get_netscape_softupdate_InstallDelete_finalFile( env, self);
fileNamePlatform = (char*)JRI_GetStringPlatformChars( env, fileNameJava, "", 0);
fileName = XP_PlatformFileToURL(fileNamePlatform);
if (fileName != NULL)
{
char * temp = XP_STRDUP(&fileName[7]);
XP_FREEIF(fileName);
fileName = temp;
if (fileName)
{
err = XP_Stat(fileName, &statinfo, xpURL);
if (err != -1)
{
if ( XP_STAT_READONLY( statinfo ) )
{
err = netscape_softupdate_SoftwareUpdate_FILE_READ_ONLY;
}
else if (!S_ISDIR(statinfo.st_mode))
{
err = XP_FileRemove ( fileName, xpURL );
if (err != 0)
{
#ifdef XP_PC
/* REMIND need to move function to generic XP file */
err = REBOOT_NEEDED;
fe_DeleteOldFileLater( (char*)fileNamePlatform );
#endif
}
}
else
{
err = netscape_softupdate_SoftwareUpdate_FILE_IS_DIRECTORY;
}
}
else
{
err = netscape_softupdate_SoftwareUpdate_FILE_DOES_NOT_EXIST;
}
}
else
{
err = -1;
}
}
XP_FREEIF(fileName);
return err;
}
/*
* Checks the status of the file
*/
extern JRI_PUBLIC_API(jint)
native_netscape_softupdate_InstallDelete_NativeCheckFileStatus(JRIEnv* env,
struct netscape_softupdate_InstallDelete* self)
{
char * fileName;
char * fileNamePlatform;
struct java_lang_String * fileNameJava;
int32 err;
XP_StatStruct statinfo;
fileNameJava = get_netscape_softupdate_InstallDelete_finalFile( env, self);
fileNamePlatform = (char*)JRI_GetStringPlatformChars( env, fileNameJava, "", 0);
fileName = XP_PlatformFileToURL(fileNamePlatform);
if (fileName != NULL)
{
char * temp = XP_STRDUP(&fileName[7]);
XP_FREEIF(fileName);
fileName = temp;
if (fileName)
{
err = XP_Stat(fileName, &statinfo, xpURL);
if (err != -1)
{
if ( XP_STAT_READONLY( statinfo ) )
{
err = netscape_softupdate_SoftwareUpdate_FILE_READ_ONLY;
}
else if (!S_ISDIR(statinfo.st_mode))
{
;
}
else
{
err = netscape_softupdate_SoftwareUpdate_FILE_IS_DIRECTORY;
}
}
else
{
err = netscape_softupdate_SoftwareUpdate_FILE_DOES_NOT_EXIST;
}
}
else
{
err = -1;
}
}
else
{
err = -1;
}
XP_FREEIF(fileName);
return err;
}
/*---------------------------------------
*
* InstallPatch native methods
*
*---------------------------------------*/
/*** private native NativePatch (Ljava/lang/String;Ljava/lang/String;)Ljava/lang/String; ***/
JRI_PUBLIC_API(struct java_lang_String*)
native_netscape_softupdate_InstallPatch_NativePatch(JRIEnv* env,
struct netscape_softupdate_InstallPatch* self,
struct java_lang_String *jSrcFile,
struct java_lang_String *jDiffURL)
{
char * srcfile = NULL;
char * diffURL = NULL;
char * fullSrcURL = NULL;
char * srcURL = NULL;
char * newfileURL = NULL;
char * newfile = NULL;
int32 err = GDIFF_OK;
struct java_lang_String * jNewFile = NULL;
/* get all the required filenames in the correct URL format */
srcfile = (char*)JRI_GetStringPlatformChars( env, jSrcFile, "", 0 );
diffURL = (char*)JRI_GetStringPlatformChars( env, jDiffURL, "", 0 );
if ( srcfile != NULL && diffURL != NULL )
{
fullSrcURL = XP_PlatformFileToURL( srcfile );
if ( fullSrcURL != NULL )
RKEY newkey;
REGERR result = -1;
HREG reg;
if ( REGERR_OK == NR_RegOpen("", &reg) ) {
if (REGERR_OK == NR_RegAddKey( reg, ROOTKEY_PRIVATE,
REG_DELETE_LIST_KEY, &newkey) )
{
char ch;
char *p;
srcURL = fullSrcURL+7; /* skip "file://" part */
p = XP_STRRCHR( srcURL, '/' );
if ( p != NULL ) {
ch = p[1];
p[1] = 0;
newfileURL = WH_TempName( xpURL, srcURL );
p[1] = ch;
}
result = NR_RegSetEntryString( reg, newkey, filename, "" );
}
NR_RegClose(reg);
}
/* apply the patch if conversions worked */
if ( newfileURL != NULL ) {
err = SU_PatchFile( srcURL, xpURL, diffURL, xpURL, newfileURL, xpURL );
}
else {
/* String conversions failed -- probably out of memory */
err = netscape_softupdate_SoftwareUpdate_UNEXPECTED_ERROR;
}
if ( err == GDIFF_OK )
{
/* everything's fine, convert to java string and return */
newfile = WH_FileName( newfileURL, xpURL );
jNewFile = JRI_NewStringPlatform(env,newfile,XP_STRLEN(newfile),"",0);
}
else
{
/* convert GDIFF_ERR to SoftwareUpdate error and throw it */
/* XXX: replace with correct error message! */
struct netscape_softupdate_SoftUpdateException* e;
struct java_lang_String * errStr;
errStr = netscape_softupdate_Strings_error_0005fUnexpected(env,
class_netscape_softupdate_Strings(env));
e = netscape_softupdate_SoftUpdateException_new( env,
class_netscape_softupdate_SoftUpdateException(env),
errStr,
err);
JRI_Throw(env, (struct java_lang_Throwable *)e);
}
/* cleanup */
if ( diffURL != NULL )
XP_FileRemove( diffURL, xpURL );
XP_FREEIF( newfile );
XP_FREEIF( newfileURL );
XP_FREEIF( fullSrcURL );
return (jNewFile);
return result;
}
/*** private native NativeReplace (Ljava/lang/String;Ljava/lang/String;)I ***/
JRI_PUBLIC_API(jint)
native_netscape_softupdate_InstallPatch_NativeReplace(JRIEnv* env,
struct netscape_softupdate_InstallPatch* self,
struct java_lang_String *jTargetfile,
struct java_lang_String *jNewfile)
REGERR su_ReplaceOldFileLater(char *tmpfile, char *target )
{
char * targetfile = NULL;
char * newfile = NULL;
char * targetURL = NULL;
char * newURL = NULL;
char * pTarget;
char * pNew;
int err = SU_SUCCESS;
RKEY newkey;
REGERR err;
HREG reg;
targetfile = (char*)JRI_GetStringPlatformChars( env, jTargetfile, "", 0 );
newfile = (char*)JRI_GetStringPlatformChars( env, jNewfile, "", 0 );
if ( targetfile != NULL && newfile != NULL )
{
targetURL = XP_PlatformFileToURL( targetfile );
newURL = XP_PlatformFileToURL( newfile );
if ( targetURL != NULL && newURL != NULL )
{
XP_StatStruct st;
pTarget = targetURL+7;
pNew = newURL+7;
if ( XP_Stat( pTarget, &st, xpURL ) == SU_SUCCESS ) {
/* file still exists */
err = FE_ReplaceExistingFile( pNew, xpURL, pTarget, xpURL, 0 );
#ifdef XP_WIN16
if ( err == REBOOT_NEEDED && !utilityScheduled) {
utilityScheduled = TRUE;
FE_ScheduleRenameUtility();
}
#endif
}
else {
/* someone got rid of the target file? */
/* can do simple rename, but assert */
err = XP_FileRename( pNew, xpURL, pTarget, xpURL );
XP_ASSERT( err == SU_SUCCESS );
XP_ASSERT(0);
}
}
else {
err = -1;
err = NR_RegOpen("", &reg);
if ( err == REGERR_OK ) {
err = NR_RegAddKey( reg, ROOTKEY_PRIVATE, REG_REPLACE_LIST_KEY, &newkey);
if ( err == REGERR_OK ) {
err = NR_RegSetEntryString( reg, newkey, tmpfile, target );
}
NR_RegClose(reg);
}
else {
err = -1;
}
XP_FREEIF( targetURL );
XP_FREEIF( newURL );
return (err);
return err;
}
/*** private native NativeDeleteFile (Ljava/lang/String;)V ***/
JRI_PUBLIC_API(void)
native_netscape_softupdate_InstallPatch_NativeDeleteFile(JRIEnv* env,
struct netscape_softupdate_InstallPatch* self,
struct java_lang_String *jFilename)
{
char * filename = NULL;
char * fnameURL = NULL;
char * fname = NULL;
int result;
XP_StatStruct s;
filename = (char*)JRI_GetStringPlatformChars( env, jFilename, "", 0 );
XP_ASSERT( filename );
if ( filename != NULL ) {
fnameURL = XP_PlatformFileToURL( filename );
XP_ASSERT( fnameURL );
if ( fnameURL != NULL ) {
fname = fnameURL+7;
if ( XP_Stat( fname, &s, xpURL ) == 0 ) {
/* file is still here */
result = XP_FileRemove( fname, xpURL );
if ( result != SU_SUCCESS ) {
/* schedule for later */
}
}
}
}
XP_FREEIF( fnameURL );
}

View File

@ -40,5 +40,9 @@ void FE_ScheduleRenameUtility(void);
int FE_CopyFile (const char *in, const char *out);
#endif
int32 su_DeleteOldFileLater(char * filename);
int32 su_ReplaceOldFileLater(char *tmpfile, char *target );
XP_END_PROTOS

View File

@ -14,7 +14,7 @@
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
* Reserved.
*/
/* su_mac.c
/* su_mac.cp
* Mac specific softupdate routines
*/
@ -27,10 +27,13 @@
#include <Folders.h>
// MacFE
#include "ufilemgr.h"
#include "uprefd.h"
#include "macutil.h"
#include "macfeprefs.h"
#include "FSpCompat.h"
/* Given a system folder enum, returns a full path, in the URL form */
char * GetDirectoryPathFromSystemEnum(OSType folder)
@ -153,14 +156,14 @@ PR_PUBLIC_API(char *) FE_GetDirectoryPath( su_DirSpecID folderID)
case eOSDriveFolder:
{
char *p;
path = GetDirectoryPathFromSystemEnum(kSystemFolderType);
/* Drive on mac is :Drive:, so look for second ':' */
if ( (p = XP_STRCHR( path+1, ':' )) )
{
if (p[1])
p[1] = '\0';
}
path = GetDirectoryPathFromSystemEnum(kSystemFolderType);
/* Drive on mac is :Drive:, so look for second ':' */
char* p = XP_STRCHR( path+1, ':' );
if (p)
{
if (p[1])
p[1] = '\0';
}
}
break;
@ -192,9 +195,11 @@ PR_PUBLIC_API(char *) FE_GetDirectoryPath( su_DirSpecID folderID)
int FE_ExecuteFile( const char * fileName, const char * cmdline )
{
OSErr err;
FSSpec appSpec;
OSErr err;
FSSpec appSpec;
char* doomedPath;
if ( fileName == NULL )
return -1;
@ -215,6 +220,24 @@ int FE_ExecuteFile( const char * fileName, const char * cmdline )
launchThis.launchControlFlags += launchDontSwitch;
err = LaunchApplication(&launchThis);
ThrowIfOSErr_(err);
/* add this file to the registry to be deleted when we restart communicator */
if ( err == noErr)
{
/* Returns a full pathname to the given file */
doomedPath = CFileMgr::PathNameFromFSSpec(appSpec, true );
if (doomedPath)
{
su_DeleteOldFileLater(doomedPath);
XP_FREEIF(doomedPath);
}
}
}
catch (OSErr err)
{
@ -231,7 +254,6 @@ int FE_ReplaceExistingFile(char *from, XP_FileType ftype,
XP_Bool /* force */) /* We ignore force because we do not check versions */
{
int result;
OSErr err;
FSSpec fileSpec;
short vRefNum;
long dirID;
@ -241,25 +263,81 @@ int FE_ReplaceExistingFile(char *from, XP_FileType ftype,
{
result = XP_FileRename(from, ftype, to, totype);
}
else {
err = CFileMgr::FSSpecFromLocalUnixPath(to, &fileSpec, true);
if (err != noErr)
else
{
FSSpec tempFileSpec; /* Temp Spec for the unique file name */
FSSpec trashSpec;
char* doomedPath;
result = CFileMgr::FSSpecFromLocalUnixPath(to, &fileSpec, true);
if (result != noErr)
return -1;
err = FindFolder(fileSpec.vRefNum, kTrashFolderType, true, &vRefNum, &dirID);
if (err != noErr)
/* Get the trash DirID and RefNum */
result = FindFolder(fileSpec.vRefNum, kTrashFolderType, true, &vRefNum, &dirID);
if (result != noErr)
return -1;
CMovePBRec pb;
/*
We need to see if there is a file in the trash that is already named
what we are planning to move there. If there is, give us another name
that will work
*/
trashSpec.vRefNum = vRefNum;
trashSpec.parID = dirID;
trashSpec.name[0] = 0;
result = CFileMgr::UniqueFileSpec(trashSpec, fileSpec.name, tempFileSpec);
if ( result != noErr )
return -1;
/* Lets rename the file in-place. This works on application an open files */
result = FSpRename(&fileSpec, tempFileSpec.name);
if ( result != noErr)
return -1;
/* now that we renamed it to something that does not exist in the trash, move it there */
CMovePBRec pb;
pb.ioCompletion = NULL;
pb.ioNamePtr = (StringPtr)&fileSpec.name;
pb.ioNamePtr = (StringPtr)&tempFileSpec.name;
pb.ioDirID = fileSpec.parID;
pb.ioVRefNum = vRefNum;
pb.ioNewName = NULL;
pb.ioNewDirID = dirID;
err = PBCatMoveSync(&pb);
if ( err != noErr)
result = PBCatMoveSync(&pb);
if ( result != noErr)
return -1;
/* add this file to the registry to be deleted when we restart communicator */
result = FSMakeFSSpec(pb.ioVRefNum, pb.ioNewDirID, pb.ioNamePtr, &tempFileSpec);
if ( result == noErr)
{
/* Returns a full pathname to the given file */
doomedPath = CFileMgr::PathNameFromFSSpec(tempFileSpec, true );
if (doomedPath)
{
result = su_DeleteOldFileLater(doomedPath);
XP_FREEIF(doomedPath);
}
}
/* Rename the new file */
result = XP_FileRename(from, ftype, to, totype);
if ( result != noErr)
return -1;
}
return result;
}

View File

@ -15,144 +15,6 @@
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
* Reserved.
*/
#include "prtypes.h"
#include "prlink.h"
extern void Java_netscape_softupdate_FolderSpec_GetNativePath_stub();
extern void Java_netscape_softupdate_FolderSpec_NativeGetDirectoryPath_stub();
extern void Java_netscape_softupdate_FolderSpec_NativePickDefaultDirectory_stub();
extern void Java_netscape_softupdate_InstallDelete_NativeComplete_stub();
extern void Java_netscape_softupdate_InstallDelete_NativeCheckFileStatus_stub();
extern void Java_netscape_softupdate_InstallExecute_NativeAbort_stub();
extern void Java_netscape_softupdate_InstallExecute_NativeComplete_stub();
extern void Java_netscape_softupdate_InstallFile_NativeAbort_stub();
extern void Java_netscape_softupdate_InstallFile_NativeComplete_stub();
extern void Java_netscape_softupdate_InstallFile_NativeDoesFileExist_stub();
extern void Java_netscape_softupdate_InstallPatch_NativeDeleteFile_stub();
extern void Java_netscape_softupdate_InstallPatch_NativePatch_stub();
extern void Java_netscape_softupdate_InstallPatch_NativeReplace_stub();
extern void Java_netscape_softupdate_RegEntryEnumerator_regNext_stub();
extern void Java_netscape_softupdate_RegKeyEnumerator_regNext_stub();
extern void Java_netscape_softupdate_RegistryNode_nDeleteEntry_stub();
extern void Java_netscape_softupdate_RegistryNode_nGetEntryType_stub();
extern void Java_netscape_softupdate_RegistryNode_nGetEntry_stub();
extern void Java_netscape_softupdate_RegistryNode_setEntryB_stub();
extern void Java_netscape_softupdate_RegistryNode_setEntryI_stub();
extern void Java_netscape_softupdate_RegistryNode_setEntryS_stub();
extern void Java_netscape_softupdate_Registry_nAddKey_stub();
extern void Java_netscape_softupdate_Registry_nClose_stub();
extern void Java_netscape_softupdate_Registry_nDeleteKey_stub();
extern void Java_netscape_softupdate_Registry_nGetKey_stub();
extern void Java_netscape_softupdate_Registry_nOpen_stub();
extern void Java_netscape_softupdate_Registry_nUserName_stub();
extern void Java_netscape_softupdate_SoftwareUpdate_CloseJARFile_stub();
extern void Java_netscape_softupdate_SoftwareUpdate_NativeExtractJARFile_stub();
extern void Java_netscape_softupdate_SoftwareUpdate_OpenJARFile_stub();
extern void Java_netscape_softupdate_SoftwareUpdate_VerifyJSObject_stub();
extern void Java_netscape_softupdate_SoftwareUpdate_getCertificates_stub();
extern void Java_netscape_softupdate_SoftwareUpdate_NativeGestalt_stub();
extern void Java_netscape_softupdate_SoftwareUpdate_NativeDiskSpaceAvailable_stub();
extern void Java_netscape_softupdate_SoftwareUpdate_NativeFileURLToNative_stub();
extern void Java_netscape_softupdate_SoftwareUpdate_NativeMakeDirectory_stub();
extern void Java_netscape_softupdate_SoftwareUpdate_ExtractDirEntries_stub();
extern void Java_netscape_softupdate_SoftwareUpdate_NativeUninstall_stub();
extern void Java_netscape_softupdate_Trigger_StartSoftwareUpdate_stub();
extern void Java_netscape_softupdate_Trigger_UpdateEnabled_stub();
extern void Java_netscape_softupdate_VerRegEnumerator_regNext_stub();
extern void Java_netscape_softupdate_VersionRegistry_close_stub();
extern void Java_netscape_softupdate_VersionRegistry_componentPath_stub();
extern void Java_netscape_softupdate_VersionRegistry_componentVersion_stub();
extern void Java_netscape_softupdate_VersionRegistry_deleteComponent_stub();
extern void Java_netscape_softupdate_VersionRegistry_getDefaultDirectory_stub();
extern void Java_netscape_softupdate_VersionRegistry_getRefCount_stub();
extern void Java_netscape_softupdate_VersionRegistry_inRegistry_stub();
extern void Java_netscape_softupdate_VersionRegistry_installComponent_stub();
extern void Java_netscape_softupdate_VersionRegistry_setDefaultDirectory_stub();
extern void Java_netscape_softupdate_VersionRegistry_setRefCount_stub();
extern void Java_netscape_softupdate_VersionRegistry_uninstallAddFileToList_stub();
extern void Java_netscape_softupdate_VersionRegistry_uninstallCreateNode_stub();
extern void Java_netscape_softupdate_VersionRegistry_uninstallFileExistsInList_stub();
extern void Java_netscape_softupdate_VersionRegistry_validateComponent_stub();
#ifdef XP_PC
extern void Java_netscape_softupdate_WinProfile_nativeWriteString_stub();
extern void Java_netscape_softupdate_WinProfile_nativeGetString_stub();
extern void Java_netscape_softupdate_WinReg_nativeCreateKey_stub();
extern void Java_netscape_softupdate_WinReg_nativeDeleteKey_stub();
extern void Java_netscape_softupdate_WinReg_nativeDeleteValue_stub();
extern void Java_netscape_softupdate_WinReg_nativeSetValueString_stub();
extern void Java_netscape_softupdate_WinReg_nativeGetValueString_stub();
extern void Java_netscape_softupdate_WinReg_nativeSetValue_stub();
extern void Java_netscape_softupdate_WinReg_nativeGetValue_stub();
#endif
PRStaticLinkTable su_nodl_tab[] = {
{ "Java_netscape_softupdate_FolderSpec_GetNativePath_stub", Java_netscape_softupdate_FolderSpec_GetNativePath_stub },
{ "Java_netscape_softupdate_FolderSpec_NativeGetDirectoryPath_stub", Java_netscape_softupdate_FolderSpec_NativeGetDirectoryPath_stub },
{ "Java_netscape_softupdate_FolderSpec_NativePickDefaultDirectory_stub", Java_netscape_softupdate_FolderSpec_NativePickDefaultDirectory_stub },
{ "Java_netscape_softupdate_InstallDelete_NativeComplete_stub", Java_netscape_softupdate_InstallDelete_NativeComplete_stub },
{ "Java_netscape_softupdate_InstallDelete_NativeCheckFileStatus_stub", Java_netscape_softupdate_InstallDelete_NativeCheckFileStatus_stub },
{ "Java_netscape_softupdate_InstallExecute_NativeAbort_stub", Java_netscape_softupdate_InstallExecute_NativeAbort_stub },
{ "Java_netscape_softupdate_InstallExecute_NativeComplete_stub", Java_netscape_softupdate_InstallExecute_NativeComplete_stub },
{ "Java_netscape_softupdate_InstallFile_NativeAbort_stub", Java_netscape_softupdate_InstallFile_NativeAbort_stub },
{ "Java_netscape_softupdate_InstallFile_NativeComplete_stub", Java_netscape_softupdate_InstallFile_NativeComplete_stub },
{ "Java_netscape_softupdate_InstallFile_NativeDoesFileExist_stub", Java_netscape_softupdate_InstallFile_NativeDoesFileExist_stub },
{ "Java_netscape_softupdate_InstallPatch_NativeDeleteFile_stub", Java_netscape_softupdate_InstallPatch_NativeDeleteFile_stub },
{ "Java_netscape_softupdate_InstallPatch_NativePatch_stub", Java_netscape_softupdate_InstallPatch_NativePatch_stub },
{ "Java_netscape_softupdate_InstallPatch_NativeReplace_stub", Java_netscape_softupdate_InstallPatch_NativeReplace_stub },
{ "Java_netscape_softupdate_RegEntryEnumerator_regNext_stub", Java_netscape_softupdate_RegEntryEnumerator_regNext_stub },
{ "Java_netscape_softupdate_RegKeyEnumerator_regNext_stub", Java_netscape_softupdate_RegKeyEnumerator_regNext_stub },
{ "Java_netscape_softupdate_RegistryNode_nDeleteEntry_stub", Java_netscape_softupdate_RegistryNode_nDeleteEntry_stub },
{ "Java_netscape_softupdate_RegistryNode_nGetEntryType_stub", Java_netscape_softupdate_RegistryNode_nGetEntryType_stub },
{ "Java_netscape_softupdate_RegistryNode_nGetEntry_stub", Java_netscape_softupdate_RegistryNode_nGetEntry_stub },
{ "Java_netscape_softupdate_RegistryNode_setEntryB_stub", Java_netscape_softupdate_RegistryNode_setEntryB_stub },
{ "Java_netscape_softupdate_RegistryNode_setEntryI_stub", Java_netscape_softupdate_RegistryNode_setEntryI_stub },
{ "Java_netscape_softupdate_RegistryNode_setEntryS_stub", Java_netscape_softupdate_RegistryNode_setEntryS_stub },
{ "Java_netscape_softupdate_Registry_nAddKey_stub", Java_netscape_softupdate_Registry_nAddKey_stub },
{ "Java_netscape_softupdate_Registry_nClose_stub", Java_netscape_softupdate_Registry_nClose_stub },
{ "Java_netscape_softupdate_Registry_nDeleteKey_stub", Java_netscape_softupdate_Registry_nDeleteKey_stub },
{ "Java_netscape_softupdate_Registry_nGetKey_stub", Java_netscape_softupdate_Registry_nGetKey_stub },
{ "Java_netscape_softupdate_Registry_nOpen_stub", Java_netscape_softupdate_Registry_nOpen_stub },
{ "Java_netscape_softupdate_Registry_nUserName_stub", Java_netscape_softupdate_Registry_nUserName_stub },
{ "Java_netscape_softupdate_SoftwareUpdate_CloseJARFile_stub", Java_netscape_softupdate_SoftwareUpdate_CloseJARFile_stub },
{ "Java_netscape_softupdate_SoftwareUpdate_NativeExtractJARFile_stub", Java_netscape_softupdate_SoftwareUpdate_NativeExtractJARFile_stub },
{ "Java_netscape_softupdate_SoftwareUpdate_OpenJARFile_stub", Java_netscape_softupdate_SoftwareUpdate_OpenJARFile_stub },
{ "Java_netscape_softupdate_SoftwareUpdate_VerifyJSObject_stub", Java_netscape_softupdate_SoftwareUpdate_VerifyJSObject_stub },
{ "Java_netscape_softupdate_SoftwareUpdate_getCertificates_stub", Java_netscape_softupdate_SoftwareUpdate_getCertificates_stub },
{ "Java_netscape_softupdate_SoftwareUpdate_NativeGestalt_stub", Java_netscape_softupdate_SoftwareUpdate_NativeGestalt_stub },
{ "Java_netscape_softupdate_SoftwareUpdate_ExtractDirEntries_stub", Java_netscape_softupdate_SoftwareUpdate_ExtractDirEntries_stub },
{ "Java_netscape_softupdate_SoftwareUpdate_NativeDiskSpaceAvailable_stub", Java_netscape_softupdate_SoftwareUpdate_NativeDiskSpaceAvailable_stub },
{ "Java_netscape_softupdate_SoftwareUpdate_NativeFileURLToNative_stub", Java_netscape_softupdate_SoftwareUpdate_NativeFileURLToNative_stub },
{ "Java_netscape_softupdate_SoftwareUpdate_NativeMakeDirectory_stub", Java_netscape_softupdate_SoftwareUpdate_NativeMakeDirectory_stub },
{ "Java_netscape_softupdate_SoftwareUpdate_NativeUninstall_stub", Java_netscape_softupdate_SoftwareUpdate_NativeUninstall_stub },
{ "Java_netscape_softupdate_Trigger_StartSoftwareUpdate_stub", Java_netscape_softupdate_Trigger_StartSoftwareUpdate_stub },
{ "Java_netscape_softupdate_Trigger_UpdateEnabled_stub", Java_netscape_softupdate_Trigger_UpdateEnabled_stub },
{ "Java_netscape_softupdate_VerRegEnumerator_regNext_stub", Java_netscape_softupdate_VerRegEnumerator_regNext_stub },
{ "Java_netscape_softupdate_VersionRegistry_close_stub", Java_netscape_softupdate_VersionRegistry_close_stub },
{ "Java_netscape_softupdate_VersionRegistry_componentPath_stub", Java_netscape_softupdate_VersionRegistry_componentPath_stub },
{ "Java_netscape_softupdate_VersionRegistry_componentVersion_stub", Java_netscape_softupdate_VersionRegistry_componentVersion_stub },
{ "Java_netscape_softupdate_VersionRegistry_deleteComponent_stub", Java_netscape_softupdate_VersionRegistry_deleteComponent_stub },
{ "Java_netscape_softupdate_VersionRegistry_getDefaultDirectory_stub", Java_netscape_softupdate_VersionRegistry_getDefaultDirectory_stub },
{ "Java_netscape_softupdate_VersionRegistry_getRefCount_stub", Java_netscape_softupdate_VersionRegistry_getRefCount_stub },
{ "Java_netscape_softupdate_VersionRegistry_inRegistry_stub", Java_netscape_softupdate_VersionRegistry_inRegistry_stub },
{ "Java_netscape_softupdate_VersionRegistry_installComponent_stub", Java_netscape_softupdate_VersionRegistry_installComponent_stub },
{ "Java_netscape_softupdate_VersionRegistry_setDefaultDirectory_stub", Java_netscape_softupdate_VersionRegistry_setDefaultDirectory_stub },
{ "Java_netscape_softupdate_VersionRegistry_setRefCount_stub", Java_netscape_softupdate_VersionRegistry_setRefCount_stub },
{ "Java_netscape_softupdate_VersionRegistry_uninstallAddFileToList_stub", Java_netscape_softupdate_VersionRegistry_uninstallAddFileToList_stub },
{ "Java_netscape_softupdate_VersionRegistry_uninstallCreateNode_stub", Java_netscape_softupdate_VersionRegistry_uninstallCreateNode_stub },
{ "Java_netscape_softupdate_VersionRegistry_uninstallFileExistsInList_stub", Java_netscape_softupdate_VersionRegistry_uninstallFileExistsInList_stub },
{ "Java_netscape_softupdate_VersionRegistry_validateComponent_stub", Java_netscape_softupdate_VersionRegistry_validateComponent_stub },
#ifdef XP_PC
{ "Java_netscape_softupdate_WinProfile_nativeWriteString_stub", Java_netscape_softupdate_WinProfile_nativeWriteString_stub },
{ "Java_netscape_softupdate_WinProfile_nativeGetString_stub", Java_netscape_softupdate_WinProfile_nativeGetString_stub },
{ "Java_netscape_softupdate_WinReg_nativeCreateKey_stub", Java_netscape_softupdate_WinReg_nativeCreateKey_stub },
{ "Java_netscape_softupdate_WinReg_nativeDeleteKey_stub", Java_netscape_softupdate_WinReg_nativeDeleteKey_stub },
{ "Java_netscape_softupdate_WinReg_nativeDeleteValue_stub", Java_netscape_softupdate_WinReg_nativeDeleteValue_stub },
{ "Java_netscape_softupdate_WinReg_nativeSetValueString_stub", Java_netscape_softupdate_WinReg_nativeSetValueString_stub },
{ "Java_netscape_softupdate_WinReg_nativeGetValueString_stub", Java_netscape_softupdate_WinReg_nativeGetValueString_stub },
{ "Java_netscape_softupdate_WinReg_nativeSetValue_stub", Java_netscape_softupdate_WinReg_nativeSetValue_stub },
{ "Java_netscape_softupdate_WinReg_nativeGetValue_stub", Java_netscape_softupdate_WinReg_nativeGetValue_stub },
#endif
{ 0, 0, },
};
/*
* TODO: We need to delete this file
*/

View File

@ -0,0 +1,898 @@
/* -*- Mode: C++; tab-width: 4; tabs-indent-mode: nil -*-
* 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 "su_pas.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
OSErr PAS_EncodeFile(FSSpec *inSpec, FSSpec *outSpec);
OSErr PAS_DecodeFile(FSSpec *inSpec, FSSpec *outSpec);
OSErr PAS_encodeResource(FSSpec *inFile, short outRefNum);
OSErr PAS_decodeResource(PASEntry *entry, FSSpec *outFile, short inRefNum);
OSErr PAS_encodeMisc(FSSpec *inFile, short outRefNum);
OSErr PAS_decodeMisc(PASEntry *entry, FSSpec *outFile, short inRefNum);
OSErr PAS_encodeData(FSSpec *inFile, short outRefNum);
OSErr PAS_decodeData(PASEntry *entry, FSSpec *outFile, short inRefNum);
OSErr PAS_encodeHeader(short refnum);
OSErr PAS_decodeHeader(short refNum, PASHeader *header);
unsigned long PAS_getDataSize(FSSpec *spec);
short PAS_getResourceID(Handle resource);
OSErr PAS_flattenResource(ResType type, short *ids, long count, short source, short dest);
OSErr PAS_unflattenResource(PASResource *pasRes, Ptr buffer, short dest);
void PAS_sortTypes(short sourceRefNum, ResType **resTypePtr, long *count);
void PAS_sortIDs(short sourceRefNum, OSType theType, short **IdPtr, long *count);
void PAS_bubbleSortResType(ResType *types, long count);
void PAS_bubbleSortIDS(short *ids, long count);
OSErr PAS_EncodeFile(FSSpec *inSpec, FSSpec *outSpec)
{
OSErr err;
short outRefNum;
PASEntry dataEntry, miscEntry, resourceEntry;
long sizeOfEntry;
memset(&dataEntry, 0, sizeof(PASEntry));
memset(&miscEntry, 0, sizeof(PASEntry));
memset(&resourceEntry, 0, sizeof(PASEntry));
FSpDelete( outSpec ) ;
err = FSpCreate( outSpec, kCreator, kType ,smSystemScript );
if (err != noErr) return err;
err = FSpOpenDF(outSpec, fsRdWrPerm, &outRefNum);
if (err != noErr) goto error;
/* Write Out Header */
err = PAS_encodeHeader(outRefNum);
if (err != noErr) goto error;
/* Write Out Data Entry */
dataEntry.entryID = ePas_Data;
dataEntry.entryLength = PAS_getDataSize(inSpec);
dataEntry.entryOffset = sizeof(PASHeader) + (3 * sizeof(PASEntry));
sizeOfEntry = sizeof(PASEntry);
if(dataEntry.entryLength < 0)
{
err = dataEntry.entryLength;
goto error;
}
err = FSWrite(outRefNum, &sizeOfEntry, &dataEntry);
if (err != noErr) goto error;
/* Write Out Misc Entry */
miscEntry.entryID = ePas_Misc;
miscEntry.entryLength = sizeof(PASMiscInfo);
miscEntry.entryOffset = sizeof(PASHeader) + (3 * sizeof(PASEntry)) + dataEntry.entryLength;
sizeOfEntry = sizeof(PASEntry);
err = FSWrite(outRefNum, &sizeOfEntry, &miscEntry);
if (err != noErr) goto error;
/* Write Out Resource Entry */
resourceEntry.entryID = ePas_Resource;
resourceEntry.entryLength = -1;
resourceEntry.entryOffset = sizeof(PASHeader) + (3 * sizeof(PASEntry)) + dataEntry.entryLength + miscEntry.entryLength;
sizeOfEntry = sizeof(PASEntry);
err = FSWrite(outRefNum, &sizeOfEntry, &resourceEntry);
if (err != noErr) goto error;
err = PAS_encodeData(inSpec, outRefNum);
if (err != noErr) goto error;
err = PAS_encodeMisc(inSpec, outRefNum);
if (err != noErr) goto error;
err = PAS_encodeResource(inSpec, outRefNum);
if (err == kResFileNotOpened)
{
// there was no resource fork
err = noErr;
}
else if (err != noErr)
{
goto error;
}
FSClose(outRefNum);
return noErr;
error:
if (outRefNum != kResFileNotOpened)
{
FSClose(outRefNum);
}
FSpDelete( outSpec ) ;
return err;
}
OSErr PAS_DecodeFile(FSSpec *inSpec, FSSpec *outSpec)
{
OSErr err;
short inRefNum;
PASHeader header;
PASEntry dataEntry, miscEntry, resourceEntry;
long sizeOfEntry;
FSpDelete( outSpec ) ;
err = FSpCreate( outSpec, kCreator, kType ,smSystemScript );
if (err != noErr) return err;
err = FSpOpenDF(inSpec, fsRdPerm, &inRefNum);
if (err != noErr) goto error;
/* Read Header */
err = PAS_decodeHeader(inRefNum, &header);
if (err != noErr) goto error;
if( header.magicNum != PAS_MAGIC_NUM ||
header.versionNum != PAS_VERSION)
{
err = -1;
goto error;
}
/* Read Data Entry */
err = SetFPos(inRefNum, fsFromStart, sizeof(PASHeader));
if (err != noErr) goto error;
sizeOfEntry = sizeof(PASEntry);
err = FSRead(inRefNum, &sizeOfEntry, &dataEntry);
if (err != noErr) goto error;
/* Read Misc Entry */
err = SetFPos(inRefNum, fsFromStart, (sizeof(PASHeader) + sizeof(PASEntry)));
if (err != noErr) goto error;
sizeOfEntry = sizeof(PASEntry);
err = FSRead(inRefNum, &sizeOfEntry, &miscEntry);
if (err != noErr) goto error;
/* Read Resource Entry */
err = SetFPos(inRefNum, fsFromStart, (sizeof(PASHeader) + (2 * sizeof(PASEntry)))) ;
if (err != noErr) goto error;
sizeOfEntry = sizeof(PASEntry);
err = FSRead(inRefNum, &sizeOfEntry, &resourceEntry);
if (err != noErr) goto error;
err = PAS_decodeData(&dataEntry, outSpec, inRefNum);
if (err != noErr) goto error;
err = PAS_decodeMisc(&miscEntry, outSpec, inRefNum);
if (err != noErr) goto error;
err = PAS_decodeResource(&resourceEntry, outSpec, inRefNum);
if (err == kResFileNotOpened)
{
// there was no resource fork
err = noErr;
}
else if (err != noErr)
{
goto error;
}
FSClose(inRefNum);
return noErr;
error:
if (inRefNum != kResFileNotOpened)
{
FSClose(inRefNum);
}
FSpDelete( outSpec ) ;
return err;
}
#pragma mark -
OSErr PAS_encodeResource(FSSpec *inFile, short outRefNum)
{
OSErr err;
short inRefNum;
PASResFork resInfo;
SInt32 currentWrite;
ResType *resTypes;
long typeCount;
short *ids;
long idCount;
inRefNum = FSpOpenResFile(inFile, fsRdPerm);
if (inRefNum < noErr) return inRefNum;
memset(&resInfo, 0, sizeof(PASResFork));
PAS_sortTypes(inRefNum, &resTypes, &typeCount);
resInfo.NumberOfTypes = typeCount;
currentWrite = sizeof(PASResFork);
err = FSWrite(outRefNum, &currentWrite, &resInfo);
if (err != noErr) return err;
for (typeCount = 0; typeCount < resInfo.NumberOfTypes; typeCount++)
{
PAS_sortIDs(inRefNum, resTypes[typeCount], &ids, &idCount);
PAS_flattenResource(resTypes[typeCount], ids, idCount, inRefNum, outRefNum);
DisposePtr((Ptr)ids);
}
DisposePtr((Ptr)resTypes);
CloseResFile(inRefNum);
return noErr;
}
OSErr PAS_decodeResource(PASEntry *entry, FSSpec *outFile, short inRefNum)
{
OSErr err;
short outRefNum;
PASResFork info;
SInt32 infoSize;
PASResource pasRes;
SInt32 pasResSize;
Ptr buffer;
long bufSize;
outRefNum = FSpOpenResFile(outFile, fsRdWrPerm);
if (outRefNum < noErr) return outRefNum;
infoSize = sizeof(PASResFork);
err = SetFPos(inRefNum, fsFromStart, (*entry).entryOffset );
if (err != noErr) return err;
err = FSRead( inRefNum, &infoSize, &info);
if (err != noErr) return err;
if(infoSize != sizeof(PASResFork))
{
return -1;
}
while (err == noErr)
{
pasResSize = sizeof(PASResource);
err = FSRead( inRefNum, &pasResSize, &pasRes);
if(err == eofErr)
{
break;
}
if (err != noErr)
{
goto error;
}
bufSize = pasRes.length;
buffer = NewPtrClear(bufSize);
err = FSRead( inRefNum, &bufSize, buffer);
if (err != noErr && err != eofErr) goto error;
err = PAS_unflattenResource( &pasRes,
buffer,
outRefNum);
if (err != noErr) goto error;
DisposePtr(buffer);
}
CloseResFile(outRefNum);
return noErr;
error:
return -1;
}
#pragma mark -
OSErr PAS_encodeMisc(FSSpec *inFile, short outRefNum)
{
OSErr err;
short inRefNum;
PASMiscInfo infoBlock;
FInfo fInfo;
SInt32 currentRead;
err = FSpOpenDF(inFile, fsRdPerm, &inRefNum);
if (err != noErr) return err;
memset(&infoBlock, 0, sizeof(PASMiscInfo));
err = FSpGetFInfo(inFile, &fInfo);
if (err != noErr) return err;
infoBlock.fileType = fInfo.fdType;
infoBlock.fileCreator = fInfo.fdCreator;
infoBlock.fileFlags = fInfo.fdFlags;
FSClose(inRefNum);
inRefNum = FSpOpenResFile(inFile, fsRdPerm);
if (inRefNum > noErr)
{
infoBlock.fileHasResFork = 1;
infoBlock.fileResAttrs = GetResFileAttrs(inRefNum);
FSClose(inRefNum);
}
else
{
infoBlock.fileHasResFork = 0;
infoBlock.fileResAttrs = 0;
}
currentRead = sizeof(PASMiscInfo);
err = FSWrite(outRefNum, &currentRead, &infoBlock);
if (err != noErr) return err;
CloseResFile(inRefNum);
return noErr;
}
OSErr PAS_decodeMisc(PASEntry *entry, FSSpec *outFile, short inRefNum)
{
OSErr err;
short outRefNum;
PASMiscInfo info;
SInt32 infoSize;
FInfo theFInfo;
infoSize = sizeof(PASMiscInfo);
err = SetFPos(inRefNum, fsFromStart, (*entry).entryOffset );
if (err != noErr) return err;
err = FSRead( inRefNum, &infoSize, &info);
if (err != noErr) return err;
if(infoSize != sizeof(PASMiscInfo))
{
return -1;
}
err = FSpOpenDF(outFile, fsRdWrPerm, &outRefNum);
if (err != noErr) return err;
memset(&theFInfo, 0, sizeof(FInfo));
theFInfo.fdType = info.fileType;
theFInfo.fdCreator = info.fileCreator;
theFInfo.fdFlags = info.fileFlags;
err = FSpSetFInfo(outFile, &theFInfo);
if (err != noErr) return err;
FSClose(outRefNum);
if (info.fileHasResFork)
{
outRefNum = FSpOpenResFile(outFile, fsRdWrPerm);
if (outRefNum < noErr)
{
// maybe it does not have one!
FSpCreateResFile(outFile, info.fileCreator, info.fileType, smSystemScript);
outRefNum = FSpOpenResFile(outFile, fsRdWrPerm);
if (outRefNum < noErr)
{
return err;
}
}
SetResFileAttrs(outRefNum, info.fileResAttrs);
CloseResFile(outRefNum);
}
return noErr;
}
#pragma mark -
OSErr PAS_encodeData(FSSpec *inFile, short outRefNum)
{
OSErr err;
short inRefNum;
char buffer[PAS_BUFFER_SIZE];
SInt32 currentRead = PAS_BUFFER_SIZE;
err = FSpOpenDF(inFile, fsRdPerm, &inRefNum);
if (err != noErr) return err;
while ( currentRead > 0 )
{
err = FSRead( inRefNum, &currentRead, buffer);
if (err != noErr && err != eofErr) return err;
err = FSWrite(outRefNum, &currentRead, buffer);
if (err != noErr) return err;
}
FSClose(inRefNum);
return noErr;
}
OSErr PAS_decodeData(PASEntry *entry, FSSpec *outFile, short inRefNum)
{
OSErr err;
short outRefNum;
char buffer[PAS_BUFFER_SIZE];
SInt32 currentWrite = PAS_BUFFER_SIZE;
SInt32 totalSize;
err = FSpOpenDF(outFile, fsRdWrPerm, &outRefNum);
if (err != noErr) return err;
err = SetFPos(inRefNum, fsFromStart, (*entry).entryOffset );
if (err != noErr) return err;
err = SetFPos(outRefNum, fsFromStart, 0 );
if (err != noErr) return err;
totalSize = (*entry).entryLength;
while(totalSize > 0)
{
currentWrite = PAS_BUFFER_SIZE;
if (totalSize < currentWrite)
{
currentWrite = totalSize;
}
err = FSRead( inRefNum, &currentWrite, buffer);
if (err != noErr && err != eofErr) return err;
err = FSWrite(outRefNum, &currentWrite, buffer);
if (err != noErr) return err;
totalSize = totalSize - currentWrite;
}
FSClose(outRefNum);
return noErr;
}
#pragma mark -
OSErr PAS_encodeHeader(short refnum)
{
PASHeader header;
long sizeOfHeader;
OSErr err;
sizeOfHeader = sizeof(PASHeader);
memset(&header, 0, sizeOfHeader);
header.magicNum = PAS_MAGIC_NUM;
header.versionNum = PAS_VERSION;
header.numEntries = 3;
/* Write Out Header */
err = FSWrite(refnum, &sizeOfHeader, &header);
return err;
}
OSErr PAS_decodeHeader(short refNum, PASHeader *header)
{
OSErr err;
long sizeOfHeader;
sizeOfHeader = sizeof(PASHeader);
memset(header, 0, sizeOfHeader);
err = FSRead(refNum, &sizeOfHeader, header);
return err;
}
#pragma mark -
unsigned long PAS_getDataSize(FSSpec *spec)
{
short refNum;
OSErr err;
Str255 temp;
CInfoPBRec cbrec;
err = FSpOpenDF(spec, fsRdPerm, &refNum);
memcpy( temp, spec->name, spec->name[0] + 1);
cbrec.hFileInfo.ioNamePtr = temp;
cbrec.hFileInfo.ioDirID = spec->parID;
cbrec.hFileInfo.ioVRefNum = spec->vRefNum;
cbrec.hFileInfo.ioFDirIndex = 0;
err = PBGetCatInfoSync(&cbrec);
FSClose(refNum);
if(err != noErr)
{
cbrec.hFileInfo.ioFlLgLen = err;
}
return (cbrec.hFileInfo.ioFlLgLen);
}
short PAS_getResourceID(Handle resource)
{
ResType theType;
Str255 name;
short theID;
memset(&name, 0, sizeof(Str255));
GetResInfo(resource, &theID, &theType, name);
return theID;
}
#pragma mark -
OSErr PAS_flattenResource(ResType type, short *ids, long count, short source, short dest)
{
long idIndex;
short oldResFile;
Handle resToCopy;
long handleLength;
PASResource pasResource;
long pasResLen;
OSErr err;
oldResFile=CurResFile();
UseResFile(source);
for (idIndex=0; idIndex < count; idIndex++)
{
if( (type == 'SIZE') && ( ids[idIndex] == 1 || ids[idIndex] == 0 ) )
{
/*
We do not want to encode/flatten SIZE 0 or 1 because this
is the resource that the user can motify. Most applications
will not be effected if we remove these resources
*/
}
else
{
resToCopy=Get1Resource(type,ids[idIndex]);
if(!resToCopy)
{
return resNotFound;
}
memset(&pasResource, 0, sizeof(PASResource));
GetResInfo( resToCopy,
&pasResource.attrID,
&pasResource.attrType,
pasResource.attrName);
pasResource.attr = GetResAttrs(resToCopy);
DetachResource(resToCopy);
HLock(resToCopy);
pasResource.length = GetHandleSize(resToCopy);
handleLength = pasResource.length;
pasResLen = sizeof(PASResource);
err = FSWrite(dest, &pasResLen, &pasResource);
if(err != noErr)
{
return err;
}
err = FSWrite(dest, &handleLength, &(**resToCopy));
if(err != noErr)
{
return err;
}
DisposeHandle(resToCopy);
}
}
UseResFile(oldResFile);
return noErr;
}
OSErr PAS_unflattenResource(PASResource *pasRes, Ptr buffer, short dest)
{
short oldResFile;
Handle resToCopy;
OSErr err = noErr;
if( dest < 0 ||
pasRes->length <= 0 ||
buffer == NULL )
{
return paramErr;
}
oldResFile=CurResFile();
UseResFile(dest);
resToCopy = NewHandle(pasRes->length);
if(resToCopy == NULL)
{
return memFullErr;
}
HLock(resToCopy);
BlockMove(buffer, *resToCopy, pasRes->length);
AddResource(resToCopy, pasRes->attrType, pasRes->attrID, pasRes->attrName);
WriteResource(resToCopy);
UpdateResFile(dest);
SetResAttrs(resToCopy, pasRes->attr);
WriteResource(resToCopy);
UpdateResFile(dest);
ReleaseResource(resToCopy);
UseResFile(oldResFile);
return noErr;
}
#pragma mark -
void PAS_sortTypes(short sourceRefNum, ResType **resTypePtr, long *count)
{
short oldRef;
short typeIndex;
short numberOfTypes;
*count = -1;
oldRef = CurResFile();
UseResFile(sourceRefNum);
numberOfTypes = Count1Types();
*resTypePtr = (ResType*) NewPtrClear( numberOfTypes * sizeof(OSType) );
for (typeIndex=1; typeIndex <= numberOfTypes; typeIndex++)
{
Get1IndType(&(*resTypePtr)[typeIndex-1], typeIndex);
}
UseResFile(oldRef);
PAS_bubbleSortResType(*resTypePtr, numberOfTypes);
*count = numberOfTypes;
}
void PAS_sortIDs(short sourceRefNum, OSType theType, short **IdPtr, long *count)
{
short oldRef;
Handle theHandle;
short resCount;
short resIndex;
*count = -1;
oldRef = CurResFile();
UseResFile(sourceRefNum);
resCount = Count1Resources(theType);
*IdPtr = (short*) NewPtrClear( resCount * sizeof(short) );
for (resIndex=1; resIndex <= resCount; resIndex++)
{
theHandle = Get1IndResource(theType, resIndex);
if(theHandle == NULL) return;
(*IdPtr)[resIndex-1] = PAS_getResourceID(theHandle);
ReleaseResource(theHandle);
}
UseResFile(oldRef);
PAS_bubbleSortIDS(*IdPtr, resCount);
*count = resCount;
}
#pragma mark -
void
PAS_bubbleSortResType(ResType *types, long count)
{
long x, y;
OSType temp;
for (x=0; x < count-1; x++)
{
for (y=0; y < count-x-1; y++)
{
if (types[y] > types[y+1])
{
temp=types[y];
types[y]=types[y+1];
types[y+1]=temp;
}
}
}
}
void
PAS_bubbleSortIDS(short *ids, long count)
{
long x, y;
short temp;
for (x=0; x < count-1; x++)
{
for (y=0; y < count-x-1; y++)
{
if (ids[y] > ids[y+1])
{
temp=ids[y];
ids[y]=ids[y+1];
ids[y+1]=temp;
}
}
}
}

View File

@ -0,0 +1,109 @@
/* -*- Mode: C++; tab-width: 4; tabs-indent-mode: nil -*-
* 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 SU_PAS_H
#define SU_PAS_H
#include <Errors.h>
#include <Types.h>
#include <Files.h>
#include <Script.h>
#include <Resources.h>
typedef struct PASHeader /* header portion of Patchable AppleSingle */
{
UInt32 magicNum; /* internal file type tag = 0x00244200*/
UInt32 versionNum; /* format version: 1 = 0x00010000 */
UInt8 filler[16]; /* filler */
UInt16 numEntries; /* number of entries which follow */
} PASHeader ;
typedef struct PASEntry /* one Patchable AppleSingle entry descriptor */
{
UInt32 entryID; /* entry type: see list, 0 invalid */
UInt32 entryOffset; /* offset, in bytes, from beginning */
/* of file to this entry's data */
UInt32 entryLength; /* length of data in octets */
} PASEntry;
typedef struct PASMiscInfo
{
short fileHasResFork;
short fileResAttrs;
OSType fileType;
OSType fileCreator;
UInt32 fileFlags;
} PASMiscInfo;
typedef struct PASResFork
{
short NumberOfTypes;
} PASResFork;
typedef struct PASResource
{
short attr;
short attrID;
OSType attrType;
Str255 attrName;
unsigned long length;
} PASResource;
#if PRAGMA_ALIGN_SUPPORTED
#pragma options align=reset
#endif
#define kCreator '????'
#define kType '????'
#define PAS_BUFFER_SIZE 8192
#define PAS_MAGIC_NUM (0x00244200)
#define PAS_VERSION (0x00010000)
enum
{
ePas_Data = 1,
ePas_Misc,
ePas_Resource
};
#ifdef __cplusplus
extern "C" {
#endif
/* Prototypes */
OSErr PAS_EncodeFile(FSSpec *inSpec, FSSpec *outSpec);
OSErr PAS_DecodeFile(FSSpec *inSpec, FSSpec *outSpec);
#ifdef __cplusplus
}
#endif
#endif /* SU_PAS_H */

View File

@ -26,6 +26,13 @@
#include <winnt.h>
#endif
#ifdef SUNOS4
#include <unistd.h> /* for SEEK_SET */
#endif
#ifdef XP_MAC
#include "Errors.h" /* for fnfErr */
#endif
/*--------------------------------------
* constants / macros
@ -74,10 +81,11 @@ int32 SU_PatchFile( char* srcfile, XP_FileType srctype, char* patchfile,
XP_FileType patchtype, char* outfile, XP_FileType outtype )
{
DIFFDATA *dd;
int32 status = GDIFF_ERR_MEM;
char *realfile = srcfile;
XP_FileType realtype = srctype;
char *tmpurl = NULL;
int32 status = GDIFF_ERR_MEM;
char *realfile = srcfile;
XP_FileType realtype = srctype;
char *tmpurl = NULL;
dd = XP_CALLOC( 1, sizeof(DIFFDATA) );
if ( dd != NULL )
@ -109,6 +117,7 @@ int32 SU_PatchFile( char* srcfile, XP_FileType srctype, char* patchfile,
if (su_unbind( srcfile, srctype, tmpurl, xpURL )) {
realfile = tmpurl;
realtype = xpURL;
}
}
else
@ -116,6 +125,68 @@ int32 SU_PatchFile( char* srcfile, XP_FileType srctype, char* patchfile,
}
#endif
#ifdef XP_MAC
if ( dd->bMacAppleSingle && status == GDIFF_OK )
{
FSSpec srcFSSpec, tmpFSSpec;
char *srcMacPath, *tmpMacPath;
/* We need a tmp file so that we can AppleSingle the src file */
tmpurl = WH_TempName( xpURL, NULL );
/* Put the source file into a mac file path */
tmpMacPath = WH_FileName( tmpurl, xpURL );
/* Get the mac filepath for srcMacPath */
srcMacPath = WH_FileName( srcfile, srctype );
/* bail if we did not get our files! */
if ( tmpMacPath == NULL || srcMacPath == NULL)
{
XP_FREEIF( srcMacPath );
XP_FREEIF( tmpMacPath );
goto cleanup;
}
/* Get the source FSSpec */
status = FSpLocationFromFullPath(strlen(srcMacPath), srcMacPath, &srcFSSpec);
if (status != noErr)
{
XP_FREEIF( srcMacPath );
XP_FREEIF( tmpMacPath );
goto cleanup;
}
/* Get the temporary FSSpec. THis is where the encoded file will go */
status = FSpLocationFromFullPath(strlen(tmpMacPath), tmpMacPath, &tmpFSSpec);
if (status != noErr && status != fnfErr)
{
XP_FREEIF( srcMacPath );
XP_FREEIF( tmpMacPath );
goto cleanup;
}
/* Encode! */
status = PAS_EncodeFile(&srcFSSpec, &tmpFSSpec);
if (status == noErr)
{
/* set */
realfile = tmpurl;
realtype = xpURL;
}
XP_FREEIF( srcMacPath );
XP_FREEIF( tmpMacPath );
}
#endif
if ( status != GDIFF_OK )
goto cleanup;
@ -141,16 +212,120 @@ int32 SU_PatchFile( char* srcfile, XP_FileType srctype, char* patchfile,
}
#ifdef XP_MAC
if ( dd->bMacAppleSingle && status == GDIFF_OK )
{
FSSpec outFSSpec;
char *outMacPath;
char* anotherURL;
char* anotherURLMacPath;
FSSpec anotherFSSpec;
Str63 fileName;
/* We need a temp file so that we can decode somewhere */
anotherURL = WH_TempName( xpURL, NULL );
/* Get the mac file path for anotherURL */
anotherURLMacPath = WH_FileName( anotherURL, xpURL );
/* Get the mac file path for outfile */
outMacPath = WH_FileName( outfile, outtype );
if ( anotherURLMacPath == NULL || outMacPath == NULL)
{
status = mFulErr;
goto macPostProcessCleanup;
}
/* Get the out FSSpec. This is where the decoded will end up */
status = FSpLocationFromFullPath(strlen(outMacPath), outMacPath, &outFSSpec);
if (status != noErr)
{
goto macPostProcessCleanup;
}
/* Get the anotherURL FSSpec. This is where the decoded will first be placed */
status = FSpLocationFromFullPath(strlen(anotherURLMacPath), anotherURLMacPath, &anotherFSSpec);
if (status != noErr && status != fnfErr)
{
goto macPostProcessCleanup;
}
/* Close the out file so that we can read it */
XP_FileClose( dd->fOut );
dd->fOut = NULL;
status = PAS_DecodeFile(&outFSSpec, &anotherFSSpec);
if (status != noErr)
{
goto macPostProcessCleanup;
}
/* Delete the outfile so that we can replace */
XP_FileRemove( outfile, outtype );
/* get the name of the file */
BlockMove(outFSSpec.name, fileName, sizeof(Str63) );
/* We want the parent */
outFSSpec.name[0] = 0;
/* Copy the output of the decodef to the outfile location passed to us */
status = FSpFileCopy(&anotherFSSpec, &outFSSpec, fileName, NULL, 0,true);
if (status != noErr)
{
goto macPostProcessCleanup;
}
macPostProcessCleanup:
XP_FREEIF( outMacPath );
XP_FREEIF( anotherURLMacPath );
if(anotherURL)
{
XP_FileRemove( anotherURL, xpURL );
XP_FREEIF( anotherURL );
}
if (status != noErr)
{
goto cleanup;
}
}
#endif
cleanup:
if ( dd != NULL )
{
if ( dd->fSrc != NULL )
XP_FileClose( dd->fSrc );
if ( dd->fDiff != NULL )
XP_FileClose( dd->fDiff );
if ( dd->fOut != NULL )
if ( dd->fDiff != NULL )
{
XP_FileClose( dd->fDiff );
if ( status != GDIFF_OK )
{
XP_FileRemove( outfile, outtype );
}
}
if ( dd->fOut != NULL )
XP_FileClose( dd->fOut );
XP_FREEIF( dd->databuf );
@ -159,13 +334,11 @@ cleanup:
XP_FREE(dd);
}
if ( status != GDIFF_OK )
XP_FileRemove( outfile, outtype );
if ( tmpurl != NULL ) {
if ( tmpurl != NULL ) {
XP_FileRemove( tmpurl, xpURL );
XP_FREE( tmpurl );
}
return status;
}

View File

@ -16,642 +16,11 @@
* Reserved.
*/
/* su_trigger.c
* netscape.softupdate.Trigger.java
* native implementation
* TODO: we should delete this file.
*/
#define IMPLEMENT_netscape_softupdate_Trigger
#ifndef XP_MAC
#include "_jri/netscape_softupdate_Trigger.c"
#else
#include "netscape_softupdate_Trigger.c"
#endif
#define IMPLEMENT_netscape_softupdate_SoftUpdateException
#ifndef XP_MAC
#include "_jri/netscape_softupdate_SoftUpdateException.c"
#else
#include "n_s_SoftUpdateException.c"
#endif
#define IMPLEMENT_netscape_softupdate_SoftwareUpdate
#ifndef XP_MAC
#include "_jri/netscape_softupdate_SoftwareUpdate.c"
#else
#include "n_softupdate_SoftwareUpdate.c"
#endif
#define IMPLEMENT_netscape_javascript_JSObject /* Only needed because we are calling privates */
#ifndef XP_MAC
#include "netscape_javascript_JSObject.h"
#else
#include "netscape_javascript_JSObject.h"
#endif
#ifndef XP_MAC
#include "_jri/netscape_softupdate_Strings.c"
#else
#include "netscape_softupdate_Strings.c"
#endif
#include "softupdt.h"
#include "zig.h"
#include "prefapi.h"
#include "su_aplsn.h"
#include "proto.h"
#include "jsapi.h"
#include "xp_error.h"
#include "jsjava.h"
#include "NSReg.h"
#include "VerReg.h"
extern void FolderSpecInitialize(JRIEnv * env);
extern void InstallFileInitialize(JRIEnv * env);
extern void SU_Reg_Initialize(JRIEnv *env );
extern void SUWinSpecificInit( JRIEnv *env );
extern uint32 FE_DiskSpaceAvailable (MWContext *context, const char *lpszPath );
#ifdef XP_MAC
#pragma export on
#endif
void SU_Initialize(JRIEnv * env)
void SU_Initialize()
{
SU_Reg_Initialize( env );
use_netscape_softupdate_Trigger( env );
use_netscape_softupdate_SoftwareUpdate( env );
use_netscape_softupdate_Strings( env );
use_netscape_softupdate_SoftUpdateException( env );
FolderSpecInitialize(env);
InstallFileInitialize(env);
#if defined(XP_PC)
SUWinSpecificInit( env );
#endif
}
#ifdef XP_MAC
#pragma export reset
#endif
JRI_PUBLIC_API(jbool)
native_netscape_softupdate_Trigger_UpdateEnabled(
JRIEnv* env,
struct java_lang_Class* clazz)
{
XP_Bool enabled;
PREF_GetBoolPref( AUTOUPDATE_ENABLE_PREF, &enabled);
if (enabled)
return JRITrue;
else
return JRIFalse;
}
JRI_PUBLIC_API(jbool)
native_netscape_softupdate_Trigger_StartSoftwareUpdate(JRIEnv* env,
struct java_lang_Class* clazz,
struct java_lang_String *jurl,
jint flags)
{
char * url = NULL;
url = (char*)JRI_GetStringPlatformChars( env, jurl, "", 0 );
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 FALSE;
}
return FALSE;
}
extern int MK_OUT_OF_MEMORY;
extern JSClass lm_softup_class;
/*** private native VerifyJSObject ()V ***/
/* Check out Java declaration for docs */
JRI_PUBLIC_API(void)
native_netscape_softupdate_SoftwareUpdate_VerifyJSObject(JRIEnv* env,
struct netscape_softupdate_SoftwareUpdate* self,
struct netscape_javascript_JSObject *a)
{
/*
Get the object's class, and verify that it is of class SoftUpdate
*/
JSObject * jsobj;
JSClass * jsclass;
/* jsobj = (JSObject *) get_netscape_javascript_JSObject_internal(env, a); */
#ifdef OJI // XXX hack
jsobj = NULL;
#else
jsobj = JSJ_ExtractInternalJSObject(env, (HObject*)a);
#endif
jsclass = JS_GetClass(jsobj);
if ( jsclass != &lm_softup_class )
{
struct netscape_softupdate_SoftUpdateException* e;
struct java_lang_String * errStr;
errStr = netscape_softupdate_Strings_error_0005fBadJSArgument(env,
class_netscape_softupdate_Strings(env));
e = netscape_softupdate_SoftUpdateException_new( env,
class_netscape_softupdate_SoftUpdateException(env),
errStr,
-1);
JRI_Throw(env, (struct java_lang_Throwable *)e);
return;
}
}
/*** private native OpenJARFile ()V ***/
JRI_PUBLIC_API(void)
native_netscape_softupdate_SoftwareUpdate_OpenJARFile(JRIEnv* env, struct netscape_softupdate_SoftwareUpdate* self)
{
ZIG * jarData;
char * jarFile;
struct java_lang_String * jjarFile;
int err;
struct java_lang_String * errStr;
struct netscape_softupdate_SoftUpdateException* e;
XP_Bool enabled;
PREF_GetBoolPref( AUTOUPDATE_ENABLE_PREF, &enabled);
if (!enabled)
{
errStr = netscape_softupdate_Strings_error_0005fSmartUpdateDisabled(env,
class_netscape_softupdate_Strings(env));
e = netscape_softupdate_SoftUpdateException_new( env,
class_netscape_softupdate_SoftUpdateException(env),
errStr,
-1);
JRI_Throw(env, (struct java_lang_Throwable *)e);
return;
}
jjarFile = get_netscape_softupdate_SoftwareUpdate_jarName( env, self);
jarFile = (char*)JRI_GetStringPlatformChars( env, jjarFile, "", 0 );
if (jarFile == NULL) return; /* error already signaled */
/* Open and initialize the JAR archive */
jarData = SOB_new();
if ( jarData == NULL )
{
errStr = netscape_softupdate_Strings_error_0005fUnexpected(env,
class_netscape_softupdate_Strings(env));
e = netscape_softupdate_SoftUpdateException_new( env,
class_netscape_softupdate_SoftUpdateException(env),
errStr,
-1);
JRI_Throw(env, (struct java_lang_Throwable *)e);
return;
}
err = SOB_pass_archive( ZIG_F_GUESS,
jarFile,
NULL, /* realStream->fURL->address, */
jarData);
if ( err != 0 )
{
errStr = netscape_softupdate_Strings_error_0005fVerificationFailed(env,
class_netscape_softupdate_Strings(env));
e = netscape_softupdate_SoftUpdateException_new( env,
class_netscape_softupdate_SoftUpdateException(env),
errStr,
err);
JRI_Throw(env, (struct java_lang_Throwable *)e);
return;
}
/* Get the installer file name */
{
char * installerJarName = NULL;
unsigned long fileNameLength;
err = SOB_get_metainfo( jarData, NULL, INSTALLER_HEADER, (void**)&installerJarName, &fileNameLength);
if (err != 0)
{
errStr = netscape_softupdate_Strings_error_0005fMissingInstaller(env,
class_netscape_softupdate_Strings(env));
e = netscape_softupdate_SoftUpdateException_new( env,
class_netscape_softupdate_SoftUpdateException(env),
errStr,
err);
JRI_Throw(env, (struct java_lang_Throwable *)e);
return;
}
set_netscape_softupdate_SoftwareUpdate_installerJarName(env, self,
JRI_NewStringPlatform(env, installerJarName, fileNameLength, "", 0));
}
set_netscape_softupdate_SoftwareUpdate_zigPtr(env, self, (long)jarData);
}
/*** private native CloseJARFile ()V ***/
extern JRI_PUBLIC_API(void)
native_netscape_softupdate_SoftwareUpdate_CloseJARFile(JRIEnv* env, struct netscape_softupdate_SoftwareUpdate* self)
{
ZIG * jarData;
jarData = (ZIG*)get_netscape_softupdate_SoftwareUpdate_zigPtr(env, self);
if (jarData != NULL)
SOB_destroy( jarData);
set_netscape_softupdate_SoftwareUpdate_zigPtr(env, self, 0);
}
#define APPLESINGLE_MAGIC_HACK 1 /* Hack to automatically detect applesingle files until we get tdell to do the right thing */
/* Extracts a JAR target into the directory */
/* Always decodes AppleSingle files */
JRI_PUBLIC_API(struct java_lang_String *)
native_netscape_softupdate_SoftwareUpdate_NativeExtractJARFile(JRIEnv* env,
struct netscape_softupdate_SoftwareUpdate* self,
struct java_lang_String *jJarSource,
struct java_lang_String *finalFile)
{
char * tempName = NULL;
char * target = NULL;
struct java_lang_String * tempNameJava = NULL;
int result;
target = (char*)JRI_GetStringPlatformChars( env, finalFile, "", 0 );
if (target)
{
char *fn;
char *end;
char *URLfile = XP_PlatformFileToURL(target);
fn = URLfile+7; /* skip "file://" part */
if ((end = XP_STRRCHR(fn, '/')) != NULL )
end[1] = 0;
/* Create a temporary location */
tempName = WH_TempName( xpURL, fn );
XP_FREEIF(URLfile);
}
else
tempName = WH_TempName( xpURL, NULL );
if (tempName == NULL)
{
result = MK_OUT_OF_MEMORY;
goto done;
}
{
ZIG * jar;
char * jarPath;
/* Extract the file */
jar = (ZIG *)get_netscape_softupdate_SoftwareUpdate_zigPtr(env, self);
jarPath = (char*)JRI_GetStringPlatformChars( env, jJarSource, "", 0 );
if (jarPath == NULL) {
/* out-of-memory error already signaled */
free(tempName);
return NULL;
}
result = SOB_verified_extract( jar, jarPath, tempName);
if ( result == 0 )
{
/* If we have an applesingle file
decode it to a new file
*/
char * encodingName;
unsigned long encodingNameLength;
XP_Bool isApplesingle = FALSE;
result = SOB_get_metainfo( jar, NULL, CONTENT_ENCODING_HEADER, (void**)&encodingName, &encodingNameLength);
#ifdef APPLESINGLE_MAGIC_HACK
if (result != 0)
{
XP_File f;
uint32 magic;
f = XP_FileOpen(tempName, xpURL, XP_FILE_READ_BIN);
XP_FileRead( &magic, sizeof(magic), f);
XP_FileClose(f);
isApplesingle = (magic == 0x00051600 );
result = 0;
}
#else
isApplesingle = (( result == 0 ) &&
(XP_STRNCMP(APPLESINGLE_MIME_TYPE, encodingName, XP_STRLEN( APPLESINGLE_MIME_TYPE ) == 0)));
#endif
if ( isApplesingle )
/* We have an AppleSingle file */
/* Extract it to the new AppleFile, and get the URL back */
{
char * newTempName = NULL;
#ifdef XP_MAC
result = SU_DecodeAppleSingle(tempName, &newTempName);
if ( result == 0 )
{
XP_FileRemove( tempName, xpURL );
XP_FREE(tempName);
tempName = newTempName;
}
else
XP_FileRemove( tempName, xpURL );
#else
result = 0;
#endif
}
}
else
result = XP_GetError();
}
done:
/* Create the return Java string if everything went OK */
if (tempName && ( result == 0) )
{
tempNameJava = JRI_NewStringPlatform(env, tempName, XP_STRLEN( tempName), "", 0);
if (tempNameJava == NULL)
result = MK_OUT_OF_MEMORY;
XP_FREE(tempName);
}
if ( (result != 0) || (tempNameJava == NULL) )
{
struct netscape_softupdate_SoftUpdateException* e;
struct java_lang_String * errStr;
errStr = netscape_softupdate_Strings_error_0005fExtractFailed(env,
class_netscape_softupdate_Strings(env));
e = netscape_softupdate_SoftUpdateException_new( env,
class_netscape_softupdate_SoftUpdateException(env),
errStr,
result);
JRI_Throw(env, (struct java_lang_Throwable *)e);
return NULL;
}
return tempNameJava;
}
/* getCertificates
* native encapsulation that calls AppletClassLoader.getCertificates
* we cannot call this method from Java because it is private.
* The method cannot be made public because it is a security risk
*/
/* From java.h (keeping the old hack, until include path is setup correctly on Mac) */
PR_PUBLIC_API(jref)
LJ_GetCertificates(JRIEnv* env, void *zigPtr, char *pathname);
JRI_PUBLIC_API(jref)
native_netscape_softupdate_SoftwareUpdate_getCertificates(JRIEnv* env,
struct netscape_softupdate_SoftwareUpdate* self,
jint zigPtr,
struct java_lang_String *name)
{
char* pathname;
if (!name)
return NULL;
pathname = (char *)JRI_GetStringUTFChars(env, name);
if (!pathname)
return NULL;
#ifdef OJI // XXX hack
return NULL;
#else
return LJ_GetCertificates(env, (void *)zigPtr, pathname);
#endif
}
#ifdef XP_MAC
#include <Gestalt.h>
#endif
/*** private native NativeGestalt (Ljava/lang/String;)I ***/
JRI_PUBLIC_API(jint)
native_netscape_softupdate_SoftwareUpdate_NativeGestalt(JRIEnv* env,
struct netscape_softupdate_SoftwareUpdate* self,
struct java_lang_String *jselector)
{
#ifdef XP_MAC
OSErr err;
long response;
char * selectorStr;
OSType selector;
selectorStr = (char*)JRI_GetStringPlatformChars( env, jselector, "", 0 );
if ((selectorStr == NULL) ||
(XP_STRLEN(selectorStr) != 4))
{
err = -5550; /* gestaltUnknownErr */
goto fail;
}
XP_MEMCPY(&selector, selectorStr, 4);
err = Gestalt(selector, &response);
if (err == noErr)
return response;
goto fail; /* Drop through to failure */
#else
int32 err;
err = -1;
goto fail;
#endif
fail:
{
struct netscape_softupdate_SoftUpdateException* e;
struct java_lang_String * errStr;
/* Just a random error message, it will never be seen, error code is the only important bit */
errStr = netscape_softupdate_Strings_error_0005fExtractFailed(env,
class_netscape_softupdate_Strings(env));
e = netscape_softupdate_SoftUpdateException_new( env,
class_netscape_softupdate_SoftUpdateException(env),
errStr,
err);
JRI_Throw(env, (struct java_lang_Throwable *)e);
}
return 0;
}
/*** private native ExtractDirEntries (Ljava/lang/String;)[Ljava/lang/String; ***/
JRI_PUBLIC_API(jref)
native_netscape_softupdate_SoftwareUpdate_ExtractDirEntries(
JRIEnv* env,
struct netscape_softupdate_SoftwareUpdate* self,
struct java_lang_String * dir)
{
int size = 0;
int len = 0;
int dirlen;
ZIG *zigPtr;
char *Directory;
char *pattern = NULL;
ZIG_Context *context;
SOBITEM *item;
jref StrArray = NULL;
char *buff;
if (!dir)
goto bail;
if ( !(zigPtr = (ZIG *)get_netscape_softupdate_SoftwareUpdate_zigPtr(env, self)) )
goto bail;
if ( !(Directory = (char*)JRI_GetStringPlatformChars( env, dir, "", 0 )) )
goto bail;
dirlen = XP_STRLEN(Directory);
if ( (pattern = XP_ALLOC(dirlen + 3)) == NULL)
goto bail;
XP_STRCPY(pattern, Directory);
XP_STRCPY(pattern+dirlen, "/*");
/* it's either go through the JAR twice (first time just to get a count)
* or go through once and potentially use lots of memory saving all the
* strings. In deference to Win16 and potentially large installs we're
* going to loop through the JAR twice and take the performance hit;
* no one installs very often anyway.
*/
if ((context = SOB_find (zigPtr, pattern, ZIG_MF)) == NULL)
goto bail;
while (SOB_find_next (context, &item) >= 0)
size++;
SOB_find_end (context);
if ( (StrArray = JRI_NewObjectArray(env, size, JRI_FindClass(env, "java/lang/String"), NULL)) == 0)
goto bail;
if ((context = SOB_find (zigPtr, pattern, ZIG_MF)) == NULL)
goto bail;
size = 0;
while (SOB_find_next (context, &item) >= 0)
{
len = XP_STRLEN(item->pathname);
/* subtract length of target directory + slash */
len = len - (dirlen+1);
if (( buff = XP_ALLOC (len+1)) != NULL )
{
/* Don't copy the search directory part */
XP_STRCPY (buff, (item->pathname)+dirlen+1);
/* XXX -- use intl_makeJavaString() instead? */
JRI_SetObjectArrayElement( env, StrArray, size++,
JRI_NewStringPlatform(env, buff, len, "", 0) );
XP_FREE(buff);
}
}
SOB_find_end (context);
bail:
XP_FREEIF(pattern);
return StrArray;
}
/*** private native NativeDiskSpaceAvailable (Ljava/lang/String;)J ***/
JRI_PUBLIC_API(jlong)
native_netscape_softupdate_SoftwareUpdate_NativeDiskSpaceAvailable(
JRIEnv* env,
struct netscape_softupdate_SoftwareUpdate* self,
struct java_lang_String *path)
{
char *fileSystem;
jlong val;
fileSystem = (char*)JRI_GetStringPlatformChars( env, path, "", 0 );
if (fileSystem)
{
#ifndef XP_MAC
jlong_UI2L( val, FE_DiskSpaceAvailable(NULL, fileSystem));
#else
assert(false); /* FE_DiskSpaceAvailable() unimplemented on Mac */
jlong_UI2L( val, 0 );
#endif /* XP_MAC */
}
else
{
jlong_UI2L( val, 0 );
}
return val;
}
/*** private native NativeMakeDirectory (Ljava/lang/String;)I ***/
JRI_PUBLIC_API(jint)
native_netscape_softupdate_SoftwareUpdate_NativeMakeDirectory(
JRIEnv* env,
struct netscape_softupdate_SoftwareUpdate* self,
struct java_lang_String *path)
{
char *dir;
if ( !(dir = (char*)JRI_GetStringPlatformChars( env, path, "", 0 )) )
return -1;
return XP_MakeDirectoryR ( dir, xpURL );
}
/* Returns native path, given a fileURL */
JRI_PUBLIC_API(struct java_lang_String *)
native_netscape_softupdate_SoftwareUpdate_NativeFileURLToNative(JRIEnv* env,
struct netscape_softupdate_SoftwareUpdate* self,
struct java_lang_String *path)
{
char * pathNamePlatform;
char * newName;
struct java_lang_String * pathNameJava = NULL;
pathNamePlatform = (char*)JRI_GetStringPlatformChars( env, path, "", 0);
if (pathNamePlatform != NULL)
{
newName = WH_FileName(pathNamePlatform, xpURL);
/* Create the return Java string if everything went OK */
if (newName)
{
pathNameJava = JRI_NewStringPlatform(env, newName, XP_STRLEN( newName), "", 0);
XP_FREE(newName);
}
}
return pathNameJava;
}
JRI_PUBLIC_API(jint)
native_netscape_softupdate_SoftwareUpdate_NativeUninstall(
JRIEnv* env,
struct netscape_softupdate_SoftwareUpdate* self,
struct java_lang_String * regPackageName)
{
char * regPackageNamePlatform;
int err;
regPackageNamePlatform = (char*)JRI_GetStringPlatformChars( env, regPackageName, "", 0);
if (regPackageNamePlatform == NULL)
err = REGERR_PARAM;
err = SU_Uninstall(regPackageNamePlatform);
return err;
}

View File

@ -46,9 +46,6 @@ extern "C" char * FE_GetProgramDirectory(char *buffer, int length);
extern "C" int SU_NEED_TO_REBOOT;
extern "C" REGERR fe_DeleteOldFileLater(char * filename);
extern "C" REGERR fe_ReplaceOldFileLater(char *tmpfile, char *target);
XP_Bool fe_FileNeedsUpdate(char *sourceFile, char *targetFile);
#if defined(WIN32) || defined(XP_OS2)
@ -218,7 +215,7 @@ int FE_ExecuteFile( const char * filename, const char * cmdline )
return -1;
DWORD hInst = WinExec( cmdline, SW_NORMAL );
fe_DeleteOldFileLater( (char*)filename );
su_DeleteOldFileLater( (char*)filename );
if ( hInst < 32 )
return -1;
@ -303,7 +300,7 @@ int FE_ReplaceExistingFile(char *CurrentFname, XP_FileType ctype,
if ( nameFound ) {
if ( MoveFile( finalName, tmpname ) ) {
if ( MoveFile( currentName, finalName ) ) {
err = fe_DeleteOldFileLater( tmpname );
err = su_DeleteOldFileLater( tmpname );
}
else {
/* 2nd move failed, put old file back */
@ -312,7 +309,7 @@ int FE_ReplaceExistingFile(char *CurrentFname, XP_FileType ctype,
}
else {
/* non-executable in use; schedule for later */
err = fe_ReplaceOldFileLater( CurrentFname, FinalFname );
err = su_ReplaceOldFileLater( CurrentFname, FinalFname );
}
}
}
@ -457,42 +454,6 @@ XP_Bool fe_FileNeedsUpdate(char *sourceFile, char *targetFile)
}
REGERR fe_DeleteOldFileLater(char * filename)
{
RKEY newkey;
REGERR result = -1;
HREG reg;
if ( REGERR_OK == NR_RegOpen("", &reg) ) {
if (REGERR_OK == NR_RegAddKey( reg, ROOTKEY_PRIVATE,
REG_DELETE_LIST_KEY, &newkey) )
{
result = NR_RegSetEntryString( reg, newkey, filename, "" );
}
NR_RegClose(reg);
}
return result;
}
REGERR fe_ReplaceOldFileLater(char *tmpfile, char *target )
{
RKEY newkey;
REGERR err;
HREG reg;
err = NR_RegOpen("", &reg);
if ( err == REGERR_OK ) {
err = NR_RegAddKey( reg, ROOTKEY_PRIVATE, REG_REPLACE_LIST_KEY, &newkey);
if ( err == REGERR_OK ) {
err = NR_RegSetEntryString( reg, newkey, tmpfile, target );
}
NR_RegClose(reg);
}
return err;
}

View File

@ -15,400 +15,6 @@
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
* Reserved.
*/
#ifdef XP_PC
#include <windows.h>
#define IMPLEMENT_netscape_softupdate_WinProfile
#define IMPLEMENT_netscape_softupdate_WinReg
#define IMPLEMENT_netscape_softupdate_WinRegValue
#include "_jri/netscape_softupdate_WinProfile.c"
#include "_jri/netscape_softupdate_WinReg.c"
#include "_jri/netscape_softupdate_WinRegValue.c"
#ifdef XP_OS2
#include "registry.h" //from cmd/os2fe/nfc/include/registry.h
#define REG_SZ 0
#endif
#ifndef WIN32
#include "shellapi.h"
#endif
#define STRBUFLEN 1024
/* ------------------------------------------------------------------
* WinProfile native methods
* ------------------------------------------------------------------
/*
* TODO: We need to delete this file
*/
void SUWinSpecificInit( JRIEnv *env )
{
use_netscape_softupdate_WinProfile((JRIEnv*)env);
use_netscape_softupdate_WinReg((JRIEnv*)env);
use_netscape_softupdate_WinRegValue((JRIEnv*)env);
}
/*** public native nativeWriteString
(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)I ***/
JRI_PUBLIC_API(jint)
native_netscape_softupdate_WinProfile_nativeWriteString(
JRIEnv* env,
struct netscape_softupdate_WinProfile* self,
struct java_lang_String *section,
struct java_lang_String *key,
struct java_lang_String *value)
{
int success = 0;
char * pApp;
char * pKey;
char * pValue;
char * pFile;
struct java_lang_String *file;
file = get_netscape_softupdate_WinProfile_filename( env, self );
pFile = (char*)JRI_GetStringPlatformChars( env, file, "", 0 );
pApp = (char*)JRI_GetStringPlatformChars( env, section, "", 0 );
pKey = (char*)JRI_GetStringPlatformChars( env, key, "", 0 );
pValue = (char*)JRI_GetStringPlatformChars( env, value, "", 0 );
/* make sure conversions worked */
if ( pApp != NULL && pKey != NULL && pFile != NULL ) {
/* it's OK for pValue to be null only if original param was also NULL */
if ( pValue != NULL || value == NULL ) {
success = WritePrivateProfileString( pApp, pKey, pValue, pFile );
}
}
return success;
}
/*** public native nativeGetString
(Ljava/lang/String;Ljava/lang/String;)Ljava/lang/String; ***/
JRI_PUBLIC_API(struct java_lang_String *)
native_netscape_softupdate_WinProfile_nativeGetString(
JRIEnv* env,
struct netscape_softupdate_WinProfile* self,
struct java_lang_String *section,
struct java_lang_String *key)
{
int numChars;
char * pApp;
char * pKey;
char * pFile;
char valbuf[STRBUFLEN];
struct java_lang_String *file;
struct java_lang_String *value = NULL;
file = get_netscape_softupdate_WinProfile_filename( env, self );
pFile = (char*)JRI_GetStringPlatformChars( env, file, "", 0 );
pApp = (char*)JRI_GetStringPlatformChars( env, section, "", 0 );
pKey = (char*)JRI_GetStringPlatformChars( env, key, "", 0 );
/* make sure conversions worked */
if ( pApp != NULL && pKey != NULL && pFile != NULL ) {
numChars = GetPrivateProfileString( pApp, pKey, "",
valbuf, STRBUFLEN, pFile );
/* if the value fit in the buffer */
if ( numChars < STRBUFLEN ) {
value = JRI_NewStringPlatform( env, valbuf, numChars, "", 0 );
}
}
return value;
}
/* ------------------------------------------------------------------
* WinReg native methods
* ------------------------------------------------------------------
*/
/*** public native createKey (Ljava/lang/String;Ljava/lang/String;)I ***/
JRI_PUBLIC_API(jint)
native_netscape_softupdate_WinReg_nativeCreateKey(
JRIEnv* env,
struct netscape_softupdate_WinReg* self,
struct java_lang_String *subkey,
struct java_lang_String *classname)
{
char * pSubkey;
char * pClass;
HKEY root, newkey;
LONG result;
LONG disposition;
pSubkey = (char*)JRI_GetStringPlatformChars( env, subkey, "", 0 );
pClass = (char*)JRI_GetStringPlatformChars( env, classname, "", 0 );
#ifdef WIN32
root = (HKEY)get_netscape_softupdate_WinReg_rootkey( env, self );
result = RegCreateKeyEx( root, pSubkey, 0, pClass, REG_OPTION_NON_VOLATILE,
KEY_ALL_ACCESS, NULL, &newkey, &disposition );
#else
result = RegCreateKey( HKEY_CLASSES_ROOT, pSubkey, &newkey );
#endif
if (ERROR_SUCCESS == result ) {
RegCloseKey( newkey );
}
return result;
}
/*** public native deleteKey (Ljava/lang/String;)I ***/
JRI_PUBLIC_API(jint)
native_netscape_softupdate_WinReg_nativeDeleteKey(
JRIEnv* env,
struct netscape_softupdate_WinReg* self,
struct java_lang_String *subkey)
{
char * pSubkey;
HKEY root;
pSubkey = (char*)JRI_GetStringPlatformChars( env, subkey, "", 0 );
#ifdef WIN32
root = (HKEY)get_netscape_softupdate_WinReg_rootkey( env, self );
#else
root = HKEY_CLASSES_ROOT;
#endif
return RegDeleteKey( root, pSubkey );
}
/*** public native deleteValue (Ljava/lang/String;Ljava/lang/String;)I ***/
JRI_PUBLIC_API(jint)
native_netscape_softupdate_WinReg_nativeDeleteValue(
JRIEnv* env,
struct netscape_softupdate_WinReg* self,
struct java_lang_String *subkey,
struct java_lang_String *valname)
{
#if defined (WIN32) || defined (XP_OS2)
char * pSubkey;
char * pValue;
HKEY root, newkey;
LONG result;
pSubkey = (char*)JRI_GetStringPlatformChars( env, subkey, "", 0 );
pValue = (char*)JRI_GetStringPlatformChars( env, valname, "", 0 );
root = (HKEY)get_netscape_softupdate_WinReg_rootkey( env, self );
result = RegOpenKeyEx( root, pSubkey, 0, KEY_WRITE, &newkey );
if ( ERROR_SUCCESS == result ) {
result = RegDeleteValue( newkey, pValue );
RegCloseKey( newkey );
}
return result;
#else
return ERROR_INVALID_PARAMETER;
#endif
}
/*** public native setValueString (Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)I ***/
JRI_PUBLIC_API(jint)
native_netscape_softupdate_WinReg_nativeSetValueString(
JRIEnv* env,
struct netscape_softupdate_WinReg* self,
struct java_lang_String *subkey,
struct java_lang_String *valname,
struct java_lang_String *value)
{
char * pSubkey;
char * pName;
char * pValue;
HKEY root;
HKEY newkey;
LONG result;
DWORD length;
pSubkey = (char*)JRI_GetStringPlatformChars( env, subkey, "", 0 );
pValue = (char*)JRI_GetStringPlatformChars( env, value, "", 0 );
length = (pValue == NULL) ? 0 : strlen(pValue);
#ifdef WIN32
pName = (char*)JRI_GetStringPlatformChars( env, valname, "", 0 );
root = (HKEY)get_netscape_softupdate_WinReg_rootkey( env, self );
result = RegOpenKeyEx( root, pSubkey, 0, KEY_ALL_ACCESS, &newkey );
if ( ERROR_SUCCESS == result ) {
result = RegSetValueEx( newkey, pName, 0, REG_SZ, pValue, length );
RegCloseKey( newkey );
}
#else
result = RegSetValue( HKEY_CLASSES_ROOT, pSubkey, REG_SZ, pValue, length );
#endif
return result;
}
/*** public native getValueString (Ljava/lang/String;Ljava/lang/String;)Ljava/lang/String; ***/
JRI_PUBLIC_API(struct java_lang_String *)
native_netscape_softupdate_WinReg_nativeGetValueString(
JRIEnv* env,
struct netscape_softupdate_WinReg* self,
struct java_lang_String *subkey,
struct java_lang_String *valname)
{
char * pSubkey;
char * pName;
char valbuf[STRBUFLEN];
HKEY root;
HKEY newkey;
LONG result;
DWORD type = REG_SZ;
DWORD length = STRBUFLEN;
struct java_lang_String *value = NULL;
pSubkey = (char*)JRI_GetStringPlatformChars( env, subkey, "", 0 );
#ifdef WIN32
pName = (char*)JRI_GetStringPlatformChars( env, valname, "", 0 );
root = (HKEY)get_netscape_softupdate_WinReg_rootkey( env, self );
result = RegOpenKeyEx( root, pSubkey, 0, KEY_ALL_ACCESS, &newkey );
if ( ERROR_SUCCESS == result ) {
result = RegQueryValueEx( newkey, pName, NULL, &type, valbuf, &length );
RegCloseKey( newkey );
}
#else
result = RegQueryValue( HKEY_CLASSES_ROOT, pSubkey, valbuf, &length );
#endif
if ( ERROR_SUCCESS == result && type == REG_SZ ) {
value = JRI_NewStringPlatform( env, valbuf, length, "", 0 );
}
return value;
}
/*** public native setValue (Ljava/lang/String;Ljava/lang/String;Lnetscape/softupdate/WinRegValue;)I ***/
JRI_PUBLIC_API(jint)
native_netscape_softupdate_WinReg_nativeSetValue(
JRIEnv* env,
struct netscape_softupdate_WinReg* self,
struct java_lang_String *subkey,
struct java_lang_String *valname,
struct netscape_softupdate_WinRegValue *value)
{
#if defined (WIN32) || defined (XP_OS2)
char * pSubkey;
char * pName;
char * pValue;
HKEY root;
HKEY newkey;
LONG result;
DWORD length;
DWORD type;
jref data;
pSubkey = (char*)JRI_GetStringPlatformChars( env, subkey, "", 0 );
root = (HKEY)get_netscape_softupdate_WinReg_rootkey( env, self );
result = RegOpenKeyEx( root, pSubkey, 0, KEY_ALL_ACCESS, &newkey );
if ( ERROR_SUCCESS == result ) {
pName = (char*)JRI_GetStringPlatformChars( env, valname, "", 0 );
type = get_netscape_softupdate_WinRegValue_type( env, value );
data = get_netscape_softupdate_WinRegValue_data( env, value );
length = JRI_GetByteArrayLength( env, data );
pValue = JRI_GetByteArrayElements( env, data );
result = RegSetValueEx( newkey, pName, 0, type, pValue, length );
RegCloseKey( newkey );
}
return result;
#else
return ERROR_INVALID_PARAMETER;
#endif
}
/*** public native getValue (Ljava/lang/String;Ljava/lang/String;)Lnetscape/softupdate/WinRegValue; ***/
JRI_PUBLIC_API(struct netscape_softupdate_WinRegValue *)
native_netscape_softupdate_WinReg_nativeGetValue(
JRIEnv* env,
struct netscape_softupdate_WinReg* self,
struct java_lang_String *subkey,
struct java_lang_String *valname)
{
#if defined (WIN32) || defined (XP_OS2)
char * pSubkey;
char * pName;
char valbuf[STRBUFLEN];
HKEY root;
HKEY newkey;
LONG result;
DWORD length=STRBUFLEN;
DWORD type;
jref data;
struct netscape_softupdate_WinRegValue * value = NULL;
pSubkey = (char*)JRI_GetStringPlatformChars( env, subkey, "", 0 );
root = (HKEY)get_netscape_softupdate_WinReg_rootkey( env, self );
result = RegOpenKeyEx( root, pSubkey, 0, KEY_ALL_ACCESS, &newkey );
if ( ERROR_SUCCESS == result ) {
pName = (char*)JRI_GetStringPlatformChars( env, valname, "", 0 );
result = RegQueryValueEx( newkey, pName, NULL, &type, valbuf, &length );
if ( ERROR_SUCCESS == result ) {
data = JRI_NewByteArray( env, length, valbuf );
value = netscape_softupdate_WinRegValue_new(
env,
class_netscape_softupdate_WinRegValue(env),
type,
data );
}
RegCloseKey( newkey );
}
return value;
#else
return NULL;
#endif
}
#endif /* XP_PC */

View File

@ -16,446 +16,16 @@
* Reserved.
*/
/*
* Native implementation for the netscape.softupdate.VersionRegistry,
* netscape.softupdate.Registry classes and helper classes
* We need to convert Reg*.java files.
* TODO: delete this file.
*/
#define IMPLEMENT_netscape_softupdate_VersionRegistry
#define IMPLEMENT_netscape_softupdate_VerRegEnumerator
#define IMPLEMENT_netscape_softupdate_VersionInfo
#define IMPLEMENT_netscape_softupdate_Registry
#define IMPLEMENT_netscape_softupdate_RegistryNode
#define IMPLEMENT_netscape_softupdate_RegKeyEnumerator
#define IMPLEMENT_netscape_softupdate_RegEntryEnumerator
#define IMPLEMENT_netscape_softupdate_RegistryException
#ifndef XP_MAC
#include "_jri/netscape_softupdate_VersionRegistry.c"
#include "_jri/netscape_softupdate_VerRegEnumerator.c"
#include "_jri/netscape_softupdate_VersionInfo.c"
#include "_jri/netscape_softupdate_Registry.c"
#include "_jri/netscape_softupdate_RegistryNode.c"
#include "_jri/netscape_softupdate_RegKeyEnumerator.c"
#include "_jri/netscape_softupdate_RegEntryEnumerator.c"
#include "_jri/netscape_softupdate_RegistryException.c"
#else
#include "n_softupdate_VersionRegistry.c"
#include "n_softupdate_VerRegEnumerator.c"
#include "n_softupdate_VersionInfo.c"
#include "netscape_softupdate_Registry.c"
#include "n_softupdate_RegistryNode.c"
#include "n_softupdate_RegKeyEnumerator.c"
#include "n_s_RegEntryEnumerator.c"
#include "n_s_RegistryException.c"
#endif
#ifndef XP_MAC
#include "_jri/java_lang_Integer.c"
#else
/* #include "java_lang_Integer.c" */
#endif
#include "xp_mcom.h"
#include "NSReg.h"
#include "VerReg.h"
#include "prefapi.h"
void SU_Reg_Initialize(JRIEnv* env)
{
use_netscape_softupdate_VersionRegistry(env);
use_netscape_softupdate_VerRegEnumerator(env);
use_netscape_softupdate_VersionInfo(env);
use_netscape_softupdate_Registry(env);
use_netscape_softupdate_RegistryNode(env);
use_netscape_softupdate_RegKeyEnumerator(env);
use_netscape_softupdate_RegEntryEnumerator(env);
use_netscape_softupdate_RegistryException(env);
#ifndef XP_MAC
use_java_lang_Integer(env);
#endif
}
/* ------------------------------------------------------------------
* VersionRegistry native methods
* ------------------------------------------------------------------
*/
/*
* VersionRegistry::componentPath()
*/
JRI_PUBLIC_API(struct java_lang_String *)
native_netscape_softupdate_VersionRegistry_componentPath(
JRIEnv* env,
struct java_lang_Class* clazz,
struct java_lang_String* component )
{
char* szComponent;
char pathbuf[MAXREGPATHLEN];
REGERR status;
/* (return NULL if an error occurs) */
struct java_lang_String *javaPath = NULL;
/* convert component from a Java string to a C String */
szComponent = (char*)JRI_GetStringUTFChars( env, component );
/* If conversion is successful */
if ( szComponent != NULL ) {
/* get component path from the registry */
status = VR_GetPath( szComponent, MAXREGPATHLEN, pathbuf );
/* if we get a path */
if ( status == REGERR_OK ) {
/* convert native path string to a Java String */
javaPath = JRI_NewStringPlatform( env, pathbuf, XP_STRLEN(pathbuf), "", 0 );
}
}
return (javaPath);
}
/*
* VersionRegistry::getDefaultDirectory()
*/
JRI_PUBLIC_API(struct java_lang_String *)
native_netscape_softupdate_VersionRegistry_getDefaultDirectory(
JRIEnv* env,
struct java_lang_Class* clazz,
struct java_lang_String* component )
{
char* szComponent = NULL;
char pathbuf[MAXREGPATHLEN];
REGERR status;
/* (return NULL if an error occurs) */
struct java_lang_String *javaPath = NULL;
/* convert component from a Java string to a C String */
if (component)
szComponent = (char*)JRI_GetStringUTFChars( env, component );
/* If conversion is successful */
if ( szComponent != NULL ) {
/* get component path from the registry */
status = VR_GetDefaultDirectory( szComponent, MAXREGPATHLEN, pathbuf );
/* if we get a path */
if ( status == REGERR_OK ) {
/* convert native path string to a Java String */
javaPath = JRI_NewStringPlatform( env, pathbuf, XP_STRLEN(pathbuf), "", 0 );
}
}
return (javaPath);
}
/*
* VersionRegistry::setDefaultDirectory()
*/
JRI_PUBLIC_API(jint)
native_netscape_softupdate_VersionRegistry_setDefaultDirectory(
JRIEnv* env,
struct java_lang_Class* clazz,
struct java_lang_String* component,
struct java_lang_String* directory )
{
char* szComponent;
char* szDirectory;
REGERR status = REGERR_FAIL;
/* convert component from a Java string to a UTF String for registry */
szComponent = (char*)JRI_GetStringUTFChars( env, component );
/* convert directory to a string in the platform charset */
szDirectory = (char*)JRI_GetStringPlatformChars( env, directory, "", 0 );
/* If conversion is successful */
if ( szComponent != NULL && szDirectory != NULL ) {
/* get component path from the registry */
status = VR_SetDefaultDirectory( szComponent, szDirectory );
}
return (status);
}
/*
* VersionRegistry::componentVersion()
*/
JRI_PUBLIC_API(struct netscape_softupdate_VersionInfo *)
native_netscape_softupdate_VersionRegistry_componentVersion(
JRIEnv* env,
struct java_lang_Class* clazz,
struct java_lang_String* component )
{
char* szComponent;
REGERR status;
VERSION cVersion;
/* (return NULL if an error occurs) */
struct netscape_softupdate_VersionInfo * javaVersion = NULL;
/* convert component from a Java string to a C String */
szComponent = (char*)JRI_GetStringUTFChars( env, component );
/* if conversion is successful */
if ( szComponent != NULL ) {
/* get component version from the registry */
status = VR_GetVersion( szComponent, &cVersion );
/* if we got the version */
if ( status == REGERR_OK ) {
/* convert to a java VersionInfo structure */
javaVersion = netscape_softupdate_VersionInfo_new_1(
env,
class_netscape_softupdate_VersionInfo(env),
cVersion.major,
cVersion.minor,
cVersion.release,
cVersion.build,
cVersion.check);
}
}
return (javaVersion);
}
/*
* VersionRegistry::installComponent()
*/
JRI_PUBLIC_API(jint)
native_netscape_softupdate_VersionRegistry_installComponent(
JRIEnv* env,
struct java_lang_Class* clazz,
struct java_lang_String* component,
struct java_lang_String* path,
struct netscape_softupdate_VersionInfo* version )
{
char * szComponent = NULL;
char * szPath = NULL;
char * szVersion = NULL;
REGERR status = REGERR_FAIL;
struct java_lang_String *jVersion = NULL;
/* convert java component to UTF for registry name */
szComponent = (char*)JRI_GetStringUTFChars( env, component );
/* convert path to native OS charset */
szPath = (char*)JRI_GetStringPlatformChars( env, path, "", 0 );
if (version != NULL) {
jVersion = netscape_softupdate_VersionInfo_toString( env, version );
szVersion = (char*)JRI_GetStringUTFChars( env, jVersion );
}
/* if java-to-C conversion was successful */
if ( szComponent != NULL ) {
/* call registry with converted data */
/* XXX need to allow Directory installs also, change in Java */
status = VR_Install( szComponent, szPath, szVersion, 0 );
}
return (status);
}
/*
* VersionRegistry::deleteComponent()
*/
JRI_PUBLIC_API(jint)
native_netscape_softupdate_VersionRegistry_deleteComponent(
JRIEnv* env,
struct java_lang_Class* clazz,
struct java_lang_String* component )
{
char* szComponent;
REGERR status = REGERR_FAIL;
/* convert component from a Java string to a C String */
szComponent = (char*)JRI_GetStringUTFChars( env, component );
/* If conversion is successful */
if ( szComponent != NULL ) {
/* delete entry from registry */
status = VR_Remove( szComponent );
}
/* return status */
return (status);
}
/*
* VersionRegistry::validateComponent()
*/
JRI_PUBLIC_API(jint)
native_netscape_softupdate_VersionRegistry_validateComponent(
JRIEnv* env,
struct java_lang_Class* clazz,
struct java_lang_String* component )
{
char* szComponent = (char*)JRI_GetStringUTFChars( env, component );
if ( szComponent == NULL ) {
return REGERR_FAIL;
}
return ( VR_ValidateComponent( szComponent ) );
}
/*
* VersionRegistry::inRegistry()
*/
JRI_PUBLIC_API(jint)
native_netscape_softupdate_VersionRegistry_inRegistry(
JRIEnv* env,
struct java_lang_Class* clazz,
struct java_lang_String* component )
{
char* szComponent = (char*)JRI_GetStringUTFChars( env, component );
if ( szComponent == NULL ) {
return REGERR_FAIL;
}
return ( VR_InRegistry( szComponent ) );
}
/*
* VersionRegistry::close
*/
JRI_PUBLIC_API(jint)
native_netscape_softupdate_VersionRegistry_close(
JRIEnv* env,
struct java_lang_Class* clazz )
{
return ( VR_Close() );
}
/*
* VersionRegistry::setRefCount()
*/
JRI_PUBLIC_API(jint)
native_netscape_softupdate_VersionRegistry_setRefCount(
JRIEnv* env,
struct java_lang_Class* clazz,
struct java_lang_String* component,
jint refcount )
{
char* szComponent = (char*)JRI_GetStringUTFChars( env, component );
if ( szComponent == NULL ) {
return REGERR_FAIL;
}
return VR_SetRefCount( szComponent, refcount );
}
/*
* VersionRegistry::getRefCount()
*/
JRI_PUBLIC_API(struct java_lang_Integer*)
native_netscape_softupdate_VersionRegistry_getRefCount(
JRIEnv* env,
struct java_lang_Class* clazz,
struct java_lang_String* component )
{
#ifndef XP_MAC
REGERR status;
int cRefCount;
char* szComponent = (char*)JRI_GetStringUTFChars( env, component );
if ( szComponent != NULL ) {
status = VR_GetRefCount( szComponent, &cRefCount );
if ( status == REGERR_OK ) {
return java_lang_Integer_new( env,
class_java_lang_Integer(env),
cRefCount);
}
}
#endif /* XP_MAC */
return NULL;
}
/*
* VersionRegistry::uninstallCreateNode()
*/
extern JRI_PUBLIC_API(jint)
native_netscape_softupdate_VersionRegistry_uninstallCreateNode(
JRIEnv* env,
struct java_lang_Class* clazz,
struct java_lang_String *regPackageName,
struct java_lang_String *userPackageName)
{
char* szRegPackageName = (char*)JRI_GetStringUTFChars( env, regPackageName );
char* szUserPackageName = (char*)JRI_GetStringUTFChars( env, userPackageName );
if ( szRegPackageName == NULL ) {
return REGERR_FAIL;
}
if ( szUserPackageName == NULL ) {
return REGERR_FAIL;
}
return VR_UninstallCreateNode( szRegPackageName, szUserPackageName );
}
/*
* VersionRegistry::uninstallAddFileToList()
*/
extern JRI_PUBLIC_API(jint)
native_netscape_softupdate_VersionRegistry_uninstallAddFileToList(
JRIEnv* env,
struct java_lang_Class* clazz,
struct java_lang_String *regPackageName,
struct java_lang_String *vrName)
{
char* szRegPackageName = (char*)JRI_GetStringUTFChars( env, regPackageName );
char* szVrName = (char*)JRI_GetStringUTFChars( env, vrName );
if ( szRegPackageName == NULL ) {
return REGERR_FAIL;
}
if ( szVrName == NULL ) {
return REGERR_FAIL;
}
return VR_UninstallAddFileToList( szRegPackageName, szVrName );
}
/*
* VersionRegistry::uninstallFileExistsInList()
*/
extern JRI_PUBLIC_API(jint)
native_netscape_softupdate_VersionRegistry_uninstallFileExistsInList(
JRIEnv* env,
struct java_lang_Class* clazz,
struct java_lang_String *regPackageName,
struct java_lang_String *vrName)
{
char* szRegPackageName = (char*)JRI_GetStringUTFChars( env, regPackageName );
char* szVrName = (char*)JRI_GetStringUTFChars( env, vrName );
if ( szRegPackageName == NULL ) {
return REGERR_FAIL;
}
if ( szVrName == NULL ) {
return REGERR_FAIL;
}
return VR_UninstallFileExistsInList( szRegPackageName, szVrName );
}
#ifdef NEVER
/* ------------------------------------------------------------------
* VerRegEnumerator native methods
@ -527,6 +97,7 @@ native_netscape_softupdate_Registry_nOpen(
/* Registry must not be already open */
if ( hReg == NULL ) {
/* this is incorrect, want OS chars, not UTF-8! */
pFilename = (char*)JRI_GetStringPlatformChars( env, filename, "", 0 );
if ( pFilename != NULL ) {
@ -866,7 +437,7 @@ native_netscape_softupdate_RegistryNode_nGetEntry(
if ( REGERR_OK == status )
{
size = info.entryLength;
pValue = XP_ALLOC(size);
pValue = malloc(size);
if ( pValue != NULL )
{
status = NR_RegGetEntry( hReg, key, pName, pValue, &size );
@ -1017,3 +588,4 @@ native_netscape_softupdate_RegEntryEnumerator_regNext(
return (javaName);
}
#endif /* NEVER */