This commit is contained in:
dougt%netscape.com 1999-03-01 21:35:13 +00:00
Родитель b03ef3499c
Коммит d6cc5463ee
19 изменённых файлов: 1431 добавлений и 664 удалений

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

@ -18,16 +18,6 @@
*/
#include "nsInstall.h"
#include "nsIDOMInstall.h"
#include "nsIDOMInstallFolder.h"
#include "nsIDOMInstallVersion.h"
#include "nsInstallFile.h"
#include "nsInstallDelete.h"
#include "nsInstallExecute.h"
#include "nscore.h"
#include "nsIFactory.h"
#include "nsISupports.h"
@ -40,13 +30,27 @@
#include "prefapi.h"
#include "VerReg.h"
static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID);
static NS_DEFINE_IID(kIFactoryIID, NS_IFACTORY_IID);
static NS_DEFINE_IID(kIScriptObjectOwnerIID, NS_ISCRIPTOBJECTOWNER_IID);
static NS_DEFINE_IID(kIInstall_IID, NS_IDOMINSTALL_IID);
#include "nsInstall.h"
#include "nsIDOMInstallFolder.h"
#include "nsIDOMInstallVersion.h"
#include "nsInstallFile.h"
#include "nsInstallDelete.h"
#include "nsInstallExecute.h"
#include "nsInstallPatch.h"
static NS_DEFINE_IID(kIInstallFolder_IID, NS_IDOMINSTALLFOLDER_IID);
#ifdef XP_PC
#define FILESEP "\\"
#elif defined(XP_MAC)
#define FILESEP ":"
#else
#define FILESEP "/"
#endif
nsInstall::nsInstall()
@ -59,8 +63,6 @@ nsInstall::nsInstall()
mUninstallPackage = PR_FALSE;
mRegisterPackage = PR_FALSE;
NS_INIT_REFCNT();
}
nsInstall::~nsInstall()
@ -69,85 +71,28 @@ nsInstall::~nsInstall()
delete mVersionInfo;
}
NS_IMETHODIMP
nsInstall::QueryInterface(REFNSIID aIID,void** aInstancePtr)
{
if (aInstancePtr == NULL)
{
return NS_ERROR_NULL_POINTER;
}
// Always NULL result, in case of failure
*aInstancePtr = NULL;
if ( aIID.Equals(kIScriptObjectOwnerIID))
{
*aInstancePtr = (void*) ((nsIScriptObjectOwner*)this);
AddRef();
return NS_OK;
}
else if ( aIID.Equals(kIInstall_IID) )
{
*aInstancePtr = (void*) ((nsIDOMInstall*)this);
AddRef();
return NS_OK;
}
else if ( aIID.Equals(kISupportsIID) )
{
*aInstancePtr = (void*)(nsISupports*)(nsIScriptObjectOwner*)this;
AddRef();
return NS_OK;
}
return NS_NOINTERFACE;
}
NS_IMPL_ADDREF(nsInstall)
NS_IMPL_RELEASE(nsInstall)
NS_IMETHODIMP
nsInstall::GetScriptObject(nsIScriptContext *aContext, void** aScriptObject)
{
NS_PRECONDITION(nsnull != aScriptObject, "null arg");
nsresult res = NS_OK;
if (nsnull == mScriptObject)
{
res = NS_NewScriptInstall( aContext,
(nsISupports *)(nsIDOMInstall*)this,
nsnull,
&mScriptObject);
}
*aScriptObject = mScriptObject;
return res;
}
NS_IMETHODIMP
nsInstall::SetScriptObject(void *aScriptObject)
{
mScriptObject = aScriptObject;
mScriptObject = (JSObject*) aScriptObject;
return NS_OK;
}
NS_IMETHODIMP
PRInt32
nsInstall::GetUserPackageName(nsString& aUserPackageName)
{
aUserPackageName = mUserPackageName;
return NS_OK;
}
NS_IMETHODIMP
PRInt32
nsInstall::GetRegPackageName(nsString& aRegPackageName)
{
aRegPackageName = mPackageName;
return NS_OK;
}
NS_IMETHODIMP
PRInt32
nsInstall::AbortInstall()
{
nsInstallObject* ie;
@ -168,7 +113,7 @@ nsInstall::AbortInstall()
return NS_OK;
}
//FIX: Should we use empty strings or nulls for parameters that do not need values.
NS_IMETHODIMP
PRInt32
nsInstall::AddDirectory(const nsString& aRegName, const nsString& aVersion, const nsString& aJarSource, nsIDOMInstallFolder* aFolder, const nsString& aSubdir, PRBool aForceMode, PRInt32* aReturn)
{
nsInstallFile* ie = nsnull;
@ -176,13 +121,13 @@ nsInstall::AddDirectory(const nsString& aRegName, const nsString& aVersion, cons
if ( aJarSource == "null" || aFolder == nsnull)
{
*aReturn = SaveError(nsIDOMInstall::SUERR_INVALID_ARGUMENTS);
*aReturn = SaveError(nsInstall::INVALID_ARGUMENTS);
return NS_OK;
}
result = SanityCheck();
if (result != nsIDOMInstall::SU_SUCCESS)
if (result != nsInstall::SUCCESS)
{
*aReturn = SaveError( result );
return NS_OK;
@ -202,7 +147,7 @@ nsInstall::AddDirectory(const nsString& aRegName, const nsString& aVersion, cons
if (qualifiedRegName == nsnull)
{
*aReturn = SaveError( SUERR_BAD_PACKAGE_NAME );
*aReturn = SaveError( BAD_PACKAGE_NAME );
return NS_OK;
}
@ -221,7 +166,7 @@ nsInstall::AddDirectory(const nsString& aRegName, const nsString& aVersion, cons
PRInt32 pathsUpperBound = paths.GetUpperBound();
if (result != nsIDOMInstall::SU_SUCCESS)
if (result != nsInstall::SUCCESS)
{
*aReturn = SaveError( result );
return NS_OK;
@ -304,7 +249,7 @@ nsInstall::AddDirectory(const nsString& aRegName, const nsString& aVersion, cons
delete newSubDir;
delete newVersion;
if (result == SU_SUCCESS)
if (result == nsInstall::SUCCESS)
{
result = ScheduleForInstall( ie );
}
@ -323,7 +268,7 @@ nsInstall::AddDirectory(const nsString& aRegName, const nsString& aVersion, cons
return NS_OK;
}
NS_IMETHODIMP
PRInt32
nsInstall::AddSubcomponent(const nsString& aRegName,
const nsString& aVersion,
const nsString& aJarSource,
@ -335,17 +280,17 @@ nsInstall::AddSubcomponent(const nsString& aRegName,
nsInstallFile* ie;
nsString* qualifiedRegName = nsnull;
PRInt32 errcode = SU_SUCCESS;
PRInt32 errcode = nsInstall::SUCCESS;
if ( aJarSource == "null" || aFolder == nsnull)
{
*aReturn = SaveError( nsIDOMInstall::SUERR_INVALID_ARGUMENTS );
*aReturn = SaveError( nsInstall::INVALID_ARGUMENTS );
return NS_OK;
}
PRInt32 result = SanityCheck();
if (result != nsIDOMInstall::SU_SUCCESS)
if (result != nsInstall::SUCCESS)
{
*aReturn = SaveError( result );
return NS_OK;
@ -364,7 +309,7 @@ nsInstall::AddSubcomponent(const nsString& aRegName,
if (qualifiedRegName == nsnull)
{
*aReturn = SaveError( SUERR_BAD_PACKAGE_NAME );
*aReturn = SaveError( BAD_PACKAGE_NAME );
return NS_OK;
}
@ -392,7 +337,7 @@ nsInstall::AddSubcomponent(const nsString& aRegName,
PRInt32 areTheyEqual;
newVersion->CompareTo((nsInstallVersion*)oldVersion, &areTheyEqual);
if ( areTheyEqual != nsIDOMInstallVersion::SU_EQUAL )
if ( areTheyEqual != nsIDOMInstallVersion::EQUAL )
versionNewer = PR_TRUE;
if ( oldVersion )
@ -418,7 +363,7 @@ nsInstall::AddSubcomponent(const nsString& aRegName,
aForceMode,
&errcode );
if (errcode == SU_SUCCESS)
if (errcode == nsInstall::SUCCESS)
{
errcode = ScheduleForInstall( ie );
}
@ -438,12 +383,12 @@ nsInstall::AddSubcomponent(const nsString& aRegName,
return NS_OK;
}
NS_IMETHODIMP
PRInt32
nsInstall::DeleteComponent(const nsString& aRegistryName, PRInt32* aReturn)
{
PRInt32 result = SanityCheck();
if (result != nsIDOMInstall::SU_SUCCESS)
if (result != nsInstall::SUCCESS)
{
*aReturn = SaveError( result );
return NS_OK;
@ -454,12 +399,12 @@ nsInstall::DeleteComponent(const nsString& aRegistryName, PRInt32* aReturn)
if (qualifiedRegName == nsnull)
{
*aReturn = SaveError( SUERR_BAD_PACKAGE_NAME );
*aReturn = SaveError( BAD_PACKAGE_NAME );
return NS_OK;
}
nsInstallDelete* id = new nsInstallDelete(this, NULL, *qualifiedRegName, &result);
if (result == SU_SUCCESS)
if (result == nsInstall::SUCCESS)
{
result = ScheduleForInstall( id );
}
@ -471,12 +416,12 @@ nsInstall::DeleteComponent(const nsString& aRegistryName, PRInt32* aReturn)
return NS_OK;
}
NS_IMETHODIMP
PRInt32
nsInstall::DeleteFile(nsIDOMInstallFolder* aFolder, const nsString& aRelativeFileName, PRInt32* aReturn)
{
PRInt32 result = SanityCheck();
if (result != nsIDOMInstall::SU_SUCCESS)
if (result != nsInstall::SUCCESS)
{
*aReturn = SaveError( result );
return NS_OK;
@ -484,14 +429,14 @@ nsInstall::DeleteFile(nsIDOMInstallFolder* aFolder, const nsString& aRelativeFil
nsInstallDelete* id = new nsInstallDelete(this, aFolder, aRelativeFileName, &result);
if (result == SU_SUCCESS)
if (result == nsInstall::SUCCESS)
{
result = ScheduleForInstall( id );
}
if (result == SUERR_FILE_DOES_NOT_EXIST)
if (result == nsInstall::FILE_DOES_NOT_EXIST)
{
result = SU_SUCCESS;
result = nsInstall::SUCCESS;
}
*aReturn = SaveError(result);
@ -499,25 +444,26 @@ nsInstall::DeleteFile(nsIDOMInstallFolder* aFolder, const nsString& aRelativeFil
return NS_OK;
}
NS_IMETHODIMP
PRInt32
nsInstall::DiskSpaceAvailable(nsIDOMInstallFolder* aFolder, PRInt32* aReturn)
{
return NS_OK;
}
NS_IMETHODIMP
PRInt32
nsInstall::Execute(const nsString& aJarSource, const nsString& aArgs, PRInt32* aReturn)
{
PRInt32 result = SanityCheck();
if (result != nsIDOMInstall::SU_SUCCESS)
if (result != nsInstall::SUCCESS)
{
*aReturn = SaveError( result );
return NS_OK;
}
nsInstallExecute* ie = new nsInstallExecute(this, aJarSource, aArgs, &result);
nsInstallExecute* ie = new nsInstallExecute(this, aJarSource, aArgs, &result);
if (result == SU_SUCCESS)
if (result == nsInstall::SUCCESS)
{
result = ScheduleForInstall( ie );
}
@ -527,14 +473,14 @@ nsInstall::Execute(const nsString& aJarSource, const nsString& aArgs, PRInt32* a
return NS_OK;
}
NS_IMETHODIMP
PRInt32
nsInstall::FinalizeInstall(PRInt32* aReturn)
{
PRBool rebootNeeded = PR_FALSE;
PRInt32 result = SanityCheck();
if (result != nsIDOMInstall::SU_SUCCESS)
if (result != nsInstall::SUCCESS)
{
*aReturn = SaveError( result );
return NS_OK;
@ -574,7 +520,7 @@ nsInstall::FinalizeInstall(PRInt32* aReturn)
//result = ie->Complete();
ie->Complete();
if (result != SU_SUCCESS)
if (result != nsInstall::SUCCESS)
{
ie->Abort();
*aReturn = SaveError( result );
@ -586,21 +532,80 @@ nsInstall::FinalizeInstall(PRInt32* aReturn)
return NS_OK;
}
NS_IMETHODIMP
PRInt32
nsInstall::Gestalt(const nsString& aSelector, PRInt32* aReturn)
{
*aReturn = nsnull;
return NS_OK;
}
NS_IMETHODIMP
nsInstall::GetComponentFolder(const nsString& aRegName, const nsString& aSubdirectory, nsIDOMInstallFolder** aFolder)
PRInt32
nsInstall::GetComponentFolder(const nsString& aComponentName, const nsString& aSubdirectory, nsIDOMInstallFolder** aFolder)
{
nsInstallFolder* spec = nsnull;
*aFolder = nsnull;
nsString *tempString = GetQualifiedPackageName( aComponentName );
if (tempString == nsnull)
return NS_OK;
long err;
char* dir;
char* componentCString;
componentCString = tempString->ToNewCString();
delete tempString;
dir = (char*)PR_Malloc(MAXREGPATHLEN);
err = VR_GetDefaultDirectory( componentCString, MAXREGPATHLEN, dir );
if (err != REGERR_OK)
{
PR_FREEIF(dir);
}
if ( dir == NULL )
{
dir = (char*)PR_Malloc(MAXREGPATHLEN);
err = VR_GetPath( componentCString, MAXREGPATHLEN, dir );
if (err != REGERR_OK)
{
PR_FREEIF(dir);
}
if ( dir != nsnull )
{
int i;
nsString dirStr(dir);
if ( (i = dirStr.RFind(FILESEP)) > 0 )
{
PR_FREEIF(dir);
dir = (char*)PR_Malloc(i);
dir = dirStr.ToCString(dir, i);
}
}
}
if ( dir != NULL )
{
spec = new nsInstallFolder();
spec->Init("Installed", nsString(dir), mUserPackageName);
}
PR_FREEIF(dir);
delete [] componentCString;
nsresult result = spec->QueryInterface(kIInstallFolder_IID, (void**)aFolder);
if (result != NS_OK)
*aFolder = nsnull;
return NS_OK;
}
NS_IMETHODIMP
PRInt32
nsInstall::GetFolder(const nsString& targetFolder, const nsString& aSubdirectory, nsIDOMInstallFolder** aFolder)
{
nsInstallFolder* spec = nsnull;
@ -620,42 +625,86 @@ nsInstall::GetFolder(const nsString& targetFolder, const nsString& aSubdirectory
return NS_OK;
}
NS_IMETHODIMP
PRInt32
nsInstall::GetLastError(PRInt32* aReturn)
{
*aReturn = mLastError;
return NS_OK;
}
NS_IMETHODIMP
PRInt32
nsInstall::GetWinProfile(nsIDOMInstallFolder* aFolder, const nsString& aFile, PRInt32* aReturn)
{
return NS_OK;
}
NS_IMETHODIMP
PRInt32
nsInstall::GetWinRegistry(PRInt32* aReturn)
{
return NS_OK;
}
NS_IMETHODIMP
PRInt32
nsInstall::Patch(const nsString& aRegName, const nsString& aVersion, const nsString& aJarSource, nsIDOMInstallFolder* aFolder, const nsString& aTargetName, PRInt32* aReturn)
{
PRInt32 result = SanityCheck();
if (result != nsInstall::SUCCESS)
{
*aReturn = SaveError( result );
return NS_OK;
}
nsString* qualifiedRegName = GetQualifiedRegName( aRegName );
if (qualifiedRegName == nsnull)
{
*aReturn = SaveError( nsInstall::BAD_PACKAGE_NAME );
return NS_OK;
}
nsInstallVersion *newVersion = new nsInstallVersion();
newVersion->Init(aVersion);
nsInstallPatch* ip = new nsInstallPatch( this,
*qualifiedRegName,
newVersion,
aJarSource,
&result);
delete newVersion;
if (result == nsInstall::SUCCESS)
{
result = ScheduleForInstall( ip );
}
*aReturn = SaveError(result);
return NS_OK;
}
NS_IMETHODIMP
PRInt32
nsInstall::ResetError()
{
mLastError = SU_SUCCESS;
mLastError = nsInstall::SUCCESS;
return NS_OK;
}
NS_IMETHODIMP
PRInt32
nsInstall::SetPackageFolder(nsIDOMInstallFolder* aFolder)
{
nsString directoryPath;
aFolder->GetDirectoryPath(directoryPath);
if (mPackageFolder != nsnull)
delete mPackageFolder;
mPackageFolder = new nsInstallFolder();
mPackageFolder->Init("Installed", directoryPath, mPackageName);
return NS_OK;
}
@ -679,10 +728,10 @@ nsInstall::SetPackageFolder(nsIDOMInstallFolder* aFolder)
* @param flags Once was securityLevel(LIMITED_INSTALL or FULL_INSTALL). Now
* can be either NO_STATUS_DLG or NO_FINALIZE_DLG
*/
NS_IMETHODIMP
PRInt32
nsInstall::StartInstall(const nsString& aUserPackageName, const nsString& aPackageName, const nsString& aVersion, PRInt32 aFlags, PRInt32* aReturn)
{
*aReturn = SU_SUCCESS;
*aReturn = nsInstall::SUCCESS;
ResetError();
ParseFlags(aFlags);
@ -693,7 +742,7 @@ nsInstall::StartInstall(const nsString& aUserPackageName, const nsString& aPacka
if ( aPackageName.Equals("") )
{
*aReturn = SUERR_INVALID_ARGUMENTS;
*aReturn = nsInstall::INVALID_ARGUMENTS;
return NS_OK;
}
@ -724,7 +773,7 @@ nsInstall::StartInstall(const nsString& aUserPackageName, const nsString& aPacka
/* this function should also check security!!! */
*aReturn = OpenJARFile();
if (*aReturn != SU_SUCCESS)
if (*aReturn != nsInstall::SUCCESS)
{
/* if we can not continue with the javascript return a JAR error*/
return -1; /* FIX: need real error code */
@ -735,7 +784,8 @@ nsInstall::StartInstall(const nsString& aUserPackageName, const nsString& aPacka
/* Show our window here */
}
// set up default package folder, if any
#if 0
// set up default package folder, if any
int err;
char* path = (char*) PR_Malloc(MAXREGPATHLEN);
char* packageNameCString = mPackageName.ToNewCString();
@ -757,10 +807,11 @@ nsInstall::StartInstall(const nsString& aUserPackageName, const nsString& aPacka
PR_FREEIF(path);
}
#endif
SaveError(*aReturn);
if (*aReturn != SU_SUCCESS)
if (*aReturn != nsInstall::SUCCESS)
{
mPackageName = ""; // Reset!
}
@ -768,18 +819,51 @@ nsInstall::StartInstall(const nsString& aUserPackageName, const nsString& aPacka
return NS_OK;
}
NS_IMETHODIMP
PRInt32
nsInstall::Uninstall(const nsString& aPackageName, PRInt32* aReturn)
{
PRInt32 result = SanityCheck();
if (result != nsInstall::SUCCESS)
{
*aReturn = SaveError( result );
return NS_OK;
}
nsString* qualifiedPackageName = GetQualifiedPackageName( aPackageName );
if (qualifiedPackageName == nsnull)
{
*aReturn = SaveError( BAD_PACKAGE_NAME );
return NS_OK;
}
// Create UNinstall object here FIX
delete qualifiedPackageName;
if (result == SUCCESS)
{
// result = ScheduleForInstall( ip );
}
*aReturn = SaveError(result);
return NS_OK;
}
////////////////////////////////////////
/*
aJarFile - location inside a jar file
*/
PRInt32
nsInstall::ExtractFileFromJar(const nsString& aJarfile, const nsString& aFinalFile, nsString& aTempFile, PRInt32* error)
{
*error = SU_SUCCESS;
*error = SUCCESS;
return NS_OK;
}
@ -815,7 +899,7 @@ nsInstall::GetPatch(nsHashKey *aKey, nsString* fileName)
PRInt32
nsInstall::ScheduleForInstall(nsInstallObject* ob)
{
PRInt32 error = SU_SUCCESS;
PRInt32 error = nsInstall::SUCCESS;
char *objString = ob->toString();
@ -827,7 +911,7 @@ nsInstall::ScheduleForInstall(nsInstallObject* ob)
// do any unpacking or other set-up
error = ob->Prepare();
if (error != SU_SUCCESS)
if (error != nsInstall::SUCCESS)
return error;
@ -844,7 +928,7 @@ nsInstall::ScheduleForInstall(nsInstallObject* ob)
if (ob->RegisterPackageNode())
mRegisterPackage = PR_TRUE;
return SU_SUCCESS;
return nsInstall::SUCCESS;
}
@ -853,11 +937,11 @@ void
nsInstall::ParseFlags(int flags)
{
mShowProgress = mShowFinalize = PR_TRUE;
if ((flags & SU_NO_STATUS_DLG) == SU_NO_STATUS_DLG)
if ((flags & NO_STATUS_DLG) == NO_STATUS_DLG)
{
mShowProgress = PR_FALSE;
}
if ((flags & SU_NO_FINALIZE_DLG) == SU_NO_FINALIZE_DLG)
if ((flags & NO_FINALIZE_DLG) == NO_FINALIZE_DLG)
{
mShowFinalize = PR_FALSE;
}
@ -874,14 +958,14 @@ nsInstall::SanityCheck(void)
{
if ( mPackageName == "" || mUserPackageName == "")
{
return SUERR_INSTALL_NOT_STARTED;
return INSTALL_NOT_STARTED;
}
if (mUserCancelled)
{
AbortInstall();
SaveError(SUERR_USER_CANCELLED);
return SUERR_USER_CANCELLED;
SaveError(USER_CANCELLED);
return USER_CANCELLED;
}
return 0;
@ -1039,7 +1123,7 @@ nsInstall::BadRegName(nsString* regName)
PRInt32
nsInstall::SaveError(PRInt32 errcode)
{
if ( errcode != SU_SUCCESS )
if ( errcode != nsInstall::SUCCESS )
mLastError = errcode;
return errcode;
@ -1085,7 +1169,7 @@ nsInstall::CleanUp(void)
PRInt32
nsInstall::OpenJARFile(void)
{
return SU_SUCCESS;
return nsInstall::SUCCESS;
}
void
@ -1096,107 +1180,5 @@ nsInstall::CloseJARFile(void)
PRInt32
nsInstall::ExtractDirEntries(const nsString& directory, nsVector *paths)
{
return SU_SUCCESS;
return nsInstall::SUCCESS;
}
/////////////////////////////////////////////////////////////////////////
//
/////////////////////////////////////////////////////////////////////////
static PRInt32 gInstallInstanceCnt = 0;
static PRInt32 gInstallLock = 0;
nsInstallFactory::nsInstallFactory(void)
{
mRefCnt=0;
PR_AtomicIncrement(&gInstallInstanceCnt);
}
nsInstallFactory::~nsInstallFactory(void)
{
PR_AtomicDecrement(&gInstallInstanceCnt);
}
NS_IMETHODIMP
nsInstallFactory::QueryInterface(REFNSIID aIID,void** aInstancePtr)
{
if (aInstancePtr == NULL)
{
return NS_ERROR_NULL_POINTER;
}
// Always NULL result, in case of failure
*aInstancePtr = NULL;
if ( aIID.Equals(kISupportsIID) )
{
*aInstancePtr = (void*) this;
}
else if ( aIID.Equals(kIFactoryIID) )
{
*aInstancePtr = (void*) this;
}
if (aInstancePtr == NULL)
{
return NS_ERROR_NO_INTERFACE;
}
AddRef();
return NS_OK;
}
NS_IMETHODIMP
nsInstallFactory::AddRef(void)
{
return ++mRefCnt;
}
NS_IMETHODIMP
nsInstallFactory::Release(void)
{
if (--mRefCnt ==0)
{
delete this;
return 0; // Don't access mRefCnt after deleting!
}
return mRefCnt;
}
NS_IMETHODIMP
nsInstallFactory::CreateInstance(nsISupports *aOuter, REFNSIID aIID, void **aResult)
{
if (aResult == NULL)
{
return NS_ERROR_NULL_POINTER;
}
*aResult = NULL;
/* do I have to use iSupports? */
nsInstall *inst = new nsInstall();
if (inst == NULL)
return NS_ERROR_OUT_OF_MEMORY;
nsresult result = inst->QueryInterface(aIID, aResult);
if (result != NS_OK)
delete inst;
return result;
}
NS_IMETHODIMP
nsInstallFactory::LockFactory(PRBool aLock)
{
if (aLock)
PR_AtomicIncrement(&gInstallLock);
else
PR_AtomicDecrement(&gInstallLock);
return NS_OK;
}

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

@ -3,15 +3,13 @@
#include "nscore.h"
#include "nsString.h"
#include "nsIFactory.h"
#include "nsISupports.h"
#include "nsIScriptObjectOwner.h"
#include "jsapi.h"
#include "nsFileSpec.h"
#include "nsVector.h"
#include "nsHashtable.h"
#include "nsIDOMInstall.h"
#include "nsSoftwareUpdate.h"
#include "nsInstallFolder.h"
@ -19,41 +17,80 @@
#include "nsInstallObject.h"
class nsInstall: public nsIScriptObjectOwner, public nsIDOMInstall
class nsInstall
{
public:
static const nsIID& IID() { static nsIID iid = NS_SoftwareUpdateInstall_CID; return iid; }
enum
{
BAD_PACKAGE_NAME = -200,
UNEXPECTED_ERROR = -201,
ACCESS_DENIED = -202,
TOO_MANY_CERTIFICATES = -203,
NO_INSTALLER_CERTIFICATE = -204,
NO_CERTIFICATE = -205,
NO_MATCHING_CERTIFICATE = -206,
UNKNOWN_JAR_FILE = -207,
INVALID_ARGUMENTS = -208,
ILLEGAL_RELATIVE_PATH = -209,
USER_CANCELLED = -210,
INSTALL_NOT_STARTED = -211,
SILENT_MODE_DENIED = -212,
NO_SUCH_COMPONENT = -213,
FILE_DOES_NOT_EXIST = -214,
FILE_READ_ONLY = -215,
FILE_IS_DIRECTORY = -216,
NETWORK_FILE_IS_IN_USE = -217,
APPLE_SINGLE_ERR = -218,
INVALID_PATH_ERR = -219,
PATCH_BAD_DIFF = -220,
PATCH_BAD_CHECKSUM_TARGET = -221,
PATCH_BAD_CHECKSUM_RESULT = -222,
UNINSTALL_FAILED = -223,
GESTALT_UNKNOWN_ERR = -5550,
GESTALT_INVALID_ARGUMENT = -5551,
SUCCESS = 0,
REBOOT_NEEDED = 999,
LIMITED_INSTALL = 0,
FULL_INSTALL = 1,
NO_STATUS_DLG = 2,
NO_FINALIZE_DLG = 4,
INSTALL_FILE_UNEXPECTED_MSG_ID = 0,
DETAILS_REPLACE_FILE_MSG_ID = 1,
DETAILS_INSTALL_FILE_MSG_ID = 2
};
nsInstall();
~nsInstall();
NS_DECL_ISUPPORTS
NS_IMETHOD GetScriptObject(nsIScriptContext *aContext, void** aScriptObject);
NS_IMETHOD SetScriptObject(void* aScriptObject);
PRInt32 SetScriptObject(void* aScriptObject);
NS_IMETHOD GetUserPackageName(nsString& aUserPackageName);
NS_IMETHOD GetRegPackageName(nsString& aRegPackageName);
PRInt32 GetUserPackageName(nsString& aUserPackageName);
PRInt32 GetRegPackageName(nsString& aRegPackageName);
NS_IMETHOD AbortInstall();
NS_IMETHOD AddDirectory(const nsString& aRegName, const nsString& aVersion, const nsString& aJarSource, nsIDOMInstallFolder* aFolder, const nsString& aSubdir, PRBool aForceMode, PRInt32* aReturn);
NS_IMETHOD AddSubcomponent(const nsString& aRegName, const nsString& aVersion, const nsString& aJarSource, nsIDOMInstallFolder* aFolder, const nsString& aTargetName, PRBool aForceMode, PRInt32* aReturn);
NS_IMETHOD DeleteComponent(const nsString& aRegistryName, PRInt32* aReturn);
NS_IMETHOD DeleteFile(nsIDOMInstallFolder* aFolder, const nsString& aRelativeFileName, PRInt32* aReturn);
NS_IMETHOD DiskSpaceAvailable(nsIDOMInstallFolder* aFolder, PRInt32* aReturn);
NS_IMETHOD Execute(const nsString& aJarSource, const nsString& aArgs, PRInt32* aReturn);
NS_IMETHOD FinalizeInstall(PRInt32* aReturn);
NS_IMETHOD Gestalt(const nsString& aSelector, PRInt32* aReturn);
NS_IMETHOD GetComponentFolder(const nsString& aRegName, const nsString& aSubdirectory, nsIDOMInstallFolder** aFolder);
NS_IMETHOD GetFolder(const nsString& aTargetFolder, const nsString& aSubdirectory, nsIDOMInstallFolder** aFolder);
NS_IMETHOD GetLastError(PRInt32* aReturn);
NS_IMETHOD GetWinProfile(nsIDOMInstallFolder* aFolder, const nsString& aFile, PRInt32* aReturn);
NS_IMETHOD GetWinRegistry(PRInt32* aReturn);
NS_IMETHOD Patch(const nsString& aRegName, const nsString& aVersion, const nsString& aJarSource, nsIDOMInstallFolder* aFolder, const nsString& aTargetName, PRInt32* aReturn);
NS_IMETHOD ResetError();
NS_IMETHOD SetPackageFolder(nsIDOMInstallFolder* aFolder);
NS_IMETHOD StartInstall(const nsString& aUserPackageName, const nsString& aPackageName, const nsString& aVersion, PRInt32 aFlags, PRInt32* aReturn);
NS_IMETHOD Uninstall(const nsString& aPackageName, PRInt32* aReturn);
PRInt32 AbortInstall();
PRInt32 AddDirectory(const nsString& aRegName, const nsString& aVersion, const nsString& aJarSource, nsIDOMInstallFolder* aFolder, const nsString& aSubdir, PRBool aForceMode, PRInt32* aReturn);
PRInt32 AddSubcomponent(const nsString& aRegName, const nsString& aVersion, const nsString& aJarSource, nsIDOMInstallFolder* aFolder, const nsString& aTargetName, PRBool aForceMode, PRInt32* aReturn);
PRInt32 DeleteComponent(const nsString& aRegistryName, PRInt32* aReturn);
PRInt32 DeleteFile(nsIDOMInstallFolder* aFolder, const nsString& aRelativeFileName, PRInt32* aReturn);
PRInt32 DiskSpaceAvailable(nsIDOMInstallFolder* aFolder, PRInt32* aReturn);
PRInt32 Execute(const nsString& aJarSource, const nsString& aArgs, PRInt32* aReturn);
PRInt32 FinalizeInstall(PRInt32* aReturn);
PRInt32 Gestalt(const nsString& aSelector, PRInt32* aReturn);
PRInt32 GetComponentFolder(const nsString& aComponentName, const nsString& aSubdirectory, nsIDOMInstallFolder** aFolder);
PRInt32 GetFolder(const nsString& aTargetFolder, const nsString& aSubdirectory, nsIDOMInstallFolder** aFolder);
PRInt32 GetLastError(PRInt32* aReturn);
PRInt32 GetWinProfile(nsIDOMInstallFolder* aFolder, const nsString& aFile, PRInt32* aReturn);
PRInt32 GetWinRegistry(PRInt32* aReturn);
PRInt32 Patch(const nsString& aRegName, const nsString& aVersion, const nsString& aJarSource, nsIDOMInstallFolder* aFolder, const nsString& aTargetName, PRInt32* aReturn);
PRInt32 ResetError();
PRInt32 SetPackageFolder(nsIDOMInstallFolder* aFolder);
PRInt32 StartInstall(const nsString& aUserPackageName, const nsString& aPackageName, const nsString& aVersion, PRInt32 aFlags, PRInt32* aReturn);
PRInt32 Uninstall(const nsString& aPackageName, PRInt32* aReturn);
@ -62,7 +99,7 @@ class nsInstall: public nsIScriptObjectOwner, public nsIDOMInstall
void GetPatch(nsHashKey *aKey, nsString* fileName);
private:
void *mScriptObject;
JSObject* mScriptObject;
PRBool mUserCancelled;
PRBool mShowProgress;
@ -101,22 +138,4 @@ class nsInstall: public nsIScriptObjectOwner, public nsIDOMInstall
};
class nsInstallFactory : public nsIFactory
{
public:
nsInstallFactory();
~nsInstallFactory();
NS_DECL_ISUPPORTS
NS_IMETHOD CreateInstance(nsISupports *aOuter,
REFNSIID aIID,
void **aResult);
NS_IMETHOD LockFactory(PRBool aLock);
};
#endif

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

@ -0,0 +1,235 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/*
* The contents of this file are subject to the Netscape Public License
* Version 1.0 (the "NPL"); you may not use this file except in
* compliance with the NPL. You may obtain a copy of the NPL at
* http://www.mozilla.org/NPL/
*
* Software distributed under the NPL is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
* for the specific language governing rights and limitations under the
* NPL.
*
* The Initial Developer of this code under the NPL is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
* Reserved.
*/
#include "prmem.h"
#include "nsFileSpec.h"
#include "VerReg.h"
#include "nsInstallDelete.h"
#include "nsInstall.h"
#include "nsIDOMInstallFolder.h"
#include "nsIDOMInstallVersion.h"
#include "nsInstallErrorMessages.h"
nsInstallDelete::nsInstallDelete( nsInstall* inInstall,
nsIDOMInstallFolder* folderSpec,
const nsString& inPartialPath,
PRInt32 *error)
: nsInstallObject(inInstall)
{
if ((folderSpec == NULL) || (inInstall == NULL))
{
*error = nsInstall::INVALID_ARGUMENTS;
return;
}
mDeleteStatus = DELETE_FILE;
mFinalFile = "";
mRegistryName = "";
folderSpec->MakeFullPath(inPartialPath, mFinalFile);
*error = ProcessInstallDelete();
}
nsInstallDelete::nsInstallDelete( nsInstall* inInstall,
const nsString& inComponentName,
PRInt32 *error)
: nsInstallObject(inInstall)
{
if (inInstall == NULL)
{
*error = nsInstall::INVALID_ARGUMENTS;
return;
}
mDeleteStatus = DELETE_COMPONENT;
mFinalFile = "";
mRegistryName = inComponentName;
*error = ProcessInstallDelete();
}
nsInstallDelete::~nsInstallDelete()
{
}
PRInt32 nsInstallDelete::Prepare()
{
// no set-up necessary
return nsInstall::SUCCESS;
}
PRInt32 nsInstallDelete::Complete()
{
PRInt32 err = nsInstall::SUCCESS;
if (mInstall == NULL)
return nsInstall::INVALID_ARGUMENTS;
if (mDeleteStatus == DELETE_COMPONENT)
{
char* tempString = mRegistryName.ToNewCString();
err = VR_Remove( tempString );
delete tempString;
}
if ((mDeleteStatus == DELETE_FILE) || (err == REGERR_OK))
{
err = NativeComplete();
}
else
{
err = nsInstall::UNEXPECTED_ERROR;
}
return err;
}
void nsInstallDelete::Abort()
{
}
char* nsInstallDelete::toString()
{
if (mDeleteStatus == DELETE_FILE)
{
// FIX!
// return nsInstallErrorMessages::GetString(nsInstall::DETAILS_DELETE_FILE, mFinalFile);
}
else
{
// return nsInstallErrorMessages::GetString(nsInstall::DETAILS_DELETE_COMPONENT, mRegistryName);
}
return nsnull;
}
PRBool
nsInstallDelete::CanUninstall()
{
return PR_FALSE;
}
PRBool
nsInstallDelete::RegisterPackageNode()
{
return PR_FALSE;
}
PRInt32 nsInstallDelete::ProcessInstallDelete()
{
PRInt32 err;
char* tempString;
if (mDeleteStatus == DELETE_COMPONENT)
{
/* Check if the component is in the registry */
tempString = mRegistryName.ToNewCString();
err = VR_InRegistry(tempString);
delete tempString;
if (err != REGERR_OK)
{
return err;
}
else
{
tempString = (char*)PR_Calloc(MAXREGPATHLEN, sizeof(char));
char* regTempString = mRegistryName.ToNewCString();
err = VR_GetPath( regTempString , MAXREGPATHLEN, tempString);
delete regTempString;
if (err == REGERR_OK)
{
mFinalFile.SetString(tempString);
}
PR_FREEIF(tempString);
}
}
tempString = mFinalFile.ToNewCString();
nsFileSpec file(tempString);
delete tempString;
if (file.Exists())
{
if (file.IsFile())
{
err = nsInstall::SUCCESS;
}
else
{
err = nsInstall::FILE_IS_DIRECTORY;
}
}
else
{
err = nsInstall::FILE_DOES_NOT_EXIST;
}
return err;
}
PRInt32 nsInstallDelete::NativeComplete()
{
char * tempFile = mFinalFile.ToNewCString();
nsFileSpec file(tempFile);
delete tempFile;
if (file.Exists())
{
if (file.IsFile())
{
file.Delete(false);
if (file.Exists())
{
// If file still exists, we need to delete it later!
// FIX DeleteOldFileLater( (char*)finalFile );
return nsInstall::REBOOT_NEEDED;
}
}
else
{
return nsInstall::FILE_IS_DIRECTORY;
}
}
else
{
return nsInstall::FILE_DOES_NOT_EXIST;
}
}

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

@ -0,0 +1,70 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/*
* The contents of this file are subject to the Netscape Public License
* Version 1.0 (the "NPL"); you may not use this file except in
* compliance with the NPL. You may obtain a copy of the NPL at
* http://www.mozilla.org/NPL/
*
* Software distributed under the NPL is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
* for the specific language governing rights and limitations under the
* NPL.
*
* The Initial Developer of this code under the NPL is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
* Reserved.
*/
#ifndef nsInstallDelete_h__
#define nsInstallDelete_h__
#include "prtypes.h"
#include "nsString.h"
#include "nsInstallObject.h"
#include "nsInstall.h"
#include "nsIDOMInstallFolder.h"
#define DELETE_COMPONENT 1
#define DELETE_FILE 2
class nsInstallDelete : public nsInstallObject
{
public:
nsInstallDelete( nsInstall* inInstall,
nsIDOMInstallFolder* folderSpec,
const nsString& inPartialPath,
PRInt32 *error);
nsInstallDelete( nsInstall* inInstall,
const nsString& ,
PRInt32 *error);
virtual ~nsInstallDelete();
PRInt32 Prepare();
PRInt32 Complete();
void Abort();
char* toString();
PRBool CanUninstall();
PRBool RegisterPackageNode();
private:
/* Private Fields */
nsString mFinalFile;
nsString mRegistryName;
PRInt32 mDeleteStatus;
PRInt32 ProcessInstallDelete();
PRInt32 NativeComplete();
};
#endif /* nsInstallDelete_h__ */

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

@ -0,0 +1,138 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/*
* The contents of this file are subject to the Netscape Public License
* Version 1.0 (the "NPL"); you may not use this file except in
* compliance with the NPL. You may obtain a copy of the NPL at
* http://www.mozilla.org/NPL/
*
* Software distributed under the NPL is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
* for the specific language governing rights and limitations under the
* NPL.
*
* The Initial Developer of this code under the NPL is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
* Reserved.
*/
#include "prmem.h"
#include "nsFileSpec.h"
#include "VerReg.h"
#include "nsInstallExecute.h"
#include "nsInstall.h"
#include "nsIDOMInstallFolder.h"
#include "nsIDOMInstallVersion.h"
#include "nsInstallErrorMessages.h"
nsInstallExecute:: nsInstallExecute( nsInstall* inInstall,
const nsString& inJarLocation,
const nsString& inArgs,
PRInt32 *error)
: nsInstallObject(inInstall)
{
if ((inInstall == nsnull) || (inJarLocation == "null"))
{
*error = nsInstall::INVALID_ARGUMENTS;
return;
}
mJarLocation = inJarLocation;
mArgs = inArgs;
}
nsInstallExecute::~nsInstallExecute()
{
}
PRInt32 nsInstallExecute::Prepare()
{
if (mInstall == NULL || mExecutableFile == "null" || mJarLocation == "null")
return nsInstall::INVALID_ARGUMENTS;
PRInt32 err;
mInstall->ExtractFileFromJar(mJarLocation, "", mExecutableFile, &err);
return err;
}
PRInt32 nsInstallExecute::Complete()
{
char* tempCString = mExecutableFile.ToNewCString();
nsFileSpec appPath(tempCString , false);
delete [] tempCString;
if (!appPath.Exists())
{
return nsInstall::INVALID_ARGUMENTS;
}
tempCString = mArgs.ToNewCString();
PRInt32 result = appPath.Execute(tempCString);
delete [] tempCString;
return result;
}
void nsInstallExecute::Abort()
{
char* currentName;
int result;
/* Get the names */
if (mExecutableFile == "")
return;
currentName = mExecutableFile.ToNewCString();
result = PR_Delete(currentName);
PR_ASSERT(result == 0); /* XXX: need to fe_deletefilelater() or something */
delete currentName;
}
char* nsInstallExecute::toString()
{
nsString fullPathString;
fullPathString = mJarLocation;
fullPathString += mExecutableFile;
if (mExecutableFile == "null")
{
// FIX!
// return nsInstallErrorMessages::GetString(nsInstall::DETAILS_EXECUTE_PROGRESS, fullPathString);
}
else
{
// return nsInstallErrorMessages::GetString(nsInstall::DETAILS_EXECUTE_PROGRESS2, fullPathString);
}
return nsnull;
}
PRBool
nsInstallExecute::CanUninstall()
{
return PR_FALSE;
}
PRBool
nsInstallExecute::RegisterPackageNode()
{
return PR_FALSE;
}

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

@ -0,0 +1,64 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/*
* The contents of this file are subject to the Netscape Public License
* Version 1.0 (the "NPL"); you may not use this file except in
* compliance with the NPL. You may obtain a copy of the NPL at
* http://www.mozilla.org/NPL/
*
* Software distributed under the NPL is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
* for the specific language governing rights and limitations under the
* NPL.
*
* The Initial Developer of this code under the NPL is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
* Reserved.
*/
#ifndef nsInstallExecute_h__
#define nsInstallExecute_h__
#include "prtypes.h"
#include "nsString.h"
#include "nsInstallObject.h"
#include "nsInstall.h"
#include "nsIDOMInstallFolder.h"
#include "nsIDOMInstallVersion.h"
class nsInstallExecute : public nsInstallObject
{
public:
nsInstallExecute( nsInstall* inInstall,
const nsString& inJarLocation,
const nsString& inArgs,
PRInt32 *error);
virtual ~nsInstallExecute();
PRInt32 Prepare();
PRInt32 Complete();
void Abort();
char* toString();
PRBool CanUninstall();
PRBool RegisterPackageNode();
private:
nsString mJarLocation; // Location in the JAR
nsString mExecutableFile; // temporary file location
nsString mArgs; // command line arguments
PRInt32 NativeComplete(void);
void NativeAbort(void);
};
#endif /* nsInstallExecute_h__ */

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

@ -76,7 +76,7 @@ nsInstallFile::nsInstallFile(nsInstall* inInstall,
if ((folderSpec == NULL) || (inInstall == NULL) || (inVInfo == NULL))
{
*error = nsIDOMInstall::SUERR_INVALID_ARGUMENTS;
*error = nsInstall::INVALID_ARGUMENTS;
return;
}
@ -136,7 +136,7 @@ nsInstallFile::~nsInstallFile()
PRInt32 nsInstallFile::Prepare()
{
if (mInstall == NULL || mFinalFile == NULL || mJarLocation == NULL)
return nsIDOMInstall::SUERR_INVALID_ARGUMENTS;
return nsInstall::INVALID_ARGUMENTS;
PRInt32 err;
mInstall->ExtractFileFromJar(*mJarLocation, *mFinalFile, *mTempFile, &err);
@ -157,7 +157,7 @@ PRInt32 nsInstallFile::Complete()
if (mInstall == NULL || mVersionRegistryName == NULL || mFinalFile == NULL)
{
return nsIDOMInstall::SUERR_INVALID_ARGUMENTS;
return nsInstall::INVALID_ARGUMENTS;
}
/* Check the security for our target */
@ -187,7 +187,7 @@ PRInt32 nsInstallFile::Complete()
// Register file and log for Uninstall
if ( 0 == err || nsIDOMInstall::SU_REBOOT_NEEDED == err )
if ( 0 == err || nsInstall::REBOOT_NEEDED == err )
{
// we ignore all registry errors because they're not
// important enough to abort an otherwise OK install.
@ -291,9 +291,9 @@ PRInt32 nsInstallFile::Complete()
delete final_file;
if ( err != 0 )
return nsIDOMInstall::SUERR_UNEXPECTED_ERROR;
return nsInstall::UNEXPECTED_ERROR;
return nsIDOMInstall::SU_SUCCESS;
return nsInstall::SUCCESS;
}
void nsInstallFile::Abort()
@ -315,11 +315,11 @@ char* nsInstallFile::toString()
{
if (mReplaceFile)
{
return nsInstallErrorMessages::GetString(nsIDOMInstall::SU_DETAILS_REPLACE_FILE_MSG_ID, mFinalFile);
return nsInstallErrorMessages::GetString(nsInstall::DETAILS_REPLACE_FILE_MSG_ID, mFinalFile);
}
else
{
return nsInstallErrorMessages::GetString(nsIDOMInstall::SU_DETAILS_INSTALL_FILE_MSG_ID, mFinalFile);
return nsInstallErrorMessages::GetString(nsInstall::DETAILS_INSTALL_FILE_MSG_ID, mFinalFile);
}
}
@ -382,7 +382,7 @@ int nsInstallFile::NativeComplete()
{
/* File already exists, need to remove the original */
// FIX result = FE_ReplaceExistingFile(currentName, xpURL, finalName, xpURL, mForceInstall);
if ( result == nsIDOMInstall::SU_REBOOT_NEEDED )
if ( result == nsInstall::REBOOT_NEEDED )
{
}
}
@ -397,9 +397,9 @@ int nsInstallFile::NativeComplete()
{
end[0] = 0;
// Lame use of nsNativeFileSpec, but NSPR does not support creation
// Lame use of nsFileSpec, but NSPR does not support creation
// of nested directories.
nsNativeFileSpec* directoryMaker = new nsNativeFileSpec(finalName, PR_TRUE);
nsFileSpec* directoryMaker = new nsFileSpec(finalName, PR_TRUE);
delete directoryMaker;
end[0] = separator;

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

@ -61,12 +61,12 @@ static NS_DEFINE_IID(kIInstallFolder_IID, NS_IDOMINSTALLFOLDER_IID);
#endif
#endif
typedef enum su_SecurityLevel {
typedef enum SecurityLevel {
eOneFolderAccess,
eAllFolderAccess
} su_SecurityLevel;
} SecurityLevel;
struct su_DirectoryTable
struct DirectoryTable
{
char * directoryName; /* The formal directory name */
PRInt32 folderEnum; /* Directory ID */
@ -80,7 +80,7 @@ struct su_DirectoryTable
* DirectoryTable holds the info about built-in directories:
* Text name, security level, enum
*/
struct su_DirectoryTable DirectoryTable[] =
struct DirectoryTable DirectoryTable[] =
{
{"Plugins", nsIDOMInstallFolder::PluginFolder, PR_TRUE},
{"Program", nsIDOMInstallFolder::ProgramFolder, PR_FALSE},
@ -205,7 +205,7 @@ nsInstallFolder::Init(const nsString& aFolderID, const nsString& aVrPatch, const
{
/* Since urlPath is set to NULL, this FolderSpec is essentially the error message */
if ( aFolderID == "null" || aVrPatch == "null" || aPackageName == "null")
if ( aFolderID == "null" || aPackageName == "null")
{
return NS_OK; // should we stop the script?
}

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

@ -0,0 +1,344 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/*
* The contents of this file are subject to the Netscape Public License
* Version 1.0 (the "NPL"); you may not use this file except in
* compliance with the NPL. You may obtain a copy of the NPL at
* http://www.mozilla.org/NPL/
*
* Software distributed under the NPL is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
* for the specific language governing rights and limitations under the
* NPL.
*
* The Initial Developer of this code under the NPL is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
* Reserved.
*/
#include "prmem.h"
#include "nsCRT.h"
#include "nsFileSpec.h"
#include "VerReg.h"
#include "nsInstallPatch.h"
#include "nsInstall.h"
#include "nsIDOMInstallFolder.h"
#include "nsIDOMInstallVersion.h"
#include "nsInstallErrorMessages.h"
nsInstallPatch::nsInstallPatch( nsInstall* inInstall,
const nsString& inVRName,
nsIDOMInstallVersion* inVInfo,
const nsString& inJarLocation,
PRInt32 *error)
: nsInstallObject(inInstall)
{
if ((inInstall == nsnull) || (inVRName == "null") || (inJarLocation == "null"))
{
*error = nsInstall::INVALID_ARGUMENTS;
return;
}
mRegistryName = inVRName;
mVersionInfo = inVInfo; /* Who owns this object? May be we should make a copy of it */
mJarLocation = inJarLocation;
mPatchFile = "";
mTargetFile = "";
mPatchedFile = "";
char* tempTargetFile = (char*) PR_MALLOC(MAXREGPATHLEN);
char* tempVRName = inVRName.ToNewCString();
PRInt32 err = VR_GetPath( tempVRName, MAXREGPATHLEN, tempTargetFile );
if (err != REGERR_OK)
{
PR_FREEIF(tempTargetFile);
*error = nsInstall::NO_SUCH_COMPONENT;
return;
}
mTargetFile.SetString(tempTargetFile);
delete tempVRName;
delete tempTargetFile;
*error = nsInstall::SUCCESS;
}
nsInstallPatch::nsInstallPatch( nsInstall* inInstall,
const nsString& inVRName,
nsIDOMInstallVersion* inVInfo,
const nsString& inJarLocation,
nsIDOMInstallFolder* folderSpec,
const nsString& inPartialPath,
PRInt32 *error)
: nsInstallObject(inInstall)
{
if ((inInstall == nsnull) || (inVRName == "null") || (inJarLocation == "null"))
{
*error = nsInstall::INVALID_ARGUMENTS;
return;
}
mRegistryName = inVRName;
mVersionInfo = inVInfo; /* Who owns this object? May be we should make a copy of it */
mJarLocation = inJarLocation;
mPatchFile = "";
mPatchedFile = "";
folderSpec->MakeFullPath(inPartialPath, mTargetFile);
}
nsInstallPatch::~nsInstallPatch()
{
}
PRInt32 nsInstallPatch::Prepare()
{
PRInt32 err;
PRBool deleteOldSrc;
char *tempString = mTargetFile.ToNewCString();
nsFileSpec file(tempString);
delete tempString;
if (file.Exists())
{
if (file.IsFile())
{
err = nsInstall::SUCCESS;
}
else
{
err = nsInstall::FILE_IS_DIRECTORY;
}
}
else
{
err = nsInstall::FILE_DOES_NOT_EXIST;
}
if (err != nsInstall::SUCCESS)
{
return err;
}
mInstall->ExtractFileFromJar(mJarLocation, mTargetFile, mPatchFile, &err);
nsString *fileName = nsnull;
nsVoidKey ikey( (void*) nsCRT::HashValue( mTargetFile.GetUnicode() ) );
mInstall->GetPatch(&ikey, fileName);
if (fileName != nsnull)
{
deleteOldSrc = PR_TRUE;
}
else
{
fileName = new nsString(mTargetFile);
deleteOldSrc = PR_FALSE;
}
err = NativePatch( *fileName, mPatchFile, mPatchedFile);
if (err != nsInstall::SUCCESS)
{
return err;
}
if ( mPatchedFile != "" )
{
mInstall->AddPatch(&ikey, &mPatchedFile );
}
else
{
// This is a wierd state. NativePatch should have generated an error here. Is there any
// reason why we return a Invalid_Arg error here?
err = nsInstall::INVALID_ARGUMENTS;
}
if ( deleteOldSrc )
{
NativeDeleteFile( *fileName );
}
return err;
}
PRInt32 nsInstallPatch::Complete()
{
if ((mInstall == nsnull) || (mVersionInfo == nsnull) || (mPatchedFile == "") || (mTargetFile == ""))
{
return nsInstall::INVALID_ARGUMENTS;
}
PRInt32 err = nsInstall::SUCCESS;
nsString *fileName = nsnull;
nsVoidKey ikey( (void*) nsCRT::HashValue( mTargetFile.GetUnicode() ) );
mInstall->GetPatch(&ikey, fileName);
if (fileName != nsnull && fileName->Equals(mPatchedFile) )
{
// the patch has not been superceded--do final replacement
err = NativeReplace( mTargetFile, mPatchedFile );
if ( 0 == err || nsInstall::REBOOT_NEEDED == err )
{
// WHY DO nsString suck so bad!
char* tempVRString = mRegistryName.ToNewCString();
char* tempTargetFile = mTargetFile.ToNewCString();
nsString tempString;
mVersionInfo->ToString(tempString);
char* tempVersion = tempString.ToNewCString();
err = VR_Install( tempVRString, tempTargetFile, tempVersion, PR_FALSE );
delete tempVRString;
delete tempTargetFile;
delete tempVersion;
}
else
{
err = nsInstall::UNEXPECTED_ERROR;
}
}
else
{
// nothing -- old intermediate patched file was
// deleted by a superceding patch
}
return err;
}
void nsInstallPatch::Abort()
{
nsString *fileName = nsnull;
nsVoidKey ikey( (void*) nsCRT::HashValue( mTargetFile.GetUnicode() ) );
mInstall->GetPatch(&ikey, fileName);
if (fileName != nsnull && fileName->Equals(mPatchedFile) )
{
NativeDeleteFile( mPatchedFile );
}
}
char* nsInstallPatch::toString()
{
//return GetString1(DETAILS_PATCH, targetfile);
return nsnull;
}
PRBool
nsInstallPatch::CanUninstall()
{
return PR_FALSE;
}
PRBool
nsInstallPatch::RegisterPackageNode()
{
return PR_FALSE;
}
PRInt32
nsInstallPatch::NativePatch(const nsString &sourceFile, const nsString &patchfile, nsString &newFile)
{
return -1;
}
PRInt32
nsInstallPatch::NativeDeleteFile(const nsString& doomedFile)
{
char * tempFile = doomedFile.ToNewCString();
nsFileSpec file(tempFile);
delete tempFile;
if (file.Exists())
{
if (file.IsFile())
{
file.Delete(false);
if (file.Exists())
{
// If file still exists, we need to delete it later!
// FIX DeleteOldFileLater( (char*)finalFile );
return nsInstall::REBOOT_NEEDED;
}
}
else
{
return nsInstall::FILE_IS_DIRECTORY;
}
}
else
{
return nsInstall::FILE_DOES_NOT_EXIST;
}
}
PRInt32
nsInstallPatch::NativeReplace(const nsString& oldfile, nsString& newFile)
{
char *tempString = oldfile.ToNewCString();
nsFileSpec file(tempString);
delete tempString;
if (file.Exists() && (! file.IsFile()) )
return nsInstall::FILE_IS_DIRECTORY;
file.Delete(PR_FALSE);
if (file.Exists())
{
//FIX: FE_ReplaceExistingFile
}
nsFileSpec parentDirectory;
file.GetParent(parentDirectory);
if (parentDirectory.Exists() && parentDirectory.IsDirectory())
{
char* currentName = oldfile.ToNewCString();
char* finalName = newFile.ToNewCString();
// FIX - this may not work on UNIX between different
// filesystems!
PRInt32 result = PR_Rename(currentName, finalName);
delete currentName;
delete finalName;
if (result != 0)
{
return nsInstall::UNEXPECTED_ERROR;
}
}
return nsInstall::SUCCESS;
}

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

@ -0,0 +1,76 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/*
* The contents of this file are subject to the Netscape Public License
* Version 1.0 (the "NPL"); you may not use this file except in
* compliance with the NPL. You may obtain a copy of the NPL at
* http://www.mozilla.org/NPL/
*
* Software distributed under the NPL is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
* for the specific language governing rights and limitations under the
* NPL.
*
* The Initial Developer of this code under the NPL is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
* Reserved.
*/
#ifndef nsInstallPatch_h__
#define nsInstallPatch_h__
#include "prtypes.h"
#include "nsString.h"
#include "nsInstallObject.h"
#include "nsInstall.h"
#include "nsIDOMInstallFolder.h"
#include "nsIDOMInstallVersion.h"
class nsInstallPatch : public nsInstallObject
{
public:
nsInstallPatch( nsInstall* inInstall,
const nsString& inVRName,
nsIDOMInstallVersion* inVInfo,
const nsString& inJarLocation,
nsIDOMInstallFolder* folderSpec,
const nsString& inPartialPath,
PRInt32 *error);
nsInstallPatch( nsInstall* inInstall,
const nsString& inVRName,
nsIDOMInstallVersion* inVInfo,
const nsString& inJarLocation,
PRInt32 *error);
virtual ~nsInstallPatch();
PRInt32 Prepare();
PRInt32 Complete();
void Abort();
char* toString();
PRBool CanUninstall();
PRBool RegisterPackageNode();
private:
nsString mRegistryName;
nsIDOMInstallVersion* mVersionInfo;
nsString mJarLocation;
nsString mPatchFile;
nsString mTargetFile;
nsString mPatchedFile;
PRInt32 NativePatch(const nsString &sourceFile, const nsString &patchfile, nsString &newFile);
PRInt32 NativeReplace (const nsString& target, nsString& tempFile);
PRInt32 NativeDeleteFile(const nsString& doomedFile);
};
#endif /* nsInstallPatch_h__ */

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

@ -128,7 +128,7 @@ nsInstallTrigger::StartSoftwareUpdate(const nsString& aURL, PRInt32* aReturn)
{
nsString location = "C:\\temp\\test.jar";
*aReturn = su_DownloadJar(aURL, location);
*aReturn = DownloadJar(aURL, location);
return NS_OK;
}

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

@ -233,26 +233,26 @@ nsInstallVersion::CompareTo(PRInt32 aMajor, PRInt32 aMinor, PRInt32 aRelease, PR
if ( release == aRelease )
{
if ( build == aBuild )
diff = SU_EQUAL;
diff = EQUAL;
else if ( build > aBuild )
diff = SU_BLD_DIFF;
diff = BLD_DIFF;
else
diff = SU_BLD_DIFF_MINUS;
diff = BLD_DIFF_MINUS;
}
else if ( release > aRelease )
diff = SU_REL_DIFF;
diff = REL_DIFF;
else
diff = SU_REL_DIFF_MINUS;
diff = REL_DIFF_MINUS;
}
else if ( minor > aMinor )
diff = SU_MINOR_DIFF;
diff = MINOR_DIFF;
else
diff = SU_MINOR_DIFF_MINUS;
diff = MINOR_DIFF_MINUS;
}
else if ( major > aMajor )
diff = SU_MAJOR_DIFF;
diff = MAJOR_DIFF;
else
diff = SU_MAJOR_DIFF_MINUS;
diff = MAJOR_DIFF_MINUS;
*aReturn = diff;

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

@ -15,7 +15,6 @@
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
* Reserved.
*/
/* AUTO-GENERATED. DO NOT EDIT!!! */
#include "jsapi.h"
#include "nsJSUtils.h"
@ -26,28 +25,25 @@
#include "nsIScriptGlobalObject.h"
#include "nsIPtr.h"
#include "nsString.h"
#include "nsIDOMInstall.h"
#include "nsInstall.h"
#include "nsIDOMInstallFolder.h"
#include "nsIScriptNameSpaceManager.h"
#include "nsRepository.h"
#include "nsDOMCID.h"
static NS_DEFINE_IID(kIScriptObjectOwnerIID, NS_ISCRIPTOBJECTOWNER_IID);
static NS_DEFINE_IID(kIJSScriptObjectIID, NS_IJSSCRIPTOBJECT_IID);
static NS_DEFINE_IID(kIScriptGlobalObjectIID, NS_ISCRIPTGLOBALOBJECT_IID);
static NS_DEFINE_IID(kIInstallIID, NS_IDOMINSTALL_IID);
static NS_DEFINE_IID(kIInstallFolderIID, NS_IDOMINSTALLFOLDER_IID);
NS_DEF_PTR(nsIDOMInstall);
NS_DEF_PTR(nsIDOMInstallFolder);
//
// Install property ids
//
enum Install_slots {
enum Install_slots
{
INSTALL_USERPACKAGENAME = -1,
INSTALL_REGPACKAGENAME = -2
INSTALL_REGPACKAGENAME = -2,
INSTALL_SILENT = -3,
INSTALL_JARFILE = -4,
INSTALL_FORCE = -5,
INSTALL_ARGUMENTS = -6
};
/***********************************************************************/
@ -57,14 +53,15 @@ enum Install_slots {
PR_STATIC_CALLBACK(JSBool)
GetInstallProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp)
{
nsIDOMInstall *a = (nsIDOMInstall*)JS_GetPrivate(cx, obj);
nsInstall *a = (nsInstall*)JS_GetPrivate(cx, obj);
// If there's no private data, this must be the prototype, so ignore
if (nsnull == a) {
return JS_TRUE;
}
if (JSVAL_IS_INT(id)) {
if (JSVAL_IS_INT(id))
{
switch(JSVAL_TO_INT(id)) {
case INSTALL_USERPACKAGENAME:
{
@ -73,7 +70,7 @@ GetInstallProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp)
nsJSUtils::nsConvertStringToJSVal(prop, cx, vp);
}
else {
return JS_FALSE;
return JS_TRUE;
}
break;
}
@ -84,16 +81,16 @@ GetInstallProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp)
nsJSUtils::nsConvertStringToJSVal(prop, cx, vp);
}
else {
return JS_FALSE;
return JS_TRUE;
}
break;
}
default:
return nsJSUtils::nsCallJSScriptObjectGetProperty(a, cx, id, vp);
return JS_TRUE;
}
}
else {
return nsJSUtils::nsCallJSScriptObjectGetProperty(a, cx, id, vp);
return JS_TRUE;
}
return PR_TRUE;
@ -106,7 +103,7 @@ GetInstallProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp)
PR_STATIC_CALLBACK(JSBool)
SetInstallProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp)
{
nsIDOMInstall *a = (nsIDOMInstall*)JS_GetPrivate(cx, obj);
nsInstall *a = (nsInstall*)JS_GetPrivate(cx, obj);
// If there's no private data, this must be the prototype, so ignore
if (nsnull == a) {
@ -117,11 +114,11 @@ SetInstallProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp)
switch(JSVAL_TO_INT(id)) {
case 0:
default:
return nsJSUtils::nsCallJSScriptObjectSetProperty(a, cx, id, vp);
return JS_TRUE;
}
}
else {
return nsJSUtils::nsCallJSScriptObjectSetProperty(a, cx, id, vp);
return JS_TRUE;
}
return PR_TRUE;
@ -164,7 +161,7 @@ ResolveInstall(JSContext *cx, JSObject *obj, jsval id)
PR_STATIC_CALLBACK(JSBool)
InstallAbortInstall(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
{
nsIDOMInstall *nativeThis = (nsIDOMInstall*)JS_GetPrivate(cx, obj);
nsInstall *nativeThis = (nsInstall*)JS_GetPrivate(cx, obj);
JSBool rBool = JS_FALSE;
*rval = JSVAL_NULL;
@ -197,7 +194,7 @@ InstallAbortInstall(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval
PR_STATIC_CALLBACK(JSBool)
InstallAddDirectory(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
{
nsIDOMInstall *nativeThis = (nsIDOMInstall*)JS_GetPrivate(cx, obj);
nsInstall *nativeThis = (nsInstall*)JS_GetPrivate(cx, obj);
JSBool rBool = JS_FALSE;
PRInt32 nativeRet;
nsAutoString b0;
@ -257,7 +254,7 @@ InstallAddDirectory(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval
PR_STATIC_CALLBACK(JSBool)
InstallAddSubcomponent(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
{
nsIDOMInstall *nativeThis = (nsIDOMInstall*)JS_GetPrivate(cx, obj);
nsInstall *nativeThis = (nsInstall*)JS_GetPrivate(cx, obj);
JSBool rBool = JS_FALSE;
PRInt32 nativeRet;
nsAutoString b0;
@ -317,7 +314,7 @@ InstallAddSubcomponent(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, js
PR_STATIC_CALLBACK(JSBool)
InstallDeleteComponent(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
{
nsIDOMInstall *nativeThis = (nsIDOMInstall*)JS_GetPrivate(cx, obj);
nsInstall *nativeThis = (nsInstall*)JS_GetPrivate(cx, obj);
JSBool rBool = JS_FALSE;
PRInt32 nativeRet;
nsAutoString b0;
@ -354,7 +351,7 @@ InstallDeleteComponent(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, js
PR_STATIC_CALLBACK(JSBool)
InstallDeleteFile(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
{
nsIDOMInstall *nativeThis = (nsIDOMInstall*)JS_GetPrivate(cx, obj);
nsInstall *nativeThis = (nsInstall*)JS_GetPrivate(cx, obj);
JSBool rBool = JS_FALSE;
PRInt32 nativeRet;
nsIDOMInstallFolderPtr b0;
@ -400,7 +397,7 @@ InstallDeleteFile(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *
PR_STATIC_CALLBACK(JSBool)
InstallDiskSpaceAvailable(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
{
nsIDOMInstall *nativeThis = (nsIDOMInstall*)JS_GetPrivate(cx, obj);
nsInstall *nativeThis = (nsInstall*)JS_GetPrivate(cx, obj);
JSBool rBool = JS_FALSE;
PRInt32 nativeRet;
nsIDOMInstallFolderPtr b0;
@ -443,7 +440,7 @@ InstallDiskSpaceAvailable(JSContext *cx, JSObject *obj, uintN argc, jsval *argv,
PR_STATIC_CALLBACK(JSBool)
InstallExecute(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
{
nsIDOMInstall *nativeThis = (nsIDOMInstall*)JS_GetPrivate(cx, obj);
nsInstall *nativeThis = (nsInstall*)JS_GetPrivate(cx, obj);
JSBool rBool = JS_FALSE;
PRInt32 nativeRet;
nsAutoString b0;
@ -483,7 +480,7 @@ InstallExecute(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rva
PR_STATIC_CALLBACK(JSBool)
InstallFinalizeInstall(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
{
nsIDOMInstall *nativeThis = (nsIDOMInstall*)JS_GetPrivate(cx, obj);
nsInstall *nativeThis = (nsInstall*)JS_GetPrivate(cx, obj);
JSBool rBool = JS_FALSE;
PRInt32 nativeRet;
@ -517,7 +514,7 @@ InstallFinalizeInstall(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, js
PR_STATIC_CALLBACK(JSBool)
InstallGestalt(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
{
nsIDOMInstall *nativeThis = (nsIDOMInstall*)JS_GetPrivate(cx, obj);
nsInstall *nativeThis = (nsInstall*)JS_GetPrivate(cx, obj);
JSBool rBool = JS_FALSE;
PRInt32 nativeRet;
nsAutoString b0;
@ -554,7 +551,7 @@ InstallGestalt(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rva
PR_STATIC_CALLBACK(JSBool)
InstallGetComponentFolder(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
{
nsIDOMInstall *nativeThis = (nsIDOMInstall*)JS_GetPrivate(cx, obj);
nsInstall *nativeThis = (nsInstall*)JS_GetPrivate(cx, obj);
JSBool rBool = JS_FALSE;
nsIDOMInstallFolder* nativeRet;
nsAutoString b0;
@ -594,7 +591,7 @@ InstallGetComponentFolder(JSContext *cx, JSObject *obj, uintN argc, jsval *argv,
PR_STATIC_CALLBACK(JSBool)
InstallGetFolder(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
{
nsIDOMInstall *nativeThis = (nsIDOMInstall*)JS_GetPrivate(cx, obj);
nsInstall *nativeThis = (nsInstall*)JS_GetPrivate(cx, obj);
JSBool rBool = JS_FALSE;
nsIDOMInstallFolder* nativeRet;
nsAutoString b0;
@ -634,7 +631,7 @@ InstallGetFolder(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *r
PR_STATIC_CALLBACK(JSBool)
InstallGetLastError(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
{
nsIDOMInstall *nativeThis = (nsIDOMInstall*)JS_GetPrivate(cx, obj);
nsInstall *nativeThis = (nsInstall*)JS_GetPrivate(cx, obj);
JSBool rBool = JS_FALSE;
PRInt32 nativeRet;
@ -668,7 +665,7 @@ InstallGetLastError(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval
PR_STATIC_CALLBACK(JSBool)
InstallGetWinProfile(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
{
nsIDOMInstall *nativeThis = (nsIDOMInstall*)JS_GetPrivate(cx, obj);
nsInstall *nativeThis = (nsInstall*)JS_GetPrivate(cx, obj);
JSBool rBool = JS_FALSE;
PRInt32 nativeRet;
nsIDOMInstallFolderPtr b0;
@ -714,7 +711,7 @@ InstallGetWinProfile(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsva
PR_STATIC_CALLBACK(JSBool)
InstallGetWinRegistry(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
{
nsIDOMInstall *nativeThis = (nsIDOMInstall*)JS_GetPrivate(cx, obj);
nsInstall *nativeThis = (nsInstall*)JS_GetPrivate(cx, obj);
JSBool rBool = JS_FALSE;
PRInt32 nativeRet;
@ -748,7 +745,7 @@ InstallGetWinRegistry(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsv
PR_STATIC_CALLBACK(JSBool)
InstallPatch(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
{
nsIDOMInstall *nativeThis = (nsIDOMInstall*)JS_GetPrivate(cx, obj);
nsInstall *nativeThis = (nsInstall*)JS_GetPrivate(cx, obj);
JSBool rBool = JS_FALSE;
PRInt32 nativeRet;
nsAutoString b0;
@ -803,7 +800,7 @@ InstallPatch(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
PR_STATIC_CALLBACK(JSBool)
InstallResetError(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
{
nsIDOMInstall *nativeThis = (nsIDOMInstall*)JS_GetPrivate(cx, obj);
nsInstall *nativeThis = (nsInstall*)JS_GetPrivate(cx, obj);
JSBool rBool = JS_FALSE;
*rval = JSVAL_NULL;
@ -836,7 +833,7 @@ InstallResetError(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *
PR_STATIC_CALLBACK(JSBool)
InstallSetPackageFolder(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
{
nsIDOMInstall *nativeThis = (nsIDOMInstall*)JS_GetPrivate(cx, obj);
nsInstall *nativeThis = (nsInstall*)JS_GetPrivate(cx, obj);
JSBool rBool = JS_FALSE;
nsIDOMInstallFolderPtr b0;
@ -878,7 +875,7 @@ InstallSetPackageFolder(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, j
PR_STATIC_CALLBACK(JSBool)
InstallStartInstall(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
{
nsIDOMInstall *nativeThis = (nsIDOMInstall*)JS_GetPrivate(cx, obj);
nsInstall *nativeThis = (nsInstall*)JS_GetPrivate(cx, obj);
JSBool rBool = JS_FALSE;
PRInt32 nativeRet;
nsAutoString b0;
@ -927,7 +924,7 @@ InstallStartInstall(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval
PR_STATIC_CALLBACK(JSBool)
InstallUninstall(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
{
nsIDOMInstall *nativeThis = (nsIDOMInstall*)JS_GetPrivate(cx, obj);
nsInstall *nativeThis = (nsInstall*)JS_GetPrivate(cx, obj);
JSBool rBool = JS_FALSE;
PRInt32 nativeRet;
nsAutoString b0;
@ -981,36 +978,76 @@ JSClass InstallClass = {
//
static JSPropertySpec InstallProperties[] =
{
{"UserPackageName", INSTALL_USERPACKAGENAME, JSPROP_ENUMERATE | JSPROP_READONLY},
{"RegPackageName", INSTALL_REGPACKAGENAME, JSPROP_ENUMERATE | JSPROP_READONLY},
{"userPackageName", INSTALL_USERPACKAGENAME, JSPROP_ENUMERATE | JSPROP_READONLY},
{"regPackageName", INSTALL_REGPACKAGENAME, JSPROP_ENUMERATE | JSPROP_READONLY},
{"silent", INSTALL_SILENT, JSPROP_ENUMERATE | JSPROP_READONLY},
{"force", INSTALL_FORCE, JSPROP_ENUMERATE | JSPROP_READONLY},
{"jarfile", INSTALL_JARFILE, JSPROP_ENUMERATE | JSPROP_READONLY},
{"arguments", INSTALL_ARGUMENTS, JSPROP_ENUMERATE | JSPROP_READONLY},
{0}
};
static JSConstDoubleSpec install_constants[] =
{
{ nsInstall::BAD_PACKAGE_NAME, "BAD_PACKAGE_NAME" },
{ nsInstall::UNEXPECTED_ERROR, "UNEXPECTED_ERROR" },
{ nsInstall::ACCESS_DENIED, "ACCESS_DENIED" },
{ nsInstall::NO_INSTALLER_CERTIFICATE, "NO_INSTALLER_CERTIFICATE" },
{ nsInstall::NO_CERTIFICATE, "NO_CERTIFICATE" },
{ nsInstall::NO_MATCHING_CERTIFICATE, "NO_MATCHING_CERTIFICATE" },
{ nsInstall::UNKNOWN_JAR_FILE, "UNKNOWN_JAR_FILE" },
{ nsInstall::INVALID_ARGUMENTS, "INVALID_ARGUMENTS" },
{ nsInstall::ILLEGAL_RELATIVE_PATH, "ILLEGAL_RELATIVE_PATH" },
{ nsInstall::USER_CANCELLED, "USER_CANCELLED" },
{ nsInstall::INSTALL_NOT_STARTED, "INSTALL_NOT_STARTED" },
{ nsInstall::SILENT_MODE_DENIED, "SILENT_MODE_DENIED" },
{ nsInstall::FILE_DOES_NOT_EXIST, "FILE_DOES_NOT_EXIST" },
{ nsInstall::FILE_READ_ONLY, "FILE_READ_ONLY" },
{ nsInstall::FILE_IS_DIRECTORY, "FILE_IS_DIRECTORY" },
{ nsInstall::NETWORK_FILE_IS_IN_USE, "NETWORK_FILE_IS_IN_USE" },
{ nsInstall::APPLE_SINGLE_ERR, "APPLE_SINGLE_ERR" },
{ nsInstall::INVALID_PATH_ERR, "INVALID_PATH_ERR" },
{ nsInstall::PATCH_BAD_DIFF, "PATCH_BAD_DIFF" },
{ nsInstall::PATCH_BAD_CHECKSUM_TARGET, "PATCH_BAD_CHECKSUM_TARGET" },
{ nsInstall::PATCH_BAD_CHECKSUM_RESULT, "PATCH_BAD_CHECKSUM_RESULT" },
{ nsInstall::UNINSTALL_FAILED, "UNINSTALL_FAILED" },
{ nsInstall::GESTALT_UNKNOWN_ERR, "GESTALT_UNKNOWN_ERR" },
{ nsInstall::GESTALT_INVALID_ARGUMENT, "GESTALT_INVALID_ARGUMENT" },
{ nsInstall::SUCCESS, "SUCCESS" },
{ nsInstall::REBOOT_NEEDED, "REBOOT_NEEDED" },
{ nsInstall::LIMITED_INSTALL, "LIMITED_INSTALL" },
{ nsInstall::FULL_INSTALL, "FULL_INSTALL" },
{ nsInstall::NO_STATUS_DLG , "NO_STATUS_DLG" },
{ nsInstall::NO_FINALIZE_DLG, "NO_FINALIZE_DLG" },
{0}
};
//
// Install class methods
//
static JSFunctionSpec InstallMethods[] =
{
{"AbortInstall", InstallAbortInstall, 0},
{"AddDirectory", InstallAddDirectory, 6},
{"AddSubcomponent", InstallAddSubcomponent, 6},
{"DeleteComponent", InstallDeleteComponent, 1},
{"DeleteFile", InstallDeleteFile, 2},
{"DiskSpaceAvailable", InstallDiskSpaceAvailable, 1},
{"Execute", InstallExecute, 2},
{"FinalizeInstall", InstallFinalizeInstall, 0},
{"Gestalt", InstallGestalt, 1},
{"GetComponentFolder", InstallGetComponentFolder, 2},
{"GetFolder", InstallGetFolder, 2},
{"GetLastError", InstallGetLastError, 0},
{"GetWinProfile", InstallGetWinProfile, 2},
{"GetWinRegistry", InstallGetWinRegistry, 0},
{"Patch", InstallPatch, 5},
{"ResetError", InstallResetError, 0},
{"SetPackageFolder", InstallSetPackageFolder, 1},
{"StartInstall", InstallStartInstall, 4},
{"Uninstall", InstallUninstall, 1},
{"AbortInstall", InstallAbortInstall, 0},
{"AddDirectory", InstallAddDirectory, 6},
{"AddSubcomponent", InstallAddSubcomponent, 6},
{"DeleteComponent", InstallDeleteComponent, 1},
{"DeleteFile", InstallDeleteFile, 2},
{"DiskSpaceAvailable", InstallDiskSpaceAvailable, 1},
{"Execute", InstallExecute, 2},
{"FinalizeInstall", InstallFinalizeInstall, 0},
{"Gestalt", InstallGestalt, 1},
{"GetComponentFolder", InstallGetComponentFolder, 2},
{"GetFolder", InstallGetFolder, 2},
{"GetLastError", InstallGetLastError, 0},
{"GetWinProfile", InstallGetWinProfile, 2},
{"GetWinRegistry", InstallGetWinRegistry, 0},
{"Patch", InstallPatch, 5},
{"ResetError", InstallResetError, 0},
{"SetPackageFolder", InstallSetPackageFolder, 1},
{"StartInstall", InstallStartInstall, 4},
{"Uninstall", InstallUninstall, 1},
{0}
};
@ -1021,252 +1058,45 @@ static JSFunctionSpec InstallMethods[] =
PR_STATIC_CALLBACK(JSBool)
Install(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
{
nsresult result;
nsIID classID;
nsIScriptContext* context = (nsIScriptContext*)JS_GetContextPrivate(cx);
nsIScriptNameSpaceManager* manager;
nsIDOMInstall *nativeThis;
nsIScriptObjectOwner *owner = nsnull;
static NS_DEFINE_IID(kIDOMInstallIID, NS_IDOMINSTALL_IID);
result = context->GetNameSpaceManager(&manager);
if (NS_OK != result) {
return JS_FALSE;
}
result = manager->LookupName("Install", PR_TRUE, classID);
NS_RELEASE(manager);
if (NS_OK != result) {
return JS_FALSE;
}
result = nsRepository::CreateInstance(classID,
nsnull,
kIDOMInstallIID,
(void **)&nativeThis);
if (NS_OK != result) {
return JS_FALSE;
}
// XXX We should be calling Init() on the instance
result = nativeThis->QueryInterface(kIScriptObjectOwnerIID, (void **)&owner);
if (NS_OK != result) {
NS_RELEASE(nativeThis);
return JS_FALSE;
}
owner->SetScriptObject((void *)obj);
JS_SetPrivate(cx, obj, nativeThis);
NS_RELEASE(owner);
return JS_TRUE;
return JS_FALSE;
}
//
// Install class initialization
//
nsresult NS_InitInstallClass(nsIScriptContext *aContext, void **aPrototype)
PRInt32 InitXPInstallObjects(nsIScriptContext *aContext, nsFileSpec* jarfile, PRInt32 flags, char* argc, PRInt32 argv)
{
JSContext *jscontext = (JSContext *)aContext->GetNativeContext();
JSObject *proto = nsnull;
JSObject *constructor = nsnull;
JSObject *parent_proto = nsnull;
JSObject *global = JS_GetGlobalObject(jscontext);
jsval vp;
JSContext *jscontext = (JSContext *)aContext->GetNativeContext();
JSObject *global = JS_GetGlobalObject(jscontext);
JSObject *installObject = nsnull;
nsInstall *nativeInstallObject;
if ((PR_TRUE != JS_LookupProperty(jscontext, global, "Install", &vp)) ||
!JSVAL_IS_OBJECT(vp) ||
((constructor = JSVAL_TO_OBJECT(vp)) == nsnull) ||
(PR_TRUE != JS_LookupProperty(jscontext, JSVAL_TO_OBJECT(vp), "prototype", &vp)) ||
!JSVAL_IS_OBJECT(vp)) {
installObject = JS_InitClass( jscontext, // context
global, // global object
nsnull, // parent proto
&InstallClass, // JSClass
nsnull, // JSNative ctor
0, // ctor args
nsnull, // proto props
nsnull, // proto funcs
InstallProperties, // ctor props (static)
InstallMethods); // ctor funcs (static)
proto = JS_InitClass(jscontext, // context
global, // global object
parent_proto, // parent proto
&InstallClass, // JSClass
Install, // JSNative ctor
0, // ctor args
InstallProperties, // proto props
InstallMethods, // proto funcs
nsnull, // ctor props (static)
nsnull); // ctor funcs (static)
if (nsnull == proto) {
if (nsnull == installObject)
{
return NS_ERROR_FAILURE;
}
if ((PR_TRUE == JS_LookupProperty(jscontext, global, "Install", &vp)) &&
JSVAL_IS_OBJECT(vp) &&
((constructor = JSVAL_TO_OBJECT(vp)) != nsnull)) {
vp = INT_TO_JSVAL(nsIDOMInstall::SUERR_BAD_PACKAGE_NAME);
JS_SetProperty(jscontext, constructor, "SUERR_BAD_PACKAGE_NAME", &vp);
vp = INT_TO_JSVAL(nsIDOMInstall::SUERR_UNEXPECTED_ERROR);
JS_SetProperty(jscontext, constructor, "SUERR_UNEXPECTED_ERROR", &vp);
vp = INT_TO_JSVAL(nsIDOMInstall::SUERR_ACCESS_DENIED);
JS_SetProperty(jscontext, constructor, "SUERR_ACCESS_DENIED", &vp);
vp = INT_TO_JSVAL(nsIDOMInstall::SUERR_TOO_MANY_CERTIFICATES);
JS_SetProperty(jscontext, constructor, "SUERR_TOO_MANY_CERTIFICATES", &vp);
vp = INT_TO_JSVAL(nsIDOMInstall::SUERR_NO_INSTALLER_CERTIFICATE);
JS_SetProperty(jscontext, constructor, "SUERR_NO_INSTALLER_CERTIFICATE", &vp);
vp = INT_TO_JSVAL(nsIDOMInstall::SUERR_NO_CERTIFICATE);
JS_SetProperty(jscontext, constructor, "SUERR_NO_CERTIFICATE", &vp);
vp = INT_TO_JSVAL(nsIDOMInstall::SUERR_NO_MATCHING_CERTIFICATE);
JS_SetProperty(jscontext, constructor, "SUERR_NO_MATCHING_CERTIFICATE", &vp);
vp = INT_TO_JSVAL(nsIDOMInstall::SUERR_UNKNOWN_JAR_FILE);
JS_SetProperty(jscontext, constructor, "SUERR_UNKNOWN_JAR_FILE", &vp);
vp = INT_TO_JSVAL(nsIDOMInstall::SUERR_INVALID_ARGUMENTS);
JS_SetProperty(jscontext, constructor, "SUERR_INVALID_ARGUMENTS", &vp);
vp = INT_TO_JSVAL(nsIDOMInstall::SUERR_ILLEGAL_RELATIVE_PATH);
JS_SetProperty(jscontext, constructor, "SUERR_ILLEGAL_RELATIVE_PATH", &vp);
vp = INT_TO_JSVAL(nsIDOMInstall::SUERR_USER_CANCELLED);
JS_SetProperty(jscontext, constructor, "SUERR_USER_CANCELLED", &vp);
vp = INT_TO_JSVAL(nsIDOMInstall::SUERR_INSTALL_NOT_STARTED);
JS_SetProperty(jscontext, constructor, "SUERR_INSTALL_NOT_STARTED", &vp);
vp = INT_TO_JSVAL(nsIDOMInstall::SUERR_SILENT_MODE_DENIED);
JS_SetProperty(jscontext, constructor, "SUERR_SILENT_MODE_DENIED", &vp);
vp = INT_TO_JSVAL(nsIDOMInstall::SUERR_NO_SUCH_COMPONENT);
JS_SetProperty(jscontext, constructor, "SUERR_NO_SUCH_COMPONENT", &vp);
vp = INT_TO_JSVAL(nsIDOMInstall::SUERR_FILE_DOES_NOT_EXIST);
JS_SetProperty(jscontext, constructor, "SUERR_FILE_DOES_NOT_EXIST", &vp);
vp = INT_TO_JSVAL(nsIDOMInstall::SUERR_FILE_READ_ONLY);
JS_SetProperty(jscontext, constructor, "SUERR_FILE_READ_ONLY", &vp);
vp = INT_TO_JSVAL(nsIDOMInstall::SUERR_FILE_IS_DIRECTORY);
JS_SetProperty(jscontext, constructor, "SUERR_FILE_IS_DIRECTORY", &vp);
vp = INT_TO_JSVAL(nsIDOMInstall::SUERR_NETWORK_FILE_IS_IN_USE);
JS_SetProperty(jscontext, constructor, "SUERR_NETWORK_FILE_IS_IN_USE", &vp);
vp = INT_TO_JSVAL(nsIDOMInstall::SUERR_APPLE_SINGLE_ERR);
JS_SetProperty(jscontext, constructor, "SUERR_APPLE_SINGLE_ERR", &vp);
vp = INT_TO_JSVAL(nsIDOMInstall::SUERR_INVALID_PATH_ERR);
JS_SetProperty(jscontext, constructor, "SUERR_INVALID_PATH_ERR", &vp);
vp = INT_TO_JSVAL(nsIDOMInstall::SUERR_PATCH_BAD_DIFF);
JS_SetProperty(jscontext, constructor, "SUERR_PATCH_BAD_DIFF", &vp);
vp = INT_TO_JSVAL(nsIDOMInstall::SUERR_PATCH_BAD_CHECKSUM_TARGET);
JS_SetProperty(jscontext, constructor, "SUERR_PATCH_BAD_CHECKSUM_TARGET", &vp);
vp = INT_TO_JSVAL(nsIDOMInstall::SUERR_PATCH_BAD_CHECKSUM_RESULT);
JS_SetProperty(jscontext, constructor, "SUERR_PATCH_BAD_CHECKSUM_RESULT", &vp);
vp = INT_TO_JSVAL(nsIDOMInstall::SUERR_UNINSTALL_FAILED);
JS_SetProperty(jscontext, constructor, "SUERR_UNINSTALL_FAILED", &vp);
vp = INT_TO_JSVAL(nsIDOMInstall::SUERR_GESTALT_UNKNOWN_ERR);
JS_SetProperty(jscontext, constructor, "SUERR_GESTALT_UNKNOWN_ERR", &vp);
vp = INT_TO_JSVAL(nsIDOMInstall::SUERR_GESTALT_INVALID_ARGUMENT);
JS_SetProperty(jscontext, constructor, "SUERR_GESTALT_INVALID_ARGUMENT", &vp);
vp = INT_TO_JSVAL(nsIDOMInstall::SU_SUCCESS);
JS_SetProperty(jscontext, constructor, "SU_SUCCESS", &vp);
vp = INT_TO_JSVAL(nsIDOMInstall::SU_REBOOT_NEEDED);
JS_SetProperty(jscontext, constructor, "SU_REBOOT_NEEDED", &vp);
vp = INT_TO_JSVAL(nsIDOMInstall::SU_LIMITED_INSTALL);
JS_SetProperty(jscontext, constructor, "SU_LIMITED_INSTALL", &vp);
vp = INT_TO_JSVAL(nsIDOMInstall::SU_FULL_INSTALL);
JS_SetProperty(jscontext, constructor, "SU_FULL_INSTALL", &vp);
vp = INT_TO_JSVAL(nsIDOMInstall::SU_NO_STATUS_DLG);
JS_SetProperty(jscontext, constructor, "SU_NO_STATUS_DLG", &vp);
vp = INT_TO_JSVAL(nsIDOMInstall::SU_NO_FINALIZE_DLG);
JS_SetProperty(jscontext, constructor, "SU_NO_FINALIZE_DLG", &vp);
vp = INT_TO_JSVAL(nsIDOMInstall::SU_INSTALL_FILE_UNEXPECTED_MSG_ID);
JS_SetProperty(jscontext, constructor, "SU_INSTALL_FILE_UNEXPECTED_MSG_ID", &vp);
vp = INT_TO_JSVAL(nsIDOMInstall::SU_DETAILS_REPLACE_FILE_MSG_ID);
JS_SetProperty(jscontext, constructor, "SU_DETAILS_REPLACE_FILE_MSG_ID", &vp);
vp = INT_TO_JSVAL(nsIDOMInstall::SU_DETAILS_INSTALL_FILE_MSG_ID);
JS_SetProperty(jscontext, constructor, "SU_DETAILS_INSTALL_FILE_MSG_ID", &vp);
}
}
else if ((nsnull != constructor) && JSVAL_IS_OBJECT(vp)) {
proto = JSVAL_TO_OBJECT(vp);
}
else {
return NS_ERROR_FAILURE;
}
if (aPrototype) {
*aPrototype = proto;
}
if ( PR_FALSE == JS_DefineConstDoubles(jscontext, installObject, install_constants) )
return NS_ERROR_FAILURE;
nativeInstallObject = new nsInstall();
JS_SetPrivate(jscontext, installObject, nativeInstallObject);
nativeInstallObject->SetScriptObject(installObject);
return NS_OK;
}
//
// Method for creating a new Install JavaScript object
//
extern "C" NS_DOM nsresult NS_NewScriptInstall(nsIScriptContext *aContext, nsISupports *aSupports, nsISupports *aParent, void **aReturn)
{
NS_PRECONDITION(nsnull != aContext && nsnull != aSupports && nsnull != aReturn, "null argument to NS_NewScriptInstall");
JSObject *proto;
JSObject *parent;
nsIScriptObjectOwner *owner;
JSContext *jscontext = (JSContext *)aContext->GetNativeContext();
nsresult result = NS_OK;
nsIDOMInstall *aInstall;
if (nsnull == aParent) {
parent = nsnull;
}
else if (NS_OK == aParent->QueryInterface(kIScriptObjectOwnerIID, (void**)&owner)) {
if (NS_OK != owner->GetScriptObject(aContext, (void **)&parent)) {
NS_RELEASE(owner);
return NS_ERROR_FAILURE;
}
NS_RELEASE(owner);
}
else {
return NS_ERROR_FAILURE;
}
if (NS_OK != NS_InitInstallClass(aContext, (void **)&proto)) {
return NS_ERROR_FAILURE;
}
result = aSupports->QueryInterface(kIInstallIID, (void **)&aInstall);
if (NS_OK != result) {
return result;
}
// create a js object for this class
*aReturn = JS_NewObject(jscontext, &InstallClass, proto, parent);
if (nsnull != *aReturn) {
// connect the native object to the js object
JS_SetPrivate(jscontext, (JSObject *)*aReturn, aInstall);
}
else {
NS_RELEASE(aInstall);
return NS_ERROR_FAILURE;
}
return NS_OK;
}
}

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

@ -482,32 +482,32 @@ nsresult NS_InitInstallVersionClass(nsIScriptContext *aContext, void **aPrototyp
if ((PR_TRUE == JS_LookupProperty(jscontext, global, "InstallVersion", &vp)) &&
JSVAL_IS_OBJECT(vp) &&
((constructor = JSVAL_TO_OBJECT(vp)) != nsnull)) {
vp = INT_TO_JSVAL(nsIDOMInstallVersion::SU_EQUAL);
JS_SetProperty(jscontext, constructor, "SU_EQUAL", &vp);
vp = INT_TO_JSVAL(nsIDOMInstallVersion::EQUAL);
JS_SetProperty(jscontext, constructor, "EQUAL", &vp);
vp = INT_TO_JSVAL(nsIDOMInstallVersion::SU_BLD_DIFF);
JS_SetProperty(jscontext, constructor, "SU_BLD_DIFF", &vp);
vp = INT_TO_JSVAL(nsIDOMInstallVersion::BLD_DIFF);
JS_SetProperty(jscontext, constructor, "BLD_DIFF", &vp);
vp = INT_TO_JSVAL(nsIDOMInstallVersion::SU_BLD_DIFF_MINUS);
JS_SetProperty(jscontext, constructor, "SU_BLD_DIFF_MINUS", &vp);
vp = INT_TO_JSVAL(nsIDOMInstallVersion::BLD_DIFF_MINUS);
JS_SetProperty(jscontext, constructor, "BLD_DIFF_MINUS", &vp);
vp = INT_TO_JSVAL(nsIDOMInstallVersion::SU_REL_DIFF);
JS_SetProperty(jscontext, constructor, "SU_REL_DIFF", &vp);
vp = INT_TO_JSVAL(nsIDOMInstallVersion::REL_DIFF);
JS_SetProperty(jscontext, constructor, "REL_DIFF", &vp);
vp = INT_TO_JSVAL(nsIDOMInstallVersion::SU_REL_DIFF_MINUS);
JS_SetProperty(jscontext, constructor, "SU_REL_DIFF_MINUS", &vp);
vp = INT_TO_JSVAL(nsIDOMInstallVersion::REL_DIFF_MINUS);
JS_SetProperty(jscontext, constructor, "REL_DIFF_MINUS", &vp);
vp = INT_TO_JSVAL(nsIDOMInstallVersion::SU_MINOR_DIFF);
JS_SetProperty(jscontext, constructor, "SU_MINOR_DIFF", &vp);
vp = INT_TO_JSVAL(nsIDOMInstallVersion::MINOR_DIFF);
JS_SetProperty(jscontext, constructor, "MINOR_DIFF", &vp);
vp = INT_TO_JSVAL(nsIDOMInstallVersion::SU_MINOR_DIFF_MINUS);
JS_SetProperty(jscontext, constructor, "SU_MINOR_DIFF_MINUS", &vp);
vp = INT_TO_JSVAL(nsIDOMInstallVersion::MINOR_DIFF_MINUS);
JS_SetProperty(jscontext, constructor, "MINOR_DIFF_MINUS", &vp);
vp = INT_TO_JSVAL(nsIDOMInstallVersion::SU_MAJOR_DIFF);
JS_SetProperty(jscontext, constructor, "SU_MAJOR_DIFF", &vp);
vp = INT_TO_JSVAL(nsIDOMInstallVersion::MAJOR_DIFF);
JS_SetProperty(jscontext, constructor, "MAJOR_DIFF", &vp);
vp = INT_TO_JSVAL(nsIDOMInstallVersion::SU_MAJOR_DIFF_MINUS);
JS_SetProperty(jscontext, constructor, "SU_MAJOR_DIFF_MINUS", &vp);
vp = INT_TO_JSVAL(nsIDOMInstallVersion::MAJOR_DIFF_MINUS);
JS_SetProperty(jscontext, constructor, "MAJOR_DIFF_MINUS", &vp);
}

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

@ -47,7 +47,6 @@
#include "nsSoftwareUpdateStream.h"
#include "nsSoftwareUpdateRun.h"
#include "nsIDOMInstall.h"
#include "nsInstall.h"
#include "nsIDOMInstallTriggerGlobal.h"
@ -73,9 +72,6 @@ static NS_DEFINE_IID(kIScriptExternalNameSetIID, NS_ISCRIPTEXTERNALNAMESET_IID);
static NS_DEFINE_IID(kISoftwareUpdate_IID, NS_ISOFTWAREUPDATE_IID);
static NS_DEFINE_IID(kSoftwareUpdate_CID, NS_SoftwareUpdate_CID);
static NS_DEFINE_IID(kIInstall_IID, NS_IDOMINSTALL_IID);
static NS_DEFINE_IID(kInstall_CID, NS_SoftwareUpdateInstall_CID);
static NS_DEFINE_IID(kIInstallTrigger_IID, NS_IDOMINSTALLTRIGGERGLOBAL_IID);
static NS_DEFINE_IID(kInstallTrigger_CID, NS_SoftwareUpdateInstallTrigger_CID);
@ -140,15 +136,14 @@ nsSoftwareUpdate::Startup()
// FIX: Only add the Trigger Object to the JS NameSpace. Then when before we run
// the InstallScript, add our other objects to just that env.
nsIScriptNameSetRegistry *registry;
nsIScriptNameSetRegistry *scriptNameSet;
nsresult result = nsServiceManager::GetService(kCScriptNameSetRegistryCID,
kIScriptNameSetRegistryIID,
(nsISupports **)&registry);
(nsISupports **)&scriptNameSet);
if (NS_OK == result)
{
nsSoftwareUpdateNameSet* nameSet = new nsSoftwareUpdateNameSet();
registry->AddExternalNameSet(nameSet);
/* FIX - do we need to release this service? When we do, it get deleted,and our name is lost. */
scriptNameSet->AddExternalNameSet(nameSet);
}
/***************************************/
@ -315,7 +310,7 @@ nsSoftwareUpdateNameSet::InitializeClasses(nsIScriptContext* aScriptContext)
{
nsresult result = NS_OK;
result = NS_InitInstallClass(aScriptContext, nsnull);
// result = NS_InitInstallClass(aScriptContext, nsnull);
if (result != NS_OK) return result;
result = NS_InitInstallVersionClass(aScriptContext, nsnull);
@ -339,13 +334,13 @@ nsSoftwareUpdateNameSet::AddNameSet(nsIScriptContext* aScriptContext)
result = aScriptContext->GetNameSpaceManager(&manager);
if (NS_OK == result)
{
/*
result = manager->RegisterGlobalName("Install",
kInstall_CID,
PR_TRUE);
if (result != NS_OK) return result;
*/
result = manager->RegisterGlobalName("InstallVersion",
kInstallVersion_CID,
PR_TRUE);
@ -388,7 +383,6 @@ extern "C" NS_EXPORT nsresult
NSRegisterSelf(const char *path)
{
nsRepository::RegisterFactory(kSoftwareUpdate_CID, path, PR_TRUE, PR_TRUE);
nsRepository::RegisterFactory(kInstall_CID, path, PR_TRUE, PR_TRUE);
nsRepository::RegisterFactory(kInstallTrigger_CID, path, PR_TRUE, PR_TRUE);
nsRepository::RegisterFactory(kInstallVersion_CID, path, PR_TRUE, PR_TRUE);
nsRepository::RegisterFactory(kInstallFolder_CID, path, PR_TRUE, PR_TRUE);
@ -399,7 +393,6 @@ extern "C" NS_EXPORT nsresult
NSUnregisterSelf(const char *path)
{
nsRepository::UnregisterFactory(kSoftwareUpdate_CID, path);
nsRepository::UnregisterFactory(kInstall_CID, path);
nsRepository::UnregisterFactory(kInstallTrigger_CID, path);
nsRepository::UnregisterFactory(kInstallVersion_CID, path);
nsRepository::UnregisterFactory(kInstallFolder_CID, path);
@ -421,12 +414,8 @@ NSGetFactory(const nsCID &aClass, nsISupports* serviceMgr, nsIFactory **aFactory
*aFactory = NULL;
nsISupports *inst;
if ( aClass.Equals(kInstall_CID) )
{
inst = new nsInstallFactory();
}
else if (aClass.Equals(kInstallTrigger_CID) )
if (aClass.Equals(kInstallTrigger_CID) )
{
inst = new nsInstallTriggerFactory();
}

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

@ -51,11 +51,11 @@ class nsSoftwareUpdateNameSet : public nsIScriptExternalNameSet
#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
#define ErrInvalidArgs -1
#define ErrUnknownInstaller -2
#define ErrInternalError -3
#define ErrBadScript -4
#define JarError -5
#define DiskSpaceError -6
#endif

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

@ -11,6 +11,10 @@
#include "nsIScriptContext.h"
#include "nsIScriptContextOwner.h"
#include "nsInstall.h"
extern PRInt32 InitXPInstallObjects(nsIScriptContext *aContext, nsFileSpec* jarfile, PRInt32 flags, char* argc, PRInt32 argv);
static NS_DEFINE_IID(kBrowserWindowCID, NS_BROWSER_WINDOW_CID);
static NS_DEFINE_IID(kIBrowserWindowIID, NS_IBROWSER_WINDOW_IID);
@ -18,7 +22,7 @@ static NS_DEFINE_IID(kIBrowserWindowIID, NS_IBROWSER_WINDOW_IID);
static NS_DEFINE_IID(kIScriptContextOwnerIID, NS_ISCRIPTCONTEXTOWNER_IID);
/* su_ReadFileIntoBuffer
/* ReadFileIntoBuffer
* given a file name, reads it into buffer
* returns an error code
*/
@ -31,7 +35,7 @@ static short ReadFileIntoBuffer(char * fileName, char** buffer, unsigned long *b
if ( stat( fileName, &st) != 0 )
{
result = su_ErrInternalError;
result = ErrInternalError;
goto fail;
}
@ -49,13 +53,13 @@ static short ReadFileIntoBuffer(char * fileName, char** buffer, unsigned long *b
if ( file == NULL)
{
result = su_ErrInternalError;
result = ErrInternalError;
goto fail;
}
if ( PR_Read(file, *buffer, *bufferSize ) != st.st_size )
{
result = su_ErrInternalError;
result = ErrInternalError;
PR_Close( file );
goto fail;
}
@ -108,10 +112,26 @@ int RunInstallJS(char* installJSFile)
{
const char* url = "";
nsIScriptContext* scriptContext;
nsresult res = scriptContextOwner->GetScriptContext(&scriptContext);
rv = scriptContextOwner->GetScriptContext(&scriptContext);
if (NS_OK == res)
if (NS_OK == rv)
{
///////////////////////////////////////////////////////////////////////
// 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;
unsigned long bufferLength;
ReadFileIntoBuffer(installJSFile, &buffer, &bufferLength);

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

@ -31,7 +31,7 @@
nsresult
su_DownloadJar(const nsString& aUrlString, const nsString& aSaveLocationString)
DownloadJar(const nsString& aUrlString, const nsString& aSaveLocationString)
{
long result=0;
nsIURL *pURL;

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

@ -35,7 +35,7 @@ static NS_DEFINE_IID(kInetLibURLIID, NS_INETLIBURL_IID);
static NS_DEFINE_IID(kIStreamListenerIID, NS_ISTREAMLISTENER_IID);
extern "C" nsresult su_DownloadJar(const nsString& aUrlString, const nsString& aSaveLocationString );
extern "C" nsresult DownloadJar(const nsString& aUrlString, const nsString& aSaveLocationString );
class nsSoftwareUpdateListener : public nsIStreamListener