зеркало из https://github.com/mozilla/gecko-dev.git
Removed InstallFolder Object - just using nsStrings now.
Now creating tempfiles for ZIP calls hooked up to nsSpecialSystemDirectory cleaned up Install() api
This commit is contained in:
Родитель
975e9fd1dc
Коммит
584478324d
|
@ -19,10 +19,8 @@ DEPTH=..\..
|
|||
|
||||
DEFINES=-D_IMPL_NS_DOM
|
||||
|
||||
EXPORTS= nsIDOMInstall.h \
|
||||
nsIDOMInstallTriggerGlobal.h \
|
||||
EXPORTS= nsIDOMInstallTriggerGlobal.h \
|
||||
nsIDOMInstallVersion.h \
|
||||
nsIDOMInstallFolder.h \
|
||||
nsSoftwareUpdateIIDs.h \
|
||||
nsISoftwareUpdate.h
|
||||
|
||||
|
|
|
@ -71,12 +71,10 @@ OBJS = \
|
|||
.\$(OBJDIR)\nsJSInstall.obj \
|
||||
.\$(OBJDIR)\nsJSInstallTriggerGlobal.obj \
|
||||
.\$(OBJDIR)\nsJSInstallVersion.obj \
|
||||
.\$(OBJDIR)\nsJSInstallFolder.obj \
|
||||
.\$(OBJDIR)\nsSoftwareUpdate.obj \
|
||||
.\$(OBJDIR)\nsSoftwareUpdateQueue.obj \
|
||||
.\$(OBJDIR)\nsSoftwareUpdateRun.obj \
|
||||
.\$(OBJDIR)\nsSoftwareUpdateStream.obj \
|
||||
.\$(OBJDIR)\nsInstallErrorMessages.obj \
|
||||
.\$(OBJDIR)\nsInstallFile.obj \
|
||||
.\$(OBJDIR)\nsInstallDelete.obj \
|
||||
.\$(OBJDIR)\nsInstallExecute.obj \
|
||||
|
|
|
@ -25,6 +25,7 @@
|
|||
#include "nsVector.h"
|
||||
#include "nsHashtable.h"
|
||||
#include "nsFileSpec.h"
|
||||
#include "nsSpecialSystemDirectory.h"
|
||||
|
||||
#include "prmem.h"
|
||||
#include "pratom.h"
|
||||
|
@ -34,8 +35,8 @@
|
|||
#include "zipfile.h"
|
||||
|
||||
#include "nsInstall.h"
|
||||
#include "nsInstallFolder.h"
|
||||
|
||||
#include "nsIDOMInstallFolder.h"
|
||||
#include "nsIDOMInstallVersion.h"
|
||||
|
||||
#include "nsInstallFile.h"
|
||||
|
@ -43,8 +44,6 @@
|
|||
#include "nsInstallExecute.h"
|
||||
#include "nsInstallPatch.h"
|
||||
|
||||
static NS_DEFINE_IID(kIInstallFolder_IID, NS_IDOMINSTALLFOLDER_IID);
|
||||
|
||||
#ifdef XP_PC
|
||||
#define FILESEP "\\"
|
||||
#elif defined(XP_MAC)
|
||||
|
@ -57,13 +56,11 @@ static NS_DEFINE_IID(kIInstallFolder_IID, NS_IDOMINSTALLFOLDER_IID);
|
|||
|
||||
nsInstall::nsInstall()
|
||||
{
|
||||
mScriptObject = nsnull;
|
||||
mVersionInfo = nsnull;
|
||||
|
||||
mJarFileData = nsnull;
|
||||
|
||||
mPackageName = "";
|
||||
mUserPackageName= "";
|
||||
mScriptObject = nsnull; // this is the jsobject for our context
|
||||
mVersionInfo = nsnull; // this is the version information passed to us in StartInstall()
|
||||
mJarFileData = nsnull; // this is an opaque handle to the jarfile.
|
||||
mRegistryPackageName = ""; // this is the name that we will add into the registry for the component we are installing
|
||||
mUIName = ""; // this is the name that will be displayed in UI.
|
||||
|
||||
mUninstallPackage = PR_FALSE;
|
||||
mRegisterPackage = PR_FALSE;
|
||||
|
@ -85,14 +82,14 @@ nsInstall::SetScriptObject(void *aScriptObject)
|
|||
PRInt32
|
||||
nsInstall::GetUserPackageName(nsString& aUserPackageName)
|
||||
{
|
||||
aUserPackageName = mUserPackageName;
|
||||
aUserPackageName = mUIName;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
PRInt32
|
||||
nsInstall::GetRegPackageName(nsString& aRegPackageName)
|
||||
{
|
||||
aRegPackageName = mPackageName;
|
||||
aRegPackageName = mRegistryPackageName;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
@ -116,14 +113,20 @@ nsInstall::AbortInstall()
|
|||
|
||||
return NS_OK;
|
||||
}
|
||||
//FIX: Should we use empty strings or nulls for parameters that do not need values.
|
||||
|
||||
PRInt32
|
||||
nsInstall::AddDirectory(const nsString& aRegName, const nsString& aVersion, const nsString& aJarSource, nsIDOMInstallFolder* aFolder, const nsString& aSubdir, PRBool aForceMode, PRInt32* aReturn)
|
||||
nsInstall::AddDirectory(const nsString& aRegName,
|
||||
const nsString& aVersion,
|
||||
const nsString& aJarSource,
|
||||
const nsString& aFolder,
|
||||
const nsString& aSubdir,
|
||||
PRBool aForceMode,
|
||||
PRInt32* aReturn)
|
||||
{
|
||||
nsInstallFile* ie = nsnull;
|
||||
PRInt32 result;
|
||||
|
||||
if ( aJarSource == "null" || aFolder == nsnull)
|
||||
if ( aJarSource == "null" || aFolder == "null")
|
||||
{
|
||||
*aReturn = SaveError(nsInstall::INVALID_ARGUMENTS);
|
||||
return NS_OK;
|
||||
|
@ -175,8 +178,6 @@ nsInstall::AddDirectory(const nsString& aRegName, const nsString& aVersion, cons
|
|||
*aReturn = SaveError( result );
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
|
||||
for (int i=0; i< pathsUpperBound; i++)
|
||||
{
|
||||
|
@ -276,7 +277,7 @@ PRInt32
|
|||
nsInstall::AddSubcomponent(const nsString& aRegName,
|
||||
const nsString& aVersion,
|
||||
const nsString& aJarSource,
|
||||
nsIDOMInstallFolder* aFolder,
|
||||
const nsString& aFolder,
|
||||
const nsString& aTargetName,
|
||||
PRBool aForceMode,
|
||||
PRInt32* aReturn)
|
||||
|
@ -286,7 +287,7 @@ nsInstall::AddSubcomponent(const nsString& aRegName,
|
|||
|
||||
PRInt32 errcode = nsInstall::SUCCESS;
|
||||
|
||||
if ( aJarSource == "null" || aFolder == nsnull)
|
||||
if ( aJarSource == "null" || aFolder == "null")
|
||||
{
|
||||
*aReturn = SaveError( nsInstall::INVALID_ARGUMENTS );
|
||||
return NS_OK;
|
||||
|
@ -407,7 +408,7 @@ nsInstall::DeleteComponent(const nsString& aRegistryName, PRInt32* aReturn)
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
nsInstallDelete* id = new nsInstallDelete(this, NULL, *qualifiedRegName, &result);
|
||||
nsInstallDelete* id = new nsInstallDelete(this, "", *qualifiedRegName, &result);
|
||||
if (result == nsInstall::SUCCESS)
|
||||
{
|
||||
result = ScheduleForInstall( id );
|
||||
|
@ -421,7 +422,7 @@ nsInstall::DeleteComponent(const nsString& aRegistryName, PRInt32* aReturn)
|
|||
}
|
||||
|
||||
PRInt32
|
||||
nsInstall::DeleteFile(nsIDOMInstallFolder* aFolder, const nsString& aRelativeFileName, PRInt32* aReturn)
|
||||
nsInstall::DeleteFile(const nsString& aFolder, const nsString& aRelativeFileName, PRInt32* aReturn)
|
||||
{
|
||||
PRInt32 result = SanityCheck();
|
||||
|
||||
|
@ -449,7 +450,7 @@ nsInstall::DeleteFile(nsIDOMInstallFolder* aFolder, const nsString& aRelativeFil
|
|||
}
|
||||
|
||||
PRInt32
|
||||
nsInstall::DiskSpaceAvailable(nsIDOMInstallFolder* aFolder, PRInt32* aReturn)
|
||||
nsInstall::DiskSpaceAvailable(const nsString& aFolder, PRInt32* aReturn)
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
|
@ -503,15 +504,9 @@ nsInstall::FinalizeInstall(PRInt32* aReturn)
|
|||
|
||||
if ( mUninstallPackage )
|
||||
{
|
||||
char* packageName = mPackageName.ToNewCString();
|
||||
char* userPackageName = mUserPackageName.ToNewCString();
|
||||
|
||||
// The Version Registry is not real. FIX!
|
||||
//
|
||||
//VR_UninstallCreateNode( packageName, userPackageName);
|
||||
|
||||
delete packageName;
|
||||
delete userPackageName;
|
||||
//VR_UninstallCreateNode( nsAutoCString(mRegistryPackageName), nsAutoCString(mUIName));
|
||||
}
|
||||
|
||||
PRUint32 i=0;
|
||||
|
@ -520,8 +515,7 @@ nsInstall::FinalizeInstall(PRInt32* aReturn)
|
|||
ie = (nsInstallObject*)mInstalledFiles->Get(i);
|
||||
if (ie == NULL)
|
||||
continue;
|
||||
//CAN we get rid of char* crap?? FiX
|
||||
//result = ie->Complete();
|
||||
|
||||
ie->Complete();
|
||||
|
||||
if (result != nsInstall::SUCCESS)
|
||||
|
@ -533,6 +527,8 @@ nsInstall::FinalizeInstall(PRInt32* aReturn)
|
|||
|
||||
//SetProgressDialogThermo(++count);
|
||||
}
|
||||
|
||||
*aReturn = NS_OK;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
@ -544,9 +540,12 @@ nsInstall::Gestalt(const nsString& aSelector, PRInt32* aReturn)
|
|||
}
|
||||
|
||||
PRInt32
|
||||
nsInstall::GetComponentFolder(const nsString& aComponentName, const nsString& aSubdirectory, nsIDOMInstallFolder** aFolder)
|
||||
nsInstall::GetComponentFolder(const nsString& aComponentName, const nsString& aSubdirectory, nsString** aFolder)
|
||||
{
|
||||
nsInstallFolder* spec = nsnull;
|
||||
long err;
|
||||
char* dir;
|
||||
char* componentCString;
|
||||
|
||||
*aFolder = nsnull;
|
||||
|
||||
nsString *tempString = GetQualifiedPackageName( aComponentName );
|
||||
|
@ -554,10 +553,6 @@ nsInstall::GetComponentFolder(const nsString& aComponentName, const nsString& aS
|
|||
if (tempString == nsnull)
|
||||
return NS_OK;
|
||||
|
||||
long err;
|
||||
char* dir;
|
||||
char* componentCString;
|
||||
|
||||
componentCString = tempString->ToNewCString();
|
||||
delete tempString;
|
||||
|
||||
|
@ -594,39 +589,30 @@ nsInstall::GetComponentFolder(const nsString& aComponentName, const nsString& aS
|
|||
|
||||
if ( dir != NULL )
|
||||
{
|
||||
spec = new nsInstallFolder();
|
||||
spec->Init("Installed", nsString(dir), mUserPackageName);
|
||||
*aFolder = new nsString(dir);
|
||||
}
|
||||
|
||||
PR_FREEIF(dir);
|
||||
delete [] componentCString;
|
||||
|
||||
nsresult result = spec->QueryInterface(kIInstallFolder_IID, (void**)aFolder);
|
||||
|
||||
if (result != NS_OK)
|
||||
*aFolder = nsnull;
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
PRInt32
|
||||
nsInstall::GetFolder(const nsString& targetFolder, const nsString& aSubdirectory, nsIDOMInstallFolder** aFolder)
|
||||
nsInstall::GetFolder(const nsString& targetFolder, const nsString& aSubdirectory, nsString** aFolder)
|
||||
{
|
||||
nsInstallFolder* spec = nsnull;
|
||||
*aFolder = nsnull;
|
||||
|
||||
// FIX: What was this for? if ((! targetFolder.EqualsIgnoreCase("Installed")) && (! targetFolder.EqualsIgnoreCase("file:///")) )
|
||||
{
|
||||
spec = new nsInstallFolder();
|
||||
spec->Init(targetFolder, aSubdirectory, mUserPackageName);
|
||||
}
|
||||
spec = new nsInstallFolder(targetFolder, aSubdirectory);
|
||||
|
||||
nsString dirString;
|
||||
spec->GetDirectoryPath(dirString);
|
||||
|
||||
nsresult result = spec->QueryInterface(kIInstallFolder_IID, (void**)aFolder);
|
||||
|
||||
if (result != NS_OK)
|
||||
*aFolder = nsnull;
|
||||
*aFolder = new nsString(dirString);
|
||||
|
||||
|
||||
return NS_OK;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
PRInt32
|
||||
|
@ -637,7 +623,7 @@ nsInstall::GetLastError(PRInt32* aReturn)
|
|||
}
|
||||
|
||||
PRInt32
|
||||
nsInstall::GetWinProfile(nsIDOMInstallFolder* aFolder, const nsString& aFile, PRInt32* aReturn)
|
||||
nsInstall::GetWinProfile(const nsString& aFolder, const nsString& aFile, PRInt32* aReturn)
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
|
@ -649,7 +635,7 @@ nsInstall::GetWinRegistry(PRInt32* aReturn)
|
|||
}
|
||||
|
||||
PRInt32
|
||||
nsInstall::Patch(const nsString& aRegName, const nsString& aVersion, const nsString& aJarSource, nsIDOMInstallFolder* aFolder, const nsString& aTargetName, PRInt32* aReturn)
|
||||
nsInstall::Patch(const nsString& aRegName, const nsString& aVersion, const nsString& aJarSource, const nsString& aFolder, const nsString& aTargetName, PRInt32* aReturn)
|
||||
{
|
||||
PRInt32 result = SanityCheck();
|
||||
|
||||
|
@ -698,16 +684,12 @@ nsInstall::ResetError()
|
|||
|
||||
|
||||
PRInt32
|
||||
nsInstall::SetPackageFolder(nsIDOMInstallFolder* aFolder)
|
||||
nsInstall::SetPackageFolder(const nsString& aFolder)
|
||||
{
|
||||
nsString directoryPath;
|
||||
aFolder->GetDirectoryPath(directoryPath);
|
||||
|
||||
if (mPackageFolder != nsnull)
|
||||
delete mPackageFolder;
|
||||
|
||||
mPackageFolder = new nsInstallFolder();
|
||||
mPackageFolder->Init("Installed", directoryPath, mPackageName);
|
||||
mPackageFolder = new nsString(aFolder);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
@ -741,7 +723,7 @@ nsInstall::StartInstall(const nsString& aUserPackageName, const nsString& aPacka
|
|||
|
||||
mUserCancelled = PR_FALSE;
|
||||
|
||||
mUserPackageName = aUserPackageName;
|
||||
mUIName = aUserPackageName;
|
||||
|
||||
if ( aPackageName.Equals("") )
|
||||
{
|
||||
|
@ -751,17 +733,17 @@ nsInstall::StartInstall(const nsString& aUserPackageName, const nsString& aPacka
|
|||
|
||||
nsString *tempString = GetQualifiedPackageName( aPackageName );
|
||||
|
||||
mPackageName.SetLength(0);
|
||||
mPackageName.Append( *tempString );
|
||||
mRegistryPackageName.SetLength(0);
|
||||
mRegistryPackageName.Append( *tempString );
|
||||
|
||||
delete tempString;
|
||||
|
||||
/* Check to see if the PackageName ends in a '/'. If it does nuke it. */
|
||||
|
||||
if (mPackageName.Last() == '/')
|
||||
if (mRegistryPackageName.Last() == '/')
|
||||
{
|
||||
PRInt32 index = mPackageName.Length();
|
||||
mPackageName.Truncate(--index);
|
||||
PRInt32 index = mRegistryPackageName.Length();
|
||||
mRegistryPackageName.Truncate(--index);
|
||||
}
|
||||
|
||||
if (mVersionInfo != nsnull)
|
||||
|
@ -788,7 +770,7 @@ nsInstall::StartInstall(const nsString& aUserPackageName, const nsString& aPacka
|
|||
|
||||
if (*aReturn != nsInstall::SUCCESS)
|
||||
{
|
||||
mPackageName = ""; // Reset!
|
||||
mRegistryPackageName = ""; // Reset!
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
|
@ -830,7 +812,7 @@ nsInstall::Uninstall(const nsString& aPackageName, PRInt32* aReturn)
|
|||
|
||||
|
||||
void
|
||||
nsInstall::AddPatch(nsHashKey *aKey, nsString* fileName)
|
||||
nsInstall::AddPatch(nsHashKey *aKey, nsFileSpec* fileName)
|
||||
{
|
||||
if (mPatchList != nsnull)
|
||||
{
|
||||
|
@ -839,11 +821,11 @@ nsInstall::AddPatch(nsHashKey *aKey, nsString* fileName)
|
|||
}
|
||||
|
||||
void
|
||||
nsInstall::GetPatch(nsHashKey *aKey, nsString* fileName)
|
||||
nsInstall::GetPatch(nsHashKey *aKey, nsFileSpec* fileName)
|
||||
{
|
||||
if (mPatchList != nsnull)
|
||||
{
|
||||
fileName = (nsString*) mPatchList->Get(aKey);
|
||||
fileName = (nsFileSpec*) mPatchList->Get(aKey);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -903,7 +885,7 @@ nsInstall::ScheduleForInstall(nsInstallObject* ob)
|
|||
PRInt32
|
||||
nsInstall::SanityCheck(void)
|
||||
{
|
||||
if ( mPackageName == "" || mUserPackageName == "")
|
||||
if ( mRegistryPackageName == "" || mUIName == "")
|
||||
{
|
||||
return INSTALL_NOT_STARTED;
|
||||
}
|
||||
|
@ -982,9 +964,9 @@ nsInstall::GetQualifiedRegName(const nsString& name )
|
|||
}
|
||||
else if ( name[0] != '/' )
|
||||
{
|
||||
if (mUserPackageName != "")
|
||||
if (mUIName != "")
|
||||
{
|
||||
qualifiedRegName = new nsString(mUserPackageName);
|
||||
qualifiedRegName = new nsString(mUIName);
|
||||
qualifiedRegName->Append("/");
|
||||
qualifiedRegName->Append(name);
|
||||
}
|
||||
|
@ -1108,7 +1090,7 @@ nsInstall::CleanUp(void)
|
|||
delete mPatchList;
|
||||
}
|
||||
|
||||
mPackageName = ""; // used to see if StartInstall() has been called
|
||||
mRegistryPackageName = ""; // used to see if StartInstall() has been called
|
||||
|
||||
//CloseProgressDialog();
|
||||
}
|
||||
|
@ -1144,7 +1126,7 @@ PRInt32
|
|||
nsInstall::OpenJARFile(void)
|
||||
{
|
||||
|
||||
PRInt32 result = ZIPR_OpenArchive(mJarFileLocation, &mJarFileData);
|
||||
PRInt32 result = ZIP_OpenArchive(mJarFileLocation, &mJarFileData);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
@ -1152,7 +1134,7 @@ nsInstall::OpenJARFile(void)
|
|||
void
|
||||
nsInstall::CloseJARFile(void)
|
||||
{
|
||||
ZIPR_CloseArchive(&mJarFileData);
|
||||
ZIP_CloseArchive(&mJarFileData);
|
||||
mJarFileData = nsnull;
|
||||
}
|
||||
|
||||
|
@ -1162,33 +1144,53 @@ nsInstall::CloseJARFile(void)
|
|||
// 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)
|
||||
nsInstall::ExtractFileFromJar(const nsString& aJarfile, nsFileSpec* aSuggestedName, nsFileSpec** aRealName)
|
||||
{
|
||||
PRInt32 result;
|
||||
char* extractFileHere;
|
||||
const char* extractFileHere;
|
||||
|
||||
|
||||
nsFileSpec finalFile(aSuggestedName);
|
||||
|
||||
if (aSuggestedName == "" || finalFile.Exists() )
|
||||
nsSpecialSystemDirectory tempFile(nsSpecialSystemDirectory::OS_TemporaryDirectory);
|
||||
|
||||
if (aSuggestedName == nsnull || aSuggestedName->Exists() )
|
||||
{
|
||||
nsString tempfileName = "xpinstall";
|
||||
|
||||
// Get the extention of the file in the jar.
|
||||
|
||||
PRInt32 result = aJarfile.RFind('.');
|
||||
if (result != -1)
|
||||
{
|
||||
// We found an extention. Add it to the tempfileName string
|
||||
nsString extention;
|
||||
aJarfile.Right(extention, (aJarfile.Length() - result) );
|
||||
tempfileName += extention;
|
||||
}
|
||||
|
||||
tempFile += tempfileName;
|
||||
|
||||
// Create a temporary file to extract to.
|
||||
|
||||
extractFileHere = "c:\\temp\\tempFile.tmp";
|
||||
tempFile.MakeUnique();
|
||||
|
||||
extractFileHere = tempFile.operator const char* ();
|
||||
}
|
||||
else
|
||||
{
|
||||
// extract to the final destination.
|
||||
extractFileHere = aSuggestedName.ToNewCString();
|
||||
extractFileHere = aSuggestedName->operator const char* ();
|
||||
}
|
||||
|
||||
*aRealName = new nsString(extractFileHere);
|
||||
|
||||
char* fileInJar = aJarfile.ToNewCString();
|
||||
// Return the filepath that we extracted to:
|
||||
|
||||
result = ZIPR_ExtractFile( mJarFileData, fileInJar, extractFileHere );
|
||||
nsFileSpec *fileSpec = new nsFileSpec(extractFileHere);
|
||||
|
||||
// FIX: We will overwrite what is in the way. is this something that we want to do?
|
||||
fileSpec->Delete(PR_FALSE);
|
||||
|
||||
result = ZIP_ExtractFile( mJarFileData, nsAutoCString(aJarfile), extractFileHere );
|
||||
|
||||
delete [] fileInJar;
|
||||
if (result == 0)
|
||||
*aRealName = fileSpec;
|
||||
|
||||
//delete [] extractFileHere;
|
||||
|
||||
return result;
|
||||
|
|
|
@ -14,7 +14,6 @@
|
|||
#include "nsSoftwareUpdate.h"
|
||||
|
||||
#include "nsInstallObject.h"
|
||||
#include "nsInstallFolder.h"
|
||||
#include "nsInstallVersion.h"
|
||||
|
||||
class nsInstall
|
||||
|
@ -73,30 +72,30 @@ class nsInstall
|
|||
PRInt32 GetRegPackageName(nsString& aRegPackageName);
|
||||
|
||||
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 AddDirectory(const nsString& aRegName, const nsString& aVersion, const nsString& aJarSource, const nsString& aFolder, const nsString& aSubdir, PRBool aForceMode, PRInt32* aReturn);
|
||||
PRInt32 AddSubcomponent(const nsString& aRegName, const nsString& aVersion, const nsString& aJarSource, const nsString& 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 DeleteFile(const nsString& aFolder, const nsString& aRelativeFileName, PRInt32* aReturn);
|
||||
PRInt32 DiskSpaceAvailable(const nsString& 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 GetComponentFolder(const nsString& aComponentName, const nsString& aSubdirectory, nsString** aFolder);
|
||||
PRInt32 GetFolder(const nsString& aTargetFolder, const nsString& aSubdirectory, nsString** aFolder);
|
||||
PRInt32 GetLastError(PRInt32* aReturn);
|
||||
PRInt32 GetWinProfile(nsIDOMInstallFolder* aFolder, const nsString& aFile, PRInt32* aReturn);
|
||||
PRInt32 GetWinProfile(const nsString& 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 Patch(const nsString& aRegName, const nsString& aVersion, const nsString& aJarSource, const nsString& aFolder, const nsString& aTargetName, PRInt32* aReturn);
|
||||
PRInt32 ResetError();
|
||||
PRInt32 SetPackageFolder(nsIDOMInstallFolder* aFolder);
|
||||
PRInt32 SetPackageFolder(const nsString& aFolder);
|
||||
PRInt32 StartInstall(const nsString& aUserPackageName, const nsString& aPackageName, const nsString& aVersion, PRInt32 aFlags, PRInt32* aReturn);
|
||||
PRInt32 Uninstall(const nsString& aPackageName, PRInt32* aReturn);
|
||||
|
||||
|
||||
|
||||
PRInt32 ExtractFileFromJar(const nsString& aJarfile, const nsString& aFinalFile, nsString** aTempFile);
|
||||
void AddPatch(nsHashKey *aKey, nsString* fileName);
|
||||
void GetPatch(nsHashKey *aKey, nsString* fileName);
|
||||
PRInt32 ExtractFileFromJar(const nsString& aJarfile, nsFileSpec* aSuggestedName, nsFileSpec** aRealName);
|
||||
void AddPatch(nsHashKey *aKey, nsFileSpec* fileName);
|
||||
void GetPatch(nsHashKey *aKey, nsFileSpec* fileName);
|
||||
|
||||
void GetJarFileLocation(char** aFile);
|
||||
void SetJarFileLocation(char* aFile);
|
||||
|
@ -119,11 +118,12 @@ class nsInstall
|
|||
PRBool mUninstallPackage;
|
||||
PRBool mRegisterPackage;
|
||||
|
||||
nsString mPackageName; /* Name of the package we are installing */
|
||||
nsString mUserPackageName; /* User-readable package name */
|
||||
nsString mRegistryPackageName; /* Name of the package we are installing */
|
||||
nsString mUIName; /* User-readable package name */
|
||||
|
||||
nsInstallVersion* mVersionInfo; /* Component version info */
|
||||
nsInstallFolder* mPackageFolder;
|
||||
|
||||
nsString* mPackageFolder;
|
||||
|
||||
nsVector* mInstalledFiles;
|
||||
nsHashtable* mPatchList;
|
||||
|
|
|
@ -25,30 +25,29 @@
|
|||
#include "nsInstallDelete.h"
|
||||
|
||||
#include "nsInstall.h"
|
||||
#include "nsIDOMInstallFolder.h"
|
||||
#include "nsIDOMInstallVersion.h"
|
||||
|
||||
#include "nsInstallErrorMessages.h"
|
||||
|
||||
|
||||
nsInstallDelete::nsInstallDelete( nsInstall* inInstall,
|
||||
nsIDOMInstallFolder* folderSpec,
|
||||
const nsString& folderSpec,
|
||||
const nsString& inPartialPath,
|
||||
PRInt32 *error)
|
||||
|
||||
: nsInstallObject(inInstall)
|
||||
{
|
||||
if ((folderSpec == NULL) || (inInstall == NULL))
|
||||
if ((folderSpec == "null") || (inInstall == NULL))
|
||||
{
|
||||
*error = nsInstall::INVALID_ARGUMENTS;
|
||||
return;
|
||||
}
|
||||
|
||||
mDeleteStatus = DELETE_FILE;
|
||||
mFinalFile = "";
|
||||
mFinalFile = nsnull;
|
||||
mRegistryName = "";
|
||||
folderSpec->MakeFullPath(inPartialPath, mFinalFile);
|
||||
|
||||
|
||||
|
||||
mFinalFile = new nsFileSpec(folderSpec);
|
||||
*mFinalFile += inPartialPath;
|
||||
|
||||
*error = ProcessInstallDelete();
|
||||
}
|
||||
|
||||
|
@ -65,7 +64,7 @@ nsInstallDelete::nsInstallDelete( nsInstall* inInstall,
|
|||
}
|
||||
|
||||
mDeleteStatus = DELETE_COMPONENT;
|
||||
mFinalFile = "";
|
||||
mFinalFile = nsnull;
|
||||
mRegistryName = inComponentName;
|
||||
|
||||
*error = ProcessInstallDelete();
|
||||
|
@ -74,6 +73,8 @@ nsInstallDelete::nsInstallDelete( nsInstall* inInstall,
|
|||
|
||||
nsInstallDelete::~nsInstallDelete()
|
||||
{
|
||||
if (mFinalFile == nsnull)
|
||||
delete mFinalFile;
|
||||
}
|
||||
|
||||
|
||||
|
@ -92,9 +93,9 @@ PRInt32 nsInstallDelete::Complete()
|
|||
|
||||
if (mDeleteStatus == DELETE_COMPONENT)
|
||||
{
|
||||
char* tempString = mRegistryName.ToNewCString();
|
||||
err = VR_Remove( tempString );
|
||||
delete tempString;
|
||||
char* temp = mRegistryName.ToNewCString();
|
||||
err = VR_Remove(temp);
|
||||
delete [] temp;
|
||||
}
|
||||
|
||||
if ((mDeleteStatus == DELETE_FILE) || (err == REGERR_OK))
|
||||
|
@ -116,16 +117,6 @@ 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;
|
||||
}
|
||||
|
||||
|
@ -146,45 +137,46 @@ nsInstallDelete::RegisterPackageNode()
|
|||
PRInt32 nsInstallDelete::ProcessInstallDelete()
|
||||
{
|
||||
PRInt32 err;
|
||||
char* tempString;
|
||||
|
||||
char* tempCString = nsnull;
|
||||
|
||||
if (mDeleteStatus == DELETE_COMPONENT)
|
||||
{
|
||||
/* Check if the component is in the registry */
|
||||
tempString = mRegistryName.ToNewCString();
|
||||
err = VR_InRegistry(tempString);
|
||||
delete tempString;
|
||||
|
||||
tempCString = mRegistryName.ToNewCString();
|
||||
|
||||
err = VR_InRegistry( tempCString );
|
||||
|
||||
if (err != REGERR_OK)
|
||||
{
|
||||
return err;
|
||||
}
|
||||
else
|
||||
{
|
||||
tempString = (char*)PR_Calloc(MAXREGPATHLEN, sizeof(char));
|
||||
char* regTempString = mRegistryName.ToNewCString();
|
||||
char* tempRegistryString;
|
||||
|
||||
err = VR_GetPath( regTempString , MAXREGPATHLEN, tempString);
|
||||
tempRegistryString = (char*)PR_Calloc(MAXREGPATHLEN, sizeof(char));
|
||||
|
||||
err = VR_GetPath( tempCString , MAXREGPATHLEN, tempRegistryString);
|
||||
|
||||
delete regTempString;
|
||||
|
||||
if (err == REGERR_OK)
|
||||
{
|
||||
mFinalFile.SetString(tempString);
|
||||
if (mFinalFile)
|
||||
delete mFinalFile;
|
||||
|
||||
mFinalFile = new nsFileSpec(tempRegistryString);
|
||||
}
|
||||
|
||||
PR_FREEIF(tempString);
|
||||
PR_FREEIF(tempRegistryString);
|
||||
}
|
||||
}
|
||||
|
||||
tempString = mFinalFile.ToNewCString();
|
||||
|
||||
nsFileSpec file(tempString);
|
||||
delete tempString;
|
||||
if(tempCString)
|
||||
delete [] tempCString;
|
||||
|
||||
if (file.Exists())
|
||||
if (mFinalFile->Exists())
|
||||
{
|
||||
if (file.IsFile())
|
||||
if (mFinalFile->IsFile())
|
||||
{
|
||||
err = nsInstall::SUCCESS;
|
||||
}
|
||||
|
@ -205,17 +197,13 @@ PRInt32 nsInstallDelete::ProcessInstallDelete()
|
|||
|
||||
PRInt32 nsInstallDelete::NativeComplete()
|
||||
{
|
||||
char * tempFile = mFinalFile.ToNewCString();
|
||||
nsFileSpec file(tempFile);
|
||||
delete tempFile;
|
||||
|
||||
if (file.Exists())
|
||||
if (mFinalFile->Exists())
|
||||
{
|
||||
if (file.IsFile())
|
||||
if (mFinalFile->IsFile())
|
||||
{
|
||||
file.Delete(false);
|
||||
mFinalFile->Delete(false);
|
||||
|
||||
if (file.Exists())
|
||||
if (mFinalFile->Exists())
|
||||
{
|
||||
// If file still exists, we need to delete it later!
|
||||
// FIX DeleteOldFileLater( (char*)finalFile );
|
||||
|
@ -227,9 +215,7 @@ PRInt32 nsInstallDelete::NativeComplete()
|
|||
return nsInstall::FILE_IS_DIRECTORY;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return nsInstall::FILE_DOES_NOT_EXIST;
|
||||
}
|
||||
|
||||
return nsInstall::FILE_DOES_NOT_EXIST;
|
||||
}
|
||||
|
||||
|
|
|
@ -25,7 +25,6 @@
|
|||
#include "nsInstallObject.h"
|
||||
|
||||
#include "nsInstall.h"
|
||||
#include "nsIDOMInstallFolder.h"
|
||||
|
||||
#define DELETE_COMPONENT 1
|
||||
#define DELETE_FILE 2
|
||||
|
@ -35,7 +34,7 @@ class nsInstallDelete : public nsInstallObject
|
|||
public:
|
||||
|
||||
nsInstallDelete( nsInstall* inInstall,
|
||||
nsIDOMInstallFolder* folderSpec,
|
||||
const nsString& folderSpec,
|
||||
const nsString& inPartialPath,
|
||||
PRInt32 *error);
|
||||
|
||||
|
@ -58,9 +57,10 @@ class nsInstallDelete : public nsInstallObject
|
|||
|
||||
/* Private Fields */
|
||||
|
||||
nsString mFinalFile;
|
||||
nsString mRegistryName;
|
||||
PRInt32 mDeleteStatus;
|
||||
nsFileSpec* mFinalFile;
|
||||
|
||||
nsString mRegistryName;
|
||||
PRInt32 mDeleteStatus;
|
||||
|
||||
PRInt32 ProcessInstallDelete();
|
||||
PRInt32 NativeComplete();
|
||||
|
|
|
@ -25,12 +25,8 @@
|
|||
#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,
|
||||
|
@ -53,7 +49,8 @@ nsInstallExecute:: nsInstallExecute( nsInstall* inInstall,
|
|||
|
||||
nsInstallExecute::~nsInstallExecute()
|
||||
{
|
||||
delete mExecutableFile;
|
||||
if (mExecutableFile)
|
||||
delete mExecutableFile;
|
||||
}
|
||||
|
||||
|
||||
|
@ -63,66 +60,42 @@ PRInt32 nsInstallExecute::Prepare()
|
|||
if (mInstall == NULL || mJarLocation == "null")
|
||||
return nsInstall::INVALID_ARGUMENTS;
|
||||
|
||||
return mInstall->ExtractFileFromJar(mJarLocation, "", &mExecutableFile);
|
||||
return mInstall->ExtractFileFromJar(mJarLocation, nsnull, &mExecutableFile);
|
||||
}
|
||||
|
||||
PRInt32 nsInstallExecute::Complete()
|
||||
{
|
||||
if (mExecutableFile == nsnull)
|
||||
return nsInstall::INVALID_ARGUMENTS;
|
||||
|
||||
char* tempCString = mExecutableFile->ToNewCString();
|
||||
|
||||
nsFileSpec appPath(tempCString , false);
|
||||
nsFileSpec appPath( *mExecutableFile, false);
|
||||
|
||||
delete [] tempCString;
|
||||
|
||||
if (!appPath.Exists())
|
||||
{
|
||||
return nsInstall::INVALID_ARGUMENTS;
|
||||
}
|
||||
|
||||
tempCString = mArgs.ToNewCString();
|
||||
|
||||
PRInt32 result = appPath.Execute(tempCString);
|
||||
|
||||
delete [] tempCString;
|
||||
PRInt32 result = appPath.Execute( mArgs );
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
void nsInstallExecute::Abort()
|
||||
{
|
||||
char* currentName;
|
||||
int result;
|
||||
|
||||
/* Get the names */
|
||||
if (mExecutableFile == nsnull)
|
||||
return;
|
||||
|
||||
currentName = mExecutableFile->ToNewCString();
|
||||
|
||||
result = PR_Delete(currentName);
|
||||
PR_ASSERT(result == 0); /* FIX: need to fe_deletefilelater() or something */
|
||||
mExecutableFile->Delete(PR_FALSE);
|
||||
|
||||
delete currentName;
|
||||
if ( mExecutableFile->Exists() )
|
||||
{
|
||||
/* FIX: need to fe_deletefilelater() or something */
|
||||
}
|
||||
}
|
||||
|
||||
char* nsInstallExecute::toString()
|
||||
{
|
||||
nsString fullPathString(mJarLocation);
|
||||
fullPathString.Append(*mExecutableFile);
|
||||
|
||||
if (mExecutableFile == nsnull)
|
||||
{
|
||||
// FIX!
|
||||
// return nsInstallErrorMessages::GetString(nsInstall::DETAILS_EXECUTE_PROGRESS, fullPathString);
|
||||
}
|
||||
else
|
||||
{
|
||||
// return nsInstallErrorMessages::GetString(nsInstall::DETAILS_EXECUTE_PROGRESS2, fullPathString);
|
||||
}
|
||||
|
||||
return nsnull;
|
||||
}
|
||||
|
||||
|
|
|
@ -25,7 +25,6 @@
|
|||
#include "nsInstallObject.h"
|
||||
|
||||
#include "nsInstall.h"
|
||||
#include "nsIDOMInstallFolder.h"
|
||||
#include "nsIDOMInstallVersion.h"
|
||||
|
||||
|
||||
|
@ -55,7 +54,7 @@ class nsInstallExecute : public nsInstallObject
|
|||
nsString mJarLocation; // Location in the JAR
|
||||
nsString mArgs; // command line arguments
|
||||
|
||||
nsString *mExecutableFile; // temporary file location
|
||||
nsFileSpec *mExecutableFile; // temporary file location
|
||||
|
||||
|
||||
PRInt32 NativeComplete(void);
|
||||
|
|
|
@ -15,15 +15,6 @@
|
|||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
#if defined(XP_MAC)
|
||||
#include <stat.h>
|
||||
#else
|
||||
#include <sys/stat.h>
|
||||
#endif
|
||||
|
||||
#include "prio.h"
|
||||
#include "prmem.h"
|
||||
#include "plstr.h"
|
||||
|
||||
#include "nsFileSpec.h"
|
||||
|
||||
|
@ -32,25 +23,6 @@
|
|||
|
||||
#include "nsInstall.h"
|
||||
#include "nsInstallVersion.h"
|
||||
#include "nsIDOMInstallFolder.h"
|
||||
|
||||
|
||||
#include "nsInstallErrorMessages.h"
|
||||
|
||||
static PRBool endsWith(nsString* str, char* string_to_find);
|
||||
|
||||
static PRBool endsWith(nsString* str, char* string_to_find)
|
||||
{
|
||||
PRBool found = PR_FALSE;
|
||||
if (str) {
|
||||
int len = strlen(".zip");
|
||||
int size = str->Length();
|
||||
int offset = str->RFind(string_to_find, PR_FALSE);
|
||||
if (offset == (size - len))
|
||||
found = PR_TRUE;
|
||||
}
|
||||
return found;
|
||||
}
|
||||
|
||||
/* Public Methods */
|
||||
|
||||
|
@ -62,46 +34,38 @@ static PRBool endsWith(nsString* str, char* string_to_find)
|
|||
inFinalFileSpec - final location on disk
|
||||
*/
|
||||
nsInstallFile::nsInstallFile(nsInstall* inInstall,
|
||||
const nsString& inVRName,
|
||||
const nsString& inComponentName,
|
||||
nsIDOMInstallVersion* inVInfo,
|
||||
const nsString& inJarLocation,
|
||||
nsIDOMInstallFolder* folderSpec,
|
||||
const nsString& folderSpec,
|
||||
const nsString& inPartialPath,
|
||||
PRBool forceInstall,
|
||||
PRInt32 *error)
|
||||
: nsInstallObject(inInstall)
|
||||
{
|
||||
mTempFile = nsnull;
|
||||
mExtracedFile= nsnull;
|
||||
mFinalFile = nsnull;
|
||||
mUpgradeFile = PR_FALSE;
|
||||
|
||||
if ((folderSpec == NULL) || (inInstall == NULL) || (inVInfo == NULL))
|
||||
if ((folderSpec == "null") || (inInstall == NULL) || (inVInfo == NULL))
|
||||
{
|
||||
*error = nsInstall::INVALID_ARGUMENTS;
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
mReplaceFile = DoesFileExist();
|
||||
mFinalFile = new nsFileSpec(folderSpec);
|
||||
*mFinalFile += inPartialPath;
|
||||
|
||||
mForceInstall = forceInstall;
|
||||
|
||||
mVersionRegistryName = new nsString(inVRName);
|
||||
mVersionRegistryName = new nsString(inComponentName);
|
||||
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();
|
||||
folderSpec->MakeFullPath(inPartialPath, *mFinalFile);
|
||||
|
||||
|
||||
|
||||
|
||||
mVersionInfo->Init(tempString);
|
||||
|
||||
nsString regPackageName;
|
||||
mInstall->GetRegPackageName(regPackageName);
|
||||
|
||||
|
@ -138,8 +102,8 @@ nsInstallFile::~nsInstallFile()
|
|||
if (mJarLocation)
|
||||
delete mJarLocation;
|
||||
|
||||
if (mTempFile)
|
||||
delete mTempFile;
|
||||
if (mExtracedFile)
|
||||
delete mExtracedFile;
|
||||
|
||||
if (mFinalFile)
|
||||
delete mFinalFile;
|
||||
|
@ -149,14 +113,14 @@ nsInstallFile::~nsInstallFile()
|
|||
}
|
||||
|
||||
/* Prepare
|
||||
* Extracts file out of the JAR archive into the temp directory
|
||||
* Extracts file out of the JAR archive
|
||||
*/
|
||||
PRInt32 nsInstallFile::Prepare()
|
||||
{
|
||||
if (mInstall == NULL || mFinalFile == NULL || mJarLocation == NULL)
|
||||
if (mInstall == nsnull || mFinalFile == nsnull || mJarLocation == nsnull )
|
||||
return nsInstall::INVALID_ARGUMENTS;
|
||||
|
||||
return mInstall->ExtractFileFromJar(*mJarLocation, *mFinalFile, &mTempFile);
|
||||
return mInstall->ExtractFileFromJar(*mJarLocation, mFinalFile, &mExtracedFile);
|
||||
}
|
||||
|
||||
/* Complete
|
||||
|
@ -167,21 +131,95 @@ PRInt32 nsInstallFile::Prepare()
|
|||
PRInt32 nsInstallFile::Complete()
|
||||
{
|
||||
PRInt32 err;
|
||||
int refCount;
|
||||
int rc;
|
||||
|
||||
if (mInstall == NULL || mVersionRegistryName == NULL || mFinalFile == NULL)
|
||||
if (mInstall == nsnull || mVersionRegistryName == nsnull || mFinalFile == nsnull )
|
||||
{
|
||||
return nsInstall::INVALID_ARGUMENTS;
|
||||
}
|
||||
|
||||
/* Check the security for our target */
|
||||
err = CompleteFileMove();
|
||||
|
||||
err = NativeComplete();
|
||||
|
||||
if ( 0 == err || nsInstall::REBOOT_NEEDED == err )
|
||||
{
|
||||
err = RegisterInVersionRegistry();
|
||||
}
|
||||
|
||||
return err;
|
||||
|
||||
char *final_file = mFinalFile->ToNewCString();
|
||||
char *vr_name = mVersionRegistryName->ToNewCString();
|
||||
}
|
||||
|
||||
void nsInstallFile::Abort()
|
||||
{
|
||||
if (mExtracedFile != nsnull)
|
||||
mExtracedFile->Delete(PR_FALSE);
|
||||
}
|
||||
|
||||
char* nsInstallFile::toString()
|
||||
{
|
||||
return nsnull;
|
||||
}
|
||||
|
||||
|
||||
PRInt32 nsInstallFile::CompleteFileMove()
|
||||
{
|
||||
int result = 0;
|
||||
|
||||
if (mExtracedFile == nsnull)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
if ( mExtracedFile->Equals(*mFinalFile) )
|
||||
{
|
||||
/* No need to rename, they are the same */
|
||||
result = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (mFinalFile->Exists() == PR_FALSE)
|
||||
{
|
||||
// We can simple move the extracted file to the mFinalFile's parent
|
||||
nsFileSpec parentofFinalFile;
|
||||
|
||||
mFinalFile->GetParent(parentofFinalFile);
|
||||
result = mExtracedFile->Move(parentofFinalFile);
|
||||
|
||||
char* leafName = mFinalFile->GetLeafName();
|
||||
mExtracedFile->Rename(leafName);
|
||||
delete [] leafName;
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Target exists, can't trust XP_FileRename--do platform specific stuff in FE_ReplaceExistingFile() */
|
||||
// FIX: FE_ReplaceExistingFile()
|
||||
mFinalFile->Delete(PR_FALSE);
|
||||
|
||||
// Now that we have move the existing file, we can move the mExtracedFile into place.
|
||||
nsFileSpec parentofFinalFile;
|
||||
|
||||
mFinalFile->GetParent(parentofFinalFile);
|
||||
result = mExtracedFile->Move(parentofFinalFile);
|
||||
|
||||
char* leafName = mFinalFile->GetLeafName();
|
||||
mExtracedFile->Rename(leafName);
|
||||
delete [] leafName;
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
PRInt32
|
||||
nsInstallFile::RegisterInVersionRegistry()
|
||||
{
|
||||
PRInt32 err;
|
||||
int refCount;
|
||||
int rc;
|
||||
char* tempCString;
|
||||
|
||||
char *final_file = nsFilePath(*mFinalFile); // FIX: mac? What should we be passing to the version registry???
|
||||
char *vr_name = mVersionRegistryName->ToNewCString();
|
||||
|
||||
nsString regPackageName;
|
||||
mInstall->GetRegPackageName(regPackageName);
|
||||
|
@ -189,260 +227,120 @@ PRInt32 nsInstallFile::Complete()
|
|||
|
||||
// Register file and log for Uninstall
|
||||
|
||||
if ( 0 == err || nsInstall::REBOOT_NEEDED == err )
|
||||
// we ignore all registry errors because they're not
|
||||
// important enough to abort an otherwise OK install.
|
||||
if (!mChildFile)
|
||||
{
|
||||
// we ignore all registry errors because they're not
|
||||
// important enough to abort an otherwise OK install.
|
||||
if (!mChildFile)
|
||||
int found;
|
||||
if (regPackageName != "")
|
||||
{
|
||||
int found;
|
||||
if (regPackageName != "")
|
||||
{
|
||||
char *reg_package_name = regPackageName.ToNewCString();
|
||||
found = VR_UninstallFileExistsInList( reg_package_name, vr_name );
|
||||
delete reg_package_name;
|
||||
}
|
||||
else
|
||||
{
|
||||
found = VR_UninstallFileExistsInList( "", vr_name );
|
||||
}
|
||||
|
||||
if (found != REGERR_OK)
|
||||
mUpgradeFile = PR_FALSE;
|
||||
else
|
||||
mUpgradeFile = PR_TRUE;
|
||||
}
|
||||
else if (REGERR_OK == VR_InRegistry(vr_name))
|
||||
{
|
||||
mUpgradeFile = PR_TRUE;
|
||||
tempCString = regPackageName.ToNewCString();
|
||||
found = VR_UninstallFileExistsInList( tempCString , vr_name );
|
||||
}
|
||||
else
|
||||
{
|
||||
found = VR_UninstallFileExistsInList( "", vr_name );
|
||||
}
|
||||
|
||||
if (found != REGERR_OK)
|
||||
mUpgradeFile = PR_FALSE;
|
||||
}
|
||||
|
||||
err = VR_GetRefCount( vr_name, &refCount );
|
||||
if ( err != REGERR_OK )
|
||||
{
|
||||
refCount = 0;
|
||||
}
|
||||
//FIX need to delete char* created by .ToNewCString(). There should be 5 of them. mcmullen told me that
|
||||
// he was working on a nsAutoString that would do this.
|
||||
else
|
||||
mUpgradeFile = PR_TRUE;
|
||||
}
|
||||
else if (REGERR_OK == VR_InRegistry(vr_name))
|
||||
{
|
||||
mUpgradeFile = PR_TRUE;
|
||||
}
|
||||
else
|
||||
{
|
||||
mUpgradeFile = PR_FALSE;
|
||||
}
|
||||
|
||||
if (!mUpgradeFile)
|
||||
err = VR_GetRefCount( vr_name, &refCount );
|
||||
if ( err != REGERR_OK )
|
||||
{
|
||||
refCount = 0;
|
||||
}
|
||||
|
||||
if (!mUpgradeFile)
|
||||
{
|
||||
if (refCount != 0)
|
||||
{
|
||||
if (refCount != 0)
|
||||
{
|
||||
rc = 1 + refCount;
|
||||
nsString tempString;
|
||||
mVersionInfo->ToString(tempString);
|
||||
VR_Install( vr_name, final_file, tempString.ToNewCString(), PR_FALSE );
|
||||
VR_SetRefCount( vr_name, rc );
|
||||
}
|
||||
else
|
||||
{
|
||||
if (mReplaceFile)
|
||||
{
|
||||
nsString tempString;
|
||||
mVersionInfo->ToString(tempString);
|
||||
VR_Install( vr_name, final_file, tempString.ToNewCString(), PR_FALSE);
|
||||
VR_SetRefCount( vr_name, 2 );
|
||||
}
|
||||
else
|
||||
{
|
||||
nsString tempString;
|
||||
mVersionInfo->ToString(tempString);
|
||||
VR_Install( vr_name, final_file, tempString.ToNewCString(), PR_FALSE );
|
||||
VR_SetRefCount( vr_name, 1 );
|
||||
}
|
||||
}
|
||||
rc = 1 + refCount;
|
||||
nsString tempString;
|
||||
mVersionInfo->ToString(tempString);
|
||||
tempCString = regPackageName.ToNewCString();
|
||||
VR_Install( vr_name, final_file, tempCString, PR_FALSE );
|
||||
VR_SetRefCount( vr_name, rc );
|
||||
}
|
||||
else if (mUpgradeFile)
|
||||
else
|
||||
{
|
||||
if (refCount == 0)
|
||||
if (mFinalFile->Exists())
|
||||
{
|
||||
nsString tempString;
|
||||
mVersionInfo->ToString(tempString);
|
||||
VR_Install( vr_name, final_file, tempString.ToNewCString(), PR_FALSE );
|
||||
tempCString = regPackageName.ToNewCString();
|
||||
VR_Install( vr_name, final_file, tempCString, PR_FALSE);
|
||||
VR_SetRefCount( vr_name, 2 );
|
||||
}
|
||||
else
|
||||
{
|
||||
nsString tempString;
|
||||
mVersionInfo->ToString(tempString);
|
||||
tempCString = regPackageName.ToNewCString();
|
||||
VR_Install( vr_name, final_file, tempCString, PR_FALSE );
|
||||
VR_SetRefCount( vr_name, 1 );
|
||||
}
|
||||
else
|
||||
{
|
||||
nsString tempString;
|
||||
mVersionInfo->ToString(tempString);
|
||||
VR_Install( vr_name, final_file, tempString.ToNewCString(), PR_FALSE );
|
||||
VR_SetRefCount( vr_name, 0 );
|
||||
}
|
||||
}
|
||||
|
||||
if ( !mChildFile && !mUpgradeFile )
|
||||
}
|
||||
else if (mUpgradeFile)
|
||||
{
|
||||
if (refCount == 0)
|
||||
{
|
||||
if (regPackageName != "")
|
||||
{
|
||||
char *reg_package_name = regPackageName.ToNewCString();
|
||||
VR_UninstallAddFileToList( reg_package_name, vr_name );
|
||||
delete reg_package_name;
|
||||
}
|
||||
else
|
||||
{
|
||||
VR_UninstallAddFileToList( "", vr_name );
|
||||
}
|
||||
nsString tempString;
|
||||
mVersionInfo->ToString(tempString);
|
||||
tempCString = regPackageName.ToNewCString();
|
||||
VR_Install( vr_name, final_file, tempCString, PR_FALSE );
|
||||
VR_SetRefCount( vr_name, 1 );
|
||||
}
|
||||
else
|
||||
{
|
||||
nsString tempString;
|
||||
mVersionInfo->ToString(tempString);
|
||||
tempCString = regPackageName.ToNewCString();
|
||||
VR_Install( vr_name, final_file, tempCString, PR_FALSE );
|
||||
VR_SetRefCount( vr_name, 0 );
|
||||
}
|
||||
}
|
||||
|
||||
if ( !mChildFile && !mUpgradeFile )
|
||||
{
|
||||
if (regPackageName != "")
|
||||
{
|
||||
if (tempCString == nsnull)
|
||||
tempCString = regPackageName.ToNewCString();
|
||||
|
||||
VR_UninstallAddFileToList( tempCString, vr_name );
|
||||
}
|
||||
else
|
||||
{
|
||||
VR_UninstallAddFileToList( "", vr_name );
|
||||
}
|
||||
}
|
||||
delete vr_name;
|
||||
delete final_file;
|
||||
|
||||
if (vr_name != nsnull)
|
||||
delete vr_name;
|
||||
|
||||
if (tempCString != nsnull)
|
||||
delete [] tempCString;
|
||||
|
||||
if ( err != 0 )
|
||||
return nsInstall::UNEXPECTED_ERROR;
|
||||
|
||||
return nsInstall::SUCCESS;
|
||||
|
||||
}
|
||||
|
||||
void nsInstallFile::Abort()
|
||||
{
|
||||
char* currentName;
|
||||
int result;
|
||||
|
||||
/* Get the names */
|
||||
if (mTempFile == NULL)
|
||||
return;
|
||||
currentName = mTempFile->ToNewCString();
|
||||
|
||||
result = PR_Delete(currentName);
|
||||
PR_ASSERT(result == 0); /* XXX: need to fe_deletefilelater() or something */
|
||||
delete currentName;
|
||||
}
|
||||
|
||||
char* nsInstallFile::toString()
|
||||
{
|
||||
if (mReplaceFile)
|
||||
{
|
||||
return nsInstallErrorMessages::GetString(nsInstall::DETAILS_REPLACE_FILE_MSG_ID, mFinalFile);
|
||||
}
|
||||
else
|
||||
{
|
||||
return nsInstallErrorMessages::GetString(nsInstall::DETAILS_INSTALL_FILE_MSG_ID, mFinalFile);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* Private Methods */
|
||||
|
||||
/* Complete
|
||||
* copies the file to its final location
|
||||
* Tricky, we need to create the directories
|
||||
*/
|
||||
int nsInstallFile::NativeComplete()
|
||||
{
|
||||
char* currentName = NULL;
|
||||
char* finalName = NULL;
|
||||
int result = 0;
|
||||
|
||||
if (mTempFile == nsnull)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* Get the names */
|
||||
currentName = mTempFile->ToNewCString();
|
||||
finalName = mFinalFile->ToNewCString();
|
||||
|
||||
if ( finalName == NULL || currentName == NULL )
|
||||
{
|
||||
/* memory or JRI problems */
|
||||
result = -1;
|
||||
goto end;
|
||||
}
|
||||
|
||||
if ( PL_strcmp(finalName, currentName) == 0 )
|
||||
{
|
||||
/* No need to rename, they are the same */
|
||||
result = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
struct stat finfo;
|
||||
if (stat(finalName, &finfo) != 0)
|
||||
{
|
||||
PR_Rename(currentName, finalName);
|
||||
}
|
||||
else
|
||||
{
|
||||
/* FIX
|
||||
* Target exists, can't trust XP_FileRename--do platform
|
||||
* specific stuff in FE_ReplaceExistingFile()
|
||||
*/
|
||||
result = -1;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (result != 0)
|
||||
{
|
||||
struct stat finfo;
|
||||
if (stat(finalName, &finfo) == 0)
|
||||
{
|
||||
/* File already exists, need to remove the original */
|
||||
// FIX result = FE_ReplaceExistingFile(currentName, xpURL, finalName, xpURL, mForceInstall);
|
||||
if ( result == nsInstall::REBOOT_NEEDED )
|
||||
{
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Directory might not exist, check and create if necessary */
|
||||
char separator;
|
||||
char * end;
|
||||
separator = '/';
|
||||
end = PL_strrchr(finalName, separator);
|
||||
if (end)
|
||||
{
|
||||
end[0] = 0;
|
||||
|
||||
// Lame use of nsFileSpec, but NSPR does not support creation
|
||||
// of nested directories.
|
||||
nsFileSpec* directoryMaker = new nsFileSpec(finalName, PR_TRUE);
|
||||
delete directoryMaker;
|
||||
|
||||
end[0] = separator;
|
||||
if ( 0 == result )
|
||||
{
|
||||
// FIX - this may not work on UNIX between different
|
||||
// filesystems!
|
||||
result = PR_Rename(currentName, finalName);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
end:
|
||||
delete [] finalName;
|
||||
delete [] currentName;
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
/* Finds out if the file exists
|
||||
*/
|
||||
PRBool nsInstallFile::DoesFileExist()
|
||||
{
|
||||
if (mFinalFile == nsnull)
|
||||
return PR_FALSE;
|
||||
|
||||
char* finalName = mFinalFile->ToNewCString();
|
||||
|
||||
struct stat finfo;
|
||||
if ( stat(finalName, &finfo) != -1)
|
||||
{
|
||||
delete [] finalName;
|
||||
return PR_TRUE;
|
||||
}
|
||||
delete [] finalName;
|
||||
return PR_FALSE;
|
||||
}
|
||||
|
||||
|
||||
/* CanUninstall
|
||||
* InstallFile() installs files which can be uninstalled,
|
||||
* hence this function returns true.
|
||||
|
|
|
@ -26,9 +26,6 @@
|
|||
|
||||
#include "nsInstall.h"
|
||||
#include "nsInstallVersion.h"
|
||||
#include "nsIDOMInstallFolder.h"
|
||||
|
||||
|
||||
|
||||
class nsInstallFile : public nsInstallObject
|
||||
{
|
||||
|
@ -48,7 +45,7 @@ class nsInstallFile : public nsInstallObject
|
|||
const nsString& inVRName,
|
||||
nsIDOMInstallVersion* inVInfo,
|
||||
const nsString& inJarLocation,
|
||||
nsIDOMInstallFolder* folderSpec,
|
||||
const nsString& folderSpec,
|
||||
const nsString& inPartialPath,
|
||||
PRBool forceInstall,
|
||||
PRInt32 *error);
|
||||
|
@ -67,21 +64,23 @@ class nsInstallFile : public nsInstallObject
|
|||
private:
|
||||
|
||||
/* Private Fields */
|
||||
nsInstallVersion* mVersionInfo; /* Version info for this file*/
|
||||
nsInstallVersion* mVersionInfo; /* Version info for this file*/
|
||||
|
||||
nsString* mJarLocation; /* Location in the JAR */
|
||||
nsString* mTempFile; /* temporary file location */
|
||||
nsString* mFinalFile; /* final file destination */
|
||||
nsString* mJarLocation; /* Location in the JAR */
|
||||
nsFileSpec* mExtracedFile; /* temporary file location */
|
||||
nsFileSpec* mFinalFile; /* final file destination */
|
||||
|
||||
nsString* mVersionRegistryName; /* full version path */
|
||||
|
||||
PRBool mForceInstall; /* whether install is forced */
|
||||
PRBool mJavaInstall; /* whether file is installed to a Java directory */
|
||||
PRBool mReplaceFile; /* whether file exists */
|
||||
PRBool mChildFile; /* whether file is a child */
|
||||
PRBool mUpgradeFile; /* whether file is an upgrade */
|
||||
PRBool mUpgradeFile; /* whether file is an upgrade */
|
||||
|
||||
int NativeComplete();
|
||||
PRBool DoesFileExist();
|
||||
|
||||
PRInt32 CompleteFileMove();
|
||||
PRInt32 RegisterInVersionRegistry();
|
||||
};
|
||||
|
||||
#endif /* nsInstallFile_h__ */
|
||||
|
|
|
@ -17,489 +17,189 @@
|
|||
* Netscape Communications Corporation. All Rights Reserved.
|
||||
*/
|
||||
|
||||
#include "nsSoftwareUpdate.h"
|
||||
|
||||
#include "nsInstall.h"
|
||||
#include "nsInstallFolder.h"
|
||||
#include "nsIDOMInstallFolder.h"
|
||||
|
||||
#include "nscore.h"
|
||||
#include "nsIFactory.h"
|
||||
#include "nsISupports.h"
|
||||
#include "nsIScriptGlobalObject.h"
|
||||
#include "prtypes.h"
|
||||
|
||||
#include "prefapi.h"
|
||||
#include "pratom.h"
|
||||
#include "prprf.h"
|
||||
#include "nsString.h"
|
||||
#include "nsFileSpec.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(kIInstallFolder_IID, NS_IDOMINSTALLFOLDER_IID);
|
||||
|
||||
|
||||
|
||||
#ifndef MAX_PATH
|
||||
#if defined(XP_WIN) || defined(XP_OS2)
|
||||
#define MAX_PATH _MAX_PATH
|
||||
#endif
|
||||
#ifdef XP_UNIX
|
||||
#if defined(HPUX) || defined(SCO)
|
||||
/*
|
||||
** HPUX: PATH_MAX is defined in <limits.h> to be 1023, but they
|
||||
** recommend that it not be used, and that pathconf() be
|
||||
** used to determine the maximum at runtime.
|
||||
** SCO: This is what MAXPATHLEN is set to in <arpa/ftp.h> and
|
||||
** NL_MAXPATHLEN in <nl_types.h>. PATH_MAX is defined in
|
||||
** <limits.h> to be 256, but the comments in that file
|
||||
** claim the setting is wrong.
|
||||
*/
|
||||
#define MAX_PATH 1024
|
||||
#else
|
||||
#define MAX_PATH PATH_MAX
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
|
||||
typedef enum SecurityLevel {
|
||||
eOneFolderAccess,
|
||||
eAllFolderAccess
|
||||
} SecurityLevel;
|
||||
|
||||
struct DirectoryTable
|
||||
{
|
||||
char * directoryName; /* The formal directory name */
|
||||
PRInt32 folderEnum; /* Directory ID */
|
||||
PRBool bJavaDir; /* TRUE is a Java-capable directory */
|
||||
};
|
||||
|
||||
|
||||
/*
|
||||
* Directory manipulation
|
||||
*
|
||||
* DirectoryTable holds the info about built-in directories:
|
||||
* Text name, security level, enum
|
||||
*/
|
||||
struct DirectoryTable DirectoryTable[] =
|
||||
{
|
||||
{"Plugins", nsIDOMInstallFolder::PluginFolder, PR_TRUE},
|
||||
{"Program", nsIDOMInstallFolder::ProgramFolder, PR_FALSE},
|
||||
{"Communicator", nsIDOMInstallFolder::CommunicatorFolder, PR_FALSE},
|
||||
{"User Pick", nsIDOMInstallFolder::PackageFolder, PR_FALSE},
|
||||
{"Temporary", nsIDOMInstallFolder::TemporaryFolder, PR_FALSE},
|
||||
{"Installed", nsIDOMInstallFolder::InstalledFolder, PR_FALSE},
|
||||
{"Current User", nsIDOMInstallFolder::CurrentUserFolder, PR_FALSE},
|
||||
{"Plugins", 100 },
|
||||
{"Program", 101 },
|
||||
{"Communicator", 102 },
|
||||
{"User Pick", 103 },
|
||||
{"Temporary", 104 },
|
||||
{"Installed", 105 },
|
||||
{"Current User", 106 },
|
||||
{"NetHelp", 107 },
|
||||
{"OS Drive", 108 },
|
||||
{"File URL", 109 },
|
||||
|
||||
{"NetHelp", nsIDOMInstallFolder::NetHelpFolder, PR_FALSE},
|
||||
{"OS Drive", nsIDOMInstallFolder::OSDriveFolder, PR_FALSE},
|
||||
{"File URL", nsIDOMInstallFolder::FileURLFolder, PR_FALSE},
|
||||
{"Win System", 200 },
|
||||
{"Windows", 201 },
|
||||
|
||||
{"Netscape Java Bin", nsIDOMInstallFolder::JavaBinFolder, PR_FALSE},
|
||||
{"Netscape Java Classes", nsIDOMInstallFolder::JavaClassesFolder, PR_TRUE},
|
||||
{"Java Download", nsIDOMInstallFolder::JavaDownloadFolder, PR_TRUE},
|
||||
{"Mac System", 300 },
|
||||
{"Mac Desktop", 301 },
|
||||
{"Mac Trash", 302 },
|
||||
{"Mac Startup", 303 },
|
||||
{"Mac Shutdown", 304 },
|
||||
{"Mac Apple Menu", 305 },
|
||||
{"Mac Control Panel", 306 },
|
||||
{"Mac Extension", 307 },
|
||||
{"Mac Fonts", 308 },
|
||||
{"Mac Preferences", 309 },
|
||||
|
||||
{"Win System", nsIDOMInstallFolder::Win_SystemFolder, PR_FALSE},
|
||||
{"Win System16", nsIDOMInstallFolder::Win_System16Folder, PR_FALSE},
|
||||
{"Windows", nsIDOMInstallFolder::Win_WindowsFolder, PR_FALSE},
|
||||
{"Unix Local", 400 },
|
||||
{"Unix Lib", 401 },
|
||||
|
||||
{"Mac System", nsIDOMInstallFolder::Mac_SystemFolder, PR_FALSE},
|
||||
{"Mac Desktop", nsIDOMInstallFolder::Mac_DesktopFolder, PR_FALSE},
|
||||
{"Mac Trash", nsIDOMInstallFolder::Mac_TrashFolder, PR_FALSE},
|
||||
{"Mac Startup", nsIDOMInstallFolder::Mac_StartupFolder, PR_FALSE},
|
||||
{"Mac Shutdown", nsIDOMInstallFolder::Mac_ShutdownFolder, PR_FALSE},
|
||||
{"Mac Apple Menu", nsIDOMInstallFolder::Mac_AppleMenuFolder, PR_FALSE},
|
||||
{"Mac Control Panel", nsIDOMInstallFolder::Mac_ControlPanelFolder, PR_FALSE},
|
||||
{"Mac Extension", nsIDOMInstallFolder::Mac_ExtensionFolder, PR_FALSE},
|
||||
{"Mac Fonts", nsIDOMInstallFolder::Mac_FontsFolder, PR_FALSE},
|
||||
{"Mac Preferences", nsIDOMInstallFolder::Mac_PreferencesFolder, PR_FALSE},
|
||||
|
||||
{"Unix Local", nsIDOMInstallFolder::Unix_LocalFolder, PR_FALSE},
|
||||
{"Unix Lib", nsIDOMInstallFolder::Unix_LibFolder, PR_FALSE},
|
||||
|
||||
{"", nsIDOMInstallFolder::BadFolder, PR_FALSE} /* Termination */
|
||||
{"", -1 }
|
||||
};
|
||||
|
||||
|
||||
nsInstallFolder::nsInstallFolder()
|
||||
|
||||
nsInstallFolder::nsInstallFolder(const nsString& aFolderID)
|
||||
{
|
||||
mScriptObject = nsnull;
|
||||
|
||||
mUrlPath = mFolderID = mVersionRegistryPath = mUserPackageName = nsnull;
|
||||
|
||||
NS_INIT_REFCNT();
|
||||
nsInstallFolder(aFolderID, "");
|
||||
}
|
||||
|
||||
nsInstallFolder::nsInstallFolder(const nsString& aFolderID, const nsString& aRelativePath)
|
||||
{
|
||||
mUrlPath = nsnull;
|
||||
|
||||
if ( aFolderID == "null")
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
SetDirectoryPath( aFolderID, aRelativePath);
|
||||
}
|
||||
|
||||
|
||||
nsInstallFolder::~nsInstallFolder()
|
||||
{
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsInstallFolder::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(kIInstallFolder_IID) )
|
||||
{
|
||||
*aInstancePtr = (void*) ((nsIDOMInstallFolder*)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(nsInstallFolder)
|
||||
NS_IMPL_RELEASE(nsInstallFolder)
|
||||
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsInstallFolder::GetScriptObject(nsIScriptContext *aContext, void** aScriptObject)
|
||||
{
|
||||
NS_PRECONDITION(nsnull != aScriptObject, "null arg");
|
||||
nsresult res = NS_OK;
|
||||
|
||||
if (nsnull == mScriptObject)
|
||||
{
|
||||
res = NS_NewScriptInstallFolder( aContext,
|
||||
(nsISupports *)(nsIDOMInstallFolder*)this,
|
||||
nsnull,
|
||||
&mScriptObject);
|
||||
}
|
||||
|
||||
|
||||
*aScriptObject = mScriptObject;
|
||||
return res;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsInstallFolder::SetScriptObject(void *aScriptObject)
|
||||
{
|
||||
mScriptObject = aScriptObject;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
// this will go away when our constructors can have parameters.
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsInstallFolder::Init(const nsString& aFolderID, const nsString& aVrPatch, const nsString& aPackageName)
|
||||
{
|
||||
/* Since urlPath is set to NULL, this FolderSpec is essentially the error message */
|
||||
|
||||
if ( aFolderID == "null" || aPackageName == "null")
|
||||
{
|
||||
return NS_OK; // should we stop the script?
|
||||
}
|
||||
|
||||
mFolderID = new nsString(aFolderID);
|
||||
mVersionRegistryPath = new nsString(aVrPatch);
|
||||
mUserPackageName = new nsString(aPackageName);
|
||||
|
||||
/* Setting the urlPath to a real file patch. */
|
||||
SetDirectoryPath( &mUrlPath );
|
||||
|
||||
return NS_OK;
|
||||
if (mUrlPath != nsnull)
|
||||
delete mUrlPath;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
void
|
||||
nsInstallFolder::GetDirectoryPath(nsString& aDirectoryPath)
|
||||
{
|
||||
aDirectoryPath.SetLength(0);
|
||||
aDirectoryPath.Append(*mUrlPath);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsInstallFolder::MakeFullPath(const nsString& aRelativePath, nsString& aFullPath)
|
||||
{
|
||||
nsString *tempString = GetNativePath(aRelativePath);
|
||||
|
||||
aFullPath.SetLength(0);
|
||||
|
||||
if (mUrlPath != nsnull)
|
||||
{
|
||||
aFullPath.Append( *mUrlPath );
|
||||
}
|
||||
|
||||
if (tempString != nsnull)
|
||||
{
|
||||
aFullPath.Append( *tempString );
|
||||
delete tempString;
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsInstallFolder::IsJavaCapable(PRBool* aReturn)
|
||||
{
|
||||
*aReturn = PR_FALSE; // FIX: what are we going to do here.
|
||||
return -1;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsInstallFolder::ToString(nsString& aFolderString)
|
||||
{
|
||||
return GetDirectoryPath(aFolderString);
|
||||
}
|
||||
|
||||
void
|
||||
nsInstallFolder::SetDirectoryPath(nsString** aFolderString)
|
||||
nsInstallFolder::SetDirectoryPath(const nsString& aFolderID, const nsString& aRelativePath)
|
||||
{
|
||||
if ( mFolderID->EqualsIgnoreCase("User Pick") )
|
||||
if ( aFolderID.EqualsIgnoreCase("User Pick") )
|
||||
{
|
||||
PickDefaultDirectory(&mUrlPath);
|
||||
PickDefaultDirectory();
|
||||
}
|
||||
else if ( mFolderID->EqualsIgnoreCase("Installed") )
|
||||
{
|
||||
mUrlPath = mVersionRegistryPath->ToNewString();
|
||||
else if ( aFolderID.EqualsIgnoreCase("Installed") )
|
||||
{
|
||||
mUrlPath = new nsFileSpec(aRelativePath, PR_TRUE); // creates the directories to the relative path.
|
||||
}
|
||||
else
|
||||
{
|
||||
PRInt32 folderDirSpecID;
|
||||
char* folderPath = NULL;
|
||||
|
||||
folderDirSpecID = MapNameToEnum(mFolderID);
|
||||
PRInt32 folderDirSpecID = MapNameToEnum(aFolderID);
|
||||
|
||||
switch (folderDirSpecID)
|
||||
{
|
||||
case nsIDOMInstallFolder::BadFolder:
|
||||
folderPath = NULL;
|
||||
break;
|
||||
case 100: // Plugins
|
||||
|
||||
case nsIDOMInstallFolder::CurrentUserFolder:
|
||||
{
|
||||
char dir[MAX_PATH];
|
||||
int len = MAX_PATH;
|
||||
if ( PREF_GetCharPref("profile.directory", dir, &len) == PREF_NOERROR)
|
||||
{
|
||||
// char * platformDir = WH_FileName(dir, xpURL);
|
||||
// if (platformDir)
|
||||
// folderPath = AppendSlashToDirPath(platformDir);
|
||||
// PR_FREEIF(platformDir);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 101: // Program
|
||||
|
||||
case 102: // Communicator
|
||||
|
||||
case 103: // User Pick
|
||||
// we should never be here.
|
||||
break;
|
||||
case 104: // Temporary
|
||||
|
||||
case 105: // Installed
|
||||
// we should never be here.
|
||||
break;
|
||||
case 106: // Current User
|
||||
|
||||
case 107: // NetHelp
|
||||
|
||||
case 108: // OS Drive
|
||||
|
||||
case 109: // File URL
|
||||
|
||||
default:
|
||||
/* Get the FE path */
|
||||
// folderPath = FE_GetDirectoryPath(folderDirSpecID);
|
||||
break;
|
||||
|
||||
case 200: // Win System
|
||||
|
||||
case 201: // Windows
|
||||
|
||||
case 300: // Mac System
|
||||
|
||||
case 301: // Mac Desktop
|
||||
|
||||
case 302: // Mac Trash
|
||||
|
||||
case 303: // Mac Startup
|
||||
|
||||
case 304: // Mac Shutdown
|
||||
|
||||
case 305: // Mac Apple Menu
|
||||
|
||||
case 306: // Mac Control Panel
|
||||
|
||||
case 307: // Mac Extension
|
||||
|
||||
case 308: // Mac Fonts
|
||||
|
||||
case 309: // Mac Preferences
|
||||
|
||||
case 400: // Unix Local
|
||||
case 401: // Unix Lib
|
||||
|
||||
// Insert code here...
|
||||
|
||||
case -1:
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
nsString* nsInstallFolder::GetNativePath(const nsString& path)
|
||||
void nsInstallFolder::PickDefaultDirectory()
|
||||
{
|
||||
char pathSeparator;
|
||||
char xp_pathSeparator = '/';
|
||||
|
||||
#ifdef XP_WIN
|
||||
pathSeparator = '\\';
|
||||
#elif defined(XP_MAC)
|
||||
pathSeparator = ':';
|
||||
#else /* XP_UNIX */
|
||||
pathSeparator = '/';
|
||||
#endif
|
||||
|
||||
nsString *xpPath = new nsString(path);
|
||||
PRInt32 offset = xpPath->FindCharInSet(&xp_pathSeparator);
|
||||
|
||||
while (offset != -1)
|
||||
{
|
||||
xpPath[offset] = pathSeparator;
|
||||
offset = xpPath->FindCharInSet(&xp_pathSeparator, offset);
|
||||
}
|
||||
|
||||
return xpPath;
|
||||
//FIX: Need to put up a dialog here and set mUrlPath
|
||||
return;
|
||||
}
|
||||
|
||||
void nsInstallFolder::PickDefaultDirectory(nsString** aFolderString)
|
||||
{
|
||||
return; //FIX: Need to put up a dialog here!
|
||||
}
|
||||
|
||||
PRBool nsInstallFolder::IsJavaDir(void)
|
||||
{
|
||||
for (int i=0; DirectoryTable[i].directoryName[0] != 0; i++ )
|
||||
{
|
||||
if ( mFolderID->EqualsIgnoreCase(DirectoryTable[i].directoryName) )
|
||||
return DirectoryTable[i].bJavaDir;
|
||||
}
|
||||
return PR_FALSE;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* MapNameToEnum
|
||||
* maps name from the directory table to its enum */
|
||||
PRInt32
|
||||
nsInstallFolder::MapNameToEnum(nsString* name)
|
||||
nsInstallFolder::MapNameToEnum(const nsString& name)
|
||||
{
|
||||
int i = 0;
|
||||
|
||||
if ( name == nsnull )
|
||||
return nsIDOMInstallFolder::BadFolder;
|
||||
if ( name == "null")
|
||||
return -1;
|
||||
|
||||
while ( DirectoryTable[i].directoryName[0] != 0 )
|
||||
{
|
||||
if ( name->EqualsIgnoreCase(DirectoryTable[i].directoryName) )
|
||||
if ( name.EqualsIgnoreCase(DirectoryTable[i].directoryName) )
|
||||
return DirectoryTable[i].folderEnum;
|
||||
i++;
|
||||
}
|
||||
return nsIDOMInstallFolder::BadFolder;
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
Makes sure that the path ends with a slash (or other platform end character)
|
||||
*/
|
||||
|
||||
void
|
||||
nsInstallFolder::AppendSlashToDirPath(nsString* dirPath)
|
||||
{
|
||||
char pathSeparator;
|
||||
|
||||
#ifdef XP_WIN
|
||||
pathSeparator = '\\';
|
||||
#elif defined(XP_MAC)
|
||||
pathSeparator = ':';
|
||||
#else /* XP_UNIX */
|
||||
pathSeparator = '/';
|
||||
#endif
|
||||
|
||||
if ( dirPath->CharAt( dirPath->Last() ) != pathSeparator )
|
||||
{
|
||||
dirPath += pathSeparator;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
static PRInt32 gInstallFolderInstanceCnt = 0;
|
||||
static PRInt32 gInstallFolderLock = 0;
|
||||
|
||||
nsInstallFolderFactory::nsInstallFolderFactory(void)
|
||||
{
|
||||
mRefCnt=0;
|
||||
PR_AtomicIncrement(&gInstallFolderInstanceCnt);
|
||||
}
|
||||
|
||||
nsInstallFolderFactory::~nsInstallFolderFactory(void)
|
||||
{
|
||||
PR_AtomicDecrement(&gInstallFolderInstanceCnt);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsInstallFolderFactory::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
|
||||
nsInstallFolderFactory::AddRef(void)
|
||||
{
|
||||
return ++mRefCnt;
|
||||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsInstallFolderFactory::Release(void)
|
||||
{
|
||||
if (--mRefCnt ==0)
|
||||
{
|
||||
delete this;
|
||||
return 0; // Don't access mRefCnt after deleting!
|
||||
}
|
||||
|
||||
return mRefCnt;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsInstallFolderFactory::CreateInstance(nsISupports *aOuter, REFNSIID aIID, void **aResult)
|
||||
{
|
||||
if (aResult == NULL)
|
||||
{
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
}
|
||||
|
||||
*aResult = NULL;
|
||||
|
||||
/* do I have to use iSupports? */
|
||||
nsInstallFolder *inst = new nsInstallFolder();
|
||||
|
||||
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
|
||||
nsInstallFolderFactory::LockFactory(PRBool aLock)
|
||||
{
|
||||
if (aLock)
|
||||
PR_AtomicIncrement(&gInstallFolderLock);
|
||||
else
|
||||
PR_AtomicDecrement(&gInstallFolderLock);
|
||||
|
||||
return NS_OK;
|
||||
}
|
|
@ -2,70 +2,33 @@
|
|||
#define __NS_INSTALLFOLDER_H__
|
||||
|
||||
#include "nscore.h"
|
||||
#include "nsString.h"
|
||||
#include "nsIFactory.h"
|
||||
#include "nsISupports.h"
|
||||
#include "nsIScriptObjectOwner.h"
|
||||
|
||||
#include "nsIDOMInstallFolder.h"
|
||||
#include "nsSoftwareUpdate.h"
|
||||
|
||||
#include "prtypes.h"
|
||||
|
||||
class nsInstallFolder: public nsIScriptObjectOwner, public nsIDOMInstallFolder
|
||||
#include "nsString.h"
|
||||
#include "nsFileSpec.h"
|
||||
|
||||
|
||||
class nsInstallFolder
|
||||
{
|
||||
public:
|
||||
static const nsIID& IID() { static nsIID iid = NS_SoftwareUpdateInstallFolder_CID; return iid; }
|
||||
|
||||
nsInstallFolder();
|
||||
|
||||
nsInstallFolder(const nsString& aFolderID);
|
||||
nsInstallFolder(const nsString& aFolderID, const nsString& aRelativePath);
|
||||
~nsInstallFolder();
|
||||
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
NS_IMETHOD GetScriptObject(nsIScriptContext *aContext, void** aScriptObject);
|
||||
NS_IMETHOD SetScriptObject(void* aScriptObject);
|
||||
|
||||
NS_IMETHOD Init(const nsString& aFolderID, const nsString& aVrPatch, const nsString& aPackageName);
|
||||
|
||||
NS_IMETHOD GetDirectoryPath(nsString& aDirectoryPath);
|
||||
NS_IMETHOD MakeFullPath(const nsString& aRelativePath, nsString& aFullPath);
|
||||
NS_IMETHOD IsJavaCapable(PRBool* aReturn);
|
||||
NS_IMETHOD ToString(nsString& aFolderString);
|
||||
|
||||
|
||||
|
||||
void GetDirectoryPath(nsString& aDirectoryPath);
|
||||
|
||||
private:
|
||||
void *mScriptObject;
|
||||
|
||||
nsString* mUrlPath; // Full path to the directory. Used to cache results from GetDirectoryPath
|
||||
nsString* mFolderID; // Unique string specifying a folder
|
||||
nsString* mVersionRegistryPath; // Version registry path of the package
|
||||
nsString* mUserPackageName; // Name of the package presented to the user
|
||||
nsFileSpec* mUrlPath;
|
||||
|
||||
void SetDirectoryPath(const nsString& aFolderID, const nsString& aRelativePath);
|
||||
|
||||
void PickDefaultDirectory();
|
||||
|
||||
PRInt32 MapNameToEnum(const nsString& name);
|
||||
|
||||
void SetDirectoryPath(nsString** aFolderString);
|
||||
void PickDefaultDirectory(nsString** aFolderString);
|
||||
nsString* GetNativePath(const nsString& path);
|
||||
PRInt32 MapNameToEnum(nsString* name);
|
||||
void AppendSlashToDirPath(nsString* dirPath);
|
||||
PRBool IsJavaDir(void);
|
||||
};
|
||||
|
||||
|
||||
class nsInstallFolderFactory : public nsIFactory
|
||||
{
|
||||
public:
|
||||
|
||||
nsInstallFolderFactory();
|
||||
~nsInstallFolderFactory();
|
||||
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
NS_IMETHOD CreateInstance(nsISupports *aOuter,
|
||||
REFNSIID aIID,
|
||||
void **aResult);
|
||||
|
||||
NS_IMETHOD LockFactory(PRBool aLock);
|
||||
|
||||
};
|
||||
|
||||
#endif
|
|
@ -16,20 +16,14 @@
|
|||
* Reserved.
|
||||
*/
|
||||
|
||||
#include "prmem.h"
|
||||
|
||||
#include "nsCRT.h"
|
||||
|
||||
#include "nsFileSpec.h"
|
||||
|
||||
#include "VerReg.h"
|
||||
#include "nsInstallPatch.h"
|
||||
|
||||
#include "prmem.h"
|
||||
#include "nsInstall.h"
|
||||
#include "nsIDOMInstallFolder.h"
|
||||
#include "nsInstallPatch.h"
|
||||
#include "nsIDOMInstallVersion.h"
|
||||
|
||||
#include "nsInstallErrorMessages.h"
|
||||
#include "VerReg.h"
|
||||
|
||||
|
||||
|
||||
nsInstallPatch::nsInstallPatch( nsInstall* inInstall,
|
||||
|
@ -40,41 +34,26 @@ nsInstallPatch::nsInstallPatch( nsInstall* inInstall,
|
|||
|
||||
: nsInstallObject(inInstall)
|
||||
{
|
||||
if ((inInstall == nsnull) || (inVRName == "null") || (inJarLocation == "null"))
|
||||
{
|
||||
*error = nsInstall::INVALID_ARGUMENTS;
|
||||
return;
|
||||
}
|
||||
char* tempTargetFile = new char[MAXREGPATHLEN];
|
||||
char* tempVersionString = inVRName.ToNewCString();
|
||||
|
||||
mRegistryName = inVRName;
|
||||
mVersionInfo = inVInfo; /* Who owns this object? May be we should make a copy of it */
|
||||
PRInt32 err = VR_GetPath(tempVersionString, MAXREGPATHLEN, tempTargetFile );
|
||||
|
||||
mJarLocation = inJarLocation;
|
||||
|
||||
mPatchFile = nsnull;
|
||||
|
||||
mTargetFile = "";
|
||||
mPatchedFile = "";
|
||||
|
||||
char* tempTargetFile = (char*) PR_MALLOC(MAXREGPATHLEN);
|
||||
char* tempVRName = inVRName.ToNewCString();
|
||||
|
||||
PRInt32 err = VR_GetPath( tempVRName, MAXREGPATHLEN, tempTargetFile );
|
||||
delete [] tempVersionString;
|
||||
|
||||
if (err != REGERR_OK)
|
||||
{
|
||||
PR_FREEIF(tempTargetFile);
|
||||
if(tempTargetFile)
|
||||
delete [] tempTargetFile;
|
||||
|
||||
*error = nsInstall::NO_SUCH_COMPONENT;
|
||||
return;
|
||||
}
|
||||
|
||||
mTargetFile.SetString(tempTargetFile);
|
||||
|
||||
delete tempVRName;
|
||||
|
||||
nsInstallPatch( inInstall, inVRName, inVInfo, inJarLocation, nsString(tempTargetFile), "null", error);
|
||||
|
||||
delete tempTargetFile;
|
||||
|
||||
*error = nsInstall::SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
|
@ -82,7 +61,7 @@ nsInstallPatch::nsInstallPatch( nsInstall* inInstall,
|
|||
const nsString& inVRName,
|
||||
nsIDOMInstallVersion* inVInfo,
|
||||
const nsString& inJarLocation,
|
||||
nsIDOMInstallFolder* folderSpec,
|
||||
const nsString& folderSpec,
|
||||
const nsString& inPartialPath,
|
||||
PRInt32 *error)
|
||||
|
||||
|
@ -93,21 +72,44 @@ nsInstallPatch::nsInstallPatch( nsInstall* inInstall,
|
|||
*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 = nsnull;
|
||||
mPatchedFile = "";
|
||||
mTargetFile = nsnull;
|
||||
mPatchedFile = nsnull;
|
||||
mRegistryName = new nsString(inVRName);
|
||||
mJarLocation = new nsString(inJarLocation);
|
||||
|
||||
folderSpec->MakeFullPath(inPartialPath, mTargetFile);
|
||||
nsString tempString;
|
||||
inVInfo->ToString(tempString);
|
||||
mVersionInfo = new nsInstallVersion();
|
||||
mVersionInfo->Init(tempString);
|
||||
|
||||
|
||||
mTargetFile = new nsFileSpec(folderSpec);
|
||||
if(inPartialPath != "null")
|
||||
*mTargetFile += inPartialPath;
|
||||
}
|
||||
|
||||
nsInstallPatch::~nsInstallPatch()
|
||||
{
|
||||
if (mPatchFile != nsnull)
|
||||
if (mVersionInfo)
|
||||
delete mVersionInfo;
|
||||
|
||||
if (mTargetFile)
|
||||
delete mTargetFile;
|
||||
|
||||
if (mJarLocation)
|
||||
delete mJarLocation;
|
||||
|
||||
if (mRegistryName)
|
||||
delete mRegistryName;
|
||||
|
||||
if (mPatchedFile)
|
||||
delete mPatchedFile;
|
||||
|
||||
if (mPatchFile)
|
||||
delete mPatchFile;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
@ -116,13 +118,12 @@ PRInt32 nsInstallPatch::Prepare()
|
|||
PRInt32 err;
|
||||
PRBool deleteOldSrc;
|
||||
|
||||
char *tempString = mTargetFile.ToNewCString();
|
||||
nsFileSpec file(tempString);
|
||||
delete tempString;
|
||||
if (mTargetFile == nsnull)
|
||||
return nsInstall::INVALID_ARGUMENTS;
|
||||
|
||||
if (file.Exists())
|
||||
if (mTargetFile->Exists())
|
||||
{
|
||||
if (file.IsFile())
|
||||
if (mTargetFile->IsFile())
|
||||
{
|
||||
err = nsInstall::SUCCESS;
|
||||
}
|
||||
|
@ -141,11 +142,11 @@ PRInt32 nsInstallPatch::Prepare()
|
|||
return err;
|
||||
}
|
||||
|
||||
err = mInstall->ExtractFileFromJar(mJarLocation, mTargetFile, &mPatchFile);
|
||||
err = mInstall->ExtractFileFromJar(*mJarLocation, mTargetFile, &mPatchFile);
|
||||
|
||||
|
||||
nsString *fileName = nsnull;
|
||||
nsVoidKey ikey( (void*) nsCRT::HashValue( mTargetFile.GetUnicode() ) );
|
||||
nsFileSpec *fileName = nsnull;
|
||||
nsVoidKey ikey( HashFilePath( nsFilePath(*mTargetFile) ) );
|
||||
|
||||
mInstall->GetPatch(&ikey, fileName);
|
||||
|
||||
|
@ -155,20 +156,22 @@ PRInt32 nsInstallPatch::Prepare()
|
|||
}
|
||||
else
|
||||
{
|
||||
fileName = new nsString(mTargetFile);
|
||||
fileName = mTargetFile;
|
||||
deleteOldSrc = PR_FALSE;
|
||||
}
|
||||
|
||||
err = NativePatch( *fileName, *mPatchFile, mPatchedFile);
|
||||
err = NativePatch( *fileName, // the file to patch
|
||||
*mPatchFile, // the patch that was extracted from the jarfile
|
||||
&mPatchedFile); // the new patched file
|
||||
|
||||
if (err != nsInstall::SUCCESS)
|
||||
{
|
||||
return err;
|
||||
}
|
||||
|
||||
if ( mPatchedFile != "" )
|
||||
if ( mPatchedFile != nsnull )
|
||||
{
|
||||
mInstall->AddPatch(&ikey, &mPatchedFile );
|
||||
mInstall->AddPatch(&ikey, mPatchedFile );
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -179,7 +182,7 @@ PRInt32 nsInstallPatch::Prepare()
|
|||
|
||||
if ( deleteOldSrc )
|
||||
{
|
||||
NativeDeleteFile( *fileName );
|
||||
NativeDeleteFile( fileName );
|
||||
}
|
||||
|
||||
return err;
|
||||
|
@ -187,38 +190,37 @@ PRInt32 nsInstallPatch::Prepare()
|
|||
|
||||
PRInt32 nsInstallPatch::Complete()
|
||||
{
|
||||
if ((mInstall == nsnull) || (mVersionInfo == nsnull) || (mPatchedFile == "") || (mTargetFile == ""))
|
||||
if ((mInstall == nsnull) || (mVersionInfo == nsnull) || (mPatchedFile == nsnull) || (mTargetFile == nsnull))
|
||||
{
|
||||
return nsInstall::INVALID_ARGUMENTS;
|
||||
}
|
||||
|
||||
PRInt32 err = nsInstall::SUCCESS;
|
||||
|
||||
nsString *fileName = nsnull;
|
||||
nsVoidKey ikey( (void*) nsCRT::HashValue( mTargetFile.GetUnicode() ) );
|
||||
nsFileSpec *fileName = nsnull;
|
||||
nsVoidKey ikey( HashFilePath( nsFilePath(*mTargetFile) ) );
|
||||
|
||||
mInstall->GetPatch(&ikey, fileName);
|
||||
|
||||
if (fileName != nsnull && fileName->Equals(mPatchedFile) )
|
||||
if (fileName != nsnull && fileName->Equals(*mPatchedFile) )
|
||||
{
|
||||
// the patch has not been superceded--do final replacement
|
||||
err = NativeReplace( mTargetFile, mPatchedFile );
|
||||
err = NativeReplace( *mTargetFile, *mPatchedFile );
|
||||
if ( 0 == err || nsInstall::REBOOT_NEEDED == err )
|
||||
{
|
||||
// WHY DO nsString suck so bad!
|
||||
nsString tempVersionString;
|
||||
mVersionInfo->ToString(tempVersionString);
|
||||
|
||||
char* tempRegName = mRegistryName->ToNewCString();
|
||||
char* tempVersion = tempVersionString.ToNewCString();
|
||||
|
||||
char* tempVRString = mRegistryName.ToNewCString();
|
||||
char* tempTargetFile = mTargetFile.ToNewCString();
|
||||
err = VR_Install( tempRegName,
|
||||
nsFilePath(*mTargetFile),
|
||||
tempVersion,
|
||||
PR_FALSE );
|
||||
|
||||
nsString tempString;
|
||||
mVersionInfo->ToString(tempString);
|
||||
char* tempVersion = tempString.ToNewCString();
|
||||
|
||||
err = VR_Install( tempVRString, tempTargetFile, tempVersion, PR_FALSE );
|
||||
|
||||
delete tempVRString;
|
||||
delete tempTargetFile;
|
||||
delete tempVersion;
|
||||
delete [] tempRegName;
|
||||
delete [] tempVersion;
|
||||
|
||||
}
|
||||
else
|
||||
|
@ -237,12 +239,12 @@ PRInt32 nsInstallPatch::Complete()
|
|||
|
||||
void nsInstallPatch::Abort()
|
||||
{
|
||||
nsString *fileName = nsnull;
|
||||
nsVoidKey ikey( (void*) nsCRT::HashValue( mTargetFile.GetUnicode() ) );
|
||||
nsFileSpec *fileName = nsnull;
|
||||
nsVoidKey ikey( HashFilePath( nsFilePath(*mTargetFile) ) );
|
||||
|
||||
mInstall->GetPatch(&ikey, fileName);
|
||||
|
||||
if (fileName != nsnull && fileName->Equals(mPatchedFile) )
|
||||
if (fileName != nsnull && fileName->Equals(*mPatchedFile) )
|
||||
{
|
||||
NativeDeleteFile( mPatchedFile );
|
||||
}
|
||||
|
@ -268,25 +270,21 @@ nsInstallPatch::RegisterPackageNode()
|
|||
}
|
||||
|
||||
PRInt32
|
||||
nsInstallPatch::NativePatch(const nsString &sourceFile, const nsString &patchfile, nsString &newFile)
|
||||
nsInstallPatch::NativePatch(const nsFileSpec &sourceFile, const nsFileSpec &patchfile, nsFileSpec **newFile)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
PRInt32
|
||||
nsInstallPatch::NativeDeleteFile(const nsString& doomedFile)
|
||||
nsInstallPatch::NativeDeleteFile(nsFileSpec* doomedFile)
|
||||
{
|
||||
char * tempFile = doomedFile.ToNewCString();
|
||||
nsFileSpec file(tempFile);
|
||||
delete tempFile;
|
||||
|
||||
if (file.Exists())
|
||||
if (doomedFile->Exists())
|
||||
{
|
||||
if (file.IsFile())
|
||||
if (doomedFile->IsFile())
|
||||
{
|
||||
file.Delete(false);
|
||||
doomedFile->Delete(false);
|
||||
|
||||
if (file.Exists())
|
||||
if (doomedFile->Exists())
|
||||
{
|
||||
// If file still exists, we need to delete it later!
|
||||
// FIX DeleteOldFileLater( (char*)finalFile );
|
||||
|
@ -298,46 +296,26 @@ nsInstallPatch::NativeDeleteFile(const nsString& doomedFile)
|
|||
return nsInstall::FILE_IS_DIRECTORY;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return nsInstall::FILE_DOES_NOT_EXIST;
|
||||
}
|
||||
|
||||
return nsInstall::FILE_DOES_NOT_EXIST;
|
||||
}
|
||||
|
||||
PRInt32
|
||||
nsInstallPatch::NativeReplace(const nsString& oldfile, nsString& newFile)
|
||||
nsInstallPatch::NativeReplace(const nsFileSpec& oldfile, const nsFileSpec& 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())
|
||||
oldfile.Delete(PR_FALSE);
|
||||
if (oldfile.Exists())
|
||||
{
|
||||
//FIX: FE_ReplaceExistingFile
|
||||
}
|
||||
|
||||
|
||||
nsFileSpec parentDirectory;
|
||||
file.GetParent(parentDirectory);
|
||||
oldfile.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)
|
||||
if (newFile.Move(parentDirectory) != 0)
|
||||
{
|
||||
return nsInstall::UNEXPECTED_ERROR;
|
||||
}
|
||||
|
@ -345,3 +323,25 @@ nsInstallPatch::NativeReplace(const nsString& oldfile, nsString& newFile)
|
|||
|
||||
return nsInstall::SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
void*
|
||||
nsInstallPatch::HashFilePath(const nsFilePath& aPath)
|
||||
{
|
||||
PRUint32 rv = 0;
|
||||
if(aPath)
|
||||
{
|
||||
char ch;
|
||||
char* filePath = nsnull;
|
||||
strcpy(filePath, aPath);
|
||||
|
||||
while ((ch = *filePath++) != 0)
|
||||
{
|
||||
// FYI: rv = rv*37 + ch
|
||||
rv = ((rv << 5) + (rv << 2) + rv) + ch;
|
||||
}
|
||||
|
||||
PR_Free(filePath);
|
||||
}
|
||||
return (void*)rv;
|
||||
}
|
|
@ -25,7 +25,7 @@
|
|||
#include "nsInstallObject.h"
|
||||
|
||||
#include "nsInstall.h"
|
||||
#include "nsIDOMInstallFolder.h"
|
||||
#include "nsInstallFolder.h"
|
||||
#include "nsIDOMInstallVersion.h"
|
||||
|
||||
|
||||
|
@ -37,7 +37,7 @@ class nsInstallPatch : public nsInstallObject
|
|||
const nsString& inVRName,
|
||||
nsIDOMInstallVersion* inVInfo,
|
||||
const nsString& inJarLocation,
|
||||
nsIDOMInstallFolder* folderSpec,
|
||||
const nsString& folderSpec,
|
||||
const nsString& inPartialPath,
|
||||
PRInt32 *error);
|
||||
|
||||
|
@ -60,19 +60,22 @@ class nsInstallPatch : public nsInstallObject
|
|||
|
||||
private:
|
||||
|
||||
nsString mRegistryName;
|
||||
nsIDOMInstallVersion* mVersionInfo;
|
||||
|
||||
nsString mJarLocation;
|
||||
|
||||
nsString *mPatchFile;
|
||||
|
||||
nsString mTargetFile;
|
||||
nsString mPatchedFile;
|
||||
nsInstallVersion *mVersionInfo;
|
||||
|
||||
nsFileSpec *mTargetFile;
|
||||
nsFileSpec *mPatchFile;
|
||||
nsFileSpec *mPatchedFile;
|
||||
|
||||
PRInt32 NativePatch(const nsString &sourceFile, const nsString &patchfile, nsString &newFile);
|
||||
PRInt32 NativeReplace (const nsString& target, nsString& tempFile);
|
||||
PRInt32 NativeDeleteFile(const nsString& doomedFile);
|
||||
nsString *mJarLocation;
|
||||
nsString *mRegistryName;
|
||||
|
||||
|
||||
|
||||
PRInt32 NativePatch(const nsFileSpec &sourceFile, const nsFileSpec &patchfile, nsFileSpec **newFile);
|
||||
PRInt32 NativeReplace (const nsFileSpec& target, const nsFileSpec& tempFile);
|
||||
PRInt32 NativeDeleteFile(nsFileSpec* doomedFile);
|
||||
void* HashFilePath(const nsFilePath& aPath);
|
||||
};
|
||||
|
||||
#endif /* nsInstallPatch_h__ */
|
||||
|
|
|
@ -20,18 +20,9 @@
|
|||
#include "nsJSUtils.h"
|
||||
#include "nscore.h"
|
||||
#include "nsIScriptContext.h"
|
||||
#include "nsIJSScriptObject.h"
|
||||
#include "nsIScriptObjectOwner.h"
|
||||
#include "nsIScriptGlobalObject.h"
|
||||
#include "nsIPtr.h"
|
||||
|
||||
#include "nsString.h"
|
||||
#include "nsInstall.h"
|
||||
#include "nsIDOMInstallFolder.h"
|
||||
#include "nsRepository.h"
|
||||
|
||||
static NS_DEFINE_IID(kIInstallFolderIID, NS_IDOMINSTALLFOLDER_IID);
|
||||
|
||||
NS_DEF_PTR(nsIDOMInstallFolder);
|
||||
|
||||
//
|
||||
// Install property ids
|
||||
|
@ -100,7 +91,7 @@ GetInstallProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp)
|
|||
nsJSUtils::nsConvertStringToJSVal(prop, cx, vp);
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
default:
|
||||
return JS_TRUE;
|
||||
}
|
||||
|
@ -216,7 +207,7 @@ InstallAddDirectory(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval
|
|||
nsAutoString b0;
|
||||
nsAutoString b1;
|
||||
nsAutoString b2;
|
||||
nsIDOMInstallFolderPtr b3;
|
||||
nsAutoString b3;
|
||||
nsAutoString b4;
|
||||
PRBool b5;
|
||||
|
||||
|
@ -235,13 +226,7 @@ InstallAddDirectory(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval
|
|||
|
||||
nsJSUtils::nsConvertJSValToString(b2, cx, argv[2]);
|
||||
|
||||
if (JS_FALSE == nsJSUtils::nsConvertJSValToObject((nsISupports **)&b3,
|
||||
kIInstallFolderIID,
|
||||
"InstallFolder",
|
||||
cx,
|
||||
argv[3])) {
|
||||
return JS_FALSE;
|
||||
}
|
||||
nsJSUtils::nsConvertJSValToString(b3, cx, argv[3]);
|
||||
|
||||
nsJSUtils::nsConvertJSValToString(b4, cx, argv[4]);
|
||||
|
||||
|
@ -276,7 +261,7 @@ InstallAddSubcomponent(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, js
|
|||
nsAutoString b0;
|
||||
nsAutoString b1;
|
||||
nsAutoString b2;
|
||||
nsIDOMInstallFolderPtr b3;
|
||||
nsAutoString b3;
|
||||
nsAutoString b4;
|
||||
PRBool b5;
|
||||
|
||||
|
@ -295,13 +280,7 @@ InstallAddSubcomponent(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, js
|
|||
|
||||
nsJSUtils::nsConvertJSValToString(b2, cx, argv[2]);
|
||||
|
||||
if (JS_FALSE == nsJSUtils::nsConvertJSValToObject((nsISupports **)&b3,
|
||||
kIInstallFolderIID,
|
||||
"InstallFolder",
|
||||
cx,
|
||||
argv[3])) {
|
||||
return JS_FALSE;
|
||||
}
|
||||
nsJSUtils::nsConvertJSValToString(b3, cx, argv[3]);
|
||||
|
||||
nsJSUtils::nsConvertJSValToString(b4, cx, argv[4]);
|
||||
|
||||
|
@ -370,7 +349,7 @@ InstallDeleteFile(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *
|
|||
nsInstall *nativeThis = (nsInstall*)JS_GetPrivate(cx, obj);
|
||||
JSBool rBool = JS_FALSE;
|
||||
PRInt32 nativeRet;
|
||||
nsIDOMInstallFolderPtr b0;
|
||||
nsAutoString b0;
|
||||
nsAutoString b1;
|
||||
|
||||
*rval = JSVAL_NULL;
|
||||
|
@ -382,13 +361,7 @@ InstallDeleteFile(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *
|
|||
|
||||
if (argc >= 2) {
|
||||
|
||||
if (JS_FALSE == nsJSUtils::nsConvertJSValToObject((nsISupports **)&b0,
|
||||
kIInstallFolderIID,
|
||||
"InstallFolder",
|
||||
cx,
|
||||
argv[0])) {
|
||||
return JS_FALSE;
|
||||
}
|
||||
nsJSUtils::nsConvertJSValToString(b0, cx, argv[0]);
|
||||
|
||||
nsJSUtils::nsConvertJSValToString(b1, cx, argv[1]);
|
||||
|
||||
|
@ -416,7 +389,7 @@ InstallDiskSpaceAvailable(JSContext *cx, JSObject *obj, uintN argc, jsval *argv,
|
|||
nsInstall *nativeThis = (nsInstall*)JS_GetPrivate(cx, obj);
|
||||
JSBool rBool = JS_FALSE;
|
||||
PRInt32 nativeRet;
|
||||
nsIDOMInstallFolderPtr b0;
|
||||
nsAutoString b0;
|
||||
|
||||
*rval = JSVAL_NULL;
|
||||
|
||||
|
@ -427,13 +400,7 @@ InstallDiskSpaceAvailable(JSContext *cx, JSObject *obj, uintN argc, jsval *argv,
|
|||
|
||||
if (argc >= 1) {
|
||||
|
||||
if (JS_FALSE == nsJSUtils::nsConvertJSValToObject((nsISupports **)&b0,
|
||||
kIInstallFolderIID,
|
||||
"InstallFolder",
|
||||
cx,
|
||||
argv[0])) {
|
||||
return JS_FALSE;
|
||||
}
|
||||
nsJSUtils::nsConvertJSValToString(b0, cx, argv[0]);
|
||||
|
||||
if (NS_OK != nativeThis->DiskSpaceAvailable(b0, &nativeRet)) {
|
||||
return JS_FALSE;
|
||||
|
@ -569,7 +536,7 @@ InstallGetComponentFolder(JSContext *cx, JSObject *obj, uintN argc, jsval *argv,
|
|||
{
|
||||
nsInstall *nativeThis = (nsInstall*)JS_GetPrivate(cx, obj);
|
||||
JSBool rBool = JS_FALSE;
|
||||
nsIDOMInstallFolder* nativeRet;
|
||||
nsString* nativeRet;
|
||||
nsAutoString b0;
|
||||
nsAutoString b1;
|
||||
|
||||
|
@ -590,7 +557,7 @@ InstallGetComponentFolder(JSContext *cx, JSObject *obj, uintN argc, jsval *argv,
|
|||
return JS_FALSE;
|
||||
}
|
||||
|
||||
nsJSUtils::nsConvertObjectToJSVal(nativeRet, cx, rval);
|
||||
nsJSUtils::nsConvertStringToJSVal(*nativeRet, cx, rval);
|
||||
}
|
||||
else {
|
||||
JS_ReportError(cx, "Function GetComponentFolder requires 2 parameters");
|
||||
|
@ -609,7 +576,7 @@ InstallGetFolder(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *r
|
|||
{
|
||||
nsInstall *nativeThis = (nsInstall*)JS_GetPrivate(cx, obj);
|
||||
JSBool rBool = JS_FALSE;
|
||||
nsIDOMInstallFolder* nativeRet;
|
||||
nsString* nativeRet;
|
||||
nsAutoString b0;
|
||||
nsAutoString b1;
|
||||
|
||||
|
@ -630,7 +597,7 @@ InstallGetFolder(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *r
|
|||
return JS_FALSE;
|
||||
}
|
||||
|
||||
nsJSUtils::nsConvertObjectToJSVal(nativeRet, cx, rval);
|
||||
nsJSUtils::nsConvertStringToJSVal(*nativeRet, cx, rval);
|
||||
}
|
||||
else {
|
||||
JS_ReportError(cx, "Function GetFolder requires 2 parameters");
|
||||
|
@ -684,7 +651,7 @@ InstallGetWinProfile(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsva
|
|||
nsInstall *nativeThis = (nsInstall*)JS_GetPrivate(cx, obj);
|
||||
JSBool rBool = JS_FALSE;
|
||||
PRInt32 nativeRet;
|
||||
nsIDOMInstallFolderPtr b0;
|
||||
nsAutoString b0;
|
||||
nsAutoString b1;
|
||||
|
||||
*rval = JSVAL_NULL;
|
||||
|
@ -696,13 +663,7 @@ InstallGetWinProfile(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsva
|
|||
|
||||
if (argc >= 2) {
|
||||
|
||||
if (JS_FALSE == nsJSUtils::nsConvertJSValToObject((nsISupports **)&b0,
|
||||
kIInstallFolderIID,
|
||||
"InstallFolder",
|
||||
cx,
|
||||
argv[0])) {
|
||||
return JS_FALSE;
|
||||
}
|
||||
nsJSUtils::nsConvertJSValToString(b0, cx, argv[0]);
|
||||
|
||||
nsJSUtils::nsConvertJSValToString(b1, cx, argv[1]);
|
||||
|
||||
|
@ -767,7 +728,7 @@ InstallPatch(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
|
|||
nsAutoString b0;
|
||||
nsAutoString b1;
|
||||
nsAutoString b2;
|
||||
nsIDOMInstallFolderPtr b3;
|
||||
nsAutoString b3;
|
||||
nsAutoString b4;
|
||||
|
||||
*rval = JSVAL_NULL;
|
||||
|
@ -785,13 +746,7 @@ InstallPatch(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
|
|||
|
||||
nsJSUtils::nsConvertJSValToString(b2, cx, argv[2]);
|
||||
|
||||
if (JS_FALSE == nsJSUtils::nsConvertJSValToObject((nsISupports **)&b3,
|
||||
kIInstallFolderIID,
|
||||
"InstallFolder",
|
||||
cx,
|
||||
argv[3])) {
|
||||
return JS_FALSE;
|
||||
}
|
||||
nsJSUtils::nsConvertJSValToString(b3, cx, argv[3]);
|
||||
|
||||
nsJSUtils::nsConvertJSValToString(b4, cx, argv[4]);
|
||||
|
||||
|
@ -851,7 +806,7 @@ InstallSetPackageFolder(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, j
|
|||
{
|
||||
nsInstall *nativeThis = (nsInstall*)JS_GetPrivate(cx, obj);
|
||||
JSBool rBool = JS_FALSE;
|
||||
nsIDOMInstallFolderPtr b0;
|
||||
nsAutoString b0;
|
||||
|
||||
*rval = JSVAL_NULL;
|
||||
|
||||
|
@ -862,13 +817,7 @@ InstallSetPackageFolder(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, j
|
|||
|
||||
if (argc >= 1) {
|
||||
|
||||
if (JS_FALSE == nsJSUtils::nsConvertJSValToObject((nsISupports **)&b0,
|
||||
kIInstallFolderIID,
|
||||
"InstallFolder",
|
||||
cx,
|
||||
argv[0])) {
|
||||
return JS_FALSE;
|
||||
}
|
||||
nsJSUtils::nsConvertJSValToString(b0, cx, argv[0]);
|
||||
|
||||
if (NS_OK != nativeThis->SetPackageFolder(b0)) {
|
||||
return JS_FALSE;
|
||||
|
|
|
@ -28,7 +28,6 @@
|
|||
|
||||
#include "VerReg.h"
|
||||
|
||||
|
||||
#include "nsIScriptObjectOwner.h"
|
||||
#include "nsIScriptGlobalObject.h"
|
||||
|
||||
|
@ -56,8 +55,6 @@
|
|||
#include "nsIDOMInstallVersion.h"
|
||||
#include "nsInstallVersion.h"
|
||||
|
||||
#include "nsIDOMInstallFolder.h"
|
||||
#include "nsInstallFolder.h"
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// Globals
|
||||
|
@ -79,9 +76,6 @@ static NS_DEFINE_IID(kInstallTrigger_CID, NS_SoftwareUpdateInstallTrigger_CID);
|
|||
static NS_DEFINE_IID(kIInstallVersion_IID, NS_IDOMINSTALLVERSION_IID);
|
||||
static NS_DEFINE_IID(kInstallVersion_CID, NS_SoftwareUpdateInstallVersion_CID);
|
||||
|
||||
static NS_DEFINE_IID(kIInstallFolder_IID, NS_IDOMINSTALLFOLDER_IID);
|
||||
static NS_DEFINE_IID(kInstallFolder_CID, NS_SoftwareUpdateInstallFolder_CID);
|
||||
|
||||
static PRInt32 gInstanceCnt = 0;
|
||||
static PRInt32 gLockCnt = 0;
|
||||
|
||||
|
@ -328,15 +322,9 @@ nsSoftwareUpdateNameSet::InitializeClasses(nsIScriptContext* aScriptContext)
|
|||
{
|
||||
nsresult result = NS_OK;
|
||||
|
||||
// result = NS_InitInstallClass(aScriptContext, nsnull);
|
||||
if (result != NS_OK) return result;
|
||||
|
||||
result = NS_InitInstallVersionClass(aScriptContext, nsnull);
|
||||
if (result != NS_OK) return result;
|
||||
|
||||
result = NS_InitInstallFolderClass(aScriptContext, nsnull);
|
||||
if (result != NS_OK) return result;
|
||||
|
||||
result = NS_InitInstallTriggerGlobalClass(aScriptContext, nsnull);
|
||||
|
||||
return result;
|
||||
|
@ -358,20 +346,10 @@ nsSoftwareUpdateNameSet::AddNameSet(nsIScriptContext* aScriptContext)
|
|||
|
||||
if (result != NS_OK) return result;
|
||||
|
||||
result = manager->RegisterGlobalName("InstallFolder",
|
||||
kInstallFolder_CID,
|
||||
PR_TRUE);
|
||||
|
||||
if (result != NS_OK) return result;
|
||||
|
||||
|
||||
result = manager->RegisterGlobalName("InstallTrigger",
|
||||
kInstallTrigger_CID,
|
||||
PR_FALSE);
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
if (manager != nsnull)
|
||||
|
@ -394,10 +372,10 @@ extern "C" NS_EXPORT nsresult
|
|||
NSRegisterSelf(nsISupports* serviceMgr, const char *path)
|
||||
{
|
||||
printf("*** XPInstall is being registered\n");
|
||||
|
||||
nsRepository::RegisterComponent(kSoftwareUpdate_CID, NULL, NULL, path, PR_TRUE, PR_TRUE);
|
||||
nsRepository::RegisterComponent(kInstallTrigger_CID, NULL, NULL, 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;
|
||||
}
|
||||
|
@ -410,7 +388,6 @@ NSUnregisterSelf(nsISupports* serviceMgr, const char *path)
|
|||
nsRepository::UnregisterFactory(kSoftwareUpdate_CID, path);
|
||||
nsRepository::UnregisterFactory(kInstallTrigger_CID, path);
|
||||
nsRepository::UnregisterFactory(kInstallVersion_CID, path);
|
||||
nsRepository::UnregisterFactory(kInstallFolder_CID, path);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
@ -438,10 +415,6 @@ NSGetFactory(nsISupports* serviceMgr,
|
|||
{
|
||||
inst = new nsInstallTriggerFactory();
|
||||
}
|
||||
else if (aClass.Equals(kInstallFolder_CID) )
|
||||
{
|
||||
inst = new nsInstallFolderFactory();
|
||||
}
|
||||
else if (aClass.Equals(kInstallVersion_CID) )
|
||||
{
|
||||
inst = new nsInstallVersionFactory();
|
||||
|
|
|
@ -14,6 +14,7 @@
|
|||
#include "nsInstall.h"
|
||||
#include "zipfile.h"
|
||||
|
||||
#include "nsSpecialSystemDirectory.h"
|
||||
|
||||
extern PRInt32 InitXPInstallObjects(nsIScriptContext *aContext, char* jarfile, char* args);
|
||||
|
||||
|
@ -29,7 +30,7 @@ static NS_DEFINE_IID(kIScriptContextOwnerIID, NS_ISCRIPTCONTEXTOWNER_IID);
|
|||
* returns an error code
|
||||
*/
|
||||
|
||||
static short ReadFileIntoBuffer(char * fileName, char** buffer, unsigned long *bufferSize)
|
||||
static short ReadFileIntoBuffer(const char* fileName, char** buffer, unsigned long *bufferSize)
|
||||
{
|
||||
PRFileDesc* file;
|
||||
struct stat st;
|
||||
|
@ -84,7 +85,7 @@ extern "C" NS_EXPORT PRInt32 Install(char* jarFile, char* args)
|
|||
// Open the jarfile.
|
||||
void* hZip;
|
||||
|
||||
PRInt32 result = ZIPR_OpenArchive(jarFile , &hZip);
|
||||
PRInt32 result = ZIP_OpenArchive(jarFile , &hZip);
|
||||
|
||||
if (result != ZIP_OK)
|
||||
{
|
||||
|
@ -95,13 +96,15 @@ extern "C" NS_EXPORT PRInt32 Install(char* jarFile, char* args)
|
|||
// Read manifest file for Install Script filename.
|
||||
//FIX: need to do.
|
||||
|
||||
char* installJSFile = "c:\\temp\\install.js";
|
||||
|
||||
nsSpecialSystemDirectory installJSFileSpec(nsSpecialSystemDirectory::OS_TemporaryDirectory);
|
||||
installJSFileSpec += "install.js";
|
||||
installJSFileSpec.MakeUnique();
|
||||
|
||||
remove(installJSFile);
|
||||
const char* installJSFile = installJSFileSpec.operator const char* ();
|
||||
|
||||
// Extract the install.js file.
|
||||
result = ZIPR_ExtractFile( hZip, "install.js", installJSFile );
|
||||
result = ZIP_ExtractFile( hZip, "install.js", installJSFile );
|
||||
if (result != ZIP_OK)
|
||||
{
|
||||
return result;
|
||||
|
@ -127,7 +130,7 @@ extern "C" NS_EXPORT PRInt32 Install(char* jarFile, char* args)
|
|||
nsIScriptContextOwner* scriptContextOwner;
|
||||
nsIScriptContext* scriptContext;
|
||||
|
||||
rv = aWindow->Init(nsnull, nsnull, rect, PRUint32(0), PR_FALSE);
|
||||
rv = aWindow->Init(nsnull, nsnull, rect, PRUint32(0), PR_TRUE);
|
||||
|
||||
if (rv == NS_OK)
|
||||
{
|
||||
|
@ -170,7 +173,8 @@ extern "C" NS_EXPORT PRInt32 Install(char* jarFile, char* args)
|
|||
return -1;
|
||||
}
|
||||
|
||||
ZIPR_CloseArchive(&hZip);
|
||||
ZIP_CloseArchive(&hZip);
|
||||
installJSFileSpec.Delete(PR_FALSE);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче