-rw-r--r-- | noncore/settings/netsystemtime/ntp.cpp | 36 |
1 files changed, 19 insertions, 17 deletions
diff --git a/noncore/settings/netsystemtime/ntp.cpp b/noncore/settings/netsystemtime/ntp.cpp index 06d944d..aecefc1 100644 --- a/noncore/settings/netsystemtime/ntp.cpp +++ b/noncore/settings/netsystemtime/ntp.cpp | |||
@@ -48,7 +48,7 @@ Ntp::Ntp( QWidget* parent, const char* name, WFlags fl ) | |||
48 | ComboNtpSrv->setCurrentItem( cfg.readNumEntry("ntpServer", 0) ); | 48 | ComboNtpSrv->setCurrentItem( cfg.readNumEntry("ntpServer", 0) ); |
49 | 49 | ||
50 | //make tab order | 50 | //make tab order |
51 | 51 | ||
52 | TabWidgetMain->removePage( tabMain ); | 52 | TabWidgetMain->removePage( tabMain ); |
53 | TabWidgetMain->removePage( tabManualSetTime ); | 53 | TabWidgetMain->removePage( tabManualSetTime ); |
54 | TabWidgetMain->removePage( TabSettings ); | 54 | TabWidgetMain->removePage( TabSettings ); |
@@ -61,7 +61,7 @@ Ntp::Ntp( QWidget* parent, const char* name, WFlags fl ) | |||
61 | TabWidgetMain->insertTab( tabNtp, tr( "NTP" ) ); | 61 | TabWidgetMain->insertTab( tabNtp, tr( "NTP" ) ); |
62 | NtpBaseLayout->addWidget( TabWidgetMain, 0, 0 ); | 62 | NtpBaseLayout->addWidget( TabWidgetMain, 0, 0 ); |
63 | 63 | ||
64 | 64 | ||
65 | 65 | ||
66 | bool advMode = cfg.readBoolEntry("advancedFeatures", false ); | 66 | bool advMode = cfg.readBoolEntry("advancedFeatures", false ); |
67 | showAdvancedFeatures(advMode); | 67 | showAdvancedFeatures(advMode); |
@@ -100,7 +100,7 @@ Ntp::~Ntp() | |||
100 | void Ntp::saveConfig(){ | 100 | void Ntp::saveConfig(){ |
101 | int srvCount = ComboNtpSrv->count(); | 101 | int srvCount = ComboNtpSrv->count(); |
102 | bool serversChanged = true; | 102 | bool serversChanged = true; |
103 | int curSrv = ComboNtpSrv->currentItem(); | 103 | int curSrv = ComboNtpSrv->currentItem(); |
104 | QString edit = ComboNtpSrv->currentText(); | 104 | QString edit = ComboNtpSrv->currentText(); |
105 | for (int i = 0; i < srvCount; i++){ | 105 | for (int i = 0; i < srvCount; i++){ |
106 | if ( edit == ComboNtpSrv->text(i)) serversChanged = false; | 106 | if ( edit == ComboNtpSrv->text(i)) serversChanged = false; |
@@ -109,7 +109,7 @@ void Ntp::saveConfig(){ | |||
109 | Config ntpSrvs(QPEApplication::qpeDir()+"etc/ntpservers",Config::File); | 109 | Config ntpSrvs(QPEApplication::qpeDir()+"etc/ntpservers",Config::File); |
110 | ntpSrvs.setGroup("servers"); | 110 | ntpSrvs.setGroup("servers"); |
111 | ntpSrvs.writeEntry("count", ++srvCount); | 111 | ntpSrvs.writeEntry("count", ++srvCount); |
112 | ntpSrvs.setGroup("0"); | 112 | ntpSrvs.setGroup("0"); |
113 | ntpSrvs.writeEntry( "name", edit ); | 113 | ntpSrvs.writeEntry( "name", edit ); |
114 | curSrv = 0; | 114 | curSrv = 0; |
115 | for (int i = 1; i < srvCount; i++){ | 115 | for (int i = 1; i < srvCount; i++){ |
@@ -131,7 +131,7 @@ bool Ntp::ntpDelayElapsed() | |||
131 | Config cfg("ntp",Config::User); | 131 | Config cfg("ntp",Config::User); |
132 | cfg.setGroup("lookups"); | 132 | cfg.setGroup("lookups"); |
133 | _lookupDiff = TimeConversion::toUTC(QDateTime::currentDateTime()) - cfg.readNumEntry("time",0); | 133 | _lookupDiff = TimeConversion::toUTC(QDateTime::currentDateTime()) - cfg.readNumEntry("time",0); |
134 | if (_lookupDiff < 0) return true; | 134 | if (_lookupDiff < 0) return true; |
135 | int i =_lookupDiff - (SpinBoxNtpDelay->value()*60); | 135 | int i =_lookupDiff - (SpinBoxNtpDelay->value()*60); |
136 | return i > -60; | 136 | return i > -60; |
137 | } | 137 | } |
@@ -172,7 +172,7 @@ void Ntp::slotRunNtp() | |||
172 | } | 172 | } |
173 | TextLabelStartTime->setText(QDateTime::currentDateTime().toString()); | 173 | TextLabelStartTime->setText(QDateTime::currentDateTime().toString()); |
174 | ntpOutPut( tr("Running:")+"\nntpdate "+getNtpServer() ); | 174 | ntpOutPut( tr("Running:")+"\nntpdate "+getNtpServer() ); |
175 | 175 | ||
176 | ntpProcess->clearArguments(); | 176 | ntpProcess->clearArguments(); |
177 | *ntpProcess << "ntpdate" << getNtpServer(); | 177 | *ntpProcess << "ntpdate" << getNtpServer(); |
178 | bool ret = ntpProcess->start(OProcess::NotifyOnExit,OProcess::AllOutput); | 178 | bool ret = ntpProcess->start(OProcess::NotifyOnExit,OProcess::AllOutput); |
@@ -202,14 +202,14 @@ void Ntp::ntpFinished(OProcess *p) | |||
202 | { | 202 | { |
203 | qDebug("p->exitStatus() %i",p->exitStatus()); | 203 | qDebug("p->exitStatus() %i",p->exitStatus()); |
204 | if (p->exitStatus()!=0 || !p->normalExit()) | 204 | if (p->exitStatus()!=0 || !p->normalExit()) |
205 | { | 205 | { |
206 | if ( isVisible() && _interactive ){ | 206 | if ( isVisible() && _interactive ){ |
207 | QMessageBox::critical(this, tr("ntp error"),tr("Error while getting time form\n server")+getNtpServer()+"\n"+_ntpOutput ); | 207 | QMessageBox::critical(this, tr("ntp error"),tr("Error while getting time form\n server")+getNtpServer()+"\n"+_ntpOutput ); |
208 | } | 208 | } |
209 | // slotCheckNtp(-1); | 209 | // slotCheckNtp(-1); |
210 | return; | 210 | return; |
211 | } | 211 | } |
212 | 212 | ||
213 | Config cfg("ntp",Config::User); | 213 | Config cfg("ntp",Config::User); |
214 | cfg.setGroup("lookups"); | 214 | cfg.setGroup("lookups"); |
215 | int lastLookup = cfg.readNumEntry("time",0); | 215 | int lastLookup = cfg.readNumEntry("time",0); |
@@ -217,7 +217,7 @@ void Ntp::ntpFinished(OProcess *p) | |||
217 | bool lastNtp = cfg.readBoolEntry("lastNtp",false); | 217 | bool lastNtp = cfg.readBoolEntry("lastNtp",false); |
218 | int time = TimeConversion::toUTC( QDateTime::currentDateTime() ); | 218 | int time = TimeConversion::toUTC( QDateTime::currentDateTime() ); |
219 | cfg.writeEntry("time", time); | 219 | cfg.writeEntry("time", time); |
220 | 220 | ||
221 | float timeShift = getTimeShift(); | 221 | float timeShift = getTimeShift(); |
222 | if (timeShift == 0.0) return; | 222 | if (timeShift == 0.0) return; |
223 | int secsSinceLast = time - lastLookup; | 223 | int secsSinceLast = time - lastLookup; |
@@ -329,7 +329,7 @@ void Ntp::slotCheckNtp(int i) | |||
329 | disconnect(ntpTimer, SIGNAL( timeout() ), this, SLOT(slotTimerRunNtp()) ); | 329 | disconnect(ntpTimer, SIGNAL( timeout() ), this, SLOT(slotTimerRunNtp()) ); |
330 | connect(ntpTimer, SIGNAL( timeout() ), SLOT(slotProbeNtpServer()) ); | 330 | connect(ntpTimer, SIGNAL( timeout() ), SLOT(slotProbeNtpServer()) ); |
331 | } | 331 | } |
332 | }else{ | 332 | }else{ |
333 | preditctTime(); | 333 | preditctTime(); |
334 | ButtonSetTime->setText( tr("Set predicted time: ")+predictedTime.toString() ); | 334 | ButtonSetTime->setText( tr("Set predicted time: ")+predictedTime.toString() ); |
335 | if (i>0)ntpOutPut(tr("Could not connect to server ")+getNtpServer()); | 335 | if (i>0)ntpOutPut(tr("Could not connect to server ")+getNtpServer()); |
@@ -350,14 +350,14 @@ void Ntp::slotNtpDelayChanged(int delay) | |||
350 | 350 | ||
351 | void Ntp::ntpOutPut(QString out) | 351 | void Ntp::ntpOutPut(QString out) |
352 | { | 352 | { |
353 | 353 | ||
354 | MultiLineEditntpOutPut->append(out); | 354 | MultiLineEditntpOutPut->append(out); |
355 | MultiLineEditntpOutPut->setCursorPosition(MultiLineEditntpOutPut->numLines() + 1,0,FALSE); | 355 | MultiLineEditntpOutPut->setCursorPosition(MultiLineEditntpOutPut->numLines() + 1,0,FALSE); |
356 | } | 356 | } |
357 | 357 | ||
358 | 358 | ||
359 | void Ntp::makeChannel() | 359 | void Ntp::makeChannel() |
360 | { | 360 | { |
361 | channel = new QCopChannel( "QPE/Application/netsystemtime", this ); | 361 | channel = new QCopChannel( "QPE/Application/netsystemtime", this ); |
362 | connect( channel, SIGNAL(received(const QCString&, const QByteArray&)), | 362 | connect( channel, SIGNAL(received(const QCString&, const QByteArray&)), |
363 | this, SLOT(receive(const QCString&, const QByteArray&)) ); | 363 | this, SLOT(receive(const QCString&, const QByteArray&)) ); |
@@ -389,9 +389,11 @@ void Ntp::setDocument(const QString &fileName) | |||
389 | void Ntp::showAdvancedFeatures(bool advMode) | 389 | void Ntp::showAdvancedFeatures(bool advMode) |
390 | { | 390 | { |
391 | if (advMode) { | 391 | if (advMode) { |
392 | 392 | ||
393 | TabWidgetMain->addTab( tabPredict, tr( "Predict" ) ); | 393 | if ( tabNtp->isVisible() ) { |
394 | TabWidgetMain->addTab( tabNtp, tr( "NTP" ) ); | 394 | TabWidgetMain->addTab( tabPredict, tr( "Predict" ) ); |
395 | TabWidgetMain->addTab( tabNtp, tr( "NTP" ) ); | ||
396 | } | ||
395 | TextLabel1_2_2->show(); | 397 | TextLabel1_2_2->show(); |
396 | TextLabel2_3->show(); | 398 | TextLabel2_3->show(); |
397 | TextLabel3_3_2->show(); | 399 | TextLabel3_3_2->show(); |
@@ -422,10 +424,10 @@ void Ntp::accept( ){ | |||
422 | qDebug("saving"); | 424 | qDebug("saving"); |
423 | //SetTimeDate | 425 | //SetTimeDate |
424 | commitTime(); | 426 | commitTime(); |
425 | writeSettings(); | 427 | writeSettings(); |
426 | updateSystem(); | 428 | updateSystem(); |
427 | // Ntp | 429 | // Ntp |
428 | saveConfig(); | 430 | saveConfig(); |
429 | qApp->quit(); | 431 | qApp->quit(); |
430 | } | 432 | } |
431 | 433 | ||