VirtualBox

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

Last change on this file since 55436 was 55436, checked in by vboxsync, 10 years ago

Reverted bad commit r99781.

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

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette