summaryrefslogtreecommitdiff
authortille <tille>2002-07-01 17:12:30 (UTC)
committer tille <tille>2002-07-01 17:12:30 (UTC)
commitfcdf02d10c738c95748f082eaf40cb47db6d2975 (patch) (unidiff)
tree96281f0d0b2a969815a3e67418c61783f9d134b1
parentdbdd9ea2e38fbe280fc4d648fbd3709e101d7eed (diff)
downloadopie-fcdf02d10c738c95748f082eaf40cb47db6d2975.zip
opie-fcdf02d10c738c95748f082eaf40cb47db6d2975.tar.gz
opie-fcdf02d10c738c95748f082eaf40cb47db6d2975.tar.bz2
s
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/settings/netsystemtime/ntp.cpp3
1 files changed, 2 insertions, 1 deletions
diff --git a/noncore/settings/netsystemtime/ntp.cpp b/noncore/settings/netsystemtime/ntp.cpp
index 7971f9a..40b5531 100644
--- a/noncore/settings/netsystemtime/ntp.cpp
+++ b/noncore/settings/netsystemtime/ntp.cpp
@@ -1,288 +1,289 @@
1#include "ntp.h" 1#include "ntp.h"
2#include <qpushbutton.h> 2#include <qpushbutton.h>
3#include <qregexp.h> 3#include <qregexp.h>
4#include <qtimer.h> 4#include <qtimer.h>
5#include <qtable.h> 5#include <qtable.h>
6#include <qlabel.h> 6#include <qlabel.h>
7#include <qsocket.h> 7#include <qsocket.h>
8#include <qlineedit.h> 8#include <qlineedit.h>
9#include <qspinbox.h> 9#include <qspinbox.h>
10#include <qmessagebox.h> 10#include <qmessagebox.h>
11#include <qmultilineedit.h> 11#include <qmultilineedit.h>
12#include <opie/oprocess.h> 12#include <opie/oprocess.h>
13#include <qpe/qpeapplication.h> 13#include <qpe/qpeapplication.h>
14#include <qpe/config.h> 14#include <qpe/config.h>
15#include <qpe/global.h> 15#include <qpe/global.h>
16#include <qpe/timeconversion.h> 16#include <qpe/timeconversion.h>
17#include <qpe/tzselect.h> 17#include <qpe/tzselect.h>
18#include <qpe/timestring.h> 18#include <qpe/timestring.h>
19#include <qpe/qpedialog.h> 19#include <qpe/qpedialog.h>
20#include <sys/time.h> 20#include <sys/time.h>
21#include <time.h> 21#include <time.h>
22#include <stdlib.h> 22#include <stdlib.h>
23 23
24 24
25Ntp::Ntp( QWidget* parent, const char* name, WFlags fl ) 25Ntp::Ntp( QWidget* parent, const char* name, WFlags fl )
26 : SetDateTime( parent, name, fl ) 26 : SetDateTime( parent, name, fl )
27{ 27{
28 Config ntpSrvs(QPEApplication::qpeDir()+"etc/ntpservers",Config::File); 28 Config ntpSrvs(QPEApplication::qpeDir()+"etc/ntpservers",Config::File);
29 ntpSrvs.setGroup("servers"); 29 ntpSrvs.setGroup("servers");
30 int srvCount = ntpSrvs.readNumEntry("count", 0 ); 30 int srvCount = ntpSrvs.readNumEntry("count", 0 );
31 for (int i = 0; i < srvCount; i++) 31 for (int i = 0; i < srvCount; i++)
32 { 32 {
33 ntpSrvs.setGroup(QString::number(i)); 33 ntpSrvs.setGroup(QString::number(i));
34 ComboNtpSrv->insertItem( ntpSrvs.readEntry("name") ); 34 ComboNtpSrv->insertItem( ntpSrvs.readEntry("name") );
35 } 35 }
36 if ( srvCount==0 ) ComboNtpSrv->insertItem(tr("time.fu-berlin.de")); 36 if ( srvCount==0 ) ComboNtpSrv->insertItem(tr("time.fu-berlin.de"));
37 37
38 Config cfg("ntp",Config::User); 38 Config cfg("ntp",Config::User);
39 cfg.setGroup("settings"); 39 cfg.setGroup("settings");
40 SpinBoxMinLookupDelay->setValue( cfg.readNumEntry("minLookupDiff",41) ); 40 SpinBoxMinLookupDelay->setValue( cfg.readNumEntry("minLookupDiff",41) );
41 SpinBoxNtpDelay->setValue( cfg.readNumEntry("ntpRefreshFreq",42) ); 41 SpinBoxNtpDelay->setValue( cfg.readNumEntry("ntpRefreshFreq",42) );
42 ComboNtpSrv->setCurrentItem( cfg.readNumEntry("ntpServer", 0) ); 42 ComboNtpSrv->setCurrentItem( cfg.readNumEntry("ntpServer", 0) );
43 43
44 ntpTimer = new QTimer(this); 44 ntpTimer = new QTimer(this);
45 45
46 ntpProcess = new OProcess( ); 46 ntpProcess = new OProcess( );
47 connect( SpinBoxNtpDelay, SIGNAL( valueChanged(int) ), 47 connect( SpinBoxNtpDelay, SIGNAL( valueChanged(int) ),
48 SLOT(slotNtpDelayChanged(int)) ); 48 SLOT(slotNtpDelayChanged(int)) );
49 49
50 ntpSock = new QSocket( this ); 50 ntpSock = new QSocket( this );
51 connect( ntpSock, SIGNAL( error(int) ), 51 connect( ntpSock, SIGNAL( error(int) ),
52 SLOT(slotCheckNtp(int)) ); 52 SLOT(slotCheckNtp(int)) );
53 slotProbeNtpServer(); 53 slotProbeNtpServer();
54 54
55 connect ( ntpProcess, SIGNAL(receivedStdout(OProcess*,char*,int)), 55 connect ( ntpProcess, SIGNAL(receivedStdout(OProcess*,char*,int)),
56 this, SLOT(getNtpOutput(OProcess*,char*,int))); 56 this, SLOT(getNtpOutput(OProcess*,char*,int)));
57 connect ( ntpProcess, SIGNAL(processExited(OProcess*)), 57 connect ( ntpProcess, SIGNAL(processExited(OProcess*)),
58 this, SLOT(ntpFinished(OProcess*))); 58 this, SLOT(ntpFinished(OProcess*)));
59 connect(runNtp, SIGNAL(clicked()), this, SLOT(slotRunNtp())); 59 connect(runNtp, SIGNAL(clicked()), this, SLOT(slotRunNtp()));
60 connect(PushButtonPredict, SIGNAL(clicked()), this, SLOT(preditctTime())); 60 connect(PushButtonPredict, SIGNAL(clicked()), this, SLOT(preditctTime()));
61 connect(PushButtonSetPredTime, SIGNAL(clicked()), this, SLOT(setPredictTime())); 61 connect(PushButtonSetPredTime, SIGNAL(clicked()), this, SLOT(setPredictTime()));
62 slotCheckNtp(-1); 62 slotCheckNtp(-1);
63 readLookups(); 63 readLookups();
64} 64}
65 65
66Ntp::~Ntp() 66Ntp::~Ntp()
67{ 67{
68 delete ntpProcess; 68 delete ntpProcess;
69 Config ntpSrvs("/etc/ntpservers",Config::File); 69 Config ntpSrvs("/etc/ntpservers",Config::File);
70 ntpSrvs.setGroup("servers"); 70 ntpSrvs.setGroup("servers");
71 int srvCount = ComboNtpSrv->count(); 71 int srvCount = ComboNtpSrv->count();
72 ntpSrvs.writeEntry("count", srvCount); 72 ntpSrvs.writeEntry("count", srvCount);
73 for (int i = 0; i < srvCount; i++) 73 for (int i = 0; i < srvCount; i++)
74 { 74 {
75 ntpSrvs.setGroup(QString::number(i)); 75 ntpSrvs.setGroup(QString::number(i));
76 ntpSrvs.writeEntry( "name", ComboNtpSrv->text(i) ); 76 ntpSrvs.writeEntry( "name", ComboNtpSrv->text(i) );
77 } 77 }
78 Config cfg("ntp",Config::User); 78 Config cfg("ntp",Config::User);
79 cfg.setGroup("settings"); 79 cfg.setGroup("settings");
80 cfg.writeEntry("ntpServer", ComboNtpSrv->currentItem()); 80 cfg.writeEntry("ntpServer", ComboNtpSrv->currentItem());
81 cfg.writeEntry( "minLookupDiff", SpinBoxMinLookupDelay->value() ); 81 cfg.writeEntry( "minLookupDiff", SpinBoxMinLookupDelay->value() );
82 cfg.writeEntry( "ntpRefreshFreq", SpinBoxNtpDelay->value() ); 82 cfg.writeEntry( "ntpRefreshFreq", SpinBoxNtpDelay->value() );
83} 83}
84 84
85bool Ntp::ntpDelayElapsed() 85bool Ntp::ntpDelayElapsed()
86{ 86{
87 Config cfg("ntp",Config::User); 87 Config cfg("ntp",Config::User);
88 cfg.setGroup("lookups"); 88 cfg.setGroup("lookups");
89 _lookupDiff = TimeConversion::toUTC(QDateTime::currentDateTime()) - cfg.readNumEntry("time",0); 89 _lookupDiff = TimeConversion::toUTC(QDateTime::currentDateTime()) - cfg.readNumEntry("time",0);
90 return (_lookupDiff - (SpinBoxNtpDelay->value()*60)) > -60; 90 return (_lookupDiff - (SpinBoxNtpDelay->value()*60)) > -60;
91} 91}
92 92
93QString Ntp::getNtpServer() 93QString Ntp::getNtpServer()
94{ 94{
95 return ComboNtpSrv->currentText(); 95 return ComboNtpSrv->currentText();
96} 96}
97 97
98void Ntp::slotRunNtp() 98void Ntp::slotRunNtp()
99{ 99{
100 if ( !ntpDelayElapsed() ) 100 if ( !ntpDelayElapsed() )
101 { 101 {
102 switch ( 102 switch (
103 QMessageBox::warning(this, tr("Run NTP?"), 103 QMessageBox::warning(this, tr("Run NTP?"),
104 tr("You asked for a delay of ")+SpinBoxNtpDelay->text()+tr(" minutes, but only ")+ 104 tr("You asked for a delay of ")+SpinBoxNtpDelay->text()+tr(" minutes, but only ")+
105 QString::number(_lookupDiff/60)+tr(" minutes elapsed since last loopup.")+ 105 QString::number(_lookupDiff/60)+tr(" minutes elapsed since last loopup.")+
106 "<br>"+tr("Rerun NTP?"), 106 "<br>"+tr("Rerun NTP?"),
107 QMessageBox::Ok,QMessageBox::Cancel) 107 QMessageBox::Ok,QMessageBox::Cancel)
108 ) { 108 ) {
109 case QMessageBox::Ok: break; 109 case QMessageBox::Ok: break;
110 case QMessageBox::Cancel: return; 110 case QMessageBox::Cancel: return;
111 default: return; 111 default: return;
112 } 112 }
113 } 113 }
114 TextLabelStartTime->setText(QDateTime::currentDateTime().toString()); 114 TextLabelStartTime->setText(QDateTime::currentDateTime().toString());
115 ntpOutPut( tr("Running:")+"\nntpdate "+getNtpServer() ); 115 ntpOutPut( tr("Running:")+"\nntpdate "+getNtpServer() );
116 116
117 ntpProcess->clearArguments(); 117 ntpProcess->clearArguments();
118 *ntpProcess << "ntpdate" << getNtpServer(); 118 *ntpProcess << "ntpdate" << getNtpServer();
119 bool ret = ntpProcess->start(OProcess::NotifyOnExit,OProcess::AllOutput); 119 bool ret = ntpProcess->start(OProcess::NotifyOnExit,OProcess::AllOutput);
120 if ( !ret ) { 120 if ( !ret ) {
121 qDebug("Error while executing ntpdate"); 121 qDebug("Error while executing ntpdate");
122 ntpOutPut( tr("Error while executing ntpdate")); 122 ntpOutPut( tr("Error while executing ntpdate"));
123 } 123 }
124} 124}
125 125
126void Ntp::getNtpOutput(OProcess *proc, char *buffer, int buflen) 126void Ntp::getNtpOutput(OProcess *proc, char *buffer, int buflen)
127{ 127{
128 QString lineStr, lineStrOld; 128 QString lineStr, lineStrOld;
129 lineStr = buffer; 129 lineStr = buffer;
130 lineStr=lineStr.left(buflen); 130 lineStr=lineStr.left(buflen);
131 if (lineStr!=lineStrOld) 131 if (lineStr!=lineStrOld)
132 { 132 {
133 ntpOutPut(lineStr); 133 ntpOutPut(lineStr);
134 _ntpOutput += lineStr; 134 _ntpOutput += lineStr;
135 } 135 }
136 lineStrOld = lineStr; 136 lineStrOld = lineStr;
137} 137}
138 138
139void Ntp::ntpFinished(OProcess *p) 139void Ntp::ntpFinished(OProcess *p)
140{ 140{
141 qDebug("p->exitStatus() %i",p->exitStatus()); 141 qDebug("p->exitStatus() %i",p->exitStatus());
142 if (p->exitStatus()!=0 || !p->normalExit()) 142 if (p->exitStatus()!=0 || !p->normalExit())
143 { 143 {
144 slotProbeNtpServer(); 144 slotProbeNtpServer();
145 return; 145 return;
146 } 146 }
147 Config cfg("ntp",Config::User); 147 Config cfg("ntp",Config::User);
148 cfg.setGroup("lookups"); 148 cfg.setGroup("lookups");
149 int lastLookup = cfg.readNumEntry("time",0); 149 int lastLookup = cfg.readNumEntry("time",0);
150 int lookupCount = cfg.readNumEntry("count",0); 150 int lookupCount = cfg.readNumEntry("count",0);
151 bool lastNtp = cfg.readBoolEntry("lastNtp",false); 151 bool lastNtp = cfg.readBoolEntry("lastNtp",false);
152 int time = TimeConversion::toUTC( QDateTime::currentDateTime() ); 152 int time = TimeConversion::toUTC( QDateTime::currentDateTime() );
153 cfg.writeEntry("time", time); 153 cfg.writeEntry("time", time);
154 154
155 float timeShift = getTimeShift(); 155 float timeShift = getTimeShift();
156 if (timeShift == 0.0) return; 156 if (timeShift == 0.0) return;
157 int secsSinceLast = time - lastLookup; 157 int secsSinceLast = time - lastLookup;
158 TextLabelNewTime->setText(QDateTime::currentDateTime().toString()); 158 TextLabelNewTime->setText(QDateTime::currentDateTime().toString());
159 TextLabelTimeShift->setText(QString::number(timeShift)+tr(" seconds")); 159 TextLabelTimeShift->setText(QString::number(timeShift)+tr(" seconds"));
160 if ( lastNtp && lastLookup > 0 && secsSinceLast > 60* SpinBoxMinLookupDelay->value()) 160 if ( lastNtp && lastLookup > 0 && secsSinceLast > 60* SpinBoxMinLookupDelay->value())
161 { 161 {
162 cfg.setGroup("lookup_"+QString::number(lookupCount)); 162 cfg.setGroup("lookup_"+QString::number(lookupCount));
163 lookupCount++; 163 lookupCount++;
164 cfg.writeEntry("count",lookupCount);
165 _shiftPerSec = timeShift / secsSinceLast; 164 _shiftPerSec = timeShift / secsSinceLast;
166 qDebug("secs since last lookup %i", secsSinceLast);qDebug("timeshift since last lookup %f", timeShift);qDebug("timeshift since per sec %f", _shiftPerSec); 165 qDebug("secs since last lookup %i", secsSinceLast);qDebug("timeshift since last lookup %f", timeShift);qDebug("timeshift since per sec %f", _shiftPerSec);
167 cfg.writeEntry("secsSinceLast",secsSinceLast); 166 cfg.writeEntry("secsSinceLast",secsSinceLast);
168 cfg.writeEntry("timeShift",QString::number(timeShift)); 167 cfg.writeEntry("timeShift",QString::number(timeShift));
168 cfg.setGroup("lookups");
169 cfg.writeEntry("count",lookupCount);
169 cfg.writeEntry("lastNtp",true); 170 cfg.writeEntry("lastNtp",true);
170 } 171 }
171} 172}
172 173
173 174
174float Ntp::getTimeShift() 175float Ntp::getTimeShift()
175{ 176{
176 QString _offset = "offset"; 177 QString _offset = "offset";
177 QString _sec = "sec"; 178 QString _sec = "sec";
178 QRegExp _reOffset = QRegExp(_offset); 179 QRegExp _reOffset = QRegExp(_offset);
179 QRegExp _reEndOffset = QRegExp(_sec); 180 QRegExp _reEndOffset = QRegExp(_sec);
180 int posOffset = _reOffset.match( _ntpOutput ); 181 int posOffset = _reOffset.match( _ntpOutput );
181 int posEndOffset = _reEndOffset.match( _ntpOutput, posOffset ); 182 int posEndOffset = _reEndOffset.match( _ntpOutput, posOffset );
182 posOffset += _offset.length() + 1; 183 posOffset += _offset.length() + 1;
183 QString diff = _ntpOutput.mid(posOffset, posEndOffset-posOffset-1); 184 QString diff = _ntpOutput.mid(posOffset, posEndOffset-posOffset-1);
184 qDebug("%s", _ntpOutput.latin1()); 185 qDebug("%s", _ntpOutput.latin1());
185 qDebug("diff = >%s<",diff.latin1()); 186 qDebug("diff = >%s<",diff.latin1());
186 return diff.toFloat(); 187 return diff.toFloat();
187} 188}
188 189
189void Ntp::readLookups() 190void Ntp::readLookups()
190{ 191{
191 Config cfg("ntp",Config::User); 192 Config cfg("ntp",Config::User);
192 cfg.setGroup("lookups"); 193 cfg.setGroup("lookups");
193 int lookupCount = cfg.readNumEntry("count",0); 194 int lookupCount = cfg.readNumEntry("count",0);
194 float last, shift, shiftPerSec; 195 float last, shift, shiftPerSec;
195 qDebug("lookupCount = %i",lookupCount); 196 qDebug("lookupCount = %i",lookupCount);
196 TableLookups->setNumCols( 3 ); 197 TableLookups->setNumCols( 3 );
197 TableLookups->setNumRows( lookupCount); 198 TableLookups->setNumRows( lookupCount);
198 TableLookups->horizontalHeader()->setLabel(1,tr("last [h]")); 199 TableLookups->horizontalHeader()->setLabel(1,tr("last [h]"));
199 TableLookups->horizontalHeader()->setLabel(2,tr("offset [s]")); 200 TableLookups->horizontalHeader()->setLabel(2,tr("offset [s]"));
200 TableLookups->horizontalHeader()->setLabel(0,tr("shift [s/h]")); 201 TableLookups->horizontalHeader()->setLabel(0,tr("shift [s/h]"));
201 int cw = TableLookups->width()/4; 202 int cw = TableLookups->width()/4;
202 qDebug("column width %i",cw); 203 qDebug("column width %i",cw);
203 cw = 50; 204 cw = 50;
204 TableLookups->setColumnWidth( 0, cw+30 ); 205 TableLookups->setColumnWidth( 0, cw+30 );
205 TableLookups->setColumnWidth( 1, cw ); 206 TableLookups->setColumnWidth( 1, cw );
206 TableLookups->setColumnWidth( 2, cw ); 207 TableLookups->setColumnWidth( 2, cw );
207 TableLookups->sortColumn(0, false, true ); 208 TableLookups->sortColumn(0, false, true );
208 // TableLookups->setSorting( true ); 209 // TableLookups->setSorting( true );
209 for (int i=0; i < lookupCount; i++) 210 for (int i=0; i < lookupCount; i++)
210 { 211 {
211 cfg.setGroup("lookup_"+QString::number(i)); 212 cfg.setGroup("lookup_"+QString::number(i));
212 last = cfg.readEntry("secsSinceLast",0).toFloat(); 213 last = cfg.readEntry("secsSinceLast",0).toFloat();
213 shift = QString(cfg.readEntry("timeShift",0)).toFloat(); 214 shift = QString(cfg.readEntry("timeShift",0)).toFloat();
214 // qDebug("%i last %f",i,last); 215 // qDebug("%i last %f",i,last);
215 // qDebug("%i shift %f",i,shift); 216 // qDebug("%i shift %f",i,shift);
216 shiftPerSec = shift / last; 217 shiftPerSec = shift / last;
217 _shiftPerSec += shiftPerSec; 218 _shiftPerSec += shiftPerSec;
218 TableLookups->setText( i,0,QString::number(shiftPerSec*60*60)); 219 TableLookups->setText( i,0,QString::number(shiftPerSec*60*60));
219 TableLookups->setText( i,2,QString::number(shift)); 220 TableLookups->setText( i,2,QString::number(shift));
220 TableLookups->setText( i,1,QString::number(last/(60*60))); 221 TableLookups->setText( i,1,QString::number(last/(60*60)));
221 } 222 }
222 _shiftPerSec /= lookupCount; 223 _shiftPerSec /= lookupCount;
223 TextLabelShift->setText(QString::number(_shiftPerSec*60*60)+tr(" s/h")); 224 TextLabelShift->setText(QString::number(_shiftPerSec*60*60)+tr(" s/h"));
224} 225}
225 226
226void Ntp::preditctTime() 227void Ntp::preditctTime()
227{ 228{
228 Config cfg("ntp",Config::User); 229 Config cfg("ntp",Config::User);
229 cfg.setGroup("lookups"); 230 cfg.setGroup("lookups");
230 int lastTime = cfg.readNumEntry("time",0); 231 int lastTime = cfg.readNumEntry("time",0);
231 cfg.writeEntry("lastNtp",true); 232 cfg.writeEntry("lastNtp",true);
232 setenv( "TZ", tz->currentZone(), 1 ); 233 setenv( "TZ", tz->currentZone(), 1 );
233 int now = TimeConversion::toUTC( QDateTime::currentDateTime() ); 234 int now = TimeConversion::toUTC( QDateTime::currentDateTime() );
234 int corr = int((now - lastTime) * _shiftPerSec); 235 int corr = int((now - lastTime) * _shiftPerSec);
235 TextLabelEstimatedShift->setText(QString::number(corr)+tr(" seconds")); 236 TextLabelEstimatedShift->setText(QString::number(corr)+tr(" seconds"));
236 predictedTime = QDateTime::currentDateTime().addSecs(corr); 237 predictedTime = QDateTime::currentDateTime().addSecs(corr);
237 TextLabelPredTime->setText(predictedTime.toString()); 238 TextLabelPredTime->setText(predictedTime.toString());
238 TextLabelMainPredTime->setText(tr("Predicted time:")+"<br><b>"+predictedTime.toString()+"</b>"); 239 TextLabelMainPredTime->setText(tr("Predicted time:")+"<br><b>"+predictedTime.toString()+"</b>");
239} 240}
240 241
241void Ntp::setPredictTime() 242void Ntp::setPredictTime()
242{ 243{
243 preditctTime(); 244 preditctTime();
244 setTime( predictedTime ); 245 setTime( predictedTime );
245} 246}
246 247
247void Ntp::slotCheckNtp(int i) 248void Ntp::slotCheckNtp(int i)
248{ 249{
249 if (i == 0) 250 if (i == 0)
250 { 251 {
251 TextLabelMainPredTime->hide(); 252 TextLabelMainPredTime->hide();
252 ButtonSetTime->setText( tr("Get time from network") ); 253 ButtonSetTime->setText( tr("Get time from network") );
253 connect( ButtonSetTime, SIGNAL(clicked()), SLOT(slotRunNtp()) ); 254 connect( ButtonSetTime, SIGNAL(clicked()), SLOT(slotRunNtp()) );
254 if ( ntpDelayElapsed() ) 255 if ( ntpDelayElapsed() )
255 { 256 {
256 slotRunNtp(); 257 slotRunNtp();
257 disconnect(ntpTimer, SIGNAL( timeout() ), this, SLOT(slotProbeNtpServer()) ); 258 disconnect(ntpTimer, SIGNAL( timeout() ), this, SLOT(slotProbeNtpServer()) );
258 connect(ntpTimer, SIGNAL( timeout() ), SLOT(slotRunNtp()) ); 259 connect(ntpTimer, SIGNAL( timeout() ), SLOT(slotRunNtp()) );
259 }else{ 260 }else{
260 disconnect(ntpTimer, SIGNAL( timeout() ), this, SLOT(slotRunNtp()) ); 261 disconnect(ntpTimer, SIGNAL( timeout() ), this, SLOT(slotRunNtp()) );
261 connect(ntpTimer, SIGNAL( timeout() ), SLOT(slotProbeNtpServer()) ); 262 connect(ntpTimer, SIGNAL( timeout() ), SLOT(slotProbeNtpServer()) );
262 } 263 }
263 }else{ 264 }else{
264 preditctTime(); 265 preditctTime();
265 ButtonSetTime->setText( tr("Set predicted time") ); 266 ButtonSetTime->setText( tr("Set predicted time") );
266 if (i>0)ntpOutPut(tr("Could not connect to server ")+getNtpServer()); 267 if (i>0)ntpOutPut(tr("Could not connect to server ")+getNtpServer());
267 connect( ButtonSetTime, SIGNAL(clicked()), SLOT(setPredictTime()) ); 268 connect( ButtonSetTime, SIGNAL(clicked()), SLOT(setPredictTime()) );
268 connect( ntpTimer, SIGNAL( timeout() ), SLOT(slotProbeNtpServer()) ); 269 connect( ntpTimer, SIGNAL( timeout() ), SLOT(slotProbeNtpServer()) );
269 } 270 }
270} 271}
271 272
272void Ntp::slotProbeNtpServer() 273void Ntp::slotProbeNtpServer()
273{ 274{
274 qDebug("Ntp::slotProbeNtpServer()"); 275 qDebug("Ntp::slotProbeNtpServer()");
275 ntpSock->connectToHost( getNtpServer() ,123); 276 ntpSock->connectToHost( getNtpServer() ,123);
276} 277}
277 278
278void Ntp::slotNtpDelayChanged(int delay) 279void Ntp::slotNtpDelayChanged(int delay)
279{ 280{
280 ntpTimer->changeInterval( delay*1000*60 ); 281 ntpTimer->changeInterval( delay*1000*60 );
281} 282}
282 283
283void Ntp::ntpOutPut(QString out) 284void Ntp::ntpOutPut(QString out)
284{ 285{
285 MultiLineEditntpOutPut->append(out); 286 MultiLineEditntpOutPut->append(out);
286 MultiLineEditntpOutPut->setCursorPosition(MultiLineEditntpOutPut->numLines() + 1,0,FALSE); 287 MultiLineEditntpOutPut->setCursorPosition(MultiLineEditntpOutPut->numLines() + 1,0,FALSE);
287} 288}
288 289