author | tille <tille> | 2002-07-06 16:11:39 (UTC) |
---|---|---|
committer | tille <tille> | 2002-07-06 16:11:39 (UTC) |
commit | 8beb5fcdbca8110dc586a7e620bf8eae892087fb (patch) (unidiff) | |
tree | e3f96de0e645f160fd54bdcb6b4c36a25f4437c1 | |
parent | b83751deab22e8e25d21265bd59ab53766109ca2 (diff) | |
download | opie-8beb5fcdbca8110dc586a7e620bf8eae892087fb.zip opie-8beb5fcdbca8110dc586a7e620bf8eae892087fb.tar.gz opie-8beb5fcdbca8110dc586a7e620bf8eae892087fb.tar.bz2 |
qcop calls
-rw-r--r-- | noncore/settings/netsystemtime/ntp.cpp | 10 | ||||
-rw-r--r-- | noncore/settings/netsystemtime/settime.cpp | 6 |
2 files changed, 10 insertions, 6 deletions
diff --git a/noncore/settings/netsystemtime/ntp.cpp b/noncore/settings/netsystemtime/ntp.cpp index 2b779fa..15dae93 100644 --- a/noncore/settings/netsystemtime/ntp.cpp +++ b/noncore/settings/netsystemtime/ntp.cpp | |||
@@ -249,77 +249,81 @@ void Ntp::preditctTime() | |||
249 | TextLabelPredTime->setText(predictedTime.toString()); | 249 | TextLabelPredTime->setText(predictedTime.toString()); |
250 | TextLabelMainPredTime->setText(tr("Predicted time:")+"<br><b>"+predictedTime.toString()+"</b>"); | 250 | TextLabelMainPredTime->setText(tr("Predicted time:")+"<br><b>"+predictedTime.toString()+"</b>"); |
251 | } | 251 | } |
252 | 252 | ||
253 | void Ntp::setPredictTime() | 253 | void Ntp::setPredictTime() |
254 | { | 254 | { |
255 | preditctTime(); | 255 | preditctTime(); |
256 | setTime( predictedTime ); | 256 | setTime( predictedTime ); |
257 | } | 257 | } |
258 | 258 | ||
259 | void Ntp::slotCheckNtp(int i) | 259 | void Ntp::slotCheckNtp(int i) |
260 | { | 260 | { |
261 | if (i == 0) | 261 | if (i == 0) |
262 | { | 262 | { |
263 | TextLabelMainPredTime->hide(); | 263 | TextLabelMainPredTime->hide(); |
264 | ButtonSetTime->setText( tr("Get time from network") ); | 264 | ButtonSetTime->setText( tr("Get time from network") ); |
265 | connect( ButtonSetTime, SIGNAL(clicked()), SLOT(slotRunNtp()) ); | 265 | connect( ButtonSetTime, SIGNAL(clicked()), SLOT(slotRunNtp()) ); |
266 | if ( ntpDelayElapsed() ) | 266 | if ( ntpDelayElapsed() ) |
267 | { | 267 | { |
268 | slotRunNtp(); | 268 | slotRunNtp(); |
269 | disconnect(ntpTimer, SIGNAL( timeout() ), this, SLOT(slotProbeNtpServer()) ); | 269 | disconnect(ntpTimer, SIGNAL( timeout() ), this, SLOT(slotProbeNtpServer()) ); |
270 | connect(ntpTimer, SIGNAL( timeout() ), SLOT(slotRunNtp()) ); | 270 | connect(ntpTimer, SIGNAL( timeout() ), SLOT(slotRunNtp()) ); |
271 | }else{ | 271 | }else{ |
272 | disconnect(ntpTimer, SIGNAL( timeout() ), this, SLOT(slotRunNtp()) ); | 272 | disconnect(ntpTimer, SIGNAL( timeout() ), this, SLOT(slotRunNtp()) ); |
273 | connect(ntpTimer, SIGNAL( timeout() ), SLOT(slotProbeNtpServer()) ); | 273 | connect(ntpTimer, SIGNAL( timeout() ), SLOT(slotProbeNtpServer()) ); |
274 | } | 274 | } |
275 | }else{ | 275 | }else{ |
276 | preditctTime(); | 276 | preditctTime(); |
277 | ButtonSetTime->setText( tr("Set predicted time") ); | 277 | ButtonSetTime->setText( tr("Set predicted time") ); |
278 | if (i>0)ntpOutPut(tr("Could not connect to server ")+getNtpServer()); | 278 | if (i>0)ntpOutPut(tr("Could not connect to server ")+getNtpServer()); |
279 | connect( ButtonSetTime, SIGNAL(clicked()), SLOT(setPredictTime()) ); | 279 | connect( ButtonSetTime, SIGNAL(clicked()), SLOT(setPredictTime()) ); |
280 | connect( ntpTimer, SIGNAL( timeout() ), SLOT(slotProbeNtpServer()) ); | 280 | connect( ntpTimer, SIGNAL( timeout() ), SLOT(slotProbeNtpServer()) ); |
281 | } | 281 | } |
282 | } | 282 | } |
283 | 283 | ||
284 | void Ntp::slotProbeNtpServer() | 284 | void Ntp::slotProbeNtpServer() |
285 | { | 285 | { |
286 | qDebug("Ntp::slotProbeNtpServer()"); | 286 | qDebug("Ntp::slotProbeNtpServer()"); |
287 | ntpSock->connectToHost( getNtpServer() ,123); | 287 | ntpSock->connectToHost( getNtpServer() ,123); |
288 | } | 288 | } |
289 | 289 | ||
290 | void Ntp::slotNtpDelayChanged(int delay) | 290 | void Ntp::slotNtpDelayChanged(int delay) |
291 | { | 291 | { |
292 | ntpTimer->changeInterval( delay*1000*60 ); | 292 | ntpTimer->changeInterval( delay*1000*60 ); |
293 | } | 293 | } |
294 | 294 | ||
295 | void Ntp::ntpOutPut(QString out) | 295 | void Ntp::ntpOutPut(QString out) |
296 | { | 296 | { |
297 | MultiLineEditntpOutPut->append(out); | 297 | MultiLineEditntpOutPut->append(out); |
298 | MultiLineEditntpOutPut->setCursorPosition(MultiLineEditntpOutPut->numLines() + 1,0,FALSE); | 298 | MultiLineEditntpOutPut->setCursorPosition(MultiLineEditntpOutPut->numLines() + 1,0,FALSE); |
299 | } | 299 | } |
300 | 300 | ||
301 | 301 | ||
302 | void Ntp::makeChannel() | 302 | void Ntp::makeChannel() |
303 | { | 303 | { |
304 | channel = new QCopChannel( "QPE/Application/netsystemtime", this ); | 304 | channel = new QCopChannel( "QPE/Application/netsystemtime", this ); |
305 | connect( channel, SIGNAL(received(const QCString&, const QByteArray&)), | 305 | connect( channel, SIGNAL(received(const QCString&, const QByteArray&)), |
306 | this, SLOT(receive(const QCString&, const QByteArray&)) ); | 306 | this, SLOT(receive(const QCString&, const QByteArray&)) ); |
307 | } | 307 | } |
308 | 308 | ||
309 | 309 | ||
310 | 310 | ||
311 | void Ntp::receive(const QCString &msg, const QByteArray &arg) | 311 | void Ntp::receive(const QCString &msg, const QByteArray &arg) |
312 | { | 312 | { |
313 | qDebug("QCop "+msg+" "+QCString(arg)); | 313 | qDebug("QCop(Ntp) "+msg+" "+QCString(arg)); |
314 | if ( msg == "open(QString)" ) | 314 | if ( msg == "ntpLookup(QString)" ) |
315 | { | 315 | { |
316 | //qApp->exec(); | 316 | slotRunNtp(); |
317 | } | ||
318 | if ( msg == "setPredictedTime(QString)" ) | ||
319 | { | ||
320 | setPredictTime(); | ||
317 | }else{ | 321 | }else{ |
318 | qDebug("Ntp::receive: Huh what do ya want"); | 322 | qDebug("Ntp::receive: Huh what do ya want"); |
319 | } | 323 | } |
320 | } | 324 | } |
321 | 325 | ||
322 | void Ntp::setDocument(const QString &fileName) | 326 | void Ntp::setDocument(const QString &fileName) |
323 | { | 327 | { |
324 | 328 | ||
325 | } \ No newline at end of file | 329 | } \ No newline at end of file |
diff --git a/noncore/settings/netsystemtime/settime.cpp b/noncore/settings/netsystemtime/settime.cpp index 9c5323a..b0fcb74 100644 --- a/noncore/settings/netsystemtime/settime.cpp +++ b/noncore/settings/netsystemtime/settime.cpp | |||
@@ -207,131 +207,131 @@ SetDateTime::~SetDateTime() | |||
207 | { | 207 | { |
208 | writeSettings(); | 208 | writeSettings(); |
209 | 209 | ||
210 | } | 210 | } |
211 | 211 | ||
212 | void SetDateTime::writeSettings() | 212 | void SetDateTime::writeSettings() |
213 | { | 213 | { |
214 | Config config("qpe"); | 214 | Config config("qpe"); |
215 | config.setGroup( "Time" ); | 215 | config.setGroup( "Time" ); |
216 | config.writeEntry( "AMPM", ampmCombo->currentItem() ); | 216 | config.writeEntry( "AMPM", ampmCombo->currentItem() ); |
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); | 233 | Config cfg("ntp",Config::User); |
234 | cfg.setGroup("lookups"); | 234 | cfg.setGroup("lookups"); |
235 | cfg.writeEntry("lastNtp",false); | 235 | cfg.writeEntry("lastNtp",false); |
236 | tz->setFocus(); | 236 | tz->setFocus(); |
237 | // Need to process the QCOP event generated above before proceeding | 237 | // Need to process the QCOP event generated above before proceeding |
238 | qApp->processEvents(); | 238 | qApp->processEvents(); |
239 | 239 | ||
240 | // before we progress further, set our TZ! | 240 | // before we progress further, set our TZ! |
241 | setenv( "TZ", tz->currentZone(), 1 ); | 241 | setenv( "TZ", tz->currentZone(), 1 ); |
242 | // now set the time... | 242 | // now set the time... |
243 | QDateTime dt( dateButton->date(), timeButton->time() ); | 243 | QDateTime dt( dateButton->date(), timeButton->time() ); |
244 | 244 | ||
245 | if ( dt.isValid() ) setTime(dt); | 245 | if ( dt.isValid() ) setTime(dt); |
246 | } | 246 | } |
247 | 247 | ||
248 | void SetDateTime::setTime(QDateTime dt) | 248 | void SetDateTime::setTime(QDateTime dt) |
249 | { | 249 | { |
250 | // really turn off the screensaver before doing anything | 250 | // really turn off the screensaver before doing anything |
251 | { | 251 | { |
252 | // Needs to be encased in { } so that it deconstructs and sends | 252 | // Needs to be encased in { } so that it deconstructs and sends |
253 | QCopEnvelope disableScreenSaver( "QPE/System", "setScreenSaverIntervals(int,int,int)" ); | 253 | QCopEnvelope disableScreenSaver( "QPE/System", "setScreenSaverIntervals(int,int,int)" ); |
254 | disableScreenSaver << 0 << 0 << 0; | 254 | disableScreenSaver << 0 << 0 << 0; |
255 | } | 255 | } |
256 | Config cfg("ntp",Config::User); | 256 | Config cfg("ntp",Config::User); |
257 | cfg.setGroup("correction"); | 257 | cfg.setGroup("correction"); |
258 | int t = TimeConversion::toUTC(dt); | 258 | int t = TimeConversion::toUTC(dt); |
259 | struct timeval myTv; | 259 | struct timeval myTv; |
260 | myTv.tv_sec = t; | 260 | myTv.tv_sec = t; |
261 | cfg.writeEntry("time", t ); | 261 | cfg.writeEntry("time", t ); |
262 | myTv.tv_usec = 0; | 262 | myTv.tv_usec = 0; |
263 | 263 | ||
264 | if ( myTv.tv_sec != -1 ) | 264 | if ( myTv.tv_sec != -1 ) |
265 | ::settimeofday( &myTv, 0 ); | 265 | ::settimeofday( &myTv, 0 ); |
266 | Global::writeHWClock(); | 266 | Global::writeHWClock(); |
267 | // since time has changed quickly load in the datebookdb | 267 | // since time has changed quickly load in the datebookdb |
268 | // to allow the alarm server to get a better grip on itself | 268 | // to allow the alarm server to get a better grip on itself |
269 | // (example re-trigger alarms for when we travel back in time) | 269 | // (example re-trigger alarms for when we travel back in time) |
270 | DateBookDB db; | 270 | DateBookDB db; |
271 | // Restore screensaver | 271 | // Restore screensaver |
272 | QCopEnvelope enableScreenSaver( "QPE/System", "setScreenSaverIntervals(int,int,int)" ); | 272 | QCopEnvelope enableScreenSaver( "QPE/System", "setScreenSaverIntervals(int,int,int)" ); |
273 | enableScreenSaver << -1 << -1 << -1; | 273 | enableScreenSaver << -1 << -1 << -1; |
274 | } | 274 | } |
275 | 275 | ||
276 | void SetDateTime::updateSystem(int i) | 276 | void SetDateTime::updateSystem(int i) |
277 | { | 277 | { |
278 | // really turn off the screensaver before doing anything | 278 | // really turn off the screensaver before doing anything |
279 | { | 279 | { |
280 | // Needs to be encased in { } so that it deconstructs and sends | 280 | // Needs to be encased in { } so that it deconstructs and sends |
281 | QCopEnvelope disableScreenSaver( "QPE/System", "setScreenSaverIntervals(int,int,int)" ); | 281 | QCopEnvelope disableScreenSaver( "QPE/System", "setScreenSaverIntervals(int,int,int)" ); |
282 | disableScreenSaver << 0 << 0 << 0; | 282 | disableScreenSaver << 0 << 0 << 0; |
283 | } | 283 | } |
284 | qDebug("SetDateTime::updateSystem(int %i)",i); | 284 | qDebug("SetDateTime::updateSystem(int %i)",i); |
285 | writeSettings(); | 285 | writeSettings(); |
286 | 286 | ||
287 | // set the timezone for everyone else... | 287 | // set the timezone for everyone else... |
288 | QCopEnvelope setTimeZone( "QPE/System", "timeChange(QString)" ); | 288 | QCopEnvelope setTimeZone( "QPE/System", "timeChange(QString)" ); |
289 | setTimeZone << tz->currentZone(); | 289 | setTimeZone << tz->currentZone(); |
290 | 290 | ||
291 | // AM/PM setting and notify time changed | 291 | // AM/PM setting and notify time changed |
292 | QCopEnvelope setClock( "QPE/System", "clockChange(bool)" ); | 292 | QCopEnvelope setClock( "QPE/System", "clockChange(bool)" ); |
293 | setClock << ampmCombo->currentItem(); | 293 | setClock << ampmCombo->currentItem(); |
294 | 294 | ||
295 | // Notify everyone what day we prefer to start the week on. | 295 | // Notify everyone what day we prefer to start the week on. |
296 | QCopEnvelope setWeek( "QPE/System", "weekChange(bool)" ); | 296 | QCopEnvelope setWeek( "QPE/System", "weekChange(bool)" ); |
297 | setWeek << weekStartCombo->currentItem(); | 297 | setWeek << weekStartCombo->currentItem(); |
298 | 298 | ||
299 | // Notify everyone what date format to use | 299 | // Notify everyone what date format to use |
300 | QCopEnvelope setDateFormat( "QPE/System", "setDateFormat(DateFormat)" ); | 300 | QCopEnvelope setDateFormat( "QPE/System", "setDateFormat(DateFormat)" ); |
301 | setDateFormat << date_formats[dateFormatCombo->currentItem()]; | 301 | setDateFormat << date_formats[dateFormatCombo->currentItem()]; |
302 | 302 | ||
303 | // Restore screensaver | 303 | // Restore screensaver |
304 | QCopEnvelope enableScreenSaver( "QPE/System", "setScreenSaverIntervals(int,int,int)" ); | 304 | QCopEnvelope enableScreenSaver( "QPE/System", "setScreenSaverIntervals(int,int,int)" ); |
305 | enableScreenSaver << -1 << -1 << -1; | 305 | enableScreenSaver << -1 << -1 << -1; |
306 | // since time has changed quickly load in the datebookdb | 306 | // since time has changed quickly load in the datebookdb |
307 | // to allow the alarm server to get a better grip on itself | 307 | // to allow the alarm server to get a better grip on itself |
308 | // (example re-trigger alarms for when we travel back in time) | 308 | // (example re-trigger alarms for when we travel back in time) |
309 | DateBookDB db; | 309 | DateBookDB db; |
310 | 310 | ||
311 | } | 311 | } |
312 | 312 | ||
313 | void SetDateTime::tzChange( const QString &tz ) | 313 | void SetDateTime::tzChange( const QString &tz ) |
314 | { | 314 | { |
315 | // set the TZ get the time and leave gracefully... | 315 | // set the TZ get the time and leave gracefully... |
316 | QString strSave; | 316 | QString strSave; |
317 | strSave = getenv( "TZ" ); | 317 | strSave = getenv( "TZ" ); |
318 | setenv( "TZ", tz, 1 ); | 318 | setenv( "TZ", tz, 1 ); |
319 | 319 | ||
320 | QDate d = QDate::currentDate(); | 320 | QDate d = QDate::currentDate(); |
321 | // reset the time. | 321 | // reset the time. |
322 | if ( !strSave.isNull() ) { | 322 | if ( !strSave.isNull() ) { |
323 | setenv( "TZ", strSave, 1 ); | 323 | setenv( "TZ", strSave, 1 ); |
324 | } | 324 | } |
325 | dateButton->setDate( d ); | 325 | dateButton->setDate( d ); |
326 | updateSystem(); | 326 | updateSystem(); |
327 | } | 327 | } |
328 | 328 | ||
329 | void SetDateTime::formatChanged(int i) | 329 | void SetDateTime::formatChanged(int i) |
330 | { | 330 | { |
331 | dateButton->setDateFormat(date_formats[i]); | 331 | dateButton->setDateFormat(date_formats[i]); |
332 | } | 332 | } |
333 | 333 | ||
334 | static const int ValueAM = 0; | 334 | static const int ValueAM = 0; |
335 | static const int ValuePM = 1; | 335 | static const int ValuePM = 1; |
336 | 336 | ||
337 | 337 | ||