ExtPackManagerImpl.cpp revision 73045e3d71f04f3d399e70e89fbd6395c4402821
/* $Id$ */
/** @file
* VirtualBox Main - interface for Extension Packs, VBoxSVC & VBoxC.
*/
/*
* Copyright (C) 2010 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.
*/
/*******************************************************************************
* Header Files *
*******************************************************************************/
#include "ExtPackManagerImpl.h"
#include "AutoCaller.h"
/*******************************************************************************
* Structures and Typedefs *
*******************************************************************************/
/**
* Private extension pack data.
*/
{
/** @name IExtPack Attributes.
* @{ */
/** The name. */
/** The version string. */
/** The revision. */
/** Whether it's usable or not. */
bool fUsable;
/** Why it is unusable. */
/** @} */
/** Where the extension pack is located. */
/** The module handle of the main extension pack module. */
};
/** List of extension packs. */
/**
* Private extension pack manager data.
*/
struct ExtPackManager::Data
{
/** Where the directory where the extension packs are installed. */
/** The list of installed extension packs. */
};
/**
* Called by ComObjPtr::createObject when creating the object.
*
* Just initialize the basic object state, do the rest in init().
*
* @returns S_OK.
*/
{
m = NULL;
return S_OK;
}
/**
* Initializes the extension pack by reading its file.
*
* @returns COM status code.
* @param a_pszName The name of the extension pack. This is also the
* name of the subdirector under @a a_pszParentDir
* where the extension pack is installed.
* @param a_pszParentDir The parent directory.
*/
{
/*
* Figure out where we live and allocate+initialize our private data.
*/
char szDir[RTPATH_MAX];
m = new Data;
m->strVersion = "";
m->uRevision = 0;
m->fUsable = false;
m->hMainMod = NIL_RTLDRMOD;
/*
* Read the description file.
*/
return S_OK;
}
/**
* COM cruft.
*/
void ExtPack::FinalRelease()
{
uninit();
}
/**
* Do the actual cleanup.
*/
{
/* Enclose the state transition Ready->InUninit->NotReady */
AutoUninitSpan autoUninitSpan(this);
{
if (m->hMainMod != NIL_RTLDRMOD)
{
RTLdrClose(m->hMainMod);
m->hMainMod = NIL_RTLDRMOD;
}
delete m;
m = NULL;
}
}
{
AutoCaller autoCaller(this);
return hrc;
}
{
AutoCaller autoCaller(this);
return hrc;
}
{
AutoCaller autoCaller(this);
*a_puRevision = m->uRevision;
return hrc;
}
{
AutoCaller autoCaller(this);
*a_pfUsable = m->fUsable;
return hrc;
}
{
AutoCaller autoCaller(this);
return hrc;
}
void *ExtPack::getCallbackTable()
{
return NULL;
}
/**
* Called by ComObjPtr::createObject when creating the object.
*
* Just initialize the basic object state, do the rest in init().
*
* @returns S_OK.
*/
{
m = NULL;
return S_OK;
}
/**
* Initializes the extension pack manager.
*
* @returns COM status code.
*/
{
/*
* Figure some stuff out before creating the instance data.
*/
char szBasePath[RTPATH_MAX];
/*
* Allocate and initialize the instance data.
*/
m = new Data;
m->strBasePath = szBasePath;
/*
* Go looking for extensions. The RTDirOpen may fail if nothing has been
* installed yet, or if root is paranoid and has revoked our access to them.
*
* We ASSUME that there are no files, directories or stuff in the directory
* that exceed the max name length in RTDIRENTRYEX.
*/
if (RT_FAILURE(vrc))
return S_OK;
for (;;)
{
if (RT_FAILURE(vrc))
{
break;
}
{
/*
* All directories are extensions, the shall be nothing but
* extensions in this subdirectory.
*/
}
}
return hrc;
}
/**
* COM cruft.
*/
void ExtPackManager::FinalRelease()
{
uninit();
}
/**
* Do the actual cleanup.
*/
void ExtPackManager::uninit()
{
/* Enclose the state transition Ready->InUninit->NotReady */
AutoUninitSpan autoUninitSpan(this);
{
/** @todo do unload notifications */
delete m;
m = NULL;
}
}
STDMETHODIMP ExtPackManager::COMGETTER(InstalledExtPacks)(ComSafeArrayOut(IExtPack *, a_paExtPacks))
{
AutoCaller autoCaller(this);
{
}
return hrc;
}
{
AutoCaller autoCaller(this);
{
it++)
{
if ( pExtPackData
{
break;
}
}
}
return hrc;
}
{
return E_NOTIMPL;
}
{
return E_NOTIMPL;
}
{
return VINF_SUCCESS;
}
{
return VINF_SUCCESS;
}
/* vi: set tabstop=4 shiftwidth=4 expandtab: */