final merge from nova 4.5 to 5.0.

This commit is contained in:
dougt%netscape.com 1998-10-20 20:55:30 +00:00
parent 63fe866d67
commit b8eecf760c
31 changed files with 1336 additions and 382 deletions

View File

@ -82,6 +82,8 @@
#define GDIFF_ERR_OLDFILE -8
#define GDIFF_ERR_CHKSUMTYPE -9
#define GDIFF_ERR_CHECKSUM -10
#define GDIFF_ERR_CHECKSUM_TARGET -11
#define GDIFF_ERR_CHECKSUM_RESULT -12
/*--------------------------------------

View File

@ -34,13 +34,12 @@ public:
*/
nsFolderSpec(char* inFolderID , char* inVRPath, char* inPackageName);
~nsFolderSpec();
/*
/*
* GetDirectoryPath
* returns full path to the directory in the standard URL form
*/
char* GetDirectoryPath(char* *errorMsg);
char* GetDirectoryPath(void);
/**
* Returns full path to a file. Makes sure that the full path is bellow
@ -69,6 +68,13 @@ private:
/* Private Methods */
/*
* SetDirectoryPath
* sets full path to the directory in the standard URL form
*/
char* SetDirectoryPath(char* *errorMsg);
/* PickDefaultDirectory
* asks the user for the default directory for the package
* stores the choice

View File

@ -56,6 +56,10 @@ public:
void Abort();
char* toString();
/* should these be protected? */
PRBool CanUninstall();
PRBool RegisterPackageNode();
private:
/* Private Fields */

View File

@ -55,6 +55,10 @@ public:
char* toString();
/* should these be protected? */
PRBool CanUninstall();
PRBool RegisterPackageNode();
private:
/* Private Fields */

View File

@ -72,7 +72,11 @@ public:
char* toString();
/* should these be protected? */
PRBool CanUninstall();
PRBool RegisterPackageNode();
private:
/* Private Fields */
@ -98,7 +102,6 @@ private:
int NativeComplete();
PRBool NativeDoesFileExist();
void AddToClasspath(nsString* file);
};
PR_END_EXTERN_C

View File

@ -46,6 +46,10 @@ public:
/* Override with your clean-up function */
virtual void Abort();
/* should these be protected? */
virtual PRBool CanUninstall();
virtual PRBool RegisterPackageNode();
private:
/* Private Field Accessors */

View File

@ -73,6 +73,11 @@ public:
char* toString(void);
/* should these be protected? */
PRBool CanUninstall();
PRBool RegisterPackageNode();
private:
/* Private Fields */

View File

@ -22,9 +22,6 @@
typedef enum nsSoftUpdateError {
nsSoftUpdateError_INVALID_PATH_ERR = -100,
nsSoftUpdateError_USER_CANCELLED_ERR = -101,
/* Errors -200 to -300 */
nsSoftUpdateError_BAD_PACKAGE_NAME = -200,
nsSoftUpdateError_UNEXPECTED_ERROR = -201,
@ -43,7 +40,15 @@ typedef enum nsSoftUpdateError {
nsSoftUpdateError_FILE_DOES_NOT_EXIST = -214, /* File cannot be deleted as it does not exist */
nsSoftUpdateError_FILE_READ_ONLY = -215, /* File cannot be deleted as it is read only. */
nsSoftUpdateError_FILE_IS_DIRECTORY = -216, /* File cannot be deleted as it is a directory */
nsSoftUpdateError_NETWORK_FILE_IS_IN_USE = -217, /* File on the network is in-use */
nsSoftUpdateError_APPLE_SINGLE_ERR = -218, /* error in AppleSingle unpacking */
nsSoftUpdateError_INVALID_PATH_ERR = -219, /* GetFolder() did not like the folderID */
nsSoftUpdateError_PATCH_BAD_DIFF = -220, /* error in GDIFF patch */
nsSoftUpdateError_PATCH_BAD_CHECKSUM_TARGET = -221, /* source file doesn't checksum */
nsSoftUpdateError_PATCH_BAD_CHECKSUM_RESULT = -222, /* final patched file fails checksum */
nsSoftUpdateError_UNINSTALL_FAILED = -223, /* error while uninstalling a package */
nsSoftUpdateError_GESTALT_UNKNOWN_ERR = -5550,
nsSoftUpdateError_GESTALT_INVALID_ARGUMENT = -5551,
} nsSoftUpdateError;
@ -54,7 +59,8 @@ typedef enum nsSoftUpdateError {
typedef enum nsInstallType {
nsInstallType_LIMITED_INSTALL= 0,
nsInstallType_FULL_INSTALL = 1,
nsInstallType_SILENT_INSTALL = 2
nsInstallType_NO_STATUS_DLG = 2,
nsInstallType_NO_FINALIZE_DLG = 4
} nsInstallType;
typedef enum nsVersionEnum {

View File

@ -35,7 +35,7 @@ PR_BEGIN_EXTERN_C
#define IMPERSONATOR "Impersonator"
#define INSTALL_PRIV "SoftwareInstall"
#define SILENT_PRIV "SilentInstall"
#define FOLDER_FILE_URL "File URL"
#define FOLDER_FILE_URL "file:///"
struct nsProgressDetails;
@ -143,15 +143,16 @@ public:
* Can be null, in which case package is installed
* without a version. Having a null version, this package is
* automatically updated in the future (ie. no version check is performed).
* @param securityLevel ignored (was LIMITED_INSTALL or FULL_INSTALL)
* @param flags Once was securityLevel(LIMITED_INSTALL or FULL_INSTALL). Now
* can be either NO_STATUS_DLG or NO_FINALIZE_DLG
*/
PRInt32 StartInstall(char* vrPackageName, nsVersionInfo* inVInfo, PRInt32 securityLevel, char* *errorMsg);
PRInt32 StartInstall(char* vrPackageName, nsVersionInfo* inVInfo, PRInt32 flags, char* *errorMsg);
/**
* An new form that doesn't require the security level
*/
PRInt32 StartInstall(char* vrPackageName, nsVersionInfo* inVInfo, char* *errorMsg);
PRInt32 StartInstall(char* vrPackageName, char* inVer, PRInt32 flags, char* *errorMsg);
/**
* another StartInstall() simplification -- version as char*
@ -333,6 +334,8 @@ private:
PRBool force; /* Force install? */
PRInt32 lastError; /* the most recent non-zero error */
char* filesep; /* the platform-specific file separator */
PRBool bShowProgress; /* true if we should show the inital progress dialog */
PRBool bShowFinalize; /* true if we should show the finalize progress dialog. */
char* installerJarName; /* Name of the installer file */
unsigned long installerJarNameLength; /* Length of Name of the installer file */
@ -342,11 +345,23 @@ private:
void* zigPtr; /* Stores the pointer to ZIG * */
nsPrincipal* installPrincipal; /* principal with the signature from the JAR file */
PRBool bUninstallPackage; /* Create an uninstall node in registry? */
PRBool bRegisterPackage; /* Create package node in registry? */
PRBool bUserCancelled; /* User cancels the install prg dialog -true else false */
/* Private Field Accessors */
/* Private Methods */
int SanityCheck(char**errorMsg);
PRBool BadRegName(char* regName);
/*
* Parses the StartInstall flags and set class varibles.
*/
void ParseFlags(int flags);
/*
* Reads in the installer certificate, and creates its principal
*/
@ -385,9 +400,18 @@ private:
* This routine converts a package-relative component registry name
* into a full name that can be used in calls to the version registry.
*/
char* GetQualifiedRegName(char* name);
char* GetQualifiedRegName(char* name, char** errMsg);
/**
* GetQualifiedPackageName
*
* This routine converts a package-relative component registry name
* into a full name that can be used in calls to the version registry.
*/
char* GetQualifiedPackageName( char* name );
char* CurrentUserNode();
char* NativeProfileName();
/* Private Native methods */
@ -428,6 +452,14 @@ private:
void NativeSetProgDlgRange(void* progptr, PRInt32 max);
void NativeSetProgDlgThermo(void* progptr, PRInt32 value);
PRBool UserWantsConfirm();
};

View File

@ -47,6 +47,10 @@ public:
void Abort();
char* toString();
/* should these be protected? */
PRBool CanUninstall();
PRBool RegisterPackageNode();
private:

View File

@ -56,6 +56,10 @@ public:
// no need for set-up
char* Prepare();
/* should these be protected? */
PRBool CanUninstall();
PRBool RegisterPackageNode();
private:
/* Private Fields */

View File

@ -52,6 +52,10 @@ public:
float GetInstallOrder();
/* should these be protected? */
PRBool CanUninstall();
PRBool RegisterPackageNode();
private:
/* Private Fields */

View File

@ -76,10 +76,25 @@ extern int32 SU_Uninstall(char *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"
#ifdef XP_UNIX
#define AUTOUPDATE_ENABLE_PREF "autoupdate.enabled_on_unix"
#else
#define AUTOUPDATE_ENABLE_PREF "autoupdate.enabled"
#endif
#define AUTOUPDATE_CONFIRM_PREF "autoupdate.confirm_install"
#define CHARSET_HEADER "Charset"
#define CONTENT_ENCODING_HEADER "Content-encoding"
#define INSTALLER_HEADER "Install-Script"
#define MOCHA_CONTEXT_PREFIX "autoinstall:"
#define REG_SOFTUPDT_DIR "Netscape/Communicator/SoftwareUpdate/"
#define LAST_REGPACK_TIME "LastRegPackTime"
/* error codes */
#define su_ErrInvalidArgs -1
#define su_ErrUnknownInstaller -2
#define su_ErrInternalError -3
#define su_ErrBadScript -4
#define su_JarError -5
#define su_DiskSpaceError -6
XP_END_PROTOS

View File

@ -65,9 +65,11 @@ PR_BEGIN_EXTERN_C
*/
nsFolderSpec::nsFolderSpec(char* inFolderID , char* inVRPath, char* inPackageName)
{
char *errorMsg = NULL;
urlPath = folderID = versionRegistryPath = userPackageName = NULL;
/* May be we should return an error message */
/* Since urlPath is set to NULL, this FolderSpec is essentially the error message */
if ((inFolderID == NULL) || (inVRPath == NULL) || (inPackageName == NULL)) {
return;
}
@ -75,6 +77,19 @@ nsFolderSpec::nsFolderSpec(char* inFolderID , char* inVRPath, char* inPackageNam
folderID = XP_STRDUP(inFolderID);
versionRegistryPath = XP_STRDUP(inVRPath);
userPackageName = XP_STRDUP(inPackageName);
/* Setting the urlPath to a real file patch. */
*errorMsg = NULL;
urlPath = SetDirectoryPath(&errorMsg);
if (errorMsg != NULL)
{
urlPath = NULL;
return;
}
}
nsFolderSpec::~nsFolderSpec(void)
@ -89,14 +104,24 @@ nsFolderSpec::~nsFolderSpec(void)
XP_FREE(urlPath);
}
/*
* GetDirectoryPath
* returns full path to the directory in the standard URL form
*
* Caller shouldn't free the returned value. It returns it copy.
*
* Returns urlPath
*
* Caller should not dispose of the return value
*/
char* nsFolderSpec::GetDirectoryPath(char* *errorMsg)
char* nsFolderSpec::GetDirectoryPath(void)
{
return urlPath;
}
/*
* SetDirectoryPath
* sets full path to the directory in the standard URL form
*/
char* nsFolderSpec::SetDirectoryPath(char* *errorMsg)
{
if ((folderID == NULL) || (versionRegistryPath == NULL)) {
*errorMsg = SU_GetErrorMsg3("Invalid arguments to the constructor",
@ -145,8 +170,9 @@ char* nsFolderSpec::MakeFullPath(char* relativePath, char* *errorMsg)
char *fullPath=NULL;
char *dir_path;
*errorMsg = NULL;
dir_path = GetDirectoryPath(errorMsg);
if (errorMsg != NULL) {
dir_path = GetDirectoryPath();
if (dir_path == NULL)
{
return NULL;
}
fullPath = XP_Cat(dir_path, GetNativePath(relativePath));
@ -158,15 +184,14 @@ char* nsFolderSpec::MakeFullPath(char* relativePath, char* *errorMsg)
*/
char* nsFolderSpec::toString()
{
char *errorMsg = NULL;
char* path = GetDirectoryPath(&errorMsg);
if (errorMsg != NULL) {
path = NULL;
} else {
PR_ASSERT(path != NULL);
XP_STRDUP(path);
char* path = GetDirectoryPath();
char* copyPath = NULL;
if (path != NULL)
{
copyPath = XP_STRDUP(path);
}
return path;
return copyPath;
}

View File

@ -216,7 +216,7 @@ void nsInstallDelete::processInstallDelete(char* *errorMsg)
if (err == 0) {
/* System.out.println("File exists and is not read only" + finalFile);*/
} else if (err == nsSoftUpdateError_FILE_DOES_NOT_EXIST) {
/*throw( new SoftUpdateException(Strings.error_FileDoesNotExist() + finalFile, err));*/
msg = SU_GetString1(nsSoftUpdateError_FILE_DOES_NOT_EXIST, finalFile);
} else if (err == nsSoftUpdateError_FILE_READ_ONLY) {
msg = SU_GetString1(SU_ERROR_FILE_READ_ONLY, finalFile);
} else if (err == nsSoftUpdateError_FILE_IS_DIRECTORY) {
@ -336,4 +336,22 @@ int nsInstallDelete::NativeCheckFileStatus()
return err;
}
PRBool
nsInstallDelete::CanUninstall()
{
return FALSE;
}
/* RegisterPackageNode
* InstallDelete() deletes files which no longer need to be registered,
* hence this function returns false.
*/
PRBool
nsInstallDelete::RegisterPackageNode()
{
return FALSE;
}
PR_END_EXTERN_C

View File

@ -220,4 +220,25 @@ void nsInstallExecute::NativeAbort(void)
XP_ASSERT(result == 0);
}
/* CanUninstall
* InstallExecute() installs files which cannot be uninstalled,
* since they are executed, hence this function returns false.
*/
PRBool
nsInstallExecute::CanUninstall()
{
return FALSE;
}
/* RegisterPackageNode
* InstallExecute() installs files which need to be registered,
* hence this function returns true.
*/
PRBool
nsInstallExecute::RegisterPackageNode()
{
return TRUE;
}
PR_END_EXTERN_C

View File

@ -483,6 +483,18 @@ end:
return result;
}
void nsInstallFile::AddToClasspath(nsString* file)
{
if ( file != NULL ) {
char *final_file = file->ToNewCString();
JVM_AddToClassPath(final_file);
delete final_file;
}
}
/* Finds out if the file exists
*/
PRBool nsInstallFile::NativeDoesFileExist()
@ -514,13 +526,28 @@ PRBool nsInstallFile::NativeDoesFileExist()
}
void nsInstallFile::AddToClasspath(nsString* file)
/* CanUninstall
* InstallFile() installs files which can be uninstalled,
* hence this function returns true.
*/
PRBool
nsInstallFile::CanUninstall()
{
if ( file != NULL ) {
char *final_file = file->ToNewCString();
JVM_AddToClassPath(final_file);
delete final_file;
}
return TRUE;
}
/* RegisterPackageNode
* InstallFile() installs files which need to be registered,
* hence this function returns true.
*/
PRBool
nsInstallFile::RegisterPackageNode()
{
return TRUE;
}
PR_END_EXTERN_C

View File

@ -138,9 +138,12 @@ nsInstallPatch::~nsInstallPatch()
char* nsInstallPatch::Prepare(void)
{
char* errorMsg = NULL;
char* srcname;
char* srcname = NULL;
PRBool deleteOldSrc;
nsTarget* priv = NULL;
char * targetfileURL;
XP_StatStruct statinfo;
int err = 0;
if ((softUpdate == NULL) || (jarLocation == NULL) || (targetfile == NULL)) {
return SU_GetErrorMsg3("Invalid arguments to the constructor",
@ -162,6 +165,46 @@ char* nsInstallPatch::Prepare(void)
}
}
/* Check for READONLY or DIRECTORY */
targetfileURL = XP_PlatformFileToURL(targetfile);
if (targetfileURL != NULL)
{
char * temp = XP_STRDUP(&targetfileURL[7]);
XP_FREEIF(targetfileURL);
targetfileURL = temp;
if (targetfileURL)
{
err = XP_Stat(targetfileURL, &statinfo, xpURL);
if (err != -1)
{
if ( XP_STAT_READONLY( statinfo ) )
{
errorMsg = SU_GetErrorMsg4(SU_ERROR_UNEXPECTED, nsSoftUpdateError_FILE_READ_ONLY);
}
else if (!S_ISDIR(statinfo.st_mode))
{
errorMsg = SU_GetErrorMsg4(SU_ERROR_UNEXPECTED, nsSoftUpdateError_FILE_IS_DIRECTORY);
}
}
else
{
errorMsg = SU_GetErrorMsg4(SU_ERROR_UNEXPECTED, nsSoftUpdateError_FILE_DOES_NOT_EXIST);
}
XP_FREEIF(targetfileURL);
}
}
if (errorMsg != NULL)
{
return errorMsg;
}
/* DFT */
patchURL = softUpdate->ExtractJARFile( jarLocation, targetfile, &errorMsg );
IntegerKey ikey(PL_HashString(targetfile));
@ -424,4 +467,25 @@ void nsInstallPatch::NativeDeleteFile( char* filename )
XP_FREEIF( fnameURL );
}
/* CanUninstall
* InstallPatch() installs files, which can be uninstalled,
* hence this function returns true.
*/
PRBool
nsInstallPatch::CanUninstall()
{
return TRUE;
}
/* RegisterPackageNode
* InstallPatch() installs files which need to be registered,
* hence this function returns true.
*/
PRBool
nsInstallPatch::RegisterPackageNode()
{
return TRUE;
}
PR_END_EXTERN_C

View File

@ -49,6 +49,8 @@
#include "xpgetstr.h"
#include "pw_public.h"
#include "NSReg.h"
#ifdef XP_MAC
#include "su_aplsn.h"
#endif
@ -119,13 +121,21 @@ nsSoftwareUpdate::nsSoftwareUpdate(void* env, char* inUserPackageName)
force = PR_FALSE;
jarName = NULL;
jarURL = NULL;
bUninstallPackage = PR_FALSE;
bRegisterPackage = PR_FALSE;
bShowProgress = PR_TRUE;
bShowFinalize = PR_TRUE;
bUserCancelled = PR_FALSE;
char *errorMsg;
/* Need to verify that this is a SoftUpdate JavaScript object */
errorMsg = VerifyJSObject(env);
/* XXX: FIX IT. How do we get data from env
jarName = (String) env.getMember("src");
jarCharset = (String) env.getMember("jarCharset");
jarURL = (String) env.getMember("srcURL");
silent = ((PRBool) env.getMember("silent")).booleanValue();
force = ((PRBool) env.getMember("force")).booleanValue();
@ -142,12 +152,12 @@ nsSoftwareUpdate::nsSoftwareUpdate(void* env, char* inUserPackageName)
nsSoftwareUpdate::~nsSoftwareUpdate()
{
if (patchList)
delete patchList;
if (packageFolder)
delete packageFolder;
if (versionInfo)
delete versionInfo;
if(patchList)
delete patchList;
if(packageFolder)
delete packageFolder;
if(versionInfo)
delete versionInfo;
CleanUp();
}
@ -216,9 +226,12 @@ nsFolderSpec* nsSoftwareUpdate::GetFolder(char* folderID, char* *errorMsg)
spec = new nsFolderSpec(folderID, packageName, userPackageName);
if (XP_STRCMP(folderID, "User Pick") == 0) {
// Force the prompt
char * ignore = spec->GetDirectoryPath(errorMsg);
if (*errorMsg != NULL) {
delete spec;
char * ignore = spec->GetDirectoryPath();
if (ignore == NULL)
{
if(spec)
delete spec;
return NULL;
}
}
@ -234,28 +247,48 @@ nsFolderSpec* nsSoftwareUpdate::GetFolder(char* folderID, char* *errorMsg)
nsFolderSpec* nsSoftwareUpdate::GetComponentFolder(char* component)
{
char* dir;
char* qualifiedComponent;
nsFolderSpec* spec = NULL;
dir = nsVersionRegistry::getDefaultDirectory( component );
qualifiedComponent = GetQualifiedPackageName( component );
if (qualifiedComponent == NULL)
{
return NULL;
}
dir = nsVersionRegistry::getDefaultDirectory( qualifiedComponent );
if ( dir == NULL ) {
dir = nsVersionRegistry::componentPath( component );
dir = nsVersionRegistry::componentPath( qualifiedComponent );
if ( dir != NULL ) {
int i;
nsString dirStr(dir);
if ((i = dirStr.RFind(filesep)) > 0) {
XP_FREE(dir);
XP_FREEIF(dir);
dir = (char*)XP_ALLOC(i);
dir = dirStr.ToCString(dir, i);
}
}
}
if ( dir != NULL ) {
if ( dir != NULL )
{
/* We have a directory */
spec = new nsFolderSpec("Installed", dir, userPackageName);
XP_FREE(dir);
if (su_PathEndsWithSeparator(dir, filesep))
{
spec = new nsFolderSpec("Installed", dir, userPackageName);
}
else
{
dir = XP_AppendStr(dir, filesep);
spec = new nsFolderSpec("Installed", dir, userPackageName);
}
XP_FREEIF(dir);
}
return spec;
}
@ -266,7 +299,10 @@ nsFolderSpec* nsSoftwareUpdate::GetComponentFolder(char* component,
{
nsFolderSpec* spec = GetComponentFolder( component );
nsFolderSpec* ret_val = GetFolder( spec, subdir, errorMsg );
if (spec) delete spec;
if(spec);
delete spec;
return ret_val;
}
@ -291,13 +327,13 @@ void* nsSoftwareUpdate::GetWinProfile(nsFolderSpec* folder,
nsWinProfile* profile = NULL;
*errorMsg = NULL;
if ( packageName == NULL ) {
*errorMsg = SU_GetErrorMsg4(SU_ERROR_WIN_PROFILE_MUST_CALL_START,
nsSoftUpdateError_INSTALL_NOT_STARTED );
return NULL;
SanityCheck(errorMsg);
if (*errorMsg == NULL)
{
profile = new nsWinProfile(this, folder, file);
}
profile = new nsWinProfile(this, folder, file);
return profile;
#else
return NULL;
@ -313,12 +349,13 @@ void* nsSoftwareUpdate::GetWinRegistry(char* *errorMsg)
#ifdef XP_PC
nsWinReg* registry = NULL;
if ( packageName == NULL ) {
*errorMsg = SU_GetErrorMsg4(SU_ERROR_WIN_PROFILE_MUST_CALL_START,
nsSoftUpdateError_INSTALL_NOT_STARTED );
return NULL;
SanityCheck(errorMsg);
if (*errorMsg == NULL)
{
registry = new nsWinReg(this);
}
registry = new nsWinReg(this);
return registry;
#else
return NULL;
@ -411,66 +448,88 @@ char* nsSoftwareUpdate::ExtractJARFile(char* inJarLocation,
return outExtractLocation;
}
void
nsSoftwareUpdate::ParseFlags(int flags)
{
if ((flags & nsInstallType_NO_STATUS_DLG) == nsInstallType_NO_STATUS_DLG)
{
bShowProgress = PR_FALSE;
}
if ((flags & nsInstallType_NO_FINALIZE_DLG) == nsInstallType_NO_FINALIZE_DLG)
{
bShowFinalize = PR_FALSE;
}
}
/**
* Call this to initialize the update
* Opens the jar file and gets the certificate of the installer
* Opens up the gui, and asks for proper security privileges
*
* @param vrPackageName Full qualified version registry name of the package
* (ex: "/Plugins/Adobe/Acrobat")
* NULL or empty package names are errors
*
* @param inVInfo version of the package installed.
* Can be NULL, in which case package is installed
* without a version. Having a NULL version, this
* package is automatically updated in the future
* (ie. no version check is performed).
* @param securityLevel ignored (was LIMITED_INSTALL or FULL_INSTALL)
*/
PRInt32 nsSoftwareUpdate::StartInstall(char* vrPackageName,
nsVersionInfo* inVInfo,
PRInt32 securityLevel, char* *errorMsg)
{
// ignore securityLevel
return StartInstall( vrPackageName, inVInfo, errorMsg );
}
/**
* An new form that doesn't require the security level
*
* @param flags Once was securityLevel(LIMITED_INSTALL or FULL_INSTALL). Now
* can be either NO_STATUS_DLG or NO_FINALIZE_DLG
*/
PRInt32 nsSoftwareUpdate::StartInstall(char* vrPackageName,
nsVersionInfo* inVInfo,
PRInt32 flags,
char* *errorMsg)
{
int errcode= nsSoftwareUpdate_SUCCESS;
*errorMsg = NULL;
ResetError();
ParseFlags(flags);
bUserCancelled = PR_FALSE;
packageName = NULL;
if ( (vrPackageName == NULL) ) {
if ( vrPackageName == NULL )
{
*errorMsg = SU_GetErrorMsg4(SU_ERROR_BAD_PACKAGE_NAME,
nsSoftUpdateError_INVALID_ARGUMENTS );
return nsSoftUpdateError_INVALID_ARGUMENTS;
}
packageName = GetQualifiedPackageName( vrPackageName );
int len = XP_STRLEN(vrPackageName);
int len = XP_STRLEN(packageName);
int last_pos = len-1;
char* tmpPackageName = new char[len+1];
XP_STRCPY(tmpPackageName, vrPackageName);
while ((last_pos >= 0) && (tmpPackageName[last_pos] == '/')) {
XP_STRCPY(tmpPackageName, packageName);
while ((last_pos >= 0) && (tmpPackageName[last_pos] == '/'))
{
// Make sure that package name does not end with '/'
char* ptr = new char[last_pos+1];
memcpy(tmpPackageName, ptr, last_pos);
ptr[last_pos] = '\0';
delete tmpPackageName;
if(tmpPackageName);
delete tmpPackageName;
tmpPackageName = ptr;
last_pos = last_pos - 1;
}
packageName = XP_STRDUP(tmpPackageName);
delete tmpPackageName;
if(tmpPackageName);
delete tmpPackageName;
if (versionInfo) {
/* delete the old nsVersionInfo object. */
delete versionInfo;
}
/* delete the old nsVersionInfo object. */
if(versionInfo);
delete versionInfo;
versionInfo = inVInfo;
installedFiles = new nsVector();
@ -487,29 +546,47 @@ PRInt32 nsSoftwareUpdate::StartInstall(char* vrPackageName,
if (*errorMsg != NULL)
return errcode;
OpenProgressDialog();
if (bShowProgress)
{
OpenProgressDialog();
}
// set up default package folder, if any
char* path = nsVersionRegistry::getDefaultDirectory( packageName );
if ( path != NULL ) {
packageFolder = new nsFolderSpec("Installed", path, userPackageName);
XP_FREE(path);
XP_FREEIF(path);
}
saveError( errcode );
if (errcode != 0)
{
packageName = NULL; // Reset!
}
return errcode;
}
/*
* another forms of StartInstall()
*/
PRInt32 nsSoftwareUpdate::StartInstall(char* vrPackageName,
char* inVer,
PRInt32 flags,
char* *errorMsg)
{
return StartInstall(vrPackageName, new nsVersionInfo( inVer ), flags, errorMsg);
}
/**
* another StartInstall() simplification -- version as char*
*/
PRInt32 nsSoftwareUpdate::StartInstall(char* vrPackageName, char* inVer,
char* *errorMsg)
{
/* StartInstall saves the nsVersionInfo and it deletes the object when
* nsSoftwareUpdate is deleted.
*/
return StartInstall( vrPackageName, new nsVersionInfo( inVer ), errorMsg );
return StartInstall( vrPackageName, new nsVersionInfo( inVer ), 0, errorMsg );
}
/*
@ -518,7 +595,6 @@ PRInt32 nsSoftwareUpdate::StartInstall(char* vrPackageName, char* inVer,
void nsSoftwareUpdate::UserCancelled()
{
userChoice = 0;
AbortInstall();
}
void nsSoftwareUpdate::UserApproved()
@ -535,14 +611,15 @@ PRInt32 nsSoftwareUpdate::FinalizeInstall(char* *errorMsg)
{
PRBool rebootNeeded = PR_FALSE;
int result = nsSoftwareUpdate_SUCCESS;
*errorMsg = NULL;
SetProgressDialogItem(""); // blank the "current item" line
if (packageName == NULL) {
// probably didn't call StartInstall()
*errorMsg = SU_GetErrorMsg4(SU_ERROR_WIN_PROFILE_MUST_CALL_START,
nsSoftUpdateError_INSTALL_NOT_STARTED);
return nsSoftUpdateError_INVALID_ARGUMENTS;
result = SanityCheck(errorMsg);
if (*errorMsg != NULL)
{
saveError( result );
return result;
}
if ( installedFiles == NULL || installedFiles->GetSize() == 0 ) {
@ -570,17 +647,22 @@ PRInt32 nsSoftwareUpdate::FinalizeInstall(char* *errorMsg)
return saveError(nsSoftUpdateError_USER_CANCELLED);
}
}
SetProgressDialogRange( installedFiles->GetSize() );
// Register default package folder if set
if ( packageFolder != NULL ) {
char* packageFolderStr = packageFolder->toString();
nsVersionRegistry::setDefaultDirectory( packageName,
packageFolderStr );
XP_FREEIF(packageFolderStr);
// If the user passed NO_FINALIZE_DLG, we should close the progress dialog here.
// If the user passed !NO_FINALIZE_DLG, we should open the progress dialog here.
if ( bShowFinalize )
{
OpenProgressDialog();
}
else
{
CloseProgressDialog();
}
SetProgressDialogItem(""); // blank the "current item" line
SetProgressDialogRange( installedFiles->GetSize() );
/* call Complete() on all the elements */
/* If an error occurs in the middle, call Abort() on the rest */
@ -589,7 +671,12 @@ PRInt32 nsSoftwareUpdate::FinalizeInstall(char* *errorMsg)
// Main loop
int count = 0;
nsVersionRegistry::uninstallCreate(packageName, userPackageName);
if ( bUninstallPackage )
{
nsVersionRegistry::uninstallCreate(packageName, userPackageName);
}
PRUint32 i=0;
for (i=0; i < ve->GetSize(); i++) {
ie = (nsInstallObject*)ve->Get(i);
@ -603,9 +690,17 @@ PRInt32 nsSoftwareUpdate::FinalizeInstall(char* *errorMsg)
SetProgressDialogThermo(++count);
}
// add overall version for package
if ( versionInfo != NULL) {
if ( (versionInfo != NULL) && (bRegisterPackage))
{
result = nsVersionRegistry::installComponent(packageName, NULL,
versionInfo);
// Register default package folder if set
if ( packageFolder != NULL )
{
nsVersionRegistry::setDefaultDirectory( packageName, packageFolder->toString() );
}
}
CleanUp();
@ -663,6 +758,17 @@ char* nsSoftwareUpdate::ScheduleForInstall(nsInstallObject* ob)
installedFiles->Add( ob );
// if (confdlg != NULL)
// confdlg.ScheduleForInstall( ob );
// turn on flags for creating the uninstall node and
// the package node for each InstallObject
if (ob->CanUninstall())
bUninstallPackage = PR_TRUE;
if (ob->RegisterPackageNode())
bRegisterPackage = PR_TRUE;
return NULL;
}
@ -713,19 +819,27 @@ PRInt32 nsSoftwareUpdate::AddSubcomponent(char* name,
nsSoftUpdateError_INVALID_ARGUMENTS );
return nsSoftUpdateError_INVALID_ARGUMENTS;
}
if (packageName == NULL) {
// probably didn't call StartInstall()
*errorMsg = SU_GetErrorMsg4(SU_ERROR_BAD_PACKAGE_NAME_AS,
nsSoftUpdateError_BAD_PACKAGE_NAME );
return nsSoftUpdateError_BAD_PACKAGE_NAME;
}
result = SanityCheck(errorMsg);
if (*errorMsg == NULL)
{
saveError( result );
return result;
}
if ((name == NULL) || (XP_STRLEN(name) == 0)) {
// Default subName = location in jar file
new_name = GetQualifiedRegName( jarSource );
new_name = GetQualifiedRegName( jarSource, errorMsg );
} else {
new_name = GetQualifiedRegName( name );
new_name = GetQualifiedRegName( name, errorMsg );
}
if (*errorMsg != NULL)
{
return nsSoftUpdateError_BAD_PACKAGE_NAME;
}
if ( (relativePath == NULL) || (XP_STRLEN(relativePath) == 0) ) {
@ -737,12 +851,19 @@ PRInt32 nsSoftwareUpdate::AddSubcomponent(char* name,
PRBool versionNewer = PR_FALSE;
if ( (forceInstall == PR_FALSE ) &&
(version != NULL) &&
( nsVersionRegistry::validateComponent( new_name ) == 0 ) ) {
( nsVersionRegistry::validateComponent( new_name ) == 0 ) )
{
nsVersionInfo* oldVersion = nsVersionRegistry::componentVersion(new_name);
if ( version->compareTo( oldVersion ) != nsVersionEnum_EQUAL )
if ( version->compareTo( oldVersion ) != nsVersionEnum_EQUAL )
versionNewer = PR_TRUE;
delete oldVersion;
} else {
if( oldVersion )
delete oldVersion;
}
else
{
versionNewer = PR_TRUE;
}
@ -758,7 +879,7 @@ PRInt32 nsSoftwareUpdate::AddSubcomponent(char* name,
result = nsSoftUpdateError_UNEXPECTED_ERROR;
}
delete new_name;
XP_FREEIF (new_name);
saveError( result );
return result;
}
@ -772,6 +893,15 @@ PRInt32 nsSoftwareUpdate::Execute(char* jarSource, char* *errorMsg, char* args)
{
int errcode = nsSoftwareUpdate_SUCCESS;
errcode = SanityCheck(errorMsg);
if (*errorMsg != NULL)
{
saveError( errcode );
return errcode;
}
nsInstallExecute* ie = new nsInstallExecute(this, jarSource, errorMsg, args);
if (*errorMsg != NULL) {
errcode = nsSoftUpdateError_ACCESS_DENIED;
@ -851,7 +981,21 @@ PRInt32 nsSoftwareUpdate::Patch(char* regName,
return saveError( nsSoftUpdateError_INVALID_ARGUMENTS );
}
char* rname = GetQualifiedRegName( regName );
errcode = SanityCheck(errorMsg);
if (*errorMsg != NULL)
{
saveError( errcode );
return errcode;
}
char* rname = GetQualifiedRegName( regName, errorMsg);
if (*errorMsg != NULL)
{
errcode = nsSoftUpdateError_BAD_PACKAGE_NAME;
saveError( errcode );
return errcode;
}
nsInstallPatch* ip = new nsInstallPatch(this, rname, version, patchname,
errorMsg);
@ -863,7 +1007,7 @@ PRInt32 nsSoftwareUpdate::Patch(char* regName,
errcode = nsSoftUpdateError_UNEXPECTED_ERROR;
}
}
delete rname;
XP_FREEIF( rname );
saveError( errcode );
return errcode;
}
@ -890,8 +1034,23 @@ PRInt32 nsSoftwareUpdate::Patch(char* regName,
int errcode = nsSoftwareUpdate_SUCCESS;
char* rname = GetQualifiedRegName( regName );
errcode = SanityCheck(errorMsg);
if (*errorMsg != NULL)
{
saveError( errcode );
return errcode;
}
char* rname = GetQualifiedRegName( regName, errorMsg );
if (*errorMsg != NULL)
{
errcode = nsSoftUpdateError_BAD_PACKAGE_NAME;
saveError( errcode );
return errcode;
}
nsInstallPatch* ip = new nsInstallPatch( this, rname, version,
patchname, folder, filename,
errorMsg );
@ -903,7 +1062,7 @@ PRInt32 nsSoftwareUpdate::Patch(char* regName,
errcode = nsSoftUpdateError_UNEXPECTED_ERROR;
}
}
delete rname;
XP_FREEIF ( rname );
saveError( errcode );
return errcode;
}
@ -920,6 +1079,14 @@ PRInt32 nsSoftwareUpdate::DeleteFile(nsFolderSpec* folder,
{
int errcode = nsSoftwareUpdate_SUCCESS;
errcode = SanityCheck(errorMsg);
if (*errorMsg != NULL)
{
saveError( errcode );
return errcode;
}
nsInstallDelete* id = new nsInstallDelete(this, folder, relativeFileName,
errorMsg);
if (*errorMsg != NULL) {
@ -950,7 +1117,23 @@ PRInt32 nsSoftwareUpdate::DeleteComponent(char* registryName, char* *errorMsg)
{
int errcode = nsSoftwareUpdate_SUCCESS;
nsInstallDelete* id = new nsInstallDelete(this, NULL, registryName, errorMsg);
errcode = SanityCheck(errorMsg);
if (*errorMsg != NULL)
{
saveError( errcode );
return errcode;
}
char* rname = GetQualifiedRegName( registryName, errorMsg );
if (*errorMsg != NULL)
{
errcode = nsSoftUpdateError_UNEXPECTED_ERROR;
saveError( errcode );
return errcode;
}
nsInstallDelete* id = new nsInstallDelete(this, NULL, rname, errorMsg);
if (*errorMsg != NULL) {
errcode = nsSoftUpdateError_ACCESS_DENIED;
} else {
@ -963,6 +1146,8 @@ PRInt32 nsSoftwareUpdate::DeleteComponent(char* registryName, char* *errorMsg)
if (errcode == nsSoftUpdateError_FILE_DOES_NOT_EXIST) {
errcode = nsSoftwareUpdate_SUCCESS;
}
XP_FREEIF (rname );
saveError( errcode );
return errcode;
}
@ -998,7 +1183,7 @@ nsFolderSpec* nsSoftwareUpdate::GetFolder(char* targetFolder,
path = XP_AppendStr(path, filesep);
spec = new nsFolderSpec("Installed", path, userPackageName);
}
XP_FREE(path);
XP_FREEIF(path);
return spec;
} else {
return NULL;
@ -1006,7 +1191,8 @@ nsFolderSpec* nsSoftwareUpdate::GetFolder(char* targetFolder,
} else {
nsFolderSpec* spec = GetFolder(targetFolder, errorMsg);
nsFolderSpec* ret_val = GetFolder( spec, subdirectory, errorMsg );
if (spec) {
if (spec)
{
delete spec;
}
return ret_val;
@ -1021,10 +1207,13 @@ nsFolderSpec* nsSoftwareUpdate::GetFolder(nsFolderSpec* folder,
char* path = NULL;
char* newPath = NULL;
if ( subdir == NULL || (XP_STRLEN(subdir) == 0 )) {
if ( subdir == NULL || (XP_STRLEN(subdir) == 0 ))
{
// no subdir, return what we were passed
spec = folder;
} else if ( folder != NULL ) {
return folder;
}
else if ( folder != NULL )
{
path = folder->MakeFullPath( subdir, errorMsg );
if (path != NULL) {
if (su_PathEndsWithSeparator(path, filesep)) {
@ -1033,7 +1222,7 @@ nsFolderSpec* nsSoftwareUpdate::GetFolder(nsFolderSpec* folder,
path = XP_AppendStr(path, filesep);
spec = new nsFolderSpec("Installed", path, userPackageName);
}
XP_FREE(path);
XP_FREEIF(path);
}
}
return spec;
@ -1046,8 +1235,8 @@ nsFolderSpec* nsSoftwareUpdate::GetFolder(nsFolderSpec* folder,
long nsSoftwareUpdate::DiskSpaceAvailable(nsFolderSpec* folder)
{
char *errorMsg = NULL;
char* path = folder->GetDirectoryPath(&errorMsg);
if ((path == NULL) || (errorMsg == NULL))
char* path = folder->GetDirectoryPath();
if (path == NULL)
return 0;
return NativeDiskSpaceAvailable(path);
@ -1090,10 +1279,16 @@ PRInt32 nsSoftwareUpdate::AddDirectory(char* name,
if ((name == NULL) || (XP_STRLEN(name) == 0)) {
// Default subName = location in jar file
qualified_name = GetQualifiedRegName( jarSource );
qualified_name = GetQualifiedRegName( jarSource, errorMsg );
} else {
qualified_name = GetQualifiedRegName( name );
qualified_name = GetQualifiedRegName( name, errorMsg );
}
if (*errorMsg != NULL)
{
return nsSoftUpdateError_BAD_PACKAGE_NAME;
}
if ( subdir == NULL ) {
subdir = NULL;
@ -1123,7 +1318,10 @@ PRInt32 nsSoftwareUpdate::AddDirectory(char* name,
// Only install if newer
nsVersionInfo* oldVer = nsVersionRegistry::componentVersion(fullRegName);
bInstall = ( version->compareTo(oldVer) > 0 );
delete oldVer;
if (oldVer)
delete oldVer;
} else {
// file doesn't exist or "forced" install
bInstall = PR_TRUE;
@ -1151,7 +1349,8 @@ PRInt32 nsSoftwareUpdate::AddDirectory(char* name,
/* We have an error and we haven't scheduled,
* thus we can delete it
*/
delete ie;
if (ie)
delete ie;
}
XP_FREEIF(newJarSource);
XP_FREEIF(newSubDir);
@ -1173,13 +1372,25 @@ PRInt32 nsSoftwareUpdate::Uninstall(char* packageName, char* *errorMsg)
{
int errcode = nsSoftwareUpdate_SUCCESS;
nsUninstallObject* u = new nsUninstallObject( this, packageName, errorMsg );
errcode = SanityCheck(errorMsg);
if (*errorMsg != NULL)
{
saveError( errcode );
return errcode;
}
char* rname = GetQualifiedPackageName( packageName );
nsUninstallObject* u = new nsUninstallObject( this, rname, errorMsg );
if (*errorMsg != NULL) {
errcode = nsSoftUpdateError_UNEXPECTED_ERROR;
} else {
ScheduleForInstall( u );
}
XP_FREEIF (rname);
saveError( errcode );
return errcode;
}
@ -1196,7 +1407,7 @@ PRInt32 nsSoftwareUpdate::Uninstall(char* packageName, char* *errorMsg)
*******************************/
void nsSoftwareUpdate::OpenProgressDialog(void)
{
if ( !silent ) {
if ( !silent && progwin == 0) {
progwin = NativeOpenProgDlg( GetUserPackageName() );
}
}
@ -1370,10 +1581,10 @@ void nsSoftwareUpdate::CleanUp()
PRUint32 i=0;
for (; i < installedFiles->GetSize(); i++) {
ie = (nsInstallObject*)installedFiles->Get(i);
delete ie;
XP_FREEIF (ie);
}
installedFiles->RemoveAll();
delete installedFiles;
XP_FREEIF (installedFiles);
installedFiles = NULL;
}
XP_FREEIF(packageName);
@ -1390,26 +1601,43 @@ void nsSoftwareUpdate::CleanUp()
* This routine converts a package-relative component registry name
* into a full name that can be used in calls to the version registry.
*/
char* nsSoftwareUpdate::GetQualifiedRegName(char* name)
char* nsSoftwareUpdate::GetQualifiedRegName(char* name, char**errorMsg)
{
char *comm = "=COMM=/";
PRUint32 comm_len = XP_STRLEN(comm);
PRBool starts_with_comm = PR_FALSE;
if ((XP_STRLEN(name)) >= comm_len) {
char *usr = "=USER=/";
PRUint32 usr_len = XP_STRLEN(usr);
if ((XP_STRLEN(name)) >= comm_len)
{
PRUint32 i;
for (i=0; i<comm_len; i++) {
for (i=0; i<comm_len; i++)
{
if (XP_TO_UPPER(name[i]) != comm[i])
break;
}
if (i == comm_len) {
starts_with_comm = PR_TRUE;
if (i == comm_len)
{
name = XP_STRDUP(&name[comm_len]);
}
}
if (starts_with_comm) {
name = XP_STRDUP(&name[comm_len]);
} else if (name[0] != '/') {
else if ((XP_STRLEN(name)) >= usr_len)
{
PRUint32 i;
for (i=0; i<usr_len; i++)
{
if (XP_TO_UPPER(name[i]) != usr[i])
break;
}
if (i == usr_len)
{
name = XP_STRDUP(&name[usr_len]);
}
}
else if (name[0] != '/')
{
// Relative package path
char* packagePrefix;
if (XP_STRLEN(packageName) != 0) {
@ -1420,6 +1648,13 @@ char* nsSoftwareUpdate::GetQualifiedRegName(char* name)
}
}
if (BadRegName(name))
{
*errorMsg = SU_GetErrorMsg4(nsSoftUpdateError_BAD_PACKAGE_NAME, nsSoftUpdateError_BAD_PACKAGE_NAME);
name = NULL;
}
return name;
}
@ -1541,10 +1776,10 @@ void nsSoftwareUpdate::freeIfCertificates(void* prins)
PRUint32 i;
for (i=0; i < noOfPrins; i++) {
nsPrincipal* prin = (nsPrincipal*)prinArray->Get(i);
delete prin;
XP_FREEIF (prin);
prinArray->Set(i, NULL);
}
delete prinArray;
XP_FREEIF (prinArray);
}
#define APPLESINGLE_MAGIC_HACK 1 /* Hack to automatically detect applesingle files until we get tdell to do the right thing */
@ -1639,7 +1874,7 @@ char* nsSoftwareUpdate::NativeExtractJARFile(char* inJarLocation,
result = SU_DecodeAppleSingle(tempName, &newTempName);
if ( result == 0 ) {
XP_FileRemove( tempName, xpURL );
XP_FREE(tempName);
XP_FREEIF(tempName);
tempName = newTempName;
} else {
XP_FileRemove( tempName, xpURL );
@ -1841,4 +2076,144 @@ PRBool nsSoftwareUpdate::UserWantsConfirm()
}
/**
* GetQualifiedPackageName
*
* This routine converts a package-relative component registry name
* into a full name that can be used in calls to the version registry.
*/
char*
nsSoftwareUpdate::GetQualifiedPackageName( char* name )
{
char* qualifedName;
if (XP_STRNCMP(name, "=USER=/", XP_STRLEN( name )) == 0)
{
char* currentUserNode;
currentUserNode = CurrentUserNode();
qualifedName = XP_STRDUP(currentUserNode);
/* Append the the the path to the CurrentUserName.
name[7], should be after the =USER=/
*/
qualifedName = XP_AppendStr(qualifedName, &name[7]);
XP_FREEIF (currentUserNode);
}
if (BadRegName(qualifedName))
{
XP_FREEIF (qualifedName);
qualifedName = NULL;
}
return qualifedName;
}
char*
nsSoftwareUpdate::CurrentUserNode()
{
char *qualifedName;
char *profileName;
qualifedName = XP_STRDUP("/Netscape/Users/");
profileName = NativeProfileName();
XP_AppendStr(qualifedName, profileName);
XP_AppendStr(qualifedName, "/");
XP_FREEIF(profileName);
return qualifedName;
}
char*
nsSoftwareUpdate::NativeProfileName( )
{
char *profname;
int len = MAXREGNAMELEN;
int err;
profname = (char*) malloc(len);
err = PREF_GetCharPref( "profile.name", profname, &len );
if ( err != PREF_OK )
{
XP_FREEIF(profname);
profname = NULL;
}
return profname;
}
/**
* SanityCheck
*
* This routine checks if the packageName is null. It also checks the flag if the user cancels
* the install progress dialog is set and acccordingly aborts the install.
*/
int
nsSoftwareUpdate::SanityCheck(char**errorMsg)
{
if ( packageName == NULL )
{
*errorMsg = SU_GetErrorMsg4(nsSoftUpdateError_INSTALL_NOT_STARTED, nsSoftUpdateError_INSTALL_NOT_STARTED);
return nsSoftUpdateError_INSTALL_NOT_STARTED;
}
if (bUserCancelled)
{
AbortInstall();
saveError(nsSoftUpdateError_USER_CANCELLED);
*errorMsg = SU_GetErrorMsg4(nsSoftUpdateError_USER_CANCELLED, nsSoftUpdateError_USER_CANCELLED);
return nsSoftUpdateError_USER_CANCELLED;
}
return 0;
}
// catch obvious registry name errors proactively
// rather than returning some cryptic libreg error
PRBool
nsSoftwareUpdate::BadRegName(char* regName)
{
long regNameLen;
if (regName== NULL)
return PR_TRUE;
regNameLen = XP_STRLEN(regName);
if ((regName[0] == ' ' ) || (regName[regNameLen] == ' ' ))
return PR_TRUE;
if ( XP_STRSTR(regName, "//") != NULL )
return PR_TRUE;
if ( XP_STRSTR(regName, " /") != NULL )
return PR_TRUE;
if ( XP_STRSTR(regName, "/ ") != NULL )
return PR_TRUE;
if ( XP_STRSTR(regName, "=") != NULL )
return PR_TRUE;
return PR_FALSE;
}
PR_END_EXTERN_C

View File

@ -157,6 +157,22 @@ char* nsUninstallObject::NativeComplete(char* regname)
}
return errorMsg;
}
/* CanUninstall
* UninstallObject() uninstall files,
* hence this function returns false.
*/
protected boolean CanUninstall()
{
return false;
}
/* RegisterPackageNode
* UninstallObject() uninstalls files which no longer need to be registered,
* hence this function returns false.
*/
protected boolean RegisterPackageNode()
{
return false;
}
PR_END_EXTERN_C

View File

@ -16,6 +16,7 @@
* Reserved.
*/
#include "nsWinProfileItem.h"
#include "xp.h"
#include "xp_str.h"
@ -77,4 +78,26 @@ char* nsWinProfileItem::Prepare()
return NULL;
}
/* CanUninstall
* WinProfileItem() does not install any files which can be uninstalled,
* hence this function returns false.
*/
PRBool
nsWinProfileItem::CanUninstall()
{
return FALSE;
}
/* RegisterPackageNode
* WinProfileItem() installs files which need to be registered,
* hence this function returns true.
*/
PRBool
nsWinProfileItem::RegisterPackageNode()
{
return TRUE;
}
PR_END_EXTERN_C

View File

@ -235,4 +235,25 @@ void nsWinRegItem::reverseString(char* s)
}
}
/* CanUninstall
* WinRegItem() does not install any files which can be uninstalled,
* hence this function returns false.
*/
PRBool
nsWinRegItem:: CanUninstall()
{
return FALSE;
}
/* RegisterPackageNode
* WinRegItem() installs files which need to be registered,
* hence this function returns true.
*/
PRBool
nsWinRegItem:: RegisterPackageNode()
{
return TRUE;
}
PR_END_EXTERN_C

View File

@ -38,18 +38,9 @@
extern int MK_OUT_OF_MEMORY;
#define MOCHA_CONTEXT_PREFIX "autoinstall:"
#define REG_SOFTUPDT_DIR "Netscape/Communicator/SoftwareUpdate/"
#define LAST_REGPACK_TIME "LastRegPackTime"
/* error codes */
#define su_ErrInvalidArgs -1
#define su_ErrUnknownInstaller -2
#define su_ErrInternalError -3
#define su_ErrBadScript -4
#define su_JarError -5
/* xp_string defines */
extern int SU_LOW_DISK_SPACE_WARNING;
extern int SU_NOT_A_ENOUGH_SPACE;
extern int SU_NOT_A_JAR_FILE;
extern int SU_SECURITY_CHECK;
extern int SU_INSTALL_FILE_HEADER;
@ -61,6 +52,9 @@ extern int REGPACK_PROGRESS_LINE1;
extern int REGPACK_PROGRESS_LINE2;
extern uint32 FE_DiskSpaceAvailable (MWContext *context, const char *lpszPath );
/* structs */
/* su_DownloadStream
@ -89,10 +83,10 @@ typedef struct su_URLFeData_struct {
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);
void su_HandleComplete (NET_StreamClass *stream);
void su_HandleAbort (NET_StreamClass *stream, int reason);
unsigned int su_HandleWriteReady (NET_StreamClass *stream);
int su_HandleProcess (void *streamData, const char *buffer, int32 buffLen);
void su_HandleComplete (void *streamData);
void su_HandleAbort (void *streamData, int reason);
unsigned int su_HandleWriteReady (void * streamData );
/* Completion routine for stream handler. Deletes su_DownloadStream */
void su_CompleteSoftwareUpdate(MWContext * context,
@ -253,6 +247,48 @@ su_startCallback *QGetItem(void)
return NULL;
}
int TestFreeSpacePriorToPassing(char* file)
{
XP_StatStruct st;
int status = 0;
uint32 availSpace = 0;
char* tempFolder;
status = XP_Stat( file, &st, xpURL );
if (status != 0)
{
return status;
}
tempFolder = XP_TempDirName();
if(tempFolder == NULL)
{
return su_ErrInternalError;
}
availSpace = FE_DiskSpaceAvailable (NULL, tempFolder );
/*
At best, a zip jar file will produce 50 percent compresssion. Let's
make sure we have this.
*/
if ( availSpace > (st.st_size * 1.5) )
{
return 0;
}
else
{
return su_DiskSpaceError;
}
}
/*
* timer callback to start the network download of a JAR file
*/
@ -325,7 +361,18 @@ void su_NetExitProc(URL_Struct* url, int result, MWContext * context)
{
su_startCallback * c;
if (result != MK_CHANGING_CONTEXT)
if (result == MK_UNABLE_TO_CONVERT)
{
PR_EnterMonitor(su_monitor);
DnLoadInProgress = FALSE;
if (context)
{
FE_Alert(context, XP_GetString(SU_NOT_A_ENOUGH_SPACE));
}
PR_ExitMonitor(su_monitor);
}
else if (result != MK_CHANGING_CONTEXT)
{
PR_EnterMonitor(su_monitor);
if ((c = QGetItem()) != NULL)
@ -477,7 +524,7 @@ NET_StreamClass * SU_NewStream (int format_out, void * registration,
goto fail;
}
prg = PW_Create(context, pwApplicationModal);
prg = PW_Create(context, pwStandard);
fContext = PW_CreateProgressContext();
PW_AssociateWindowWithContext(fContext, prg);
fContext->url = request->address;
@ -502,7 +549,7 @@ NET_StreamClass * SU_NewStream (int format_out, void * registration,
streamData->fCompletion = completion;
streamData->fCompletionClosure = completionClosure;
streamData->fFlags = flags;
streamData->progress = prg;
streamData->progress = prg;
if (request->fe_data)
{
@ -524,7 +571,7 @@ NET_StreamClass * SU_NewStream (int format_out, void * registration,
result = su_ErrInternalError;
goto fail;
}
PW_SetCancelCallback(streamData->progress, cancelProgressDlg, streamData);
PW_SetWindowTitle(streamData->progress, XP_GetString(SU_PROGRESS_DOWNLOAD_TITLE));
/*
@ -554,19 +601,17 @@ fail:
/* su_HandleProcess
* stream method, writes to disk
*/
int su_HandleProcess (NET_StreamClass *stream, const char *buffer, int32 buffLen)
int su_HandleProcess (void *streamData, const char *buffer, int32 buffLen)
{
void *streamData=stream->data_object;
return XP_FileWrite( buffer, buffLen, ((su_DownloadStream*)streamData)->fFile );
}
/* su_HandleAbort
* Clean up
*/
void su_HandleAbort (NET_StreamClass *stream, int reason)
void su_HandleAbort (void *streamData, int reason)
{
void *streamData=stream->data_object;
su_DownloadStream* realStream = (su_DownloadStream*)stream->data_object;
su_DownloadStream* realStream = (su_DownloadStream*)streamData;
/* Close the files */
if (realStream->fFile)
@ -579,7 +624,7 @@ void su_HandleAbort (NET_StreamClass *stream, int reason)
realStream->fCompletion, realStream->fCompletionClosure, reason, realStream);
}
unsigned int su_HandleWriteReady (NET_StreamClass *stream)
unsigned int su_HandleWriteReady (void * streamData )
{
return USHRT_MAX; /* Returning -1 causes errors when loading local file */
}
@ -587,10 +632,10 @@ unsigned int su_HandleWriteReady (NET_StreamClass *stream)
/* su_HandleComplete
* Clean up
*/
void su_HandleComplete (NET_StreamClass *stream)
void su_HandleComplete (void *streamData)
{
su_DownloadStream* realStream = (su_DownloadStream*)stream->data_object;
su_DownloadStream* realStream = (su_DownloadStream*)streamData;
if (realStream->fFile)
XP_FileClose(realStream->fFile);
@ -717,23 +762,60 @@ void su_HandleCompleteJavaScript (su_DownloadStream* realStream)
unsigned long bufferSize;
char * installerJarName = NULL;
char * installerFileNameURL = NULL;
char * codebase = NULL;
int32 urlLen;
char * codebase = NULL;
int32 urlLen;
unsigned long fileNameLength;
char * charset = NULL;
unsigned long charsetLen;
ZIG * jarData = NULL;
char s[255];
char * jsScope = NULL;
char * nativeJar;
Chrome chrome;
MWContext * context;
JSPrincipals * principals = NULL;
ETEvalStuff * stuff = NULL;
char * jarCharset = NULL;
unsigned long jarCharsetLen;
XP_Bool didConfirm;
#if 0
/* hold off on this change -- may create security holes
see later in this function for more detail */
char * nativeJar;
#endif
result = TestFreeSpacePriorToPassing(realStream->fJarFile);
/*
if (result != 0)
{
PR_snprintf(s, 255, XP_GetString(SU_NOT_A_ENOUGH_SPACE), installerJarName);
FE_Alert(realStream->fContext, s);
result = su_DiskSpaceError;
goto fail;
}
*/
if (result != 0)
{
PR_snprintf(s, 255, XP_GetString(SU_LOW_DISK_SPACE_WARNING), installerJarName);
didConfirm = FE_Confirm (realStream->fContext, s);
if (didConfirm)
{
/* the user wants to bail */
result = su_DiskSpaceError;
goto fail;
}
else
{
/* the user is a daredevil */
result = 0;
}
}
/* Initialize the JAR file */
jarData = SOB_new();
@ -825,8 +907,15 @@ void su_HandleCompleteJavaScript (su_DownloadStream* realStream)
/* Extract the script out */
result = SOB_verified_extract( jarData, installerJarName, installerFileNameURL);
if (result < 0)
if (result == ZIG_ERR_DISK)
{
PR_snprintf(s, 255, XP_GetString(SU_NOT_A_ENOUGH_SPACE), installerJarName);
FE_Alert(realStream->fContext, s);
result = su_DiskSpaceError;
goto fail;
}
else if (result < 0)
{
PR_snprintf(s, 255, XP_GetString(SU_INSTALL_FILE_MISSING), installerJarName);
FE_Alert(realStream->fContext, s);
@ -851,11 +940,20 @@ void su_HandleCompleteJavaScript (su_DownloadStream* realStream)
jarData = NULL;
/* add installer .JAR to the classpath */
#if 0
/* hold off on this change -- may create security holes if we switch
* to the Sun JVM. Wouldn't want to offer this functionality and then
* take it away.
* This fix doesn't work, by the way. The temp name MUST have a .jar
* or .zip extension or else Java tries to treat them as directories.
* we must first guarantee the correct extension.
*/
nativeJar = WH_FileName( realStream->fJarFile, xpURL );
if ( nativeJar != NULL ) {
JVM_AddToClassPath( nativeJar );
LJ_AddToClassPath( nativeJar );
XP_FREE( nativeJar );
}
#endif
/* For security reasons, installer JavaScript has to execute inside a
special context. This context is created by ET_EvaluateBuffer as a JS object
@ -869,10 +967,10 @@ void su_HandleCompleteJavaScript (su_DownloadStream* realStream)
if (jsScope == NULL)
goto fail;
XP_BZERO(&chrome, sizeof(Chrome));
chrome.location_is_chrome = TRUE;
XP_BZERO(&chrome, sizeof(Chrome));
chrome.location_is_chrome = TRUE;
#ifndef XP_MAC
chrome.type = MWContextDialog;
chrome.type = MWContextDialog;
#else
/* MacFE doesn't respect chrome.is_modal for MWContextDialog anymore.
We need a different solution for int'l content encoding on macs */
@ -914,11 +1012,9 @@ void su_HandleCompleteJavaScript (su_DownloadStream* realStream)
stuff->data = realStream;
stuff->version = JSVERSION_DEFAULT;
stuff->principals = principals;
/* TODO: The following member doesn't exist
stuff->charset = charset;
*/
/* FIX stuff->charset = charset; */
ET_EvaluateScript(context, buffer, stuff, su_mocha_eval_exit_fn);
ET_EvaluateScript(context, buffer, stuff, su_mocha_eval_exit_fn);
goto done;
@ -945,6 +1041,91 @@ done:
/* Should we purge stuff from the disk cache here? */
}
/* XXX: Move JavaGetBoolPref to lj_init.c.
* Delete IsJavaSecurityEnabled and IsJavaSecurityDefaultTo30Enabled functions
* XXX: Cache all security preferences while we are running on mozilla
* thread. Hack for 4.0
*/
#define MAX_PREF 20
struct {
char *pref_name;
XP_Bool value;
} cachePref[MAX_PREF];
static int free_idx=0;
static XP_Bool locked = FALSE;
static void AddPrefToCache(char *pref_name, XP_Bool value)
{
if (!pref_name)
return;
if (free_idx >= MAX_PREF) {
XP_ASSERT(FALSE); /* Implement dynamic growth of preferences */
return;
}
cachePref[free_idx].pref_name = XP_STRDUP(pref_name);
cachePref[free_idx].value = value;
free_idx++;
}
static XP_Bool GetPreference(char *pref_name, XP_Bool *pref_value)
{
int idx = 0;
*pref_value = FALSE;
if (!pref_name)
return FALSE;
for (; idx < free_idx; idx++) {
if (XP_STRCMP(cachePref[idx].pref_name, pref_name) == 0) {
*pref_value = cachePref[idx].value;
locked = TRUE;
return TRUE;
}
}
if (locked) {
XP_ASSERT(FALSE); /* Implement dynamic growth of preferences */
return FALSE;
}
if (PREF_GetBoolPref(pref_name, pref_value) >=0) {
AddPrefToCache(pref_name, *pref_value);
return TRUE;
}
return FALSE;
}
#ifdef XP_MAC
#pragma export on
#endif
int PR_CALLBACK JavaGetBoolPref(char * pref_name)
{
XP_Bool pref;
int ret_val;
GetPreference(pref_name, &pref);
ret_val = pref;
return ret_val;
}
int PR_CALLBACK IsJavaSecurityEnabled()
{
XP_Bool pref;
int ret_val;
GetPreference("signed.applets.codebase_principal_support", &pref);
ret_val = !pref;
return ret_val;
}
int PR_CALLBACK IsJavaSecurityDefaultTo30Enabled()
{
return JavaGetBoolPref("signed.applets.local_classes_have_30_powers");
}
#ifdef XP_MAC
#pragma export reset
@ -1040,7 +1221,6 @@ REGERR su_UninstallProcessItem(char *component_path)
#ifdef XP_MAC
#pragma export on
#endif
int32 SU_Uninstall(char *regPackageName)
{
REGERR status = REGERR_FAIL;
@ -1356,11 +1536,25 @@ XP_Bool su_RegPackTime()
intervalSec = intervalDays*24*60*60;
err = su_GetLastRegPackTime(&lastRegPackTime);
now = PR_Now();
#ifdef NSPR20
now = PR_Now();
#else
now = PR_LocalTime();
#endif
LL_DIV(nowSec, now, bigNumber);
LL_L2I(nowSecInt, nowSec);
/* We should not pack the Netscape Client Registry, the first
time we use Nova, instead we should set the current time in the
registry, so that the packing can happen at the intervalDays
set in the preferences */
if (lastRegPackTime == 0)
{
su_SetLastRegPackTime(nowSecInt);
return FALSE;
}
i = nowSecInt - lastRegPackTime;
if ((i > intervalSec) || (i < 0))
{
@ -1422,7 +1616,12 @@ int su_PackRegistry()
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();
#ifdef NSPR20
now = PR_Now();
#else
now = PR_LocalTime();
#endif
LL_DIV(nowSec, now, bigNumber);
LL_L2I(nowSecInt, nowSec);
su_SetLastRegPackTime(nowSecInt);

View File

@ -57,7 +57,7 @@ extern int SU_INSTALL_ASK_FOR_DIRECTORY;
/* Makes sure that the path ends with a slash (or other platform end character)
* @return alloc'd new path that ends with a slash
*/
char *
static char *
AppendSlashToDirPath(char * dirPath)
{
char pathSeparator; /* Gross, but harmless */
@ -108,7 +108,7 @@ GetDirectoryPathCallbackFunction(MWContext *context,
}
/* Callback for the timer set by FE_SetTimer */
PR_EXTERN(void)
PR_STATIC_CALLBACK(void)
pickDirectoryCallback(void * a)
{
su_PickDirTimer *t = (su_PickDirTimer *)a;
@ -126,14 +126,12 @@ pickDirectoryCallback(void * a)
/*
*Directory manipulation
*/
/* Entry for the DirectoryTable[] */
/* DirectoryTable holds the info about built-in directories:
* Directory manipulation
*
* DirectoryTable holds the info about built-in directories:
* Text name, security level, enum
*/
struct su_DirectoryTable DirectoryTable[] =
static struct su_DirectoryTable DirectoryTable[] =
{
{"Plugins", ePluginFolder, TRUE},
{"Program", eProgramFolder, FALSE},
@ -174,7 +172,7 @@ struct su_DirectoryTable DirectoryTable[] =
/* MapNameToEnum
* maps name from the directory table to its enum */
su_DirSpecID MapNameToEnum(const char * name)
static su_DirSpecID MapNameToEnum(const char * name)
{
int i = 0;
XP_ASSERT( name );
@ -183,7 +181,7 @@ su_DirSpecID MapNameToEnum(const char * name)
while ( DirectoryTable[i].directoryName[0] != 0 )
{
if ( strcmp(name, DirectoryTable[i].directoryName) == 0 )
if ( XP_STRCASECMP(name, DirectoryTable[i].directoryName) == 0 )
return DirectoryTable[i].folderEnum;
i++;
}

View File

@ -195,20 +195,21 @@ PR_PUBLIC_API(char *) FE_GetDirectoryPath( su_DirSpecID folderID)
int FE_ExecuteFile( const char * fileName, const char * cmdline )
{
OSErr err;
FSSpec appSpec;
char* doomedPath;
OSErr err;
FSSpec appSpec;
char* doomedPath;
LaunchParamBlockRec launchThis;
if ( fileName == NULL )
{
return -1;
try
}
err = CFileMgr::FSSpecFromLocalUnixPath(fileName, &appSpec, true);
if (err == noErr)
{
err = CFileMgr::FSSpecFromLocalUnixPath(fileName, &appSpec, true);
ThrowIfOSErr_(err);
LaunchParamBlockRec launchThis;
launchThis.launchAppSpec = (FSSpecPtr)&appSpec;
launchThis.launchAppParameters = NULL;
/* launch the thing */
@ -216,30 +217,26 @@ int FE_ExecuteFile( const char * fileName, const char * cmdline )
launchThis.launchEPBLength = extendedBlockLen;
launchThis.launchFileFlags = NULL;
launchThis.launchControlFlags = launchContinue + launchNoFileFlags + launchUseMinimum;
if (!IsFrontApplication())
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);
}
launchThis.launchControlFlags += launchDontSwitch;
}
err = LaunchApplication(&launchThis);
/* Returns a full pathname to the given file */
doomedPath = CFileMgr::PathNameFromFSSpec(appSpec, true );
if (doomedPath)
{
su_DeleteOldFileLater(doomedPath);
XP_FREEIF(doomedPath);
}
}
catch (OSErr err)
if (err != noErr)
{
return -1;
}

View File

@ -40,7 +40,7 @@ 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);
OSErr PAS_unflattenResource(PASResource *pasRes, Ptr buffer);
void PAS_sortTypes(short sourceRefNum, ResType **resTypePtr, long *count);
void PAS_sortIDs(short sourceRefNum, OSType theType, short **IdPtr, long *count);
@ -56,6 +56,11 @@ OSErr PAS_EncodeFile(FSSpec *inSpec, FSSpec *outSpec)
PASEntry dataEntry, miscEntry, resourceEntry;
long sizeOfEntry;
if (inSpec == NULL || outSpec == NULL)
return paramErr;
memset(&dataEntry, 0, sizeof(PASEntry));
memset(&miscEntry, 0, sizeof(PASEntry));
memset(&resourceEntry, 0, sizeof(PASEntry));
@ -77,6 +82,16 @@ OSErr PAS_EncodeFile(FSSpec *inSpec, FSSpec *outSpec)
err = PAS_encodeHeader(outRefNum);
if (err != noErr) goto error;
/* Why am I using three (3)?
E stand for entry.
The data for the entry is after the THREE headers
|---------|----|----|----|---------------------->
header E E E
*/
/* Write Out Data Entry */
@ -167,7 +182,10 @@ OSErr PAS_DecodeFile(FSSpec *inSpec, FSSpec *outSpec)
PASEntry dataEntry, miscEntry, resourceEntry;
long sizeOfEntry;
if (inSpec == NULL || outSpec == NULL)
return paramErr;
FSpDelete( outSpec ) ;
err = FSpCreate( outSpec, kCreator, kType ,smSystemScript );
@ -238,10 +256,10 @@ OSErr PAS_DecodeFile(FSSpec *inSpec, FSSpec *outSpec)
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)
{
@ -252,7 +270,7 @@ OSErr PAS_DecodeFile(FSSpec *inSpec, FSSpec *outSpec)
{
goto error;
}
FSClose(inRefNum);
@ -292,10 +310,13 @@ OSErr PAS_encodeResource(FSSpec *inFile, short outRefNum)
short *ids;
long idCount;
short oldResFile;
oldResFile=CurResFile();
inRefNum = FSpOpenResFile(inFile, fsRdPerm);
if (inRefNum < noErr) return inRefNum;
UseResFile(inRefNum);
memset(&resInfo, 0, sizeof(PASResFork));
@ -308,38 +329,36 @@ OSErr PAS_encodeResource(FSSpec *inFile, short outRefNum)
err = FSWrite(outRefNum, &currentWrite, &resInfo);
if (err != noErr) return err;
for (typeCount = 0; typeCount < resInfo.NumberOfTypes; typeCount++)
for (typeCount = 0; ((typeCount < resInfo.NumberOfTypes) && (err == noErr)); typeCount++)
{
PAS_sortIDs(inRefNum, resTypes[typeCount], &ids, &idCount);
PAS_flattenResource(resTypes[typeCount], ids, idCount, inRefNum, outRefNum);
err = PAS_flattenResource(resTypes[typeCount], ids, idCount, inRefNum, outRefNum);
DisposePtr((Ptr)ids);
}
DisposePtr((Ptr)resTypes);
UseResFile(oldResFile);
CloseResFile(inRefNum);
return noErr;
return err;
}
OSErr PAS_decodeResource(PASEntry *entry, FSSpec *outFile, short inRefNum)
{
OSErr err;
OSErr err = noErr;
short outRefNum;
PASResFork info;
SInt32 infoSize;
short oldResFile;
PASResource pasRes;
SInt32 pasResSize;
Ptr buffer;
long bufSize;
outRefNum = FSpOpenResFile(outFile, fsRdWrPerm);
if (outRefNum < noErr) return outRefNum;
Handle buffer;
long counter=0;
infoSize = sizeof(PASResFork);
@ -351,50 +370,81 @@ OSErr PAS_decodeResource(PASEntry *entry, FSSpec *outFile, short inRefNum)
if(infoSize != sizeof(PASResFork))
{
return -1;
err = -1;
goto error;
}
oldResFile=CurResFile();
while (err == noErr)
outRefNum = FSpOpenResFile(outFile, fsRdWrPerm);
if (outRefNum < noErr) return outRefNum;
UseResFile(outRefNum);
while (1)
{
pasResSize = sizeof(PASResource);
err = FSRead( inRefNum, &pasResSize, &pasRes);
if(err == eofErr)
{
break;
}
if (err != noErr)
{
goto error;
if(err == eofErr)
err = noErr;
break;
}
bufSize = pasRes.length;
buffer = NewPtrClear(bufSize);
buffer = NewHandle(bufSize);
HLock(buffer);
err = FSRead( inRefNum, &bufSize, buffer);
if (err != noErr && err != eofErr) goto error;
if(buffer == NULL)
{
/* if we did not get our memory, try updateresfile */
HUnlock(buffer);
UpdateResFile(outRefNum);
counter=0;
buffer = NewHandle(bufSize);
HLock(buffer);
if(buffer == NULL)
{
err = memFullErr;
break;
}
}
err = FSRead( inRefNum, &bufSize, &(**buffer));
if (err != noErr && err != eofErr) break;
err = PAS_unflattenResource( &pasRes,
buffer,
outRefNum);
AddResource(buffer, pasRes.attrType, pasRes.attrID, pasRes.attrName);
WriteResource(buffer);
if (err != noErr) goto error;
SetResAttrs(buffer, pasRes.attr);
ChangedResource(buffer);
WriteResource(buffer);
DisposePtr(buffer);
ReleaseResource(buffer);
if (counter++ > 100)
{
UpdateResFile(outRefNum);
counter=0;
}
}
CloseResFile(outRefNum);
return noErr;
error:
return -1;
UseResFile(oldResFile);
CloseResFile(outRefNum);
return err;
}
#pragma mark -
@ -516,8 +566,10 @@ OSErr PAS_encodeData(FSSpec *inFile, short outRefNum)
{
OSErr err;
short inRefNum;
char buffer[PAS_BUFFER_SIZE];
Ptr buffer;
SInt32 currentRead = PAS_BUFFER_SIZE;
buffer = NewPtr(currentRead);
err = FSpOpenDF(inFile, fsRdPerm, &inRefNum);
if (err != noErr) return err;
@ -533,6 +585,8 @@ OSErr PAS_encodeData(FSSpec *inFile, short outRefNum)
FSClose(inRefNum);
DisposePtr(buffer);
return noErr;
}
@ -540,10 +594,14 @@ OSErr PAS_decodeData(PASEntry *entry, FSSpec *outFile, short inRefNum)
{
OSErr err;
short outRefNum;
char buffer[PAS_BUFFER_SIZE];
Ptr buffer;
SInt32 currentWrite = PAS_BUFFER_SIZE;
SInt32 totalSize;
buffer = NewPtr(currentWrite);
err = FSpOpenDF(outFile, fsRdWrPerm, &outRefNum);
if (err != noErr) return err;
@ -577,7 +635,7 @@ OSErr PAS_decodeData(PASEntry *entry, FSSpec *outFile, short inRefNum)
FSClose(outRefNum);
DisposePtr(buffer);
return noErr;
@ -668,7 +726,7 @@ short PAS_getResourceID(Handle resource)
OSErr PAS_flattenResource(ResType type, short *ids, long count, short source, short dest)
{
long idIndex;
short oldResFile;
Handle resToCopy;
long handleLength;
@ -678,18 +736,14 @@ OSErr PAS_flattenResource(ResType type, short *ids, long count, short source, sh
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
is the resource that the user can modify. Most applications
will not be affected if we remove these resources
*/
}
else
@ -726,67 +780,21 @@ OSErr PAS_flattenResource(ResType type, short *ids, long count, short source, sh
}
err = FSWrite(dest, &handleLength, &(**resToCopy));
if(err != noErr)
{
return err;
}
HUnlock(resToCopy);
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 -

View File

@ -78,9 +78,9 @@ typedef struct PASResource
#endif
#define kCreator '????'
#define kType '????'
#define PAS_BUFFER_SIZE 8192
#define kCreator 'MOSS'
#define kType 'PASf'
#define PAS_BUFFER_SIZE (1024*512)
#define PAS_MAGIC_NUM (0x00244200)
#define PAS_VERSION (0x00010000)

View File

@ -18,6 +18,7 @@
#include "xp_mcom.h"
#include "zlib.h"
#include "nsSoftUpdateEnums.h"
#include "gdiff.h"
@ -199,14 +200,24 @@ int32 SU_PatchFile( char* srcfile, XP_FileType srctype, char* patchfile,
if ( dd->fSrc != NULL && dd->fOut != NULL )
{
status = gdiff_validateFile( dd, SRCFILE );
/* specify why diff failed */
if (status == GDIFF_ERR_CHECKSUM)
status = GDIFF_ERR_CHECKSUM_TARGET;
if ( status == GDIFF_OK )
status = gdiff_ApplyPatch( dd );
if ( status == GDIFF_OK )
status = gdiff_validateFile( dd, OUTFILE );
/* specify why diff failed */
if (status == GDIFF_ERR_CHECKSUM)
status = GDIFF_ERR_CHECKSUM_RESULT;
}
else {
else
{
status = GDIFF_ERR_ACCESS;
}
}
@ -316,19 +327,15 @@ cleanup:
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 );
if ( status != GDIFF_OK )
XP_FileRemove( outfile, outtype );
XP_FREEIF( dd->databuf );
XP_FREEIF( dd->oldChecksum );
XP_FREEIF( dd->newChecksum );
XP_FREE(dd);
@ -339,6 +346,33 @@ cleanup:
XP_FREE( tmpurl );
}
/* lets map any GDIFF error to nice SU errors */
switch (status)
{
case GDIFF_OK:
break;
case GDIFF_ERR_HEADER:
case GDIFF_ERR_BADDIFF:
case GDIFF_ERR_OPCODE:
case GDIFF_ERR_CHKSUMTYPE:
status = nsSoftUpdateError_PATCH_BAD_DIFF;
break;
case GDIFF_ERR_CHECKSUM_TARGET:
status = nsSoftUpdateError_PATCH_BAD_CHECKSUM_TARGET;
break;
case GDIFF_ERR_CHECKSUM_RESULT:
status = nsSoftUpdateError_PATCH_BAD_CHECKSUM_RESULT;
break;
case GDIFF_ERR_OLDFILE:
case GDIFF_ERR_ACCESS:
case GDIFF_ERR_MEM:
case GDIFF_ERR_UNKNOWN:
default:
status = nsSoftUpdateError_UNEXPECTED_ERROR;
break;
}
return status;
}

View File

@ -52,7 +52,6 @@ char * FE_GetDirectoryPath( su_DirSpecID folderID)
fe_GetProgramDirectory( Path, MAXPATHLEN-1 );
XP_STRCAT(Path, "plugins/");
directory = XP_STRDUP( Path );
}
else
{ /* Use local plugins path: $HOME/.netscape/plugins/ */
@ -62,8 +61,9 @@ char * FE_GetDirectoryPath( su_DirSpecID folderID)
Home = "";
else if (!strcmp (Home, "/"))
Home = "";
directory = fe_GetConfigDirFilename("plugins/");
PR_snprintf(Path, MAXPATHLEN, "%.900s/.netscape/plugins/", Home);
}
directory = XP_STRDUP( Path );
}
break;
@ -131,7 +131,6 @@ char * FE_GetDirectoryPath( su_DirSpecID folderID)
fe_GetProgramDirectory( Path, MAXPATHLEN-1 );
XP_STRCAT(Path, "java/download/");
directory = XP_STRDUP( Path );
}
else
{
@ -142,7 +141,7 @@ char * FE_GetDirectoryPath( su_DirSpecID folderID)
else if (!strcmp (Home, "/"))
Home = "";
directory = fe_GetConfigDirFilename("/java/download/");
PR_snprintf(Path, MAXPATHLEN, "%.900s/.netscape/java/download/", Home);
}
directory = XP_STRDUP( Path );
}

View File

@ -88,10 +88,20 @@ char * FE_GetDirectoryPath( su_DirSpecID folderID)
case eTemporaryFolder:
{
char* tmpdir = XP_TempDirName();
XP_STRCPY( path, tmpdir );
XP_STRCAT( path, "\\" );
int slen;
XP_STRNCPY_SAFE( path, tmpdir, _MAX_PATH );
XP_FREEIF(tmpdir);
slen = XP_STRLEN(path);
if ( slen < _MAX_PATH - 1)
{
path[slen] = '\\';
path[slen+1] = '\0';
}
else
break;
directory = XP_STRDUP( path );
}
break;
@ -112,8 +122,9 @@ char * FE_GetDirectoryPath( su_DirSpecID folderID)
case eWin_System16Folder:
len = GetSystemDirectory( path, _MAX_PATH );
// If Windows NT
#ifndef XP_OS2
// If Windows NT
dwVersion = GetVersion();
if ( dwVersion < 0x80000000 ) {
// and the last two chars of the system dir are "32"
@ -123,19 +134,35 @@ char * FE_GetDirectoryPath( su_DirSpecID folderID)
}
}
#endif
XP_STRCPY( path+len, "\\" );
// Need enough space to add the trailing backslash
if(len > _MAX_PATH-2)
break;
path[len] = '\\';
path[len+1] = '\0';
directory = XP_STRDUP( path );
break;
case eWin_SystemFolder:
len = GetSystemDirectory( path, _MAX_PATH );
XP_STRCPY( path+len, "\\" );
// Need enough space to add the trailing backslash
if(len > _MAX_PATH-2)
break;
path[len] = '\\';
path[len+1] = '\0';
directory = XP_STRDUP( path );
break;
case eWin_WindowsFolder:
len = GetWindowsDirectory( path, _MAX_PATH );
XP_STRCPY( path+len, "\\" );
// Need enough space to add the trailing backslash
if(len > _MAX_PATH-2)
break;
path[len] = '\\';
path[len+1] = '\0';
directory = XP_STRDUP( path );
break;
@ -164,6 +191,8 @@ char * FE_GetDirectoryPath( su_DirSpecID folderID)
else {
/* windows FE couldn't find registry setting */
FE_GetProgramDirectory( path, _MAX_PATH );
if(strlen(path)+strlen("NetHelp\\")+1 > _MAX_PATH)
break;
XP_STRCAT( path, "NetHelp\\" );
directory = XP_STRDUP( path );
}
@ -287,7 +316,7 @@ int FE_ReplaceExistingFile(char *CurrentFname, XP_FileType ctype,
BOOL nameFound = FALSE;
char tmpname[_MAX_PATH];
strcpy( tmpname, finalName );
XP_STRNCPY_SAFE( tmpname, finalName, _MAX_PATH );
int len = strlen(tmpname);
while (!nameFound && len < _MAX_PATH ) {
tmpname[len-1] = '~';

View File

@ -97,7 +97,6 @@ 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 ) {
@ -324,7 +323,7 @@ native_netscape_softupdate_RegistryNode_setEntryI(
pValue = (char*)JRI_GetIntArrayElements( env, value );
if ( pName != NULL && pValue != NULL && hReg != NULL ) {
datalen = JRI_GetIntArrayLength( env, value );
datalen = JRI_GetIntArrayLength( env, value ) * sizeof(jint);
status = NR_RegSetEntry( hReg, key, pName,
REGTYPE_ENTRY_INT32_ARRAY, pValue, datalen );
}
@ -454,9 +453,9 @@ native_netscape_softupdate_RegistryNode_nGetEntry(
case REGTYPE_ENTRY_INT32_ARRAY:
valObj = (struct java_lang_Object *)JRI_NewByteArray(
valObj = (struct java_lang_Object *)JRI_NewIntArray(
env,
size,
size/sizeof(jint),
(char*)pValue );
break;
@ -469,6 +468,14 @@ native_netscape_softupdate_RegistryNode_nGetEntry(
size,
(char*)pValue );
break;
case REGTYPE_ENTRY_FILE:
valObj = (struct java_lang_Object *)JRI_NewStringPlatform(
env,
(char*)pValue,
XP_STRLEN((char*)pValue), "", 0 );
break;
}
}