X-Git-Url: https://gerrit.automotivelinux.org/gerrit/gitweb?a=blobdiff_plain;f=sampleapptimedate%2Fsrc%2Ftimedateprovider.cpp;fp=sampleapptimedate%2Fsrc%2Ftimedateprovider.cpp;h=0000000000000000000000000000000000000000;hb=85392e71f90a0322fdc08359ef1d829cdcf67381;hp=2511432fb4cab8a0f649bb4c3230840dac1da76a;hpb=69be38c5d975c96eee7adab238ffd608b99d8514;p=apps%2Fhomescreen.git diff --git a/sampleapptimedate/src/timedateprovider.cpp b/sampleapptimedate/src/timedateprovider.cpp deleted file mode 100644 index 2511432..0000000 --- a/sampleapptimedate/src/timedateprovider.cpp +++ /dev/null @@ -1,76 +0,0 @@ -#include "timedateprovider.hpp" -#include - -TimeDateProvider::TimeDateProvider(QObject *parent) : - QObject(parent), - m_secondsTimerId(-1), - mp_dBusStatusBarProxy(0), - m_statusBarPlaceholder(-1) -{ - qDebug("D-Bus: register as org.agl.SampleAppTimeDate"); - // dbus setup - QDBusConnection dbus = QDBusConnection::sessionBus(); - - dbus.registerObject("/", this); - dbus.registerService("org.agl.sampleapptimedate"); - - - qDebug("D-Bus: connect to org.agl.homescreen /StatusBar"); - mp_dBusStatusBarProxy = new org::agl::statusbar("org.agl.homescreen", - "/StatusBar", - QDBusConnection::sessionBus(), - 0); -} - -TimeDateProvider::~TimeDateProvider() -{ - stop(); - - if (0 != mp_dBusStatusBarProxy) - { - mp_dBusStatusBarProxy->setStatusText(1, ""); - delete mp_dBusStatusBarProxy; - } -} - -void TimeDateProvider::start() -{ - qDebug("trying to start timer (if this lasts long, maybe the Home Screen Application is not launched."); - if ((-1 == m_statusBarPlaceholder) && (0 != mp_dBusStatusBarProxy)) - { - QList availablePlaceholder = mp_dBusStatusBarProxy->getAvailablePlaceholders(); - if (availablePlaceholder.size() > 0) - { - // just take the first available placeholder - m_statusBarPlaceholder = availablePlaceholder[0]; - qDebug("- using statusbar placeholder %d", m_statusBarPlaceholder); - - qDebug("- timer started"); - // callback every second - m_secondsTimerId = startTimer(1000); - } - } -} - -void TimeDateProvider::stop() -{ - if (-1 != m_secondsTimerId) - { - killTimer(m_secondsTimerId); - m_secondsTimerId = -1; - m_statusBarPlaceholder = -1; - } -} - -void TimeDateProvider::timerEvent(QTimerEvent *e) -{ - if (e->timerId() == m_secondsTimerId) - { - if (0 != mp_dBusStatusBarProxy) - { - QString toDisplay = QDateTime::currentDateTime().toString("hh:mm"); - qDebug("%s", toDisplay.toStdString().c_str()); - mp_dBusStatusBarProxy->setStatusText(m_statusBarPlaceholder, toDisplay); - } - } -}