VirtualBox

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

Last change on this file since 68986 was 65088, checked in by vboxsync, 8 years ago

Main: doxygen fixes

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 3.4 KB
Line 
1/* $Id: HostPower.h 65088 2017-01-03 20:52:49Z vboxsync $ */
2/** @file
3 *
4 * VirtualBox interface to host's power notification service
5 */
6
7/*
8 * Copyright (C) 2006-2016 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#ifdef RT_OS_DARWIN /* first, so we can undef pVM in iprt/cdefs.h */
23# include <IOKit/pwr_mgt/IOPMLib.h>
24# include <Carbon/Carbon.h>
25#endif
26
27#include "VirtualBoxBase.h"
28
29#include <vector>
30
31#ifdef RT_OS_LINUX
32# include <VBox/dbus.h>
33#endif
34
35class HostPowerService
36{
37 public:
38 HostPowerService(VirtualBox *aVirtualBox);
39 virtual ~HostPowerService();
40 void notify(Reason_T aReason);
41
42 protected:
43 VirtualBox *mVirtualBox;
44 std::vector<ComPtr<IInternalSessionControl> > mSessionControls;
45};
46
47# if defined(RT_OS_WINDOWS) || defined(DOXYGEN_RUNNING)
48/**
49 * The Windows hosted Power Service.
50 */
51class HostPowerServiceWin : public HostPowerService
52{
53public:
54
55 HostPowerServiceWin(VirtualBox *aVirtualBox);
56 virtual ~HostPowerServiceWin();
57
58private:
59
60 static DECLCALLBACK(int) NotificationThread(RTTHREAD ThreadSelf, void *pInstance);
61 static LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam);
62
63 HWND mHwnd;
64 RTTHREAD mThread;
65};
66# endif
67# if defined(RT_OS_LINUX) || defined(DOXYGEN_RUNNING)
68/**
69 * The Linux hosted Power Service.
70 */
71class HostPowerServiceLinux : public HostPowerService
72{
73public:
74
75 HostPowerServiceLinux(VirtualBox *aVirtualBox);
76 virtual ~HostPowerServiceLinux();
77
78private:
79
80 static DECLCALLBACK(int) powerChangeNotificationThread(RTTHREAD ThreadSelf, void *pInstance);
81
82 /* Private member vars */
83 /** Our message thread. */
84 RTTHREAD mThread;
85 /** Our (private) connection to the DBus. Closing this will cause the
86 * message thread to exit. */
87 DBusConnection *mpConnection;
88};
89
90# endif
91# if defined(RT_OS_DARWIN) || defined(DOXYGEN_RUNNING)
92/**
93 * The Darwin hosted Power Service.
94 */
95class HostPowerServiceDarwin : public HostPowerService
96{
97public:
98
99 HostPowerServiceDarwin(VirtualBox *aVirtualBox);
100 virtual ~HostPowerServiceDarwin();
101
102private:
103
104 static DECLCALLBACK(int) powerChangeNotificationThread(RTTHREAD ThreadSelf, void *pInstance);
105 static void powerChangeNotificationHandler(void *pvData, io_service_t service, natural_t messageType, void *pMessageArgument);
106 static void lowPowerHandler(void *pvData);
107
108 void checkBatteryCriticalLevel(bool *pfCriticalChanged = NULL);
109
110 /* Private member vars */
111 RTTHREAD mThread; /* Our message thread. */
112
113 io_connect_t mRootPort; /* A reference to the Root Power Domain IOService */
114 IONotificationPortRef mNotifyPort; /* Notification port allocated by IORegisterForSystemPower */
115 io_object_t mNotifierObject; /* Notifier object, used to deregister later */
116 CFRunLoopRef mRunLoop; /* A reference to the local thread run loop */
117
118 bool mCritical; /* Indicate if the battery was in the critical state last checked */
119};
120# endif
121
122#endif /* !____H_HOSTPOWER */
123/* 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