summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/settings/netsystemtime/ntp.cpp6
1 files changed, 3 insertions, 3 deletions
diff --git a/noncore/settings/netsystemtime/ntp.cpp b/noncore/settings/netsystemtime/ntp.cpp
index 6c5aaf5..9572993 100644
--- a/noncore/settings/netsystemtime/ntp.cpp
+++ b/noncore/settings/netsystemtime/ntp.cpp
@@ -110,98 +110,98 @@ void Ntp::slotRunNtp()
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");
@@ -284,49 +284,49 @@ void Ntp::slotCheckNtp(int i)
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} \ No newline at end of file 332}