summaryrefslogtreecommitdiff
authortille <tille>2002-06-27 11:05:15 (UTC)
committer tille <tille>2002-06-27 11:05:15 (UTC)
commit4301065a4e43b0860774dca358a8027790a42f4f (patch) (unidiff)
tree52e8abb5e859636b6b651727fb1dcf94350ba158
parentf2cd92301181f3bc895b0d1701183e4da7b52812 (diff)
downloadopie-4301065a4e43b0860774dca358a8027790a42f4f.zip
opie-4301065a4e43b0860774dca358a8027790a42f4f.tar.gz
opie-4301065a4e43b0860774dca358a8027790a42f4f.tar.bz2
if postinst works, clicking on clockapplet should work too
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/settings/netsystemtime/ntp.cpp12
-rw-r--r--noncore/settings/netsystemtime/opie-netsystemtime.control3
-rw-r--r--noncore/settings/netsystemtime/opie-netsystemtime.postinst7
-rw-r--r--noncore/settings/netsystemtime/opie-netsystemtime.postrm4
-rw-r--r--noncore/settings/netsystemtime/settime.cpp21
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
@@ -1,92 +1,91 @@
1#include "ntp.h" 1#include "ntp.h"
2#include <qpushbutton.h> 2#include <qpushbutton.h>
3#include <qregexp.h> 3#include <qregexp.h>
4#include <qtimer.h> 4#include <qtimer.h>
5#include <qtable.h> 5#include <qtable.h>
6#include <qlabel.h> 6#include <qlabel.h>
7#include <qsocket.h> 7#include <qsocket.h>
8#include <qlineedit.h> 8#include <qlineedit.h>
9#include <qspinbox.h> 9#include <qspinbox.h>
10#include <qmessagebox.h> 10#include <qmessagebox.h>
11#include <qmultilineedit.h> 11#include <qmultilineedit.h>
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
25Ntp::Ntp( QWidget* parent, const char* name, WFlags fl ) 25Ntp::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
45 ntpTimer = new QTimer(this); 44 ntpTimer = new QTimer(this);
46 45
47 ntpProcess = new OProcess( ); 46 ntpProcess = new OProcess( );
48 connect( SpinBoxNtpDelay, SIGNAL( valueChanged(int) ), 47 connect( SpinBoxNtpDelay, SIGNAL( valueChanged(int) ),
49 SLOT(slotNtpDelayChanged(int)) ); 48 SLOT(slotNtpDelayChanged(int)) );
50 49
51 ntpSock = new QSocket( this ); 50 ntpSock = new QSocket( this );
52 connect( ntpSock, SIGNAL( error(int) ), 51 connect( ntpSock, SIGNAL( error(int) ),
53 SLOT(slotCheckNtp(int)) ); 52 SLOT(slotCheckNtp(int)) );
54 slotProbeNtpServer(); 53 slotProbeNtpServer();
55 54
56 connect ( ntpProcess, SIGNAL(receivedStdout(OProcess*,char*,int)), 55 connect ( ntpProcess, SIGNAL(receivedStdout(OProcess*,char*,int)),
57 this, SLOT(getNtpOutput(OProcess*,char*,int))); 56 this, SLOT(getNtpOutput(OProcess*,char*,int)));
58 connect ( ntpProcess, SIGNAL(processExited(OProcess*)), 57 connect ( ntpProcess, SIGNAL(processExited(OProcess*)),
59 this, SLOT(ntpFinished(OProcess*))); 58 this, SLOT(ntpFinished(OProcess*)));
60 connect(runNtp, SIGNAL(clicked()), this, SLOT(slotRunNtp())); 59 connect(runNtp, SIGNAL(clicked()), this, SLOT(slotRunNtp()));
61 connect(PushButtonPredict, SIGNAL(clicked()), this, SLOT(preditctTime())); 60 connect(PushButtonPredict, SIGNAL(clicked()), this, SLOT(preditctTime()));
62 connect(PushButtonSetPredTime, SIGNAL(clicked()), this, SLOT(setPredictTime())); 61 connect(PushButtonSetPredTime, SIGNAL(clicked()), this, SLOT(setPredictTime()));
63 slotCheckNtp(-1); 62 slotCheckNtp(-1);
64 readLookups(); 63 readLookups();
65} 64}
66 65
67Ntp::~Ntp() 66Ntp::~Ntp()
68{ 67{
69 delete ntpProcess; 68 delete ntpProcess;
70 Config ntpSrvs("/etc/ntpservers",Config::File); 69 Config ntpSrvs("/etc/ntpservers",Config::File);
71 ntpSrvs.setGroup("servers"); 70 ntpSrvs.setGroup("servers");
72 int srvCount = ComboNtpSrv->count(); 71 int srvCount = ComboNtpSrv->count();
73 ntpSrvs.writeEntry("count", srvCount); 72 ntpSrvs.writeEntry("count", srvCount);
74 for (int i = 0; i < srvCount; i++) 73 for (int i = 0; i < srvCount; i++)
75 { 74 {
76 ntpSrvs.setGroup(QString::number(i)); 75 ntpSrvs.setGroup(QString::number(i));
77 ntpSrvs.writeEntry( "name", ComboNtpSrv->text(i) ); 76 ntpSrvs.writeEntry( "name", ComboNtpSrv->text(i) );
78 } 77 }
79 Config cfg("ntp",Config::User); 78 Config cfg("ntp",Config::User);
80 cfg.setGroup("settings"); 79 cfg.setGroup("settings");
81 cfg.writeEntry("ntpServer", ComboNtpSrv->currentItem()); 80 cfg.writeEntry("ntpServer", ComboNtpSrv->currentItem());
82 cfg.writeEntry( "minLookupDiff", SpinBoxMinLookupDelay->value() ); 81 cfg.writeEntry( "minLookupDiff", SpinBoxMinLookupDelay->value() );
83 cfg.writeEntry( "ntpRefreshFreq", SpinBoxNtpDelay->value() ); 82 cfg.writeEntry( "ntpRefreshFreq", SpinBoxNtpDelay->value() );
84} 83}
85 84
86bool Ntp::ntpDelayElapsed() 85bool Ntp::ntpDelayElapsed()
87{ 86{
88 Config cfg("ntp",Config::User); 87 Config cfg("ntp",Config::User);
89 cfg.setGroup("lookups"); 88 cfg.setGroup("lookups");
90 _lookupDiff = TimeConversion::toUTC(QDateTime::currentDateTime()) - cfg.readNumEntry("time",0); 89 _lookupDiff = TimeConversion::toUTC(QDateTime::currentDateTime()) - cfg.readNumEntry("time",0);
91 return (_lookupDiff - (SpinBoxNtpDelay->value()*60)) > -60; 90 return (_lookupDiff - (SpinBoxNtpDelay->value()*60)) > -60;
92} 91}
@@ -138,150 +137,151 @@ void Ntp::getNtpOutput(OProcess *proc, char *buffer, int buflen)
138} 137}
139 138
140void Ntp::ntpFinished(OProcess *p) 139void Ntp::ntpFinished(OProcess *p)
141{ 140{
142 qDebug("p->exitStatus() %i",p->exitStatus()); 141 qDebug("p->exitStatus() %i",p->exitStatus());
143 if (p->exitStatus()!=0 || !p->normalExit()) 142 if (p->exitStatus()!=0 || !p->normalExit())
144 { 143 {
145 slotProbeNtpServer(); 144 slotProbeNtpServer();
146 return; 145 return;
147 } 146 }
148 Config cfg("ntp",Config::User); 147 Config cfg("ntp",Config::User);
149 cfg.setGroup("lookups"); 148 cfg.setGroup("lookups");
150 int lastLookup = cfg.readNumEntry("time",0); 149 int lastLookup = cfg.readNumEntry("time",0);
151 int lookupCount = cfg.readNumEntry("count",0); 150 int lookupCount = cfg.readNumEntry("count",0);
152 int time = TimeConversion::toUTC( QDateTime::currentDateTime() ); 151 int time = TimeConversion::toUTC( QDateTime::currentDateTime() );
153 cfg.writeEntry("time", time); 152 cfg.writeEntry("time", time);
154 cfg.setGroup("correction"); 153 cfg.setGroup("correction");
155 cfg.writeEntry("time", time); 154 cfg.writeEntry("time", time);
156 155
157 float timeShift = getTimeShift(); 156 float timeShift = getTimeShift();
158 if (timeShift == 0.0) return; 157 if (timeShift == 0.0) return;
159 int secsSinceLast = time - lastLookup; 158 int secsSinceLast = time - lastLookup;
160 TextLabelNewTime->setText(QDateTime::currentDateTime().toString()); 159 TextLabelNewTime->setText(QDateTime::currentDateTime().toString());
161 TextLabelTimeShift->setText(QString::number(timeShift)+tr(" seconds")); 160 TextLabelTimeShift->setText(QString::number(timeShift)+tr(" seconds"));
162 if ( lastLookup > 0 && secsSinceLast > 60* SpinBoxMinLookupDelay->value()) 161 if ( lastLookup > 0 && secsSinceLast > 60* SpinBoxMinLookupDelay->value())
163 { 162 {
164 lookupCount++; 163 lookupCount++;
165 cfg.writeEntry("count",lookupCount); 164 cfg.writeEntry("count",lookupCount);
166 cfg.setGroup("lookup_"+QString::number(lookupCount)); 165 cfg.setGroup("lookup_"+QString::number(lookupCount));
167 _shiftPerSec = timeShift / secsSinceLast; 166 _shiftPerSec = timeShift / secsSinceLast;
168 qDebug("secs since last lookup %i", secsSinceLast);qDebug("timeshift since last lookup %f", timeShift);qDebug("timeshift since per sec %f", _shiftPerSec); 167 qDebug("secs since last lookup %i", secsSinceLast);qDebug("timeshift since last lookup %f", timeShift);qDebug("timeshift since per sec %f", _shiftPerSec);
169 cfg.writeEntry("secsSinceLast",secsSinceLast); 168 cfg.writeEntry("secsSinceLast",secsSinceLast);
170 cfg.writeEntry("timeShift",QString::number(timeShift)); 169 cfg.writeEntry("timeShift",QString::number(timeShift));
171 } 170 }
172} 171}
173 172
174 173
175float Ntp::getTimeShift() 174float Ntp::getTimeShift()
176{ 175{
177 QString _offset = "offset"; 176 QString _offset = "offset";
178 QString _sec = "sec"; 177 QString _sec = "sec";
179 QRegExp _reOffset = QRegExp(_offset); 178 QRegExp _reOffset = QRegExp(_offset);
180 QRegExp _reEndOffset = QRegExp(_sec); 179 QRegExp _reEndOffset = QRegExp(_sec);
181 int posOffset = _reOffset.match( _ntpOutput ); 180 int posOffset = _reOffset.match( _ntpOutput );
182 int posEndOffset = _reEndOffset.match( _ntpOutput, posOffset ); 181 int posEndOffset = _reEndOffset.match( _ntpOutput, posOffset );
183 posOffset += _offset.length() + 1; 182 posOffset += _offset.length() + 1;
184 QString diff = _ntpOutput.mid(posOffset, posEndOffset-posOffset-1); 183 QString diff = _ntpOutput.mid(posOffset, posEndOffset-posOffset-1);
185 qDebug("%s", _ntpOutput.latin1()); 184 qDebug("%s", _ntpOutput.latin1());
186 qDebug("diff = >%s<",diff.latin1()); 185 qDebug("diff = >%s<",diff.latin1());
187 return diff.toFloat(); 186 return diff.toFloat();
188} 187}
189 188
190void Ntp::readLookups() 189void 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
226void Ntp::preditctTime() 226void 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
240void Ntp::setPredictTime() 240void Ntp::setPredictTime()
241{ 241{
242 preditctTime(); 242 preditctTime();
243 setTime( predictedTime ); 243 setTime( predictedTime );
244} 244}
245 245
246void Ntp::slotCheckNtp(int i) 246void Ntp::slotCheckNtp(int i)
247{ 247{
248 if (i == 0) 248 if (i == 0)
249 { 249 {
250 TextLabelMainPredTime->hide(); 250 TextLabelMainPredTime->hide();
251 ButtonSetTime->setText( tr("Get time from network") ); 251 ButtonSetTime->setText( tr("Get time from network") );
252 connect( ButtonSetTime, SIGNAL(clicked()), SLOT(slotRunNtp()) ); 252 connect( ButtonSetTime, SIGNAL(clicked()), SLOT(slotRunNtp()) );
253 if ( ntpDelayElapsed() ) 253 if ( ntpDelayElapsed() )
254 { 254 {
255 slotRunNtp(); 255 slotRunNtp();
256 disconnect(ntpTimer, SIGNAL( timeout() ), this, SLOT(slotProbeNtpServer()) ); 256 disconnect(ntpTimer, SIGNAL( timeout() ), this, SLOT(slotProbeNtpServer()) );
257 connect(ntpTimer, SIGNAL( timeout() ), SLOT(slotRunNtp()) ); 257 connect(ntpTimer, SIGNAL( timeout() ), SLOT(slotRunNtp()) );
258 }else{ 258 }else{
259 disconnect(ntpTimer, SIGNAL( timeout() ), this, SLOT(slotRunNtp()) ); 259 disconnect(ntpTimer, SIGNAL( timeout() ), this, SLOT(slotRunNtp()) );
260 connect(ntpTimer, SIGNAL( timeout() ), SLOT(slotProbeNtpServer()) ); 260 connect(ntpTimer, SIGNAL( timeout() ), SLOT(slotProbeNtpServer()) );
261 } 261 }
262 }else{ 262 }else{
263 preditctTime(); 263 preditctTime();
264 ButtonSetTime->setText( tr("Set predicted time") ); 264 ButtonSetTime->setText( tr("Set predicted time") );
265 if (i>0)ntpOutPut(tr("Could not connect to server ")+getNtpServer()); 265 if (i>0)ntpOutPut(tr("Could not connect to server ")+getNtpServer());
266 connect( ButtonSetTime, SIGNAL(clicked()), SLOT(setPredictTime()) ); 266 connect( ButtonSetTime, SIGNAL(clicked()), SLOT(setPredictTime()) );
267 connect( ntpTimer, SIGNAL( timeout() ), SLOT(slotProbeNtpServer()) ); 267 connect( ntpTimer, SIGNAL( timeout() ), SLOT(slotProbeNtpServer()) );
268 } 268 }
269} 269}
270 270
271void Ntp::slotProbeNtpServer() 271void Ntp::slotProbeNtpServer()
272{ 272{
273 qDebug("Ntp::slotProbeNtpServer()"); 273 qDebug("Ntp::slotProbeNtpServer()");
274 ntpSock->connectToHost( getNtpServer() ,123); 274 ntpSock->connectToHost( getNtpServer() ,123);
275} 275}
276 276
277void Ntp::slotNtpDelayChanged(int delay) 277void Ntp::slotNtpDelayChanged(int delay)
278{ 278{
279 ntpTimer->changeInterval( delay*1000*60 ); 279 ntpTimer->changeInterval( delay*1000*60 );
280} 280}
281 281
282void Ntp::ntpOutPut(QString out) 282void Ntp::ntpOutPut(QString out)
283{ 283{
284 MultiLineEditntpOutPut->append(out); 284 MultiLineEditntpOutPut->append(out);
285 MultiLineEditntpOutPut->setCursorPosition(MultiLineEditntpOutPut->numLines() + 1,0,FALSE); 285 MultiLineEditntpOutPut->setCursorPosition(MultiLineEditntpOutPut->numLines() + 1,0,FALSE);
286} 286}
287 287
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 @@
1Packagename: opie-netsystemtime
1Files: bin/netsystemtime apps/Settings/ntpdatetime.desktop etc/ntpservers 2Files: bin/netsystemtime apps/Settings/ntpdatetime.desktop etc/ntpservers
2Priority: optional 3Priority: optional
3Section: opie/settings 4Section: opie/settings
4Depends: ntpdate 5Depends: ntpdate
5Conflicts: opie-systemtime 6Conflicts: opie-systemtime
6Maintainer: Patrick S. Vogt <tille@handhelds.org> 7Maintainer: Patrick S. Vogt <tille@handhelds.org>
7Architecture: arm 8Architecture: arm
8Version: $QPE_VERSION-$SUB_VERSION 9Version: $QPE_VERSION-$SUB_VERSION
9Depends: opie-base ($QPE_VERSION), ntpdate 10Depends: opie-base ($QPE_VERSION), ntpdate
10Description: ntp ( Network Time Protocol) gui 11Description: ntp (Network Time Protocol) gui
11This utility syncs system time with a atomic timerserver via internet 12This 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
3systime=`ipkg status | grep Package | grep -i systemtime | sed "s/Package://"`
4ipkg remove $pack
5
6cd $QPEDIR/bin/
7ln -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
3cd $QPEDIR/bin/
4rm 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
@@ -170,166 +170,175 @@ SetDateTime::SetDateTime(QWidget *parent, const char *name, WFlags f )
170 connect( dateFormatCombo, SIGNAL( activated(int)), 170 connect( dateFormatCombo, SIGNAL( activated(int)),
171 SLOT(formatChanged(int))); 171 SLOT(formatChanged(int)));
172 172
173 QHBoxLayout *hb4 = new QHBoxLayout( vb ); 173 QHBoxLayout *hb4 = new QHBoxLayout( vb );
174 l = new QLabel( tr("Applet format" ), FrameSystemTime ); 174 l = new QLabel( tr("Applet format" ), FrameSystemTime );
175 hb4->addWidget( l, 1 ); 175 hb4->addWidget( l, 1 );
176 176
177 clockAppletCombo = new QComboBox( FrameSystemTime ); 177 clockAppletCombo = new QComboBox( FrameSystemTime );
178 clockAppletCombo->insertItem( tr("hh:mm"), 0 ); 178 clockAppletCombo->insertItem( tr("hh:mm"), 0 );
179 clockAppletCombo->insertItem( tr("D/M hh:mm"), 1 ); 179 clockAppletCombo->insertItem( tr("D/M hh:mm"), 1 );
180 clockAppletCombo->insertItem( tr("M/D hh:mm"), 2 ); 180 clockAppletCombo->insertItem( tr("M/D hh:mm"), 2 );
181 181
182 hb4->addWidget( clockAppletCombo, 2 ); 182 hb4->addWidget( clockAppletCombo, 2 );
183 int clockApplet = config.readNumEntry("ClockApplet",0); 183 int clockApplet = config.readNumEntry("ClockApplet",0);
184 clockAppletCombo->setCurrentItem( clockApplet ); 184 clockAppletCombo->setCurrentItem( clockApplet );
185 185
186 vb->addStretch( 0 ); 186 vb->addStretch( 0 );
187 187
188 QObject::connect( PushButtonSetManualTime, SIGNAL(clicked()), 188 QObject::connect( PushButtonSetManualTime, SIGNAL(clicked()),
189 this, SLOT(commitTime())); 189 this, SLOT(commitTime()));
190 190
191 QObject::connect( tz, SIGNAL( signalNewTz( const QString& ) ), 191 QObject::connect( tz, SIGNAL( signalNewTz( const QString& ) ),
192 timeButton, SLOT( slotTzChange( const QString& ) ) ); 192 timeButton, SLOT( slotTzChange( const QString& ) ) );
193 QObject::connect( tz, SIGNAL( signalNewTz( const QString& ) ), 193 QObject::connect( tz, SIGNAL( signalNewTz( const QString& ) ),
194 SLOT( tzChange( const QString& ) ) ); 194 SLOT( tzChange( const QString& ) ) );
195 195
196 QObject::connect( weekStartCombo, SIGNAL( activated ( int )), 196 QObject::connect( weekStartCombo, SIGNAL( activated ( int )),
197 SLOT(updateSystem(int ) )); 197 SLOT(updateSystem(int ) ));
198 QObject::connect( ampmCombo, SIGNAL( activated ( int )), 198 QObject::connect( ampmCombo, SIGNAL( activated ( int )),
199 SLOT(updateSystem(int ) )); 199 SLOT(updateSystem(int ) ));
200 QObject::connect( dateFormatCombo, SIGNAL( activated ( int )), 200 QObject::connect( dateFormatCombo, SIGNAL( activated ( int )),
201 SLOT(updateSystem(int ) )); 201 SLOT(updateSystem(int ) ));
202 QObject::connect( clockAppletCombo, SIGNAL( activated ( int )), 202 QObject::connect( clockAppletCombo, SIGNAL( activated ( int )),
203 SLOT(updateSystem(int ) )); 203 SLOT(updateSystem(int ) ));
204} 204}
205 205
206SetDateTime::~SetDateTime() 206SetDateTime::~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 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
251void SetDateTime::setTime(QDateTime dt) 245void 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
270void SetDateTime::updateSystem(int i) 273void 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
288 QCopEnvelope setDateFormat( "QPE/System", "setDateFormat(DateFormat)" ); 297 QCopEnvelope setDateFormat( "QPE/System", "setDateFormat(DateFormat)" );
289 setDateFormat << date_formats[dateFormatCombo->currentItem()]; 298 setDateFormat << date_formats[dateFormatCombo->currentItem()];
290 299
291 // Restore screensaver 300 // Restore screensaver
292 QCopEnvelope enableScreenSaver( "QPE/System", "setScreenSaverIntervals(int,int,int)" ); 301 QCopEnvelope enableScreenSaver( "QPE/System", "setScreenSaverIntervals(int,int,int)" );
293 enableScreenSaver << -1 << -1 << -1; 302 enableScreenSaver << -1 << -1 << -1;
294 // since time has changed quickly load in the datebookdb 303 // since time has changed quickly load in the datebookdb
295 // to allow the alarm server to get a better grip on itself 304 // to allow the alarm server to get a better grip on itself
296 // (example re-trigger alarms for when we travel back in time) 305 // (example re-trigger alarms for when we travel back in time)
297 DateBookDB db; 306 DateBookDB db;
298 307
299} 308}
300 309
301void SetDateTime::tzChange( const QString &tz ) 310void SetDateTime::tzChange( const QString &tz )
302{ 311{
303 // set the TZ get the time and leave gracefully... 312 // set the TZ get the time and leave gracefully...
304 QString strSave; 313 QString strSave;
305 strSave = getenv( "TZ" ); 314 strSave = getenv( "TZ" );
306 setenv( "TZ", tz, 1 ); 315 setenv( "TZ", tz, 1 );
307 316
308 QDate d = QDate::currentDate(); 317 QDate d = QDate::currentDate();
309 // reset the time. 318 // reset the time.
310 if ( !strSave.isNull() ) { 319 if ( !strSave.isNull() ) {
311 setenv( "TZ", strSave, 1 ); 320 setenv( "TZ", strSave, 1 );
312 } 321 }
313 dateButton->setDate( d ); 322 dateButton->setDate( d );
314 updateSystem(); 323 updateSystem();
315} 324}
316 325
317void SetDateTime::formatChanged(int i) 326void SetDateTime::formatChanged(int i)
318{ 327{
319 dateButton->setDateFormat(date_formats[i]); 328 dateButton->setDateFormat(date_formats[i]);
320} 329}
321 330
322static const int ValueAM = 0; 331static const int ValueAM = 0;
323static const int ValuePM = 1; 332static const int ValuePM = 1;
324 333
325 334
326 335
327SetTime::SetTime( QWidget *parent, const char *name ) 336SetTime::SetTime( QWidget *parent, const char *name )
328 : QWidget( parent, name ) 337 : QWidget( parent, name )
329{ 338{
330 use12hourTime = FALSE; 339 use12hourTime = FALSE;
331 340
332 QTime currTime = QTime::currentTime(); 341 QTime currTime = QTime::currentTime();
333 hour = currTime.hour(); 342 hour = currTime.hour();
334 minute = currTime.minute(); 343 minute = currTime.minute();
335 344