class CMaemoSystemListener

Maemo System listener class, checks for system state changes in Maemo environment.

Inheritance:


Public Methods

[more] CMaemoSystemListener()
Default constructor - not used
[more] CMaemoSystemListener(MAbstractStateConverter* aConverter)
Constructor, initializes necessary variables.
[more] ~CMaemoSystemListener()
Destructor, closes connection to DBUS
[more]bool Connect()
Connects listener into defined DBUS-interface
[more]void Disconnect()
Disconnects the listener from DBUS
[more]void CheckInitialState()
Checks the system state at startup
[more]void CheckState()
Checks the system state
[more]const std::string& GetName()
Returns the name of this listener
[more]bool SetupConnection()
Sets up the connection to DBUS
[more]bool RegisterSignals()
Registers listener to signal(s) and interface(s)
[more]void HandleMessage(DBusMessage* message)
Handles the message (signal) from D-Bus


Inherited from MAbstractListener:


Documentation

The purpose of this class is to check and listen for system state changes in Maemo via DBUS. Usage: periodically calls to CheckState()-function which every time checks the first message in the message queue, if the state can be read from the message appropriate function of owner component is called. Uses a private connection to DBUS for listening messages, registers to com.nokia.mce.signal and com.nokia.bme.signal for listening. System state is requested from com.nokia.mce.request interface at start. This is meant to be used by PeerHood daemon only.
o CMaemoSystemListener()
Cannot be used.

o CMaemoSystemListener(MAbstractStateConverter* aConverter)
Constructor sets the name (hardcoded..) of the listener and registers itself with given component.

Parameters:
aConverter - Component that will own this listener, cannot be NULL!

o ~CMaemoSystemListener()
Destructor only closes the connection to DBUS if it seems to be active. If iConnection isn't NULL it will be closed - closing cannot be checked.

obool Connect()
A facade for conneting the listener to DBUS-interface, actually calls internal functions to set up the connection and to register listener.

Returns:
bool, true if success

ovoid Disconnect()
Disconnects the connection to DBUS (required by private DBUS connection) if the connection wasn't closed earlier.

ovoid CheckInitialState()
Checks the Maemo environment state at startup by sending a pending call (request) into the interface of mce requesting the current state of the system. Function then waits for the answer and sets the state of the daemon corresponding to the state returned by DBUS. Possible states are NORMAL and FLIGHT modes, if the mode is unknown daemon is set to offline/passive mode. Doesn't check the battery state.

ovoid CheckState()
Called periodically by daemon. This function pops the first message from the queue and checks the message for state changes, the queue isn't going to be long because listener has a private connection to DBUS and listens only one interface that sends only messages regarding the system state change. HandleMessage()- function is called to check the message if there is a message in the queue, otherwise nothing is done.

oconst std::string& GetName()
Returns the name that was set in constructor.

obool SetupConnection()
Sets up the private connection to DBUS.

Returns:
true when success, false in case of connection error

obool RegisterSignals()
Registers this listener to com.nokia.mce.signal and com.nokia.bme.signal interfaces for listening system and battery state change messages.

Returns:
true if success, false in case of error

ovoid HandleMessage(DBusMessage* message)
Handles the given message, reacts to signals from com.nokia.mce.signal and com.nokia.bme.signal interfaces. From mce FLIGHT and NORMAL signals are recognized and the state of the connected component is changed accordingly. From bme signals related to battery state changes (battery low, charging) are recognized and reacted. When the battery is on low charge connected component (PeerHood daemon) is set to passive mode.

Parameters:
message - The message to be handled.


This class has no child classes.

Alphabetic index HTML hierarchy of classes or Java



This page was generated with the help of DOC++.