delay a few things on startup, such as setting the visibility mode, which ensures...
[personal-kdebase.git] / runtime / ktimezoned / ktimezoned.h
blob3c26d306270db2d179971796199b6e4f4d199c22
1 /*
2 This file is part of the KDE libraries
3 Copyright (c) 2007 David Jarvie <software@astrojar.org.uk>
5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Library General Public
7 License as published by the Free Software Foundation; either
8 version 2 of the License, or (at your option) any later version.
10 This library 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 GNU
13 Library General Public License for more details.
15 You should have received a copy of the GNU Library General Public License
16 along with this library; see the file COPYING.LIB. If not, write to
17 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18 Boston, MA 02110-1301, USA.
21 #ifndef KTIMEZONED_H
22 #define KTIMEZONED_H
24 #include <QString>
25 #include <QByteArray>
26 class QFile;
28 #include <kdedmodule.h>
29 #include <kdirwatch.h>
30 #include <ksystemtimezone.h>
33 class KTimeZoned : public KDEDModule
35 Q_OBJECT
36 Q_CLASSINFO("D-Bus Interface", "org.kde.KTimeZoned")
38 public:
39 KTimeZoned(QObject* parent, const QList<QVariant>&);
40 ~KTimeZoned();
42 public Q_SLOTS:
43 /** D-Bus call to initialize the module.
44 * @param reinit determines whether to reinitialize if the module has already
45 * initialized itself
47 Q_SCRIPTABLE void initialize(bool reinit);
49 Q_SIGNALS:
50 /** D-Bus signal emitted when the time zone configuration file has changed. */
51 void configChanged();
52 /** D-Bus signal emitted when zone.tab contents have changed.
53 * @param zonetab path to zone.tab
55 void zonetabChanged(const QString &zonetab);
56 /** D-Bus signal emitted when the definition (not the identity) of the local
57 * system time zone has changed.
58 * @param zone path to time zone definition file
60 void zoneDefinitionChanged(const QString &zone);
62 private Q_SLOTS:
63 void zonetab_Changed(const QString& path);
64 void localChanged(const QString& path);
66 private:
67 // How the local time zone is specified
68 enum LocalMethod
70 TypeMask = 0x30,
71 Link = 0x10, // specified by a symlink
72 File = 0x20, // specified by a normal file
74 Utc, // use UTC default: no local zone spec was found
75 EnvTz, // specified in TZ environment variable
76 TzName, // specified in tzname via tzset()
77 Localtime, // specified in /etc/localtime
78 Timezone, // specified in /etc/timezone
79 DefaultInit, // specified in /etc/default/init
80 EnvTzFile = EnvTz | File,
81 EnvTzLink = EnvTz | Link,
82 LocaltimeCopy = Localtime | File,
83 LocaltimeLink = Localtime | Link
85 // Type of zone.tab cache
86 enum CacheType
88 NoCache, // zone.tab is the real thing, not a cached version
89 Solaris // Solaris: compiled from files in /usr/share/lib/zoneinfo/src
91 typedef QMap<QString, QString> MD5Map; // zone name, checksum
93 void init(bool restart);
94 bool findZoneTab(QFile& f);
95 void readZoneTab(QFile& f);
96 void findLocalZone();
97 bool checkTZ(const char *envZone);
98 bool checkLocaltimeLink();
99 bool checkLocaltimeFile();
100 bool checkTimezone();
101 bool checkDefaultInit();
102 void updateLocalZone();
103 bool matchZoneFile(const QString &path);
104 KTimeZone compareChecksum(const KTimeZone&, const QString &referenceMd5Sum, qlonglong size);
105 bool compareChecksum(MD5Map::ConstIterator, const QString &referenceMd5Sum, qlonglong size);
106 QString calcChecksum(const QString &zoneName, qlonglong size);
108 QString mZoneinfoDir; // path to zoneinfo directory
109 QString mZoneTab; // path to zone.tab file
110 QByteArray mSavedTZ; // last value of TZ if it's used to set local zone
111 KSystemTimeZoneSource *mSource;
112 KTimeZones mZones; // time zones collection
113 QString mLocalZone; // local system time zone name
114 QString mConfigLocalZone; // local system time zone name as stored in config file
115 QString mLocalIdFile; // file containing pointer to local time zone definition
116 QString mLocalZoneDataFile; // zoneinfo file containing local time zone definition
117 QString mLocaltimeMd5Sum; // MD5 checksum of /etc/localtime
118 LocalMethod mLocalMethod; // how the local time zone is specified
119 KDirWatch *mZonetabWatch; // watch for zone.tab file changes
120 KDirWatch *mDirWatch; // watch for time zone definition file changes
121 MD5Map mMd5Sums; // MD5 checksums of zoneinfo files
122 CacheType mZoneTabCache; // type of cached simulated zone.tab
123 bool mHaveCountryCodes; // true if zone.tab contains any country codes
126 #endif