author | tille <tille> | 2002-06-27 22:28:03 (UTC) |
---|---|---|
committer | tille <tille> | 2002-06-27 22:28:03 (UTC) |
commit | 2f9c9f9dfe6aff27381a3c671bbd50870976677c (patch) (unidiff) | |
tree | 28ea446384f0abc3b8c9b49d9631b46bd174b32d | |
parent | 49710f20cf0e52ea3393027ed066f11e977e3457 (diff) | |
download | opie-2f9c9f9dfe6aff27381a3c671bbd50870976677c.zip opie-2f9c9f9dfe6aff27381a3c671bbd50870976677c.tar.gz opie-2f9c9f9dfe6aff27381a3c671bbd50870976677c.tar.bz2 |
conffile count
-rw-r--r-- | noncore/settings/netsystemtime/ntp.cpp | 9 | ||||
-rw-r--r-- | noncore/settings/netsystemtime/settime.cpp | 3 |
2 files changed, 8 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 | |||
@@ -135,51 +135,51 @@ void Ntp::getNtpOutput(OProcess *proc, char *buffer, int buflen) | |||
135 | } | 135 | } |
136 | lineStrOld = lineStr; | 136 | lineStrOld = lineStr; |
137 | } | 137 | } |
138 | 138 | ||
139 | void Ntp::ntpFinished(OProcess *p) | 139 | 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 | 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 | ||
173 | 173 | ||
174 | float Ntp::getTimeShift() | 174 | float Ntp::getTimeShift() |
175 | { | 175 | { |
176 | QString _offset = "offset"; | 176 | QString _offset = "offset"; |
177 | QString _sec = "sec"; | 177 | QString _sec = "sec"; |
178 | QRegExp _reOffset = QRegExp(_offset); | 178 | QRegExp _reOffset = QRegExp(_offset); |
179 | QRegExp _reEndOffset = QRegExp(_sec); | 179 | QRegExp _reEndOffset = QRegExp(_sec); |
180 | int posOffset = _reOffset.match( _ntpOutput ); | 180 | int posOffset = _reOffset.match( _ntpOutput ); |
181 | int posEndOffset = _reEndOffset.match( _ntpOutput, posOffset ); | 181 | int posEndOffset = _reEndOffset.match( _ntpOutput, posOffset ); |
182 | posOffset += _offset.length() + 1; | 182 | posOffset += _offset.length() + 1; |
183 | QString diff = _ntpOutput.mid(posOffset, posEndOffset-posOffset-1); | 183 | QString diff = _ntpOutput.mid(posOffset, posEndOffset-posOffset-1); |
184 | qDebug("%s", _ntpOutput.latin1()); | 184 | qDebug("%s", _ntpOutput.latin1()); |
185 | qDebug("diff = >%s<",diff.latin1()); | 185 | qDebug("diff = >%s<",diff.latin1()); |
@@ -215,32 +215,33 @@ void Ntp::readLookups() | |||
215 | // qDebug("%i shift %f",i,shift); | 215 | // qDebug("%i shift %f",i,shift); |
216 | shiftPerSec = shift / last; | 216 | shiftPerSec = shift / last; |
217 | _shiftPerSec += shiftPerSec; | 217 | _shiftPerSec += shiftPerSec; |
218 | TableLookups->setText( i,0,QString::number(shiftPerSec*60*60)); | 218 | TableLookups->setText( i,0,QString::number(shiftPerSec*60*60)); |
219 | TableLookups->setText( i,2,QString::number(shift)); | 219 | TableLookups->setText( i,2,QString::number(shift)); |
220 | TableLookups->setText( i,1,QString::number(last/(60*60))); | 220 | TableLookups->setText( i,1,QString::number(last/(60*60))); |
221 | } | 221 | } |
222 | _shiftPerSec /= lookupCount; | 222 | _shiftPerSec /= lookupCount; |
223 | TextLabelShift->setText(QString::number(_shiftPerSec*60*60)+tr(" s/h")); | 223 | TextLabelShift->setText(QString::number(_shiftPerSec*60*60)+tr(" s/h")); |
224 | } | 224 | } |
225 | 225 | ||
226 | void Ntp::preditctTime() | 226 | void Ntp::preditctTime() |
227 | { | 227 | { |
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); |
234 | TextLabelEstimatedShift->setText(QString::number(corr)+tr(" seconds")); | 235 | TextLabelEstimatedShift->setText(QString::number(corr)+tr(" seconds")); |
235 | predictedTime = QDateTime::currentDateTime().addSecs(corr); | 236 | predictedTime = QDateTime::currentDateTime().addSecs(corr); |
236 | TextLabelPredTime->setText(predictedTime.toString()); | 237 | TextLabelPredTime->setText(predictedTime.toString()); |
237 | TextLabelMainPredTime->setText(tr("Predicted time:")+"<br><b>"+predictedTime.toString()+"</b>"); | 238 | TextLabelMainPredTime->setText(tr("Predicted time:")+"<br><b>"+predictedTime.toString()+"</b>"); |
238 | } | 239 | } |
239 | 240 | ||
240 | void Ntp::setPredictTime() | 241 | void Ntp::setPredictTime() |
241 | { | 242 | { |
242 | preditctTime(); | 243 | preditctTime(); |
243 | setTime( predictedTime ); | 244 | setTime( predictedTime ); |
244 | } | 245 | } |
245 | 246 | ||
246 | void Ntp::slotCheckNtp(int i) | 247 | void Ntp::slotCheckNtp(int i) |
diff --git a/noncore/settings/netsystemtime/settime.cpp b/noncore/settings/netsystemtime/settime.cpp index e7e604f..9c5323a 100644 --- a/noncore/settings/netsystemtime/settime.cpp +++ b/noncore/settings/netsystemtime/settime.cpp | |||
@@ -217,32 +217,35 @@ void SetDateTime::writeSettings() | |||
217 | config.writeEntry( "MONDAY", weekStartCombo->currentItem() ); | 217 | config.writeEntry( "MONDAY", weekStartCombo->currentItem() ); |
218 | config.setGroup( "Date" ); | 218 | config.setGroup( "Date" ); |
219 | DateFormat df = date_formats[dateFormatCombo->currentItem()]; | 219 | DateFormat df = date_formats[dateFormatCombo->currentItem()]; |
220 | config.writeEntry( "Separator", QString(df.separator())); | 220 | config.writeEntry( "Separator", QString(df.separator())); |
221 | config.writeEntry( "ShortOrder", df.shortOrder()); | 221 | config.writeEntry( "ShortOrder", df.shortOrder()); |
222 | config.writeEntry( "LongOrder", df.longOrder()); | 222 | config.writeEntry( "LongOrder", df.longOrder()); |
223 | config.writeEntry( "ClockApplet", clockAppletCombo->currentItem() ); | 223 | config.writeEntry( "ClockApplet", clockAppletCombo->currentItem() ); |
224 | 224 | ||
225 | Config lconfig("locale"); | 225 | Config lconfig("locale"); |
226 | lconfig.setGroup( "Location" ); | 226 | lconfig.setGroup( "Location" ); |
227 | lconfig.writeEntry( "Timezone", tz->currentZone() ); | 227 | lconfig.writeEntry( "Timezone", tz->currentZone() ); |
228 | 228 | ||
229 | } | 229 | } |
230 | 230 | ||
231 | void SetDateTime::commitTime() | 231 | void SetDateTime::commitTime() |
232 | { | 232 | { |
233 | Config cfg("ntp",Config::User); | ||
234 | cfg.setGroup("lookups"); | ||
235 | cfg.writeEntry("lastNtp",false); | ||
233 | tz->setFocus(); | 236 | tz->setFocus(); |
234 | // Need to process the QCOP event generated above before proceeding | 237 | // Need to process the QCOP event generated above before proceeding |
235 | qApp->processEvents(); | 238 | qApp->processEvents(); |
236 | 239 | ||
237 | // before we progress further, set our TZ! | 240 | // before we progress further, set our TZ! |
238 | setenv( "TZ", tz->currentZone(), 1 ); | 241 | setenv( "TZ", tz->currentZone(), 1 ); |
239 | // now set the time... | 242 | // now set the time... |
240 | QDateTime dt( dateButton->date(), timeButton->time() ); | 243 | QDateTime dt( dateButton->date(), timeButton->time() ); |
241 | 244 | ||
242 | if ( dt.isValid() ) setTime(dt); | 245 | if ( dt.isValid() ) setTime(dt); |
243 | } | 246 | } |
244 | 247 | ||
245 | void SetDateTime::setTime(QDateTime dt) | 248 | void SetDateTime::setTime(QDateTime dt) |
246 | { | 249 | { |
247 | // really turn off the screensaver before doing anything | 250 | // really turn off the screensaver before doing anything |
248 | { | 251 | { |