PM_Interface Class Reference

global object for abstraction of acpi and apm More...

#include <pm_interface.h>

Inheritance diagram for PM_Interface:

ACPI_Interface APM_Interface List of all members.

Public Member Functions

 PM_Interface ()
 constructor setting up the object
virtual ~PM_Interface ()
 destructor freeing all members
BATTERY_STATES batteryState ()
 get the current state the battery is in
void sleep_wrapper (const string &)
 internal action which is executed directly before and after do_suspend_* should go into this function
int executeScript (const string &script, const string &param)
 used to execute scripts in INT_SCRIPT_PATH
int screenlock (const string &param)
 triggers a screenlock either from a client or script
int x_notification (const string &param)
 triggers a notification for the user
void ignore_buttons (bool)
 sets if we ignore button events
virtual int start ()
 starts the pm_object
virtual void checkTemperatureStateChanges ()
 checks for temperature events and executes appropriate events
virtual void checkBatteryStateChanges ()
 Checks for Battery State changes (when AC adapter is not plugged in) and throws appropriate event.
virtual int checkACStateChanges ()
 Checks for AC state changes and throws appropraite events.
virtual int updateTemperatureState ()
 update temperature state
virtual int updateACState ()
 updates ACState
virtual bool checkThrottling ()
 updates the cpu state and throws appropriate events
void checkDevice (char *udi, bool added)
 check if a removed/added device belongs to us
virtual int activateScheme (const string &scheme_name)
 switches settings to a possibly new scheme and activates them
virtual int activateScheme (AC_ADAPTER_STATE ac_state)
 switches scheme according to ac_state
virtual void activateSettings ()
 Activate scheme settings.
virtual int rereadConfig ()
 reread config files.
virtual void throttle (int percent=-1)
 throttles the cpu
virtual void dethrottle ()
 dethrottles the cpu
virtual void resume ()
 called when coming back from suspend
DBUS_ERROR handleDBusRequest (DBusMessage *req, DBusMessage *reply, POWERSAVE_MESSAGE_TYPE type)
 handles a dbus request
virtual int suspend_to_ram ()=0
 triggers suspend to ram
virtual int standby ()=0
 triggers standby
virtual int openHWEventFD ()=0
 opens the event fd
virtual int openAcpidSocket ()=0
 opens the acpid socket
virtual int handleHWEventRequest (int fd=-1)=0
 handles a request on the event socket/fd
void suspendNetworkManager ()
 sends a sleep signal to the networkmanager
void resumeNetworkManager ()
 sends a wake signal to the networkmanager
bool haveSuspend2 ()
 check whether we have a suspend2 enabled kernel

Public Attributes

ClientConnection_cC
 object to manage clients connected to the daemon
EventManagement_eM
 object to manage running events
Brightness_brightness
 object implementing brightness functionality on some laptops

Protected Attributes

bool _cooling_mode_supported
 defines whether cooling mode is supported
bool _thermal_trip_points_supported
 defines whether thermal trip points are supported
PM_STATE _cur_state
 the current pm state contianing e.g. battery, thermal and cpu info
int64_t _supported_sleeping_states
 defines the supported sleeping states
ThrottleInterface _throttleInterface
 object caring about throttling
Battery _battery
 battery object represention one single battery

Static Protected Attributes

static PSD_SLEEP_STATE_REQUESTS _requested_sleep_state = PSD_NO_SLEEP_REQUEST
 used for workaround for apm to remembemer triggered sleep state, for ACPI to discard button events during resume
static bool _sleep_triggered = false
 defines whether sleep was triggered before

Private Member Functions

DBUS_ERROR handleManagerMessage (DBusMessage *msg)
 handles a message on the manager interface
DBUS_ERROR handleScriptsMessage (DBusMessage *msg)
 handles a message on the events interface
DBUS_ERROR handleRequestMessage (DBusMessage *msg, DBusMessage *reply)
 handles a message on the request interface
DBUS_ERROR handleActionMessage (DBusMessage *msg)
 handles a message on the request interface

Private Attributes

DeviceManagement _devices
 object caring about powermanagable devices

Detailed Description

global object for abstraction of acpi and apm

mainly an abstraction of apm/acpi but contains other things like ac adapter handling which maybe moves to own class in future.


Constructor & Destructor Documentation

PM_Interface::PM_Interface  ) 
 

constructor setting up the object

PM_Interface::~PM_Interface  )  [virtual]
 

destructor freeing all members


Member Function Documentation

int PM_Interface::activateScheme AC_ADAPTER_STATE  ac_state  )  [virtual]
 

switches scheme according to ac_state

Parameters:
ac_state any ac adapter status
Returns:
integer with result whether the scheme could (not) be set or is already set.
Return values:
-1 if scheme does not exist
0 if scheme is already set
1 if scheme has been successfully set

int PM_Interface::activateScheme const string &  scheme_name  )  [virtual]
 

switches settings to a possibly new scheme and activates them

Returns:
integer with result whether the scheme could (not) be set or is already set.
Return values:
-1 if scheme does not exist
0 if scheme is already set
1 if scheme has been successfully set

void PM_Interface::activateSettings  )  [virtual]
 

Activate scheme settings.

Inheriting functions in APM_Interface and ACPI_Interface set them specifically for APM/ACPI

Add additional code that is needed after activating a new scheme or after re-reading configurations here (e.g. brightness?)

Be aware that first the inhereting functions in the ACPI/APM_Interface layer are called

Reimplemented in ACPI_Interface, and APM_Interface.

BATTERY_STATES PM_Interface::batteryState  ) 
 

get the current state the battery is in

Returns:
the current battery state

int PM_Interface::checkACStateChanges  )  [virtual]
 

Checks for AC state changes and throws appropraite events.

if AC changes to offline, also battery state changes will be checked

Returns:
integer with state of AC
Return values:
0 if AC state has not changed
1 if AC state has changed
-1 if an error occur

void PM_Interface::checkBatteryStateChanges  )  [virtual]
 

Checks for Battery State changes (when AC adapter is not plugged in) and throws appropriate event.

Be careful in ACPI you have to check whether the battery alarm also needs to be set

void PM_Interface::checkDevice char *  udi,
bool  added
 

check if a removed/added device belongs to us

calls the appropriate functions out of DeviceManagement

Parameters:
udi the device udi which got removed/added
added if the device was added

void PM_Interface::checkTemperatureStateChanges  )  [virtual]
 

checks for temperature events and executes appropriate events

bool PM_Interface::checkThrottling  )  [virtual]
 

updates the cpu state and throws appropriate events

void PM_Interface::dethrottle  )  [virtual]
 

dethrottles the cpu

Only dethrottle if temperature is in unknown, ok or active state. Otherwise kernel may have throttled ...

int PM_Interface::executeScript const string &  script,
const string &  param
 

used to execute scripts in INT_SCRIPT_PATH

DBUS_ERROR PM_Interface::handleActionMessage DBusMessage *  msg  )  [private]
 

handles a message on the request interface

Parameters:
msg the dbus message received
Returns:
DBUS_ERROR

DBUS_ERROR PM_Interface::handleDBusRequest DBusMessage *  req,
DBusMessage *  reply,
POWERSAVE_MESSAGE_TYPE  type
 

handles a dbus request

Parameters:
req the dbus message containing the request
reply dbus message which should be filled with a reply
type one of REQUEST_MESSAGE, ACTION_MESSAGE or MANAGER_MESSAGE
Returns:
DBUS_ERROR

virtual int PM_Interface::handleHWEventRequest int  fd = -1  )  [pure virtual]
 

handles a request on the event socket/fd

has to be implemented in derived classes (only acpi)

Implemented in ACPI_Interface, and APM_Interface.

DBUS_ERROR PM_Interface::handleManagerMessage DBusMessage *  msg  )  [private]
 

handles a message on the manager interface

Parameters:
msg the dbus message received
Returns:
DBUS_ERROR

DBUS_ERROR PM_Interface::handleRequestMessage DBusMessage *  msg,
DBusMessage *  reply
[private]
 

handles a message on the request interface

Parameters:
msg the dbus message received
reply the dbus reply to send back
Returns:
DBUS_ERROR

DBUS_ERROR PM_Interface::handleScriptsMessage DBusMessage *  msg  )  [private]
 

handles a message on the events interface

Parameters:
msg the dbus message received
Returns:
DBUS_ERROR

bool PM_Interface::haveSuspend2  ) 
 

check whether we have a suspend2 enabled kernel

Returns:
true if suspend2 is enabled, false otherwise

void PM_Interface::ignore_buttons bool   ) 
 

sets if we ignore button events

virtual int PM_Interface::openAcpidSocket  )  [pure virtual]
 

opens the acpid socket

has to be implemented in derived classes (only acpi)

Implemented in ACPI_Interface, and APM_Interface.

virtual int PM_Interface::openHWEventFD  )  [pure virtual]
 

opens the event fd

has to be implemented in derived classes (apm/acpi)

Implemented in ACPI_Interface, and APM_Interface.

int PM_Interface::rereadConfig  )  [virtual]
 

reread config files.

void PM_Interface::resume  )  [virtual]
 

called when coming back from suspend

updates ac state, battery state and adjust speeds

void PM_Interface::resumeNetworkManager  ) 
 

sends a wake signal to the networkmanager

it only sends the signal if the NetworkManager can be found

int PM_Interface::screenlock const string &  param  ) 
 

triggers a screenlock either from a client or script

emits a screenlock signal over the bus and checks if a client with capability screenlock is connected. If not, execute script to lock the screen

void PM_Interface::sleep_wrapper const string &   ) 
 

internal action which is executed directly before and after do_suspend_* should go into this function

virtual int PM_Interface::standby  )  [pure virtual]
 

triggers standby

has to be implemented in derived classes (apm/acpi)

Implemented in ACPI_Interface, and APM_Interface.

int PM_Interface::start  )  [virtual]
 

starts the pm_object

throws appropriate ac adapter/battery events and initializes the active scheme

virtual int PM_Interface::suspend_to_ram  )  [pure virtual]
 

triggers suspend to ram

has to be implemented in derived classes (apm/acpi)

Implemented in ACPI_Interface, and APM_Interface.

void PM_Interface::suspendNetworkManager  ) 
 

sends a sleep signal to the networkmanager

it only sends the signal if the NetworkManager can be found

void PM_Interface::throttle int  percent = -1  )  [virtual]
 

throttles the cpu

Only throttle if temperature is in unknown, ok or active state. Otherwise kernel may have throttled ...

int PM_Interface::updateACState  )  [virtual]
 

updates ACState

Returns:
integer with result of check for changes
Return values:
0 if AC state did not change
1 else

int PM_Interface::updateTemperatureState  )  [virtual]
 

update temperature state

Returns:
integer with state of temperature
Return values:
-1 on failure
0 when state did not change
1 when a more critical temperature level is reached
2 when a less critical battery level is reached

int PM_Interface::x_notification const string &  param  ) 
 

triggers a notification for the user

emits a notification signal over the bus and checks if a client with capability notifications is connected. If not, execute script to display the notification


Member Data Documentation

Battery PM_Interface::_battery [protected]
 

battery object represention one single battery

Brightness* PM_Interface::_brightness
 

object implementing brightness functionality on some laptops

ClientConnection* PM_Interface::_cC
 

object to manage clients connected to the daemon

bool PM_Interface::_cooling_mode_supported [protected]
 

defines whether cooling mode is supported

PM_STATE PM_Interface::_cur_state [protected]
 

the current pm state contianing e.g. battery, thermal and cpu info

DeviceManagement PM_Interface::_devices [private]
 

object caring about powermanagable devices

EventManagement* PM_Interface::_eM
 

object to manage running events

PSD_SLEEP_STATE_REQUESTS PM_Interface::_requested_sleep_state = PSD_NO_SLEEP_REQUEST [static, protected]
 

used for workaround for apm to remembemer triggered sleep state, for ACPI to discard button events during resume

bool PM_Interface::_sleep_triggered = false [static, protected]
 

defines whether sleep was triggered before

int64_t PM_Interface::_supported_sleeping_states [protected]
 

defines the supported sleeping states

bool PM_Interface::_thermal_trip_points_supported [protected]
 

defines whether thermal trip points are supported

ThrottleInterface PM_Interface::_throttleInterface [protected]
 

object caring about throttling


The documentation for this class was generated from the following files:
Generated on Mon Mar 27 09:27:20 2006 for Powersave Daemon by  doxygen 1.4.6