summaryrefslogtreecommitdiff
Side-by-side diff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/settings/netsystemtime/ntp.cpp58
-rw-r--r--noncore/settings/netsystemtime/ntp.h4
-rw-r--r--noncore/settings/netsystemtime/ntpbase.ui4
-rw-r--r--noncore/settings/netsystemtime/opie-netsystemtime.control2
-rw-r--r--noncore/settings/netsystemtime/settime.cpp2
5 files changed, 41 insertions, 29 deletions
diff --git a/noncore/settings/netsystemtime/ntp.cpp b/noncore/settings/netsystemtime/ntp.cpp
index 364609d..bcbf7a1 100644
--- a/noncore/settings/netsystemtime/ntp.cpp
+++ b/noncore/settings/netsystemtime/ntp.cpp
@@ -46,3 +46,3 @@ Ntp::Ntp( QWidget* parent, const char* name, WFlags fl )
ntpTimer = new QTimer(this);
- ntpTimer->start(SpinBoxNtpDelay->value()*100);
+ ntpTimer->start(SpinBoxNtpDelay->value()*1000*60);
@@ -87,4 +87,3 @@ Ntp::~Ntp()
-
-void Ntp::slotRunNtp()
+bool Ntp::ntpDelayElapsed()
{
@@ -92,11 +91,20 @@ void Ntp::slotRunNtp()
cfg.setGroup("lookups");
- int lookupDiff = TimeConversion::toUTC(QDateTime::currentDateTime()) - cfg.readNumEntry("time",0);
+ _lookupDiff = TimeConversion::toUTC(QDateTime::currentDateTime()) - cfg.readNumEntry("time",0);
+ return (_lookupDiff - (SpinBoxNtpDelay->value()*60)) > -60;
+}
- if ( lookupDiff < SpinBoxNtpDelay->value()*60 )
+QString Ntp::getNtpServer()
+{
+ return ComboNtpSrv->currentText();
+}
+
+void Ntp::slotRunNtp()
+{
+ if ( !ntpDelayElapsed() )
{
switch (
- QMessageBox::warning(this, tr("Run ntp?"),
+ QMessageBox::warning(this, tr("Run NTP?"),
tr("You asked for a delay of ")+SpinBoxNtpDelay->text()+tr(" minutes, but only ")+
- QString::number(lookupDiff%60)+tr(" minutes elapsed since last loopup.")+
- "<br>"+tr("Rerun ntp?"),
+ QString::number(_lookupDiff/60)+tr(" minutes elapsed since last loopup.")+
+ "<br>"+tr("Rerun NTP?"),
QMessageBox::Ok,QMessageBox::Cancel)
@@ -109,8 +117,9 @@ void Ntp::slotRunNtp()
TextLabelStartTime->setText(QDateTime::currentDateTime().toString());
- MultiLineEditntpOutPut->append( "\n"+tr("Running:")+"\nntpdate "+ ComboNtpSrv->currentText()+"\n");
+ ntpOutPut( tr("Running:")+"\nntpdate "+getNtpServer() );
ntpProcess->clearArguments();
- *ntpProcess << "ntpdate" << ComboNtpSrv->currentText();
+ *ntpProcess << "ntpdate" << getNtpServer();
bool ret = ntpProcess->start(OProcess::NotifyOnExit,OProcess::AllOutput);
if ( !ret ) {
- qDebug("Error while executing ntp");
+ qDebug("Error while executing ntpdate");
+ ntpOutPut( tr("Error while executing ntpdate"));
}
@@ -125,3 +134,3 @@ void Ntp::getNtpOutput(OProcess *proc, char *buffer, int buflen)
{
- MultiLineEditntpOutPut->append(lineStr);
+ ntpOutPut(lineStr);
_ntpOutput += lineStr;
@@ -153,3 +162,2 @@ void Ntp::ntpFinished(OProcess*)
_shiftPerSec = timeShift / secsSinceLast;
-// float nextCorr = _maxOffset / _shiftPerSec;
qDebug("secs since last lookup %i", secsSinceLast);qDebug("timeshift since last lookup %f", timeShift);qDebug("timeshift since per sec %f", _shiftPerSec);
@@ -214,3 +222,2 @@ void Ntp::preditctTime()
{
- qDebug("current time: %s",QDateTime::currentDateTime().toString().latin1());
Config cfg("ntp",Config::User);
@@ -240,7 +247,5 @@ void Ntp::slotCheckNtp(int i)
connect( ButtonSetTime, SIGNAL(clicked()), SLOT(slotRunNtp()) );
- Config cfg("ntp",Config::User);
- cfg.setGroup("lookups");
- int lookupDiff = TimeConversion::toUTC(QDateTime::currentDateTime()) - cfg.readNumEntry("time",0);
- if ( lookupDiff > SpinBoxNtpDelay->value()*60 )
+ if ( ntpDelayElapsed() )
{
+ slotRunNtp();
disconnect(ntpTimer, SIGNAL( timeout() ), this, SLOT(slotProbeNtpServer()) );
@@ -254,2 +259,3 @@ void Ntp::slotCheckNtp(int i)
ButtonSetTime->setText( tr("Set predicted time") );
+ if (i>0)ntpOutPut(tr("Could not connect to server ")+getNtpServer());
connect( ButtonSetTime, SIGNAL(clicked()), SLOT(setPredictTime()) );
@@ -257,2 +263,3 @@ void Ntp::slotCheckNtp(int i)
}
+// ntpTimer->start(SpinBoxNtpDelay->value()*1000*60);
}
@@ -261,7 +268,4 @@ void Ntp::slotProbeNtpServer()
{
- Config cfg("ntp",Config::User);
- cfg.setGroup("lookups");
- int lookupDiff = TimeConversion::toUTC(QDateTime::currentDateTime()) - cfg.readNumEntry("time",0);
- if ( lookupDiff > SpinBoxNtpDelay->value()*60 )
- ntpSock->connectToHost( ComboNtpSrv->currentText() ,123);
+ if ( ntpDelayElapsed() )
+ ntpSock->connectToHost( getNtpServer() ,123);
}
@@ -270,3 +274,9 @@ void Ntp::slotNtpDelayChanged(int delay)
{
- ntpTimer->changeInterval( delay*100 );
+ ntpTimer->changeInterval( delay*1000*60 );
+}
+
+void Ntp::ntpOutPut(QString out)
+{
+ MultiLineEditntpOutPut->append(out);
+ MultiLineEditntpOutPut->setCursorPosition(MultiLineEditntpOutPut->numLines() + 1,0,FALSE);
}
diff --git a/noncore/settings/netsystemtime/ntp.h b/noncore/settings/netsystemtime/ntp.h
index 7cc309f..c78dc55 100644
--- a/noncore/settings/netsystemtime/ntp.h
+++ b/noncore/settings/netsystemtime/ntp.h
@@ -25,2 +25,3 @@ private:
float _shiftPerSec;
+ int _lookupDiff;
OProcess *ntpProcess;
@@ -31,2 +32,5 @@ private:
void readLookups();
+ void ntpOutPut(QString);
+ bool ntpDelayElapsed();
+ QString getNtpServer();
private slots:
diff --git a/noncore/settings/netsystemtime/ntpbase.ui b/noncore/settings/netsystemtime/ntpbase.ui
index 4e10fd2..a83dc93 100644
--- a/noncore/settings/netsystemtime/ntpbase.ui
+++ b/noncore/settings/netsystemtime/ntpbase.ui
@@ -13,4 +13,4 @@
<y>0</y>
- <width>331</width>
- <height>426</height>
+ <width>328</width>
+ <height>411</height>
</rect>
diff --git a/noncore/settings/netsystemtime/opie-netsystemtime.control b/noncore/settings/netsystemtime/opie-netsystemtime.control
index 406d7b0..d3290e9 100644
--- a/noncore/settings/netsystemtime/opie-netsystemtime.control
+++ b/noncore/settings/netsystemtime/opie-netsystemtime.control
@@ -1,2 +1,2 @@
-Files: bin/netsystemtime apps/Settings/ntpdatetime.desktop
+Files: bin/netsystemtime apps/Settings/ntpdatetime.desktop etc/ntpservers
Priority: optional
diff --git a/noncore/settings/netsystemtime/settime.cpp b/noncore/settings/netsystemtime/settime.cpp
index 2398c08..93543cd 100644
--- a/noncore/settings/netsystemtime/settime.cpp
+++ b/noncore/settings/netsystemtime/settime.cpp
@@ -302,3 +302,2 @@ void SetDateTime::tzChange( const QString &tz )
{
- qDebug("SetDateTime::tzChange");
// set the TZ get the time and leave gracefully...
@@ -458,3 +457,2 @@ void SetTime::slotTzChange( const QString &tz )
{
- qDebug("SetTime::slotTzChange");
// set the TZ get the time and leave gracefully...