2
* Copyright 2007 Aaron Seigo <aseigo@kde.org>
3
* Copyright 2008 Alex Merry <alex.merry@kdemail.net>
5
* This program is free software; you can redistribute it and/or modify
6
* it under the terms of the GNU Library General Public License as
7
* published by the Free Software Foundation; either version 2 or
8
* (at your option) any later version.
10
* This program is distributed in the hope that it will be useful,
11
* but WITHOUT ANY WARRANTY; without even the implied warranty of
12
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
* GNU General Public License for more details
15
* You should have received a copy of the GNU Library General Public
16
* License along with this program; if not, write to the
17
* Free Software Foundation, Inc.,
18
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
21
#include "timeengine.h"
24
#include <QDBusConnection>
25
#include <QStringList>
29
#include <KSystemTimeZones>
32
#include "timesource.h"
34
//timezone is defined in msvc
39
TimeEngine::TimeEngine(QObject *parent, const QVariantList &args)
40
: Plasma::DataEngine(parent, args)
43
setMinimumPollingInterval(333);
45
// To have translated timezone names
46
// (effectively a noop if the catalog is already present).
47
KGlobal::locale()->insertCatalog("timezones4");
50
TimeEngine::~TimeEngine()
54
void TimeEngine::init()
56
//QDBusInterface *ktimezoned = new QDBusInterface("org.kde.kded", "/modules/ktimezoned", "org.kde.KTimeZoned");
57
QDBusConnection dbus = QDBusConnection::sessionBus();
58
dbus.connect(QString(), QString(), "org.kde.KTimeZoned", "configChanged", this, SLOT(tzConfigChanged()));
59
dbus.connect("org.kde.Solid.PowerManagement", "/org/kde/Solid/PowerManagement", "org.kde.Solid.PowerManagement", "resumingFromSuspend", this, SLOT(clockSkewed()));
62
void TimeEngine::clockSkewed()
64
kDebug() << "Time engine Clock skew signaled";
66
forceImmediateUpdateOfAllVisualizations();
69
void TimeEngine::tzConfigChanged()
71
TimeSource *s = qobject_cast<TimeSource *>(containerForSource("Local"));
74
s->setTimeZone("Local");
80
QStringList TimeEngine::sources() const
82
QStringList timezones(KSystemTimeZones::zones().keys());
87
bool TimeEngine::sourceRequestEvent(const QString &name)
89
addSource(new TimeSource(name, this));
93
bool TimeEngine::updateSourceEvent(const QString &tz)
95
TimeSource *s = qobject_cast<TimeSource *>(containerForSource(tz));
99
scheduleSourcesUpdated();
106
K_EXPORT_PLASMA_DATAENGINE(time, TimeEngine)
108
#include "timeengine.moc"