Torc  0.1
Public Types | Public Slots | Signals | Public Member Functions | Static Public Member Functions | Protected Slots | Protected Member Functions | Protected Attributes | Properties | List of all members
TorcPower Class Referenceabstract

A generic power status class. More...

#include <torcpower.h>

Inheritance diagram for TorcPower:
[legend]

Public Types

enum  PowerLevels {
  ACPower = -1, BatteryEmpty = 0, BatteryLow = 10, BatteryFull = 100,
  UnknownPower = 101
}
 

Public Slots

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

void CanShutdownChanged (bool CanShutdown)
 
void CanSuspendChanged (bool CanSuspend)
 
void CanHibernateChanged (bool CanHibernate)
 
void CanRestartChanged (bool CanRestart)
 
void BatteryLevelChanged (int BatteryLevel)
 

Public Member Functions

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 Public Member Functions

static void Create (void)
 
static void TearDown (void)
 

Protected Slots

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

 TorcPower ()
 
void BatteryUpdated (int Level)
 
void Debug (void)
 
virtual bool DoShutdown (void)=0
 
virtual bool DoSuspend (void)=0
 
virtual bool DoHibernate (void)=0
 
virtual bool DoRestart (void)=0
 
- Protected Member Functions inherited from TorcHTTPService
void HandleSubscriberDeleted (QObject *Subscriber)
 

Protected Attributes

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

bool canShutdown
 
bool canSuspend
 
bool canHibernate
 
bool canRestart
 
int batteryLevel
 

Additional Inherited Members

- 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)
 

Detailed Description

A generic power status class.

TorcPower uses underlying platform implementations to monitor the system's power status and emits appropriate notifications (via TorcLocalContext) when the status changes. Additional implementations can be added by sub-classing PowerFactory and TorcPowerPriv.

The current power status (battery charge level or on mains power) can be queried directly via GetBatteryLevel and the system's ability to Suspend/Shutdown etc can be queried via CanSuspend, CanShutdown, CanHibernate and CanRestart.

A singleton power object is created by TorcPowerObject from within the administration thread

Note
Locking in TorcPower is complicated by the public TorcSetting's that are HTTP services in their own right. TorcSetting is however extensively locked for this reason.
See also
TorcPowerFactory
TorcPowerObject

Definition at line 12 of file torcpower.h.

Member Enumeration Documentation

Enumerator
ACPower 
BatteryEmpty 
BatteryLow 
BatteryFull 
UnknownPower 

Definition at line 27 of file torcpower.h.

Constructor & Destructor Documentation

TorcPower::~TorcPower ( )
virtual

Definition at line 198 of file torcpower.cpp.

TorcPower::TorcPower ( )
protected

Definition at line 118 of file torcpower.cpp.

Member Function Documentation

void TorcPower::BatteryLevelChanged ( int  BatteryLevel)
signal
void TorcPower::BatteryUpdated ( int  Level)
protected

Definition at line 275 of file torcpower.cpp.

void TorcPower::CanHibernateActiveChanged ( bool  Active)
protectedslot

Definition at line 450 of file torcpower.cpp.

void TorcPower::CanHibernateChanged ( bool  CanHibernate)
signal
void TorcPower::CanHibernateValueChanged ( bool  Value)
protectedslot

Definition at line 458 of file torcpower.cpp.

void TorcPower::CanRestartActiveChanged ( bool  Active)
protectedslot

Definition at line 466 of file torcpower.cpp.

void TorcPower::CanRestartChanged ( bool  CanRestart)
signal
void TorcPower::CanRestartValueChanged ( bool  Value)
protectedslot

Definition at line 474 of file torcpower.cpp.

void TorcPower::CanShutdownActiveChanged ( bool  Active)
protectedslot

Definition at line 418 of file torcpower.cpp.

void TorcPower::CanShutdownChanged ( bool  CanShutdown)
signal
void TorcPower::CanShutdownValueChanged ( bool  Value)
protectedslot

Definition at line 426 of file torcpower.cpp.

void TorcPower::CanSuspendActiveChanged ( bool  Active)
protectedslot

Definition at line 434 of file torcpower.cpp.

void TorcPower::CanSuspendChanged ( bool  CanSuspend)
signal
void TorcPower::CanSuspendValueChanged ( bool  Value)
protectedslot

Definition at line 442 of file torcpower.cpp.

static void TorcPower::Create ( void  )
static
void TorcPower::Debug ( void  )
protected

Definition at line 251 of file torcpower.cpp.

virtual bool TorcPower::DoHibernate ( void  )
protectedpure virtual
virtual bool TorcPower::DoRestart ( void  )
protectedpure virtual
virtual bool TorcPower::DoShutdown ( void  )
protectedpure virtual
virtual bool TorcPower::DoSuspend ( void  )
protectedpure virtual
bool TorcPower::event ( QEvent *  Event)
override

Definition at line 306 of file torcpower.cpp.

int TorcPower::GetBatteryLevel ( void  )
slot

Definition at line 410 of file torcpower.cpp.

bool TorcPower::GetCanHibernate ( void  )
slot

Definition at line 394 of file torcpower.cpp.

bool TorcPower::GetCanRestart ( void  )
slot

Definition at line 402 of file torcpower.cpp.

bool TorcPower::GetCanShutdown ( void  )
slot

Definition at line 378 of file torcpower.cpp.

bool TorcPower::GetCanSuspend ( void  )
slot

Definition at line 386 of file torcpower.cpp.

QVariantMap TorcPower::GetPowerStatus ( void  )
slot

Definition at line 482 of file torcpower.cpp.

QString TorcPower::GetUIName ( void  )
overridevirtual

Reimplemented from TorcHTTPService.

Definition at line 270 of file torcpower.cpp.

bool TorcPower::Hibernate ( void  )
slot

Definition at line 351 of file torcpower.cpp.

void TorcPower::Hibernating ( void  )
slot

Definition at line 505 of file torcpower.cpp.

void TorcPower::LowBattery ( void  )
slot

Definition at line 523 of file torcpower.cpp.

bool TorcPower::Restart ( void  )
slot

Definition at line 362 of file torcpower.cpp.

void TorcPower::Restarting ( void  )
slot

Definition at line 511 of file torcpower.cpp.

bool TorcPower::Shutdown ( void  )
slot

Definition at line 329 of file torcpower.cpp.

void TorcPower::ShuttingDown ( void  )
slot

Definition at line 493 of file torcpower.cpp.

void TorcPower::SubscriberDeleted ( QObject *  Subscriber)
slot

Definition at line 373 of file torcpower.cpp.

bool TorcPower::Suspend ( void  )
slot

Definition at line 340 of file torcpower.cpp.

void TorcPower::Suspending ( void  )
slot

Definition at line 499 of file torcpower.cpp.

static void TorcPower::TearDown ( void  )
static
void TorcPower::WokeUp ( void  )
slot

Definition at line 517 of file torcpower.cpp.

Member Data Documentation

int TorcPower::m_batteryLevel
protected

Definition at line 97 of file torcpower.h.

TorcSetting* TorcPower::m_canHibernate
protected

Definition at line 95 of file torcpower.h.

TorcSetting* TorcPower::m_canRestart
protected

Definition at line 96 of file torcpower.h.

TorcSetting* TorcPower::m_canShutdown
protected

Definition at line 93 of file torcpower.h.

TorcSetting* TorcPower::m_canSuspend
protected

Definition at line 94 of file torcpower.h.

Property Documentation

int TorcPower::batteryLevel
read

Definition at line 24 of file torcpower.h.

bool TorcPower::canHibernate
read

Definition at line 22 of file torcpower.h.

bool TorcPower::canRestart
read

Definition at line 23 of file torcpower.h.

bool TorcPower::canShutdown
read

Definition at line 20 of file torcpower.h.

bool TorcPower::canSuspend
read

Definition at line 21 of file torcpower.h.


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