VBoxXPCOMC.cpp revision 0bb65e71fd8bb74172b634aa7cba33cb5161c76b
/* $Id$ */
/** @file VBoxXPCOMC.cpp
* Utility functions to use with the C binding for XPCOM.
*/
/*
* Copyright (C) 2009-2013 Oracle Corporation
*
* 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 (GPL) 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.
*/
#define LOG_GROUP LOG_GROUP_MAIN
#include <nsMemory.h>
#include <nsIServiceManager.h>
#include <nsEventQueueUtils.h>
#include <nsIExceptionService.h>
#include "VBoxCAPI.h"
using namespace std;
/* The following 3 object references should be eliminated once the legacy
* way to initialize the XPCOM C bindings is removed. */
static void VBoxComUninitialize(void);
static void VBoxClientUninitialize(void);
static int
{
}
static int
{
}
static void
{
}
static void
VBoxUtf8Free(char *pszString)
{
}
static void
VBoxComUnallocMem(void *ptr)
{
if (ptr)
}
static void
{
*ppVirtualBox = NULL;
/* convert the string representation of UUID to nsIID type */
return;
{
return;
}
{
return;
}
{
return;
}
(void **)&g_VirtualBox);
{
return;
}
Log(("Cbinding: IVirtualBox object created.\n"));
(void **)&g_Session);
{
return;
}
Log(("Cbinding: ISession object created.\n"));
}
static void
{
}
static void
VBoxComUninitialize(void)
{
if (g_Session)
{
}
if (g_VirtualBox)
{
g_VirtualBox = NULL;
}
if (g_EventQueue)
{
g_EventQueue = NULL;
}
if (g_Manager)
{
}
Log(("Cbinding: Cleaned up the created objects.\n"));
}
static void
{
}
static nsresult
{
*ppException = NULL;
return rc;
{
return rc;
}
{
NS_RELEASE(es);
return rc;
}
{
NS_RELEASE(em);
NS_RELEASE(es);
return rc;
}
*ppException = ex;
NS_RELEASE(em);
NS_RELEASE(es);
return rc;
}
static nsresult
VBoxClearException(void)
{
return rc;
{
return rc;
}
{
NS_RELEASE(es);
return rc;
}
NS_RELEASE(em);
NS_RELEASE(es);
return rc;
}
static nsresult
{
/* convert the string representation of UUID to nsIID type */
return NS_ERROR_INVALID_ARG;
{
return rc;
}
{
return rc;
}
{
return rc;
}
(void **)ppVirtualBoxClient);
{
return rc;
}
Log(("Cbinding: IVirtualBoxClient object created.\n"));
return NS_OK;
}
static void
VBoxClientUninitialize(void)
{
if (g_EventQueue)
{
g_EventQueue = NULL;
}
Log(("Cbinding: Cleaned up the created objects.\n"));
}
static unsigned int
VBoxVersion(void)
{
}
static unsigned int
VBoxAPIVersion(void)
{
}
VBoxGetXPCOMCFunctions(unsigned uVersion)
{
/*
* The current interface version.
*/
static const VBOXXPCOMC s_Functions =
{
sizeof(VBOXXPCOMC),
};
return &s_Functions;
/*
* Legacy interface version 2.0.
*/
static const struct VBOXXPCOMCV2
{
/** The size of the structure. */
unsigned cb;
/** The structure version. */
unsigned uVersion;
unsigned int (*pfnGetVersion)(void);
void (*pfnComInitialize)(const char *pszVirtualBoxIID,
const char *pszSessionIID,
void (*pfnComUninitialize)(void);
void (*pfnComUnallocMem)(void *pv);
void (*pfnUtf8Free)(char *pszString);
/** Tail version, same as uVersion. */
unsigned uEndVersion;
} s_Functions_v2_0 =
{
sizeof(s_Functions_v2_0),
0x00020000U,
0x00020000U
};
return (PCVBOXXPCOM)&s_Functions_v2_0;
/*
* Legacy interface version 1.0.
*/
static const struct VBOXXPCOMCV1
{
/** The size of the structure. */
unsigned cb;
/** The structure version. */
unsigned uVersion;
unsigned int (*pfnGetVersion)(void);
void (*pfnComUninitialize)(void);
void (*pfnComUnallocMem)(void *pv);
void (*pfnUtf8Free)(char *pszString);
/** Tail version, same as uVersion. */
unsigned uEndVersion;
} s_Functions_v1_0 =
{
sizeof(s_Functions_v1_0),
0x00010000U,
0x00010000U
};
return (PCVBOXXPCOM)&s_Functions_v1_0;
/*
* Unsupported interface version.
*/
return NULL;
}
/* vim: set ts=4 sw=4 et: */