Diffstat (limited to 'noncore/settings/netsystemtime/ntp.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/settings/netsystemtime/ntp.cpp | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/noncore/settings/netsystemtime/ntp.cpp b/noncore/settings/netsystemtime/ntp.cpp index aecefc1..f653cd0 100644 --- a/noncore/settings/netsystemtime/ntp.cpp +++ b/noncore/settings/netsystemtime/ntp.cpp | |||
@@ -12,24 +12,25 @@ | |||
12 | #include <qlayout.h> | 12 | #include <qlayout.h> |
13 | #include <qmessagebox.h> | 13 | #include <qmessagebox.h> |
14 | #include <qmultilineedit.h> | 14 | #include <qmultilineedit.h> |
15 | #include <opie/oprocess.h> | 15 | #include <opie/oprocess.h> |
16 | #include <qpe/qpeapplication.h> | 16 | #include <qpe/qpeapplication.h> |
17 | #include <qpe/config.h> | 17 | #include <qpe/config.h> |
18 | #include <qpe/global.h> | 18 | #include <qpe/global.h> |
19 | #include <qpe/timeconversion.h> | 19 | #include <qpe/timeconversion.h> |
20 | #include <qpe/tzselect.h> | 20 | #include <qpe/tzselect.h> |
21 | #include <qpe/timestring.h> | 21 | #include <qpe/timestring.h> |
22 | #include <qpe/qpedialog.h> | 22 | #include <qpe/qpedialog.h> |
23 | #include <qpe/datebookdb.h> | 23 | #include <qpe/datebookdb.h> |
24 | #include <qpe/datebookmonth.h> | ||
24 | #include <qpe/qcopenvelope_qws.h> | 25 | #include <qpe/qcopenvelope_qws.h> |
25 | #include <sys/time.h> | 26 | #include <sys/time.h> |
26 | #include <time.h> | 27 | #include <time.h> |
27 | #include <stdlib.h> | 28 | #include <stdlib.h> |
28 | 29 | ||
29 | 30 | ||
30 | Ntp::Ntp( QWidget* parent, const char* name, WFlags fl ) | 31 | Ntp::Ntp( QWidget* parent, const char* name, WFlags fl ) |
31 | : SetDateTime( parent, name, fl ) | 32 | : SetDateTime( parent, name, fl ) |
32 | { | 33 | { |
33 | _interactive = false; | 34 | _interactive = false; |
34 | Config ntpSrvs(QPEApplication::qpeDir()+"etc/ntpservers",Config::File); | 35 | Config ntpSrvs(QPEApplication::qpeDir()+"etc/ntpservers",Config::File); |
35 | ntpSrvs.setGroup("servers"); | 36 | ntpSrvs.setGroup("servers"); |
@@ -214,24 +215,28 @@ void Ntp::ntpFinished(OProcess *p) | |||
214 | cfg.setGroup("lookups"); | 215 | cfg.setGroup("lookups"); |
215 | int lastLookup = cfg.readNumEntry("time",0); | 216 | int lastLookup = cfg.readNumEntry("time",0); |
216 | int lookupCount = cfg.readNumEntry("count",0); | 217 | int lookupCount = cfg.readNumEntry("count",0); |
217 | bool lastNtp = cfg.readBoolEntry("lastNtp",false); | 218 | bool lastNtp = cfg.readBoolEntry("lastNtp",false); |
218 | int time = TimeConversion::toUTC( QDateTime::currentDateTime() ); | 219 | int time = TimeConversion::toUTC( QDateTime::currentDateTime() ); |
219 | cfg.writeEntry("time", time); | 220 | cfg.writeEntry("time", time); |
220 | 221 | ||
221 | float timeShift = getTimeShift(); | 222 | float timeShift = getTimeShift(); |
222 | if (timeShift == 0.0) return; | 223 | if (timeShift == 0.0) return; |
223 | int secsSinceLast = time - lastLookup; | 224 | int secsSinceLast = time - lastLookup; |
224 | TextLabelNewTime->setText(QDateTime::currentDateTime().toString()); | 225 | TextLabelNewTime->setText(QDateTime::currentDateTime().toString()); |
225 | TextLabelTimeShift->setText(QString::number(timeShift)+tr(" seconds")); | 226 | TextLabelTimeShift->setText(QString::number(timeShift)+tr(" seconds")); |
227 | |||
228 | dateButton->setDate( QDate::currentDate() ); | ||
229 | timeButton->setTime( QDateTime::currentDateTime() ); | ||
230 | |||
226 | if ( lastNtp && lastLookup > 0 && secsSinceLast > 60* SpinBoxMinLookupDelay->value()) | 231 | if ( lastNtp && lastLookup > 0 && secsSinceLast > 60* SpinBoxMinLookupDelay->value()) |
227 | { | 232 | { |
228 | cfg.setGroup("lookup_"+QString::number(lookupCount)); | 233 | cfg.setGroup("lookup_"+QString::number(lookupCount)); |
229 | lookupCount++; | 234 | lookupCount++; |
230 | _shiftPerSec = timeShift / secsSinceLast; | 235 | _shiftPerSec = timeShift / secsSinceLast; |
231 | qDebug("secs since last lookup %i", secsSinceLast);qDebug("timeshift since last lookup %f", timeShift);qDebug("timeshift since per sec %f", _shiftPerSec); | 236 | qDebug("secs since last lookup %i", secsSinceLast);qDebug("timeshift since last lookup %f", timeShift);qDebug("timeshift since per sec %f", _shiftPerSec); |
232 | cfg.writeEntry("secsSinceLast",secsSinceLast); | 237 | cfg.writeEntry("secsSinceLast",secsSinceLast); |
233 | cfg.writeEntry("timeShift",QString::number(timeShift)); | 238 | cfg.writeEntry("timeShift",QString::number(timeShift)); |
234 | cfg.setGroup("lookups"); | 239 | cfg.setGroup("lookups"); |
235 | cfg.writeEntry("count",lookupCount); | 240 | cfg.writeEntry("count",lookupCount); |
236 | cfg.writeEntry("lastNtp",true); | 241 | cfg.writeEntry("lastNtp",true); |
237 | } | 242 | } |