Public Types | Signals | Public Member Functions | Static Public Attributes

MeeGo::QmHeartbeat Class Reference

QmHeartbeat provides the system heartbeat service. More...

#include <qmheartbeat.h>

List of all members.

Public Types

enum  SignalNeed { NoSignalNeeded = 0, SignalNeeded }
 

Signal needs.

More...
enum  WaitMode { DoNotWaitHeartbeat = 0, WaitHeartbeat }
 

Wait modes.

More...

Signals

void wakeUp (QTime time)
 Signals the wake up.

Public Member Functions

 QmHeartbeat (QObject *parent=0)
 Constructor.
 ~QmHeartbeat ()
bool open (QmHeartbeat::SignalNeed signalNeed)
 Opens the heartbeat service.
void close (void)
 Closes the heartbeat service.
int getFD ()
 Gets the file descriptor for heartbeat (for use with QSocketNotifier).
QTime wait (unsigned short mintime, unsigned short maxtime, QmHeartbeat::WaitMode wait)
 Waits for the next heartbeat.
bool IWokeUp (void)
 Called if the application woke up by itself.

Static Public Attributes

static const unsigned short WAKEUP_SLOT_30_SEC
 30 second wakeup slot
static const unsigned short WAKEUP_SLOT_2_5_MINS
 2.5 minute wakeup slot, the users of the previous slots wake here as well
static const unsigned short WAKEUP_SLOT_5_MINS
 5 minute wakeup slot, the users of the previous slots wake here as well
static const unsigned short WAKEUP_SLOT_10_MINS
 10 minute wakeup slot, the users of the previous slots wake here as well; you can use any multiplication of WAKEUP_SLOT_10_MINS, although it is recommended to use these predefined values
static const unsigned short WAKEUP_SLOT_30_MINS
 30 minute wakeup slot, the users of the previous slots wake here as well
static const unsigned short WAKEUP_SLOT_1_HOUR
 1 hour wakeup slot, the users of the previous slots wake here as well
static const unsigned short WAKEUP_SLOT_2_HOURS
 2 hours wakeup slot, the users of the previous slots wake here as well
static const unsigned short WAKEUP_SLOT_10_HOURS
 10 hours wakeup slot, the users of the previous slots wake here as well

Detailed Description

QmHeartbeat provides the system heartbeat service.

Scope:
Nokia Meego

System heartbeat is a service for applications to synchronize their activities to save the battery use time.

The main idea is that applications that must do periodic activity – after being in sleep a certain period – do that at the same time: for example send network “alive” messages at the same time (for example turn the wireless radio on at the same time).

The service is not only for network-aware applications: in fact it must be used by any applications that need to periodic wake-ups.

"Global sync" predefined values (slots), see wait(unsigned short, unsigned short, QmHeartbeat::WaitMode) function. The timeline is divided into "fixed global slots (GS)" (all waiters for a certain slot are woken up at the same time (also the lower-value waiters).

Note: the Qt Mobility System Information API provides the class QSystemAlignedTimer with similar functionality.

Definition at line 72 of file qmheartbeat.h.


Member Enumeration Documentation

Signal needs.

Enumerator:
NoSignalNeeded 

No signal needed.

SignalNeeded 

Signal is needed.

Definition at line 80 of file qmheartbeat.h.

Wait modes.

Enumerator:
DoNotWaitHeartbeat 

Do not wait for heart beat, use the wakeUp signal instead.

WaitHeartbeat 

Wait for heart beat.

Definition at line 87 of file qmheartbeat.h.


Constructor & Destructor Documentation

MeeGo::QmHeartbeat::QmHeartbeat ( QObject *  parent = 0  ) 

Constructor.

Parameters:
parent The parent object
MeeGo::QmHeartbeat::~QmHeartbeat (  ) 

Member Function Documentation

void MeeGo::QmHeartbeat::close ( void   ) 

Closes the heartbeat service.

int MeeGo::QmHeartbeat::getFD (  ) 

Gets the file descriptor for heartbeat (for use with QSocketNotifier).

Returns:
Descriptor that can be used for QSocketNotifier, -1 if error (check errno)
bool MeeGo::QmHeartbeat::IWokeUp ( void   ) 

Called if the application woke up by itself.

This method should be called if the application has woken up by some other method than via system heartbeat to prevent unnecessary wakeup signals.

Returns:
True if success, false if error
bool MeeGo::QmHeartbeat::open ( QmHeartbeat::SignalNeed  signalNeed  ) 

Opens the heartbeat service.

Parameters:
signalNeed True if wakeUp signal is to be used
Returns:
True if success
QTime MeeGo::QmHeartbeat::wait ( unsigned short  mintime,
unsigned short  maxtime,
QmHeartbeat::WaitMode  wait 
)

Waits for the next heartbeat.

Parameters:
mintime Time in seconds that MUST be waited before heartbeat is reacted to. Value 0 means 'wake me up when someboy else is woken'. It is recommended that the first wait (if possible) uses minvalue as 0 to "jump to the train"
maxtime Time in seconds when the wait MUST end. It is wise to have maxtime-mintime quite big so all users of this service get synced. For example if you preferred wait is 120 seconds, use minval 110 and maxval 130. It is also possible to use "global synchronization" by setting a WAKEUP_SLOT_* value to both mintime and maxtime (same value for both) - you will be waken up when the next proper slot is fired.
wait WaitHeartbeat if this method waits for heartbeat, DoNotWaitHeartbeat if the wakeUp signal or file descriptor for QSocketNotifier is used
Returns:
Time waited
void MeeGo::QmHeartbeat::wakeUp ( QTime  time  )  [signal]

Signals the wake up.

Parameters:
time The wakeup time

Member Data Documentation

const unsigned short MeeGo::QmHeartbeat::WAKEUP_SLOT_10_HOURS [static]

10 hours wakeup slot, the users of the previous slots wake here as well

Definition at line 126 of file qmheartbeat.h.

const unsigned short MeeGo::QmHeartbeat::WAKEUP_SLOT_10_MINS [static]

10 minute wakeup slot, the users of the previous slots wake here as well; you can use any multiplication of WAKEUP_SLOT_10_MINS, although it is recommended to use these predefined values

Definition at line 110 of file qmheartbeat.h.

const unsigned short MeeGo::QmHeartbeat::WAKEUP_SLOT_1_HOUR [static]

1 hour wakeup slot, the users of the previous slots wake here as well

Definition at line 118 of file qmheartbeat.h.

const unsigned short MeeGo::QmHeartbeat::WAKEUP_SLOT_2_5_MINS [static]

2.5 minute wakeup slot, the users of the previous slots wake here as well

Definition at line 100 of file qmheartbeat.h.

const unsigned short MeeGo::QmHeartbeat::WAKEUP_SLOT_2_HOURS [static]

2 hours wakeup slot, the users of the previous slots wake here as well

Definition at line 122 of file qmheartbeat.h.

const unsigned short MeeGo::QmHeartbeat::WAKEUP_SLOT_30_MINS [static]

30 minute wakeup slot, the users of the previous slots wake here as well

Definition at line 114 of file qmheartbeat.h.

const unsigned short MeeGo::QmHeartbeat::WAKEUP_SLOT_30_SEC [static]

30 second wakeup slot

Definition at line 96 of file qmheartbeat.h.

const unsigned short MeeGo::QmHeartbeat::WAKEUP_SLOT_5_MINS [static]

5 minute wakeup slot, the users of the previous slots wake here as well

Definition at line 104 of file qmheartbeat.h.


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