Torc  0.1
Public Member Functions | Static Protected Member Functions | List of all members
TorcPowerOSX Class Referencefinal

A power monitoring class for OS X. More...

#include <torcpowerosx.h>

Inheritance diagram for TorcPowerOSX:
[legend]

Public Member Functions

 TorcPowerOSX ()
 
virtual ~TorcPowerOSX ()
 
bool DoShutdown (void) override
 Shutdown the system. More...
 
bool DoSuspend (void) override
 Suspend the system. More...
 
bool DoHibernate (void) override
 Hibernate the system. More...
 
bool DoRestart (void) override
 Restart the system. More...
 
void Refresh (void)
 Update the current power supply status. More...
 
- Public Member Functions inherited from TorcPower
virtual ~TorcPower ()
 
QString GetUIName (void) override
 
bool event (QEvent *Event) override
 
- Public Member Functions inherited from TorcHTTPService
 TorcHTTPService (QObject *Parent, const QString &Signature, const QString &Name, const QMetaObject &MetaObject, const QString &Blacklist=QStringLiteral(""))
 
virtual ~TorcHTTPService ()
 
void ProcessHTTPRequest (const QString &PeerAddress, int PeerPort, const QString &LocalAddress, int LocalPort, TorcHTTPRequest &Request) override
 
QVariantMap ProcessRequest (const QString &Method, const QVariant &Parameters, QObject *Connection, bool Authenticated) override
 
QString GetMethod (int Index)
 
QVariant GetProperty (int Index)
 Get the value of a given property. More...
 
QVariantMap GetServiceDetails (void)
 Return a QVariantMap describing the services methods and properties. More...
 
virtual QString GetPresentationURL (void)
 
- Public Member Functions inherited from TorcHTTPHandler
 TorcHTTPHandler (const QString &Signature, const QString &Name)
 
virtual ~TorcHTTPHandler ()
 
QString Signature (void) const
 
bool GetRecursive (void) const
 
QString Name (void) const
 

Static Protected Member Functions

static void PowerCallBack (void *Reference, io_service_t Service, natural_t Type, void *Data)
 Receive notification of power status changes. More...
 
static void PowerSourceCallBack (void *Reference)
 Receive notification of changes to the power supply. More...
 
- Static Protected Member Functions inherited from TorcHTTPHandler
static bool MethodIsAuthorised (TorcHTTPRequest &Request, int Allowed)
 Check the current request is authorised and set the authentication header if not. More...
 
static void HandleOptions (TorcHTTPRequest &Request, int Allowed)
 
static void HandleFile (TorcHTTPRequest &Request, const QString &Filename, int Cache)
 

Additional Inherited Members

- Public Types inherited from TorcPower
enum  PowerLevels {
  ACPower = -1, BatteryEmpty = 0, BatteryLow = 10, BatteryFull = 100,
  UnknownPower = 101
}
 
- Public Slots inherited from TorcPower
void SubscriberDeleted (QObject *Subscriber)
 
bool GetCanShutdown (void)
 
bool GetCanSuspend (void)
 
bool GetCanHibernate (void)
 
bool GetCanRestart (void)
 
int GetBatteryLevel (void)
 
QVariantMap GetPowerStatus (void)
 
bool Shutdown (void)
 
bool Suspend (void)
 
bool Hibernate (void)
 
bool Restart (void)
 
void ShuttingDown (void)
 
void Suspending (void)
 
void Hibernating (void)
 
void Restarting (void)
 
void WokeUp (void)
 
void LowBattery (void)
 
- Signals inherited from TorcPower
void CanShutdownChanged (bool CanShutdown)
 
void CanSuspendChanged (bool CanSuspend)
 
void CanHibernateChanged (bool CanHibernate)
 
void CanRestartChanged (bool CanRestart)
 
void BatteryLevelChanged (int BatteryLevel)
 
- Static Public Member Functions inherited from TorcPower
static void Create (void)
 
static void TearDown (void)
 
- Protected Slots inherited from TorcPower
void CanShutdownActiveChanged (bool Active)
 
void CanSuspendActiveChanged (bool Active)
 
void CanHibernateActiveChanged (bool Active)
 
void CanRestartActiveChanged (bool Active)
 
void CanShutdownValueChanged (bool Value)
 
void CanSuspendValueChanged (bool Value)
 
void CanHibernateValueChanged (bool Value)
 
void CanRestartValueChanged (bool Value)
 
- Protected Member Functions inherited from TorcPower
 TorcPower ()
 
void BatteryUpdated (int Level)
 
void Debug (void)
 
- Protected Member Functions inherited from TorcHTTPService
void HandleSubscriberDeleted (QObject *Subscriber)
 
- Protected Attributes inherited from TorcPower
TorcSettingm_canShutdown
 
TorcSettingm_canSuspend
 
TorcSettingm_canHibernate
 
TorcSettingm_canRestart
 
int m_batteryLevel
 
- Protected Attributes inherited from TorcHTTPService
QReadWriteLock m_httpServiceLock
 
- Protected Attributes inherited from TorcHTTPHandler
QString m_signature
 
bool m_recursive
 
QString m_name
 
- Properties inherited from TorcPower
bool canShutdown
 
bool canSuspend
 
bool canHibernate
 
bool canRestart
 
int batteryLevel
 

Detailed Description

A power monitoring class for OS X.

TorcPowerOSX uses the IOKit framework to monitor the system's power status.

See also
TorcRunLoopOSX

Definition at line 12 of file torcpowerosx.h.

Constructor & Destructor Documentation

TorcPowerOSX::TorcPowerOSX ( )

Definition at line 44 of file torcpowerosx.cpp.

TorcPowerOSX::~TorcPowerOSX ( )
virtual

Definition at line 99 of file torcpowerosx.cpp.

Member Function Documentation

bool TorcPowerOSX::DoHibernate ( void  )
overridevirtual

Hibernate the system.

Implements TorcPower.

Definition at line 158 of file torcpowerosx.cpp.

bool TorcPowerOSX::DoRestart ( void  )
overridevirtual

Restart the system.

Implements TorcPower.

Definition at line 164 of file torcpowerosx.cpp.

bool TorcPowerOSX::DoShutdown ( void  )
overridevirtual

Shutdown the system.

Implements TorcPower.

Definition at line 123 of file torcpowerosx.cpp.

bool TorcPowerOSX::DoSuspend ( void  )
overridevirtual

Suspend the system.

Implements TorcPower.

Definition at line 141 of file torcpowerosx.cpp.

void TorcPowerOSX::PowerCallBack ( void *  Reference,
io_service_t  Service,
natural_t  Type,
void *  Data 
)
staticprotected

Receive notification of power status changes.

The OS will call this function when the power state is about to change. We can then make the appropriate internal calls to handle any necessary state changes.

In the case of system requests to ask whether power changes can proceed, we always allow.

Definition at line 243 of file torcpowerosx.cpp.

void TorcPowerOSX::PowerSourceCallBack ( void *  Reference)
staticprotected

Receive notification of changes to the power supply.

Changes may be a change in the battery level or switches between mains power and battery.

Note
This is currently not being called using torc-server from the command line.

Definition at line 288 of file torcpowerosx.cpp.

void TorcPowerOSX::Refresh ( void  )

Update the current power supply status.

A change to the current status is notified from PowerSourceCallback, which calls this method to check for the actual change.

Definition at line 185 of file torcpowerosx.cpp.


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