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
@@ -93,129 +93,132 @@ bool Ntp::ntpDelayElapsed()
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 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);
206 float last, shift, shiftPerSec; 209 float last, shift, shiftPerSec;
207 qDebug("lookupCount = %i",lookupCount); 210 qDebug("lookupCount = %i",lookupCount);
208 TableLookups->setNumCols( 3 ); 211 TableLookups->setNumCols( 3 );
209 TableLookups->setNumRows( lookupCount); 212 TableLookups->setNumRows( lookupCount);
210 TableLookups->horizontalHeader()->setLabel(1,tr("last [h]")); 213 TableLookups->horizontalHeader()->setLabel(1,tr("last [h]"));
211 TableLookups->horizontalHeader()->setLabel(2,tr("offset [s]")); 214 TableLookups->horizontalHeader()->setLabel(2,tr("offset [s]"));
212 TableLookups->horizontalHeader()->setLabel(0,tr("shift [s/h]")); 215 TableLookups->horizontalHeader()->setLabel(0,tr("shift [s/h]"));
213 int cw = TableLookups->width()/4; 216 int cw = TableLookups->width()/4;
214 qDebug("column width %i",cw); 217 qDebug("column width %i",cw);
215 cw = 50; 218 cw = 50;
216 TableLookups->setColumnWidth( 0, cw+30 ); 219 TableLookups->setColumnWidth( 0, cw+30 );
217 TableLookups->setColumnWidth( 1, cw ); 220 TableLookups->setColumnWidth( 1, cw );
218 TableLookups->setColumnWidth( 2, cw ); 221 TableLookups->setColumnWidth( 2, cw );
219 TableLookups->sortColumn(0, false, true ); 222 TableLookups->sortColumn(0, false, true );
220 // TableLookups->setSorting( true ); 223 // TableLookups->setSorting( true );
221 _shiftPerSec = 0; 224 _shiftPerSec = 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
@@ -207,128 +207,130 @@ SetDateTime::~SetDateTime()
207{ 207{
208 writeSettings(); 208 writeSettings();
209 209
210} 210}
211 211
212void SetDateTime::writeSettings() 212void SetDateTime::writeSettings()
213{ 213{
214 Config config("qpe"); 214 Config config("qpe");
215 config.setGroup( "Time" ); 215 config.setGroup( "Time" );
216 config.writeEntry( "AMPM", ampmCombo->currentItem() ); 216 config.writeEntry( "AMPM", ampmCombo->currentItem() );
217 config.writeEntry( "MONDAY", weekStartCombo->currentItem() ); 217 config.writeEntry( "MONDAY", weekStartCombo->currentItem() );
218 config.setGroup( "Date" ); 218 config.setGroup( "Date" );
219 DateFormat df = date_formats[dateFormatCombo->currentItem()]; 219 DateFormat df = date_formats[dateFormatCombo->currentItem()];
220 config.writeEntry( "Separator", QString(df.separator())); 220 config.writeEntry( "Separator", QString(df.separator()));
221 config.writeEntry( "ShortOrder", df.shortOrder()); 221 config.writeEntry( "ShortOrder", df.shortOrder());
222 config.writeEntry( "LongOrder", df.longOrder()); 222 config.writeEntry( "LongOrder", df.longOrder());
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 );
319 321
320 QDate d = QDate::currentDate(); 322 QDate d = QDate::currentDate();
321 // reset the time. 323 // reset the time.
322 if ( !strSave.isNull() ) { 324 if ( !strSave.isNull() ) {
323 setenv( "TZ", strSave, 1 ); 325 setenv( "TZ", strSave, 1 );
324 } 326 }
325 dateButton->setDate( d ); 327 dateButton->setDate( d );
326 updateSystem(); 328 updateSystem();
327} 329}
328 330
329void SetDateTime::formatChanged(int i) 331void SetDateTime::formatChanged(int i)
330{ 332{
331 dateButton->setDateFormat(date_formats[i]); 333 dateButton->setDateFormat(date_formats[i]);
332} 334}
333 335
334static const int ValueAM = 0; 336static const int ValueAM = 0;