Diffstat (limited to 'noncore/settings/netsystemtime/settime.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/settings/netsystemtime/settime.cpp | 24 |
1 files changed, 13 insertions, 11 deletions
diff --git a/noncore/settings/netsystemtime/settime.cpp b/noncore/settings/netsystemtime/settime.cpp index dac5bd4..01268c9 100644 --- a/noncore/settings/netsystemtime/settime.cpp +++ b/noncore/settings/netsystemtime/settime.cpp | |||
@@ -199,58 +199,60 @@ void SetDateTime::accept() | |||
199 | config.writeEntry( "ShortOrder", df.shortOrder()); | 199 | config.writeEntry( "ShortOrder", df.shortOrder()); |
200 | config.writeEntry( "LongOrder", df.longOrder()); | 200 | config.writeEntry( "LongOrder", df.longOrder()); |
201 | config.writeEntry( "ClockApplet", clockAppletCombo->currentItem() ); | 201 | config.writeEntry( "ClockApplet", clockAppletCombo->currentItem() ); |
202 | 202 | ||
203 | Config lconfig("locale"); | 203 | Config lconfig("locale"); |
204 | lconfig.setGroup( "Location" ); | 204 | lconfig.setGroup( "Location" ); |
205 | lconfig.writeEntry( "Timezone", tz->currentZone() ); | 205 | lconfig.writeEntry( "Timezone", tz->currentZone() ); |
206 | 206 | ||
207 | } | 207 | } |
208 | 208 | ||
209 | void SetDateTime::commitTime() | 209 | void SetDateTime::commitTime() |
210 | { | 210 | { |
211 | Config cfg("ntp",Config::User); | ||
212 | cfg.setGroup("lookups"); | ||
213 | int time = TimeConversion::toUTC( QDateTime::currentDateTime() ); | ||
214 | cfg.writeEntry("time", time); | ||
215 | tz->setFocus(); | 211 | tz->setFocus(); |
216 | // really turn off the screensaver before doing anything | 212 | // really turn off the screensaver before doing anything |
217 | { | 213 | { |
218 | // Needs to be encased in { } so that it deconstructs and sends | 214 | // Needs to be encased in { } so that it deconstructs and sends |
219 | QCopEnvelope disableScreenSaver( "QPE/System", "setScreenSaverIntervals(int,int,int)" ); | 215 | QCopEnvelope disableScreenSaver( "QPE/System", "setScreenSaverIntervals(int,int,int)" ); |
220 | disableScreenSaver << 0 << 0 << 0; | 216 | disableScreenSaver << 0 << 0 << 0; |
221 | } | 217 | } |
222 | // Need to process the QCOP event generated above before proceeding | 218 | // Need to process the QCOP event generated above before proceeding |
223 | qApp->processEvents(); | 219 | qApp->processEvents(); |
224 | 220 | ||
225 | // before we progress further, set our TZ! | 221 | // before we progress further, set our TZ! |
226 | setenv( "TZ", tz->currentZone(), 1 ); | 222 | setenv( "TZ", tz->currentZone(), 1 ); |
227 | // now set the time... | 223 | // now set the time... |
228 | QDateTime dt( dateButton->date(), timeButton->time() ); | 224 | QDateTime dt( dateButton->date(), timeButton->time() ); |
229 | 225 | ||
230 | if ( dt.isValid() ) { | 226 | if ( dt.isValid() ) setTime(dt); |
231 | struct timeval myTv; | 227 | } |
232 | myTv.tv_sec = TimeConversion::toUTC( dt ); | 228 | |
233 | myTv.tv_usec = 0; | 229 | void SetDateTime::setTime(QDateTime dt) |
230 | { | ||
231 | Config cfg("ntp",Config::User); | ||
232 | cfg.setGroup("correction"); | ||
233 | int t = TimeConversion::toUTC(dt); | ||
234 | struct timeval myTv; | ||
235 | myTv.tv_sec = t; | ||
236 | cfg.writeEntry("time", t ); | ||
237 | myTv.tv_usec = 0; | ||
234 | 238 | ||
235 | if ( myTv.tv_sec != -1 ) | 239 | if ( myTv.tv_sec != -1 ) |
236 | ::settimeofday( &myTv, 0 ); | 240 | ::settimeofday( &myTv, 0 ); |
237 | Global::writeHWClock(); | 241 | Global::writeHWClock(); |
238 | // since time has changed quickly load in the datebookdb | 242 | // since time has changed quickly load in the datebookdb |
239 | // to allow the alarm server to get a better grip on itself | 243 | // to allow the alarm server to get a better grip on itself |
240 | // (example re-trigger alarms for when we travel back in time) | 244 | // (example re-trigger alarms for when we travel back in time) |
241 | DateBookDB db; | 245 | DateBookDB db; |
242 | } else { | 246 | |
243 | qWarning( "Invalid date/time" ); | ||
244 | } | ||
245 | // set the timezone for everyone else... | 247 | // set the timezone for everyone else... |
246 | QCopEnvelope setTimeZone( "QPE/System", "timeChange(QString)" ); | 248 | QCopEnvelope setTimeZone( "QPE/System", "timeChange(QString)" ); |
247 | setTimeZone << tz->currentZone(); | 249 | setTimeZone << tz->currentZone(); |
248 | 250 | ||
249 | // AM/PM setting and notify time changed | 251 | // AM/PM setting and notify time changed |
250 | QCopEnvelope setClock( "QPE/System", "clockChange(bool)" ); | 252 | QCopEnvelope setClock( "QPE/System", "clockChange(bool)" ); |
251 | setClock << ampmCombo->currentItem(); | 253 | setClock << ampmCombo->currentItem(); |
252 | 254 | ||
253 | // Notify everyone what day we prefer to start the week on. | 255 | // Notify everyone what day we prefer to start the week on. |
254 | QCopEnvelope setWeek( "QPE/System", "weekChange(bool)" ); | 256 | QCopEnvelope setWeek( "QPE/System", "weekChange(bool)" ); |
255 | setWeek << weekStartCombo->currentItem(); | 257 | setWeek << weekStartCombo->currentItem(); |
256 | 258 | ||