diff --git a/mozilla/xpinstall/src/ScheduledTasks.cpp b/mozilla/xpinstall/src/ScheduledTasks.cpp index f3519f34dd1..69a2828acf0 100644 --- a/mozilla/xpinstall/src/ScheduledTasks.cpp +++ b/mozilla/xpinstall/src/ScheduledTasks.cpp @@ -31,130 +31,79 @@ #include "prmem.h" #include "ScheduledTasks.h" + + +static nsresult +GetPersistentStringFromSpec(const nsFileSpec& inSpec, char **string) +{ + if (!string) return NS_ERROR_NULL_POINTER; + + nsCOMPtr spec; + nsresult rv = NS_NewFileSpecWithSpec(inSpec, getter_AddRefs(spec)); + if (NS_SUCCEEDED(rv)) { + rv = spec->GetPersistentDescriptorString(string); + } + else { + *string = nsnull; + } + return rv; +} + + + + + #ifdef _WINDOWS #include #include -BOOL WIN32_IsMoveFileExBroken() +PRInt32 ReplaceExistingWindowsFile(const nsFileSpec& currentSpec, const nsFileSpec& finalSpec) { - /* the NT option MOVEFILE_DELAY_UNTIL_REBOOT is broken on - * Windows NT 3.51 Service Pack 4 and NT 4.0 before Service Pack 2 - */ - BOOL broken = PR_FALSE; - OSVERSIONINFO osinfo; + // this routine is now for DOS-based windows only. WinNT should + // be taken care of by the XP code + // + // NOTE for WINNT: + // + // the MOVEFILE_DELAY_UNTIL_REBOOT option doesn't work on + // NT 3.51 SP4 or on NT 4.0 until SP2. On the broken versions + // of NT 4.0 Microsoft warns using it can lead to an irreparably + // corrupt windows' registry "after an unknown number of calls". + // Time to reinstall windows when that happens. + // + // I don't want to risk it, I also don't want two separate code + // paths to test, so we do it the lame way on all NT systems + // until such time as there are few enough old revs around to + // make it worth switching back to MoveFileEx(). - // they *all* appear broken--better to have one way that works. - return PR_TRUE; - - osinfo.dwOSVersionInfoSize = sizeof(OSVERSIONINFO); - if (GetVersionEx(&osinfo) && osinfo.dwPlatformId == VER_PLATFORM_WIN32_NT) - { - if ( osinfo.dwMajorVersion == 3 && osinfo.dwMinorVersion == 51 ) - { - if ( 0 == stricmp(osinfo.szCSDVersion,"Service Pack 4")) - { - broken = PR_TRUE; - } - } - else if ( osinfo.dwMajorVersion == 4 ) - { - if (osinfo.szCSDVersion[0] == '\0' || - (0 == stricmp(osinfo.szCSDVersion,"Service Pack 1"))) - { - broken = PR_TRUE; - } - } - } - - return broken; -} - - -PRInt32 DoWindowsReplaceExistingFileStuff(const char* currentName, const char* finalName) -{ - PRInt32 err = 0; - - char* final = strdup(finalName); - char* current = strdup(currentName); - - /* couldn't delete, probably in use. Schedule for later */ - DWORD dwVersion, dwWindowsMajorVersion; + PRInt32 err = -1; /* Get OS version info */ - dwVersion = GetVersion(); - dwWindowsMajorVersion = (DWORD)(LOBYTE(LOWORD(dwVersion))); + DWORD dwVersion = GetVersion(); /* Get build numbers for Windows NT or Win32s */ - if (dwVersion < 0x80000000) // Windows NT + if (dwVersion > 0x80000000) { - /* On Windows NT */ - if ( WIN32_IsMoveFileExBroken() ) - { - /* the MOVEFILE_DELAY_UNTIL_REBOOT option doesn't work on - * NT 3.51 SP4 or on NT 4.0 until SP2 - */ - struct stat statbuf; - PRBool nameFound = PR_FALSE; - char tmpname[_MAX_PATH]; - - strncpy( tmpname, finalName, _MAX_PATH ); - int len = strlen(tmpname); - while (!nameFound && len < _MAX_PATH ) - { - tmpname[len-1] = '~'; - tmpname[len] = '\0'; - if ( stat(tmpname, &statbuf) != 0 ) - nameFound = PR_TRUE; - else - len++; - } + // Windows 95 or Win16 - if ( nameFound ) - { - if ( MoveFile( finalName, tmpname ) ) - { - if ( MoveFile( currentName, finalName ) ) - { - DeleteFileNowOrSchedule(nsFileSpec(tmpname)); - } - else - { - /* 2nd move failed, put old file back */ - MoveFile( tmpname, finalName ); - } - } - else - { - /* non-executable in use; schedule for later */ - return -1; // let the start registry stuff do our work! - } - } - } - else if ( MoveFileEx(currentName, finalName, MOVEFILE_DELAY_UNTIL_REBOOT) ) - { - err = 0; - } - } - else // Windows 95 or Win16 - { - /* - * Place an entry in the WININIT.INI file in the Windows directory - * to delete finalName and rename currentName to be finalName at reboot - */ + // Place an entry in the WININIT.INI file in the Windows directory + // to delete finalName and rename currentName to be finalName at reboot - int strlen; - char Src[_MAX_PATH]; // 8.3 name - char Dest[_MAX_PATH]; // 8.3 name + int strlen; + char Src[_MAX_PATH]; // 8.3 name + char Dest[_MAX_PATH]; // 8.3 name - strlen = GetShortPathName( (LPCTSTR)currentName, (LPTSTR)Src, (DWORD)sizeof(Src) ); + char* final = strdup(finalSpec.GetNativePathCString()); + char* current = strdup(currentSpec.GetNativePathCString()); + + strlen = GetShortPathName( (LPCTSTR)current, (LPTSTR)Src, (DWORD)sizeof(Src) ); if ( strlen > 0 ) { free(current); current = strdup(Src); } - strlen = GetShortPathName( (LPCTSTR) finalName, (LPTSTR) Dest, (DWORD) sizeof(Dest)); + strlen = GetShortPathName( (LPCTSTR) final, (LPTSTR) Dest, (DWORD) sizeof(Dest)); if ( strlen > 0 ) { free(final); @@ -169,12 +118,12 @@ PRInt32 DoWindowsReplaceExistingFileStuff(const char* currentName, const char* f AnsiToOem( current, current ); if ( WritePrivateProfileString( "Rename", final, current, "WININIT.INI" ) ) - err = 0; + err = 0; + + free(final); + free(current); } - free(final); - free(current); - return err; } #endif @@ -182,28 +131,47 @@ PRInt32 DoWindowsReplaceExistingFileStuff(const char* currentName, const char* f - -REGERR DeleteFileNowOrSchedule(const nsFileSpec& filename) +PRInt32 DeleteFileNowOrSchedule(const nsFileSpec& filename) { - REGERR result = 0; + PRInt32 result = nsInstall::SUCCESS; filename.Delete(PR_FALSE); - if (filename.Exists()) { + // could not delete, schedule it for later + RKEY newkey; HREG reg; - if ( REGERR_OK == NR_RegOpen("", ®) ) - { - if (REGERR_OK == NR_RegAddKey( reg, ROOTKEY_PRIVATE, REG_DELETE_LIST_KEY, &newkey) ) - { - // FIX should be using nsPersistentFileDescriptor!!! + REGERR err; + result = nsInstall::UNEXPECTED_ERROR; - const char *fnamestr = filename.GetNativePathCString(); - result = NR_RegSetEntry( reg, newkey, (char*)fnamestr, REGTYPE_ENTRY_FILE, (void*)fnamestr, strlen(fnamestr)); - if (result == REGERR_OK) - result = nsInstall::REBOOT_NEEDED; + err = NR_RegOpen("", ®) ; + if ( err == REGERR_OK ) + { + err = NR_RegAddKey(reg,ROOTKEY_PRIVATE,REG_DELETE_LIST_KEY,&newkey); + if ( err == REGERR_OK ) + { + char valname[20]; + char* fnamestr = nsnull; + + err = NR_RegGetUniqueName( reg, valname, sizeof(valname) ); + if ( err == REGERR_OK ) + { + nsresult rv; + rv = GetPersistentStringFromSpec( filename, &fnamestr ); + if ( NS_SUCCEEDED(rv) && fnamestr ) + { + + err = NR_RegSetEntry( reg, newkey, valname, + REGTYPE_ENTRY_BYTES, + (void*)fnamestr, + strlen(fnamestr)); + + if ( err == REGERR_OK ) + result = nsInstall::REBOOT_NEEDED; + } + } } NR_RegClose(reg); @@ -212,23 +180,41 @@ REGERR DeleteFileNowOrSchedule(const nsFileSpec& filename) return result; } -/* tmp file is the bad one that we want to replace with target. */ -REGERR ReplaceFileNowOrSchedule(nsFileSpec& replacementFile, nsFileSpec& doomedFile ) + + + +PRInt32 ReplaceFileNow(nsFileSpec& replacementFile, nsFileSpec& doomedFile ) { - REGERR result = 0; - - if(replacementFile == doomedFile) + // replacement file must exist, doomed file doesn't have to + if ( !replacementFile.Exists() ) + return nsInstall::DOES_NOT_EXIST; + + // don't have to do anything if the files are the same + if ( replacementFile == doomedFile ) + return nsInstall::SUCCESS; + + + PRInt32 result = nsInstall::ACCESS_DENIED; + + // first try to rename the doomed file out of the way (if it exists) + char* leafname; + nsFileSpec tmpfile( doomedFile ); + if ( tmpfile.Exists() ) { - /* do not have to do anything */ - return result; + tmpfile.MakeUnique(); + leafname = tmpfile.GetLeafName(); + tmpfile = doomedFile; + tmpfile.Rename( leafname ); + nsCRT::free( leafname ); } - doomedFile.Delete(PR_FALSE); + + // if doomedFile is gone move new file into place + nsresult rv; if ( !doomedFile.Exists() ) { - // Now that we have removed the existing file, we can move the replacement file into place. nsFileSpec parentofFinalFile; nsFileSpec parentofReplacementFile; @@ -240,37 +226,102 @@ REGERR ReplaceFileNowOrSchedule(nsFileSpec& replacementFile, nsFileSpec& doomedF // files like this (i.e. error if not in the same dir) or we need to take // a little more care in the move. if(parentofReplacementFile != parentofFinalFile) - result = replacementFile.MoveToDir(parentofFinalFile); - else - result = NS_OK; - - if ( NS_SUCCEEDED(result) ) { - char* leafName = doomedFile.GetLeafName(); - replacementFile.Rename(leafName); - nsCRT::free(leafName); + NS_WARN_IF_FALSE( 0, "File unpacked into a non-dest dir" ); + rv = replacementFile.MoveToDir(parentofFinalFile); } + else + rv = NS_OK; + + leafname = doomedFile.GetLeafName(); + if ( NS_SUCCEEDED(rv) ) + rv = replacementFile.Rename( leafname ); + + if ( NS_SUCCEEDED(rv) ) + { + // we replaced the old file OK, now we have to + // get rid of it permanently + result = DeleteFileNowOrSchedule( tmpfile ); + } + else + { + // couldn't rename file, try to put old file back + tmpfile.Rename( leafname ); + } + nsCRT::free( leafname ); } - else + + return result; +} + + + + + +PRInt32 ReplaceFileNowOrSchedule(nsFileSpec& replacementFile, nsFileSpec& doomedFile ) +{ + PRInt32 result = ReplaceFileNow( replacementFile, doomedFile ); + + if ( result == nsInstall::ACCESS_DENIED ) { + // if we couldn't replace the file schedule it for later #ifdef _WINDOWS - // XXX Holy cow! what the fsck is this? Fix it! - if (DoWindowsReplaceExistingFileStuff(replacementFile.GetNativePathCString(), doomedFile.GetNativePathCString()) == 0) - return 0; + if ( ReplaceExistingWindowsFile(replacementFile, doomedFile) == 0 ) + return nsInstall::REBOOT_NEEDED; #endif - RKEY newkey; - HREG reg; + RKEY listkey; + RKEY filekey; + HREG reg; + REGERR err; if ( REGERR_OK == NR_RegOpen("", ®) ) { - result = NR_RegAddKey( reg, ROOTKEY_PRIVATE, REG_REPLACE_LIST_KEY, &newkey); - if ( result == REGERR_OK ) + err = NR_RegAddKey( reg, ROOTKEY_PRIVATE, REG_REPLACE_LIST_KEY, &listkey ); + if ( err == REGERR_OK ) { - char* replacementFileName = (char*)(const char*)replacementFile.GetNativePathCString(); - result = NR_RegSetEntry( reg, newkey, (char*)(const char*)doomedFile.GetNativePathCString(), REGTYPE_ENTRY_FILE, replacementFileName, strlen(replacementFileName)); - if (result == REGERR_OK) - result = nsInstall::REBOOT_NEEDED; + char valname[20]; + char* fsrc = nsnull; + char* fdest = nsnull; + REGERR err2; + nsresult rv, rv2; + + err = NR_RegGetUniqueName( reg, valname, sizeof(valname) ); + if ( err == REGERR_OK ) + { + err = NR_RegAddKey( reg, listkey, valname, &filekey ); + if ( REGERR_OK == err ) + { + rv = GetPersistentStringFromSpec(replacementFile, &fsrc); + rv2 = GetPersistentStringFromSpec(doomedFile, &fdest); + if ( NS_SUCCEEDED(rv) && NS_SUCCEEDED(rv2) ) + { + + err = NR_RegSetEntry( reg, filekey, + REG_REPLACE_SRCFILE, + REGTYPE_ENTRY_BYTES, + (void*)fsrc, + strlen(fsrc)); + + err2 = NR_RegSetEntry(reg, filekey, + REG_REPLACE_DESTFILE, + REGTYPE_ENTRY_BYTES, + (void*)fdest, + strlen(fdest)); + + if ( err == REGERR_OK && err2 == REGERR_OK ) + result = nsInstall::REBOOT_NEEDED; + else + NR_RegDeleteKey( reg, listkey, valname ); + } + + if (NS_SUCCEEDED(rv)) + nsCRT::free(fsrc); + + if (NS_SUCCEEDED(rv2)) + nsCRT::free(fdest); + } + } } NR_RegClose(reg); @@ -280,113 +331,154 @@ REGERR ReplaceFileNowOrSchedule(nsFileSpec& replacementFile, nsFileSpec& doomedF return result; } -void DeleteScheduledFiles(void); -void ReplaceScheduledFiles(void); -extern "C" void PerformScheduledTasks(void *data) + + +//----------------------------------------------------------------------------- +// +// STARTUP: DO SCHEDULED ACTIONS +// +//----------------------------------------------------------------------------- + +void DeleteScheduledFiles(HREG); +void ReplaceScheduledFiles(HREG); + +void PerformScheduledTasks(void *data) { - DeleteScheduledFiles(); - ReplaceScheduledFiles(); -} + HREG reg; - -void DeleteScheduledFiles(void) -{ - HREG reg; - - if (REGERR_OK == NR_RegOpen("", ®)) + if ( REGERR_OK == NR_RegOpen("", ®) ) { - RKEY key; - REGENUM state = 0; - - /* perform scheduled file deletions and replacements (PC only) */ - if (REGERR_OK == NR_RegGetKey(reg, ROOTKEY_PRIVATE, REG_DELETE_LIST_KEY,&key)) - { - char buf[MAXREGNAMELEN]; - - while (REGERR_OK == NR_RegEnumEntries(reg, key, &state, buf, sizeof(buf), NULL )) - { - nsFileSpec doomedFile(buf); - - doomedFile.Delete(PR_FALSE); - - if (! doomedFile.Exists()) - { - NR_RegDeleteEntry( reg, key, buf ); - } - } - - /* delete list node if empty */ - if (REGERR_NOMORE == NR_RegEnumEntries( reg, key, &state, buf, sizeof(buf), NULL )) - { - NR_RegDeleteKey(reg, ROOTKEY_PRIVATE, REG_DELETE_LIST_KEY); - } - } - + DeleteScheduledFiles( reg ); + ReplaceScheduledFiles( reg ); NR_RegClose(reg); } } -void ReplaceScheduledFiles(void) + + +void DeleteScheduledFiles( HREG reg ) { - HREG reg; - - if (REGERR_OK == NR_RegOpen("", ®)) + REGERR err; + RKEY key; + REGENUM state = 0; + + /* perform scheduled file deletions */ + if (REGERR_OK == NR_RegGetKey(reg,ROOTKEY_PRIVATE,REG_DELETE_LIST_KEY,&key)) { - RKEY key; - REGENUM state; + // the delete key exists, so we loop through its children + // and try to delete all the listed files - /* replace files if any listed */ - if (REGERR_OK == NR_RegGetKey(reg, ROOTKEY_PRIVATE, REG_REPLACE_LIST_KEY, &key)) + char namebuf[MAXREGNAMELEN]; + char valbuf[MAXREGPATHLEN]; + + nsFileSpec doomedFile; + nsCOMPtr spec; + + nsresult rv = NS_NewFileSpec(getter_AddRefs(spec)); + if (NS_SUCCEEDED(rv)) { - char dummyFile[MAXREGNAMELEN]; - char target[MAXREGNAMELEN]; - - state = 0; - while (REGERR_OK == NR_RegEnumEntries(reg, key, &state, dummyFile, sizeof(dummyFile), NULL )) + while (REGERR_OK == NR_RegEnumEntries( reg, key, &state, namebuf, + sizeof(namebuf), 0 ) ) { - - nsFileSpec replaceFile(dummyFile); - - if (! replaceFile.Exists() ) + uint32 bufsize = sizeof(valbuf); // gets changed, must reset + err = NR_RegGetEntry( reg, key, namebuf, valbuf, &bufsize ); + if ( err == REGERR_OK ) { - NR_RegDeleteEntry( reg, key, dummyFile ); - } - else if ( REGERR_OK != NR_RegGetEntryString( reg, key, dummyFile, target, sizeof(target) ) ) - { - /* can't read target filename, corruption? */ - NR_RegDeleteEntry( reg, key, dummyFile ); - } - else - { - nsFileSpec targetFile(target); - - targetFile.Delete(PR_FALSE); - - if (!targetFile.Exists()) + // no need to check return value of + // SetPersistentDescriptorString, it's always NS_OK + spec->SetPersistentDescriptorString(valbuf); + rv = spec->GetFileSpec(&doomedFile); + if (NS_SUCCEEDED(rv)) { - nsFileSpec parentofTarget; - targetFile.GetParent(parentofTarget); - - nsresult result = replaceFile.MoveToDir(parentofTarget); - if ( NS_SUCCEEDED(result) ) + doomedFile.Delete(PR_FALSE); + if ( !doomedFile.Exists() ) { - char* leafName = targetFile.GetLeafName(); - replaceFile.Rename(leafName); - nsCRT::free(leafName); - - NR_RegDeleteEntry( reg, key, dummyFile ); + // deletion successful, don't have to retry + NR_RegDeleteEntry( reg, key, namebuf ); } } } } + /* delete list node if empty */ - if (REGERR_NOMORE == NR_RegEnumEntries(reg, key, &state, dummyFile, sizeof(dummyFile), NULL )) + state = 0; + err = NR_RegEnumEntries(reg, key, &state, namebuf, sizeof(namebuf), 0); + if ( err == REGERR_NOMORE ) + { + NR_RegDeleteKey(reg, ROOTKEY_PRIVATE, REG_DELETE_LIST_KEY); + } + } + } +} + + + +void ReplaceScheduledFiles( HREG reg ) +{ + RKEY key; + + /* replace files if any listed */ + if (REGERR_OK == NR_RegGetKey(reg,ROOTKEY_PRIVATE,REG_REPLACE_LIST_KEY,&key)) + { + char keyname[MAXREGNAMELEN]; + char doomedFile[MAXREGPATHLEN]; + char srcFile[MAXREGPATHLEN]; + + nsFileSpec doomedSpec; + nsFileSpec srcSpec; + nsCOMPtr src; + nsCOMPtr dest; + nsresult rv1, rv2; + + rv1 = NS_NewFileSpec(getter_AddRefs(src)); + rv2 = NS_NewFileSpec(getter_AddRefs(dest)); + if (NS_SUCCEEDED(rv1) && NS_SUCCEEDED(rv2)) + { + uint32 bufsize; + REGENUM state = 0; + while (REGERR_OK == NR_RegEnumSubkeys( reg, key, &state, + keyname, sizeof(keyname), REGENUM_CHILDREN)) + { + bufsize = sizeof(srcFile); + REGERR err1 = NR_RegGetEntry( reg, (RKEY)state, + REG_REPLACE_SRCFILE, srcFile, &bufsize); + + bufsize = sizeof(doomedFile); + REGERR err2 = NR_RegGetEntry( reg, (RKEY)state, + REG_REPLACE_DESTFILE, doomedFile, &bufsize); + + if ( err1 == REGERR_OK && err2 == REGERR_OK ) + { + src->SetPersistentDescriptorString(srcFile); + rv1 = src->GetFileSpec(&srcSpec); + + dest->SetPersistentDescriptorString(doomedFile); + rv2 = src->GetFileSpec(&doomedSpec); + + if (NS_SUCCEEDED(rv1) && NS_SUCCEEDED(rv2)) + { + // finally now try to do the replace + PRInt32 result = ReplaceFileNow( srcSpec, doomedSpec ); + + if ( result == nsInstall::DOES_NOT_EXIST || + result == nsInstall::SUCCESS ) + { + // This one is done + NR_RegDeleteKey( reg, key, keyname ); + } + } + } + } + + + /* delete list node if empty */ + state = 0; + if (REGERR_NOMORE == NR_RegEnumSubkeys( reg, key, &state, keyname, + sizeof(keyname), REGENUM_CHILDREN )) { NR_RegDeleteKey(reg, ROOTKEY_PRIVATE, REG_REPLACE_LIST_KEY); } } - - NR_RegClose(reg); } } diff --git a/mozilla/xpinstall/src/ScheduledTasks.h b/mozilla/xpinstall/src/ScheduledTasks.h index 2aec3bda345..1e11bb33e34 100644 --- a/mozilla/xpinstall/src/ScheduledTasks.h +++ b/mozilla/xpinstall/src/ScheduledTasks.h @@ -30,12 +30,14 @@ #include "NSReg.h" #include "nsFileSpec.h" +PR_BEGIN_EXTERN_C -REGERR DeleteFileNowOrSchedule(const nsFileSpec& filename); -REGERR ReplaceFileNowOrSchedule(nsFileSpec& tmpfile, nsFileSpec& target ); +PRInt32 DeleteFileNowOrSchedule(const nsFileSpec& filename); +PRInt32 ReplaceFileNowOrSchedule(nsFileSpec& tmpfile, nsFileSpec& target ); -extern "C" void PerformScheduledTasks(void *data); +void PerformScheduledTasks(void *data); +PR_END_EXTERN_C #endif diff --git a/mozilla/xpinstall/src/nsInstall.cpp b/mozilla/xpinstall/src/nsInstall.cpp index 067828dd590..4ae98649291 100644 --- a/mozilla/xpinstall/src/nsInstall.cpp +++ b/mozilla/xpinstall/src/nsInstall.cpp @@ -135,6 +135,13 @@ 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(kJARCID, nsnull, kIJARIID, (void**) &mJarFileData); @@ -333,7 +340,7 @@ nsInstall::AddDirectory(const nsString& aRegName, if (count == 0) { - *aReturn = SaveError( nsInstall::DESTINATION_DOES_NOT_EXIST ); + *aReturn = SaveError( nsInstall::DOES_NOT_EXIST ); return NS_OK; } @@ -671,7 +678,7 @@ nsInstall::DeleteFile(const nsString& aFolder, const nsString& aRelativeFileName result = ScheduleForInstall( id ); } - if (result == nsInstall::DESTINATION_DOES_NOT_EXIST) + if (result == nsInstall::DOES_NOT_EXIST) { result = nsInstall::SUCCESS; } @@ -736,7 +743,7 @@ nsInstall::Execute(const nsString& aJarSource, PRInt32* aReturn) PRInt32 nsInstall::FinalizeInstall(PRInt32* aReturn) { - PRInt32 result; + PRInt32 result = SUCCESS; PRBool rebootNeeded = PR_FALSE; *aReturn = SanityCheck(); @@ -832,7 +839,7 @@ nsInstall::FinalizeInstall(PRInt32* aReturn) mNotifier->FinalStatus(mInstallURL.GetUnicode(), *aReturn); mStatusSent = PR_TRUE; } - } + } if((result == nsInstall::SUCCESS) || (result == REBOOT_NEEDED)) CleanUp(); diff --git a/mozilla/xpinstall/src/nsInstall.h b/mozilla/xpinstall/src/nsInstall.h index 0b2bbc305da..013c96ae0b7 100644 --- a/mozilla/xpinstall/src/nsInstall.h +++ b/mozilla/xpinstall/src/nsInstall.h @@ -123,9 +123,9 @@ class nsInstall INSTALL_NOT_STARTED = -211, SILENT_MODE_DENIED = -212, NO_SUCH_COMPONENT = -213, - DESTINATION_DOES_NOT_EXIST = -214, - DESTINATION_READ_ONLY = -215, - DESTINATION_IS_DIRECTORY = -216, + DOES_NOT_EXIST = -214, + READ_ONLY = -215, + IS_DIRECTORY = -216, NETWORK_FILE_IS_IN_USE = -217, APPLE_SINGLE_ERR = -218, INVALID_PATH_ERR = -219, @@ -140,8 +140,8 @@ class nsInstall DOWNLOAD_ERROR = -228, SCRIPT_ERROR = -229, - DESTINATION_ALREADY_EXISTS = -230, - DESTINATION_IS_FILE = -231, + ALREADY_EXISTS = -230, + IS_FILE = -231, SOURCE_DOES_NOT_EXIST = -232, SOURCE_IS_DIRECTORY = -233, SOURCE_IS_FILE = -234, diff --git a/mozilla/xpinstall/src/nsInstallDelete.cpp b/mozilla/xpinstall/src/nsInstallDelete.cpp index 9888306eccc..c93e31122b0 100644 --- a/mozilla/xpinstall/src/nsInstallDelete.cpp +++ b/mozilla/xpinstall/src/nsInstallDelete.cpp @@ -244,12 +244,12 @@ PRInt32 nsInstallDelete::ProcessInstallDelete() } else { - err = nsInstall::DESTINATION_IS_DIRECTORY; + err = nsInstall::IS_DIRECTORY; } } else { - err = nsInstall::DESTINATION_DOES_NOT_EXIST; + err = nsInstall::DOES_NOT_EXIST; } return err; @@ -259,6 +259,7 @@ PRInt32 nsInstallDelete::ProcessInstallDelete() PRInt32 nsInstallDelete::NativeComplete() { + NS_WARN_IF_FALSE(mFinalFile->Exists(),"nsInstallDelete::Complete -- file should exist!"); if (mFinalFile->Exists()) { if (mFinalFile->IsFile()) @@ -267,10 +268,11 @@ PRInt32 nsInstallDelete::NativeComplete() } else { - return nsInstall::DESTINATION_IS_DIRECTORY; + NS_ASSERTION(0,"nsInstallDelete::Complete -- expected file was a directory!"); + return nsInstall::IS_DIRECTORY; } } - return nsInstall::DESTINATION_DOES_NOT_EXIST; + return nsInstall::DOES_NOT_EXIST; } diff --git a/mozilla/xpinstall/src/nsInstallFile.cpp b/mozilla/xpinstall/src/nsInstallFile.cpp index 325ea0a9ad1..ffa7bd96ba8 100644 --- a/mozilla/xpinstall/src/nsInstallFile.cpp +++ b/mozilla/xpinstall/src/nsInstallFile.cpp @@ -253,7 +253,7 @@ PRInt32 nsInstallFile::Complete() if ( 0 == err || nsInstall::REBOOT_NEEDED == err ) { - err = RegisterInVersionRegistry(); + RegisterInVersionRegistry(); } return err; diff --git a/mozilla/xpinstall/src/nsInstallFileOpItem.cpp b/mozilla/xpinstall/src/nsInstallFileOpItem.cpp index 7dfd92c83c4..744eebb93e0 100644 --- a/mozilla/xpinstall/src/nsInstallFileOpItem.cpp +++ b/mozilla/xpinstall/src/nsInstallFileOpItem.cpp @@ -450,7 +450,7 @@ nsInstallFileOpItem::RegisterPackageNode() PRInt32 nsInstallFileOpItem::NativeFileOpDirCreatePrepare() { - PRInt32 ret = nsInstall::DESTINATION_ALREADY_EXISTS; + PRInt32 ret = nsInstall::ALREADY_EXISTS; PRBool flagPreExist; mAction = nsInstallFileOpItem::ACTION_FAILED; @@ -488,10 +488,10 @@ nsInstallFileOpItem::NativeFileOpDirRemovePrepare() if(!mTarget->IsFile()) return nsInstall::SUCCESS; else - return nsInstall::DESTINATION_IS_FILE; + return nsInstall::IS_FILE; } - return nsInstall::DESTINATION_DOES_NOT_EXIST; + return nsInstall::DOES_NOT_EXIST; } PRInt32 @@ -518,7 +518,7 @@ nsInstallFileOpItem::NativeFileOpFileRenamePrepare() target += *mStrTarget; if(target.Exists()) - return nsInstall::DESTINATION_ALREADY_EXISTS; + return nsInstall::ALREADY_EXISTS; else return nsInstall::SUCCESS; } @@ -555,7 +555,7 @@ nsInstallFileOpItem::NativeFileOpFileRenameComplete() Recycle(cStrTarget); } else - return nsInstall::DESTINATION_ALREADY_EXISTS; + return nsInstall::ALREADY_EXISTS; } else ret = nsInstall::SOURCE_IS_DIRECTORY; @@ -600,9 +600,9 @@ nsInstallFileOpItem::NativeFileOpFileCopyPrepare() if(mSrc->IsFile()) { if(!mTarget->Exists()) - return nsInstall::DESTINATION_DOES_NOT_EXIST; + return nsInstall::DOES_NOT_EXIST; else if(mTarget->IsFile()) - return nsInstall::DESTINATION_IS_FILE; + return nsInstall::IS_FILE; return nsInstall::SUCCESS; } @@ -653,10 +653,10 @@ nsInstallFileOpItem::NativeFileOpFileDeletePrepare() if(mTarget->IsFile()) return nsInstall::SUCCESS; else - return nsInstall::DESTINATION_IS_DIRECTORY; + return nsInstall::IS_DIRECTORY; } - return nsInstall::DESTINATION_DOES_NOT_EXIST; + return nsInstall::DOES_NOT_EXIST; } PRInt32 @@ -667,10 +667,10 @@ nsInstallFileOpItem::NativeFileOpFileDeleteComplete(nsFileSpec *aTarget) if(aTarget->IsFile()) return DeleteFileNowOrSchedule(*aTarget); else - return nsInstall::DESTINATION_IS_DIRECTORY; + return nsInstall::IS_DIRECTORY; } - return nsInstall::DESTINATION_DOES_NOT_EXIST; + return nsInstall::DOES_NOT_EXIST; } PRInt32 @@ -687,10 +687,10 @@ nsInstallFileOpItem::NativeFileOpFileExecutePrepare() if(mTarget->IsFile()) return nsInstall::SUCCESS; else - return nsInstall::DESTINATION_IS_DIRECTORY; + return nsInstall::IS_DIRECTORY; } - return nsInstall::DESTINATION_DOES_NOT_EXIST; + return nsInstall::DOES_NOT_EXIST; } PRInt32 @@ -711,7 +711,7 @@ nsInstallFileOpItem::NativeFileOpFileMovePrepare() if(mSrc->Exists()) { if(!mTarget->Exists()) - return nsInstall::DESTINATION_DOES_NOT_EXIST; + return nsInstall::DOES_NOT_EXIST; else return NativeFileOpFileCopyPrepare(); } @@ -728,7 +728,7 @@ nsInstallFileOpItem::NativeFileOpFileMoveComplete() if(mSrc->Exists()) { if(!mTarget->Exists()) - ret = nsInstall::DESTINATION_DOES_NOT_EXIST; + ret = nsInstall::DOES_NOT_EXIST; else { PRInt32 ret2 = nsInstall::SUCCESS; @@ -786,7 +786,7 @@ nsInstallFileOpItem::NativeFileOpFileMoveAbort() } } else - ret = nsInstall::DESTINATION_DOES_NOT_EXIST; + ret = nsInstall::DOES_NOT_EXIST; } return ret; @@ -809,12 +809,12 @@ nsInstallFileOpItem::NativeFileOpDirRenamePrepare() target += *mStrTarget; if(target.Exists()) - return nsInstall::DESTINATION_ALREADY_EXISTS; + return nsInstall::ALREADY_EXISTS; else return nsInstall::SUCCESS; } else - return nsInstall::DESTINATION_IS_FILE; + return nsInstall::IS_FILE; } return nsInstall::SOURCE_DOES_NOT_EXIST; @@ -846,7 +846,7 @@ nsInstallFileOpItem::NativeFileOpDirRenameComplete() Recycle(cStrTarget); } else - return nsInstall::DESTINATION_ALREADY_EXISTS; + return nsInstall::ALREADY_EXISTS; } else ret = nsInstall::SOURCE_IS_FILE; diff --git a/mozilla/xpinstall/src/nsInstallPatch.cpp b/mozilla/xpinstall/src/nsInstallPatch.cpp index 9e752f9e453..665adefd249 100644 --- a/mozilla/xpinstall/src/nsInstallPatch.cpp +++ b/mozilla/xpinstall/src/nsInstallPatch.cpp @@ -184,12 +184,12 @@ PRInt32 nsInstallPatch::Prepare() } else { - err = nsInstall::DESTINATION_IS_DIRECTORY; + err = nsInstall::IS_DIRECTORY; } } else { - err = nsInstall::DESTINATION_DOES_NOT_EXIST; + err = nsInstall::DOES_NOT_EXIST; } if (err != nsInstall::SUCCESS) diff --git a/mozilla/xpinstall/src/nsJSInstall.cpp b/mozilla/xpinstall/src/nsJSInstall.cpp index c0554f5921e..a0cec945be3 100644 --- a/mozilla/xpinstall/src/nsJSInstall.cpp +++ b/mozilla/xpinstall/src/nsJSInstall.cpp @@ -192,7 +192,6 @@ void ConvertJSValToStr(nsString& aString, jsval aValue) { JSString *jsstring; - jschar* chars=nsnull; if((jsstring = JS_ValueToString(aContext, aValue)) != nsnull) { @@ -1037,7 +1036,6 @@ InstallGetWinRegistry(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsv #ifdef _WINDOWS nsInstall *nativeThis = (nsInstall*)JS_GetPrivate(cx, obj); - JSBool rBool = JS_FALSE; // If there's no private data, this must be the prototype, so ignore if(nsnull == nativeThis) @@ -2514,9 +2512,9 @@ static JSConstDoubleSpec install_constants[] = { nsInstall::INSTALL_NOT_STARTED, "INSTALL_NOT_STARTED" }, { nsInstall::SILENT_MODE_DENIED, "SILENT_MODE_DENIED" }, { nsInstall::NO_SUCH_COMPONENT, "NO_SUCH_COMPONENT" }, - { nsInstall::DESTINATION_DOES_NOT_EXIST, "DESTINATION_DOES_NOT_EXIST" }, - { nsInstall::DESTINATION_READ_ONLY, "DESTINATION_READ_ONLY" }, - { nsInstall::DESTINATION_IS_DIRECTORY, "DESTINATION_IS_DIRECTORY" }, + { nsInstall::DOES_NOT_EXIST, "DOES_NOT_EXIST" }, + { nsInstall::READ_ONLY, "READ_ONLY" }, + { nsInstall::IS_DIRECTORY, "IS_DIRECTORY" }, { nsInstall::NETWORK_FILE_IS_IN_USE, "NETWORK_FILE_IS_IN_USE" }, { nsInstall::APPLE_SINGLE_ERR, "APPLE_SINGLE_ERR" }, { nsInstall::INVALID_PATH_ERR, "INVALID_PATH_ERR" }, @@ -2531,8 +2529,8 @@ static JSConstDoubleSpec install_constants[] = { nsInstall::DOWNLOAD_ERROR, "DOWNLOAD_ERROR" }, { nsInstall::SCRIPT_ERROR, "SCRIPT_ERROR" }, - { nsInstall::DESTINATION_ALREADY_EXISTS, "DESTINATION_ALREADY_EXISTS" }, - { nsInstall::DESTINATION_IS_FILE, "DESTINATION_IS_FILE" }, + { nsInstall::ALREADY_EXISTS, "ALREADY_EXISTS" }, + { nsInstall::IS_FILE, "IS_FILE" }, { nsInstall::SOURCE_DOES_NOT_EXIST, "SOURCE_DOES_NOT_EXIST" }, { nsInstall::SOURCE_IS_DIRECTORY, "SOURCE_IS_DIRECTORY" }, { nsInstall::SOURCE_IS_FILE, "SOURCE_IS_FILE" }, diff --git a/mozilla/xpinstall/src/nsSoftwareUpdate.cpp b/mozilla/xpinstall/src/nsSoftwareUpdate.cpp index 6efdd533a84..ecd1aa51a01 100644 --- a/mozilla/xpinstall/src/nsSoftwareUpdate.cpp +++ b/mozilla/xpinstall/src/nsSoftwareUpdate.cpp @@ -101,10 +101,6 @@ nsSoftwareUpdate::GetInstance() nsSoftwareUpdate::nsSoftwareUpdate() { -#ifdef NS_DEBUG - printf("XPInstall Component created\n"); -#endif - NS_INIT_ISUPPORTS(); mStubLockout = PR_FALSE; @@ -167,17 +163,13 @@ nsSoftwareUpdate::nsSoftwareUpdate() nsSoftwareUpdate::~nsSoftwareUpdate() { -#ifdef NS_DEBUG - printf("*** XPInstall Component destroyed\n"); -#endif - PR_Lock(mLock); if (mJarInstallQueue != nsnull) { - PRInt32 i=0; - for (; i < mJarInstallQueue->Count(); i++) + nsInstallInfo* element; + for (PRInt32 i=0; i < mJarInstallQueue->Count(); i++) { - nsInstallInfo* element = (nsInstallInfo*)mJarInstallQueue->ElementAt(i); + element = (nsInstallInfo*)mJarInstallQueue->ElementAt(i); //FIX: need to add to registry.... delete element; } @@ -191,8 +183,7 @@ nsSoftwareUpdate::~nsSoftwareUpdate() NR_ShutdownRegistry(); - if (mProgramDir) - mProgramDir->Release(); + NS_IF_RELEASE( mProgramDir ); }