diff options
author | Leela Prasanna Kumar Chintagunta <leelaprasannakumar.chintagunta@nokia.com> | 2011-05-10 19:01:33 +0530 |
---|---|---|
committer | Leela Prasanna Kumar Chintagunta <leelaprasannakumar.chintagunta@nokia.com> | 2011-05-10 19:01:33 +0530 |
commit | 3bf82d70fcebb107798135d732614c977b1ff435 (patch) | |
tree | 85f5454f9f84f7d7c2a89a2eeb591daaba99155c | |
parent | f17640cb81b71990f826c76219c3c88f0554c0d6 (diff) |
Heartbeattimer -- implementation
-rw-r--r-- | src/systeminfo/qsystemalignedtimer_symbian.cpp | 44 | ||||
-rw-r--r-- | src/systeminfo/qsysteminfocommon_p.h | 4 | ||||
-rw-r--r-- | src/systeminfo/symbian/HeartBeatTimer_s60.cpp | 16 | ||||
-rw-r--r-- | src/systeminfo/systeminfo.pro | 2 |
4 files changed, 43 insertions, 23 deletions
diff --git a/src/systeminfo/qsystemalignedtimer_symbian.cpp b/src/systeminfo/qsystemalignedtimer_symbian.cpp index 0369a5f793..6e8648a072 100644 --- a/src/systeminfo/qsystemalignedtimer_symbian.cpp +++ b/src/systeminfo/qsystemalignedtimer_symbian.cpp @@ -54,27 +54,19 @@ QSystemAlignedTimerPrivate::QSystemAlignedTimerPrivate(QObject *parent) : m_singleShot(false), m_singleShotReceiver(0),m_singleShotMember(0),m_heartbeattimer(0) { TRACES(qDebug() << "QSystemAlignedTimerPrivate--Constructor Start"); - m_heartbeattimer = CHeartbeatTimer::NewL(); - m_heartbeattimer->addObserver(this); TRACES(qDebug() << "QSystemAlignedTimerPrivate--Constructor End"); } QSystemAlignedTimerPrivate::~QSystemAlignedTimerPrivate() { - TRACES(qDebug() << "QSystemAlignedTimerPrivate::~QSystemAlignedTimerPrivate-Start"); - - if (m_heartbeattimer ) { - m_heartbeattimer->removeObserver(this); - delete m_heartbeattimer; - m_heartbeattimer = 0; - } - - TRACES(qDebug() << "QSystemAlignedTimerPrivate::~QSystemAlignedTimerPrivate-End"); + TRACES(qDebug() << "QSystemAlignedTimerPrivate::~QSystemAlignedTimerPrivate-Start"); + TRACES(qDebug() << "QSystemAlignedTimerPrivate::~QSystemAlignedTimerPrivate-End"); } void QSystemAlignedTimerPrivate::wokeUp() { TRACES(qDebug() << "QSystemAlignedTimerPrivate::wokeUp-Start"); + if ( !m_heartbeattimer ) return; if (m_singleShot) { //if singleshot stop the timer @@ -105,12 +97,12 @@ int QSystemAlignedTimerPrivate::maximumInterval() const void QSystemAlignedTimerPrivate::setMaximumInterval(int seconds) { m_maximumInterval = seconds; + TRACES(qDebug() << "SetMaxInterval:" << m_maximumInterval); } void QSystemAlignedTimerPrivate::setSingleShot(bool singleShot) { m_singleShot = singleShot; - m_heartbeattimer->setsingleShot(singleShot); } bool QSystemAlignedTimerPrivate::isSingleShot() const @@ -134,6 +126,7 @@ void QSystemAlignedTimerPrivate::singleShot(int minimumTime, int maximumTime, QO QSystemAlignedTimer::AlignedTimerError QSystemAlignedTimerPrivate::lastError() const { + TRACES(qDebug() << "QSystemAlignedTimerPrivate::lastError:" << m_lastError); return m_lastError; } @@ -149,17 +142,28 @@ void QSystemAlignedTimerPrivate::start(int minimumTime, int maximumTime) void QSystemAlignedTimerPrivate::start() { + TRACES(qDebug() << "QSystemAlignedTimerPrivate::start+"); if (m_running) { TRACES(qDebug() << "QSystemAlignedTimerPrivate::start()-Already Started, return"); return; } + TRACES(qDebug() << "minimum interval:" << m_minimumInterval); + TRACES(qDebug() << "minimum interval:" << m_maximumInterval); + if ( m_minimumInterval < 0 || m_maximumInterval < 0 ) { + TRACES(qDebug() << "m_minimumInterval < 0 || m_maximumInterval < 0 , return"); m_lastError = QSystemAlignedTimer::InvalidArgument; emit error(m_lastError); return; } + if ( !m_heartbeattimer ) { + m_heartbeattimer = CHeartbeatTimer::NewL(); + m_heartbeattimer->setsingleShot(m_singleShot); + m_heartbeattimer->addObserver(this); + } + //Arguments are valid, Go ahead to start the timer TTimeIntervalMicroSeconds window = (m_maximumInterval - m_minimumInterval)* 1000 * 1000; TTimeIntervalMicroSeconds interval = m_maximumInterval * 1000 * 1000; @@ -170,6 +174,7 @@ void QSystemAlignedTimerPrivate::start() m_running = true; m_lastError = QSystemAlignedTimer::NoError; + TRACES(qDebug() << "QSystemAlignedTimerPrivate::start-"); } void QSystemAlignedTimerPrivate::stop() @@ -177,9 +182,15 @@ void QSystemAlignedTimerPrivate::stop() if (!m_running) { return; } - TRACES(qDebug() << "QSystemAlignedTimerPrivate::stop()-Issuing stop request"); - //Do heartbeattimer here - m_heartbeattimer->StopTimer(); + + if ( m_heartbeattimer ) { + TRACES(qDebug() << "QSystemAlignedTimerPrivate::stop()-Issuing stop request"); + //Do heartbeattimer here + m_heartbeattimer->StopTimer(); + m_heartbeattimer->removeObserver(this); + delete m_heartbeattimer; + m_heartbeattimer = 0; + } m_running = false; m_lastError = QSystemAlignedTimer::NoError; @@ -190,6 +201,7 @@ void QSystemAlignedTimerPrivate::NotifyheartbeatReceived() TRACES(qDebug() << "QSystemAlignedTimerPrivate::NotiftyheartbeatReceived()"); //Check if there are any single shot members. //Issuing or (Not to issue) of timer is taken care by CHeartbeatTimer + if (m_singleShot) m_running = false; if (m_singleShotMember != NULL && m_singleShotMember !=NULL ) { TRACES(qDebug() << "Single shot members exist"); @@ -204,6 +216,8 @@ void QSystemAlignedTimerPrivate::NotifyheartbeatReceived() bool QSystemAlignedTimerPrivate::isActive () const { + TRACES(qDebug() << "QSystemAlignedTimerPrivate::isActive+"); + TRACES(qDebug() << "State :" << m_running); return m_running; } diff --git a/src/systeminfo/qsysteminfocommon_p.h b/src/systeminfo/qsysteminfocommon_p.h index 59f856e722..d1d2104211 100644 --- a/src/systeminfo/qsysteminfocommon_p.h +++ b/src/systeminfo/qsysteminfocommon_p.h @@ -75,8 +75,10 @@ #if defined(ALIGNEDTIMER_MEEGO) #include "qsystemalignedtimer_meego_p.h" +#elif defined(ALIGNEDTIMER_SYMBIAN) +#include "qsystemalignedtimer_symbian_p.h" #else #include "qsystemalignedtimer_stub_p.h" -#endif // ALIGNEDTIMER_MEEGO +#endif #endif // QSYSTEMINFOCOMMON_H diff --git a/src/systeminfo/symbian/HeartBeatTimer_s60.cpp b/src/systeminfo/symbian/HeartBeatTimer_s60.cpp index 98451b1358..a418462a88 100644 --- a/src/systeminfo/symbian/HeartBeatTimer_s60.cpp +++ b/src/systeminfo/symbian/HeartBeatTimer_s60.cpp @@ -98,18 +98,22 @@ void CHeartbeatTimer::RunL() if (iStatus == KErrNone) { TRACES(qDebug() << "CHeartbeatTimer::RunL()->TimerExpired"); + TRACES(qDebug() << "CHeartbeatTimer::Notify observers Start"); + foreach (MHeartBeatObserver *observer, m_observers) { + TRACES(qDebug() << "observer...:" << observer); observer->NotifyheartbeatReceived(); } - if (m_singleShot == false) CFlexTimer::After(m_interval); //Refresh timer if not singleshot - } - if (iStatus == KErrCancel ) { - TRACES(qDebug() << "CHeartbeatTimer::RunL->TimerCancelled"); - //Take some action ??? + TRACES(qDebug() << "CHeartbeatTimer::Notify observers End"); + if (m_singleShot == false) { + TRACES(qDebug() << "Timer is non-single shot"); + CFlexTimer::After(m_interval); //Refresh timer if not singleshot + } } + TRACES(qDebug() << "CHeartbeatTimer::RunL()-End"); } @@ -160,5 +164,5 @@ void CHeartbeatTimer::ResetTimer() TRACES(qDebug() << "iStatus:" << iStatus.Int()); CFlexTimer::Cancel(); CFlexTimer::After(m_interval); - TRACES(qDebug() << "CHeartbeatTimer::StopTimer-End"); + TRACES(qDebug() << "CHeartbeatTimer::ResetTimer-End"); } diff --git a/src/systeminfo/systeminfo.pro b/src/systeminfo/systeminfo.pro index 5932cf1911..9f43900dd4 100644 --- a/src/systeminfo/systeminfo.pro +++ b/src/systeminfo/systeminfo.pro @@ -254,7 +254,7 @@ unix:!simulator { LIBS += -lptiengine } - contains(symbianflextimer_tenabled, yes) { #disabled until test crash is fixed + contains(symbianflextimer_enabled, yes) { #disabled until test crash is fixed message("SymbianFlexTimer enabled") SOURCES += qsystemalignedtimer_symbian.cpp heartbeattimer_s60.cpp HEADERS += qsystemalignedtimer_symbian_p.h heartbeattimer_s60.h |