summaryrefslogtreecommitdiff
Side-by-side diff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/settings/netsystemtime/ntp.cpp55
-rw-r--r--noncore/settings/netsystemtime/ntp.h4
2 files changed, 40 insertions, 19 deletions
diff --git a/noncore/settings/netsystemtime/ntp.cpp b/noncore/settings/netsystemtime/ntp.cpp
index 6e74e32..c7e3b52 100644
--- a/noncore/settings/netsystemtime/ntp.cpp
+++ b/noncore/settings/netsystemtime/ntp.cpp
@@ -31,4 +31,5 @@ Ntp::Ntp( QWidget* parent, const char* name, WFlags fl )
: SetDateTime( parent, name, fl )
{
+ _interactive = false;
Config ntpSrvs(QPEApplication::qpeDir()+"etc/ntpservers",Config::File);
ntpSrvs.setGroup("servers");
@@ -79,6 +80,5 @@ Ntp::Ntp( QWidget* parent, const char* name, WFlags fl )
ntpSock = new QSocket( this );
- connect( ntpSock, SIGNAL( error(int) ),
- SLOT(slotCheckNtp(int)) );
+ connect( ntpSock, SIGNAL( error(int) ),SLOT(slotCheckNtp(int)) );
slotProbeNtpServer();
@@ -87,5 +87,5 @@ Ntp::Ntp( QWidget* parent, const char* name, WFlags fl )
connect ( ntpProcess, SIGNAL(processExited(OProcess*)),
this, SLOT(ntpFinished(OProcess*)));
- connect(runNtp, SIGNAL(clicked()), this, SLOT(slotRunNtp()));
+ connect(runNtp, SIGNAL(clicked()), this, SLOT(slotButtonRunNtp()));
connect(PushButtonPredict, SIGNAL(clicked()), this, SLOT(preditctTime()));
connect(PushButtonSetPredTime, SIGNAL(clicked()), this, SLOT(setPredictTime()));
@@ -97,11 +97,19 @@ Ntp::~Ntp()
{
delete ntpProcess;
- Config ntpSrvs("/etc/ntpservers",Config::File);
- ntpSrvs.setGroup("servers");
int srvCount = ComboNtpSrv->count();
- ntpSrvs.writeEntry("count", srvCount);
+ bool serversChanged = true;
+ QString edit = ComboNtpSrv->currentText();
for (int i = 0; i < srvCount; i++){
- ntpSrvs.setGroup(QString::number(i));
- ntpSrvs.writeEntry( "name", ComboNtpSrv->text(i) );
+ if ( edit == ComboNtpSrv->text(i)) serversChanged = false;
+ }
+ if (serversChanged){
+ Config ntpSrvs("/etc/ntpservers",Config::File);
+ ntpSrvs.setGroup("servers");
+ ntpSrvs.writeEntry("count", srvCount);
+ for (int i = 0; i < srvCount; i++){
+ qDebug("ntpSrvs[%i/%i]=%s",i,srvCount,ComboNtpSrv->text(i).latin1());
+ ntpSrvs.setGroup(QString::number(i));
+ ntpSrvs.writeEntry( "name", ComboNtpSrv->text(i) );
+ }
}
Config cfg("ntp",Config::User);
@@ -128,4 +136,17 @@ QString Ntp::getNtpServer()
}
+void Ntp::slotButtonRunNtp()
+{
+ _interactive = true;
+ slotRunNtp();
+}
+
+void Ntp::slotTimerRunNtp()
+{
+ _interactive = false;
+ slotRunNtp();
+}
+
+
void Ntp::slotRunNtp()
{
@@ -177,12 +198,9 @@ void Ntp::ntpFinished(OProcess *p)
if (p->exitStatus()!=0 || !p->normalExit())
{
- if ( isVisible() ) {
- QMessageBox::critical(this, tr("ntp error"),
- tr("Error while getting time form\n server")+
- getNtpServer()+"\n"+
- _ntpOutput );
- TabWidgetMain->showPage( tabManualSetTime );
+ if ( isVisible() && _interactive ){
+ QMessageBox::critical(this, tr("ntp error"),tr("Error while getting time form\n server")+getNtpServer()+"\n"+_ntpOutput );
+ TabWidgetMain->showPage( tabManualSetTime );
}
-
+
return;
}
@@ -304,12 +322,12 @@ void Ntp::slotCheckNtp(int i)
TextLabelMainPredTime->hide();
ButtonSetTime->setText( tr("Get time from network") );
- connect( ButtonSetTime, SIGNAL(clicked()), SLOT(slotRunNtp()) );
+ connect( ButtonSetTime, SIGNAL(clicked()), SLOT(slotButtonRunNtp()) );
if ( ntpDelayElapsed() )
{
slotRunNtp();
disconnect(ntpTimer, SIGNAL( timeout() ), this, SLOT(slotProbeNtpServer()) );
- connect(ntpTimer, SIGNAL( timeout() ), SLOT(slotRunNtp()) );
+ connect(ntpTimer, SIGNAL( timeout() ), SLOT(slotTimerRunNtp()) );
}else{
- disconnect(ntpTimer, SIGNAL( timeout() ), this, SLOT(slotRunNtp()) );
+ disconnect(ntpTimer, SIGNAL( timeout() ), this, SLOT(slotTimerRunNtp()) );
connect(ntpTimer, SIGNAL( timeout() ), SLOT(slotProbeNtpServer()) );
}
@@ -355,4 +373,5 @@ void Ntp::receive(const QCString &msg, const QByteArray &arg)
if ( msg == "ntpLookup(QString)" )
{
+ _interactive = false;
slotRunNtp();
}
diff --git a/noncore/settings/netsystemtime/ntp.h b/noncore/settings/netsystemtime/ntp.h
index f6694c9..15cddbd 100644
--- a/noncore/settings/netsystemtime/ntp.h
+++ b/noncore/settings/netsystemtime/ntp.h
@@ -33,5 +33,5 @@ private:
QSocket *ntpSock;
QCopChannel *channel;
-
+ bool _interactive;
float getTimeShift();
void readLookups();
@@ -40,4 +40,6 @@ private:
QString getNtpServer();
private slots:
+ void slotTimerRunNtp();
+ void slotButtonRunNtp();
void slotRunNtp();
void getNtpOutput(OProcess *proc, char *buffer, int buflen);