mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-15 06:15:43 +00:00
Fixes for bug 18683. Libjar interfaces changed but the implementation didn't. This fixes the runtime XP horkage. [r=dveditz]
This commit is contained in:
parent
49a3e8a1fa
commit
fd32fa05d8
@ -102,13 +102,13 @@ nsInstallInfo::~nsInstallInfo()
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
nsInstallInfo::GetLocalFile(char **aPath)
|
||||
nsresult
|
||||
nsInstallInfo::GetLocalFile(nsFileSpec& aSpec)
|
||||
{
|
||||
if (mFile)
|
||||
mFile->GetNSPRPath(aPath);
|
||||
else
|
||||
*aPath = 0;
|
||||
if (!mFile)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
|
||||
return mFile->GetFileSpec(&aSpec);
|
||||
}
|
||||
|
||||
|
||||
@ -135,13 +135,6 @@ nsInstall::nsInstall()
|
||||
mJarFileLocation = "";
|
||||
mInstallArguments = "";
|
||||
|
||||
mUninstallPackage = PR_FALSE;
|
||||
mRegisterPackage = PR_FALSE;
|
||||
mStatusSent = PR_FALSE;
|
||||
|
||||
mJarFileLocation = "";
|
||||
mInstallArguments = "";
|
||||
|
||||
// mJarFileData is an opaque handle to the jarfile.
|
||||
nsresult rv = nsComponentManager::CreateInstance(kZipReaderCID, nsnull, kIZipReaderIID,
|
||||
(void**) &mJarFileData);
|
||||
@ -2087,11 +2080,11 @@ nsInstall::CleanUp(void)
|
||||
void
|
||||
nsInstall::GetJarFileLocation(nsString& aFile)
|
||||
{
|
||||
aFile = mJarFileLocation;
|
||||
aFile = mJarFileLocation.GetCString();
|
||||
}
|
||||
|
||||
void
|
||||
nsInstall::SetJarFileLocation(const nsString& aFile)
|
||||
nsInstall::SetJarFileLocation(const nsFileSpec& aFile)
|
||||
{
|
||||
mJarFileLocation = aFile;
|
||||
}
|
||||
@ -2143,8 +2136,7 @@ nsInstall::Confirm(nsString& string, PRBool* aReturn)
|
||||
PRInt32
|
||||
nsInstall::OpenJARFile(void)
|
||||
{
|
||||
nsFileSpec loc(mJarFileLocation);
|
||||
nsresult rv = mJarFileData->Init(loc);
|
||||
nsresult rv = mJarFileData->Init(mJarFileLocation);
|
||||
if (NS_FAILED(rv))
|
||||
return UNEXPECTED_ERROR;
|
||||
|
||||
@ -2169,7 +2161,7 @@ nsInstall::CloseJARFile(void)
|
||||
PRInt32
|
||||
nsInstall::ExtractFileFromJar(const nsString& aJarfile, nsFileSpec* aSuggestedName, nsFileSpec** aRealName)
|
||||
{
|
||||
PRInt32 result;
|
||||
PRInt32 extpos = 0;
|
||||
nsFileSpec *extractHereSpec;
|
||||
|
||||
if (aSuggestedName == nsnull)
|
||||
@ -2178,12 +2170,12 @@ nsInstall::ExtractFileFromJar(const nsString& aJarfile, nsFileSpec* aSuggestedNa
|
||||
nsString tempFileName = "xpinstall";
|
||||
|
||||
// Get the extension of the file in the JAR
|
||||
result = aJarfile.RFindChar('.');
|
||||
if (result != -1)
|
||||
extpos = aJarfile.RFindChar('.');
|
||||
if (extpos != -1)
|
||||
{
|
||||
// We found the extension; add it to the tempFileName string
|
||||
nsString extension;
|
||||
aJarfile.Right(extension, (aJarfile.Length() - result) );
|
||||
aJarfile.Right(extension, (aJarfile.Length() - extpos) );
|
||||
tempFileName += extension;
|
||||
}
|
||||
|
||||
@ -2217,51 +2209,43 @@ nsInstall::ExtractFileFromJar(const nsString& aJarfile, nsFileSpec* aSuggestedNa
|
||||
delete extractHereSpec;
|
||||
return EXTRACTION_FAILED;
|
||||
}
|
||||
|
||||
if (result == 0)
|
||||
{
|
||||
|
||||
#ifdef XP_MAC
|
||||
FSSpec finalSpec, extractedSpec = extractHereSpec->GetFSSpec();
|
||||
|
||||
if ( nsAppleSingleDecoder::IsAppleSingleFile(&extractedSpec) )
|
||||
{
|
||||
nsAppleSingleDecoder *asd = new nsAppleSingleDecoder(&extractedSpec, &finalSpec);
|
||||
OSErr decodeErr = fnfErr;
|
||||
FSSpec finalSpec, extractedSpec = extractHereSpec->GetFSSpec();
|
||||
|
||||
if ( nsAppleSingleDecoder::IsAppleSingleFile(&extractedSpec) )
|
||||
{
|
||||
nsAppleSingleDecoder *asd = new nsAppleSingleDecoder(&extractedSpec, &finalSpec);
|
||||
OSErr decodeErr = fnfErr;
|
||||
|
||||
if (asd)
|
||||
decodeErr = asd->Decode();
|
||||
|
||||
if (decodeErr != noErr)
|
||||
{
|
||||
if (extractHereSpec)
|
||||
delete extractHereSpec;
|
||||
if (asd)
|
||||
delete asd;
|
||||
return EXTRACTION_FAILED;
|
||||
}
|
||||
|
||||
if ( !(extractedSpec.vRefNum == finalSpec.vRefNum) ||
|
||||
!(extractedSpec.parID == finalSpec.parID) ||
|
||||
!(nsAppleSingleDecoder::PLstrcmp(extractedSpec.name, finalSpec.name)) )
|
||||
{
|
||||
// delete the unique extracted file that got renamed in AS decoding
|
||||
FSpDelete(&extractedSpec);
|
||||
|
||||
// "real name" in AppleSingle entry may cause file rename
|
||||
*extractHereSpec = finalSpec;
|
||||
}
|
||||
}
|
||||
if (asd)
|
||||
decodeErr = asd->Decode();
|
||||
|
||||
if (decodeErr != noErr)
|
||||
{
|
||||
if (extractHereSpec)
|
||||
delete extractHereSpec;
|
||||
if (asd)
|
||||
delete asd;
|
||||
return EXTRACTION_FAILED;
|
||||
}
|
||||
|
||||
if ( !(extractedSpec.vRefNum == finalSpec.vRefNum) ||
|
||||
!(extractedSpec.parID == finalSpec.parID) ||
|
||||
!(nsAppleSingleDecoder::PLstrcmp(extractedSpec.name, finalSpec.name)) )
|
||||
{
|
||||
// delete the unique extracted file that got renamed in AS decoding
|
||||
FSpDelete(&extractedSpec);
|
||||
|
||||
// "real name" in AppleSingle entry may cause file rename
|
||||
*extractHereSpec = finalSpec;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
*aRealName = extractHereSpec;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (extractHereSpec != nsnull)
|
||||
delete extractHereSpec;
|
||||
}
|
||||
return result;
|
||||
*aRealName = extractHereSpec;
|
||||
|
||||
return nsInstall::SUCCESS;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -68,7 +68,7 @@ class nsInstallInfo
|
||||
|
||||
virtual ~nsInstallInfo();
|
||||
|
||||
void GetLocalFile(char** aPath);
|
||||
nsresult GetLocalFile(nsFileSpec& aSpec);
|
||||
|
||||
void GetURL(nsString& aURL) { aURL = mURL; }
|
||||
|
||||
@ -242,7 +242,7 @@ class nsInstall
|
||||
void GetPatch(nsHashKey *aKey, nsFileSpec** fileName);
|
||||
|
||||
void GetJarFileLocation(nsString& aFile);
|
||||
void SetJarFileLocation(const nsString& aFile);
|
||||
void SetJarFileLocation(const nsFileSpec& aFile);
|
||||
|
||||
void GetInstallArguments(nsString& args);
|
||||
void SetInstallArguments(const nsString& args);
|
||||
@ -265,7 +265,7 @@ class nsInstall
|
||||
JSObject* mWinRegObject;
|
||||
JSObject* mWinProfileObject;
|
||||
|
||||
nsString mJarFileLocation;
|
||||
nsFileSpec mJarFileLocation;
|
||||
nsIZipReader* mJarFileData;
|
||||
|
||||
nsString mInstallArguments;
|
||||
|
@ -2655,7 +2655,7 @@ static JSFunctionSpec InstallMethods[] =
|
||||
|
||||
JSObject * InitXPInstallObjects(JSContext *jscontext,
|
||||
JSObject *global,
|
||||
const char* jarfile,
|
||||
const nsFileSpec& jarfile,
|
||||
const PRUnichar* url,
|
||||
const PRUnichar* args)
|
||||
{
|
||||
|
@ -61,6 +61,9 @@
|
||||
#include "nsIEventQueueService.h"
|
||||
#include "nsProxyObjectManager.h"
|
||||
|
||||
#ifdef XP_MAC
|
||||
#include <profiler.h>
|
||||
#endif
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// Globals
|
||||
@ -107,7 +110,7 @@ nsSoftwareUpdate::nsSoftwareUpdate()
|
||||
NS_INIT_ISUPPORTS();
|
||||
|
||||
mStubLockout = PR_FALSE;
|
||||
/***************************************/
|
||||
/***************************************/
|
||||
/* Create us a queue */
|
||||
/***************************************/
|
||||
mLock = PR_NewLock();
|
||||
@ -289,6 +292,9 @@ nsSoftwareUpdate::InstallJar( nsIFileSpec* aLocalFile,
|
||||
long flags,
|
||||
nsIXPINotifier* aNotifier)
|
||||
{
|
||||
#ifdef __PROFILER__
|
||||
ProfilerInit(collectDetailed, bestTimeBase, 2000, 2000);
|
||||
#endif
|
||||
if ( !aLocalFile )
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
|
||||
@ -303,6 +309,10 @@ nsSoftwareUpdate::InstallJar( nsIFileSpec* aLocalFile,
|
||||
PR_Unlock(mLock);
|
||||
RunNextInstall();
|
||||
|
||||
#ifdef __PROFILER__
|
||||
ProfilerDump("\pXPI_PofileDump");
|
||||
ProfilerTerm();
|
||||
#endif
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
@ -48,14 +48,14 @@ static NS_DEFINE_IID(kSoftwareUpdateCID, NS_SoftwareUpdate_CID);
|
||||
|
||||
|
||||
|
||||
extern JSObject *InitXPInstallObjects(JSContext *jscontext, JSObject *global, const char* jarfile, const PRUnichar* url, const PRUnichar* args);
|
||||
extern JSObject *InitXPInstallObjects(JSContext *jscontext, JSObject *global, const nsFileSpec& jarfile, const PRUnichar* url, const PRUnichar* args);
|
||||
extern nsresult InitInstallVersionClass(JSContext *jscontext, JSObject *global, void** prototype);
|
||||
extern nsresult InitInstallTriggerGlobalClass(JSContext *jscontext, JSObject *global, void** prototype);
|
||||
|
||||
// Defined in this file:
|
||||
static void XPInstallErrorReporter(JSContext *cx, const char *message, JSErrorReport *report);
|
||||
static PRInt32 GetInstallScriptFromJarfile(const char* jarFile, char** scriptBuffer, PRUint32 *scriptLength);
|
||||
static nsresult SetupInstallContext(const char* jarFile, const PRUnichar* url, const PRUnichar* args, JSRuntime **jsRT, JSContext **jsCX, JSObject **jsGlob);
|
||||
static PRInt32 GetInstallScriptFromJarfile(nsFileSpec& jarFile, char** scriptBuffer, PRUint32 *scriptLength);
|
||||
static nsresult SetupInstallContext(const nsFileSpec* jarFile, const PRUnichar* url, const PRUnichar* args, JSRuntime **jsRT, JSContext **jsCX, JSObject **jsGlob);
|
||||
|
||||
extern "C" void RunInstallOnThread(void *data);
|
||||
|
||||
@ -118,7 +118,7 @@ XPInstallErrorReporter(JSContext *cx, const char *message, JSErrorReport *report
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
static PRInt32
|
||||
GetInstallScriptFromJarfile(const char* jarFile, char** scriptBuffer, PRUint32 *scriptLength)
|
||||
GetInstallScriptFromJarfile(nsFileSpec& jarFile, char** scriptBuffer, PRUint32 *scriptLength)
|
||||
{
|
||||
nsCOMPtr<nsIZipReader> hZip;
|
||||
PRInt32 result = NS_OK;
|
||||
@ -132,9 +132,8 @@ GetInstallScriptFromJarfile(const char* jarFile, char** scriptBuffer, PRUint32 *
|
||||
getter_AddRefs(hZip));
|
||||
if (NS_FAILED(rv))
|
||||
return nsInstall::CANT_READ_ARCHIVE;
|
||||
|
||||
nsFileSpec fs(jarFile);
|
||||
rv = hZip->Init(fs);
|
||||
|
||||
rv = hZip->Init(jarFile);
|
||||
if (NS_FAILED(rv))
|
||||
return nsInstall::CANT_READ_ARCHIVE;
|
||||
|
||||
@ -205,7 +204,7 @@ GetInstallScriptFromJarfile(const char* jarFile, char** scriptBuffer, PRUint32 *
|
||||
// Argument : JSContext **jsCX - Must be deleted via JS_DestroyContext
|
||||
// Argument : JSObject **jsGlob
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////
|
||||
static nsresult SetupInstallContext(const char* jarFile,
|
||||
static nsresult SetupInstallContext(const nsFileSpec& jarFile,
|
||||
const PRUnichar* url,
|
||||
const PRUnichar* args,
|
||||
JSRuntime **jsRT,
|
||||
@ -328,10 +327,10 @@ extern "C" void RunInstallOnThread(void *data)
|
||||
nsString args;
|
||||
installInfo->GetArguments(args);
|
||||
|
||||
char *jarpath; // XXX this should be an nsIFileSpec or moral equivalent
|
||||
installInfo->GetLocalFile(&jarpath);
|
||||
if (jarpath)
|
||||
{
|
||||
nsFileSpec jarpath;
|
||||
rv = installInfo->GetLocalFile(jarpath);
|
||||
if (NS_SUCCEEDED(rv))
|
||||
{
|
||||
finalStatus = GetInstallScriptFromJarfile( jarpath,
|
||||
&scriptBuffer,
|
||||
&scriptLength);
|
||||
@ -414,15 +413,11 @@ extern "C" void RunInstallOnThread(void *data)
|
||||
}
|
||||
|
||||
if (scriptBuffer) delete [] scriptBuffer;
|
||||
if (jarpath)
|
||||
{
|
||||
if ( !url.Equals("file:/",PR_FALSE,6) )
|
||||
{
|
||||
// delete the jarfile only if we've downloaded it
|
||||
PR_Delete(jarpath);
|
||||
}
|
||||
|
||||
nsCRT::free(jarpath);
|
||||
if ( !url.Equals("file:/",PR_FALSE,6) )
|
||||
{
|
||||
// delete the jarfile only if we've downloaded it
|
||||
jarpath.Delete(PR_FALSE);
|
||||
}
|
||||
|
||||
softwareUpdate->SetActiveNotifier(0);
|
||||
|
Loading…
Reference in New Issue
Block a user