summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/settings/netsystemtime/mainwindow.cpp2
1 files changed, 1 insertions, 1 deletions
diff --git a/noncore/settings/netsystemtime/mainwindow.cpp b/noncore/settings/netsystemtime/mainwindow.cpp
index 01d9a98..1f9f8c3 100644
--- a/noncore/settings/netsystemtime/mainwindow.cpp
+++ b/noncore/settings/netsystemtime/mainwindow.cpp
@@ -256,129 +256,129 @@ void MainWindow::slotDisplayNTPTab( bool display )
256 256
257 // Create widget if it hasn't needed 257 // Create widget if it hasn't needed
258 if ( display && !ntpTab ) 258 if ( display && !ntpTab )
259 { 259 {
260 ntpTab = new NTPTabWidget( mainWidget ); 260 ntpTab = new NTPTabWidget( mainWidget );
261 connect( ntpTab, SIGNAL(getNTPTime()), this, SLOT(slotGetNTPTime()) ); 261 connect( ntpTab, SIGNAL(getNTPTime()), this, SLOT(slotGetNTPTime()) );
262 } 262 }
263 263
264 // Display/hide tab 264 // Display/hide tab
265 display ? mainWidget->addTab( ntpTab, "netsystemtime/ntptab", tr( "Time Server" ) ) 265 display ? mainWidget->addTab( ntpTab, "netsystemtime/ntptab", tr( "Time Server" ) )
266 : mainWidget->removePage( ntpTab ); 266 : mainWidget->removePage( ntpTab );
267} 267}
268 268
269void MainWindow::slotDisplayPredictTab( bool display ) 269void MainWindow::slotDisplayPredictTab( bool display )
270{ 270{
271 predictTabEnabled = display; 271 predictTabEnabled = display;
272 272
273 // Create widget if it hasn't needed 273 // Create widget if it hasn't needed
274 if ( display && !predictTab ) 274 if ( display && !predictTab )
275 { 275 {
276 } 276 }
277 // Display/hide tab 277 // Display/hide tab
278 display ? mainWidget->addTab( predictTab, "netsystemtime/predicttab", tr( "Predict" ) ) 278 display ? mainWidget->addTab( predictTab, "netsystemtime/predicttab", tr( "Predict" ) )
279 : mainWidget->removePage( predictTab ); 279 : mainWidget->removePage( predictTab );
280} 280}
281 281
282void MainWindow::slotGetNTPTime() 282void MainWindow::slotGetNTPTime()
283{ 283{
284 ntpInteractive = true; 284 ntpInteractive = true;
285 runNTP(); 285 runNTP();
286} 286}
287 287
288void MainWindow::slotTimerGetNTPTime() 288void MainWindow::slotTimerGetNTPTime()
289{ 289{
290 ntpInteractive = false; 290 ntpInteractive = false;
291 runNTP(); 291 runNTP();
292} 292}
293 293
294void MainWindow::slotProbeNTPServer() 294void MainWindow::slotProbeNTPServer()
295{ 295{
296 ntpSock->connectToHost( settingsTab->ntpServer(), 123 ); 296 ntpSock->connectToHost( settingsTab->ntpServer(), 123 );
297} 297}
298 298
299void MainWindow::slotNtpOutput( OProcess *, char *buffer, int buflen ) 299void MainWindow::slotNtpOutput( OProcess *, char *buffer, int buflen )
300{ 300{
301 QString output = QString( buffer ).left( buflen ); 301 QString output = QString( buffer ).left( buflen );
302 ntpOutput.append( output ); 302 ntpOutput.append( output );
303 303
304 if ( ntpTabEnabled ) 304 if ( ntpTabEnabled )
305 ntpTab->addNtpOutput( output ); 305 ntpTab->addNtpOutput( output );
306} 306}
307 307
308void MainWindow::slotNtpFinished( OProcess *p ) 308void MainWindow::slotNtpFinished( OProcess *p )
309{ 309{
310 QString output; 310 QString output;
311 QDateTime dt = QDateTime::currentDateTime(); 311 QDateTime dt = QDateTime::currentDateTime();
312 312
313 // Re-enable set time buttons & change app caption to indicate time update is happening 313 // Re-enable set time buttons & change app caption to indicate time update is happening
314 if ( ntpTabEnabled ) 314 if ( ntpTabEnabled )
315 ntpTab->setNTPBtnEnabled( true ); 315 ntpTab->setNTPBtnEnabled( true );
316 timeTab->setNTPBtnEnabled( true ); 316 timeTab->setNTPBtnEnabled( true );
317 setCaption( tr( "SystemTime" ) ); 317 setCaption( tr( "SystemTime" ) );
318 318
319 // Verify run was successful 319 // Verify run was successful
320 if ( p->exitStatus() != 0 || !p->normalExit() ) 320 if ( p->exitStatus() != 0 )
321 { 321 {
322 if ( isVisible() && ntpInteractive ) 322 if ( isVisible() && ntpInteractive )
323 { 323 {
324 output = tr( "Error while getting time from\n server: " ); 324 output = tr( "Error while getting time from\n server: " );
325 output.append( settingsTab->ntpServer() ); 325 output.append( settingsTab->ntpServer() );
326 QMessageBox::critical(this, tr( "Error" ), output ); 326 QMessageBox::critical(this, tr( "Error" ), output );
327 } 327 }
328 // slotCheckNtp(-1); 328 // slotCheckNtp(-1);
329 return; 329 return;
330 } 330 }
331 331
332 // Set controls on time tab to new time value 332 // Set controls on time tab to new time value
333 timeTab->setDateTime( dt ); 333 timeTab->setDateTime( dt );
334 334
335 // Write out lookup information 335 // Write out lookup information
336 Config config( "ntp" ); 336 Config config( "ntp" );
337 config.setGroup( "lookups" ); 337 config.setGroup( "lookups" );
338 int lastLookup = config.readNumEntry( "time", 0 ); 338 int lastLookup = config.readNumEntry( "time", 0 );
339 int lookupCount = config.readNumEntry( "count", 0 ); 339 int lookupCount = config.readNumEntry( "count", 0 );
340 bool lastNtp = config.readBoolEntry( "lastNtp", false ); 340 bool lastNtp = config.readBoolEntry( "lastNtp", false );
341 int time = TimeConversion::toUTC( QDateTime::currentDateTime() ); 341 int time = TimeConversion::toUTC( QDateTime::currentDateTime() );
342 config.writeEntry( "time", time ); 342 config.writeEntry( "time", time );
343 343
344 // Calculate new time/time shift 344 // Calculate new time/time shift
345 QString _offset = "offset"; 345 QString _offset = "offset";
346 QString _sec = "sec"; 346 QString _sec = "sec";
347 QRegExp _reOffset = QRegExp( _offset ); 347 QRegExp _reOffset = QRegExp( _offset );
348 QRegExp _reEndOffset = QRegExp( _sec ); 348 QRegExp _reEndOffset = QRegExp( _sec );
349 int posOffset = _reOffset.match( ntpOutput ); 349 int posOffset = _reOffset.match( ntpOutput );
350 int posEndOffset = _reEndOffset.match( ntpOutput, posOffset ); 350 int posEndOffset = _reEndOffset.match( ntpOutput, posOffset );
351 posOffset += _offset.length() + 1; 351 posOffset += _offset.length() + 1;
352 QString diff = ntpOutput.mid( posOffset, posEndOffset - posOffset - 1 ); 352 QString diff = ntpOutput.mid( posOffset, posEndOffset - posOffset - 1 );
353 353
354 float timeShift = diff.toFloat(); 354 float timeShift = diff.toFloat();
355 if ( timeShift == 0.0 ) 355 if ( timeShift == 0.0 )
356 return; 356 return;
357 int secsSinceLast = time - lastLookup; 357 int secsSinceLast = time - lastLookup;
358 output = tr( "%1 seconds").arg(QString::number( timeShift )); 358 output = tr( "%1 seconds").arg(QString::number( timeShift ));
359 359
360 // Display information on time server tab 360 // Display information on time server tab
361 if ( ntpTabEnabled ) 361 if ( ntpTabEnabled )
362 { 362 {
363 ntpTab->setTimeShift( output ); 363 ntpTab->setTimeShift( output );
364 ntpTab->setNewTime( dt.toString() ); 364 ntpTab->setNewTime( dt.toString() );
365 } 365 }
366 366
367 if ( lastNtp && lastLookup > 0 && secsSinceLast > 60 * ntpDelay ) 367 if ( lastNtp && lastLookup > 0 && secsSinceLast > 60 * ntpDelay )
368 { 368 {
369 QString grpname = QString( "lookup_" ).append( QString::number( lookupCount ) ); 369 QString grpname = QString( "lookup_" ).append( QString::number( lookupCount ) );
370 config.setGroup( grpname ); 370 config.setGroup( grpname );
371 lookupCount++; 371 lookupCount++;
372 predictTab->setShiftPerSec( (int)(timeShift / secsSinceLast) ); 372 predictTab->setShiftPerSec( (int)(timeShift / secsSinceLast) );
373 config.writeEntry( "secsSinceLast", secsSinceLast ); 373 config.writeEntry( "secsSinceLast", secsSinceLast );
374 config.writeEntry( "timeShift", QString::number( timeShift ) ); 374 config.writeEntry( "timeShift", QString::number( timeShift ) );
375 config.setGroup( "lookups" ); 375 config.setGroup( "lookups" );
376 config.writeEntry( "count", lookupCount ); 376 config.writeEntry( "count", lookupCount );
377 config.writeEntry( "lastNtp", true ); 377 config.writeEntry( "lastNtp", true );
378 } 378 }
379} 379}
380 380
381void MainWindow::slotNTPDelayChanged( int delay ) 381void MainWindow::slotNTPDelayChanged( int delay )
382{ 382{
383 ntpTimer->changeInterval( delay * 1000 * 60 ); 383 ntpTimer->changeInterval( delay * 1000 * 60 );
384 ntpDelay = delay; 384 ntpDelay = delay;