Fix for #168255 - Change references to MRE into GRE in XPCOM/Embedding

r=dougt, sr=alecf


git-svn-id: svn://10.0.0.236/trunk@129568 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
chak%netscape.com
2002-09-13 22:18:43 +00:00
parent bb9e89902c
commit 98ed7836a1
11 changed files with 118 additions and 115 deletions

View File

@@ -149,21 +149,21 @@ winEmbedFileLocProvider::GetFile(const char *prop, PRBool *persistant, nsIFile *
rv = localFile->AppendRelativeNativePath(SEARCH_DIR_NAME);
}
//---------------------------------------------------------------
// Note that by returning a valid localFile's for NS_MRE_DIR and
// NS_NRE_COMPONENT_DIR your app is indicating to XPCOM that
// it found an MRE version with which it's compatible with and
// it intends to be "run against" that MRE
// Note that by returning a valid localFile's for NS_GRE_DIR and
// NS_GRE_COMPONENT_DIR your app is indicating to XPCOM that
// it found an GRE version with which it's compatible with and
// it intends to be "run against" that GRE
//
// Please see http://www.mozilla.org/projects/embedding/MRE.html
// for more info. on MRE
// for more info. on GRE
//---------------------------------------------------------------
else if (nsCRT::strcmp(prop, NS_MRE_DIR) == 0)
else if (nsCRT::strcmp(prop, NS_GRE_DIR) == 0)
{
rv = GetMreDirectory(getter_AddRefs(localFile));
rv = GetGreDirectory(getter_AddRefs(localFile));
}
else if (nsCRT::strcmp(prop, NS_MRE_COMPONENT_DIR) == 0)
else if (nsCRT::strcmp(prop, NS_GRE_COMPONENT_DIR) == 0)
{
rv = GetMreDirectory(getter_AddRefs(localFile));
rv = GetGreDirectory(getter_AddRefs(localFile));
if (NS_SUCCEEDED(rv))
rv = localFile->AppendRelativeNativePath(COMPONENTS_DIR_NAME);
}
@@ -174,73 +174,73 @@ winEmbedFileLocProvider::GetFile(const char *prop, PRBool *persistant, nsIFile *
return rv;
}
// Get the location of the MRE version we're compatible with from
// Get the location of the GRE version we're compatible with from
// the registry
//
static char * GetMreLocationFromRegistry()
static char * GetGreLocationFromRegistry()
{
char szKey[256];
HKEY hRegKey = NULL;
DWORD dwLength = _MAX_PATH * sizeof(char);
long rc;
char keyValue[_MAX_PATH + 1];
char *pMreLocation = NULL;
char *pGreLocation = NULL;
// A couple of key points here:
// 1. Note the usage of the "Software\\Mozilla\\MRE" subkey - this allows
// us to have multiple versions of MREs on the same machine by having
// 1. Note the usage of the "Software\\Mozilla\\GRE" subkey - this allows
// us to have multiple versions of GREs on the same machine by having
// subkeys such as 1.0, 1.1, 2.0 etc. under it.
// 2. In this sample below we're looking for the location of MRE version 1.0
// i.e. we're compatible with MRE 1.0 and we're trying to find it's install
// 2. In this sample below we're looking for the location of GRE version 1.2
// i.e. we're compatible with GRE 1.2 and we're trying to find it's install
// location.
//
// Please see http://www.mozilla.org/projects/embedding/MRE.html for
// more info.
//
strcpy(szKey, "Software\\Mozilla\\MRE\\1.0");
strcpy(szKey, "Software\\Mozilla\\GRE\\1.2b");
if (::RegOpenKeyEx(HKEY_LOCAL_MACHINE, szKey, 0, KEY_QUERY_VALUE, &hRegKey) == ERROR_SUCCESS)
{
if ((rc = ::RegQueryValueEx(hRegKey, "MreHome", NULL, NULL, (BYTE *)keyValue, &dwLength))==ERROR_SUCCESS)
if ((rc = ::RegQueryValueEx(hRegKey, "GreHome", NULL, NULL, (BYTE *)keyValue, &dwLength))==ERROR_SUCCESS)
{
pMreLocation = ::strdup(keyValue);
pGreLocation = ::strdup(keyValue);
::RegCloseKey(hRegKey);
}
}
return pMreLocation;
return pGreLocation;
}
// Create and return the location of the MRE the application is
// Create and return the location of the GRE the application is
// currently using, if any, via the |aLocalFile| param
//
// If an embedding application is written to use an MRE it determines
// the compatible MRE's location by looking in the Windows registry
// In this case GetMreDirectory() creates a new localFile based on the
// MRE path it just read from the registry
// If an embedding application is written to use an GRE it determines
// the compatible GRE's location by looking in the Windows registry
// In this case GetGreDirectory() creates a new localFile based on the
// GRE path it just read from the registry
//
// If the embedding appliction is not using an MRE and is running in
// a "regular" embedding scenario GetMreDirectory() simply returns a
// failure code indicating to the caller to fallback to a non-MRE
// If the embedding appliction is not using an GRE and is running in
// a "regular" embedding scenario GetGreDirectory() simply returns a
// failure code indicating to the caller to fallback to a non-GRE
// based operation - which is the default mode of operation.
//
// Please see http://www.mozilla.org/projects/embedding/MRE.html for
// more information on the Mozilla Runtime Environment(MRE) and for
// the actual registry key whichs contains the MRE path, if any.
// more information on the Mozilla Runtime Environment(GRE) and for
// the actual registry key whichs contains the GRE path, if any.
NS_METHOD winEmbedFileLocProvider::GetMreDirectory(nsILocalFile **aLocalFile)
NS_METHOD winEmbedFileLocProvider::GetGreDirectory(nsILocalFile **aLocalFile)
{
NS_ENSURE_ARG_POINTER(aLocalFile);
nsresult rv = NS_ERROR_FAILURE;
// Get the path of the MRE which is compatible with our embedding application
// Get the path of the GRE which is compatible with our embedding application
// from the registry
//
char *pMreDir = GetMreLocationFromRegistry();
if(pMreDir)
char *pGreDir = GetMreLocationFromRegistry();
if(pGreDir)
{
nsCOMPtr<nsILocalFile> tempLocal;
rv = NS_NewNativeLocalFile(nsDependentCString(pMreDir), TRUE, getter_AddRefs(tempLocal));
rv = NS_NewNativeLocalFile(nsDependentCString(pGreDir), TRUE, getter_AddRefs(tempLocal));
if (tempLocal)
{
@@ -249,7 +249,7 @@ NS_METHOD winEmbedFileLocProvider::GetMreDirectory(nsILocalFile **aLocalFile)
rv = NS_OK;
}
::free(pMreDir);
::free(pGreDir);
}
return rv;