summaryrefslogtreecommitdiff
path: root/noncore
authortille <tille>2002-11-10 21:56:47 (UTC)
committer tille <tille>2002-11-10 21:56:47 (UTC)
commit0e357841ca8ff0f38bdb4ac7c2883ded2c407810 (patch) (unidiff)
treed2283dcdca4e85a8435689291afec45e5c34a5f4 /noncore
parent727eb9283d10cf61cc7f7a8506124cab9f37f2ed (diff)
downloadopie-0e357841ca8ff0f38bdb4ac7c2883ded2c407810.zip
opie-0e357841ca8ff0f38bdb4ac7c2883ded2c407810.tar.gz
opie-0e357841ca8ff0f38bdb4ac7c2883ded2c407810.tar.bz2
only show popup if visible
Diffstat (limited to 'noncore') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/settings/netsystemtime/ntp.cpp7
1 files changed, 4 insertions, 3 deletions
diff --git a/noncore/settings/netsystemtime/ntp.cpp b/noncore/settings/netsystemtime/ntp.cpp
index 111f7d4..6e74e32 100644
--- a/noncore/settings/netsystemtime/ntp.cpp
+++ b/noncore/settings/netsystemtime/ntp.cpp
@@ -131,102 +131,103 @@ void Ntp::slotRunNtp()
131{ 131{
132 if ( !ntpDelayElapsed() && CheckBoxAdvSettings->isChecked() ) 132 if ( !ntpDelayElapsed() && CheckBoxAdvSettings->isChecked() )
133 { 133 {
134 switch ( 134 switch (
135 QMessageBox::warning(this, tr("Run NTP?"), 135 QMessageBox::warning(this, tr("Run NTP?"),
136 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 ")+
137 QString::number(_lookupDiff/60)+tr(" minutes elapsed since last lookup.")+ 137 QString::number(_lookupDiff/60)+tr(" minutes elapsed since last lookup.")+
138 "<br>"+tr("Rerun NTP?"), 138 "<br>"+tr("Rerun NTP?"),
139 QMessageBox::Ok,QMessageBox::Cancel) 139 QMessageBox::Ok,QMessageBox::Cancel)
140 ) { 140 ) {
141 case QMessageBox::Ok: break; 141 case QMessageBox::Ok: break;
142 case QMessageBox::Cancel: return; 142 case QMessageBox::Cancel: return;
143 default: return; 143 default: return;
144 } 144 }
145 } 145 }
146 TextLabelStartTime->setText(QDateTime::currentDateTime().toString()); 146 TextLabelStartTime->setText(QDateTime::currentDateTime().toString());
147 ntpOutPut( tr("Running:")+"\nntpdate "+getNtpServer() ); 147 ntpOutPut( tr("Running:")+"\nntpdate "+getNtpServer() );
148 148
149 ntpProcess->clearArguments(); 149 ntpProcess->clearArguments();
150 *ntpProcess << "ntpdate" << getNtpServer(); 150 *ntpProcess << "ntpdate" << getNtpServer();
151 bool ret = ntpProcess->start(OProcess::NotifyOnExit,OProcess::AllOutput); 151 bool ret = ntpProcess->start(OProcess::NotifyOnExit,OProcess::AllOutput);
152 if ( !ret ) { 152 if ( !ret ) {
153 QMessageBox::critical(this, tr("ntp error"), 153 QMessageBox::critical(this, tr("ntp error"),
154 tr("Error while getting time form network!")); 154 tr("Error while getting time form network!"));
155 qDebug("Error while executing ntpdate"); 155 qDebug("Error while executing ntpdate");
156 ntpOutPut( tr("Error while executing ntpdate")); 156 ntpOutPut( tr("Error while executing ntpdate"));
157 } 157 }
158} 158}
159 159
160void Ntp::getNtpOutput(OProcess *proc, char *buffer, int buflen) 160void Ntp::getNtpOutput(OProcess *proc, char *buffer, int buflen)
161{ 161{
162 if (! proc ) qDebug("Ntp::getNtpOutput OProcess is null"); 162 if (! proc ) qDebug("Ntp::getNtpOutput OProcess is null");
163 QString lineStr, lineStrOld; 163 QString lineStr, lineStrOld;
164 lineStr = buffer; 164 lineStr = buffer;
165 lineStr=lineStr.left(buflen); 165 lineStr=lineStr.left(buflen);
166 if (lineStr!=lineStrOld) 166 if (lineStr!=lineStrOld)
167 { 167 {
168 ntpOutPut(lineStr); 168 ntpOutPut(lineStr);
169 _ntpOutput += lineStr; 169 _ntpOutput += lineStr;
170 } 170 }
171 lineStrOld = lineStr; 171 lineStrOld = lineStr;
172} 172}
173 173
174void Ntp::ntpFinished(OProcess *p) 174void Ntp::ntpFinished(OProcess *p)
175{ 175{
176 qDebug("p->exitStatus() %i",p->exitStatus()); 176 qDebug("p->exitStatus() %i",p->exitStatus());
177 if (p->exitStatus()!=0 || !p->normalExit()) 177 if (p->exitStatus()!=0 || !p->normalExit())
178 { 178 {
179 QMessageBox::critical(this, tr("ntp error"), 179 if ( isVisible() ) {
180 QMessageBox::critical(this, tr("ntp error"),
180 tr("Error while getting time form\n server")+ 181 tr("Error while getting time form\n server")+
181 getNtpServer()+"\n"+ 182 getNtpServer()+"\n"+
182 _ntpOutput ); 183 _ntpOutput );
183 // TabWidgetMain->setCurrentPage( 1 ); 184 TabWidgetMain->showPage( tabManualSetTime );
184 TabWidgetMain->showPage( tabManualSetTime ); 185 }
185 186
186 return; 187 return;
187 } 188 }
188 189
189 Global::writeHWClock(); 190 Global::writeHWClock();
190 // since time has changed quickly load in the datebookdb 191 // since time has changed quickly load in the datebookdb
191 // to allow the alarm server to get a better grip on itself 192 // to allow the alarm server to get a better grip on itself
192 // (example re-trigger alarms for when we travel back in time) 193 // (example re-trigger alarms for when we travel back in time)
193 DateBookDB db; 194 DateBookDB db;
194 195
195 // QCopEnvelope timeApplet( "QPE/TaskBar", "reloadApplets()" ); 196 // QCopEnvelope timeApplet( "QPE/TaskBar", "reloadApplets()" );
196 // timeApplet << ""; 197 // timeApplet << "";
197 198
198 Config cfg("ntp",Config::User); 199 Config cfg("ntp",Config::User);
199 cfg.setGroup("lookups"); 200 cfg.setGroup("lookups");
200 int lastLookup = cfg.readNumEntry("time",0); 201 int lastLookup = cfg.readNumEntry("time",0);
201 int lookupCount = cfg.readNumEntry("count",0); 202 int lookupCount = cfg.readNumEntry("count",0);
202 bool lastNtp = cfg.readBoolEntry("lastNtp",false); 203 bool lastNtp = cfg.readBoolEntry("lastNtp",false);
203 int time = TimeConversion::toUTC( QDateTime::currentDateTime() ); 204 int time = TimeConversion::toUTC( QDateTime::currentDateTime() );
204 cfg.writeEntry("time", time); 205 cfg.writeEntry("time", time);
205 206
206 float timeShift = getTimeShift(); 207 float timeShift = getTimeShift();
207 if (timeShift == 0.0) return; 208 if (timeShift == 0.0) return;
208 int secsSinceLast = time - lastLookup; 209 int secsSinceLast = time - lastLookup;
209 TextLabelNewTime->setText(QDateTime::currentDateTime().toString()); 210 TextLabelNewTime->setText(QDateTime::currentDateTime().toString());
210 TextLabelTimeShift->setText(QString::number(timeShift)+tr(" seconds")); 211 TextLabelTimeShift->setText(QString::number(timeShift)+tr(" seconds"));
211 if ( lastNtp && lastLookup > 0 && secsSinceLast > 60* SpinBoxMinLookupDelay->value()) 212 if ( lastNtp && lastLookup > 0 && secsSinceLast > 60* SpinBoxMinLookupDelay->value())
212 { 213 {
213 cfg.setGroup("lookup_"+QString::number(lookupCount)); 214 cfg.setGroup("lookup_"+QString::number(lookupCount));
214 lookupCount++; 215 lookupCount++;
215 _shiftPerSec = timeShift / secsSinceLast; 216 _shiftPerSec = timeShift / secsSinceLast;
216 qDebug("secs since last lookup %i", secsSinceLast);qDebug("timeshift since last lookup %f", timeShift);qDebug("timeshift since per sec %f", _shiftPerSec); 217 qDebug("secs since last lookup %i", secsSinceLast);qDebug("timeshift since last lookup %f", timeShift);qDebug("timeshift since per sec %f", _shiftPerSec);
217 cfg.writeEntry("secsSinceLast",secsSinceLast); 218 cfg.writeEntry("secsSinceLast",secsSinceLast);
218 cfg.writeEntry("timeShift",QString::number(timeShift)); 219 cfg.writeEntry("timeShift",QString::number(timeShift));
219 cfg.setGroup("lookups"); 220 cfg.setGroup("lookups");
220 cfg.writeEntry("count",lookupCount); 221 cfg.writeEntry("count",lookupCount);
221 cfg.writeEntry("lastNtp",true); 222 cfg.writeEntry("lastNtp",true);
222 } 223 }
223} 224}
224 225
225 226
226float Ntp::getTimeShift() 227float Ntp::getTimeShift()
227{ 228{
228 QString _offset = "offset"; 229 QString _offset = "offset";
229 QString _sec = "sec"; 230 QString _sec = "sec";
230 QRegExp _reOffset = QRegExp(_offset); 231 QRegExp _reOffset = QRegExp(_offset);
231 QRegExp _reEndOffset = QRegExp(_sec); 232 QRegExp _reEndOffset = QRegExp(_sec);
232 int posOffset = _reOffset.match( _ntpOutput ); 233 int posOffset = _reOffset.match( _ntpOutput );