Adding generic support for the GRE in the xpcom glue. r=chak, sr=darin, b=185681
git-svn-id: svn://10.0.0.236/trunk@135798 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
@@ -107,6 +107,47 @@ NS_GetFrozenFunctions(XPCOMFunctions *entryPoints, const char* libraryPath);
|
||||
// think hard before changing this
|
||||
#define XPCOM_GLUE_VERSION 1
|
||||
|
||||
|
||||
/* XPCOM Specific Defines
|
||||
*
|
||||
* XPCOM_DLL - name of the loadable xpcom library on disk.
|
||||
* XPCOM_SEARCH_KEY - name of the environment variable that can be
|
||||
* modified to include additional search paths.
|
||||
* GRE_CONF_NAME - Name of the GRE Configuration file
|
||||
*/
|
||||
|
||||
#ifdef XP_PC
|
||||
|
||||
#define XPCOM_DLL "xpcom.dll"
|
||||
#define XPCOM_SEARCH_KEY "PATH"
|
||||
#define GRE_CONF_NAME "gre.config"
|
||||
#define GRE_WIN_REG_LOC "Software\\mozilla.org\\GRE\\"
|
||||
#elif XP_UNIX
|
||||
|
||||
// you have to love apple..
|
||||
#ifdef XP_MACOSX
|
||||
#define XPCOM_DLL "libxpcom.bundle"
|
||||
#else
|
||||
#define XPCOM_DLL "libxpcom"MOZ_DLL_SUFFIX
|
||||
#endif
|
||||
|
||||
#define XPCOM_SEARCH_KEY "LD_LIBRARY_PATH"
|
||||
#define GRE_CONF_NAME ".gre.config"
|
||||
#define GRE_CONF_PATH "/etc/gre.conf"
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
#if defined(XP_MAC)
|
||||
#define XPCOM_FILE_PATH_SEPARATOR ":"
|
||||
#elif defined(XP_WIN) || defined(XP_OS2)
|
||||
#define XPCOM_FILE_PATH_SEPARATOR "\\"
|
||||
#elif defined(XP_UNIX) || defined(XP_BEOS)
|
||||
#define XPCOM_FILE_PATH_SEPARATOR "/"
|
||||
#else
|
||||
#error need_to_define_your_file_path_separator_and_illegal_characters
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
@@ -110,16 +110,6 @@
|
||||
#endif
|
||||
#include "nsRecyclingAllocator.h"
|
||||
|
||||
// seawood tells me there isn't a better way...
|
||||
#ifdef XP_PC
|
||||
#define XPCOM_DLL "xpcom.dll"
|
||||
#else
|
||||
#ifdef XP_MAC
|
||||
#define XPCOM_DLL "XPCOM_DLL"
|
||||
#else
|
||||
#define XPCOM_DLL "libxpcom"MOZ_DLL_SUFFIX
|
||||
#endif
|
||||
#endif
|
||||
|
||||
// Registry Factory creation function defined in nsRegistry.cpp
|
||||
// We hook into this function locally to create and register the registry
|
||||
|
||||
@@ -40,6 +40,7 @@ LOCAL_INCLUDES = \
|
||||
|
||||
CPPSRCS = \
|
||||
$(XPCOM_GLUE_SRC_LCSRCS) \
|
||||
nsDebug.cpp \
|
||||
$(NULL)
|
||||
|
||||
SDK_HEADERS = \
|
||||
|
||||
@@ -36,7 +36,6 @@
|
||||
|
||||
XPCOM_GLUE_SRC_LCSRCS = \
|
||||
nsCOMPtr.cpp \
|
||||
nsDebug.cpp \
|
||||
nsGenericFactory.cpp \
|
||||
nsIInterfaceRequestorUtils.cpp \
|
||||
nsMemory.cpp \
|
||||
|
||||
@@ -65,13 +65,15 @@ CPPSRCS = \
|
||||
$(STRING_LCSRCS) \
|
||||
nsXPCOMGlue.cpp \
|
||||
nsEmbedString.cpp \
|
||||
nsGREDirServiceProvider.cpp \
|
||||
nsDebugGlue.cpp \
|
||||
$(NULL)
|
||||
|
||||
EXPORTS = \
|
||||
nsXPCOMGlue.h \
|
||||
$(NULL)
|
||||
|
||||
SDK_HEADERS = \
|
||||
nsXPCOMGlue.h \
|
||||
nsEmbedString.h \
|
||||
$(NULL)
|
||||
|
||||
@@ -97,6 +99,8 @@ SRCS_IN_OBJDIR = 1
|
||||
|
||||
include $(topsrcdir)/config/rules.mk
|
||||
|
||||
CXXFLAGS += -DMOZILLA_VERSION=\"$(MOZILLA_VERSION)\"
|
||||
|
||||
export:: $(XPCOM_GLUE_SRC_CSRCS) $(STRING_CSRCS)
|
||||
$(INSTALL) $^ .
|
||||
|
||||
|
||||
87
mozilla/xpcom/glue/standalone/nsDebugGlue.cpp
Normal file
87
mozilla/xpcom/glue/standalone/nsDebugGlue.cpp
Normal file
@@ -0,0 +1,87 @@
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is Mozilla.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Austin Powers.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2002
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#include "nsDebug.h"
|
||||
|
||||
// Empty implementation of nsDebug for XPCOM Glue
|
||||
|
||||
void
|
||||
nsDebug::AbortIfFalse(const char* aStr, const char* aExpr,
|
||||
const char* aFile, PRIntn aLine) {}
|
||||
void
|
||||
nsDebug::WarnIfFalse(const char* aStr, const char* aExpr,
|
||||
const char* aFile, PRIntn aLine) {}
|
||||
|
||||
void
|
||||
nsDebug::SetWarningMessageBoxEnable(PRBool aOnOff) {}
|
||||
|
||||
PRBool
|
||||
nsDebug::GetWarningMessageBoxEnable(void) { return PR_FALSE; }
|
||||
|
||||
|
||||
void
|
||||
nsDebug::Abort(const char* aFile, PRIntn aLine) {}
|
||||
|
||||
void
|
||||
nsDebug::Break(const char* aFile, PRIntn aLine) {}
|
||||
|
||||
void
|
||||
nsDebug::PreCondition(const char* aStr, const char* aExpr,
|
||||
const char* aFile, PRIntn aLine) {}
|
||||
|
||||
void
|
||||
nsDebug::PostCondition(const char* aStr, const char* aExpr,
|
||||
const char* aFile, PRIntn aLine) {}
|
||||
|
||||
void
|
||||
nsDebug::Assertion(const char* aStr, const char* aExpr,
|
||||
const char* aFile, PRIntn aLine) {
|
||||
}
|
||||
|
||||
void
|
||||
nsDebug::NotYetImplemented(const char* aMessage,
|
||||
const char* aFile, PRIntn aLine) {}
|
||||
|
||||
void
|
||||
nsDebug::NotReached(const char* aMessage,
|
||||
const char* aFile, PRIntn aLine) {}
|
||||
|
||||
void
|
||||
nsDebug::Error(const char* aMessage,
|
||||
const char* aFile, PRIntn aLine) {}
|
||||
|
||||
void
|
||||
nsDebug::Warning(const char* aMessage,
|
||||
const char* aFile, PRIntn aLine) {}
|
||||
286
mozilla/xpcom/glue/standalone/nsGREDirServiceProvider.cpp
Normal file
286
mozilla/xpcom/glue/standalone/nsGREDirServiceProvider.cpp
Normal file
@@ -0,0 +1,286 @@
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is Mozilla Communicator.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Netscape Communications Corp.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2003
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Sean Su <ssu@netscape.com>
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#include "nsGREDirServiceProvider.h"
|
||||
|
||||
#include "nsXPCOMPrivate.h"
|
||||
|
||||
#include "nspr.h"
|
||||
#include "prenv.h"
|
||||
|
||||
#ifdef XP_PC
|
||||
#include <windows.h>
|
||||
#include <stdlib.h>
|
||||
#endif
|
||||
|
||||
//*****************************************************************************
|
||||
// greEmbedFileLocProvider::Constructor/Destructor
|
||||
//*****************************************************************************
|
||||
|
||||
nsGREDirServiceProvider::nsGREDirServiceProvider()
|
||||
: mPathEnvString(nsnull)
|
||||
{
|
||||
NS_INIT_ISUPPORTS();
|
||||
AddGRELocationToPath();
|
||||
}
|
||||
|
||||
nsGREDirServiceProvider::~nsGREDirServiceProvider()
|
||||
{
|
||||
if (mPathEnvString)
|
||||
PR_smprintf_free(mPathEnvString);
|
||||
}
|
||||
|
||||
//*****************************************************************************
|
||||
// nsGREDirServiceProvider::nsISupports
|
||||
//*****************************************************************************
|
||||
|
||||
NS_IMPL_ISUPPORTS1(nsGREDirServiceProvider, nsIDirectoryServiceProvider)
|
||||
|
||||
//*****************************************************************************
|
||||
// nsGREDirServiceProvider::nsIDirectoryServiceProvider
|
||||
//*****************************************************************************
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsGREDirServiceProvider::GetFile(const char *prop, PRBool *persistant, nsIFile **_retval)
|
||||
{
|
||||
nsCOMPtr<nsILocalFile> localFile;
|
||||
nsresult rv = NS_ERROR_FAILURE;
|
||||
|
||||
*_retval = nsnull;
|
||||
*persistant = PR_TRUE;
|
||||
|
||||
//---------------------------------------------------------------
|
||||
// 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 a GRE version with which it's compatible with and
|
||||
// intends to be "run against" that GRE.
|
||||
//
|
||||
// Please see http://www.mozilla.org/projects/embedding/MRE.html
|
||||
// for more info on GRE.
|
||||
//---------------------------------------------------------------
|
||||
if(strcmp(prop, NS_GRE_DIR) == 0)
|
||||
{
|
||||
rv = GetGreDirectory(getter_AddRefs(localFile));
|
||||
}
|
||||
else if(strcmp(prop, NS_GRE_COMPONENT_DIR) == 0)
|
||||
{
|
||||
rv = GetGreDirectory(getter_AddRefs(localFile));
|
||||
if(NS_SUCCEEDED(rv))
|
||||
rv = localFile->AppendRelativeNativePath(NS_LITERAL_CSTRING("components"));
|
||||
}
|
||||
|
||||
if(!localFile || NS_FAILED(rv))
|
||||
return rv;
|
||||
|
||||
return localFile->QueryInterface(NS_GET_IID(nsIFile), (void**)_retval);
|
||||
}
|
||||
|
||||
// Get the location of the GRE version we're compatible with from
|
||||
// the registry
|
||||
//
|
||||
char *
|
||||
nsGREDirServiceProvider::GetGREDirectoryPath()
|
||||
{
|
||||
char *pGreLocation = NULL;
|
||||
|
||||
// check in the HOME directory
|
||||
char * path = PR_GetEnv("HOME");
|
||||
if (path) {
|
||||
char* greConfHomePath= (char *)malloc(strlen(path) + sizeof(GRE_CONF_NAME) + sizeof(XPCOM_FILE_PATH_SEPARATOR));
|
||||
|
||||
sprintf(greConfHomePath, "%s" XPCOM_FILE_PATH_SEPARATOR GRE_CONF_NAME, path);
|
||||
|
||||
pGreLocation = GetPathFromConfigFile(greConfHomePath);
|
||||
free(greConfHomePath);
|
||||
if (pGreLocation)
|
||||
return pGreLocation;
|
||||
}
|
||||
|
||||
path = PR_GetEnv("MOZ_GRE_CONF");
|
||||
if (path) {
|
||||
pGreLocation = GetPathFromConfigFile(path);
|
||||
if (pGreLocation)
|
||||
return pGreLocation;
|
||||
}
|
||||
|
||||
#ifdef XP_UNIX
|
||||
pGreLocation = GetPathFromConfigFile(GRE_CONF_PATH);
|
||||
if (pGreLocation)
|
||||
return pGreLocation;
|
||||
#endif
|
||||
|
||||
#if XP_PC
|
||||
char szKey[256];
|
||||
HKEY hRegKey = NULL;
|
||||
DWORD dwLength = _MAX_PATH * sizeof(char);
|
||||
long rc;
|
||||
char keyValue[_MAX_PATH + 1];
|
||||
|
||||
// A couple of key points here:
|
||||
// 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 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, GRE_WIN_REG_LOC MOZILLA_VERSION);
|
||||
|
||||
if (::RegOpenKeyEx(HKEY_LOCAL_MACHINE, szKey, 0, KEY_QUERY_VALUE, &hRegKey) == ERROR_SUCCESS) {
|
||||
if ((rc = ::RegQueryValueEx(hRegKey, "GreHome", NULL, NULL, (BYTE *)keyValue, &dwLength))==ERROR_SUCCESS) {
|
||||
pGreLocation = strdup(keyValue);
|
||||
}
|
||||
::RegCloseKey(hRegKey);
|
||||
}
|
||||
if (pGreLocation)
|
||||
return pGreLocation;
|
||||
#endif
|
||||
return pGreLocation;
|
||||
}
|
||||
|
||||
char*
|
||||
nsGREDirServiceProvider::GetPathFromConfigFile(const char* filename)
|
||||
{
|
||||
char* pGreLocation = nsnull;
|
||||
char buffer[1024];
|
||||
FILE *cfg;
|
||||
PRBool foundHeader = PR_FALSE;
|
||||
PRInt32 versionLen = sizeof(MOZILLA_VERSION)-1;
|
||||
|
||||
if((cfg=fopen(filename,"r"))==nsnull) {
|
||||
return nsnull;
|
||||
}
|
||||
|
||||
while (fgets(buffer, 1024, cfg) != nsnull) {
|
||||
// skip over comment lines and blank lines
|
||||
if (buffer[0] == '#' || buffer[0] == '\n') {
|
||||
continue;
|
||||
}
|
||||
|
||||
// we found a section heading, check to see if it is the one we are intersted in.
|
||||
if (buffer[0] == '[') {
|
||||
if (!strncmp (buffer+1, MOZILLA_VERSION, versionLen)) {
|
||||
foundHeader = PR_TRUE;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
if (foundHeader && !strncmp (buffer, "GRE_PATH=", 9)) {
|
||||
pGreLocation = strdup(buffer + 9 );
|
||||
// kill the line feed if any
|
||||
PRInt32 len = strlen(pGreLocation);
|
||||
len--;
|
||||
|
||||
if (pGreLocation[len] == '\n')
|
||||
pGreLocation[len] = '\0';
|
||||
break;
|
||||
}
|
||||
}
|
||||
fclose(cfg);
|
||||
return pGreLocation;
|
||||
}
|
||||
|
||||
|
||||
|
||||
nsresult
|
||||
nsGREDirServiceProvider::GetGreDirectory(nsILocalFile **aLocalFile)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aLocalFile);
|
||||
nsresult rv = NS_ERROR_FAILURE;
|
||||
|
||||
// Get the path of the GRE which is compatible with our embedding application
|
||||
// from the registry
|
||||
//
|
||||
char *pGreDir = GetGREDirectoryPath();
|
||||
if(pGreDir) {
|
||||
nsCOMPtr<nsILocalFile> tempLocal;
|
||||
rv = NS_NewNativeLocalFile(nsDependentCString(pGreDir), PR_TRUE, getter_AddRefs(tempLocal));
|
||||
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
*aLocalFile = tempLocal;
|
||||
NS_ADDREF(*aLocalFile);
|
||||
}
|
||||
|
||||
free(pGreDir);
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
|
||||
|
||||
char*
|
||||
nsGREDirServiceProvider::GetXPCOMPath()
|
||||
{
|
||||
char* grePath = GetGREDirectoryPath();
|
||||
if (!grePath)
|
||||
return nsnull;
|
||||
|
||||
int len = strlen(grePath);
|
||||
char* xpcomPath = (char*) malloc(len + sizeof(XPCOM_DLL) + sizeof(XPCOM_FILE_PATH_SEPARATOR) + 1);
|
||||
|
||||
sprintf(xpcomPath, "%s" XPCOM_FILE_PATH_SEPARATOR XPCOM_DLL, grePath);
|
||||
|
||||
free(grePath);
|
||||
return xpcomPath;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
nsGREDirServiceProvider::AddGRELocationToPath()
|
||||
{
|
||||
char* grePath = GetGREDirectoryPath();
|
||||
if (!grePath)
|
||||
return;
|
||||
|
||||
char* path = PR_GetEnv(XPCOM_SEARCH_KEY);
|
||||
if (!path) {
|
||||
path = "";
|
||||
}
|
||||
|
||||
if (mPathEnvString)
|
||||
PR_Free(mPathEnvString);
|
||||
|
||||
mPathEnvString = PR_smprintf("%s=%s;%s",
|
||||
XPCOM_SEARCH_KEY,
|
||||
path,
|
||||
grePath);
|
||||
PR_SetEnv(mPathEnvString);
|
||||
free(grePath);
|
||||
}
|
||||
|
||||
74
mozilla/xpcom/glue/standalone/nsGREDirServiceProvider.h
Normal file
74
mozilla/xpcom/glue/standalone/nsGREDirServiceProvider.h
Normal file
@@ -0,0 +1,74 @@
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is Mozilla Communicator.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Netscape Communications Corp.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2003
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Sean Su <ssu@netscape.com>
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#ifndef nsGREDirServiceProvider_h_
|
||||
#define nsGREDirServiceProvider_h_
|
||||
|
||||
#include "nsILocalFile.h"
|
||||
#include "nsIDirectoryService.h"
|
||||
#include "nsDirectoryServiceDefs.h"
|
||||
#include "nsString.h"
|
||||
|
||||
class nsIFile;
|
||||
|
||||
//*****************************************************************************
|
||||
// class greEmbedFileLocProvider
|
||||
//*****************************************************************************
|
||||
|
||||
class nsGREDirServiceProvider : public nsIDirectoryServiceProvider
|
||||
{
|
||||
public:
|
||||
|
||||
nsGREDirServiceProvider();
|
||||
|
||||
NS_DECL_ISUPPORTS
|
||||
NS_DECL_NSIDIRECTORYSERVICEPROVIDER
|
||||
|
||||
static char* GetXPCOMPath();
|
||||
static char* GetGREDirectoryPath();
|
||||
static char* GetPathFromConfigFile(const char* filename);
|
||||
|
||||
protected:
|
||||
virtual ~nsGREDirServiceProvider();
|
||||
nsresult GetGreDirectory(nsILocalFile **aLocalFile);
|
||||
void AddGRELocationToPath();
|
||||
|
||||
char* mPathEnvString;
|
||||
};
|
||||
|
||||
#endif // nsGREDirServiceProvider.h
|
||||
|
||||
@@ -40,10 +40,7 @@
|
||||
#include "nsMemory.h"
|
||||
#include "nsXPCOMPrivate.h"
|
||||
|
||||
#if defined(XP_WIN32)
|
||||
#include <windows.h> // for SetProcessWorkingSetSize()
|
||||
#include <malloc.h> // for _heapmin()
|
||||
#endif
|
||||
#include "nsGREDirServiceProvider.h"
|
||||
|
||||
static PRLibrary *xpcomLib = nsnull;
|
||||
static XPCOMFunctions *xpcomFunctions = nsnull;
|
||||
@@ -51,19 +48,6 @@ static nsIMemory* xpcomMemory = nsnull;
|
||||
|
||||
//#define XPCOM_GLUE_NO_DYNAMIC_LOADING
|
||||
|
||||
// seawood tells me there isn't a better way...
|
||||
#ifdef XP_PC
|
||||
#define XPCOM_DLL "xpcom.dll"
|
||||
#else
|
||||
#ifdef XP_MAC
|
||||
#define XPCOM_DLL "XPCOM_DLL"
|
||||
#else
|
||||
#define XPCOM_DLL "libxpcom"MOZ_DLL_SUFFIX
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
extern nsresult GlueStartupMemory();
|
||||
extern void GlueShutdownMemory();
|
||||
|
||||
@@ -222,3 +206,51 @@ NS_UnregisterXPCOMExitRoutine(XPCOMExitRoutine exitRoutine)
|
||||
return xpcomFunctions->unregisterExitRoutine(exitRoutine);
|
||||
}
|
||||
#endif // #ifndef XPCOM_GLUE_NO_DYNAMIC_LOADING
|
||||
|
||||
|
||||
// Default GRE startup/shutdown code
|
||||
|
||||
extern "C"
|
||||
nsresult NS_COM GRE_Startup()
|
||||
{
|
||||
char* xpcomLocation = nsGREDirServiceProvider::GetXPCOMPath();
|
||||
|
||||
// Startup the XPCOM Glue that links us up with XPCOM.
|
||||
nsresult rv = XPCOMGlueStartup(xpcomLocation);
|
||||
|
||||
if (xpcomLocation)
|
||||
free(xpcomLocation);
|
||||
|
||||
if (NS_FAILED(rv)) {
|
||||
NS_WARNING("gre: XPCOMGlueStartup failed");
|
||||
return rv;
|
||||
}
|
||||
|
||||
nsGREDirServiceProvider *provider = new nsGREDirServiceProvider();
|
||||
if ( !provider ) {
|
||||
NS_WARNING("GRE_Startup failed");
|
||||
XPCOMGlueShutdown();
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIServiceManager> servMan;
|
||||
NS_ADDREF( provider );
|
||||
rv = NS_InitXPCOM2(getter_AddRefs(servMan), nsnull, provider);
|
||||
NS_RELEASE(provider);
|
||||
|
||||
if ( NS_FAILED(rv) || !servMan) {
|
||||
NS_WARNING("gre: NS_InitXPCOM failed");
|
||||
XPCOMGlueShutdown();
|
||||
return rv;
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
extern "C"
|
||||
nsresult NS_COM GRE_Shutdown()
|
||||
{
|
||||
NS_ShutdownXPCOM(nsnull);
|
||||
XPCOMGlueShutdown();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
@@ -44,3 +44,12 @@ nsresult NS_COM XPCOMGlueStartup(const char* xpcomFile);
|
||||
|
||||
extern "C"
|
||||
nsresult NS_COM XPCOMGlueShutdown();
|
||||
|
||||
|
||||
// Default GRE startup and shutdown
|
||||
|
||||
extern "C"
|
||||
nsresult NS_COM GRE_Startup();
|
||||
|
||||
extern "C"
|
||||
nsresult NS_COM GRE_Shutdown();
|
||||
|
||||
Reference in New Issue
Block a user