-rw-r--r-- | noncore/settings/netsystemtime/ntp.cpp | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/noncore/settings/netsystemtime/ntp.cpp b/noncore/settings/netsystemtime/ntp.cpp index 7971f9a..40b5531 100644 --- a/noncore/settings/netsystemtime/ntp.cpp +++ b/noncore/settings/netsystemtime/ntp.cpp | |||
@@ -140,53 +140,54 @@ void Ntp::ntpFinished(OProcess *p) | |||
140 | { | 140 | { |
141 | qDebug("p->exitStatus() %i",p->exitStatus()); | 141 | qDebug("p->exitStatus() %i",p->exitStatus()); |
142 | if (p->exitStatus()!=0 || !p->normalExit()) | 142 | if (p->exitStatus()!=0 || !p->normalExit()) |
143 | { | 143 | { |
144 | slotProbeNtpServer(); | 144 | slotProbeNtpServer(); |
145 | return; | 145 | return; |
146 | } | 146 | } |
147 | Config cfg("ntp",Config::User); | 147 | Config cfg("ntp",Config::User); |
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 | bool lastNtp = cfg.readBoolEntry("lastNtp",false); |
152 | int time = TimeConversion::toUTC( QDateTime::currentDateTime() ); | 152 | int time = TimeConversion::toUTC( QDateTime::currentDateTime() ); |
153 | cfg.writeEntry("time", time); | 153 | cfg.writeEntry("time", time); |
154 | 154 | ||
155 | float timeShift = getTimeShift(); | 155 | float timeShift = getTimeShift(); |
156 | if (timeShift == 0.0) return; | 156 | if (timeShift == 0.0) return; |
157 | int secsSinceLast = time - lastLookup; | 157 | int secsSinceLast = time - lastLookup; |
158 | TextLabelNewTime->setText(QDateTime::currentDateTime().toString()); | 158 | TextLabelNewTime->setText(QDateTime::currentDateTime().toString()); |
159 | TextLabelTimeShift->setText(QString::number(timeShift)+tr(" seconds")); | 159 | TextLabelTimeShift->setText(QString::number(timeShift)+tr(" seconds")); |
160 | if ( lastNtp && lastLookup > 0 && secsSinceLast > 60* SpinBoxMinLookupDelay->value()) | 160 | if ( lastNtp && lastLookup > 0 && secsSinceLast > 60* SpinBoxMinLookupDelay->value()) |
161 | { | 161 | { |
162 | cfg.setGroup("lookup_"+QString::number(lookupCount)); | 162 | cfg.setGroup("lookup_"+QString::number(lookupCount)); |
163 | lookupCount++; | 163 | lookupCount++; |
164 | cfg.writeEntry("count",lookupCount); | ||
165 | _shiftPerSec = timeShift / secsSinceLast; | 164 | _shiftPerSec = timeShift / secsSinceLast; |
166 | qDebug("secs since last lookup %i", secsSinceLast);qDebug("timeshift since last lookup %f", timeShift);qDebug("timeshift since per sec %f", _shiftPerSec); | 165 | qDebug("secs since last lookup %i", secsSinceLast);qDebug("timeshift since last lookup %f", timeShift);qDebug("timeshift since per sec %f", _shiftPerSec); |
167 | cfg.writeEntry("secsSinceLast",secsSinceLast); | 166 | cfg.writeEntry("secsSinceLast",secsSinceLast); |
168 | cfg.writeEntry("timeShift",QString::number(timeShift)); | 167 | cfg.writeEntry("timeShift",QString::number(timeShift)); |
168 | cfg.setGroup("lookups"); | ||
169 | cfg.writeEntry("count",lookupCount); | ||
169 | cfg.writeEntry("lastNtp",true); | 170 | cfg.writeEntry("lastNtp",true); |
170 | } | 171 | } |
171 | } | 172 | } |
172 | 173 | ||
173 | 174 | ||
174 | float Ntp::getTimeShift() | 175 | float Ntp::getTimeShift() |
175 | { | 176 | { |
176 | QString _offset = "offset"; | 177 | QString _offset = "offset"; |
177 | QString _sec = "sec"; | 178 | QString _sec = "sec"; |
178 | QRegExp _reOffset = QRegExp(_offset); | 179 | QRegExp _reOffset = QRegExp(_offset); |
179 | QRegExp _reEndOffset = QRegExp(_sec); | 180 | QRegExp _reEndOffset = QRegExp(_sec); |
180 | int posOffset = _reOffset.match( _ntpOutput ); | 181 | int posOffset = _reOffset.match( _ntpOutput ); |
181 | int posEndOffset = _reEndOffset.match( _ntpOutput, posOffset ); | 182 | int posEndOffset = _reEndOffset.match( _ntpOutput, posOffset ); |
182 | posOffset += _offset.length() + 1; | 183 | posOffset += _offset.length() + 1; |
183 | QString diff = _ntpOutput.mid(posOffset, posEndOffset-posOffset-1); | 184 | QString diff = _ntpOutput.mid(posOffset, posEndOffset-posOffset-1); |
184 | qDebug("%s", _ntpOutput.latin1()); | 185 | qDebug("%s", _ntpOutput.latin1()); |
185 | qDebug("diff = >%s<",diff.latin1()); | 186 | qDebug("diff = >%s<",diff.latin1()); |
186 | return diff.toFloat(); | 187 | return diff.toFloat(); |
187 | } | 188 | } |
188 | 189 | ||
189 | void Ntp::readLookups() | 190 | void Ntp::readLookups() |
190 | { | 191 | { |
191 | Config cfg("ntp",Config::User); | 192 | Config cfg("ntp",Config::User); |
192 | cfg.setGroup("lookups"); | 193 | cfg.setGroup("lookups"); |