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; nsInstallObject* ie;
if (mInstalledFiles != nsnull) if (mInstalledFiles != nsnull)
{ {
//PRUint32 i;
//mInstalledFiles->Count(&i);
for (PRInt32 i = mInstalledFiles->Count(); i >= 0; i--) for (PRInt32 i = mInstalledFiles->Count(); i >= 0; i--)
{ {
ie = (nsInstallObject *)mInstalledFiles->ElementAt(i); ie = (nsInstallObject *)mInstalledFiles->ElementAt(i);
@ -788,10 +786,6 @@ nsInstall::FinalizeInstall(PRInt32* aReturn)
} }
if ( mInstalledFiles != NULL)
{
//PRUint32 i = 0;
//mInstalledFiles->Count(&i);
if ( mInstalledFiles->Count() > 0 ) if ( mInstalledFiles->Count() > 0 )
{ {
if ( mUninstallPackage ) if ( mUninstallPackage )
@ -804,7 +798,7 @@ nsInstall::FinalizeInstall(PRInt32* aReturn)
if (mVersionInfo) if (mVersionInfo)
{ {
nsString versionString; nsString versionString;
nsString path; nsCString path;
mVersionInfo->ToString(versionString); mVersionInfo->ToString(versionString);
@ -812,15 +806,13 @@ nsInstall::FinalizeInstall(PRInt32* aReturn)
mPackageFolder->GetDirectoryPath(path); mPackageFolder->GetDirectoryPath(path);
VR_Install( (char*)(const char*)nsAutoCString(mRegistryPackageName), VR_Install( (char*)(const char*)nsAutoCString(mRegistryPackageName),
(char*)(const char*)nsAutoCString(path), (char*)path.GetBuffer(),
(char*)(const char*)nsAutoCString(versionString), (char*)(const char*)nsAutoCString(versionString),
PR_FALSE ); PR_FALSE );
} }
nsInstallObject* ie = nsnull; nsInstallObject* ie = nsnull;
//PRUint32 numberOfFiles = 0;
//mInstalledFiles->Count(&numberOfFiles);
for (PRInt32 i=0; i < mInstalledFiles->Count(); i++) for (PRInt32 i=0; i < mInstalledFiles->Count(); i++)
{ {
ie = (nsInstallObject*)mInstalledFiles->ElementAt(i); ie = (nsInstallObject*)mInstalledFiles->ElementAt(i);
@ -884,7 +876,6 @@ nsInstall::FinalizeInstall(PRInt32* aReturn)
mStatusSent = PR_TRUE; mStatusSent = PR_TRUE;
} }
} }
}
else else
{ {
// no actions queued: don't register the package version // no actions queued: don't register the package version
@ -1493,7 +1484,6 @@ nsInstall::StartInstall(const nsString& aUserPackageName, const nsString& aRegis
mVersionInfo->Init(aVersion); mVersionInfo->Init(aVersion);
mInstalledFiles = new nsVoidArray(); mInstalledFiles = new nsVoidArray();
//nsresult rv = NS_NewISupportsArray(getter_AddRefs(mInstalledFiles));
if (mInstalledFiles == nsnull) if (mInstalledFiles == nsnull)
{ {
@ -2351,8 +2341,6 @@ nsInstall::CleanUp(void)
if ( mInstalledFiles != nsnull ) if ( mInstalledFiles != nsnull )
{ {
//PRUint32 numberOfObjects = 0;
//mInstalledFiles->Count(&numberOfObjects);
for (PRInt32 i=0; i < mInstalledFiles->Count(); i++) for (PRInt32 i=0; i < mInstalledFiles->Count(); i++)
{ {
ie = (nsInstallObject*)mInstalledFiles->ElementAt(i); ie = (nsInstallObject*)mInstalledFiles->ElementAt(i);

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

@ -160,6 +160,8 @@ class nsInstall
CHROME_REGISTRY_ERROR = -239, CHROME_REGISTRY_ERROR = -239,
MALFORMED_INSTALL = -240,
OUT_OF_MEMORY = -299, OUT_OF_MEMORY = -299,
GESTALT_UNKNOWN_ERR = -5550, GESTALT_UNKNOWN_ERR = -5550,

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

@ -31,6 +31,7 @@
#include "nsRepository.h" #include "nsRepository.h"
#include "nsString.h" #include "nsString.h"
#include "nsXPIDLString.h"
#include "nsFileSpec.h" #include "nsFileSpec.h"
#include "nsIFileSpec.h" #include "nsIFileSpec.h"
#include "nsIFile.h" #include "nsIFile.h"
@ -102,50 +103,10 @@ nsInstallFolder::Init(nsIFile* rawIFile)
nsresult nsresult
nsInstallFolder::Init(const nsString& aFolderID, const nsString& aRelativePath) nsInstallFolder::Init(const nsString& aFolderID, const nsString& aRelativePath)
{ {
PRBool flagIsDir, flagExists;
mFileSpec = nsnull; 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 ); 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) if (mFileSpec)
return NS_OK; return NS_OK;
@ -164,10 +125,7 @@ nsInstallFolder::Init(nsInstallFolder& inFolder, const nsString& subString)
return NS_ERROR_FAILURE; return NS_ERROR_FAILURE;
if(!subString.IsEmpty()) if(!subString.IsEmpty())
{ AppendXPPath(subString);
nsAutoCString tempSubString(subString);
mFileSpec->Append(tempSubString);
}
return NS_OK; return NS_OK;
} }
@ -179,24 +137,24 @@ nsInstallFolder::~nsInstallFolder()
} }
void void
nsInstallFolder::GetDirectoryPath(nsString& aDirectoryPath) nsInstallFolder::GetDirectoryPath(nsCString& aDirectoryPath)
{ {
PRBool flagIsDir; PRBool flagIsDir;
char* thePath; nsXPIDLCString thePath;
aDirectoryPath.SetLength(0); aDirectoryPath.SetLength(0);
if (mFileSpec != nsnull) if (mFileSpec != nsnull)
{ {
// We want the a NATIVE path. // We want the NATIVE path.
mFileSpec->GetPath(&thePath); mFileSpec->GetPath(getter_Copies(thePath));
aDirectoryPath.AssignWithConversion(thePath); aDirectoryPath.Assign(thePath);
mFileSpec->IsDirectory(&flagIsDir); mFileSpec->IsDirectory(&flagIsDir);
if (flagIsDir) if (flagIsDir)
{ {
if (aDirectoryPath.Last() != FILESEP) if (aDirectoryPath.Last() != FILESEP)
aDirectoryPath.AppendWithConversion(FILESEP); aDirectoryPath.Append(FILESEP);
} }
} }
} }
@ -548,19 +506,48 @@ nsInstallFolder::SetDirectoryPath(const nsString& aFolderID, const nsString& aRe
case -1: case -1:
default: default:
mFileSpec = nsnull; mFileSpec = nsnull;
return; break;
} }
if (aRelativePath.Length() > 0 && mFileSpec) if (aRelativePath.Length() > 0 && mFileSpec)
{ {
//nsString tempPath(aRelativePath); AppendXPPath(aRelativePath);
}
}
}
//if (aRelativePath.Last() != '/' || aRelativePath.Last() != '\\')
// tempPath.AppendWithConversion('/'); void
nsAutoCString tempRelPath(aRelativePath); nsInstallFolder::AppendXPPath(const nsString& aRelativePath)
mFileSpec->Append(tempRelPath); {
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 );
} }
@ -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 //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. // 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; if (!mFileSpec || !outString)
PRBool flagIsFile;
if (!mFileSpec)
return NS_ERROR_NULL_POINTER; 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); mFileSpec->IsFile(&flagIsFile);
if (!flagIsFile) if (!flagIsFile)
{ {
nsString tempString; // assume directory, thus end with slash.
tempString.AssignWithConversion(temp); outString->AppendWithConversion(FILESEP);
tempString.AppendWithConversion(FILESEP);
nsAutoCString tempAutoString(tempString);
outString->AssignWithConversion(tempAutoString);
} }
else
outString->AssignWithConversion(temp);
return rv; return rv;
} }

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

@ -45,7 +45,7 @@ class nsInstallFolder
nsresult Init(const nsString& aFolderID, const nsString& aRelativePath); nsresult Init(const nsString& aFolderID, const nsString& aRelativePath);
nsresult Init(nsIFile* rawIFile); nsresult Init(nsIFile* rawIFile);
void GetDirectoryPath(nsString& aDirectoryPath); void GetDirectoryPath(nsCString& aDirectoryPath);
nsIFile* GetFileSpec(); nsIFile* GetFileSpec();
PRInt32 ToString(nsAutoString* outString); PRInt32 ToString(nsAutoString* outString);
@ -54,7 +54,7 @@ class nsInstallFolder
nsCOMPtr<nsIFile> mFileSpec; nsCOMPtr<nsIFile> mFileSpec;
void SetDirectoryPath(const nsString& aFolderID, const nsString& aRelativePath); void SetDirectoryPath(const nsString& aFolderID, const nsString& aRelativePath);
void PickDefaultDirectory(); void AppendXPPath(const nsString& aRelativePath);
PRInt32 MapNameToEnum(const nsString& name); 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_LOCATE_LIB_FUNCTION, "UNABLE_TO_LOCATE_LIB_FUNCTION"},
{ nsInstall::UNABLE_TO_LOAD_LIBRARY, "UNABLE_TO_LOAD_LIBRARY" }, { nsInstall::UNABLE_TO_LOAD_LIBRARY, "UNABLE_TO_LOAD_LIBRARY" },
{ nsInstall::CHROME_REGISTRY_ERROR, "CHROME_REGISTRY_ERROR" }, { nsInstall::CHROME_REGISTRY_ERROR, "CHROME_REGISTRY_ERROR" },
{ nsInstall::MALFORMED_INSTALL, "MALFORMED_INSTALL" },
{ nsInstall::GESTALT_UNKNOWN_ERR, "GESTALT_UNKNOWN_ERR" }, { nsInstall::GESTALT_UNKNOWN_ERR, "GESTALT_UNKNOWN_ERR" },
{ nsInstall::GESTALT_INVALID_ARGUMENT, "GESTALT_INVALID_ARGUMENT" }, { nsInstall::GESTALT_INVALID_ARGUMENT, "GESTALT_INVALID_ARGUMENT" },

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

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

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

@ -428,7 +428,7 @@ extern "C" void RunInstallOnThread(void *data)
if(!ok) if(!ok)
{ {
// problem compiling or running script // problem compiling or running script -- a true SCRIPT_ERROR
if(JS_GetProperty(cx, glob, "_installedFiles", &installedFiles) && if(JS_GetProperty(cx, glob, "_installedFiles", &installedFiles) &&
JSVAL_TO_BOOLEAN(installedFiles)) JSVAL_TO_BOOLEAN(installedFiles))
{ {
@ -440,21 +440,24 @@ extern "C" void RunInstallOnThread(void *data)
} }
else 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; jsval sent;
if(JS_GetProperty(cx, glob, "_installedFiles", &installedFiles) && if(JS_GetProperty(cx, glob, "_installedFiles", &installedFiles) &&
JSVAL_TO_BOOLEAN(installedFiles)) JSVAL_TO_BOOLEAN(installedFiles))
{ {
nsInstall *a = (nsInstall*)JS_GetPrivate(cx, glob); nsInstall *a = (nsInstall*)JS_GetPrivate(cx, glob);
a->InternalAbort(nsInstall::SCRIPT_ERROR); a->InternalAbort(nsInstall::MALFORMED_INSTALL);
} }
if ( JS_GetProperty( cx, glob, "_statusSent", &sent ) && if ( JS_GetProperty( cx, glob, "_statusSent", &sent ) &&
JSVAL_TO_BOOLEAN(sent) ) JSVAL_TO_BOOLEAN(sent) )
sendStatus = PR_FALSE; sendStatus = PR_FALSE;
else else
finalStatus = nsInstall::SCRIPT_ERROR; finalStatus = nsInstall::MALFORMED_INSTALL;
} }
JS_DestroyContextMaybeGC(cx); JS_DestroyContextMaybeGC(cx);