summaryrefslogtreecommitdiff
authortille <tille>2002-07-17 12:06:33 (UTC)
committer tille <tille>2002-07-17 12:06:33 (UTC)
commitc79db8d80c67bc66d49f8150ff85d0cc5f7e5f0e (patch) (unidiff)
tree19ba9386d43c7d5834e50d051d498b6dec6a0d0b
parent37e199dcbb75c057b30a6cc96b1a8dabbf9036cd (diff)
downloadopie-c79db8d80c67bc66d49f8150ff85d0cc5f7e5f0e.zip
opie-c79db8d80c67bc66d49f8150ff85d0cc5f7e5f0e.tar.gz
opie-c79db8d80c67bc66d49f8150ff85d0cc5f7e5f0e.tar.bz2
reload applets
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/settings/netsystemtime/ntp.cpp5
-rw-r--r--noncore/settings/netsystemtime/settime.cpp2
2 files changed, 6 insertions, 1 deletions
diff --git a/noncore/settings/netsystemtime/ntp.cpp b/noncore/settings/netsystemtime/ntp.cpp
index 15dae93..6c5aaf5 100644
--- a/noncore/settings/netsystemtime/ntp.cpp
+++ b/noncore/settings/netsystemtime/ntp.cpp
@@ -109,97 +109,100 @@ void Ntp::slotRunNtp()
109 QString::number(_lookupDiff/60)+tr(" minutes elapsed since last loopup.")+ 109 QString::number(_lookupDiff/60)+tr(" minutes elapsed since last loopup.")+
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()" );
159 timeApplet << "";
160
158 Config cfg("ntp",Config::User); 161 Config cfg("ntp",Config::User);
159 cfg.setGroup("lookups"); 162 cfg.setGroup("lookups");
160 int lastLookup = cfg.readNumEntry("time",0); 163 int lastLookup = cfg.readNumEntry("time",0);
161 int lookupCount = cfg.readNumEntry("count",0); 164 int lookupCount = cfg.readNumEntry("count",0);
162 bool lastNtp = cfg.readBoolEntry("lastNtp",false); 165 bool lastNtp = cfg.readBoolEntry("lastNtp",false);
163 int time = TimeConversion::toUTC( QDateTime::currentDateTime() ); 166 int time = TimeConversion::toUTC( QDateTime::currentDateTime() );
164 cfg.writeEntry("time", time); 167 cfg.writeEntry("time", time);
165 168
166 float timeShift = getTimeShift(); 169 float timeShift = getTimeShift();
167 if (timeShift == 0.0) return; 170 if (timeShift == 0.0) return;
168 int secsSinceLast = time - lastLookup; 171 int secsSinceLast = time - lastLookup;
169 TextLabelNewTime->setText(QDateTime::currentDateTime().toString()); 172 TextLabelNewTime->setText(QDateTime::currentDateTime().toString());
170 TextLabelTimeShift->setText(QString::number(timeShift)+tr(" seconds")); 173 TextLabelTimeShift->setText(QString::number(timeShift)+tr(" seconds"));
171 if ( lastNtp && lastLookup > 0 && secsSinceLast > 60* SpinBoxMinLookupDelay->value()) 174 if ( lastNtp && lastLookup > 0 && secsSinceLast > 60* SpinBoxMinLookupDelay->value())
172 { 175 {
173 cfg.setGroup("lookup_"+QString::number(lookupCount)); 176 cfg.setGroup("lookup_"+QString::number(lookupCount));
174 lookupCount++; 177 lookupCount++;
175 _shiftPerSec = timeShift / secsSinceLast; 178 _shiftPerSec = timeShift / secsSinceLast;
176 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);
177 cfg.writeEntry("secsSinceLast",secsSinceLast); 180 cfg.writeEntry("secsSinceLast",secsSinceLast);
178 cfg.writeEntry("timeShift",QString::number(timeShift)); 181 cfg.writeEntry("timeShift",QString::number(timeShift));
179 cfg.setGroup("lookups"); 182 cfg.setGroup("lookups");
180 cfg.writeEntry("count",lookupCount); 183 cfg.writeEntry("count",lookupCount);
181 cfg.writeEntry("lastNtp",true); 184 cfg.writeEntry("lastNtp",true);
182 } 185 }
183} 186}
184 187
185 188
186float Ntp::getTimeShift() 189float Ntp::getTimeShift()
187{ 190{
188 QString _offset = "offset"; 191 QString _offset = "offset";
189 QString _sec = "sec"; 192 QString _sec = "sec";
190 QRegExp _reOffset = QRegExp(_offset); 193 QRegExp _reOffset = QRegExp(_offset);
191 QRegExp _reEndOffset = QRegExp(_sec); 194 QRegExp _reEndOffset = QRegExp(_sec);
192 int posOffset = _reOffset.match( _ntpOutput ); 195 int posOffset = _reOffset.match( _ntpOutput );
193 int posEndOffset = _reEndOffset.match( _ntpOutput, posOffset ); 196 int posEndOffset = _reEndOffset.match( _ntpOutput, posOffset );
194 posOffset += _offset.length() + 1; 197 posOffset += _offset.length() + 1;
195 QString diff = _ntpOutput.mid(posOffset, posEndOffset-posOffset-1); 198 QString diff = _ntpOutput.mid(posOffset, posEndOffset-posOffset-1);
196 qDebug("%s", _ntpOutput.latin1()); 199 qDebug("%s", _ntpOutput.latin1());
197 qDebug("diff = >%s<",diff.latin1()); 200 qDebug("diff = >%s<",diff.latin1());
198 return diff.toFloat(); 201 return diff.toFloat();
199} 202}
200 203
201void Ntp::readLookups() 204void Ntp::readLookups()
202{ 205{
203 Config cfg("ntp",Config::User); 206 Config cfg("ntp",Config::User);
204 cfg.setGroup("lookups"); 207 cfg.setGroup("lookups");
205 int lookupCount = cfg.readNumEntry("count",0); 208 int lookupCount = cfg.readNumEntry("count",0);
diff --git a/noncore/settings/netsystemtime/settime.cpp b/noncore/settings/netsystemtime/settime.cpp
index b0fcb74..e3b2ddd 100644
--- a/noncore/settings/netsystemtime/settime.cpp
+++ b/noncore/settings/netsystemtime/settime.cpp
@@ -223,96 +223,98 @@ void SetDateTime::writeSettings()
223 config.writeEntry( "ClockApplet", clockAppletCombo->currentItem() ); 223 config.writeEntry( "ClockApplet", clockAppletCombo->currentItem() );
224 224
225 Config lconfig("locale"); 225 Config lconfig("locale");
226 lconfig.setGroup( "Location" ); 226 lconfig.setGroup( "Location" );
227 lconfig.writeEntry( "Timezone", tz->currentZone() ); 227 lconfig.writeEntry( "Timezone", tz->currentZone() );
228 228
229} 229}
230 230
231void SetDateTime::commitTime() 231void SetDateTime::commitTime()
232{ 232{
233 Config cfg("ntp",Config::User); 233 Config cfg("ntp",Config::User);
234 cfg.setGroup("lookups"); 234 cfg.setGroup("lookups");
235 cfg.writeEntry("lastNtp",false); 235 cfg.writeEntry("lastNtp",false);
236 tz->setFocus(); 236 tz->setFocus();
237 // Need to process the QCOP event generated above before proceeding 237 // Need to process the QCOP event generated above before proceeding
238 qApp->processEvents(); 238 qApp->processEvents();
239 239
240 // before we progress further, set our TZ! 240 // before we progress further, set our TZ!
241 setenv( "TZ", tz->currentZone(), 1 ); 241 setenv( "TZ", tz->currentZone(), 1 );
242 // now set the time... 242 // now set the time...
243 QDateTime dt( dateButton->date(), timeButton->time() ); 243 QDateTime dt( dateButton->date(), timeButton->time() );
244 244
245 if ( dt.isValid() ) setTime(dt); 245 if ( dt.isValid() ) setTime(dt);
246} 246}
247 247
248void SetDateTime::setTime(QDateTime dt) 248void SetDateTime::setTime(QDateTime dt)
249{ 249{
250 // really turn off the screensaver before doing anything 250 // really turn off the screensaver before doing anything
251 { 251 {
252 // Needs to be encased in { } so that it deconstructs and sends 252 // Needs to be encased in { } so that it deconstructs and sends
253 QCopEnvelope disableScreenSaver( "QPE/System", "setScreenSaverIntervals(int,int,int)" ); 253 QCopEnvelope disableScreenSaver( "QPE/System", "setScreenSaverIntervals(int,int,int)" );
254 disableScreenSaver << 0 << 0 << 0; 254 disableScreenSaver << 0 << 0 << 0;
255 } 255 }
256 Config cfg("ntp",Config::User); 256 Config cfg("ntp",Config::User);
257 cfg.setGroup("correction"); 257 cfg.setGroup("correction");
258 int t = TimeConversion::toUTC(dt); 258 int t = TimeConversion::toUTC(dt);
259 struct timeval myTv; 259 struct timeval myTv;
260 myTv.tv_sec = t; 260 myTv.tv_sec = t;
261 cfg.writeEntry("time", t ); 261 cfg.writeEntry("time", t );
262 myTv.tv_usec = 0; 262 myTv.tv_usec = 0;
263 263
264 if ( myTv.tv_sec != -1 ) 264 if ( myTv.tv_sec != -1 )
265 ::settimeofday( &myTv, 0 ); 265 ::settimeofday( &myTv, 0 );
266 Global::writeHWClock(); 266 Global::writeHWClock();
267 // since time has changed quickly load in the datebookdb 267 // since time has changed quickly load in the datebookdb
268 // to allow the alarm server to get a better grip on itself 268 // to allow the alarm server to get a better grip on itself
269 // (example re-trigger alarms for when we travel back in time) 269 // (example re-trigger alarms for when we travel back in time)
270 DateBookDB db; 270 DateBookDB db;
271 QCopEnvelope timeApplet( "QPE/TaskBar", "reloadApplets()" );
272 timeApplet << "";
271 // Restore screensaver 273 // Restore screensaver
272 QCopEnvelope enableScreenSaver( "QPE/System", "setScreenSaverIntervals(int,int,int)" ); 274 QCopEnvelope enableScreenSaver( "QPE/System", "setScreenSaverIntervals(int,int,int)" );
273 enableScreenSaver << -1 << -1 << -1; 275 enableScreenSaver << -1 << -1 << -1;
274} 276}
275 277
276void SetDateTime::updateSystem(int i) 278void SetDateTime::updateSystem(int i)
277{ 279{
278 // really turn off the screensaver before doing anything 280 // really turn off the screensaver before doing anything
279 { 281 {
280 // Needs to be encased in { } so that it deconstructs and sends 282 // Needs to be encased in { } so that it deconstructs and sends
281 QCopEnvelope disableScreenSaver( "QPE/System", "setScreenSaverIntervals(int,int,int)" ); 283 QCopEnvelope disableScreenSaver( "QPE/System", "setScreenSaverIntervals(int,int,int)" );
282 disableScreenSaver << 0 << 0 << 0; 284 disableScreenSaver << 0 << 0 << 0;
283 } 285 }
284 qDebug("SetDateTime::updateSystem(int %i)",i); 286 qDebug("SetDateTime::updateSystem(int %i)",i);
285 writeSettings(); 287 writeSettings();
286 288
287 // set the timezone for everyone else... 289 // set the timezone for everyone else...
288 QCopEnvelope setTimeZone( "QPE/System", "timeChange(QString)" ); 290 QCopEnvelope setTimeZone( "QPE/System", "timeChange(QString)" );
289 setTimeZone << tz->currentZone(); 291 setTimeZone << tz->currentZone();
290 292
291 // AM/PM setting and notify time changed 293 // AM/PM setting and notify time changed
292 QCopEnvelope setClock( "QPE/System", "clockChange(bool)" ); 294 QCopEnvelope setClock( "QPE/System", "clockChange(bool)" );
293 setClock << ampmCombo->currentItem(); 295 setClock << ampmCombo->currentItem();
294 296
295 // Notify everyone what day we prefer to start the week on. 297 // Notify everyone what day we prefer to start the week on.
296 QCopEnvelope setWeek( "QPE/System", "weekChange(bool)" ); 298 QCopEnvelope setWeek( "QPE/System", "weekChange(bool)" );
297 setWeek << weekStartCombo->currentItem(); 299 setWeek << weekStartCombo->currentItem();
298 300
299 // Notify everyone what date format to use 301 // Notify everyone what date format to use
300 QCopEnvelope setDateFormat( "QPE/System", "setDateFormat(DateFormat)" ); 302 QCopEnvelope setDateFormat( "QPE/System", "setDateFormat(DateFormat)" );
301 setDateFormat << date_formats[dateFormatCombo->currentItem()]; 303 setDateFormat << date_formats[dateFormatCombo->currentItem()];
302 304
303 // Restore screensaver 305 // Restore screensaver
304 QCopEnvelope enableScreenSaver( "QPE/System", "setScreenSaverIntervals(int,int,int)" ); 306 QCopEnvelope enableScreenSaver( "QPE/System", "setScreenSaverIntervals(int,int,int)" );
305 enableScreenSaver << -1 << -1 << -1; 307 enableScreenSaver << -1 << -1 << -1;
306 // since time has changed quickly load in the datebookdb 308 // since time has changed quickly load in the datebookdb
307 // to allow the alarm server to get a better grip on itself 309 // to allow the alarm server to get a better grip on itself
308 // (example re-trigger alarms for when we travel back in time) 310 // (example re-trigger alarms for when we travel back in time)
309 DateBookDB db; 311 DateBookDB db;
310 312
311} 313}
312 314
313void SetDateTime::tzChange( const QString &tz ) 315void SetDateTime::tzChange( const QString &tz )
314{ 316{
315 // set the TZ get the time and leave gracefully... 317 // set the TZ get the time and leave gracefully...
316 QString strSave; 318 QString strSave;
317 strSave = getenv( "TZ" ); 319 strSave = getenv( "TZ" );
318 setenv( "TZ", tz, 1 ); 320 setenv( "TZ", tz, 1 );