5 files changed, 34 insertions, 13 deletions
diff --git a/noncore/settings/netsystemtime/ntp.cpp b/noncore/settings/netsystemtime/ntp.cpp index 083b50f..830c0c3 100644 --- a/noncore/settings/netsystemtime/ntp.cpp +++ b/noncore/settings/netsystemtime/ntp.cpp | |||
@@ -12,33 +12,32 @@ | |||
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 <sys/time.h> | 20 | #include <sys/time.h> |
21 | #include <time.h> | 21 | #include <time.h> |
22 | #include <stdlib.h> | 22 | #include <stdlib.h> |
23 | 23 | ||
24 | 24 | ||
25 | Ntp::Ntp( QWidget* parent, const char* name, WFlags fl ) | 25 | Ntp::Ntp( QWidget* parent, const char* name, WFlags fl ) |
26 | : SetDateTime( parent, name, fl ) | 26 | : SetDateTime( parent, name, fl ) |
27 | { | 27 | { |
28 | qDebug("%s", QPEApplication::qpeDir().latin1()); | ||
29 | Config ntpSrvs(QPEApplication::qpeDir()+"etc/ntpservers",Config::File); | 28 | Config ntpSrvs(QPEApplication::qpeDir()+"etc/ntpservers",Config::File); |
30 | ntpSrvs.setGroup("servers"); | 29 | ntpSrvs.setGroup("servers"); |
31 | int srvCount = ntpSrvs.readNumEntry("count", 0 ); | 30 | int srvCount = ntpSrvs.readNumEntry("count", 0 ); |
32 | for (int i = 0; i < srvCount; i++) | 31 | for (int i = 0; i < srvCount; i++) |
33 | { | 32 | { |
34 | ntpSrvs.setGroup(QString::number(i)); | 33 | ntpSrvs.setGroup(QString::number(i)); |
35 | ComboNtpSrv->insertItem( ntpSrvs.readEntry("name") ); | 34 | ComboNtpSrv->insertItem( ntpSrvs.readEntry("name") ); |
36 | } | 35 | } |
37 | if ( srvCount==0 ) ComboNtpSrv->insertItem(tr("time.fu-berlin.de")); | 36 | if ( srvCount==0 ) ComboNtpSrv->insertItem(tr("time.fu-berlin.de")); |
38 | 37 | ||
39 | Config cfg("ntp",Config::User); | 38 | Config cfg("ntp",Config::User); |
40 | cfg.setGroup("settings"); | 39 | cfg.setGroup("settings"); |
41 | SpinBoxMinLookupDelay->setValue( cfg.readNumEntry("minLookupDiff",41) ); | 40 | SpinBoxMinLookupDelay->setValue( cfg.readNumEntry("minLookupDiff",41) ); |
42 | SpinBoxNtpDelay->setValue( cfg.readNumEntry("ntpRefreshFreq",42) ); | 41 | SpinBoxNtpDelay->setValue( cfg.readNumEntry("ntpRefreshFreq",42) ); |
43 | ComboNtpSrv->setCurrentItem( cfg.readNumEntry("ntpServer", 0) ); | 42 | ComboNtpSrv->setCurrentItem( cfg.readNumEntry("ntpServer", 0) ); |
44 | 43 | ||
@@ -186,54 +185,55 @@ float Ntp::getTimeShift() | |||
186 | qDebug("diff = >%s<",diff.latin1()); | 185 | qDebug("diff = >%s<",diff.latin1()); |
187 | return diff.toFloat(); | 186 | return diff.toFloat(); |
188 | } | 187 | } |
189 | 188 | ||
190 | void Ntp::readLookups() | 189 | void Ntp::readLookups() |
191 | { | 190 | { |
192 | Config cfg("ntp",Config::User); | 191 | Config cfg("ntp",Config::User); |
193 | cfg.setGroup("lookups"); | 192 | cfg.setGroup("lookups"); |
194 | int lookupCount = cfg.readNumEntry("count",0); | 193 | int lookupCount = cfg.readNumEntry("count",0); |
195 | float last, shift, shiftPerSec; | 194 | float last, shift, shiftPerSec; |
196 | qDebug("lookupCount = %i",lookupCount); | 195 | qDebug("lookupCount = %i",lookupCount); |
197 | TableLookups->setNumCols( 3 ); | 196 | TableLookups->setNumCols( 3 ); |
198 | TableLookups->setNumRows( lookupCount); | 197 | TableLookups->setNumRows( lookupCount); |
199 | TableLookups->horizontalHeader()->setLabel(1,tr("last [h]")); | 198 | TableLookups->horizontalHeader()->setLabel(1,tr("last [h]")); |
200 | TableLookups->horizontalHeader()->setLabel(2,tr("offset [s]")); | 199 | TableLookups->horizontalHeader()->setLabel(2,tr("offset [s]")); |
201 | TableLookups->horizontalHeader()->setLabel(0,tr("shift [s/h]")); | 200 | TableLookups->horizontalHeader()->setLabel(0,tr("shift [s/h]")); |
202 | int cw = 50;//TableLookups->width()/4; | 201 | int cw = TableLookups->width()/4; |
203 | qDebug("column width %i",cw); | 202 | qDebug("column width %i",cw); |
203 | cw = 50; | ||
204 | TableLookups->setColumnWidth( 0, cw+30 ); | 204 | TableLookups->setColumnWidth( 0, cw+30 ); |
205 | TableLookups->setColumnWidth( 1, cw ); | 205 | TableLookups->setColumnWidth( 1, cw ); |
206 | TableLookups->setColumnWidth( 2, cw ); | 206 | TableLookups->setColumnWidth( 2, cw ); |
207 | TableLookups->sortColumn(0, false, true ); | 207 | TableLookups->sortColumn(0, false, true ); |
208 | // TableLookups->setSorting( true ); | 208 | // TableLookups->setSorting( true ); |
209 | for (int i=0; i < lookupCount; i++) | 209 | for (int i=0; i < lookupCount; i++) |
210 | { | 210 | { |
211 | cfg.setGroup("lookup_"+QString::number(i)); | 211 | cfg.setGroup("lookup_"+QString::number(i)); |
212 | last = cfg.readEntry("secsSinceLast",0).toFloat(); | 212 | last = cfg.readEntry("secsSinceLast",0).toFloat(); |
213 | shift = QString(cfg.readEntry("timeShift",0)).toFloat(); | 213 | shift = QString(cfg.readEntry("timeShift",0)).toFloat(); |
214 | // qDebug("%i last %f",i,last); | 214 | // qDebug("%i last %f",i,last); |
215 | // qDebug("%i shift %f",i,shift); | 215 | // qDebug("%i shift %f",i,shift); |
216 | shiftPerSec = shift / last; | 216 | shiftPerSec = shift / last; |
217 | _shiftPerSec += shiftPerSec; | 217 | _shiftPerSec += shiftPerSec; |
218 | TableLookups->setText( i,0,QString::number(shiftPerSec*60)); | 218 | TableLookups->setText( i,0,QString::number(shiftPerSec*60*60)); |
219 | TableLookups->setText( i,2,QString::number(shift)); | 219 | TableLookups->setText( i,2,QString::number(shift)); |
220 | TableLookups->setText( i,1,QString::number(last/60)); | 220 | TableLookups->setText( i,1,QString::number(last/(60*60))); |
221 | } | 221 | } |
222 | _shiftPerSec /= lookupCount+1; | 222 | _shiftPerSec /= lookupCount; |
223 | TextLabelShift->setText(QString::number(_shiftPerSec)+tr(" seconds")); | 223 | TextLabelShift->setText(QString::number(_shiftPerSec*60*60)+tr(" s/h")); |
224 | } | 224 | } |
225 | 225 | ||
226 | void Ntp::preditctTime() | 226 | void Ntp::preditctTime() |
227 | { | 227 | { |
228 | Config cfg("ntp",Config::User); | 228 | Config cfg("ntp",Config::User); |
229 | cfg.setGroup("lookups"); | 229 | cfg.setGroup("lookups"); |
230 | int lastTime = cfg.readNumEntry("time",0); | 230 | int lastTime = cfg.readNumEntry("time",0); |
231 | setenv( "TZ", tz->currentZone(), 1 ); | 231 | setenv( "TZ", tz->currentZone(), 1 ); |
232 | int now = TimeConversion::toUTC( QDateTime::currentDateTime() ); | 232 | int now = TimeConversion::toUTC( QDateTime::currentDateTime() ); |
233 | int corr = int((now - lastTime) * _shiftPerSec); | 233 | int corr = int((now - lastTime) * _shiftPerSec); |
234 | TextLabelEstimatedShift->setText(QString::number(corr)+tr(" seconds")); | 234 | TextLabelEstimatedShift->setText(QString::number(corr)+tr(" seconds")); |
235 | predictedTime = QDateTime::currentDateTime().addSecs(corr); | 235 | predictedTime = QDateTime::currentDateTime().addSecs(corr); |
236 | TextLabelPredTime->setText(predictedTime.toString()); | 236 | TextLabelPredTime->setText(predictedTime.toString()); |
237 | TextLabelMainPredTime->setText(tr("Predicted time:")+"<br><b>"+predictedTime.toString()+"</b>"); | 237 | TextLabelMainPredTime->setText(tr("Predicted time:")+"<br><b>"+predictedTime.toString()+"</b>"); |
238 | } | 238 | } |
239 | 239 | ||
diff --git a/noncore/settings/netsystemtime/opie-netsystemtime.control b/noncore/settings/netsystemtime/opie-netsystemtime.control index d3290e9..8fd7da5 100644 --- a/noncore/settings/netsystemtime/opie-netsystemtime.control +++ b/noncore/settings/netsystemtime/opie-netsystemtime.control | |||
@@ -1,11 +1,12 @@ | |||
1 | Packagename: opie-netsystemtime | ||
1 | Files: bin/netsystemtime apps/Settings/ntpdatetime.desktop etc/ntpservers | 2 | Files: bin/netsystemtime apps/Settings/ntpdatetime.desktop etc/ntpservers |
2 | Priority: optional | 3 | Priority: optional |
3 | Section: opie/settings | 4 | Section: opie/settings |
4 | Depends: ntpdate | 5 | Depends: ntpdate |
5 | Conflicts: opie-systemtime | 6 | Conflicts: opie-systemtime |
6 | Maintainer: Patrick S. Vogt <tille@handhelds.org> | 7 | Maintainer: Patrick S. Vogt <tille@handhelds.org> |
7 | Architecture: arm | 8 | Architecture: arm |
8 | Version: $QPE_VERSION-$SUB_VERSION | 9 | Version: $QPE_VERSION-$SUB_VERSION |
9 | Depends: opie-base ($QPE_VERSION), ntpdate | 10 | Depends: opie-base ($QPE_VERSION), ntpdate |
10 | Description: ntp ( Network Time Protocol) gui | 11 | Description: ntp (Network Time Protocol) gui |
11 | This utility syncs system time with a atomic timerserver via internet | 12 | This utility syncs system time with a atomic timerserver via internet |
diff --git a/noncore/settings/netsystemtime/opie-netsystemtime.postinst b/noncore/settings/netsystemtime/opie-netsystemtime.postinst new file mode 100644 index 0000000..233cd31 --- a/dev/null +++ b/noncore/settings/netsystemtime/opie-netsystemtime.postinst | |||
@@ -0,0 +1,7 @@ | |||
1 | #!/bin/sh -v | ||
2 | |||
3 | systime=`ipkg status | grep Package | grep -i systemtime | sed "s/Package://"` | ||
4 | ipkg remove $pack | ||
5 | |||
6 | cd $QPEDIR/bin/ | ||
7 | ln -s netsystemtime systemtime | ||
diff --git a/noncore/settings/netsystemtime/opie-netsystemtime.postrm b/noncore/settings/netsystemtime/opie-netsystemtime.postrm new file mode 100644 index 0000000..4b2ab7c --- a/dev/null +++ b/noncore/settings/netsystemtime/opie-netsystemtime.postrm | |||
@@ -0,0 +1,4 @@ | |||
1 | #!/bin/sh -v | ||
2 | |||
3 | cd $QPEDIR/bin/ | ||
4 | rm systemtime | ||
diff --git a/noncore/settings/netsystemtime/settime.cpp b/noncore/settings/netsystemtime/settime.cpp index 93543cd..e7e604f 100644 --- a/noncore/settings/netsystemtime/settime.cpp +++ b/noncore/settings/netsystemtime/settime.cpp | |||
@@ -218,70 +218,79 @@ void SetDateTime::writeSettings() | |||
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 | ||
231 | void SetDateTime::commitTime() | 231 | void SetDateTime::commitTime() |
232 | { | 232 | { |
233 | tz->setFocus(); | 233 | tz->setFocus(); |
234 | // really turn off the screensaver before doing anything | ||
235 | { | ||
236 | // Needs to be encased in { } so that it deconstructs and sends | ||
237 | QCopEnvelope disableScreenSaver( "QPE/System", "setScreenSaverIntervals(int,int,int)" ); | ||
238 | disableScreenSaver << 0 << 0 << 0; | ||
239 | } | ||
240 | // Need to process the QCOP event generated above before proceeding | 234 | // Need to process the QCOP event generated above before proceeding |
241 | qApp->processEvents(); | 235 | qApp->processEvents(); |
242 | 236 | ||
243 | // before we progress further, set our TZ! | 237 | // before we progress further, set our TZ! |
244 | setenv( "TZ", tz->currentZone(), 1 ); | 238 | setenv( "TZ", tz->currentZone(), 1 ); |
245 | // now set the time... | 239 | // now set the time... |
246 | QDateTime dt( dateButton->date(), timeButton->time() ); | 240 | QDateTime dt( dateButton->date(), timeButton->time() ); |
247 | 241 | ||
248 | if ( dt.isValid() ) setTime(dt); | 242 | if ( dt.isValid() ) setTime(dt); |
249 | } | 243 | } |
250 | 244 | ||
251 | void SetDateTime::setTime(QDateTime dt) | 245 | void SetDateTime::setTime(QDateTime dt) |
252 | { | 246 | { |
247 | // really turn off the screensaver before doing anything | ||
248 | { | ||
249 | // Needs to be encased in { } so that it deconstructs and sends | ||
250 | QCopEnvelope disableScreenSaver( "QPE/System", "setScreenSaverIntervals(int,int,int)" ); | ||
251 | disableScreenSaver << 0 << 0 << 0; | ||
252 | } | ||
253 | Config cfg("ntp",Config::User); | 253 | Config cfg("ntp",Config::User); |
254 | cfg.setGroup("correction"); | 254 | cfg.setGroup("correction"); |
255 | int t = TimeConversion::toUTC(dt); | 255 | int t = TimeConversion::toUTC(dt); |
256 | struct timeval myTv; | 256 | struct timeval myTv; |
257 | myTv.tv_sec = t; | 257 | myTv.tv_sec = t; |
258 | cfg.writeEntry("time", t ); | 258 | cfg.writeEntry("time", t ); |
259 | myTv.tv_usec = 0; | 259 | myTv.tv_usec = 0; |
260 | 260 | ||
261 | if ( myTv.tv_sec != -1 ) | 261 | if ( myTv.tv_sec != -1 ) |
262 | ::settimeofday( &myTv, 0 ); | 262 | ::settimeofday( &myTv, 0 ); |
263 | Global::writeHWClock(); | 263 | Global::writeHWClock(); |
264 | // since time has changed quickly load in the datebookdb | 264 | // since time has changed quickly load in the datebookdb |
265 | // to allow the alarm server to get a better grip on itself | 265 | // to allow the alarm server to get a better grip on itself |
266 | // (example re-trigger alarms for when we travel back in time) | 266 | // (example re-trigger alarms for when we travel back in time) |
267 | DateBookDB db; | 267 | DateBookDB db; |
268 | // Restore screensaver | ||
269 | QCopEnvelope enableScreenSaver( "QPE/System", "setScreenSaverIntervals(int,int,int)" ); | ||
270 | enableScreenSaver << -1 << -1 << -1; | ||
268 | } | 271 | } |
269 | 272 | ||
270 | void SetDateTime::updateSystem(int i) | 273 | void SetDateTime::updateSystem(int i) |
271 | { | 274 | { |
275 | // really turn off the screensaver before doing anything | ||
276 | { | ||
277 | // Needs to be encased in { } so that it deconstructs and sends | ||
278 | QCopEnvelope disableScreenSaver( "QPE/System", "setScreenSaverIntervals(int,int,int)" ); | ||
279 | disableScreenSaver << 0 << 0 << 0; | ||
280 | } | ||
272 | qDebug("SetDateTime::updateSystem(int %i)",i); | 281 | qDebug("SetDateTime::updateSystem(int %i)",i); |
273 | writeSettings(); | 282 | writeSettings(); |
274 | 283 | ||
275 | // set the timezone for everyone else... | 284 | // set the timezone for everyone else... |
276 | QCopEnvelope setTimeZone( "QPE/System", "timeChange(QString)" ); | 285 | QCopEnvelope setTimeZone( "QPE/System", "timeChange(QString)" ); |
277 | setTimeZone << tz->currentZone(); | 286 | setTimeZone << tz->currentZone(); |
278 | 287 | ||
279 | // AM/PM setting and notify time changed | 288 | // AM/PM setting and notify time changed |
280 | QCopEnvelope setClock( "QPE/System", "clockChange(bool)" ); | 289 | QCopEnvelope setClock( "QPE/System", "clockChange(bool)" ); |
281 | setClock << ampmCombo->currentItem(); | 290 | setClock << ampmCombo->currentItem(); |
282 | 291 | ||
283 | // Notify everyone what day we prefer to start the week on. | 292 | // Notify everyone what day we prefer to start the week on. |
284 | QCopEnvelope setWeek( "QPE/System", "weekChange(bool)" ); | 293 | QCopEnvelope setWeek( "QPE/System", "weekChange(bool)" ); |
285 | setWeek << weekStartCombo->currentItem(); | 294 | setWeek << weekStartCombo->currentItem(); |
286 | 295 | ||
287 | // Notify everyone what date format to use | 296 | // Notify everyone what date format to use |