0b4b395eb911641f926d4f2f45e5620028120a60vboxsync/** @file
0b4b395eb911641f926d4f2f45e5620028120a60vboxsync *
0b4b395eb911641f926d4f2f45e5620028120a60vboxsync * VirtualBox interface to host's power notification service
0b4b395eb911641f926d4f2f45e5620028120a60vboxsync */
0b4b395eb911641f926d4f2f45e5620028120a60vboxsync
0b4b395eb911641f926d4f2f45e5620028120a60vboxsync/*
0158d474771d8cf8fb0bfbbe297d3f9b74de04ccvboxsync * Copyright (C) 2006-2013 Oracle Corporation
0b4b395eb911641f926d4f2f45e5620028120a60vboxsync *
0b4b395eb911641f926d4f2f45e5620028120a60vboxsync * This file is part of VirtualBox Open Source Edition (OSE), as
0b4b395eb911641f926d4f2f45e5620028120a60vboxsync * available from http://www.virtualbox.org. This file is free software;
0b4b395eb911641f926d4f2f45e5620028120a60vboxsync * you can redistribute it and/or modify it under the terms of the GNU
0b4b395eb911641f926d4f2f45e5620028120a60vboxsync * General Public License (GPL) as published by the Free Software
0b4b395eb911641f926d4f2f45e5620028120a60vboxsync * Foundation, in version 2 as it comes in the "COPYING" file of the
0b4b395eb911641f926d4f2f45e5620028120a60vboxsync * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
0b4b395eb911641f926d4f2f45e5620028120a60vboxsync * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
0b4b395eb911641f926d4f2f45e5620028120a60vboxsync */
0b4b395eb911641f926d4f2f45e5620028120a60vboxsync
0b4b395eb911641f926d4f2f45e5620028120a60vboxsync#ifndef ____H_HOSTPOWER
0b4b395eb911641f926d4f2f45e5620028120a60vboxsync#define ____H_HOSTPOWER
0b4b395eb911641f926d4f2f45e5620028120a60vboxsync
0b4b395eb911641f926d4f2f45e5620028120a60vboxsync#include "VirtualBoxBase.h"
0b4b395eb911641f926d4f2f45e5620028120a60vboxsync
0b4b395eb911641f926d4f2f45e5620028120a60vboxsync#include <vector>
0b4b395eb911641f926d4f2f45e5620028120a60vboxsync
0b4b395eb911641f926d4f2f45e5620028120a60vboxsync#ifdef RT_OS_DARWIN
0b4b395eb911641f926d4f2f45e5620028120a60vboxsync# include <IOKit/pwr_mgt/IOPMLib.h>
0b4b395eb911641f926d4f2f45e5620028120a60vboxsync# include <Carbon/Carbon.h>
0b4b395eb911641f926d4f2f45e5620028120a60vboxsync#endif /* RT_OS_DARWIN */
0b4b395eb911641f926d4f2f45e5620028120a60vboxsync
0b4b395eb911641f926d4f2f45e5620028120a60vboxsyncclass HostPowerService
0b4b395eb911641f926d4f2f45e5620028120a60vboxsync{
0a1ded7cadae50b2ee93d8df1d2af5b00b5b88e5vboxsync public:
0158d474771d8cf8fb0bfbbe297d3f9b74de04ccvboxsync HostPowerService(VirtualBox *aVirtualBox);
0b4b395eb911641f926d4f2f45e5620028120a60vboxsync virtual ~HostPowerService();
0158d474771d8cf8fb0bfbbe297d3f9b74de04ccvboxsync void notify(Reason_T aReason);
0b4b395eb911641f926d4f2f45e5620028120a60vboxsync
0a1ded7cadae50b2ee93d8df1d2af5b00b5b88e5vboxsync protected:
0158d474771d8cf8fb0bfbbe297d3f9b74de04ccvboxsync VirtualBox *mVirtualBox;
0158d474771d8cf8fb0bfbbe297d3f9b74de04ccvboxsync std::vector<ComPtr<IInternalSessionControl> > mSessionControls;
0b4b395eb911641f926d4f2f45e5620028120a60vboxsync};
0b4b395eb911641f926d4f2f45e5620028120a60vboxsync
0b4b395eb911641f926d4f2f45e5620028120a60vboxsync# ifdef RT_OS_WINDOWS
0b4b395eb911641f926d4f2f45e5620028120a60vboxsync/**
0b4b395eb911641f926d4f2f45e5620028120a60vboxsync * The Windows hosted Power Service.
0b4b395eb911641f926d4f2f45e5620028120a60vboxsync */
0b4b395eb911641f926d4f2f45e5620028120a60vboxsyncclass HostPowerServiceWin : public HostPowerService
0b4b395eb911641f926d4f2f45e5620028120a60vboxsync{
0b4b395eb911641f926d4f2f45e5620028120a60vboxsyncpublic:
0b4b395eb911641f926d4f2f45e5620028120a60vboxsync
0b4b395eb911641f926d4f2f45e5620028120a60vboxsync HostPowerServiceWin(VirtualBox *aVirtualBox);
0b4b395eb911641f926d4f2f45e5620028120a60vboxsync virtual ~HostPowerServiceWin();
0b4b395eb911641f926d4f2f45e5620028120a60vboxsync
0b4b395eb911641f926d4f2f45e5620028120a60vboxsyncprivate:
0b4b395eb911641f926d4f2f45e5620028120a60vboxsync
0158d474771d8cf8fb0bfbbe297d3f9b74de04ccvboxsync static DECLCALLBACK(int) NotificationThread(RTTHREAD ThreadSelf, void *pInstance);
0b4b395eb911641f926d4f2f45e5620028120a60vboxsync static LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam);
0b4b395eb911641f926d4f2f45e5620028120a60vboxsync
0b4b395eb911641f926d4f2f45e5620028120a60vboxsync HWND mHwnd;
0b4b395eb911641f926d4f2f45e5620028120a60vboxsync RTTHREAD mThread;
0b4b395eb911641f926d4f2f45e5620028120a60vboxsync};
0b4b395eb911641f926d4f2f45e5620028120a60vboxsync# elif defined(RT_OS_DARWIN) /* RT_OS_WINDOWS */
0b4b395eb911641f926d4f2f45e5620028120a60vboxsync/**
0b4b395eb911641f926d4f2f45e5620028120a60vboxsync * The Darwin hosted Power Service.
0b4b395eb911641f926d4f2f45e5620028120a60vboxsync */
0b4b395eb911641f926d4f2f45e5620028120a60vboxsyncclass HostPowerServiceDarwin : public HostPowerService
0b4b395eb911641f926d4f2f45e5620028120a60vboxsync{
0b4b395eb911641f926d4f2f45e5620028120a60vboxsyncpublic:
0b4b395eb911641f926d4f2f45e5620028120a60vboxsync
0158d474771d8cf8fb0bfbbe297d3f9b74de04ccvboxsync HostPowerServiceDarwin(VirtualBox *aVirtualBox);
0b4b395eb911641f926d4f2f45e5620028120a60vboxsync virtual ~HostPowerServiceDarwin();
0b4b395eb911641f926d4f2f45e5620028120a60vboxsync
0b4b395eb911641f926d4f2f45e5620028120a60vboxsyncprivate:
0b4b395eb911641f926d4f2f45e5620028120a60vboxsync
0158d474771d8cf8fb0bfbbe297d3f9b74de04ccvboxsync static DECLCALLBACK(int) powerChangeNotificationThread(RTTHREAD ThreadSelf, void *pInstance);
0158d474771d8cf8fb0bfbbe297d3f9b74de04ccvboxsync static void powerChangeNotificationHandler(void *pvData, io_service_t service, natural_t messageType, void *pMessageArgument);
0158d474771d8cf8fb0bfbbe297d3f9b74de04ccvboxsync static void lowPowerHandler(void *pvData);
847533b44f1a1636747d3b211c921d4b92a152c6vboxsync
0158d474771d8cf8fb0bfbbe297d3f9b74de04ccvboxsync void checkBatteryCriticalLevel(bool *pfCriticalChanged = NULL);
0b4b395eb911641f926d4f2f45e5620028120a60vboxsync
0b4b395eb911641f926d4f2f45e5620028120a60vboxsync /* Private member vars */
0b4b395eb911641f926d4f2f45e5620028120a60vboxsync RTTHREAD mThread; /* Our message thread. */
0b4b395eb911641f926d4f2f45e5620028120a60vboxsync
0b4b395eb911641f926d4f2f45e5620028120a60vboxsync io_connect_t mRootPort; /* A reference to the Root Power Domain IOService */
0b4b395eb911641f926d4f2f45e5620028120a60vboxsync IONotificationPortRef mNotifyPort; /* Notification port allocated by IORegisterForSystemPower */
0b4b395eb911641f926d4f2f45e5620028120a60vboxsync io_object_t mNotifierObject; /* Notifier object, used to deregister later */
0b4b395eb911641f926d4f2f45e5620028120a60vboxsync CFRunLoopRef mRunLoop; /* A reference to the local thread run loop */
847533b44f1a1636747d3b211c921d4b92a152c6vboxsync
847533b44f1a1636747d3b211c921d4b92a152c6vboxsync bool mCritical; /* Indicate if the battery was in the critical state last checked */
0b4b395eb911641f926d4f2f45e5620028120a60vboxsync};
0b4b395eb911641f926d4f2f45e5620028120a60vboxsync# endif /* RT_OS_DARWIN */
0b4b395eb911641f926d4f2f45e5620028120a60vboxsync
0b4b395eb911641f926d4f2f45e5620028120a60vboxsync#endif /* !____H_HOSTPOWER */
f6adf1a86574758258baa232172c965aed0d848dvboxsync/* vi: set tabstop=4 shiftwidth=4 expandtab: */