Getting installed overlays to work, dogfood bug 1011 in bugSCAPE. Also fixing

misc horkage (still!!) from the nsIFile landing necessary to get this working
(bugs 40228, 40403, 40405, 37964, 28950)
This commit is contained in:
dveditz%netscape.com 2000-05-24 14:13:39 +00:00
Родитель f7e354c4f1
Коммит 7a106ebdea
7 изменённых файлов: 108 добавлений и 98 удалений

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

@ -257,8 +257,6 @@ nsInstall::InternalAbort(PRInt32 errcode)
nsInstallObject* ie;
if (mInstalledFiles != nsnull)
{
//PRUint32 i;
//mInstalledFiles->Count(&i);
for (PRInt32 i = mInstalledFiles->Count(); i >= 0; i--)
{
ie = (nsInstallObject *)mInstalledFiles->ElementAt(i);
@ -788,12 +786,8 @@ nsInstall::FinalizeInstall(PRInt32* aReturn)
}
if ( mInstalledFiles != NULL)
if ( mInstalledFiles->Count() > 0 )
{
//PRUint32 i = 0;
//mInstalledFiles->Count(&i);
if ( mInstalledFiles->Count() > 0 )
{
if ( mUninstallPackage )
{
VR_UninstallCreateNode( (char*)(const char*) nsAutoCString(mRegistryPackageName),
@ -804,7 +798,7 @@ nsInstall::FinalizeInstall(PRInt32* aReturn)
if (mVersionInfo)
{
nsString versionString;
nsString path;
nsCString path;
mVersionInfo->ToString(versionString);
@ -812,15 +806,13 @@ nsInstall::FinalizeInstall(PRInt32* aReturn)
mPackageFolder->GetDirectoryPath(path);
VR_Install( (char*)(const char*)nsAutoCString(mRegistryPackageName),
(char*)(const char*)nsAutoCString(path),
(char*)path.GetBuffer(),
(char*)(const char*)nsAutoCString(versionString),
PR_FALSE );
}
nsInstallObject* ie = nsnull;
//PRUint32 numberOfFiles = 0;
//mInstalledFiles->Count(&numberOfFiles);
for (PRInt32 i=0; i < mInstalledFiles->Count(); i++)
{
ie = (nsInstallObject*)mInstalledFiles->ElementAt(i);
@ -883,7 +875,6 @@ nsInstall::FinalizeInstall(PRInt32* aReturn)
mListener->FinalStatus(mInstallURL.GetUnicode(), *aReturn);
mStatusSent = PR_TRUE;
}
}
}
else
{
@ -1493,7 +1484,6 @@ nsInstall::StartInstall(const nsString& aUserPackageName, const nsString& aRegis
mVersionInfo->Init(aVersion);
mInstalledFiles = new nsVoidArray();
//nsresult rv = NS_NewISupportsArray(getter_AddRefs(mInstalledFiles));
if (mInstalledFiles == nsnull)
{
@ -2351,8 +2341,6 @@ nsInstall::CleanUp(void)
if ( mInstalledFiles != nsnull )
{
//PRUint32 numberOfObjects = 0;
//mInstalledFiles->Count(&numberOfObjects);
for (PRInt32 i=0; i < mInstalledFiles->Count(); i++)
{
ie = (nsInstallObject*)mInstalledFiles->ElementAt(i);

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

@ -159,6 +159,8 @@ class nsInstall
UNABLE_TO_LOAD_LIBRARY = -238,
CHROME_REGISTRY_ERROR = -239,
MALFORMED_INSTALL = -240,
OUT_OF_MEMORY = -299,

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

@ -31,6 +31,7 @@
#include "nsRepository.h"
#include "nsString.h"
#include "nsXPIDLString.h"
#include "nsFileSpec.h"
#include "nsIFileSpec.h"
#include "nsIFile.h"
@ -102,50 +103,10 @@ nsInstallFolder::Init(nsIFile* rawIFile)
nsresult
nsInstallFolder::Init(const nsString& aFolderID, const nsString& aRelativePath)
{
PRBool flagIsDir, flagExists;
mFileSpec = nsnull;
/*
aFolderID can be either a Folder enum in which case we merely pass it
to SetDirectoryPath, or it can be a Directory. If it is the later, it
must already exist and of course be a directory not a file.
*/
SetDirectoryPath( aFolderID, aRelativePath );
if (mFileSpec)
return NS_OK;
// it didn't, so aFolderID is not one of the magic strings.
// maybe it's already a pathname? If so it had better be a directory
// if it already exists...
nsAutoCString tempFolderID(aFolderID);
nsCOMPtr<nsILocalFile> dirCheck;
NS_NewLocalFile(tempFolderID, getter_AddRefs(dirCheck));
if (!dirCheck)
return NS_ERROR_FAILURE;
dirCheck->IsDirectory(&flagIsDir);
dirCheck->Exists(&flagExists);
if ( flagIsDir && flagExists )
{
mFileSpec = dirCheck;
if (aRelativePath.Length() > 0 )
{
// we've got a subdirectory to tack on
nsString morePath(aFolderID);
morePath.Append(aRelativePath);
nsAutoCString tempMorePath(morePath);
NS_NewLocalFile(tempMorePath, getter_AddRefs(dirCheck));
mFileSpec = dirCheck;
}
}
if (mFileSpec)
return NS_OK;
@ -164,10 +125,7 @@ nsInstallFolder::Init(nsInstallFolder& inFolder, const nsString& subString)
return NS_ERROR_FAILURE;
if(!subString.IsEmpty())
{
nsAutoCString tempSubString(subString);
mFileSpec->Append(tempSubString);
}
AppendXPPath(subString);
return NS_OK;
}
@ -179,24 +137,24 @@ nsInstallFolder::~nsInstallFolder()
}
void
nsInstallFolder::GetDirectoryPath(nsString& aDirectoryPath)
nsInstallFolder::GetDirectoryPath(nsCString& aDirectoryPath)
{
PRBool flagIsDir;
char* thePath;
PRBool flagIsDir;
nsXPIDLCString thePath;
aDirectoryPath.SetLength(0);
if (mFileSpec != nsnull)
{
// We want the a NATIVE path.
mFileSpec->GetPath(&thePath);
aDirectoryPath.AssignWithConversion(thePath);
// We want the NATIVE path.
mFileSpec->GetPath(getter_Copies(thePath));
aDirectoryPath.Assign(thePath);
mFileSpec->IsDirectory(&flagIsDir);
if (flagIsDir)
{
if (aDirectoryPath.Last() != FILESEP)
aDirectoryPath.AppendWithConversion(FILESEP);
aDirectoryPath.Append(FILESEP);
}
}
}
@ -205,7 +163,7 @@ void
nsInstallFolder::SetDirectoryPath(const nsString& aFolderID, const nsString& aRelativePath)
{
if ( aFolderID.EqualsIgnoreCase("Installed") )
{
{
// XXX block from users or remove "Installed"
// XXX the filespec creation will fail due to unix slashes on Mac
nsAutoCString tempRelPath(aRelativePath);
@ -548,22 +506,51 @@ nsInstallFolder::SetDirectoryPath(const nsString& aFolderID, const nsString& aRe
case -1:
default:
mFileSpec = nsnull;
return;
break;
}
if (aRelativePath.Length() > 0 && mFileSpec)
{
//nsString tempPath(aRelativePath);
//if (aRelativePath.Last() != '/' || aRelativePath.Last() != '\\')
// tempPath.AppendWithConversion('/');
nsAutoCString tempRelPath(aRelativePath);
mFileSpec->Append(tempRelPath);
AppendXPPath(aRelativePath);
}
}
}
void
nsInstallFolder::AppendXPPath(const nsString& aRelativePath)
{
nsAutoString segment;
PRInt32 start = 0;
PRInt32 curr;
do {
curr = aRelativePath.FindChar('/',PR_FALSE,start);
if ( curr > start )
{
// found a segment
aRelativePath.Mid(segment,start,curr-start);
start = curr+1;
}
else
{
// last segment
aRelativePath.Mid(segment,start,-1);
}
nsresult rv = mFileSpec->AppendUnicode(segment.GetUnicode());
if (NS_FAILED(rv))
{
// Unicode converters not present (likely wizard case)
// so do our best with the vanilla conversion.
nsCAutoString tmp;
tmp.AssignWithConversion(segment);
mFileSpec->Append(tmp.GetBuffer());
}
} while ( curr != kNotFound );
}
/* MapNameToEnum
* maps name from the directory table to its enum */
PRInt32
@ -596,24 +583,37 @@ nsInstallFolder::ToString(nsAutoString* outString)
{
//XXX: May need to fix. Native charset paths will be converted into Unicode when the get to JS
// This will appear to work on Latin-1 charsets but won't work on Mac or other charsets.
// On the other hand doing it right requires intl charset converters
// which we don't yet have in the initial install case.
char* temp;
PRBool flagIsFile;
if (!mFileSpec)
if (!mFileSpec || !outString)
return NS_ERROR_NULL_POINTER;
nsresult rv = mFileSpec->GetPath(&temp);
nsXPIDLString tempUC;
nsresult rv = mFileSpec->GetUnicodePath(getter_Copies(tempUC));
if (NS_SUCCEEDED(rv))
{
outString->Assign(tempUC);
}
else
{
// converters not present, most likely in wizard case;
// do best we can with stock ASCII conversion
// XXX NOTE we can make sure our filenames are ASCII, but we have no
// control over the directory name which might be localized!!!
nsXPIDLCString temp;
rv = mFileSpec->GetPath(getter_Copies(temp));
outString->AssignWithConversion(temp);
}
PRBool flagIsFile;
mFileSpec->IsFile(&flagIsFile);
if (!flagIsFile)
{
nsString tempString;
tempString.AssignWithConversion(temp);
tempString.AppendWithConversion(FILESEP);
nsAutoCString tempAutoString(tempString);
outString->AssignWithConversion(tempAutoString);
// assume directory, thus end with slash.
outString->AppendWithConversion(FILESEP);
}
else
outString->AssignWithConversion(temp);
return rv;
}

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

@ -45,7 +45,7 @@ class nsInstallFolder
nsresult Init(const nsString& aFolderID, const nsString& aRelativePath);
nsresult Init(nsIFile* rawIFile);
void GetDirectoryPath(nsString& aDirectoryPath);
void GetDirectoryPath(nsCString& aDirectoryPath);
nsIFile* GetFileSpec();
PRInt32 ToString(nsAutoString* outString);
@ -54,7 +54,7 @@ class nsInstallFolder
nsCOMPtr<nsIFile> mFileSpec;
void SetDirectoryPath(const nsString& aFolderID, const nsString& aRelativePath);
void PickDefaultDirectory();
void AppendXPPath(const nsString& aRelativePath);
PRInt32 MapNameToEnum(const nsString& name);
};

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

@ -1868,6 +1868,7 @@ static JSConstDoubleSpec install_constants[] =
{ nsInstall::UNABLE_TO_LOCATE_LIB_FUNCTION, "UNABLE_TO_LOCATE_LIB_FUNCTION"},
{ nsInstall::UNABLE_TO_LOAD_LIBRARY, "UNABLE_TO_LOAD_LIBRARY" },
{ nsInstall::CHROME_REGISTRY_ERROR, "CHROME_REGISTRY_ERROR" },
{ nsInstall::MALFORMED_INSTALL, "MALFORMED_INSTALL" },
{ nsInstall::GESTALT_UNKNOWN_ERR, "GESTALT_UNKNOWN_ERR" },
{ nsInstall::GESTALT_INVALID_ARGUMENT, "GESTALT_INVALID_ARGUMENT" },

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

@ -107,7 +107,7 @@ PRInt32 nsRegisterItem::Complete()
if ( reg && !(mChromeType & CHROME_DELAYED) )
{
if (mChromeType & CHROME_SKIN)
rv = reg->InstallSkin(mURL.GetBuffer(), isProfile, PR_FALSE);
rv = reg->InstallSkin(mURL.GetBuffer(), isProfile, PR_TRUE);
if (mChromeType & CHROME_LOCALE)
rv = reg->InstallLocale(mURL.GetBuffer(), isProfile);
@ -117,9 +117,11 @@ PRInt32 nsRegisterItem::Complete()
}
else
{
// Couldn't get the chrome registry (probably during the wizard),
// so we need to save this info into the magic startup file
result = nsInstall::REBOOT_NEEDED;
// Unless the script explicitly told us to register later
// return the REBOOT_NEEDED status. If the script requested
// it then we assume it knows what it's doing.
if (!(mChromeType & CHROME_DELAYED))
result = nsInstall::REBOOT_NEEDED;
// First find the "bin" diretory of the install
PRFileDesc* fd = nsnull;
@ -173,6 +175,9 @@ PRInt32 nsRegisterItem::Complete()
{
PRInt32 written, actual;
char* installStr = nsnull;
// this looks redundant, but a single registerChrome()
// call can register all three types.
if (mChromeType & CHROME_SKIN)
{
installStr = PR_smprintf("skin,%s,path,%s\n",
@ -249,6 +254,7 @@ char* nsRegisterItem::toString()
if (buffer == nsnull || !mInstall)
return nsnull;
buffer[0] = '\0';
switch (mChromeType & CHROME_ALL)
{
case CHROME_SKIN:
@ -271,7 +277,17 @@ char* nsRegisterItem::toString()
if (rsrcVal)
{
PR_snprintf(buffer, 1024, rsrcVal, mURL.GetBuffer());
if (mInstall->GetChromeRegistry() && !(mChromeType & CHROME_DELAYED))
PR_snprintf(buffer, 1024, rsrcVal, mURL.GetBuffer());
else
{
nsXPIDLCString path;
nsresult rv = mChrome->GetPath(getter_Copies(path));
if (NS_SUCCEEDED(rv) && path)
{
PR_snprintf(buffer, 1024, rsrcVal, path);
}
}
nsCRT::free(rsrcVal);
}

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

@ -428,7 +428,7 @@ extern "C" void RunInstallOnThread(void *data)
if(!ok)
{
// problem compiling or running script
// problem compiling or running script -- a true SCRIPT_ERROR
if(JS_GetProperty(cx, glob, "_installedFiles", &installedFiles) &&
JSVAL_TO_BOOLEAN(installedFiles))
{
@ -440,21 +440,24 @@ extern "C" void RunInstallOnThread(void *data)
}
else
{
// check to make sure the script sent back a status
// check to make sure the script sent back a status -- if
// not the install may have been syntactically correct but
// left the init/(perform|cancel) transaction open
jsval sent;
if(JS_GetProperty(cx, glob, "_installedFiles", &installedFiles) &&
JSVAL_TO_BOOLEAN(installedFiles))
{
nsInstall *a = (nsInstall*)JS_GetPrivate(cx, glob);
a->InternalAbort(nsInstall::SCRIPT_ERROR);
a->InternalAbort(nsInstall::MALFORMED_INSTALL);
}
if ( JS_GetProperty( cx, glob, "_statusSent", &sent ) &&
JSVAL_TO_BOOLEAN(sent) )
sendStatus = PR_FALSE;
else
finalStatus = nsInstall::SCRIPT_ERROR;
finalStatus = nsInstall::MALFORMED_INSTALL;
}
JS_DestroyContextMaybeGC(cx);