[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-devel
Subject:    [PATCH] kcmshell4 clock partially works
From:       yinshuiboy <yinshuiboy () gmail ! com>
Date:       2008-09-01 3:48:59
Message-ID: 48BB662B.8090405 () gmail ! com
[Download RAW message or body]

hi all,
i found some problems of kcm_clock. first, kcm_clock write config file
wrong place and wrong permission, and i18n'ed ntp server list is not
work fine under non en_US environment, and update of timezone does not
always work. some other trivial problems also exists, i think kde
developers should take a look at these problems in control center.

kcontrol-dateandtime.patch applies to
kdebase/workspace/kcontrol/dateandtime.
ktimezoned-watch-lose.patch applies to kdebase/runtime/ktimezoned.

Greetings,
Siyuan Cao




["kcontrol-dateandtime.patch" (text/x-patch)]

Index: helper.cpp
===================================================================
--- helper.cpp	(版本 854190)
+++ helper.cpp	(工作副本)
@@ -52,10 +52,14 @@
 {
   int ret = 0;
   // write to the system config file
-  KConfig _config( KDE_CONFDIR "kcmclockrc", KConfig::SimpleConfig);
+  KConfig _config( KDE_CONFDIR "/kcmclockrc", KConfig::SimpleConfig );
   KConfigGroup config(&_config, "NTP");
   config.writeEntry("servers", ntpServers );
   config.writeEntry("enabled", ntpEnabled );
+  config.sync();
+  if ( !QFile::setPermissions( KDE_CONFDIR "/kcmclockrc",
+							  QFile::ReadUser|QFile::WriteUser|QFile::ReadGroup|QFile::ReadOther) )
+	  kDebug() << " set file perm failed";
 
   QString ntpUtility;
   if(!KStandardDirs::findExe("ntpdate").isEmpty()) {
@@ -102,7 +106,7 @@
         tf.setPrefix("kde-tzone");
         tf.open();
         QTextStream ts(&tf);
-
+		
         QFile fTimezoneFile(INITFILE);
         bool updatedFile = false;
 
@@ -193,7 +197,6 @@
 
         setenv("TZ", val.toAscii(), 1);
         tzset();
-
     return ret;
 }
 
Index: tzone.cpp
--- tzone.cpp	(版本 854190)
+++ tzone.cpp	(工作副本)
@@ -57,6 +57,8 @@
 #include <sys/stat.h>
 #endif
 
+#include <QDBusConnection>
+
 #include "helper.h"
 
 Tzone::Tzone(QWidget * parent)
@@ -67,6 +69,7 @@
     QVBoxLayout *lay = new QVBoxLayout(this);
 
     tzonelist = new KTimeZoneWidget(this);
+	tzonelist->setSelectionMode( QAbstractItemView::SingleSelection );
     connect( tzonelist, SIGNAL(itemSelectionChanged()), SLOT(handleZoneChange()) );
 
     m_local = new QLabel(this);
@@ -74,15 +77,20 @@
     lay->addWidget(m_local);
     lay->addWidget(tzonelist);
 
+    QDBusConnection dbus = QDBusConnection::sessionBus();
+#define KTIMEZONED_DBUS_IFACE "org.kde.KTimeZoned"
+    dbus.connect(QString(), QString(), KTIMEZONED_DBUS_IFACE, "configChanged", this, \
SLOT(currentZone())); +#undef KTIMEZONED_DBUS_IFACE
+	
     load();
 }
 
 void Tzone::load()
 {
-    currentZone();
-
+	tzonelist->clearSelection();
     // read the currently set time zone
     tzonelist->setSelected(KSystemTimeZones::local().name(), true);
+    currentZone();	
 }
 
 void Tzone::currentZone()
@@ -91,10 +99,18 @@
 
     time_t now = time(0);
     tzset();
+
     strftime(result.data(), result.size(), "%Z", localtime(&now));
-    m_local->setText(i18n("Current local timezone: %1 (%2)",
-                          KTimeZoneWidget::displayName(KSystemTimeZones::local()),
-                          QLatin1String(result)));
+	if ( !tzonelist->selection().isEmpty() ) {
+		KTimeZone curZone = KSystemTimeZones::zone( tzonelist->selection()[0] );
+		m_local->setText(i18n("Current local timezone: %1 (%2)",
+							  KTimeZoneWidget::displayName(curZone),
+							  QLatin1String(result)));
+	} else
+		m_local->setText(i18n("Current local timezone: %1 (%2)",
+							  KTimeZoneWidget::displayName(KSystemTimeZones::local()),
+							  QLatin1String(result)));
+	
 }
 
 // FIXME: Does the logic in this routine actually work correctly? For example,
@@ -111,7 +127,7 @@
       helperargs << "tzreset"; // // make the helper reset the timezone
     }
 
-    currentZone();
+//    currentZone(); // useless, cause timezone not changed at this point
 }
 
 void Tzone::processHelperErrors( int code )
Index: dtime.cpp
--- dtime.cpp	(版本 854190)
+++ dtime.cpp	(工作副本)
@@ -261,8 +261,11 @@
   // since there is nothing writing it.
   KConfig _config( "kcmclockrc", KConfig::NoGlobals );
   KConfigGroup config(&_config, "NTP");
+  // localized string can not be process correctly, and since servers read from \
file, people can +  // modify it, so mark i18n for default servers is useless. 
+  timeServerList->clear();
   timeServerList->addItems(config.readEntry("servers",
-    i18n("Public Time Server (pool.ntp.org),\
+    QString("pool.ntp.org,\
 asia.pool.ntp.org,\
 europe.pool.ntp.org,\
 north-america.pool.ntp.org,\
Index: main.cpp
--- main.cpp	(版本 854190)
+++ main.cpp	(工作副本)
@@ -98,6 +98,9 @@
     proc << helperargs;
     error = proc.execute();
   }
+
+//  tzone->currentZone();
+  
   if( error < 0 || error == ERROR_CALL )
     KMessageBox::error( this, i18n( "Failed to set system date/time/timezone."), \
i18n( "Date/Time Error" ));  else {
Index: tzone.h
--- tzone.h	(版本 854190)
+++ tzone.h	(工作副本)
@@ -41,6 +41,9 @@
   void processHelperErrors( int code );
   void  load();
 
+public Q_SLOTS:
+  void currentZone(); 
+  
 Q_SIGNALS:
 	void zoneChanged(bool);
 
@@ -48,7 +51,6 @@
   void handleZoneChange() {emit zoneChanged( true );}
 
 private:
-  void currentZone();
   QLabel *m_local;
   KTimeZoneWidget *tzonelist;
 };


["ktimezoned-watch-lose.patch" (text/x-patch)]

Index: ktimezoned.cpp
===================================================================
--- ktimezoned.cpp	(版本 854190)
+++ ktimezoned.cpp	(工作副本)
@@ -385,8 +385,8 @@
         // in local time zone.
         mDirWatch = new KDirWatch(this);
         mDirWatch->addFile(mLocalIdFile);
-        if (!mLocalZoneDataFile.isEmpty())
-            mDirWatch->addFile(mLocalZoneDataFile);
+//        if (!mLocalZoneDataFile.isEmpty())
+//            mDirWatch->addFile(mLocalZoneDataFile);
         connect(mDirWatch, SIGNAL(dirty(const QString&)), SLOT(localChanged(const QString&)));
     }
     else if (!mZoneinfoDir.isEmpty())
@@ -475,7 +475,7 @@
         args += mLocalZone;
         message.setArguments(args);
         QDBusConnection::sessionBus().send(message);
-        return;
+//        return; 
     }
     QString oldDataFile = mLocalZoneDataFile;
     switch (mLocalMethod)
@@ -512,6 +512,8 @@
             mDirWatch->removeFile(oldDataFile);
         if (!mLocalZoneDataFile.isEmpty())
             mDirWatch->addFile(mLocalZoneDataFile);
+	    mDirWatch->removeFile( mLocalIdFile );
+	    mDirWatch->addFile( mLocalIdFile );
     }
     updateLocalZone();
 }



>> Visit http://mail.kde.org/mailman/listinfo/kde-devel#unsub to unsubscribe <<


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic