1. Uses appfilelocationprovider. Can pass one in or pass nsnull and default is made.

2. Removed version of NS_InitEmbedding which took char* path.
r=dougt


git-svn-id: svn://10.0.0.236/trunk@75950 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
conrad%ingress.com
2000-08-10 03:07:25 +00:00
parent a08d1fb996
commit dd41a9d6cc
2 changed files with 37 additions and 23 deletions

View File

@@ -28,6 +28,9 @@
#include "nsIStringBundle.h"
#include "nsIDirectoryService.h"
#include "nsAppFileLocationProvider.h"
#include "nsEmbedAPI.h"
static nsIServiceManager *sServiceManager = nsnull;
@@ -66,24 +69,11 @@ static XPCOMCleanupHack sXPCOMCleanupHack;
extern "C" void NS_SetupRegistry();
nsresult NS_InitEmbedding(const char *aPath)
nsresult NS_InitEmbedding(nsILocalFile *mozBinDirectory,
nsIDirectoryServiceProvider *appFileLocProvider)
{
// Create an object to represent the path
nsILocalFile *localFile = nsnull;
if (aPath && strlen(aPath) > 0)
{
NS_NewLocalFile(aPath, PR_FALSE, &localFile);
}
nsresult rv;
nsresult rv = NS_InitEmbedding(localFile);
NS_IF_RELEASE(localFile);
return rv;
}
nsresult NS_InitEmbedding(nsILocalFile *aPath)
{
// Reentrant calls to this method do nothing except increment a counter
sInitCounter++;
if (sInitCounter > 1)
@@ -96,19 +86,32 @@ nsresult NS_InitEmbedding(nsILocalFile *aPath)
#endif
{
// Initialise XPCOM
NS_InitXPCOM(&sServiceManager, aPath);
NS_InitXPCOM(&sServiceManager, mozBinDirectory);
if (!sServiceManager)
return NS_ERROR_NULL_POINTER;
// Hook up the file location provider - make one if nsnull was passed
if (!appFileLocProvider)
{
appFileLocProvider = new nsAppFileLocationProvider;
if (!appFileLocProvider)
return NS_ERROR_OUT_OF_MEMORY;
NS_ADDREF(appFileLocProvider);
}
NS_WITH_SERVICE(nsIDirectoryService, directoryService, NS_DIRECTORY_SERVICE_PROGID, &rv);
if (NS_FAILED(rv))
return rv;
rv = directoryService->RegisterProvider(appFileLocProvider);
if (rv != TRUE) // This is needed but WRONG. RegisterProvider returns TRUE is suceeded, should return NS_OK
return NS_ERROR_FAILURE;
NS_RELEASE(appFileLocProvider); // RegisterProvider did AddRef - It owns it now
#ifdef HACK_AROUND_NONREENTRANT_INITXPCOM
sXPCOMInitializedFlag = PR_TRUE;
sXPCOMCleanupHack.mCleanOnExit = PR_TRUE;
#endif
}
nsresult rv;
// Register components
if (!sRegistryInitializedFlag)
{