Added Unix makefiles (that really do not do anything)

Added Arguments and Jarfile variables to the Install object which
are now being reflected into js.
Fixed how ExtractJarFile in Install was working
Hooked up to libjar.

** These changes are not part of the Tinderbox builds **
This commit is contained in:
dougt%netscape.com 1999-03-02 20:25:42 +00:00
Родитель 2317e4b478
Коммит 1d2debbaed
22 изменённых файлов: 425 добавлений и 277 удалений

31
xpinstall/Makefile.in Normal file
Просмотреть файл

@ -0,0 +1,31 @@
#
# 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.
#
DEPTH = ..
topsrcdir = @top_srcdir@
srcdir = @srcdir@
VPATH = @srcdir@
include $(DEPTH)/config/autoconf.mk
DIRS = public src
include $(topsrcdir)/config/config.mk
include $(topsrcdir)/config/rules.mk

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

@ -0,0 +1,36 @@
#!gmake
#
# 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.
DEPTH = ../..
topsrcdir = @top_srcdir@
srcdir = @srcdir@
VPATH = @srcdir@
include $(DEPTH)/config/autoconf.mk
MODULE = xpinstall
EXPORTS = \
nsSoftwareUpdateIIDs.h \
nsISoftwareUpdate.h \
$(NULL)
EXPORTS := $(addprefix $(srcdir)/, $(EXPORTS))
include $(topsrcdir)/config/config.mk
include $(topsrcdir)/config/rules.mk

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

@ -3,48 +3,48 @@ interface Install
/* IID: { 0x18c2f988, 0xb09f, 0x11d2, \ /* IID: { 0x18c2f988, 0xb09f, 0x11d2, \
{0xbc, 0xde, 0x00, 0x80, 0x5f, 0x0e, 0x13, 0x53}} */ {0xbc, 0xde, 0x00, 0x80, 0x5f, 0x0e, 0x13, 0x53}} */
const int SUERR_BAD_PACKAGE_NAME = -200; const int BAD_PACKAGE_NAME = -200;
const int SUERR_UNEXPECTED_ERROR = -201; const int UNEXPECTED_ERROR = -201;
const int SUERR_ACCESS_DENIED = -202; const int ACCESS_DENIED = -202;
const int SUERR_TOO_MANY_CERTIFICATES = -203; /* Installer file must have 1 certificate */ const int TOO_MANY_CERTIFICATES = -203; /* Installer file must have 1 certificate */
const int SUERR_NO_INSTALLER_CERTIFICATE = -204; /* Installer file must have a certificate */ const int NO_INSTALLER_CERTIFICATE = -204; /* Installer file must have a certificate */
const int SUERR_NO_CERTIFICATE = -205; /* Extracted file is not signed */ const int NO_CERTIFICATE = -205; /* Extracted file is not signed */
const int SUERR_NO_MATCHING_CERTIFICATE = -206; /* Extracted file does not match installer certificate */ const int NO_MATCHING_CERTIFICATE = -206; /* Extracted file does not match installer certificate */
const int SUERR_UNKNOWN_JAR_FILE = -207; /* JAR file has not been opened */ const int UNKNOWN_JAR_FILE = -207; /* JAR file has not been opened */
const int SUERR_INVALID_ARGUMENTS = -208; /* Bad arguments to a function */ const int INVALID_ARGUMENTS = -208; /* Bad arguments to a function */
const int SUERR_ILLEGAL_RELATIVE_PATH = -209; /* Illegal relative path */ const int ILLEGAL_RELATIVE_PATH = -209; /* Illegal relative path */
const int SUERR_USER_CANCELLED = -210; /* User cancelled */ const int USER_CANCELLED = -210; /* User cancelled */
const int SUERR_INSTALL_NOT_STARTED = -211; const int INSTALL_NOT_STARTED = -211;
const int SUERR_SILENT_MODE_DENIED = -212; const int SILENT_MODE_DENIED = -212;
const int SUERR_NO_SUCH_COMPONENT = -213; /* no such component in the registry. */ const int NO_SUCH_COMPONENT = -213; /* no such component in the registry. */
const int SUERR_FILE_DOES_NOT_EXIST = -214; /* File cannot be deleted as it does not exist */ const int FILE_DOES_NOT_EXIST = -214; /* File cannot be deleted as it does not exist */
const int SUERR_FILE_READ_ONLY = -215; /* File cannot be deleted as it is read only. */ const int FILE_READ_ONLY = -215; /* File cannot be deleted as it is read only. */
const int SUERR_FILE_IS_DIRECTORY = -216; /* File cannot be deleted as it is a directory */ const int FILE_IS_DIRECTORY = -216; /* File cannot be deleted as it is a directory */
const int SUERR_NETWORK_FILE_IS_IN_USE = -217; /* File on the network is in-use */ const int NETWORK_FILE_IS_IN_USE = -217; /* File on the network is in-use */
const int SUERR_APPLE_SINGLE_ERR = -218; /* error in AppleSingle unpacking */ const int APPLE_SINGLE_ERR = -218; /* error in AppleSingle unpacking */
const int SUERR_INVALID_PATH_ERR = -219; /* GetFolder() did not like the folderID */ const int INVALID_PATH_ERR = -219; /* GetFolder() did not like the folderID */
const int SUERR_PATCH_BAD_DIFF = -220; /* error in GDIFF patch */ const int PATCH_BAD_DIFF = -220; /* error in GDIFF patch */
const int SUERR_PATCH_BAD_CHECKSUM_TARGET = -221; /* source file doesn't checksum */ const int PATCH_BAD_CHECKSUM_TARGET = -221; /* source file doesn't checksum */
const int SUERR_PATCH_BAD_CHECKSUM_RESULT = -222; /* final patched file fails checksum */ const int PATCH_BAD_CHECKSUM_RESULT = -222; /* final patched file fails checksum */
const int SUERR_UNINSTALL_FAILED = -223; /* error while uninstalling a package */ const int UNINSTALL_FAILED = -223; /* error while uninstalling a package */
const int SUERR_GESTALT_UNKNOWN_ERR = -5550; const int GESTALT_UNKNOWN_ERR = -5550;
const int SUERR_GESTALT_INVALID_ARGUMENT = -5551; const int GESTALT_INVALID_ARGUMENT = -5551;
const int SU_SUCCESS = 0; const int SUCCESS = 0;
const int SU_REBOOT_NEEDED = 999; const int REBOOT_NEEDED = 999;
/* install types */ /* install types */
const int SU_LIMITED_INSTALL = 0; const int LIMITED_INSTALL = 0;
const int SU_FULL_INSTALL = 1; const int FULL_INSTALL = 1;
const int SU_NO_STATUS_DLG = 2; const int NO_STATUS_DLG = 2;
const int SU_NO_FINALIZE_DLG = 4; const int NO_FINALIZE_DLG = 4;
// these should not be public...
/* message IDs*/ /* message IDs*/
const int SU_INSTALL_FILE_UNEXPECTED_MSG_ID = 0; const int SU_INSTALL_FILE_UNEXPECTED_MSG_ID = 0;
const int SU_DETAILS_REPLACE_FILE_MSG_ID = 1; const int SU_DETAILS_REPLACE_FILE_MSG_ID = 1;
const int SU_DETAILS_INSTALL_FILE_MSG_ID = 2; const int SU_DETAILS_INSTALL_FILE_MSG_ID = 2;
//////////////////////////
readonly attribute wstring UserPackageName; readonly attribute wstring UserPackageName;
readonly attribute wstring RegPackageName; readonly attribute wstring RegPackageName;

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

@ -1,34 +0,0 @@
interface InstallVersion
{
/* IID: { 0x18c2f986, 0xb09f, 0x11d2, \
{0xbc, 0xde, 0x00, 0x80, 0x5f, 0x0e, 0x13, 0x53}} */
const int SU_EQUAL = 0;
const int SU_BLD_DIFF = 1;
const int SU_BLD_DIFF_MINUS = -1;
const int SU_REL_DIFF = 2;
const int SU_REL_DIFF_MINUS = -2;
const int SU_MINOR_DIFF = 3;
const int SU_MINOR_DIFF_MINUS = -3;
const int SU_MAJOR_DIFF = 4;
const int SU_MAJOR_DIFF_MINUS = -4;
attribute int major;
attribute int minor;
attribute int release;
attribute int build;
void InstallVersion();
void init(in wstring versionString);
/*
void init(in int major, in int minor, in int release, in int build);
*/
wstring toString();
/* int compareTo(in wstring version);
int compareTo(in int major, in int minor, in int release, in int build);
*/
int compareTo(in InstallVersion versionObject);
};

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

@ -34,15 +34,15 @@ class nsIDOMInstallVersion : public nsISupports {
public: public:
static const nsIID& IID() { static nsIID iid = NS_IDOMINSTALLVERSION_IID; return iid; } static const nsIID& IID() { static nsIID iid = NS_IDOMINSTALLVERSION_IID; return iid; }
enum { enum {
SU_EQUAL = 0, EQUAL = 0,
SU_BLD_DIFF = 1, BLD_DIFF = 1,
SU_BLD_DIFF_MINUS = -1, BLD_DIFF_MINUS = -1,
SU_REL_DIFF = 2, REL_DIFF = 2,
SU_REL_DIFF_MINUS = -2, REL_DIFF_MINUS = -2,
SU_MINOR_DIFF = 3, MINOR_DIFF = 3,
SU_MINOR_DIFF_MINUS = -3, MINOR_DIFF_MINUS = -3,
SU_MAJOR_DIFF = 4, MAJOR_DIFF = 4,
SU_MAJOR_DIFF_MINUS = -4 MAJOR_DIFF_MINUS = -4
}; };
NS_IMETHOD GetMajor(PRInt32* aMajor)=0; NS_IMETHOD GetMajor(PRInt32* aMajor)=0;

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

@ -21,6 +21,9 @@
#include "nsISupports.h" #include "nsISupports.h"
#include "nsIFactory.h" #include "nsIFactory.h"
#include "nsString.h"
//FIX NEED REAL IID //FIX NEED REAL IID
#define NS_ISOFTWAREUPDATE_IID \ #define NS_ISOFTWAREUPDATE_IID \
@ -34,6 +37,8 @@ class nsISoftwareUpdate : public nsISupports
NS_IMETHOD Startup() = 0; NS_IMETHOD Startup() = 0;
NS_IMETHOD Shutdown()= 0; NS_IMETHOD Shutdown()= 0;
NS_IMETHOD InstallJar(const nsString& jarFile, const nsString& args) = 0;
}; };

23
xpinstall/src/Makefile.in Normal file
Просмотреть файл

@ -0,0 +1,23 @@
#
# 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.
#
DEPTH = ../..
topsrcdir = @top_srcdir@
VPATH = @srcdir@
srcdir = @srcdir@
include $(topsrcdir)/config/rules.mk

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

@ -35,6 +35,7 @@ LINCS= \
-I..\base \ -I..\base \
-I$(XPDIST)\public\xpinstall \ -I$(XPDIST)\public\xpinstall \
-I$(XPDIST)\public\js \ -I$(XPDIST)\public\js \
-I$(XPDIST)\public\jar \
-I$(XPDIST)\public\netlib \ -I$(XPDIST)\public\netlib \
-I$(XPDIST)\public\network \ -I$(XPDIST)\public\network \
-I$(XPDIST)\public\dom \ -I$(XPDIST)\public\dom \
@ -47,6 +48,7 @@ LINCS= \
$(NULL) $(NULL)
LLIBS = \ LLIBS = \
$(DIST)\lib\jar50.lib \
$(DIST)\lib\libreg32.lib \ $(DIST)\lib\libreg32.lib \
$(DIST)\lib\netlib.lib \ $(DIST)\lib\netlib.lib \
$(DIST)\lib\xpcom32.lib \ $(DIST)\lib\xpcom32.lib \

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

@ -24,12 +24,14 @@
#include "nsVector.h" #include "nsVector.h"
#include "nsHashtable.h" #include "nsHashtable.h"
#include "nsFileSpec.h"
#include "prmem.h" #include "prmem.h"
#include "pratom.h" #include "pratom.h"
#include "prefapi.h" #include "prefapi.h"
#include "VerReg.h" #include "VerReg.h"
#include "zipfile.h"
#include "nsInstall.h" #include "nsInstall.h"
@ -58,6 +60,8 @@ nsInstall::nsInstall()
mScriptObject = nsnull; mScriptObject = nsnull;
mVersionInfo = nsnull; mVersionInfo = nsnull;
mJarFileData = nsnull;
mPackageName = ""; mPackageName = "";
mUserPackageName= ""; mUserPackageName= "";
@ -734,7 +738,6 @@ nsInstall::StartInstall(const nsString& aUserPackageName, const nsString& aPacka
*aReturn = nsInstall::SUCCESS; *aReturn = nsInstall::SUCCESS;
ResetError(); ResetError();
ParseFlags(aFlags);
mUserCancelled = PR_FALSE; mUserCancelled = PR_FALSE;
@ -779,35 +782,7 @@ nsInstall::StartInstall(const nsString& aUserPackageName, const nsString& aPacka
return -1; /* FIX: need real error code */ return -1; /* FIX: need real error code */
} }
if (mShowProgress)
{
/* Show our window here */ /* Show our window here */
}
#if 0
// set up default package folder, if any
int err;
char* path = (char*) PR_Malloc(MAXREGPATHLEN);
char* packageNameCString = mPackageName.ToNewCString();
err = VR_GetDefaultDirectory( packageNameCString , MAXREGPATHLEN, path );
delete [] packageNameCString;
if (err != REGERR_OK)
{
PR_FREEIF(path);
path = NULL;
}
if ( path != NULL )
{
mPackageFolder = new nsInstallFolder();
mPackageFolder->Init("Installed", nsString(path), mPackageName);
PR_FREEIF(path);
}
#endif
SaveError(*aReturn); SaveError(*aReturn);
@ -853,20 +828,6 @@ nsInstall::Uninstall(const nsString& aPackageName, PRInt32* aReturn)
//////////////////////////////////////// ////////////////////////////////////////
/*
aJarFile - location inside a jar file
*/
PRInt32
nsInstall::ExtractFileFromJar(const nsString& aJarfile, const nsString& aFinalFile, nsString& aTempFile, PRInt32* error)
{
*error = SUCCESS;
return NS_OK;
}
void void
nsInstall::AddPatch(nsHashKey *aKey, nsString* fileName) nsInstall::AddPatch(nsHashKey *aKey, nsString* fileName)
@ -933,20 +894,6 @@ nsInstall::ScheduleForInstall(nsInstallObject* ob)
void
nsInstall::ParseFlags(int flags)
{
mShowProgress = mShowFinalize = PR_TRUE;
if ((flags & NO_STATUS_DLG) == NO_STATUS_DLG)
{
mShowProgress = PR_FALSE;
}
if ((flags & NO_FINALIZE_DLG) == NO_FINALIZE_DLG)
{
mShowFinalize = PR_FALSE;
}
}
/** /**
* SanityCheck * SanityCheck
* *
@ -1166,17 +1113,88 @@ nsInstall::CleanUp(void)
//CloseProgressDialog(); //CloseProgressDialog();
} }
void
nsInstall::GetJarFileLocation(char** aFile)
{
*aFile = mJarFileLocation;
}
void
nsInstall::SetJarFileLocation(char* aFile)
{
mJarFileLocation = aFile;
}
void
nsInstall::GetInstallArguments(char** args)
{
*args = mInstallArguments;
}
void
nsInstall::SetInstallArguments(char* args)
{
mInstallArguments = args;
}
PRInt32 PRInt32
nsInstall::OpenJARFile(void) nsInstall::OpenJARFile(void)
{ {
return nsInstall::SUCCESS;
PRInt32 result = ZIPR_OpenArchive(mJarFileLocation, &mJarFileData);
return result;
} }
void void
nsInstall::CloseJARFile(void) nsInstall::CloseJARFile(void)
{ {
ZIPR_CloseArchive(&mJarFileData);
mJarFileData = nsnull;
} }
// aJarFile - This is the filepath within the jar file.
// aSuggestedName - This is the name that we should try to extract to. If we can, we will create a new temporary file.
// aRealName - This is the name that we did extract to. This will be allocated by use and should be disposed by the caller.
PRInt32
nsInstall::ExtractFileFromJar(const nsString& aJarfile, const nsString& aSuggestedName, nsString** aRealName)
{
PRInt32 result;
char* extractFileHere;
nsFileSpec finalFile(aSuggestedName);
if (aSuggestedName == "" || finalFile.Exists() )
{
// Create a temporary file to extract to.
extractFileHere = "c:\\temp\\tempFile.tmp";
}
else
{
// extract to the final destination.
extractFileHere = aSuggestedName.ToNewCString();
}
*aRealName = new nsString(extractFileHere);
char* fileInJar = aJarfile.ToNewCString();
result = ZIPR_ExtractFile( mJarFileData, fileInJar, extractFileHere );
delete [] fileInJar;
//delete [] extractFileHere;
return result;
}
PRInt32 PRInt32
nsInstall::ExtractDirEntries(const nsString& directory, nsVector *paths) nsInstall::ExtractDirEntries(const nsString& directory, nsVector *paths)
{ {

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

@ -2,21 +2,21 @@
#define __NS_INSTALL_H__ #define __NS_INSTALL_H__
#include "nscore.h" #include "nscore.h"
#include "nsString.h"
#include "nsISupports.h" #include "nsISupports.h"
#include "jsapi.h" #include "jsapi.h"
#include "nsString.h"
#include "nsFileSpec.h" #include "nsFileSpec.h"
#include "nsVector.h" #include "nsVector.h"
#include "nsHashtable.h" #include "nsHashtable.h"
#include "nsSoftwareUpdate.h" #include "nsSoftwareUpdate.h"
#include "nsInstallObject.h"
#include "nsInstallFolder.h" #include "nsInstallFolder.h"
#include "nsInstallVersion.h" #include "nsInstallVersion.h"
#include "nsInstallObject.h"
class nsInstall class nsInstall
{ {
public: public:
@ -94,16 +94,28 @@ class nsInstall
PRInt32 ExtractFileFromJar(const nsString& aJarfile, const nsString& aFinalFile, nsString& aTempFile, PRInt32* aError); PRInt32 ExtractFileFromJar(const nsString& aJarfile, const nsString& aFinalFile, nsString** aTempFile);
void AddPatch(nsHashKey *aKey, nsString* fileName); void AddPatch(nsHashKey *aKey, nsString* fileName);
void GetPatch(nsHashKey *aKey, nsString* fileName); void GetPatch(nsHashKey *aKey, nsString* fileName);
void GetJarFileLocation(char** aFile);
void SetJarFileLocation(char* aFile);
void GetInstallArguments(char** args);
void SetInstallArguments(char* args);
private: private:
JSObject* mScriptObject; JSObject* mScriptObject;
char* mJarFileLocation;
void* mJarFileData;
char* mInstallArguments;
PRBool mUserCancelled; PRBool mUserCancelled;
PRBool mShowProgress;
PRBool mShowFinalize;
PRBool mUninstallPackage; PRBool mUninstallPackage;
PRBool mRegisterPackage; PRBool mRegisterPackage;

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

@ -46,29 +46,32 @@ nsInstallExecute:: nsInstallExecute( nsInstall* inInstall,
mJarLocation = inJarLocation; mJarLocation = inJarLocation;
mArgs = inArgs; mArgs = inArgs;
mExecutableFile = nsnull;
} }
nsInstallExecute::~nsInstallExecute() nsInstallExecute::~nsInstallExecute()
{ {
delete mExecutableFile;
} }
PRInt32 nsInstallExecute::Prepare() PRInt32 nsInstallExecute::Prepare()
{ {
if (mInstall == NULL || mExecutableFile == "null" || mJarLocation == "null") if (mInstall == NULL || mJarLocation == "null")
return nsInstall::INVALID_ARGUMENTS; return nsInstall::INVALID_ARGUMENTS;
PRInt32 err; return mInstall->ExtractFileFromJar(mJarLocation, "", &mExecutableFile);
mInstall->ExtractFileFromJar(mJarLocation, "", mExecutableFile, &err);
return err;
} }
PRInt32 nsInstallExecute::Complete() PRInt32 nsInstallExecute::Complete()
{ {
char* tempCString = mExecutableFile.ToNewCString(); if (mExecutableFile == nsnull)
return nsInstall::INVALID_ARGUMENTS;
char* tempCString = mExecutableFile->ToNewCString();
nsFileSpec appPath(tempCString , false); nsFileSpec appPath(tempCString , false);
@ -94,23 +97,23 @@ void nsInstallExecute::Abort()
int result; int result;
/* Get the names */ /* Get the names */
if (mExecutableFile == "") if (mExecutableFile == nsnull)
return; return;
currentName = mExecutableFile.ToNewCString();
currentName = mExecutableFile->ToNewCString();
result = PR_Delete(currentName); result = PR_Delete(currentName);
PR_ASSERT(result == 0); /* XXX: need to fe_deletefilelater() or something */ PR_ASSERT(result == 0); /* FIX: need to fe_deletefilelater() or something */
delete currentName; delete currentName;
} }
char* nsInstallExecute::toString() char* nsInstallExecute::toString()
{ {
nsString fullPathString; nsString fullPathString(mJarLocation);
fullPathString.Append(*mExecutableFile);
fullPathString = mJarLocation; if (mExecutableFile == nsnull)
fullPathString += mExecutableFile;
if (mExecutableFile == "null")
{ {
// FIX! // FIX!
// return nsInstallErrorMessages::GetString(nsInstall::DETAILS_EXECUTE_PROGRESS, fullPathString); // return nsInstallErrorMessages::GetString(nsInstall::DETAILS_EXECUTE_PROGRESS, fullPathString);

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

@ -53,9 +53,11 @@ class nsInstallExecute : public nsInstallObject
private: private:
nsString mJarLocation; // Location in the JAR nsString mJarLocation; // Location in the JAR
nsString mExecutableFile; // temporary file location
nsString mArgs; // command line arguments nsString mArgs; // command line arguments
nsString *mExecutableFile; // temporary file location
PRInt32 NativeComplete(void); PRInt32 NativeComplete(void);
void NativeAbort(void); void NativeAbort(void);

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

@ -31,8 +31,9 @@
#include "nsInstallFile.h" #include "nsInstallFile.h"
#include "nsInstall.h" #include "nsInstall.h"
#include "nsInstallVersion.h"
#include "nsIDOMInstallFolder.h" #include "nsIDOMInstallFolder.h"
#include "nsIDOMInstallVersion.h"
#include "nsInstallErrorMessages.h" #include "nsInstallErrorMessages.h"
@ -80,16 +81,25 @@ nsInstallFile::nsInstallFile(nsInstall* inInstall,
return; return;
} }
mVersionRegistryName = new nsString(inVRName);
mJarLocation = new nsString(inJarLocation); mReplaceFile = DoesFileExist();
mVersionInfo = inVInfo; /* XXX: Who owns and who free's this object. Is it nsSoftwareUpdate?? */
mForceInstall = forceInstall; mForceInstall = forceInstall;
folderSpec->IsJavaCapable(&mJavaInstall); mVersionRegistryName = new nsString(inVRName);
mJarLocation = new nsString(inJarLocation);
mVersionInfo = new nsInstallVersion();
//FIX need to delete char* created by .ToNewCString().
nsString tempString;
inVInfo->ToString(tempString);
mVersionInfo->Init(tempString.ToNewCString());
mFinalFile = new nsString(); mFinalFile = new nsString();
folderSpec->MakeFullPath(inPartialPath, *mFinalFile); folderSpec->MakeFullPath(inPartialPath, *mFinalFile);
mReplaceFile = DoesFileExist();
nsString regPackageName; nsString regPackageName;
@ -122,12 +132,20 @@ nsInstallFile::nsInstallFile(nsInstall* inInstall,
nsInstallFile::~nsInstallFile() nsInstallFile::~nsInstallFile()
{ {
if (mVersionRegistryName)
delete mVersionRegistryName; delete mVersionRegistryName;
if (mJarLocation)
delete mJarLocation; delete mJarLocation;
if (mTempFile) if (mTempFile)
delete mTempFile; delete mTempFile;
if (mFinalFile) if (mFinalFile)
delete mFinalFile; delete mFinalFile;
if (mVersionInfo)
delete mVersionInfo;
} }
/* Prepare /* Prepare
@ -138,10 +156,7 @@ PRInt32 nsInstallFile::Prepare()
if (mInstall == NULL || mFinalFile == NULL || mJarLocation == NULL) if (mInstall == NULL || mFinalFile == NULL || mJarLocation == NULL)
return nsInstall::INVALID_ARGUMENTS; return nsInstall::INVALID_ARGUMENTS;
PRInt32 err; return mInstall->ExtractFileFromJar(*mJarLocation, *mFinalFile, &mTempFile);
mInstall->ExtractFileFromJar(*mJarLocation, *mFinalFile, *mTempFile, &err);
return err;
} }
/* Complete /* Complete
@ -165,21 +180,8 @@ PRInt32 nsInstallFile::Complete()
err = NativeComplete(); err = NativeComplete();
char *vr_name = mVersionRegistryName->ToNewCString();
char *final_file = mFinalFile->ToNewCString(); char *final_file = mFinalFile->ToNewCString();
char *vr_name = mVersionRegistryName->ToNewCString();
// Add java archives to the classpath. Don't add if we're
// replacing an existing file -- it'll already be there.
if ( mJavaInstall && !mReplaceFile )
{
PRBool found_zip = endsWith(mFinalFile, ".zip");
PRBool found_jar = endsWith(mFinalFile, ".jar");;
if (found_zip || found_jar)
{
AddToClasspath( mFinalFile );
}
}
nsString regPackageName; nsString regPackageName;
mInstall->GetRegPackageName(regPackageName); mInstall->GetRegPackageName(regPackageName);
@ -421,17 +423,6 @@ end:
} }
void nsInstallFile::AddToClasspath(nsString* file)
{
if ( file != NULL ) {
char *final_file = file->ToNewCString();
// FIX JVM_AddToClassPath(final_file);
delete final_file;
}
}
/* Finds out if the file exists /* Finds out if the file exists
*/ */
PRBool nsInstallFile::DoesFileExist() PRBool nsInstallFile::DoesFileExist()

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

@ -25,8 +25,9 @@
#include "nsInstallObject.h" #include "nsInstallObject.h"
#include "nsInstall.h" #include "nsInstall.h"
#include "nsInstallVersion.h"
#include "nsIDOMInstallFolder.h" #include "nsIDOMInstallFolder.h"
#include "nsIDOMInstallVersion.h"
class nsInstallFile : public nsInstallObject class nsInstallFile : public nsInstallObject
@ -66,7 +67,7 @@ class nsInstallFile : public nsInstallObject
private: private:
/* Private Fields */ /* Private Fields */
nsIDOMInstallVersion* mVersionInfo; /* Version info for this file*/ nsInstallVersion* mVersionInfo; /* Version info for this file*/
nsString* mJarLocation; /* Location in the JAR */ nsString* mJarLocation; /* Location in the JAR */
nsString* mTempFile; /* temporary file location */ nsString* mTempFile; /* temporary file location */
@ -81,7 +82,6 @@ class nsInstallFile : public nsInstallObject
int NativeComplete(); int NativeComplete();
PRBool DoesFileExist(); PRBool DoesFileExist();
void AddToClasspath(nsString* file);
}; };
#endif /* nsInstallFile_h__ */ #endif /* nsInstallFile_h__ */

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

@ -51,7 +51,8 @@ nsInstallPatch::nsInstallPatch( nsInstall* inInstall,
mJarLocation = inJarLocation; mJarLocation = inJarLocation;
mPatchFile = ""; mPatchFile = nsnull;
mTargetFile = ""; mTargetFile = "";
mPatchedFile = ""; mPatchedFile = "";
@ -97,7 +98,7 @@ nsInstallPatch::nsInstallPatch( nsInstall* inInstall,
mVersionInfo = inVInfo; /* Who owns this object? May be we should make a copy of it */ mVersionInfo = inVInfo; /* Who owns this object? May be we should make a copy of it */
mJarLocation = inJarLocation; mJarLocation = inJarLocation;
mPatchFile = ""; mPatchFile = nsnull;
mPatchedFile = ""; mPatchedFile = "";
folderSpec->MakeFullPath(inPartialPath, mTargetFile); folderSpec->MakeFullPath(inPartialPath, mTargetFile);
@ -105,6 +106,8 @@ nsInstallPatch::nsInstallPatch( nsInstall* inInstall,
nsInstallPatch::~nsInstallPatch() nsInstallPatch::~nsInstallPatch()
{ {
if (mPatchFile != nsnull)
delete mPatchFile;
} }
@ -138,7 +141,7 @@ PRInt32 nsInstallPatch::Prepare()
return err; return err;
} }
mInstall->ExtractFileFromJar(mJarLocation, mTargetFile, mPatchFile, &err); err = mInstall->ExtractFileFromJar(mJarLocation, mTargetFile, &mPatchFile);
nsString *fileName = nsnull; nsString *fileName = nsnull;
@ -156,7 +159,7 @@ PRInt32 nsInstallPatch::Prepare()
deleteOldSrc = PR_FALSE; deleteOldSrc = PR_FALSE;
} }
err = NativePatch( *fileName, mPatchFile, mPatchedFile); err = NativePatch( *fileName, *mPatchFile, mPatchedFile);
if (err != nsInstall::SUCCESS) if (err != nsInstall::SUCCESS)
{ {

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

@ -64,7 +64,9 @@ class nsInstallPatch : public nsInstallObject
nsIDOMInstallVersion* mVersionInfo; nsIDOMInstallVersion* mVersionInfo;
nsString mJarLocation; nsString mJarLocation;
nsString mPatchFile;
nsString *mPatchFile;
nsString mTargetFile; nsString mTargetFile;
nsString mPatchedFile; nsString mPatchedFile;

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

@ -85,6 +85,22 @@ GetInstallProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp)
} }
break; break;
} }
case INSTALL_JARFILE:
{
char* prop;
a->GetJarFileLocation(&prop);
nsJSUtils::nsConvertStringToJSVal(prop, cx, vp);
break;
}
case INSTALL_ARGUMENTS:
{
char* prop;
a->GetInstallArguments(&prop);
nsJSUtils::nsConvertStringToJSVal(prop, cx, vp);
break;
}
default: default:
return JS_TRUE; return JS_TRUE;
} }
@ -1065,7 +1081,7 @@ Install(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
// Install class initialization // Install class initialization
// //
PRInt32 InitXPInstallObjects(nsIScriptContext *aContext, nsFileSpec* jarfile, PRInt32 flags, char* argc, PRInt32 argv) PRInt32 InitXPInstallObjects(nsIScriptContext *aContext, char* jarfile, char* args)
{ {
JSContext *jscontext = (JSContext *)aContext->GetNativeContext(); JSContext *jscontext = (JSContext *)aContext->GetNativeContext();
JSObject *global = JS_GetGlobalObject(jscontext); JSObject *global = JS_GetGlobalObject(jscontext);
@ -1094,6 +1110,8 @@ PRInt32 InitXPInstallObjects(nsIScriptContext *aContext, nsFileSpec* jarfile, PR
nativeInstallObject = new nsInstall(); nativeInstallObject = new nsInstall();
nativeInstallObject->SetJarFileLocation(jarfile);
nativeInstallObject->SetInstallArguments(args);
JS_SetPrivate(jscontext, installObject, nativeInstallObject); JS_SetPrivate(jscontext, installObject, nativeInstallObject);
nativeInstallObject->SetScriptObject(installObject); nativeInstallObject->SetScriptObject(installObject);

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

@ -28,6 +28,7 @@
#include "VerReg.h" #include "VerReg.h"
#include "nsIScriptObjectOwner.h" #include "nsIScriptObjectOwner.h"
#include "nsIScriptGlobalObject.h" #include "nsIScriptGlobalObject.h"
@ -164,7 +165,7 @@ nsSoftwareUpdate::Startup()
/* Stupid Hack to test js env*/ /* Stupid Hack to test js env*/
/***************************************/ /***************************************/
RunInstallJS("c:\\temp\\test.js"); InstallJar(nsString("c:\\temp\\test.jar"), "");
DeleteScheduledNodes(); DeleteScheduledNodes();
@ -179,6 +180,23 @@ nsSoftwareUpdate::Shutdown()
return NS_OK; return NS_OK;
} }
// We will need to have a overloaded function for multiple jarfile triggers.
NS_IMETHODIMP
nsSoftwareUpdate::InstallJar(const nsString& jarFile, const nsString& args)
{
// FIX: Display some UI indicating that we are going to start an install.
char* tempJarFileName = jarFile.ToNewCString();
PRInt32 result = Install(tempJarFileName, nsnull);
delete [] tempJarFileName;
return result;
}
nsresult nsresult
nsSoftwareUpdate::DeleteScheduledNodes() nsSoftwareUpdate::DeleteScheduledNodes()
@ -334,13 +352,6 @@ nsSoftwareUpdateNameSet::AddNameSet(nsIScriptContext* aScriptContext)
result = aScriptContext->GetNameSpaceManager(&manager); result = aScriptContext->GetNameSpaceManager(&manager);
if (NS_OK == result) if (NS_OK == result)
{ {
/*
result = manager->RegisterGlobalName("Install",
kInstall_CID,
PR_TRUE);
if (result != NS_OK) return result;
*/
result = manager->RegisterGlobalName("InstallVersion", result = manager->RegisterGlobalName("InstallVersion",
kInstallVersion_CID, kInstallVersion_CID,
PR_TRUE); PR_TRUE);
@ -374,24 +385,28 @@ nsSoftwareUpdateNameSet::AddNameSet(nsIScriptContext* aScriptContext)
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
extern "C" NS_EXPORT PRBool extern "C" NS_EXPORT PRBool
NSCanUnload(void) NSCanUnload(nsISupports* serviceMgr)
{ {
return PRBool (gInstanceCnt == 0 && gLockCnt == 0); return PRBool (gInstanceCnt == 0 && gLockCnt == 0);
} }
extern "C" NS_EXPORT nsresult extern "C" NS_EXPORT nsresult
NSRegisterSelf(const char *path) NSRegisterSelf(nsISupports* serviceMgr, const char *path)
{ {
nsRepository::RegisterFactory(kSoftwareUpdate_CID, path, PR_TRUE, PR_TRUE); printf("*** XPInstall is being registered\n");
nsRepository::RegisterFactory(kInstallTrigger_CID, path, PR_TRUE, PR_TRUE); nsRepository::RegisterComponent(kSoftwareUpdate_CID, NULL, NULL, path, PR_TRUE, PR_TRUE);
nsRepository::RegisterFactory(kInstallVersion_CID, path, PR_TRUE, PR_TRUE); nsRepository::RegisterComponent(kInstallTrigger_CID, NULL, NULL, path, PR_TRUE, PR_TRUE);
nsRepository::RegisterFactory(kInstallFolder_CID, path, PR_TRUE, PR_TRUE); nsRepository::RegisterComponent(kInstallVersion_CID, NULL, NULL, path, PR_TRUE, PR_TRUE);
nsRepository::RegisterComponent(kInstallFolder_CID, NULL, NULL, path, PR_TRUE, PR_TRUE);
return NS_OK; return NS_OK;
} }
extern "C" NS_EXPORT nsresult extern "C" NS_EXPORT nsresult
NSUnregisterSelf(const char *path) NSUnregisterSelf(nsISupports* serviceMgr, const char *path)
{ {
printf("*** XPInstall is being unregistered\n");
nsRepository::UnregisterFactory(kSoftwareUpdate_CID, path); nsRepository::UnregisterFactory(kSoftwareUpdate_CID, path);
nsRepository::UnregisterFactory(kInstallTrigger_CID, path); nsRepository::UnregisterFactory(kInstallTrigger_CID, path);
nsRepository::UnregisterFactory(kInstallVersion_CID, path); nsRepository::UnregisterFactory(kInstallVersion_CID, path);
@ -403,7 +418,11 @@ NSUnregisterSelf(const char *path)
extern "C" NS_EXPORT nsresult extern "C" NS_EXPORT nsresult
NSGetFactory(const nsCID &aClass, nsISupports* serviceMgr, nsIFactory **aFactory) NSGetFactory(nsISupports* serviceMgr,
const nsCID &aClass,
const char *aClassName,
const char *aProgID,
nsIFactory **aFactory)
{ {
if (aFactory == NULL) if (aFactory == NULL)

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

@ -8,6 +8,7 @@
#include "nscore.h" #include "nscore.h"
#include "nsIFactory.h" #include "nsIFactory.h"
#include "nsISupports.h" #include "nsISupports.h"
#include "nsString.h"
#include "nsIScriptExternalNameSet.h" #include "nsIScriptExternalNameSet.h"
@ -23,6 +24,7 @@ class nsSoftwareUpdate: public nsISoftwareUpdate
NS_IMETHOD Startup(); NS_IMETHOD Startup();
NS_IMETHOD Shutdown(); NS_IMETHOD Shutdown();
NS_IMETHOD InstallJar(const nsString& jarFile, const nsString& args);
private: private:
nsresult DeleteScheduledNodes(); nsresult DeleteScheduledNodes();
@ -40,7 +42,6 @@ class nsSoftwareUpdateNameSet : public nsIScriptExternalNameSet
NS_IMETHOD AddNameSet(nsIScriptContext* aScriptContext); NS_IMETHOD AddNameSet(nsIScriptContext* aScriptContext);
}; };
#define AUTOUPDATE_ENABLE_PREF "autoupdate.enabled" #define AUTOUPDATE_ENABLE_PREF "autoupdate.enabled"
#define AUTOUPDATE_CONFIRM_PREF "autoupdate.confirm_install" #define AUTOUPDATE_CONFIRM_PREF "autoupdate.confirm_install"
#define CHARSET_HEADER "Charset" #define CHARSET_HEADER "Charset"
@ -50,12 +51,5 @@ class nsSoftwareUpdateNameSet : public nsIScriptExternalNameSet
#define REG_SOFTUPDT_DIR "Netscape/Communicator/SoftwareUpdate/" #define REG_SOFTUPDT_DIR "Netscape/Communicator/SoftwareUpdate/"
#define LAST_REGPACK_TIME "LastRegPackTime" #define LAST_REGPACK_TIME "LastRegPackTime"
/* error codes */
#define ErrInvalidArgs -1
#define ErrUnknownInstaller -2
#define ErrInternalError -3
#define ErrBadScript -4
#define JarError -5
#define DiskSpaceError -6
#endif #endif

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

@ -12,8 +12,10 @@
#include "nsIScriptContextOwner.h" #include "nsIScriptContextOwner.h"
#include "nsInstall.h" #include "nsInstall.h"
#include "zipfile.h"
extern PRInt32 InitXPInstallObjects(nsIScriptContext *aContext, nsFileSpec* jarfile, PRInt32 flags, char* argc, PRInt32 argv);
extern PRInt32 InitXPInstallObjects(nsIScriptContext *aContext, char* jarfile, char* args);
static NS_DEFINE_IID(kBrowserWindowCID, NS_BROWSER_WINDOW_CID); static NS_DEFINE_IID(kBrowserWindowCID, NS_BROWSER_WINDOW_CID);
@ -35,7 +37,7 @@ static short ReadFileIntoBuffer(char * fileName, char** buffer, unsigned long *b
if ( stat( fileName, &st) != 0 ) if ( stat( fileName, &st) != 0 )
{ {
result = ErrInternalError; result = -1;
goto fail; goto fail;
} }
@ -53,13 +55,13 @@ static short ReadFileIntoBuffer(char * fileName, char** buffer, unsigned long *b
if ( file == NULL) if ( file == NULL)
{ {
result = ErrInternalError; result = -1;
goto fail; goto fail;
} }
if ( PR_Read(file, *buffer, *bufferSize ) != st.st_size ) if ( PR_Read(file, *buffer, *bufferSize ) != st.st_size )
{ {
result = ErrInternalError; result = -1;
PR_Close( file ); PR_Close( file );
goto fail; goto fail;
} }
@ -77,12 +79,40 @@ fail:
} }
extern "C" NS_EXPORT PRInt32 Install(char* jarFile, char* args)
int RunInstallJS(char* installJSFile)
{ {
// Open the jarfile.
void* hZip;
PRInt32 result = ZIPR_OpenArchive(jarFile , &hZip);
if (result != ZIP_OK)
{
return result;
}
// Read manifest file for Install Script filename.
//FIX: need to do.
char* installJSFile = "c:\\temp\\install.js";
remove(installJSFile);
// Extract the install.js file.
result = ZIPR_ExtractFile( hZip, "install.js", installJSFile );
if (result != ZIP_OK)
{
return result;
}
nsIBrowserWindow *aWindow; nsIBrowserWindow *aWindow;
nsIWebShell *aWebShell; nsIWebShell *aWebShell;
// Create a new window so that we can both run a script in it and display UI.
nsresult rv = nsRepository::CreateInstance( kBrowserWindowCID, nsresult rv = nsRepository::CreateInstance( kBrowserWindowCID,
nsnull, nsnull,
kIBrowserWindowIID, kIBrowserWindowIID,
@ -91,51 +121,37 @@ int RunInstallJS(char* installJSFile)
{ {
nsRect rect(0, 0, 275, 300); nsRect rect(0, 0, 275, 300);
nsAutoString retval;
PRBool isUndefined;
nsIScriptContextOwner* scriptContextOwner;
nsIScriptContext* scriptContext;
rv = aWindow->Init(nsnull, nsnull, rect, PRUint32(0), PR_FALSE); rv = aWindow->Init(nsnull, nsnull, rect, PRUint32(0), PR_FALSE);
if (rv == NS_OK) if (rv == NS_OK)
{ {
rv = aWindow->GetWebShell(aWebShell); rv = aWindow->GetWebShell(aWebShell);
/* FIX: Display a window here...(ie.OpenURL) /*
* FIX: Display a window here...(ie.OpenURL)
What about silent/forced installs?
*/ */
if (NS_OK == aWebShell->QueryInterface( kIScriptContextOwnerIID, (void**)&scriptContextOwner))
nsAutoString retval;
PRBool isUndefined;
nsIScriptContextOwner* scriptContextOwner;
if (NS_OK == aWebShell->QueryInterface( kIScriptContextOwnerIID,
(void**)&scriptContextOwner))
{ {
const char* url = "";
nsIScriptContext* scriptContext;
rv = scriptContextOwner->GetScriptContext(&scriptContext); rv = scriptContextOwner->GetScriptContext(&scriptContext);
if (NS_OK == rv) if (NS_OK == rv)
{ {
/////////////////////////////////////////////////////////////////////// InitXPInstallObjects(scriptContext, jarFile, args );
// Init Install Object
///////////////////////////////////////////////////////////////////////
nsFileSpec jarfile("c:\\temp\\jarfile.jar");
PRInt32 flags = 0;
char* argc = nsnull;
PRInt32 argv = 0;
InitXPInstallObjects(scriptContext, &jarfile, flags, argc, argv );
///////////////////////////////////////////////////////////////////////
char* buffer; char* buffer;
unsigned long bufferLength; unsigned long bufferLength;
ReadFileIntoBuffer(installJSFile, &buffer, &bufferLength); ReadFileIntoBuffer(installJSFile, &buffer, &bufferLength);
// We expected this to block.
scriptContext->EvaluateString(nsString(buffer), nsnull, 0, retval, &isUndefined); scriptContext->EvaluateString(nsString(buffer), nsnull, 0, retval, &isUndefined);
PR_FREEIF(buffer); PR_FREEIF(buffer);
@ -145,9 +161,16 @@ int RunInstallJS(char* installJSFile)
NS_RELEASE(scriptContextOwner); NS_RELEASE(scriptContextOwner);
} }
} }
aWindow->Close(); aWindow->Close();
NS_RELEASE(aWindow); NS_RELEASE(aWindow);
} }
else
{
return -1;
}
ZIPR_CloseArchive(&hZip);
return 0; return 0;
} }

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

@ -1,6 +1,6 @@
#ifndef __NS_SoftwareUpdateRun_H__ #ifndef __NS_SoftwareUpdateRun_H__
#define __NS_SoftwareUpdateRun_H__ #define __NS_SoftwareUpdateRun_H__
int RunInstallJS(char* filename); extern "C" NS_EXPORT PRInt32 Install(char* jarFile, char* args);
#endif #endif