foobar2000 SDK  2015-08-03
Public Member Functions | Private Member Functions | Private Attributes
CPowerRequest

#include <CPowerRequest.h>

Public Member Functions

 CPowerRequest (const wchar_t *Reason)
 
 CPowerRequest (const wchar_t *Reason)
 
 ~CPowerRequest ()
 
void SetDisplay (bool bDisplay)
 
void SetDisplay (bool bDisplay)
 
void SetExecution (bool bExecution)
 
void SetExecution (bool bExecution)
 
void SetSystem (bool bSystem)
 
void SetSystem (bool bSystem)
 

Private Member Functions

 CPowerRequest (const CPowerRequest &)
 
 CPowerRequest (const CPowerRequest &)
 
void _UpdateTES ()
 
void operator= (const CPowerRequest &)
 
void operator= (const CPowerRequest &)
 

Private Attributes

CPowerRequestAPI m_API
 
bool m_bDisplay
 
bool m_bSystem
 
HANDLE m_Request
 

Detailed Description

Definition at line 73 of file CPowerRequest.h.

Constructor & Destructor Documentation

CPowerRequest::CPowerRequest ( const wchar_t *  Reason)

Definition at line 38 of file CPowerRequest.cpp.

38  : m_Request(INVALID_HANDLE_VALUE), m_bSystem(), m_bDisplay() {
39  HMODULE kernel32 = GetModuleHandle(_T("kernel32.dll"));
40  if (m_API.IsValid()) {
41  winapi_substitute::REASON_CONTEXT ctx = {POWER_REQUEST_CONTEXT_VERSION, POWER_REQUEST_CONTEXT_SIMPLE_STRING};
42  ctx.Reason.SimpleReasonString = const_cast<wchar_t*>(Reason);
44  }
45 }
union winapi_substitute::_REASON_CONTEXT::@14 Reason
HANDLE m_Request
Definition: CPowerRequest.h:82
pPowerCreateRequest_t PowerCreateRequest
Definition: CPowerRequest.h:63
CPowerRequestAPI m_API
Definition: CPowerRequest.h:84
CPowerRequest::~CPowerRequest ( )

Definition at line 77 of file CPowerRequest.cpp.

77  {
78  if (m_Request != INVALID_HANDLE_VALUE) {
79  CloseHandle(m_Request);
80  } else {
81  if (m_bDisplay || m_bSystem) SetThreadExecutionState(ES_CONTINUOUS);
82  }
83 }
HANDLE m_Request
Definition: CPowerRequest.h:82
CPowerRequest::CPowerRequest ( const CPowerRequest )
private
CPowerRequest::CPowerRequest ( const wchar_t *  Reason)
inline

Definition at line 92 of file CPowerRequest.h.

92 {}
CPowerRequest::CPowerRequest ( const CPowerRequest )
private

Member Function Documentation

void CPowerRequest::_UpdateTES ( )
private

Definition at line 85 of file CPowerRequest.cpp.

85  {
86  SetThreadExecutionState(ES_CONTINUOUS | (m_bSystem ? ES_SYSTEM_REQUIRED : 0 ) | (m_bDisplay ? ES_DISPLAY_REQUIRED : 0) );
87 }
void CPowerRequest::operator= ( const CPowerRequest )
private
void CPowerRequest::operator= ( const CPowerRequest )
private
void CPowerRequest::SetDisplay ( bool  bDisplay)

Definition at line 67 of file CPowerRequest.cpp.

67  {
68  if (bDisplay == m_bDisplay) return;
69  m_bDisplay = bDisplay;
70  if (m_Request != INVALID_HANDLE_VALUE) {
71  m_API.ToggleDisplay(m_Request, bDisplay);
72  } else {
73  _UpdateTES();
74  }
75 }
HANDLE m_Request
Definition: CPowerRequest.h:82
CPowerRequestAPI m_API
Definition: CPowerRequest.h:84
void ToggleDisplay(HANDLE hRequest, bool bDisplay)
Definition: CPowerRequest.h:40
void CPowerRequest::SetDisplay ( bool  bDisplay)
inline

Definition at line 95 of file CPowerRequest.h.

95 {}
void CPowerRequest::SetExecution ( bool  bExecution)

Definition at line 57 of file CPowerRequest.cpp.

57  {
58  if (bExecution == m_bSystem) return;
59  m_bSystem = bExecution;
60  if (m_Request != INVALID_HANDLE_VALUE) {
61  m_API.ToggleExecution( m_Request, bExecution );
62  } else {
63  _UpdateTES();
64  }
65 }
void ToggleExecution(HANDLE hRequest, bool bSystem)
Definition: CPowerRequest.h:34
HANDLE m_Request
Definition: CPowerRequest.h:82
CPowerRequestAPI m_API
Definition: CPowerRequest.h:84
void CPowerRequest::SetExecution ( bool  bExecution)
inline

Definition at line 94 of file CPowerRequest.h.

94 {}
void CPowerRequest::SetSystem ( bool  bSystem)

Definition at line 47 of file CPowerRequest.cpp.

47  {
48  if (bSystem == m_bSystem) return;
49  m_bSystem = bSystem;
50  if (m_Request != INVALID_HANDLE_VALUE) {
51  m_API.ToggleSystem( m_Request, bSystem );
52  } else {
53  _UpdateTES();
54  }
55 }
HANDLE m_Request
Definition: CPowerRequest.h:82
CPowerRequestAPI m_API
Definition: CPowerRequest.h:84
void ToggleSystem(HANDLE hRequest, bool bSystem)
Definition: CPowerRequest.h:30
void CPowerRequest::SetSystem ( bool  bSystem)
inline

Definition at line 93 of file CPowerRequest.h.

93 {}

Field Documentation

CPowerRequestAPI CPowerRequest::m_API
private

Definition at line 84 of file CPowerRequest.h.

bool CPowerRequest::m_bDisplay
private

Definition at line 83 of file CPowerRequest.h.

bool CPowerRequest::m_bSystem
private

Definition at line 83 of file CPowerRequest.h.

HANDLE CPowerRequest::m_Request
private

Definition at line 82 of file CPowerRequest.h.


The documentation for this class was generated from the following files: