summaryrefslogtreecommitdiff
path: root/noncore/settings/netsystemtime/ntp.cpp
Unidiff
Diffstat (limited to 'noncore/settings/netsystemtime/ntp.cpp') (more/less context) (show whitespace changes)
-rw-r--r--noncore/settings/netsystemtime/ntp.cpp36
1 files changed, 32 insertions, 4 deletions
diff --git a/noncore/settings/netsystemtime/ntp.cpp b/noncore/settings/netsystemtime/ntp.cpp
index 40805a0..111f7d4 100644
--- a/noncore/settings/netsystemtime/ntp.cpp
+++ b/noncore/settings/netsystemtime/ntp.cpp
@@ -43,12 +43,29 @@ Ntp::Ntp( QWidget* parent, const char* name, WFlags fl )
43 Config cfg("ntp",Config::User); 43 Config cfg("ntp",Config::User);
44 cfg.setGroup("settings"); 44 cfg.setGroup("settings");
45 SpinBoxMinLookupDelay->setValue( cfg.readNumEntry("minLookupDiff",720) ); 45 SpinBoxMinLookupDelay->setValue( cfg.readNumEntry("minLookupDiff",720) );
46 SpinBoxNtpDelay->setValue( cfg.readNumEntry("ntpRefreshFreq",1440) ); 46 SpinBoxNtpDelay->setValue( cfg.readNumEntry("ntpRefreshFreq",1440) );
47 ComboNtpSrv->setCurrentItem( cfg.readNumEntry("ntpServer", 0) ); 47 ComboNtpSrv->setCurrentItem( cfg.readNumEntry("ntpServer", 0) );
48 48
49 //make tab order
50
51 TabWidgetMain->removePage( tabMain );
52 TabWidgetMain->removePage( tabManualSetTime );
53 TabWidgetMain->removePage( TabSettings );
54 TabWidgetMain->removePage( tabPredict );
55 TabWidgetMain->removePage( tabNtp );
56
57 TabWidgetMain->insertTab( tabMain, tr( "Main" ) );
58 TabWidgetMain->insertTab( tabManualSetTime, tr( "Manual" ) );
59 TabWidgetMain->insertTab( TabSettings, tr( "Settings" ) );
60 TabWidgetMain->insertTab( tabPredict, tr( "Predict" ) );
61 TabWidgetMain->insertTab( tabNtp, tr( "NTP" ) );
62 NtpBaseLayout->addWidget( TabWidgetMain, 0, 0 );
63
64
65
49 bool advMode = cfg.readBoolEntry("advancedFeatures", false ); 66 bool advMode = cfg.readBoolEntry("advancedFeatures", false );
50 showAdvancedFeatures(advMode); 67 showAdvancedFeatures(advMode);
51 CheckBoxAdvSettings->setChecked( advMode ); 68 CheckBoxAdvSettings->setChecked( advMode );
52 connect( CheckBoxAdvSettings, SIGNAL( toggled( bool ) ), 69 connect( CheckBoxAdvSettings, SIGNAL( toggled( bool ) ),
53 SLOT( showAdvancedFeatures( bool ) ) ); 70 SLOT( showAdvancedFeatures( bool ) ) );
54 71
@@ -109,13 +126,13 @@ QString Ntp::getNtpServer()
109{ 126{
110 return ComboNtpSrv->currentText(); 127 return ComboNtpSrv->currentText();
111} 128}
112 129
113void Ntp::slotRunNtp() 130void Ntp::slotRunNtp()
114{ 131{
115 if ( !ntpDelayElapsed() ) 132 if ( !ntpDelayElapsed() && CheckBoxAdvSettings->isChecked() )
116 { 133 {
117 switch ( 134 switch (
118 QMessageBox::warning(this, tr("Run NTP?"), 135 QMessageBox::warning(this, tr("Run NTP?"),
119 tr("You asked for a delay of ")+SpinBoxNtpDelay->text()+tr(" minutes, but only ")+ 136 tr("You asked for a delay of ")+SpinBoxNtpDelay->text()+tr(" minutes, but only ")+
120 QString::number(_lookupDiff/60)+tr(" minutes elapsed since last lookup.")+ 137 QString::number(_lookupDiff/60)+tr(" minutes elapsed since last lookup.")+
121 "<br>"+tr("Rerun NTP?"), 138 "<br>"+tr("Rerun NTP?"),
@@ -130,19 +147,22 @@ void Ntp::slotRunNtp()
130 ntpOutPut( tr("Running:")+"\nntpdate "+getNtpServer() ); 147 ntpOutPut( tr("Running:")+"\nntpdate "+getNtpServer() );
131 148
132 ntpProcess->clearArguments(); 149 ntpProcess->clearArguments();
133 *ntpProcess << "ntpdate" << getNtpServer(); 150 *ntpProcess << "ntpdate" << getNtpServer();
134 bool ret = ntpProcess->start(OProcess::NotifyOnExit,OProcess::AllOutput); 151 bool ret = ntpProcess->start(OProcess::NotifyOnExit,OProcess::AllOutput);
135 if ( !ret ) { 152 if ( !ret ) {
153 QMessageBox::critical(this, tr("ntp error"),
154 tr("Error while getting time form network!"));
136 qDebug("Error while executing ntpdate"); 155 qDebug("Error while executing ntpdate");
137 ntpOutPut( tr("Error while executing ntpdate")); 156 ntpOutPut( tr("Error while executing ntpdate"));
138 } 157 }
139} 158}
140 159
141void Ntp::getNtpOutput(OProcess *proc, char *buffer, int buflen) 160void Ntp::getNtpOutput(OProcess *proc, char *buffer, int buflen)
142{ 161{
162 if (! proc ) qDebug("Ntp::getNtpOutput OProcess is null");
143 QString lineStr, lineStrOld; 163 QString lineStr, lineStrOld;
144 lineStr = buffer; 164 lineStr = buffer;
145 lineStr=lineStr.left(buflen); 165 lineStr=lineStr.left(buflen);
146 if (lineStr!=lineStrOld) 166 if (lineStr!=lineStrOld)
147 { 167 {
148 ntpOutPut(lineStr); 168 ntpOutPut(lineStr);
@@ -150,16 +170,22 @@ void Ntp::getNtpOutput(OProcess *proc, char *buffer, int buflen)
150 } 170 }
151 lineStrOld = lineStr; 171 lineStrOld = lineStr;
152} 172}
153 173
154void Ntp::ntpFinished(OProcess *p) 174void Ntp::ntpFinished(OProcess *p)
155{ 175{
156 //qDebug("p->exitStatus() %i",p->exitStatus()); 176 qDebug("p->exitStatus() %i",p->exitStatus());
157 if (p->exitStatus()!=0 || !p->normalExit()) 177 if (p->exitStatus()!=0 || !p->normalExit())
158 { 178 {
159 slotProbeNtpServer(); 179 QMessageBox::critical(this, tr("ntp error"),
180 tr("Error while getting time form\n server")+
181 getNtpServer()+"\n"+
182 _ntpOutput );
183 // TabWidgetMain->setCurrentPage( 1 );
184 TabWidgetMain->showPage( tabManualSetTime );
185
160 return; 186 return;
161 } 187 }
162 188
163 Global::writeHWClock(); 189 Global::writeHWClock();
164 // since time has changed quickly load in the datebookdb 190 // since time has changed quickly load in the datebookdb
165 // to allow the alarm server to get a better grip on itself 191 // to allow the alarm server to get a better grip on itself
@@ -304,12 +330,13 @@ void Ntp::slotNtpDelayChanged(int delay)
304{ 330{
305 ntpTimer->changeInterval( delay*1000*60 ); 331 ntpTimer->changeInterval( delay*1000*60 );
306} 332}
307 333
308void Ntp::ntpOutPut(QString out) 334void Ntp::ntpOutPut(QString out)
309{ 335{
336
310 MultiLineEditntpOutPut->append(out); 337 MultiLineEditntpOutPut->append(out);
311 MultiLineEditntpOutPut->setCursorPosition(MultiLineEditntpOutPut->numLines() + 1,0,FALSE); 338 MultiLineEditntpOutPut->setCursorPosition(MultiLineEditntpOutPut->numLines() + 1,0,FALSE);
312} 339}
313 340
314 341
315void Ntp::makeChannel() 342void Ntp::makeChannel()
@@ -335,18 +362,19 @@ void Ntp::receive(const QCString &msg, const QByteArray &arg)
335 qDebug("Ntp::receive: Huh what do ya want"); 362 qDebug("Ntp::receive: Huh what do ya want");
336 } 363 }
337} 364}
338 365
339void Ntp::setDocument(const QString &fileName) 366void Ntp::setDocument(const QString &fileName)
340{ 367{
341 368 qDebug("Ntp::setDocument( %s )",fileName.latin1());
342} 369}
343 370
344void Ntp::showAdvancedFeatures(bool advMode) 371void Ntp::showAdvancedFeatures(bool advMode)
345{ 372{
346 if (advMode) { 373 if (advMode) {
374
347 TabWidgetMain->addTab( tabPredict, tr( "Predict" ) ); 375 TabWidgetMain->addTab( tabPredict, tr( "Predict" ) );
348 TabWidgetMain->addTab( tabNtp, tr( "NTP" ) ); 376 TabWidgetMain->addTab( tabNtp, tr( "NTP" ) );
349 TextLabel1_2_2->show(); 377 TextLabel1_2_2->show();
350 TextLabel2_3->show(); 378 TextLabel2_3->show();
351 TextLabel3_3_2->show(); 379 TextLabel3_3_2->show();
352 TextLabel1_2->show(); 380 TextLabel1_2->show();