VirtualBox

source: vbox/trunk/src/VBox/Main/include/HostPower.h@ 47469

Last change on this file since 47469 was 46775, checked in by vboxsync, 11 years ago

Main/Host(HostPower)+Session+Console: convert HostPower code to signal pause/resume/savestate through internal methods, conveying information why the method was called, preparing for VM/PDM passing this information to devices and drivers

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 2.7 KB
Line 
1/** @file
2 *
3 * VirtualBox interface to host's power notification service
4 */
5
6/*
7 * Copyright (C) 2006-2013 Oracle Corporation
8 *
9 * This file is part of VirtualBox Open Source Edition (OSE), as
10 * available from http://www.virtualbox.org. This file is free software;
11 * you can redistribute it and/or modify it under the terms of the GNU
12 * General Public License (GPL) as published by the Free Software
13 * Foundation, in version 2 as it comes in the "COPYING" file of the
14 * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
15 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
16 */
17
18#ifndef ____H_HOSTPOWER
19#define ____H_HOSTPOWER
20
21#include "VirtualBoxBase.h"
22
23#include <vector>
24
25#ifdef RT_OS_DARWIN
26# include <IOKit/pwr_mgt/IOPMLib.h>
27# include <Carbon/Carbon.h>
28#endif /* RT_OS_DARWIN */
29
30class HostPowerService
31{
32public:
33
34 HostPowerService(VirtualBox *aVirtualBox);
35 virtual ~HostPowerService();
36
37 void notify(Reason_T aReason);
38
39protected:
40
41 VirtualBox *mVirtualBox;
42
43 std::vector<ComPtr<IInternalSessionControl> > mSessionControls;
44};
45
46# ifdef RT_OS_WINDOWS
47/**
48 * The Windows hosted Power Service.
49 */
50class HostPowerServiceWin : public HostPowerService
51{
52public:
53
54 HostPowerServiceWin(VirtualBox *aVirtualBox);
55 virtual ~HostPowerServiceWin();
56
57private:
58
59 static DECLCALLBACK(int) NotificationThread(RTTHREAD ThreadSelf, void *pInstance);
60 static LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam);
61
62 HWND mHwnd;
63 RTTHREAD mThread;
64};
65# elif defined(RT_OS_DARWIN) /* RT_OS_WINDOWS */
66/**
67 * The Darwin hosted Power Service.
68 */
69class HostPowerServiceDarwin : public HostPowerService
70{
71public:
72
73 HostPowerServiceDarwin(VirtualBox *aVirtualBox);
74 virtual ~HostPowerServiceDarwin();
75
76private:
77
78 static DECLCALLBACK(int) powerChangeNotificationThread(RTTHREAD ThreadSelf, void *pInstance);
79 static void powerChangeNotificationHandler(void *pvData, io_service_t service, natural_t messageType, void *pMessageArgument);
80 static void lowPowerHandler(void *pvData);
81
82 void checkBatteryCriticalLevel(bool *pfCriticalChanged = NULL);
83
84 /* Private member vars */
85 RTTHREAD mThread; /* Our message thread. */
86
87 io_connect_t mRootPort; /* A reference to the Root Power Domain IOService */
88 IONotificationPortRef mNotifyPort; /* Notification port allocated by IORegisterForSystemPower */
89 io_object_t mNotifierObject; /* Notifier object, used to deregister later */
90 CFRunLoopRef mRunLoop; /* A reference to the local thread run loop */
91
92 bool mCritical; /* Indicate if the battery was in the critical state last checked */
93};
94# endif /* RT_OS_DARWIN */
95
96#endif /* !____H_HOSTPOWER */
97/* vi: set tabstop=4 shiftwidth=4 expandtab: */
Note: See TracBrowser for help on using the repository browser.

© 2023 Oracle
ContactPrivacy policyTerms of Use