logo       

branches/KDE/4.3/kdebase/runtime/ktimezoned: msg#12963

kde-commits

Subject: branches/KDE/4.3/kdebase/runtime/ktimezoned

SVN commit 1005249 by winterz:

backport SVN commit 1005130 by tilladam:

Implementation of a timezone daemon for Windows that watches the registry and
emits a dbus signal when the current timezone changes. This requires some
refactoring of shared implementation into a base class for the unix and Windows
implementations. Reviewed by David Jarvie.


M +7 -2 CMakeLists.txt
M +6 -16 ktimezoned.cpp
M +4 -24 ktimezoned.h
A ktimezoned_win.cpp
trunk/KDE/kdebase/runtime/ktimezoned/ktimezoned_win.cpp#1005130 [License: LGPL
(v2+)]
A ktimezoned_win.h
trunk/KDE/kdebase/runtime/ktimezoned/ktimezoned_win.h#1005130 [License: LGPL
(v2+)]
A ktimezonedbase.h
trunk/KDE/kdebase/runtime/ktimezoned/ktimezonedbase.h#1005130 [License: LGPL
(v2+)]


--- branches/KDE/4.3/kdebase/runtime/ktimezoned/CMakeLists.txt #1005248:1005249
@@ -1,6 +1,9 @@
-set(kded_ktimezoned_SRCS ktimezoned.cpp)
+if (WIN32)
+ set(kded_ktimezoned_SRCS ktimezoned_win.cpp)
+else (WIN32)
+ set(kded_ktimezoned_SRCS ktimezoned.cpp)
+endif (WIN32)

-
kde4_add_plugin(kded_ktimezoned ${kded_ktimezoned_SRCS})

#qt4_add_dbus_adaptor(kded_ktimezoned_SRCS org.kde.KTimeZoned ktimezonedbus.h
DBusHandler)
@@ -13,3 +16,5 @@

install( FILES ktimezoned.desktop DESTINATION ${SERVICES_INSTALL_DIR}/kded )
install( FILES org.kde.KTimeZoned.xml DESTINATION
${DBUS_INTERFACES_INSTALL_DIR} )
+
+
--- branches/KDE/4.3/kdebase/runtime/ktimezoned/ktimezoned.cpp #1005248:1005249
@@ -20,6 +20,7 @@
*/

#include "ktimezoned.moc"
+#include "ktimezonedbase.moc"

#include <climits>
#include <cstdlib>
@@ -57,8 +58,8 @@
const char LOCAL_ZONE[] = "LocalZone"; // name of local time zone


-KTimeZoned::KTimeZoned(QObject* parent, const QList<QVariant>&)
- : KDEDModule(parent),
+KTimeZoned::KTimeZoned(QObject* parent, const QList<QVariant>& l)
+ : KTimeZonedBase(parent, l),
mSource(0),
mZonetabWatch(0),
mDirWatch(0)
@@ -76,14 +77,6 @@
mDirWatch = 0;
}

-void KTimeZoned::initialize(bool reinit)
-{
- // If we reach here, the module has already been constructed and therefore
- // initialized. So only do anything if reinit is true.
- if (reinit)
- init(true);
-}
-
void KTimeZoned::init(bool restart)
{
if (restart)
@@ -97,11 +90,6 @@
mDirWatch = 0;
}

-#ifdef Q_OS_WIN
- // On Windows, HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows
NT\CurrentVersion\Time Zones
- // holds the time zone database. The TZI binary value is the
TIME_ZONE_INFORMATION structure.
-#else
- // For Unix, read zone.tab.
KConfig config(QLatin1String("ktimezonedrc"));
if (restart)
config.reparseConfiguration();
@@ -111,6 +99,9 @@
mConfigLocalZone = group.readEntry(LOCAL_ZONE);
QString ztc = group.readEntry(ZONE_TAB_CACHE, QString());
mZoneTabCache = (ztc == "Solaris") ? Solaris : NoCache;
+
+ // For Unix, read zone.tab.
+
QString oldZoneinfoDir = mZoneinfoDir;
QString oldZoneTab = mZoneTab;
CacheType oldCacheType = mZoneTabCache;
@@ -164,7 +155,6 @@
mZonetabWatch = new KDirWatch(this);
mZonetabWatch->addFile(mZoneTab);
connect(mZonetabWatch, SIGNAL(dirty(const QString&)),
SLOT(zonetab_Changed(const QString&)));
-#endif

// Find the local system time zone and set up file monitors to detect
changes
findLocalZone();
--- branches/KDE/4.3/kdebase/runtime/ktimezoned/ktimezoned.h #1005248:1005249
@@ -21,6 +21,8 @@
#ifndef KTIMEZONED_H
#define KTIMEZONED_H

+#include "ktimezonedbase.h"
+
#include <QString>
#include <QByteArray>
class QFile;
@@ -30,35 +32,14 @@
#include <ksystemtimezone.h>


-class KTimeZoned : public KDEDModule
+class KTimeZoned : public KTimeZonedBase
{
Q_OBJECT
- Q_CLASSINFO("D-Bus Interface", "org.kde.KTimeZoned")

public:
KTimeZoned(QObject* parent, const QList<QVariant>&);
~KTimeZoned();

- public Q_SLOTS:
- /** D-Bus call to initialize the module.
- * @param reinit determines whether to reinitialize if the module has
already
- * initialized itself
- */
- Q_SCRIPTABLE void initialize(bool reinit);
-
- Q_SIGNALS:
- /** D-Bus signal emitted when the time zone configuration file has
changed. */
- void configChanged();
- /** D-Bus signal emitted when zone.tab contents have changed.
- * @param zonetab path to zone.tab
- */
- void zonetabChanged(const QString &zonetab);
- /** D-Bus signal emitted when the definition (not the identity) of the
local
- * system time zone has changed.
- * @param zone path to time zone definition file
- */
- void zoneDefinitionChanged(const QString &zone);
-
private Q_SLOTS:
void zonetab_Changed(const QString& path);
void localChanged(const QString& path);
@@ -90,6 +71,7 @@
};
typedef QMap<QString, QString> MD5Map; // zone name, checksum

+ /** reimp */
void init(bool restart);
bool findZoneTab(QFile& f);
void readZoneTab(QFile& f);
@@ -110,8 +92,6 @@
QByteArray mSavedTZ; // last value of TZ if it's used to
set local zone
KSystemTimeZoneSource *mSource;
KTimeZones mZones; // time zones collection
- QString mLocalZone; // local system time zone name
- QString mConfigLocalZone; // local system time zone name as
stored in config file
QString mLocalIdFile; // file containing pointer to local
time zone definition
QString mLocalZoneDataFile; // zoneinfo file containing local time
zone definition
QString mLocaltimeMd5Sum; // MD5 checksum of /etc/localtime

<Prev in Thread] Current Thread [Next in Thread>
Google Custom Search

News | Mail Home | sitemap | FAQ | advertise