// Perform initialization, create the unique KSystemTimeZones instance, // whose only function is to receive D-Bus signals from KTimeZoned, // and create the unique KSystemTimeZonesPrivate instance. KSystemTimeZonesPrivate *KSystemTimeZonesPrivate::instance() { if (!m_instance) { m_instance = new KSystemTimeZonesPrivate; // A KSystemTimeZones instance is required only to catch D-Bus signals. m_parent = new KSystemTimeZones; // Ensure that the KDED time zones module has initialized. The call loads the module on demand. if (!QDBusConnection::sessionBus().interface()->isServiceRegistered(QLatin1String("org.kde.kded"))) KToolInvocation::klauncher(); // this calls startKdeinit, and blocks until it returns const QString dbusIface = QString::fromLatin1(KTIMEZONED_DBUS_IFACE); QDBusInterface *ktimezoned = new QDBusInterface(QLatin1String("org.kde.kded"), QLatin1String("/modules/ktimezoned"), dbusIface); QDBusReply<void> reply = ktimezoned->call(QLatin1String("initialize"), false); m_ktimezonedError = !reply.isValid(); if (m_ktimezonedError) kError(161) << "KSystemTimeZones: ktimezoned initialize() D-Bus call failed: " << reply.error().message() << endl; kDebug(161)<<"instance(): ... initialised"; delete ktimezoned; // Read the time zone config written by ktimezoned readConfig(true); // Go read the database. #ifdef Q_OS_WIN // On Windows, HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Time Zones // is the place to look. The TZI binary value is the TIME_ZONE_INFORMATION structure. m_instance->updateTimezoneInformation(false); #else // For Unix, read zone.tab. if (!m_zonetab.isEmpty()) m_instance->readZoneTab(false); #endif setLocalZone(); if (!m_localZone.isValid()) m_localZone = KTimeZone::utc(); // ensure a time zone is always returned qAddPostRoutine(KSystemTimeZonesPrivate::cleanup); } return m_instance; }
// Perform initialization, create the unique KSystemTimeZones instance, // whose only function is to receive D-Bus signals from KTimeZoned, // and create the unique KSystemTimeZonesPrivate instance. KSystemTimeZonesPrivate *KSystemTimeZonesPrivate::instance() { if (!m_instance) { m_instance = new KSystemTimeZonesPrivate; #if !defined(TIMED_SUPPORT) && !defined(KCALCORE_FOR_MEEGO) // A KSystemTimeZones instance is required only to catch D-Bus signals. m_parent = new KSystemTimeZones; // Ensure that the KDED time zones module has initialized. The call loads the module on demand. QDBusInterface *ktimezoned = new QDBusInterface("org.kde.kded", "/modules/ktimezoned", KTIMEZONED_DBUS_IFACE); QDBusReply<void> reply = ktimezoned->call("initialize", false); if (!reply.isValid()) kError(161) << "KSystemTimeZones: ktimezoned initialize() D-Bus call failed: " << reply.error().message() << endl; kDebug(161)<<"instance(): ... initialised"; delete ktimezoned; #endif // Read the time zone config written by ktimezoned readConfig(true); // Go read the database. #ifdef Q_OS_WIN // On Windows, HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Time Zones // is the place to look. The TZI binary value is the TIME_ZONE_INFORMATION structure. #else // For Unix, read zone.tab. if (!m_zonetab.isEmpty()) m_instance->readZoneTab(false); #endif setLocalZone(); if (!m_localZone.isValid()) { kDebug() << "m_localZone invalid"; m_localZone = KTimeZone::utc(); // ensure a time zone is always returned } qAddPostRoutine(KSystemTimeZonesPrivate::cleanup); } return m_instance; }