Diffstat (limited to 'noncore/settings/netsystemtime/ntp.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/settings/netsystemtime/ntp.cpp | 9 |
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 | |||
@@ -148,25 +148,25 @@ void Ntp::ntpFinished(OProcess *p) | |||
148 | cfg.setGroup("lookups"); | 148 | cfg.setGroup("lookups"); |
149 | int lastLookup = cfg.readNumEntry("time",0); | 149 | int lastLookup = cfg.readNumEntry("time",0); |
150 | int lookupCount = cfg.readNumEntry("count",0); | 150 | int lookupCount = cfg.readNumEntry("count",0); |
151 | bool lastNtp = cfg.readBoolEntry("lastNtp",false); | ||
151 | int time = TimeConversion::toUTC( QDateTime::currentDateTime() ); | 152 | int time = TimeConversion::toUTC( QDateTime::currentDateTime() ); |
152 | cfg.writeEntry("time", time); | 153 | cfg.writeEntry("time", time); |
153 | cfg.setGroup("correction"); | ||
154 | cfg.writeEntry("time", time); | ||
155 | 154 | ||
156 | float timeShift = getTimeShift(); | 155 | float timeShift = getTimeShift(); |
157 | if (timeShift == 0.0) return; | 156 | if (timeShift == 0.0) return; |
158 | int secsSinceLast = time - lastLookup; | 157 | int secsSinceLast = time - lastLookup; |
159 | TextLabelNewTime->setText(QDateTime::currentDateTime().toString()); | 158 | TextLabelNewTime->setText(QDateTime::currentDateTime().toString()); |
160 | TextLabelTimeShift->setText(QString::number(timeShift)+tr(" seconds")); | 159 | TextLabelTimeShift->setText(QString::number(timeShift)+tr(" seconds")); |
161 | if ( lastLookup > 0 && secsSinceLast > 60* SpinBoxMinLookupDelay->value()) | 160 | if ( lastNtp && lastLookup > 0 && secsSinceLast > 60* SpinBoxMinLookupDelay->value()) |
162 | { | 161 | { |
162 | cfg.setGroup("lookup_"+QString::number(lookupCount)); | ||
163 | lookupCount++; | 163 | lookupCount++; |
164 | cfg.writeEntry("count",lookupCount); | 164 | cfg.writeEntry("count",lookupCount); |
165 | cfg.setGroup("lookup_"+QString::number(lookupCount)); | ||
166 | _shiftPerSec = timeShift / secsSinceLast; | 165 | _shiftPerSec = timeShift / secsSinceLast; |
167 | qDebug("secs since last lookup %i", secsSinceLast);qDebug("timeshift since last lookup %f", timeShift);qDebug("timeshift since per sec %f", _shiftPerSec); | 166 | qDebug("secs since last lookup %i", secsSinceLast);qDebug("timeshift since last lookup %f", timeShift);qDebug("timeshift since per sec %f", _shiftPerSec); |
168 | cfg.writeEntry("secsSinceLast",secsSinceLast); | 167 | cfg.writeEntry("secsSinceLast",secsSinceLast); |
169 | cfg.writeEntry("timeShift",QString::number(timeShift)); | 168 | cfg.writeEntry("timeShift",QString::number(timeShift)); |
169 | cfg.writeEntry("lastNtp",true); | ||
170 | } | 170 | } |
171 | } | 171 | } |
172 | 172 | ||
@@ -228,6 +228,7 @@ void Ntp::preditctTime() | |||
228 | Config cfg("ntp",Config::User); | 228 | Config cfg("ntp",Config::User); |
229 | cfg.setGroup("lookups"); | 229 | cfg.setGroup("lookups"); |
230 | int lastTime = cfg.readNumEntry("time",0); | 230 | int lastTime = cfg.readNumEntry("time",0); |
231 | cfg.writeEntry("lastNtp",true); | ||
231 | setenv( "TZ", tz->currentZone(), 1 ); | 232 | setenv( "TZ", tz->currentZone(), 1 ); |
232 | int now = TimeConversion::toUTC( QDateTime::currentDateTime() ); | 233 | int now = TimeConversion::toUTC( QDateTime::currentDateTime() ); |
233 | int corr = int((now - lastTime) * _shiftPerSec); | 234 | int corr = int((now - lastTime) * _shiftPerSec); |