VirtualBox

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

Last change on this file since 83489 was 82968, checked in by vboxsync, 5 years ago

Copyright year updates by scm.

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