summaryrefslogtreecommitdiff
path: root/noncore/settings/netsystemtime/ntp.cpp
Unidiff
Diffstat (limited to 'noncore/settings/netsystemtime/ntp.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/settings/netsystemtime/ntp.cpp45
1 files changed, 40 insertions, 5 deletions
diff --git a/noncore/settings/netsystemtime/ntp.cpp b/noncore/settings/netsystemtime/ntp.cpp
index fbd65a2..6f6316c 100644
--- a/noncore/settings/netsystemtime/ntp.cpp
+++ b/noncore/settings/netsystemtime/ntp.cpp
@@ -4,12 +4,15 @@
4#include <qtimer.h> 4#include <qtimer.h>
5#include <qtable.h> 5#include <qtable.h>
6#include <qlabel.h> 6#include <qlabel.h>
7#include <qsocket.h> 7#include <qsocket.h>
8#include <qlineedit.h> 8#include <qlineedit.h>
9#include <qspinbox.h> 9#include <qspinbox.h>
10#include <qcheckbox.h>
11#include <qtabwidget.h>
12#include <qlayout.h>
10#include <qmessagebox.h> 13#include <qmessagebox.h>
11#include <qmultilineedit.h> 14#include <qmultilineedit.h>
12#include <opie/oprocess.h> 15#include <opie/oprocess.h>
13#include <qpe/qpeapplication.h> 16#include <qpe/qpeapplication.h>
14#include <qpe/config.h> 17#include <qpe/config.h>
15#include <qpe/global.h> 18#include <qpe/global.h>
@@ -36,16 +39,22 @@ Ntp::Ntp( QWidget* parent, const char* name, WFlags fl )
36 ComboNtpSrv->insertItem( ntpSrvs.readEntry("name") ); 39 ComboNtpSrv->insertItem( ntpSrvs.readEntry("name") );
37 } 40 }
38 if ( srvCount==0 ) ComboNtpSrv->insertItem(tr("time.fu-berlin.de")); 41 if ( srvCount==0 ) ComboNtpSrv->insertItem(tr("time.fu-berlin.de"));
39 42
40 Config cfg("ntp",Config::User); 43 Config cfg("ntp",Config::User);
41 cfg.setGroup("settings"); 44 cfg.setGroup("settings");
42 SpinBoxMinLookupDelay->setValue( cfg.readNumEntry("minLookupDiff",41) ); 45 SpinBoxMinLookupDelay->setValue( cfg.readNumEntry("minLookupDiff",720) );
43 SpinBoxNtpDelay->setValue( cfg.readNumEntry("ntpRefreshFreq",42) ); 46 SpinBoxNtpDelay->setValue( cfg.readNumEntry("ntpRefreshFreq",1440) );
44 ComboNtpSrv->setCurrentItem( cfg.readNumEntry("ntpServer", 0) ); 47 ComboNtpSrv->setCurrentItem( cfg.readNumEntry("ntpServer", 0) );
45 48
49 bool advMode = cfg.readBoolEntry("advancedFeatures", false );
50 showAdvancedFeatures(advMode);
51 CheckBoxAdvSettings->setChecked( advMode );
52 connect( CheckBoxAdvSettings, SIGNAL( toggled( bool ) ),
53 SLOT( showAdvancedFeatures( bool ) ) );
54
46 makeChannel(); 55 makeChannel();
47 56
48 ntpTimer = new QTimer(this); 57 ntpTimer = new QTimer(this);
49 58
50 ntpProcess = new OProcess( ); 59 ntpProcess = new OProcess( );
51 connect( SpinBoxNtpDelay, SIGNAL( valueChanged(int) ), 60 connect( SpinBoxNtpDelay, SIGNAL( valueChanged(int) ),
@@ -139,13 +148,13 @@ void Ntp::getNtpOutput(OProcess *proc, char *buffer, int buflen)
139 } 148 }
140 lineStrOld = lineStr; 149 lineStrOld = lineStr;
141} 150}
142 151
143void Ntp::ntpFinished(OProcess *p) 152void Ntp::ntpFinished(OProcess *p)
144{ 153{
145 qDebug("p->exitStatus() %i",p->exitStatus()); 154 //qDebug("p->exitStatus() %i",p->exitStatus());
146 if (p->exitStatus()!=0 || !p->normalExit()) 155 if (p->exitStatus()!=0 || !p->normalExit())
147 { 156 {
148 slotProbeNtpServer(); 157 slotProbeNtpServer();
149 return; 158 return;
150 } 159 }
151 160
@@ -274,22 +283,21 @@ void Ntp::slotCheckNtp(int i)
274 }else{ 283 }else{
275 disconnect(ntpTimer, SIGNAL( timeout() ), this, SLOT(slotRunNtp()) ); 284 disconnect(ntpTimer, SIGNAL( timeout() ), this, SLOT(slotRunNtp()) );
276 connect(ntpTimer, SIGNAL( timeout() ), SLOT(slotProbeNtpServer()) ); 285 connect(ntpTimer, SIGNAL( timeout() ), SLOT(slotProbeNtpServer()) );
277 } 286 }
278 }else{ 287 }else{
279 preditctTime(); 288 preditctTime();
280 ButtonSetTime->setText( tr("Set predicted time") ); 289 ButtonSetTime->setText( tr("Set predicted time: ")+predictedTime.toString() );
281 if (i>0)ntpOutPut(tr("Could not connect to server ")+getNtpServer()); 290 if (i>0)ntpOutPut(tr("Could not connect to server ")+getNtpServer());
282 connect( ButtonSetTime, SIGNAL(clicked()), SLOT(setPredictTime()) ); 291 connect( ButtonSetTime, SIGNAL(clicked()), SLOT(setPredictTime()) );
283 connect( ntpTimer, SIGNAL( timeout() ), SLOT(slotProbeNtpServer()) ); 292 connect( ntpTimer, SIGNAL( timeout() ), SLOT(slotProbeNtpServer()) );
284 } 293 }
285} 294}
286 295
287void Ntp::slotProbeNtpServer() 296void Ntp::slotProbeNtpServer()
288{ 297{
289 qDebug("Ntp::slotProbeNtpServer()");
290 ntpSock->connectToHost( getNtpServer() ,123); 298 ntpSock->connectToHost( getNtpServer() ,123);
291} 299}
292 300
293void Ntp::slotNtpDelayChanged(int delay) 301void Ntp::slotNtpDelayChanged(int delay)
294{ 302{
295 ntpTimer->changeInterval( delay*1000*60 ); 303 ntpTimer->changeInterval( delay*1000*60 );
@@ -327,6 +335,33 @@ void Ntp::receive(const QCString &msg, const QByteArray &arg)
327} 335}
328 336
329void Ntp::setDocument(const QString &fileName) 337void Ntp::setDocument(const QString &fileName)
330{ 338{
331 339
332} 340}
341
342void Ntp::showAdvancedFeatures(bool advMode)
343{
344 if (advMode) {
345 TabWidgetMain->addTab( tabPredict, tr( "Predict" ) );
346 TabWidgetMain->addTab( tabNtp, tr( "NTP" ) );
347 TextLabel1_2_2->show();
348 TextLabel2_3->show();
349 TextLabel3_3_2->show();
350 TextLabel1_2->show();
351 SpinBoxMinLookupDelay->show();
352 TextLabel2->show();
353 TextLabel3_3->show();
354 SpinBoxNtpDelay->show();
355 }else{
356 TabWidgetMain->removePage( tabPredict );
357 TabWidgetMain->removePage( tabNtp );
358 TextLabel1_2_2->hide();
359 TextLabel2_3->hide();
360 TextLabel3_3_2->hide();
361 TextLabel1_2->hide();
362 SpinBoxMinLookupDelay->hide();
363 TextLabel2->hide();
364 TextLabel3_3->hide();
365 SpinBoxNtpDelay->hide();
366 };
367}