-rw-r--r-- | noncore/settings/netsystemtime/ntp.cpp | 43 | ||||
-rw-r--r-- | noncore/settings/netsystemtime/ntp.h | 4 |
2 files changed, 34 insertions, 13 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 | |||
@@ -32,2 +32,3 @@ Ntp::Ntp( QWidget* parent, const char* name, WFlags fl ) | |||
32 | { | 32 | { |
33 | _interactive = false; | ||
33 | Config ntpSrvs(QPEApplication::qpeDir()+"etc/ntpservers",Config::File); | 34 | Config ntpSrvs(QPEApplication::qpeDir()+"etc/ntpservers",Config::File); |
@@ -80,4 +81,3 @@ Ntp::Ntp( QWidget* parent, const char* name, WFlags fl ) | |||
80 | ntpSock = new QSocket( this ); | 81 | ntpSock = new QSocket( this ); |
81 | connect( ntpSock, SIGNAL( error(int) ), | 82 | connect( ntpSock, SIGNAL( error(int) ),SLOT(slotCheckNtp(int)) ); |
82 | SLOT(slotCheckNtp(int)) ); | ||
83 | slotProbeNtpServer(); | 83 | slotProbeNtpServer(); |
@@ -88,3 +88,3 @@ Ntp::Ntp( QWidget* parent, const char* name, WFlags fl ) | |||
88 | this, SLOT(ntpFinished(OProcess*))); | 88 | this, SLOT(ntpFinished(OProcess*))); |
89 | connect(runNtp, SIGNAL(clicked()), this, SLOT(slotRunNtp())); | 89 | connect(runNtp, SIGNAL(clicked()), this, SLOT(slotButtonRunNtp())); |
90 | connect(PushButtonPredict, SIGNAL(clicked()), this, SLOT(preditctTime())); | 90 | connect(PushButtonPredict, SIGNAL(clicked()), this, SLOT(preditctTime())); |
@@ -98,7 +98,14 @@ Ntp::~Ntp() | |||
98 | delete ntpProcess; | 98 | delete ntpProcess; |
99 | int srvCount = ComboNtpSrv->count(); | ||
100 | bool serversChanged = true; | ||
101 | QString edit = ComboNtpSrv->currentText(); | ||
102 | for (int i = 0; i < srvCount; i++){ | ||
103 | if ( edit == ComboNtpSrv->text(i)) serversChanged = false; | ||
104 | } | ||
105 | if (serversChanged){ | ||
99 | Config ntpSrvs("/etc/ntpservers",Config::File); | 106 | Config ntpSrvs("/etc/ntpservers",Config::File); |
100 | ntpSrvs.setGroup("servers"); | 107 | ntpSrvs.setGroup("servers"); |
101 | int srvCount = ComboNtpSrv->count(); | ||
102 | ntpSrvs.writeEntry("count", srvCount); | 108 | ntpSrvs.writeEntry("count", srvCount); |
103 | for (int i = 0; i < srvCount; i++){ | 109 | for (int i = 0; i < srvCount; i++){ |
110 | qDebug("ntpSrvs[%i/%i]=%s",i,srvCount,ComboNtpSrv->text(i).latin1()); | ||
104 | ntpSrvs.setGroup(QString::number(i)); | 111 | ntpSrvs.setGroup(QString::number(i)); |
@@ -106,2 +113,3 @@ Ntp::~Ntp() | |||
106 | } | 113 | } |
114 | } | ||
107 | Config cfg("ntp",Config::User); | 115 | Config cfg("ntp",Config::User); |
@@ -129,2 +137,15 @@ QString Ntp::getNtpServer() | |||
129 | 137 | ||
138 | void Ntp::slotButtonRunNtp() | ||
139 | { | ||
140 | _interactive = true; | ||
141 | slotRunNtp(); | ||
142 | } | ||
143 | |||
144 | void Ntp::slotTimerRunNtp() | ||
145 | { | ||
146 | _interactive = false; | ||
147 | slotRunNtp(); | ||
148 | } | ||
149 | |||
150 | |||
130 | void Ntp::slotRunNtp() | 151 | void Ntp::slotRunNtp() |
@@ -178,7 +199,4 @@ void Ntp::ntpFinished(OProcess *p) | |||
178 | { | 199 | { |
179 | if ( isVisible() ) { | 200 | if ( isVisible() && _interactive ){ |
180 | QMessageBox::critical(this, tr("ntp error"), | 201 | QMessageBox::critical(this, tr("ntp error"),tr("Error while getting time form\n server")+getNtpServer()+"\n"+_ntpOutput ); |
181 | tr("Error while getting time form\n server")+ | ||
182 | getNtpServer()+"\n"+ | ||
183 | _ntpOutput ); | ||
184 | TabWidgetMain->showPage( tabManualSetTime ); | 202 | TabWidgetMain->showPage( tabManualSetTime ); |
@@ -305,3 +323,3 @@ void Ntp::slotCheckNtp(int i) | |||
305 | ButtonSetTime->setText( tr("Get time from network") ); | 323 | ButtonSetTime->setText( tr("Get time from network") ); |
306 | connect( ButtonSetTime, SIGNAL(clicked()), SLOT(slotRunNtp()) ); | 324 | connect( ButtonSetTime, SIGNAL(clicked()), SLOT(slotButtonRunNtp()) ); |
307 | if ( ntpDelayElapsed() ) | 325 | if ( ntpDelayElapsed() ) |
@@ -310,5 +328,5 @@ void Ntp::slotCheckNtp(int i) | |||
310 | disconnect(ntpTimer, SIGNAL( timeout() ), this, SLOT(slotProbeNtpServer()) ); | 328 | disconnect(ntpTimer, SIGNAL( timeout() ), this, SLOT(slotProbeNtpServer()) ); |
311 | connect(ntpTimer, SIGNAL( timeout() ), SLOT(slotRunNtp()) ); | 329 | connect(ntpTimer, SIGNAL( timeout() ), SLOT(slotTimerRunNtp()) ); |
312 | }else{ | 330 | }else{ |
313 | disconnect(ntpTimer, SIGNAL( timeout() ), this, SLOT(slotRunNtp()) ); | 331 | disconnect(ntpTimer, SIGNAL( timeout() ), this, SLOT(slotTimerRunNtp()) ); |
314 | connect(ntpTimer, SIGNAL( timeout() ), SLOT(slotProbeNtpServer()) ); | 332 | connect(ntpTimer, SIGNAL( timeout() ), SLOT(slotProbeNtpServer()) ); |
@@ -356,2 +374,3 @@ void Ntp::receive(const QCString &msg, const QByteArray &arg) | |||
356 | { | 374 | { |
375 | _interactive = false; | ||
357 | slotRunNtp(); | 376 | 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 | |||
@@ -34,3 +34,3 @@ private: | |||
34 | QCopChannel *channel; | 34 | QCopChannel *channel; |
35 | 35 | bool _interactive; | |
36 | float getTimeShift(); | 36 | float getTimeShift(); |
@@ -41,2 +41,4 @@ private: | |||
41 | private slots: | 41 | private slots: |
42 | void slotTimerRunNtp(); | ||
43 | void slotButtonRunNtp(); | ||
42 | void slotRunNtp(); | 44 | void slotRunNtp(); |