105087 r=dveditz, sr=mscott, a=asa

hook up the installer and the directory service
This commit is contained in:
dprice%netscape.com 2002-04-02 23:56:43 +00:00
Родитель 4bb72906a4
Коммит 090982c461
8 изменённых файлов: 106 добавлений и 77 удалений

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

@ -106,4 +106,5 @@
#define NS_APP_NEWS_50_DIR "NewsD"
#define NS_APP_MESSENGER_FOLDER_CACHE_50_DIR "MFCaD"
#define NS_APP_INSTALL_CLEANUP_DIR "XPIClnupD" //location of xpicleanup.dat xpicleanup.exe
#endif

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

@ -61,6 +61,7 @@
#if defined(XP_MAC) /* || defined(XP_MACOSX) REMIND HACKING FOR MACOS X!!! */
#define APP_REGISTRY_NAME "Application Registry"
#define ESSENTIAL_FILES "Essential Files"
#elif defined(XP_WIN) || defined(XP_OS2)
#define APP_REGISTRY_NAME "registry.dat"
#else
@ -204,7 +205,17 @@ nsAppFileLocationProvider::GetFile(const char *prop, PRBool *persistant, nsIFile
if (NS_SUCCEEDED(rv))
rv = localFile->AppendRelativePath(SEARCH_DIR_NAME);
}
else if (nsCRT::strcmp(prop, NS_APP_INSTALL_CLEANUP_DIR) == 0)
{
// This is cloned so that embeddors will have a hook to override
// with their own cleanup dir. See bugzilla bug #105087
rv = CloneMozBinDirectory(getter_AddRefs(localFile));
#ifdef XP_MAC
if (NS_SUCCEEDED(rv))
rv = localFile->Append(ESSENTIAL_FILES);
#endif
}
if (localFile && NS_SUCCEEDED(rv))
return localFile->QueryInterface(NS_GET_IID(nsIFile), (void**)_retval);

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

@ -1137,15 +1137,12 @@ static nsresult VerifyInstallation(int argc, char **argv)
do_GetService(NS_DIRECTORY_SERVICE_CONTRACTID, &rv);
if (NS_FAILED(rv))
return NS_OK;
rv = directoryService->Get(NS_OS_CURRENT_PROCESS_DIR,
rv = directoryService->Get(NS_APP_INSTALL_CLEANUP_DIR,
NS_GET_IID(nsIFile),
getter_AddRefs(registryFile));
if (NS_FAILED(rv) || !registryFile)
return NS_OK;
return NS_ERROR_FAILURE;
#ifdef XP_MAC
registryFile->Append(ESSENTIAL_FILES);
#endif
registryFile->Append(CLEANUP_REGISTRY);
PRBool exists;

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

@ -35,6 +35,7 @@
#include "nsSpecialSystemDirectory.h"
#include "nsDirectoryService.h"
#include "nsDirectoryServiceDefs.h"
#include "nsAppDirectoryServiceDefs.h"
static nsresult
GetPersistentStringFromSpec(nsIFile* inSpec, char **string)
@ -135,15 +136,28 @@ char* GetRegFilePath()
if (NS_FAILED(rv))
return nsnull;
directoryService->Get(NS_OS_CURRENT_PROCESS_DIR,
NS_GET_IID(nsIFile),
getter_AddRefs(iFileUtilityPath));
if (!iFileUtilityPath)
return nsnull;
if (nsSoftwareUpdate::GetProgramDirectory()) // In the stub installer
{
nsCOMPtr<nsIFile> tmp;
rv = nsSoftwareUpdate::GetProgramDirectory()->Clone(getter_AddRefs(tmp));
if (NS_FAILED(rv) || !tmp)
return nsnull;
#if defined (XP_MAC)
iFileUtilityPath->Append(ESSENTIAL_FILES);
tmp->Append(ESSENTIAL_FILES);
#endif
iFileUtilityPath = do_QueryInterface(tmp);
}
else
{
rv = directoryService->Get(NS_APP_INSTALL_CLEANUP_DIR,
NS_GET_IID(nsIFile),
getter_AddRefs(iFileUtilityPath));
}
if (NS_FAILED(rv) || !iFileUtilityPath)
return nsnull;
iFileUtilityPath->Append(CLEANUP_REGISTRY);
//Yes, we know using GetPath is buggy on the Mac.

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

@ -175,12 +175,7 @@ nsInstallFolder::SetDirectoryPath(const nsString& aFolderID, const nsString& aRe
do_GetService(NS_DIRECTORY_SERVICE_CONTRACTID, &rv);
if (!directoryService) return;
directoryService->Get(NS_OS_CURRENT_PROCESS_DIR, NS_GET_IID(nsIFile), getter_AddRefs(mFileSpec));
#ifdef XP_MAC
mFileSpec->Append("Plug-ins");
#else
mFileSpec->Append("plugins");
#endif
directoryService->Get(NS_APP_PLUGINS_DIR, NS_GET_IID(nsIFile), getter_AddRefs(mFileSpec));
}
else
{
@ -188,11 +183,7 @@ nsInstallFolder::SetDirectoryPath(const nsString& aFolderID, const nsString& aRe
if (NS_SUCCEEDED(rv))
{
#ifdef XP_MAC
mFileSpec->Append("Plug-ins");
#else
mFileSpec->Append("plugins");
#endif
mFileSpec->Append(INSTALL_PLUGINS_DIR);
}
else
mFileSpec = nsnull;
@ -285,18 +276,9 @@ nsInstallFolder::SetDirectoryPath(const nsString& aFolderID, const nsString& aRe
nsCOMPtr<nsIProperties> directoryService =
do_GetService(NS_DIRECTORY_SERVICE_CONTRACTID, &rv);
if (!directoryService) return;
directoryService->Get(NS_OS_CURRENT_PROCESS_DIR,
directoryService->Get(NS_XPCOM_COMPONENT_DIR,
NS_GET_IID(nsIFile),
getter_AddRefs(mFileSpec));
if (NS_SUCCEEDED(rv))
{
#ifdef XP_MAC
mFileSpec->Append("Components");
#else
mFileSpec->Append("components");
#endif
}
}
else
{
@ -304,11 +286,7 @@ nsInstallFolder::SetDirectoryPath(const nsString& aFolderID, const nsString& aRe
if (NS_SUCCEEDED(rv))
{
#ifdef XP_MAC
mFileSpec->Append("Components");
#else
mFileSpec->Append("components");
#endif
mFileSpec->Append(INSTALL_COMPONENTS_DIR);
}
else
mFileSpec = nsnull;
@ -321,19 +299,9 @@ nsInstallFolder::SetDirectoryPath(const nsString& aFolderID, const nsString& aRe
nsCOMPtr<nsIProperties> directoryService =
do_GetService(NS_DIRECTORY_SERVICE_CONTRACTID, &rv);
if (!directoryService) return;
directoryService->Get(NS_OS_CURRENT_PROCESS_DIR,
directoryService->Get(NS_APP_CHROME_DIR,
NS_GET_IID(nsIFile),
getter_AddRefs(mFileSpec));
if (NS_SUCCEEDED(rv))
{
#ifdef XP_MAC
mFileSpec->Append("Chrome");
#else
mFileSpec->Append("chrome");
#endif
}
}
else
{
@ -341,11 +309,7 @@ nsInstallFolder::SetDirectoryPath(const nsString& aFolderID, const nsString& aRe
if (NS_SUCCEEDED(rv))
{
#ifdef XP_MAC
mFileSpec->Append("Chrome");
#else
mFileSpec->Append("chrome");
#endif
mFileSpec->Append(INSTALL_CHROME_DIR);
}
}
break;

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

@ -34,6 +34,16 @@
#include "nsFileSpec.h"
#include "nsSpecialSystemDirectory.h"
#ifdef XP_MAC
#define INSTALL_PLUGINS_DIR "Plug-ins"
#define INSTALL_COMPONENTS_DIR "Components"
#define INSTALL_CHROME_DIR "Chrome"
#else
#define INSTALL_PLUGINS_DIR "plugins"
#define INSTALL_COMPONENTS_DIR "components"
#define INSTALL_CHROME_DIR "chrome"
#endif
class nsInstallFolder
{
public:

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

@ -33,6 +33,7 @@
#include "nsIChromeRegistry.h"
#include "nsIDirectoryService.h"
#include "nsDirectoryServiceDefs.h"
#include "nsAppDirectoryServiceDefs.h"
MOZ_DECL_CTOR_COUNTER(nsRegisterItem)
@ -259,36 +260,52 @@ PRInt32 nsRegisterItem::Complete()
{
// Either script asked for delayed chrome or we can't find
// the chrome registry to do it now.
NS_ASSERTION(mProgDir, "this.Prepare() failed to set mProgDir");
// construct a reference to the magic file
PRFileDesc* fd = nsnull;
nsCOMPtr<nsIFile> tmp;
PRBool bExists = PR_FALSE;
rv = mProgDir->Clone(getter_AddRefs(tmp));
if (NS_SUCCEEDED(rv))
if (!nsSoftwareUpdate::GetProgramDirectory()) // not in the stub installer
{
nsCOMPtr<nsIProperties> directoryService =
do_GetService(NS_DIRECTORY_SERVICE_CONTRACTID, &rv);
if (NS_SUCCEEDED(rv) && directoryService)
{
rv = directoryService->Get(NS_APP_CHROME_DIR,
NS_GET_IID(nsIFile),
getter_AddRefs(tmp));
if(NS_FAILED(rv))
{
result = nsInstall::CHROME_REGISTRY_ERROR;
return result;
}
}
}
else
{
nsCOMPtr<nsILocalFile> startupFile( do_QueryInterface(tmp, &rv) );
rv = nsSoftwareUpdate::GetProgramDirectory()->Clone(getter_AddRefs(tmp));
if (NS_SUCCEEDED(rv))
{
rv = startupFile->Append("chrome");
tmp->Append(INSTALL_CHROME_DIR);
}
}
nsCOMPtr<nsILocalFile> startupFile( do_QueryInterface(tmp, &rv) );
if (NS_SUCCEEDED(rv))
{
rv = startupFile->Exists(&bExists);
if (NS_SUCCEEDED(rv) && !bExists)
rv = startupFile->Create(nsIFile::DIRECTORY_TYPE, 0755);
if (NS_SUCCEEDED(rv))
{
rv = startupFile->Append("installed-chrome.txt");
if (NS_SUCCEEDED(rv))
{
rv = startupFile->Exists(&bExists);
if (NS_SUCCEEDED(rv) && !bExists)
rv = startupFile->Create(nsIFile::DIRECTORY_TYPE, 0755);
if (NS_SUCCEEDED(rv))
{
rv = startupFile->Append("installed-chrome.txt");
if (NS_SUCCEEDED(rv))
{
rv = startupFile->OpenNSPRFileDesc(
PR_CREATE_FILE | PR_WRONLY,
0744,
&fd);
}
}
rv = startupFile->OpenNSPRFileDesc(
PR_CREATE_FILE | PR_WRONLY,
0744,
&fd);
}
}
}

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

@ -41,6 +41,7 @@
#include "VerReg.h"
#include "nsIDirectoryService.h"
#include "nsDirectoryServiceDefs.h"
#include "nsAppDirectoryServiceDefs.h"
#include "nsInstall.h"
#include "nsSoftwareUpdateIIDs.h"
@ -199,12 +200,26 @@ nsSoftwareUpdate::Shutdown()
//Get the program directory
nsCOMPtr<nsIProperties> directoryService =
do_GetService(NS_DIRECTORY_SERVICE_CONTRACTID, &rv);
directoryService->Get(NS_OS_CURRENT_PROCESS_DIR,
NS_GET_IID(nsIFile),
getter_AddRefs(pathToCleanupUtility));
if (nsSoftwareUpdate::GetProgramDirectory()) // In the stub installer
{
nsCOMPtr<nsIFile> tmp;
rv = nsSoftwareUpdate::GetProgramDirectory()->Clone(getter_AddRefs(tmp));
#if defined (XP_MAC)
pathToCleanupUtility->Append(ESSENTIAL_FILES);
tmp->Append(ESSENTIAL_FILES);
#endif
pathToCleanupUtility = do_QueryInterface(tmp);
}
else
{
rv = directoryService->Get(NS_APP_INSTALL_CLEANUP_DIR,
NS_GET_IID(nsIFile),
getter_AddRefs(pathToCleanupUtility));
}
NS_ASSERTION(pathToCleanupUtility,"No path to cleanup utility in nsSoftwareUpdate::Shutdown()");
//Create the Process framework
pathToCleanupUtility->Append(CLEANUP_UTIL);
nsCOMPtr<nsIProcess> cleanupProcess = do_CreateInstance(kIProcessCID);