initterm.cpp revision c98fb3e16fcd571a790eab772c0c66173d225205
/** @file
* MS COM / XPCOM Abstraction Layer - Initialization and Termination.
*/
/*
* Copyright (C) 2006-2007 innotek GmbH
*
* This file is part of VirtualBox Open Source Edition (OSE), as
* available from http://www.virtualbox.org. This file is free software;
* General Public License as published by the Free Software Foundation,
* in version 2 as it comes in the "COPYING" file of the VirtualBox OSE
* distribution. VirtualBox OSE is distributed in the hope that it will
* be useful, but WITHOUT ANY WARRANTY of any kind.
*/
#if !defined (VBOX_WITH_XPCOM)
#include <objbase.h>
#else /* !defined (VBOX_WITH_XPCOM) */
#include <stdlib.h>
#include <nsXPCOMGlue.h>
#include <nsIComponentRegistrar.h>
#include <nsIServiceManager.h>
#include <nsCOMPtr.h>
#include <nsEventQueueUtils.h>
#include <nsEmbedString.h>
#include <nsILocalFile.h>
#include <nsIDirectoryService.h>
#include <nsDirectoryServiceDefs.h>
#endif /* !defined (VBOX_WITH_XPCOM) */
namespace com
{
#if defined (VBOX_WITH_XPCOM)
class DirectoryServiceProvider : public nsIDirectoryServiceProvider
{
public:
{}
virtual ~DirectoryServiceProvider();
const char *aXPTIDatLocation,
const char *aComponentDirLocation,
const char *aCurrProcDirLocation);
private:
char *mCompRegLocation;
char *mXPTIDatLocation;
char *mComponentDirLocation;
char *mCurrProcDirLocation;
};
{
if (mCompRegLocation)
{
}
if (mXPTIDatLocation)
{
}
{
}
if (mCurrProcDirLocation)
{
}
}
/**
* @param aCompRegLocation Path to compreg.dat, in Utf8.
* @param aXPTIDatLocation Path to xpti.data, in Utf8.
*/
const char *aXPTIDatLocation,
const char *aComponentDirLocation,
const char *aCurrProcDirLocation)
{
if (RT_SUCCESS (vrc))
}
{
*aPersistent = PR_TRUE;
const char *fileLocation = NULL;
else
return NS_ERROR_FAILURE;
return rv;
(void **) aRetval);
}
#endif /* defined (VBOX_WITH_XPCOM) */
{
#if !defined (VBOX_WITH_XPCOM)
#else /* !defined (VBOX_WITH_XPCOM) */
/* Set VBOX_XPCOM_HOME if not present */
if (!RTEnvExist ("VBOX_XPCOM_HOME"))
{
/* get the executable path */
char pathProgram [RTPATH_MAX];
if (RT_SUCCESS (vrc))
{
char *pathProgramCP = NULL;
if (RT_SUCCESS (vrc))
{
}
}
}
if (rc == NS_ERROR_NOT_INITIALIZED)
{
/* prepare paths for registry files */
char homeDir [RTPATH_MAX];
char privateArchDir [RTPATH_MAX];
if (RT_SUCCESS (vrc))
if (RT_SUCCESS (vrc))
{
char compReg [RTPATH_MAX];
char xptiDat [RTPATH_MAX];
char compDir [RTPATH_MAX];
dsProv = new DirectoryServiceProvider();
if (dsProv)
else
}
else
/* get the path to the executable */
{
char path [RTPATH_MAX];
#if defined (DEBUG)
if (env)
{
char *appDirUtf8 = NULL;
if (RT_SUCCESS (vrc))
{
if (RT_SUCCESS (vrc))
}
}
else
#endif
{
if (RT_SUCCESS (vrc))
}
if (RT_SUCCESS (vrc))
{
if (NS_SUCCEEDED (rc))
}
else
}
/* Finally, initialize XPCOM */
if (NS_SUCCEEDED (rc))
{
if (NS_SUCCEEDED (rc))
{
if (NS_SUCCEEDED (rc))
}
}
}
#endif /* !defined (VBOX_WITH_XPCOM) */
AssertComRC (rc);
return rc;
}
{
#if !defined (VBOX_WITH_XPCOM)
#else /* !defined (VBOX_WITH_XPCOM) */
{
/* NS_ERROR_NOT_AVAILABLE seems to mean that
* nsIEventQueue::StopAcceptingEvents() has been called (see
* nsEventQueueService.cpp). We hope that this error code always means
* just that in this case and assume that we're on the main thread
* (it's a kind of unexpected behavior if a non-main thread ever calls
* StopAcceptingEvents() on the main event queue). */
if (NS_SUCCEEDED (rc))
{
}
else
{
}
{
/* only the main thread needs to uninitialize XPCOM */
}
}
#endif /* !defined (VBOX_WITH_XPCOM) */
AssertComRC (rc);
return rc;
}
}; // namespace com