summaryrefslogtreecommitdiff
authortille <tille>2002-10-19 15:33:05 (UTC)
committer tille <tille>2002-10-19 15:33:05 (UTC)
commit7a1c7fca5105427ff569f8219fb96873571a749a (patch) (unidiff)
tree4c5620553e8647c72fb9a9f42eb069600f62e3ea
parent04d045931cb66c8ff13b1247e6a366ff77c36474 (diff)
downloadopie-7a1c7fca5105427ff569f8219fb96873571a749a.zip
opie-7a1c7fca5105427ff569f8219fb96873571a749a.tar.gz
opie-7a1c7fca5105427ff569f8219fb96873571a749a.tar.bz2
typo
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/settings/netsystemtime/ntp.cpp2
1 files changed, 1 insertions, 1 deletions
diff --git a/noncore/settings/netsystemtime/ntp.cpp b/noncore/settings/netsystemtime/ntp.cpp
index 9572993..fbd65a2 100644
--- a/noncore/settings/netsystemtime/ntp.cpp
+++ b/noncore/settings/netsystemtime/ntp.cpp
@@ -1,332 +1,332 @@
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 <qpe/datebookdb.h> 20#include <qpe/datebookdb.h>
21#include <qpe/qcopenvelope_qws.h> 21#include <qpe/qcopenvelope_qws.h>
22#include <sys/time.h> 22#include <sys/time.h>
23#include <time.h> 23#include <time.h>
24#include <stdlib.h> 24#include <stdlib.h>
25 25
26 26
27Ntp::Ntp( QWidget* parent, const char* name, WFlags fl ) 27Ntp::Ntp( QWidget* parent, const char* name, WFlags fl )
28 : SetDateTime( parent, name, fl ) 28 : SetDateTime( parent, name, fl )
29{ 29{
30 Config ntpSrvs(QPEApplication::qpeDir()+"etc/ntpservers",Config::File); 30 Config ntpSrvs(QPEApplication::qpeDir()+"etc/ntpservers",Config::File);
31 ntpSrvs.setGroup("servers"); 31 ntpSrvs.setGroup("servers");
32 int srvCount = ntpSrvs.readNumEntry("count", 0 ); 32 int srvCount = ntpSrvs.readNumEntry("count", 0 );
33 for (int i = 0; i < srvCount; i++) 33 for (int i = 0; i < srvCount; i++)
34 { 34 {
35 ntpSrvs.setGroup(QString::number(i)); 35 ntpSrvs.setGroup(QString::number(i));
36 ComboNtpSrv->insertItem( ntpSrvs.readEntry("name") ); 36 ComboNtpSrv->insertItem( ntpSrvs.readEntry("name") );
37 } 37 }
38 if ( srvCount==0 ) ComboNtpSrv->insertItem(tr("time.fu-berlin.de")); 38 if ( srvCount==0 ) ComboNtpSrv->insertItem(tr("time.fu-berlin.de"));
39 39
40 Config cfg("ntp",Config::User); 40 Config cfg("ntp",Config::User);
41 cfg.setGroup("settings"); 41 cfg.setGroup("settings");
42 SpinBoxMinLookupDelay->setValue( cfg.readNumEntry("minLookupDiff",41) ); 42 SpinBoxMinLookupDelay->setValue( cfg.readNumEntry("minLookupDiff",41) );
43 SpinBoxNtpDelay->setValue( cfg.readNumEntry("ntpRefreshFreq",42) ); 43 SpinBoxNtpDelay->setValue( cfg.readNumEntry("ntpRefreshFreq",42) );
44 ComboNtpSrv->setCurrentItem( cfg.readNumEntry("ntpServer", 0) ); 44 ComboNtpSrv->setCurrentItem( cfg.readNumEntry("ntpServer", 0) );
45 45
46 makeChannel(); 46 makeChannel();
47 47
48 ntpTimer = new QTimer(this); 48 ntpTimer = new QTimer(this);
49 49
50 ntpProcess = new OProcess( ); 50 ntpProcess = new OProcess( );
51 connect( SpinBoxNtpDelay, SIGNAL( valueChanged(int) ), 51 connect( SpinBoxNtpDelay, SIGNAL( valueChanged(int) ),
52 SLOT(slotNtpDelayChanged(int)) ); 52 SLOT(slotNtpDelayChanged(int)) );
53 53
54 ntpSock = new QSocket( this ); 54 ntpSock = new QSocket( this );
55 connect( ntpSock, SIGNAL( error(int) ), 55 connect( ntpSock, SIGNAL( error(int) ),
56 SLOT(slotCheckNtp(int)) ); 56 SLOT(slotCheckNtp(int)) );
57 slotProbeNtpServer(); 57 slotProbeNtpServer();
58 58
59 connect ( ntpProcess, SIGNAL(receivedStdout(OProcess*,char*,int)), 59 connect ( ntpProcess, SIGNAL(receivedStdout(OProcess*,char*,int)),
60 this, SLOT(getNtpOutput(OProcess*,char*,int))); 60 this, SLOT(getNtpOutput(OProcess*,char*,int)));
61 connect ( ntpProcess, SIGNAL(processExited(OProcess*)), 61 connect ( ntpProcess, SIGNAL(processExited(OProcess*)),
62 this, SLOT(ntpFinished(OProcess*))); 62 this, SLOT(ntpFinished(OProcess*)));
63 connect(runNtp, SIGNAL(clicked()), this, SLOT(slotRunNtp())); 63 connect(runNtp, SIGNAL(clicked()), this, SLOT(slotRunNtp()));
64 connect(PushButtonPredict, SIGNAL(clicked()), this, SLOT(preditctTime())); 64 connect(PushButtonPredict, SIGNAL(clicked()), this, SLOT(preditctTime()));
65 connect(PushButtonSetPredTime, SIGNAL(clicked()), this, SLOT(setPredictTime())); 65 connect(PushButtonSetPredTime, SIGNAL(clicked()), this, SLOT(setPredictTime()));
66 slotCheckNtp(-1); 66 slotCheckNtp(-1);
67 readLookups(); 67 readLookups();
68} 68}
69 69
70Ntp::~Ntp() 70Ntp::~Ntp()
71{ 71{
72 delete ntpProcess; 72 delete ntpProcess;
73 Config ntpSrvs("/etc/ntpservers",Config::File); 73 Config ntpSrvs("/etc/ntpservers",Config::File);
74 ntpSrvs.setGroup("servers"); 74 ntpSrvs.setGroup("servers");
75 int srvCount = ComboNtpSrv->count(); 75 int srvCount = ComboNtpSrv->count();
76 ntpSrvs.writeEntry("count", srvCount); 76 ntpSrvs.writeEntry("count", srvCount);
77 for (int i = 0; i < srvCount; i++) 77 for (int i = 0; i < srvCount; i++)
78 { 78 {
79 ntpSrvs.setGroup(QString::number(i)); 79 ntpSrvs.setGroup(QString::number(i));
80 ntpSrvs.writeEntry( "name", ComboNtpSrv->text(i) ); 80 ntpSrvs.writeEntry( "name", ComboNtpSrv->text(i) );
81 } 81 }
82 Config cfg("ntp",Config::User); 82 Config cfg("ntp",Config::User);
83 cfg.setGroup("settings"); 83 cfg.setGroup("settings");
84 cfg.writeEntry("ntpServer", ComboNtpSrv->currentItem()); 84 cfg.writeEntry("ntpServer", ComboNtpSrv->currentItem());
85 cfg.writeEntry( "minLookupDiff", SpinBoxMinLookupDelay->value() ); 85 cfg.writeEntry( "minLookupDiff", SpinBoxMinLookupDelay->value() );
86 cfg.writeEntry( "ntpRefreshFreq", SpinBoxNtpDelay->value() ); 86 cfg.writeEntry( "ntpRefreshFreq", SpinBoxNtpDelay->value() );
87} 87}
88 88
89bool Ntp::ntpDelayElapsed() 89bool Ntp::ntpDelayElapsed()
90{ 90{
91 Config cfg("ntp",Config::User); 91 Config cfg("ntp",Config::User);
92 cfg.setGroup("lookups"); 92 cfg.setGroup("lookups");
93 _lookupDiff = TimeConversion::toUTC(QDateTime::currentDateTime()) - cfg.readNumEntry("time",0); 93 _lookupDiff = TimeConversion::toUTC(QDateTime::currentDateTime()) - cfg.readNumEntry("time",0);
94 return (_lookupDiff - (SpinBoxNtpDelay->value()*60)) > -60; 94 return (_lookupDiff - (SpinBoxNtpDelay->value()*60)) > -60;
95} 95}
96 96
97QString Ntp::getNtpServer() 97QString Ntp::getNtpServer()
98{ 98{
99 return ComboNtpSrv->currentText(); 99 return ComboNtpSrv->currentText();
100} 100}
101 101
102void Ntp::slotRunNtp() 102void Ntp::slotRunNtp()
103{ 103{
104 if ( !ntpDelayElapsed() ) 104 if ( !ntpDelayElapsed() )
105 { 105 {
106 switch ( 106 switch (
107 QMessageBox::warning(this, tr("Run NTP?"), 107 QMessageBox::warning(this, tr("Run NTP?"),
108 tr("You asked for a delay of ")+SpinBoxNtpDelay->text()+tr(" minutes, but only ")+ 108 tr("You asked for a delay of ")+SpinBoxNtpDelay->text()+tr(" minutes, but only ")+
109 QString::number(_lookupDiff/60)+tr(" minutes elapsed since last loopup.")+ 109 QString::number(_lookupDiff/60)+tr(" minutes elapsed since last lookup.")+
110 "<br>"+tr("Rerun NTP?"), 110 "<br>"+tr("Rerun NTP?"),
111 QMessageBox::Ok,QMessageBox::Cancel) 111 QMessageBox::Ok,QMessageBox::Cancel)
112 ) { 112 ) {
113 case QMessageBox::Ok: break; 113 case QMessageBox::Ok: break;
114 case QMessageBox::Cancel: return; 114 case QMessageBox::Cancel: return;
115 default: return; 115 default: return;
116 } 116 }
117 } 117 }
118 TextLabelStartTime->setText(QDateTime::currentDateTime().toString()); 118 TextLabelStartTime->setText(QDateTime::currentDateTime().toString());
119 ntpOutPut( tr("Running:")+"\nntpdate "+getNtpServer() ); 119 ntpOutPut( tr("Running:")+"\nntpdate "+getNtpServer() );
120 120
121 ntpProcess->clearArguments(); 121 ntpProcess->clearArguments();
122 *ntpProcess << "ntpdate" << getNtpServer(); 122 *ntpProcess << "ntpdate" << getNtpServer();
123 bool ret = ntpProcess->start(OProcess::NotifyOnExit,OProcess::AllOutput); 123 bool ret = ntpProcess->start(OProcess::NotifyOnExit,OProcess::AllOutput);
124 if ( !ret ) { 124 if ( !ret ) {
125 qDebug("Error while executing ntpdate"); 125 qDebug("Error while executing ntpdate");
126 ntpOutPut( tr("Error while executing ntpdate")); 126 ntpOutPut( tr("Error while executing ntpdate"));
127 } 127 }
128} 128}
129 129
130void Ntp::getNtpOutput(OProcess *proc, char *buffer, int buflen) 130void Ntp::getNtpOutput(OProcess *proc, char *buffer, int buflen)
131{ 131{
132 QString lineStr, lineStrOld; 132 QString lineStr, lineStrOld;
133 lineStr = buffer; 133 lineStr = buffer;
134 lineStr=lineStr.left(buflen); 134 lineStr=lineStr.left(buflen);
135 if (lineStr!=lineStrOld) 135 if (lineStr!=lineStrOld)
136 { 136 {
137 ntpOutPut(lineStr); 137 ntpOutPut(lineStr);
138 _ntpOutput += lineStr; 138 _ntpOutput += lineStr;
139 } 139 }
140 lineStrOld = lineStr; 140 lineStrOld = lineStr;
141} 141}
142 142
143void Ntp::ntpFinished(OProcess *p) 143void Ntp::ntpFinished(OProcess *p)
144{ 144{
145 qDebug("p->exitStatus() %i",p->exitStatus()); 145 qDebug("p->exitStatus() %i",p->exitStatus());
146 if (p->exitStatus()!=0 || !p->normalExit()) 146 if (p->exitStatus()!=0 || !p->normalExit())
147 { 147 {
148 slotProbeNtpServer(); 148 slotProbeNtpServer();
149 return; 149 return;
150 } 150 }
151 151
152 Global::writeHWClock(); 152 Global::writeHWClock();
153 // since time has changed quickly load in the datebookdb 153 // since time has changed quickly load in the datebookdb
154 // to allow the alarm server to get a better grip on itself 154 // to allow the alarm server to get a better grip on itself
155 // (example re-trigger alarms for when we travel back in time) 155 // (example re-trigger alarms for when we travel back in time)
156 DateBookDB db; 156 DateBookDB db;
157 157
158// QCopEnvelope timeApplet( "QPE/TaskBar", "reloadApplets()" ); 158// QCopEnvelope timeApplet( "QPE/TaskBar", "reloadApplets()" );
159// timeApplet << ""; 159// timeApplet << "";
160 160
161 Config cfg("ntp",Config::User); 161 Config cfg("ntp",Config::User);
162 cfg.setGroup("lookups"); 162 cfg.setGroup("lookups");
163 int lastLookup = cfg.readNumEntry("time",0); 163 int lastLookup = cfg.readNumEntry("time",0);
164 int lookupCount = cfg.readNumEntry("count",0); 164 int lookupCount = cfg.readNumEntry("count",0);
165 bool lastNtp = cfg.readBoolEntry("lastNtp",false); 165 bool lastNtp = cfg.readBoolEntry("lastNtp",false);
166 int time = TimeConversion::toUTC( QDateTime::currentDateTime() ); 166 int time = TimeConversion::toUTC( QDateTime::currentDateTime() );
167 cfg.writeEntry("time", time); 167 cfg.writeEntry("time", time);
168 168
169 float timeShift = getTimeShift(); 169 float timeShift = getTimeShift();
170 if (timeShift == 0.0) return; 170 if (timeShift == 0.0) return;
171 int secsSinceLast = time - lastLookup; 171 int secsSinceLast = time - lastLookup;
172 TextLabelNewTime->setText(QDateTime::currentDateTime().toString()); 172 TextLabelNewTime->setText(QDateTime::currentDateTime().toString());
173 TextLabelTimeShift->setText(QString::number(timeShift)+tr(" seconds")); 173 TextLabelTimeShift->setText(QString::number(timeShift)+tr(" seconds"));
174 if ( lastNtp && lastLookup > 0 && secsSinceLast > 60* SpinBoxMinLookupDelay->value()) 174 if ( lastNtp && lastLookup > 0 && secsSinceLast > 60* SpinBoxMinLookupDelay->value())
175 { 175 {
176 cfg.setGroup("lookup_"+QString::number(lookupCount)); 176 cfg.setGroup("lookup_"+QString::number(lookupCount));
177 lookupCount++; 177 lookupCount++;
178 _shiftPerSec = timeShift / secsSinceLast; 178 _shiftPerSec = timeShift / secsSinceLast;
179 qDebug("secs since last lookup %i", secsSinceLast);qDebug("timeshift since last lookup %f", timeShift);qDebug("timeshift since per sec %f", _shiftPerSec); 179 qDebug("secs since last lookup %i", secsSinceLast);qDebug("timeshift since last lookup %f", timeShift);qDebug("timeshift since per sec %f", _shiftPerSec);
180 cfg.writeEntry("secsSinceLast",secsSinceLast); 180 cfg.writeEntry("secsSinceLast",secsSinceLast);
181 cfg.writeEntry("timeShift",QString::number(timeShift)); 181 cfg.writeEntry("timeShift",QString::number(timeShift));
182 cfg.setGroup("lookups"); 182 cfg.setGroup("lookups");
183 cfg.writeEntry("count",lookupCount); 183 cfg.writeEntry("count",lookupCount);
184 cfg.writeEntry("lastNtp",true); 184 cfg.writeEntry("lastNtp",true);
185 } 185 }
186} 186}
187 187
188 188
189float Ntp::getTimeShift() 189float Ntp::getTimeShift()
190{ 190{
191 QString _offset = "offset"; 191 QString _offset = "offset";
192 QString _sec = "sec"; 192 QString _sec = "sec";
193 QRegExp _reOffset = QRegExp(_offset); 193 QRegExp _reOffset = QRegExp(_offset);
194 QRegExp _reEndOffset = QRegExp(_sec); 194 QRegExp _reEndOffset = QRegExp(_sec);
195 int posOffset = _reOffset.match( _ntpOutput ); 195 int posOffset = _reOffset.match( _ntpOutput );
196 int posEndOffset = _reEndOffset.match( _ntpOutput, posOffset ); 196 int posEndOffset = _reEndOffset.match( _ntpOutput, posOffset );
197 posOffset += _offset.length() + 1; 197 posOffset += _offset.length() + 1;
198 QString diff = _ntpOutput.mid(posOffset, posEndOffset-posOffset-1); 198 QString diff = _ntpOutput.mid(posOffset, posEndOffset-posOffset-1);
199 qDebug("%s", _ntpOutput.latin1()); 199 qDebug("%s", _ntpOutput.latin1());
200 qDebug("diff = >%s<",diff.latin1()); 200 qDebug("diff = >%s<",diff.latin1());
201 return diff.toFloat(); 201 return diff.toFloat();
202} 202}
203 203
204void Ntp::readLookups() 204void Ntp::readLookups()
205{ 205{
206 Config cfg("ntp",Config::User); 206 Config cfg("ntp",Config::User);
207 cfg.setGroup("lookups"); 207 cfg.setGroup("lookups");
208 int lookupCount = cfg.readNumEntry("count",0); 208 int lookupCount = cfg.readNumEntry("count",0);
209 float last, shift, shiftPerSec; 209 float last, shift, shiftPerSec;
210 qDebug("lookupCount = %i",lookupCount); 210 qDebug("lookupCount = %i",lookupCount);
211 TableLookups->setNumCols( 3 ); 211 TableLookups->setNumCols( 3 );
212 TableLookups->setNumRows( lookupCount); 212 TableLookups->setNumRows( lookupCount);
213 TableLookups->horizontalHeader()->setLabel(1,tr("last [h]")); 213 TableLookups->horizontalHeader()->setLabel(1,tr("last [h]"));
214 TableLookups->horizontalHeader()->setLabel(2,tr("offset [s]")); 214 TableLookups->horizontalHeader()->setLabel(2,tr("offset [s]"));
215 TableLookups->horizontalHeader()->setLabel(0,tr("shift [s/h]")); 215 TableLookups->horizontalHeader()->setLabel(0,tr("shift [s/h]"));
216 int cw = TableLookups->width()/4; 216 int cw = TableLookups->width()/4;
217 qDebug("column width %i",cw); 217 qDebug("column width %i",cw);
218 cw = 50; 218 cw = 50;
219 TableLookups->setColumnWidth( 0, cw+30 ); 219 TableLookups->setColumnWidth( 0, cw+30 );
220 TableLookups->setColumnWidth( 1, cw ); 220 TableLookups->setColumnWidth( 1, cw );
221 TableLookups->setColumnWidth( 2, cw ); 221 TableLookups->setColumnWidth( 2, cw );
222 TableLookups->sortColumn(0, false, true ); 222 TableLookups->sortColumn(0, false, true );
223 // TableLookups->setSorting( true ); 223 // TableLookups->setSorting( true );
224 _shiftPerSec = 0; 224 _shiftPerSec = 0;
225 for (int i=0; i < lookupCount; i++) 225 for (int i=0; i < lookupCount; i++)
226 { 226 {
227 cfg.setGroup("lookup_"+QString::number(i)); 227 cfg.setGroup("lookup_"+QString::number(i));
228 last = cfg.readEntry("secsSinceLast",0).toFloat(); 228 last = cfg.readEntry("secsSinceLast",0).toFloat();
229 shift = QString(cfg.readEntry("timeShift",0)).toFloat(); 229 shift = QString(cfg.readEntry("timeShift",0)).toFloat();
230 shiftPerSec = shift / last; 230 shiftPerSec = shift / last;
231 qDebug("%i shift %f",i,shiftPerSec); 231 qDebug("%i shift %f",i,shiftPerSec);
232 _shiftPerSec += shiftPerSec; 232 _shiftPerSec += shiftPerSec;
233 TableLookups->setText( i,0,QString::number(shiftPerSec*60*60)); 233 TableLookups->setText( i,0,QString::number(shiftPerSec*60*60));
234 TableLookups->setText( i,2,QString::number(shift)); 234 TableLookups->setText( i,2,QString::number(shift));
235 TableLookups->setText( i,1,QString::number(last/(60*60))); 235 TableLookups->setText( i,1,QString::number(last/(60*60)));
236 } 236 }
237 _shiftPerSec /= lookupCount; 237 _shiftPerSec /= lookupCount;
238 TextLabelShift->setText(QString::number(_shiftPerSec*60*60)+tr(" s/h")); 238 TextLabelShift->setText(QString::number(_shiftPerSec*60*60)+tr(" s/h"));
239} 239}
240 240
241void Ntp::preditctTime() 241void Ntp::preditctTime()
242{ 242{
243 Config cfg("ntp",Config::User); 243 Config cfg("ntp",Config::User);
244 cfg.setGroup("lookups"); 244 cfg.setGroup("lookups");
245 int lastTime = cfg.readNumEntry("time",0); 245 int lastTime = cfg.readNumEntry("time",0);
246 cfg.writeEntry("lastNtp",true); 246 cfg.writeEntry("lastNtp",true);
247 setenv( "TZ", tz->currentZone(), 1 ); 247 setenv( "TZ", tz->currentZone(), 1 );
248 int now = TimeConversion::toUTC( QDateTime::currentDateTime() ); 248 int now = TimeConversion::toUTC( QDateTime::currentDateTime() );
249 int corr = int((now - lastTime) * _shiftPerSec); 249 int corr = int((now - lastTime) * _shiftPerSec);
250 TextLabelEstimatedShift->setText(QString::number(corr)+tr(" seconds")); 250 TextLabelEstimatedShift->setText(QString::number(corr)+tr(" seconds"));
251 predictedTime = QDateTime::currentDateTime().addSecs(corr); 251 predictedTime = QDateTime::currentDateTime().addSecs(corr);
252 TextLabelPredTime->setText(predictedTime.toString()); 252 TextLabelPredTime->setText(predictedTime.toString());
253 TextLabelMainPredTime->setText(tr("Predicted time:")+"<br><b>"+predictedTime.toString()+"</b>"); 253 TextLabelMainPredTime->setText(tr("Predicted time:")+"<br><b>"+predictedTime.toString()+"</b>");
254} 254}
255 255
256void Ntp::setPredictTime() 256void Ntp::setPredictTime()
257{ 257{
258 preditctTime(); 258 preditctTime();
259 setTime( predictedTime ); 259 setTime( predictedTime );
260} 260}
261 261
262void Ntp::slotCheckNtp(int i) 262void Ntp::slotCheckNtp(int i)
263{ 263{
264 if (i == 0) 264 if (i == 0)
265 { 265 {
266 TextLabelMainPredTime->hide(); 266 TextLabelMainPredTime->hide();
267 ButtonSetTime->setText( tr("Get time from network") ); 267 ButtonSetTime->setText( tr("Get time from network") );
268 connect( ButtonSetTime, SIGNAL(clicked()), SLOT(slotRunNtp()) ); 268 connect( ButtonSetTime, SIGNAL(clicked()), SLOT(slotRunNtp()) );
269 if ( ntpDelayElapsed() ) 269 if ( ntpDelayElapsed() )
270 { 270 {
271 slotRunNtp(); 271 slotRunNtp();
272 disconnect(ntpTimer, SIGNAL( timeout() ), this, SLOT(slotProbeNtpServer()) ); 272 disconnect(ntpTimer, SIGNAL( timeout() ), this, SLOT(slotProbeNtpServer()) );
273 connect(ntpTimer, SIGNAL( timeout() ), SLOT(slotRunNtp()) ); 273 connect(ntpTimer, SIGNAL( timeout() ), SLOT(slotRunNtp()) );
274 }else{ 274 }else{
275 disconnect(ntpTimer, SIGNAL( timeout() ), this, SLOT(slotRunNtp()) ); 275 disconnect(ntpTimer, SIGNAL( timeout() ), this, SLOT(slotRunNtp()) );
276 connect(ntpTimer, SIGNAL( timeout() ), SLOT(slotProbeNtpServer()) ); 276 connect(ntpTimer, SIGNAL( timeout() ), SLOT(slotProbeNtpServer()) );
277 } 277 }
278 }else{ 278 }else{
279 preditctTime(); 279 preditctTime();
280 ButtonSetTime->setText( tr("Set predicted time") ); 280 ButtonSetTime->setText( tr("Set predicted time") );
281 if (i>0)ntpOutPut(tr("Could not connect to server ")+getNtpServer()); 281 if (i>0)ntpOutPut(tr("Could not connect to server ")+getNtpServer());
282 connect( ButtonSetTime, SIGNAL(clicked()), SLOT(setPredictTime()) ); 282 connect( ButtonSetTime, SIGNAL(clicked()), SLOT(setPredictTime()) );
283 connect( ntpTimer, SIGNAL( timeout() ), SLOT(slotProbeNtpServer()) ); 283 connect( ntpTimer, SIGNAL( timeout() ), SLOT(slotProbeNtpServer()) );
284 } 284 }
285} 285}
286 286
287void Ntp::slotProbeNtpServer() 287void Ntp::slotProbeNtpServer()
288{ 288{
289 qDebug("Ntp::slotProbeNtpServer()"); 289 qDebug("Ntp::slotProbeNtpServer()");
290 ntpSock->connectToHost( getNtpServer() ,123); 290 ntpSock->connectToHost( getNtpServer() ,123);
291} 291}
292 292
293void Ntp::slotNtpDelayChanged(int delay) 293void Ntp::slotNtpDelayChanged(int delay)
294{ 294{
295 ntpTimer->changeInterval( delay*1000*60 ); 295 ntpTimer->changeInterval( delay*1000*60 );
296} 296}
297 297
298void Ntp::ntpOutPut(QString out) 298void Ntp::ntpOutPut(QString out)
299{ 299{
300 MultiLineEditntpOutPut->append(out); 300 MultiLineEditntpOutPut->append(out);
301 MultiLineEditntpOutPut->setCursorPosition(MultiLineEditntpOutPut->numLines() + 1,0,FALSE); 301 MultiLineEditntpOutPut->setCursorPosition(MultiLineEditntpOutPut->numLines() + 1,0,FALSE);
302} 302}
303 303
304 304
305void Ntp::makeChannel() 305void Ntp::makeChannel()
306 { 306 {
307 channel = new QCopChannel( "QPE/Application/netsystemtime", this ); 307 channel = new QCopChannel( "QPE/Application/netsystemtime", this );
308 connect( channel, SIGNAL(received(const QCString&, const QByteArray&)), 308 connect( channel, SIGNAL(received(const QCString&, const QByteArray&)),
309 this, SLOT(receive(const QCString&, const QByteArray&)) ); 309 this, SLOT(receive(const QCString&, const QByteArray&)) );
310} 310}
311 311
312 312
313 313
314void Ntp::receive(const QCString &msg, const QByteArray &arg) 314void Ntp::receive(const QCString &msg, const QByteArray &arg)
315{ 315{
316 qDebug("QCop(Ntp) "+msg+" "+QCString(arg)); 316 qDebug("QCop(Ntp) "+msg+" "+QCString(arg));
317 if ( msg == "ntpLookup(QString)" ) 317 if ( msg == "ntpLookup(QString)" )
318 { 318 {
319 slotRunNtp(); 319 slotRunNtp();
320 } 320 }
321 if ( msg == "setPredictedTime(QString)" ) 321 if ( msg == "setPredictedTime(QString)" )
322 { 322 {
323 setPredictTime(); 323 setPredictTime();
324 }else{ 324 }else{
325 qDebug("Ntp::receive: Huh what do ya want"); 325 qDebug("Ntp::receive: Huh what do ya want");
326 } 326 }
327} 327}
328 328
329void Ntp::setDocument(const QString &fileName) 329void Ntp::setDocument(const QString &fileName)
330{ 330{
331 331
332} 332}