summaryrefslogtreecommitdiff
path: root/noncore/settings/netsystemtime/ntp.cpp
Side-by-side diff
Diffstat (limited to 'noncore/settings/netsystemtime/ntp.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/settings/netsystemtime/ntp.cpp9
1 files changed, 5 insertions, 4 deletions
diff --git a/noncore/settings/netsystemtime/ntp.cpp b/noncore/settings/netsystemtime/ntp.cpp
index 830c0c3..7971f9a 100644
--- a/noncore/settings/netsystemtime/ntp.cpp
+++ b/noncore/settings/netsystemtime/ntp.cpp
@@ -145,31 +145,31 @@ void Ntp::ntpFinished(OProcess *p)
return;
}
Config cfg("ntp",Config::User);
cfg.setGroup("lookups");
int lastLookup = cfg.readNumEntry("time",0);
int lookupCount = cfg.readNumEntry("count",0);
+ bool lastNtp = cfg.readBoolEntry("lastNtp",false);
int time = TimeConversion::toUTC( QDateTime::currentDateTime() );
cfg.writeEntry("time", time);
- cfg.setGroup("correction");
- cfg.writeEntry("time", time);
float timeShift = getTimeShift();
if (timeShift == 0.0) return;
int secsSinceLast = time - lastLookup;
TextLabelNewTime->setText(QDateTime::currentDateTime().toString());
TextLabelTimeShift->setText(QString::number(timeShift)+tr(" seconds"));
- if ( lastLookup > 0 && secsSinceLast > 60* SpinBoxMinLookupDelay->value())
+ if ( lastNtp && lastLookup > 0 && secsSinceLast > 60* SpinBoxMinLookupDelay->value())
{
+ cfg.setGroup("lookup_"+QString::number(lookupCount));
lookupCount++;
cfg.writeEntry("count",lookupCount);
- cfg.setGroup("lookup_"+QString::number(lookupCount));
_shiftPerSec = timeShift / secsSinceLast;
qDebug("secs since last lookup %i", secsSinceLast);qDebug("timeshift since last lookup %f", timeShift);qDebug("timeshift since per sec %f", _shiftPerSec);
cfg.writeEntry("secsSinceLast",secsSinceLast);
cfg.writeEntry("timeShift",QString::number(timeShift));
+ cfg.writeEntry("lastNtp",true);
}
}
float Ntp::getTimeShift()
{
@@ -225,12 +225,13 @@ void Ntp::readLookups()
void Ntp::preditctTime()
{
Config cfg("ntp",Config::User);
cfg.setGroup("lookups");
int lastTime = cfg.readNumEntry("time",0);
+ cfg.writeEntry("lastNtp",true);
setenv( "TZ", tz->currentZone(), 1 );
int now = TimeConversion::toUTC( QDateTime::currentDateTime() );
int corr = int((now - lastTime) * _shiftPerSec);
TextLabelEstimatedShift->setText(QString::number(corr)+tr(" seconds"));
predictedTime = QDateTime::currentDateTime().addSecs(corr);
TextLabelPredTime->setText(predictedTime.toString());