From 54ed2ee67b89abab9ca05b356c0cab5b5bcd885c Mon Sep 17 00:00:00 2001 From: "dbragg%netscape.com" Date: Wed, 22 Mar 2000 21:51:26 +0000 Subject: [PATCH] Backend plumbin fix for bugs 17505 and 20046 r=dveditz git-svn-id: svn://10.0.0.236/trunk@63760 18797224-902f-48f8-a5cc-f745e15eee43 --- mozilla/xpinstall/src/nsInstall.cpp | 20 ++++++------- mozilla/xpinstall/src/nsInstall.h | 8 ++---- mozilla/xpinstall/src/nsInstallFile.cpp | 9 +++--- mozilla/xpinstall/src/nsInstallFile.h | 15 ++++++++-- mozilla/xpinstall/src/nsJSInstall.cpp | 37 +++++++++++++++++++------ 5 files changed, 60 insertions(+), 29 deletions(-) diff --git a/mozilla/xpinstall/src/nsInstall.cpp b/mozilla/xpinstall/src/nsInstall.cpp index 193ff36c6ba..9cf85b9b874 100644 --- a/mozilla/xpinstall/src/nsInstall.cpp +++ b/mozilla/xpinstall/src/nsInstall.cpp @@ -285,7 +285,7 @@ nsInstall::AddDirectory(const nsString& aRegName, const nsString& aJarSource, nsInstallFolder *aFolder, const nsString& aSubdir, - PRBool aForceMode, + PRInt32 aMode, PRInt32* aReturn) { nsInstallFile* ie = nsnull; @@ -394,7 +394,7 @@ nsInstall::AddDirectory(const nsString& aRegName, newJarSource, aFolder, newSubDir, - aForceMode, + aMode, &result); if (ie == nsnull) @@ -433,7 +433,7 @@ nsInstall::AddDirectory(const nsString& aRegName, aJarSource, aFolder, aSubdir, - PR_FALSE, + INSTALL_NO_COMPARE, aReturn); } @@ -449,7 +449,7 @@ nsInstall::AddDirectory(const nsString& aRegName, aJarSource, aFolder, aSubdir, - PR_FALSE, + INSTALL_NO_COMPARE, aReturn); } @@ -468,7 +468,7 @@ nsInstall::AddDirectory(const nsString& aJarSource, aJarSource, mPackageFolder, "", - PR_FALSE, + INSTALL_NO_COMPARE, aReturn); } @@ -478,7 +478,7 @@ nsInstall::AddSubcomponent(const nsString& aRegName, const nsString& aJarSource, nsInstallFolder *aFolder, const nsString& aTargetName, - PRBool aForceMode, + PRInt32 aMode, PRInt32* aReturn) { nsInstallFile* ie; @@ -538,7 +538,7 @@ nsInstall::AddSubcomponent(const nsString& aRegName, aJarSource, aFolder, tempTargetName, - aForceMode, + aMode, &errcode ); if (ie == nsnull) @@ -573,7 +573,7 @@ nsInstall::AddSubcomponent(const nsString& aRegName, aJarSource, aFolder, aTargetName, - PR_FALSE, + INSTALL_NO_COMPARE, aReturn); } @@ -606,7 +606,7 @@ nsInstall::AddSubcomponent(const nsString& aRegName, aJarSource, aFolder, aTargetName, - PR_FALSE, + INSTALL_NO_COMPARE, aReturn); } @@ -641,7 +641,7 @@ nsInstall::AddSubcomponent(const nsString& aJarSource, aJarSource, mPackageFolder, "", - PR_FALSE, + INSTALL_NO_COMPARE, aReturn); } diff --git a/mozilla/xpinstall/src/nsInstall.h b/mozilla/xpinstall/src/nsInstall.h index 6bba96d6fbe..bf98f5a29c4 100644 --- a/mozilla/xpinstall/src/nsInstall.h +++ b/mozilla/xpinstall/src/nsInstall.h @@ -57,7 +57,6 @@ #include "nsIEnumerator.h" #include "nsIZipReader.h" - class nsInstallInfo { public: @@ -185,12 +184,12 @@ class nsInstall PRInt32 AbortInstall(PRInt32 aErrorNumber); - PRInt32 AddDirectory(const nsString& aRegName, const nsString& aVersion, const nsString& aJarSource, nsInstallFolder* aFolder, const nsString& aSubdir, PRBool aForceMode, PRInt32* aReturn); + PRInt32 AddDirectory(const nsString& aRegName, const nsString& aVersion, const nsString& aJarSource, nsInstallFolder* aFolder, const nsString& aSubdir, PRInt32 aMode, PRInt32* aReturn); PRInt32 AddDirectory(const nsString& aRegName, const nsString& aVersion, const nsString& aJarSource, nsInstallFolder* aFolder, const nsString& aSubdir, PRInt32* aReturn); PRInt32 AddDirectory(const nsString& aRegName, const nsString& aJarSource, nsInstallFolder* aFolder, const nsString& aSubdir, PRInt32* aReturn); PRInt32 AddDirectory(const nsString& aJarSource, PRInt32* aReturn); - PRInt32 AddSubcomponent(const nsString& aRegName, const nsString& aVersion, const nsString& aJarSource, nsInstallFolder *aFolder, const nsString& aTargetName, PRBool aForceMode, PRInt32* aReturn); + PRInt32 AddSubcomponent(const nsString& aRegName, const nsString& aVersion, const nsString& aJarSource, nsInstallFolder *aFolder, const nsString& aTargetName, PRInt32 aMode, PRInt32* aReturn); PRInt32 AddSubcomponent(const nsString& aRegName, const nsString& aVersion, const nsString& aJarSource, nsInstallFolder *aFolder, const nsString& aTargetName, PRInt32* aReturn); PRInt32 AddSubcomponent(const nsString& aRegName, const nsString& aJarSource, nsInstallFolder *aFolder, const nsString& aTargetName, PRInt32* aReturn); PRInt32 AddSubcomponent(const nsString& aJarSource, PRInt32* aReturn); @@ -267,7 +266,6 @@ class nsInstall PRInt32 SaveError(PRInt32 errcode); - private: JSObject* mScriptObject; @@ -301,7 +299,7 @@ class nsInstall nsCOMPtr mStringBundle; PRInt32 mLastError; - + void ParseFlags(int flags); PRInt32 SanityCheck(void); void GetTime(nsString &aString); diff --git a/mozilla/xpinstall/src/nsInstallFile.cpp b/mozilla/xpinstall/src/nsInstallFile.cpp index 3aa12f1b27f..931c1734ff9 100644 --- a/mozilla/xpinstall/src/nsInstallFile.cpp +++ b/mozilla/xpinstall/src/nsInstallFile.cpp @@ -50,7 +50,7 @@ nsInstallFile::nsInstallFile(nsInstall* inInstall, const nsString& inJarLocation, nsInstallFolder *folderSpec, const nsString& inPartialPath, - PRBool forceInstall, + PRInt32 mode, PRInt32 *error) : nsInstallObject(inInstall), mVersionInfo(nsnull), @@ -58,7 +58,7 @@ nsInstallFile::nsInstallFile(nsInstall* inInstall, mExtractedFile(nsnull), mFinalFile(nsnull), mVersionRegistryName(nsnull), - mForceInstall(forceInstall), + mMode(mode), mReplaceFile(PR_FALSE), mChildFile(PR_TRUE), mUpgradeFile(PR_FALSE), @@ -76,7 +76,7 @@ nsInstallFile::nsInstallFile(nsInstall* inInstall, /* Check for existence of the newer version */ #if 0 // XXX need to re-implement force mode in the opposite sense - + char* qualifiedRegNameString = inComponentName.ToNewCString(); // -------------------------------------------------------------------- @@ -86,7 +86,8 @@ nsInstallFile::nsInstallFile(nsInstall* inInstall, // IFF it's not force, AND the new file has a version, AND it's been // previously installed, THEN we have to do the version comparing foo. // -------------------------------------------------------------------- - if ( (forceInstall == PR_FALSE ) && (inVInfo != "") && ( VR_ValidateComponent( qualifiedRegNameString ) == 0 ) ) + if ( !(mode & INSTALL_NO_COMPARE ) && (inVInfo != "") && + ( VR_ValidateComponent( qualifiedRegNameString ) == 0 ) ) { nsInstallVersion *newVersion = new nsInstallVersion(); diff --git a/mozilla/xpinstall/src/nsInstallFile.h b/mozilla/xpinstall/src/nsInstallFile.h index 812bad2c221..4e58c1c2d75 100644 --- a/mozilla/xpinstall/src/nsInstallFile.h +++ b/mozilla/xpinstall/src/nsInstallFile.h @@ -35,6 +35,13 @@ #include "nsInstall.h" #include "nsInstallVersion.h" + +/* Global defines for file handling mode bitfield values */ +#define INSTALL_NO_COMPARE 0x1 +#define INSTALL_IF_NEWER 0x2 +#define INSTALL_IF_EQUAL_OR_NEWER 0x4 + + class nsInstallFile : public nsInstallObject { public: @@ -55,7 +62,7 @@ class nsInstallFile : public nsInstallObject const nsString& inJarLocation, nsInstallFolder *folderSpec, const nsString& inPartialPath, - PRBool forceInstall, + PRInt32 mode, PRInt32 *error); virtual ~nsInstallFile(); @@ -85,10 +92,14 @@ class nsInstallFile : public nsInstallObject PRBool mChildFile; /* whether file is a child */ PRBool mUpgradeFile; /* whether file is an upgrade */ PRBool mSkipInstall; /* if true don't install this file */ - + + PRInt32 mMode; /* an integer used like a bitfield to control * + * how a file is installed or registered */ PRInt32 CompleteFileMove(); PRInt32 RegisterInVersionRegistry(); + + }; #endif /* nsInstallFile_h__ */ diff --git a/mozilla/xpinstall/src/nsJSInstall.cpp b/mozilla/xpinstall/src/nsJSInstall.cpp index b3219cfb629..848b94c2665 100644 --- a/mozilla/xpinstall/src/nsJSInstall.cpp +++ b/mozilla/xpinstall/src/nsJSInstall.cpp @@ -28,6 +28,7 @@ #include "nsString.h" #include "nsInstall.h" +#include "nsInstallFile.h" #include "nsIDOMInstallVersion.h" @@ -389,7 +390,7 @@ InstallAddDirectory(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval nsAutoString b4; JSObject *jsObj; nsInstallFolder *folder; - PRBool b5; + PRInt32 b5; *rval = INT_TO_JSVAL(nsInstall::UNEXPECTED_ERROR); @@ -512,11 +513,21 @@ InstallAddDirectory(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval return JS_TRUE; } - if(!ConvertJSValToBool(&b5, cx, argv[5])) + if(JSVAL_IS_BOOLEAN(argv[5])) //Old form of the AddDirectory took a boolean { - return JS_FALSE; + b5 = JSVAL_TO_BOOLEAN(argv[5]); + if( b5 == PR_TRUE ) + b5 = INSTALL_NO_COMPARE; //convert to values that mean something in the bit field + else + b5 = INSTALL_IF_NEWER; + } + else + { + if(!(b5 = JSVAL_TO_INT(argv[5]))) //File handling bit field + { + return JS_FALSE; + } } - folder = (nsInstallFolder*)JS_GetPrivate(cx, jsObj); @@ -552,7 +563,7 @@ InstallAddSubcomponent(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, js nsAutoString b4; JSObject* jsObj; nsInstallFolder* folder; - PRBool b5; + PRInt32 b5; *rval = INT_TO_JSVAL(nsInstall::UNEXPECTED_ERROR); @@ -590,11 +601,21 @@ InstallAddSubcomponent(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, js return JS_TRUE; } - if(!ConvertJSValToBool(&b5, cx, argv[5])) + if(JSVAL_IS_BOOLEAN(argv[5])) //Old form of the AddSubComponent took a boolean { - return JS_FALSE; + b5 = JSVAL_TO_BOOLEAN(argv[5]); + if( b5 == PR_TRUE ) + b5 = INSTALL_NO_COMPARE; //convert to values that mean something in the bit field + else + b5 = INSTALL_IF_NEWER; + } + else + { + if(!(b5 = JSVAL_TO_INT(argv[5]))) //File handling bit field + { + return JS_FALSE; + } } - folder = (nsInstallFolder*)JS_GetPrivate(cx, jsObj);