Diffstat (limited to 'noncore/settings/netsystemtime/ntp.cpp') (more/less context) (show whitespace changes)
-rw-r--r-- | noncore/settings/netsystemtime/ntp.cpp | 21 |
1 files changed, 17 insertions, 4 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 @@ -38,6 +38,4 @@ Ntp::Ntp( QWidget* parent, const char* name, WFlags fl ) 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) ); @@ -45,4 +43,5 @@ Ntp::Ntp( QWidget* parent, const char* name, WFlags fl ) ntpTimer = new QTimer(this); + processTimer = new QTimer(this); ntpTimer->start(SpinBoxNtpDelay->value()*1000*60); @@ -117,4 +116,7 @@ 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(); @@ -139,6 +141,12 @@ void Ntp::getNtpOutput(OProcess *proc, char *buffer, int buflen) } -void Ntp::ntpFinished(OProcess*) +void Ntp::ntpFinished(OProcess *p) +{ + if (!p->normalExit()) { + slotProbeNtpServer(); + return; + } + processTimer->stop(); Config cfg("ntp",Config::User); cfg.setGroup("lookups"); @@ -262,5 +270,4 @@ void Ntp::slotCheckNtp(int i) connect( ntpTimer, SIGNAL( timeout() ), SLOT(slotProbeNtpServer()) ); } -// ntpTimer->start(SpinBoxNtpDelay->value()*1000*60); } @@ -280,2 +287,8 @@ void Ntp::ntpOutPut(QString out) MultiLineEditntpOutPut->setCursorPosition(MultiLineEditntpOutPut->numLines() + 1,0,FALSE); } + +void Ntp::slotTimeoutNtpProcess() +{ + ntpProcess->kill(); + slotProbeNtpServer(); +} |