summaryrefslogtreecommitdiff
Side-by-side diff
Diffstat (more/less context) (show whitespace changes)
-rw-r--r--noncore/settings/netsystemtime/ntp.cpp21
-rw-r--r--noncore/settings/netsystemtime/ntp.h3
2 files changed, 19 insertions, 5 deletions
diff --git a/noncore/settings/netsystemtime/ntp.cpp b/noncore/settings/netsystemtime/ntp.cpp
index b2f5332..6a5c062 100644
--- a/noncore/settings/netsystemtime/ntp.cpp
+++ b/noncore/settings/netsystemtime/ntp.cpp
@@ -36,15 +36,14 @@ Ntp::Ntp( QWidget* parent, const char* name, WFlags fl )
if ( srvCount==0 ) ComboNtpSrv->insertItem(tr("time.fu-berlin.de"));
Config cfg("ntp",Config::User);
cfg.setGroup("settings");
-// _maxOffset = cfg.readNumEntry("maxOffset",5);
-// _minLookupDiff = cfg.readNumEntry("minLookupDiff",10);
SpinBoxMinLookupDelay->setValue( cfg.readNumEntry("minLookupDiff",41) );
SpinBoxNtpDelay->setValue( cfg.readNumEntry("ntpRefreshFreq",42) );
ComboNtpSrv->setCurrentItem( cfg.readNumEntry("ntpServer", 0) );
ntpTimer = new QTimer(this);
+ processTimer = new QTimer(this);
ntpTimer->start(SpinBoxNtpDelay->value()*1000*60);
ntpProcess = new OProcess( );
connect( SpinBoxNtpDelay, SIGNAL( valueChanged(int) ),
@@ -115,8 +114,11 @@ void Ntp::slotRunNtp()
}
}
TextLabelStartTime->setText(QDateTime::currentDateTime().toString());
ntpOutPut( tr("Running:")+"\nntpdate "+getNtpServer() );
+ connect( processTimer, SIGNAL( timeout() ), SLOT(slotTimeoutNtpProcess()) );
+ processTimer->start(2*1000*60, true);
+
ntpProcess->clearArguments();
*ntpProcess << "ntpdate" << getNtpServer();
bool ret = ntpProcess->start(OProcess::NotifyOnExit,OProcess::AllOutput);
if ( !ret ) {
@@ -137,10 +139,16 @@ void Ntp::getNtpOutput(OProcess *proc, char *buffer, int buflen)
}
lineStrOld = lineStr;
}
-void Ntp::ntpFinished(OProcess*)
+void Ntp::ntpFinished(OProcess *p)
+{
+ if (!p->normalExit())
{
+ slotProbeNtpServer();
+ return;
+ }
+ processTimer->stop();
Config cfg("ntp",Config::User);
cfg.setGroup("lookups");
int lastLookup = cfg.readNumEntry("time",0);
int lookupCount = cfg.readNumEntry("count",-1);
@@ -260,9 +268,8 @@ void Ntp::slotCheckNtp(int i)
if (i>0)ntpOutPut(tr("Could not connect to server ")+getNtpServer());
connect( ButtonSetTime, SIGNAL(clicked()), SLOT(setPredictTime()) );
connect( ntpTimer, SIGNAL( timeout() ), SLOT(slotProbeNtpServer()) );
}
-// ntpTimer->start(SpinBoxNtpDelay->value()*1000*60);
}
void Ntp::slotProbeNtpServer()
{
@@ -278,4 +285,10 @@ void Ntp::ntpOutPut(QString out)
{
MultiLineEditntpOutPut->append(out);
MultiLineEditntpOutPut->setCursorPosition(MultiLineEditntpOutPut->numLines() + 1,0,FALSE);
}
+
+void Ntp::slotTimeoutNtpProcess()
+{
+ ntpProcess->kill();
+ slotProbeNtpServer();
+}
diff --git a/noncore/settings/netsystemtime/ntp.h b/noncore/settings/netsystemtime/ntp.h
index c78dc55..d166973 100644
--- a/noncore/settings/netsystemtime/ntp.h
+++ b/noncore/settings/netsystemtime/ntp.h
@@ -24,9 +24,9 @@ private:
QString _ntpOutput;
float _shiftPerSec;
int _lookupDiff;
OProcess *ntpProcess;
- QTimer *ntpTimer;
+ QTimer *ntpTimer, *processTimer;
QSocket *ntpSock;
float getTimeShift();
void readLookups();
@@ -41,7 +41,8 @@ private slots:
void slotCheckNtp(int);
void setPredictTime();
void slotProbeNtpServer();
void slotNtpDelayChanged(int);
+ void slotTimeoutNtpProcess();
};
#endif