HostPower.cpp revision 1182fb63729addc520f50d0b2ccc537f80a2eb0b
/** @file
*
* VirtualBox interface to host's power notification service
*/
/*
* Copyright (C) 2006-2007 Sun Microsystems, Inc.
*
* 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.
*
* Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
* Clara, CA 95054 USA or visit http://www.sun.com if you need
* additional information or have any questions.
*/
/*******************************************************************************
* Header Files *
*******************************************************************************/
#include "HostPower.h"
#include "Logging.h"
HostPowerService::HostPowerService(VirtualBox *aVirtualBox) : aMachineSuspended(NULL), cbMachineSuspended(0)
{
}
{
}
{
switch (event)
{
case HostPowerEvent_Suspend:
processEvent(machines[i], HostPowerEvent_Suspend, (aMachineSuspended) ? &aMachineSuspended[i] : NULL);
Log(("HostPowerService::notify SUSPEND\n"));
break;
case HostPowerEvent_Resume:
Log(("HostPowerService::notify RESUME\n"));
if (aMachineSuspended)
{
/* It's possible (in theory) that machines are created or destroyed between the suspend notification and the actual host suspend.
* Ignore this edge case and just make sure not to access invalid data.
*/
for (size_t i = 0; i < cbMachineSuspended; i++)
cbMachineSuspended = 0;
}
break;
Log(("HostPowerService::notify BATTERY LOW\n"));
break;
}
}
HRESULT HostPowerService::processEvent(SessionMachine *machine, HostPowerEvent event, BOOL *pMachineSuspended)
{
/* Valid combinations:
* running & suspend or battery low notification events
* pause & resume or battery low notification events
*/
{
return rc;
/* get the IInternalSessionControl interface */
if (!control)
{
rc = E_INVALIDARG;
goto fail;
}
{
/* get the associated console */
{
switch (event)
{
case HostPowerEvent_Suspend:
break;
case HostPowerEvent_Resume:
if (*pMachineSuspended == TRUE)
break;
{
{
/* Wait until the operation has been completed. */
}
break;
}
} /* switch (event) */
}
}
fail:
}
return rc;
}