summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/settings/netsystemtime/main.cpp6
-rw-r--r--noncore/settings/netsystemtime/ntp.cpp32
-rw-r--r--noncore/settings/netsystemtime/ntp.h9
-rw-r--r--noncore/settings/netsystemtime/opie-netsystemtime.control2
-rw-r--r--noncore/settings/netsystemtime/opie-netsystemtime.postinst7
-rw-r--r--noncore/settings/netsystemtime/opie-netsystemtime.postrm4
6 files changed, 42 insertions, 18 deletions
diff --git a/noncore/settings/netsystemtime/main.cpp b/noncore/settings/netsystemtime/main.cpp
index 5b01408..c6d5f9a 100644
--- a/noncore/settings/netsystemtime/main.cpp
+++ b/noncore/settings/netsystemtime/main.cpp
@@ -1,14 +1,16 @@
1//#include "settime.h" 1#include <stdio.h>
2#include "ntp.h" 2#include "ntp.h"
3#include <qpe/qpeapplication.h> 3#include <qpe/qpeapplication.h>
4 4
5int main( int argc, char ** argv ) 5int main( int argc, char ** argv )
6{ 6{
7 printf("This is netsystemtime\n");
8 printf("$Id$\n");
9
7 QPEApplication a( argc, argv ); 10 QPEApplication a( argc, argv );
8 11
9 // SetDateTime mw;
10 Ntp mw; 12 Ntp mw;
11 a.showMainWidget( &mw ); 13 a.showMainWidget( &mw );
12 14
13 return a.exec(); 15 return a.exec();
14} 16}
diff --git a/noncore/settings/netsystemtime/ntp.cpp b/noncore/settings/netsystemtime/ntp.cpp
index 0b13b6d..2b779fa 100644
--- a/noncore/settings/netsystemtime/ntp.cpp
+++ b/noncore/settings/netsystemtime/ntp.cpp
@@ -1,297 +1,325 @@
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 <qpe/datebookdb.h> 20#include <qpe/datebookdb.h>
21#include <qpe/qcopenvelope_qws.h>
21#include <sys/time.h> 22#include <sys/time.h>
22#include <time.h> 23#include <time.h>
23#include <stdlib.h> 24#include <stdlib.h>
24 25
25 26
26Ntp::Ntp( QWidget* parent, const char* name, WFlags fl ) 27Ntp::Ntp( QWidget* parent, const char* name, WFlags fl )
27 : SetDateTime( parent, name, fl ) 28 : SetDateTime( parent, name, fl )
28{ 29{
29 Config ntpSrvs(QPEApplication::qpeDir()+"etc/ntpservers",Config::File); 30 Config ntpSrvs(QPEApplication::qpeDir()+"etc/ntpservers",Config::File);
30 ntpSrvs.setGroup("servers"); 31 ntpSrvs.setGroup("servers");
31 int srvCount = ntpSrvs.readNumEntry("count", 0 ); 32 int srvCount = ntpSrvs.readNumEntry("count", 0 );
32 for (int i = 0; i < srvCount; i++) 33 for (int i = 0; i < srvCount; i++)
33 { 34 {
34 ntpSrvs.setGroup(QString::number(i)); 35 ntpSrvs.setGroup(QString::number(i));
35 ComboNtpSrv->insertItem( ntpSrvs.readEntry("name") ); 36 ComboNtpSrv->insertItem( ntpSrvs.readEntry("name") );
36 } 37 }
37 if ( srvCount==0 ) ComboNtpSrv->insertItem(tr("time.fu-berlin.de")); 38 if ( srvCount==0 ) ComboNtpSrv->insertItem(tr("time.fu-berlin.de"));
38 39
39 Config cfg("ntp",Config::User); 40 Config cfg("ntp",Config::User);
40 cfg.setGroup("settings"); 41 cfg.setGroup("settings");
41 SpinBoxMinLookupDelay->setValue( cfg.readNumEntry("minLookupDiff",41) ); 42 SpinBoxMinLookupDelay->setValue( cfg.readNumEntry("minLookupDiff",41) );
42 SpinBoxNtpDelay->setValue( cfg.readNumEntry("ntpRefreshFreq",42) ); 43 SpinBoxNtpDelay->setValue( cfg.readNumEntry("ntpRefreshFreq",42) );
43 ComboNtpSrv->setCurrentItem( cfg.readNumEntry("ntpServer", 0) ); 44 ComboNtpSrv->setCurrentItem( cfg.readNumEntry("ntpServer", 0) );
44 45
46 makeChannel();
47
45 ntpTimer = new QTimer(this); 48 ntpTimer = new QTimer(this);
46 49
47 ntpProcess = new OProcess( ); 50 ntpProcess = new OProcess( );
48 connect( SpinBoxNtpDelay, SIGNAL( valueChanged(int) ), 51 connect( SpinBoxNtpDelay, SIGNAL( valueChanged(int) ),
49 SLOT(slotNtpDelayChanged(int)) ); 52 SLOT(slotNtpDelayChanged(int)) );
50 53
51 ntpSock = new QSocket( this ); 54 ntpSock = new QSocket( this );
52 connect( ntpSock, SIGNAL( error(int) ), 55 connect( ntpSock, SIGNAL( error(int) ),
53 SLOT(slotCheckNtp(int)) ); 56 SLOT(slotCheckNtp(int)) );
54 slotProbeNtpServer(); 57 slotProbeNtpServer();
55 58
56 connect ( ntpProcess, SIGNAL(receivedStdout(OProcess*,char*,int)), 59 connect ( ntpProcess, SIGNAL(receivedStdout(OProcess*,char*,int)),
57 this, SLOT(getNtpOutput(OProcess*,char*,int))); 60 this, SLOT(getNtpOutput(OProcess*,char*,int)));
58 connect ( ntpProcess, SIGNAL(processExited(OProcess*)), 61 connect ( ntpProcess, SIGNAL(processExited(OProcess*)),
59 this, SLOT(ntpFinished(OProcess*))); 62 this, SLOT(ntpFinished(OProcess*)));
60 connect(runNtp, SIGNAL(clicked()), this, SLOT(slotRunNtp())); 63 connect(runNtp, SIGNAL(clicked()), this, SLOT(slotRunNtp()));
61 connect(PushButtonPredict, SIGNAL(clicked()), this, SLOT(preditctTime())); 64 connect(PushButtonPredict, SIGNAL(clicked()), this, SLOT(preditctTime()));
62 connect(PushButtonSetPredTime, SIGNAL(clicked()), this, SLOT(setPredictTime())); 65 connect(PushButtonSetPredTime, SIGNAL(clicked()), this, SLOT(setPredictTime()));
63 slotCheckNtp(-1); 66 slotCheckNtp(-1);
64 readLookups(); 67 readLookups();
65} 68}
66 69
67Ntp::~Ntp() 70Ntp::~Ntp()
68{ 71{
69 delete ntpProcess; 72 delete ntpProcess;
70 Config ntpSrvs("/etc/ntpservers",Config::File); 73 Config ntpSrvs("/etc/ntpservers",Config::File);
71 ntpSrvs.setGroup("servers"); 74 ntpSrvs.setGroup("servers");
72 int srvCount = ComboNtpSrv->count(); 75 int srvCount = ComboNtpSrv->count();
73 ntpSrvs.writeEntry("count", srvCount); 76 ntpSrvs.writeEntry("count", srvCount);
74 for (int i = 0; i < srvCount; i++) 77 for (int i = 0; i < srvCount; i++)
75 { 78 {
76 ntpSrvs.setGroup(QString::number(i)); 79 ntpSrvs.setGroup(QString::number(i));
77 ntpSrvs.writeEntry( "name", ComboNtpSrv->text(i) ); 80 ntpSrvs.writeEntry( "name", ComboNtpSrv->text(i) );
78 } 81 }
79 Config cfg("ntp",Config::User); 82 Config cfg("ntp",Config::User);
80 cfg.setGroup("settings"); 83 cfg.setGroup("settings");
81 cfg.writeEntry("ntpServer", ComboNtpSrv->currentItem()); 84 cfg.writeEntry("ntpServer", ComboNtpSrv->currentItem());
82 cfg.writeEntry( "minLookupDiff", SpinBoxMinLookupDelay->value() ); 85 cfg.writeEntry( "minLookupDiff", SpinBoxMinLookupDelay->value() );
83 cfg.writeEntry( "ntpRefreshFreq", SpinBoxNtpDelay->value() ); 86 cfg.writeEntry( "ntpRefreshFreq", SpinBoxNtpDelay->value() );
84} 87}
85 88
86bool Ntp::ntpDelayElapsed() 89bool Ntp::ntpDelayElapsed()
87{ 90{
88 Config cfg("ntp",Config::User); 91 Config cfg("ntp",Config::User);
89 cfg.setGroup("lookups"); 92 cfg.setGroup("lookups");
90 _lookupDiff = TimeConversion::toUTC(QDateTime::currentDateTime()) - cfg.readNumEntry("time",0); 93 _lookupDiff = TimeConversion::toUTC(QDateTime::currentDateTime()) - cfg.readNumEntry("time",0);
91 return (_lookupDiff - (SpinBoxNtpDelay->value()*60)) > -60; 94 return (_lookupDiff - (SpinBoxNtpDelay->value()*60)) > -60;
92} 95}
93 96
94QString Ntp::getNtpServer() 97QString Ntp::getNtpServer()
95{ 98{
96 return ComboNtpSrv->currentText(); 99 return ComboNtpSrv->currentText();
97} 100}
98 101
99void Ntp::slotRunNtp() 102void Ntp::slotRunNtp()
100{ 103{
101 if ( !ntpDelayElapsed() ) 104 if ( !ntpDelayElapsed() )
102 { 105 {
103 switch ( 106 switch (
104 QMessageBox::warning(this, tr("Run NTP?"), 107 QMessageBox::warning(this, tr("Run NTP?"),
105 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 ")+
106 QString::number(_lookupDiff/60)+tr(" minutes elapsed since last loopup.")+ 109 QString::number(_lookupDiff/60)+tr(" minutes elapsed since last loopup.")+
107 "<br>"+tr("Rerun NTP?"), 110 "<br>"+tr("Rerun NTP?"),
108 QMessageBox::Ok,QMessageBox::Cancel) 111 QMessageBox::Ok,QMessageBox::Cancel)
109 ) { 112 ) {
110 case QMessageBox::Ok: break; 113 case QMessageBox::Ok: break;
111 case QMessageBox::Cancel: return; 114 case QMessageBox::Cancel: return;
112 default: return; 115 default: return;
113 } 116 }
114 } 117 }
115 TextLabelStartTime->setText(QDateTime::currentDateTime().toString()); 118 TextLabelStartTime->setText(QDateTime::currentDateTime().toString());
116 ntpOutPut( tr("Running:")+"\nntpdate "+getNtpServer() ); 119 ntpOutPut( tr("Running:")+"\nntpdate "+getNtpServer() );
117 120
118 ntpProcess->clearArguments(); 121 ntpProcess->clearArguments();
119 *ntpProcess << "ntpdate" << getNtpServer(); 122 *ntpProcess << "ntpdate" << getNtpServer();
120 bool ret = ntpProcess->start(OProcess::NotifyOnExit,OProcess::AllOutput); 123 bool ret = ntpProcess->start(OProcess::NotifyOnExit,OProcess::AllOutput);
121 if ( !ret ) { 124 if ( !ret ) {
122 qDebug("Error while executing ntpdate"); 125 qDebug("Error while executing ntpdate");
123 ntpOutPut( tr("Error while executing ntpdate")); 126 ntpOutPut( tr("Error while executing ntpdate"));
124 } 127 }
125} 128}
126 129
127void Ntp::getNtpOutput(OProcess *proc, char *buffer, int buflen) 130void Ntp::getNtpOutput(OProcess *proc, char *buffer, int buflen)
128{ 131{
129 QString lineStr, lineStrOld; 132 QString lineStr, lineStrOld;
130 lineStr = buffer; 133 lineStr = buffer;
131 lineStr=lineStr.left(buflen); 134 lineStr=lineStr.left(buflen);
132 if (lineStr!=lineStrOld) 135 if (lineStr!=lineStrOld)
133 { 136 {
134 ntpOutPut(lineStr); 137 ntpOutPut(lineStr);
135 _ntpOutput += lineStr; 138 _ntpOutput += lineStr;
136 } 139 }
137 lineStrOld = lineStr; 140 lineStrOld = lineStr;
138} 141}
139 142
140void Ntp::ntpFinished(OProcess *p) 143void Ntp::ntpFinished(OProcess *p)
141{ 144{
142 qDebug("p->exitStatus() %i",p->exitStatus()); 145 qDebug("p->exitStatus() %i",p->exitStatus());
143 if (p->exitStatus()!=0 || !p->normalExit()) 146 if (p->exitStatus()!=0 || !p->normalExit())
144 { 147 {
145 slotProbeNtpServer(); 148 slotProbeNtpServer();
146 return; 149 return;
147 } 150 }
148 151
149 Global::writeHWClock(); 152 Global::writeHWClock();
150 // since time has changed quickly load in the datebookdb 153 // since time has changed quickly load in the datebookdb
151 // 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
152 // (example re-trigger alarms for when we travel back in time) 155 // (example re-trigger alarms for when we travel back in time)
153 DateBookDB db; 156 DateBookDB db;
154 157
155 Config cfg("ntp",Config::User); 158 Config cfg("ntp",Config::User);
156 cfg.setGroup("lookups"); 159 cfg.setGroup("lookups");
157 int lastLookup = cfg.readNumEntry("time",0); 160 int lastLookup = cfg.readNumEntry("time",0);
158 int lookupCount = cfg.readNumEntry("count",0); 161 int lookupCount = cfg.readNumEntry("count",0);
159 bool lastNtp = cfg.readBoolEntry("lastNtp",false); 162 bool lastNtp = cfg.readBoolEntry("lastNtp",false);
160 int time = TimeConversion::toUTC( QDateTime::currentDateTime() ); 163 int time = TimeConversion::toUTC( QDateTime::currentDateTime() );
161 cfg.writeEntry("time", time); 164 cfg.writeEntry("time", time);
162 165
163 float timeShift = getTimeShift(); 166 float timeShift = getTimeShift();
164 if (timeShift == 0.0) return; 167 if (timeShift == 0.0) return;
165 int secsSinceLast = time - lastLookup; 168 int secsSinceLast = time - lastLookup;
166 TextLabelNewTime->setText(QDateTime::currentDateTime().toString()); 169 TextLabelNewTime->setText(QDateTime::currentDateTime().toString());
167 TextLabelTimeShift->setText(QString::number(timeShift)+tr(" seconds")); 170 TextLabelTimeShift->setText(QString::number(timeShift)+tr(" seconds"));
168 if ( lastNtp && lastLookup > 0 && secsSinceLast > 60* SpinBoxMinLookupDelay->value()) 171 if ( lastNtp && lastLookup > 0 && secsSinceLast > 60* SpinBoxMinLookupDelay->value())
169 { 172 {
170 cfg.setGroup("lookup_"+QString::number(lookupCount)); 173 cfg.setGroup("lookup_"+QString::number(lookupCount));
171 lookupCount++; 174 lookupCount++;
172 _shiftPerSec = timeShift / secsSinceLast; 175 _shiftPerSec = timeShift / secsSinceLast;
173 qDebug("secs since last lookup %i", secsSinceLast);qDebug("timeshift since last lookup %f", timeShift);qDebug("timeshift since per sec %f", _shiftPerSec); 176 qDebug("secs since last lookup %i", secsSinceLast);qDebug("timeshift since last lookup %f", timeShift);qDebug("timeshift since per sec %f", _shiftPerSec);
174 cfg.writeEntry("secsSinceLast",secsSinceLast); 177 cfg.writeEntry("secsSinceLast",secsSinceLast);
175 cfg.writeEntry("timeShift",QString::number(timeShift)); 178 cfg.writeEntry("timeShift",QString::number(timeShift));
176 cfg.setGroup("lookups"); 179 cfg.setGroup("lookups");
177 cfg.writeEntry("count",lookupCount); 180 cfg.writeEntry("count",lookupCount);
178 cfg.writeEntry("lastNtp",true); 181 cfg.writeEntry("lastNtp",true);
179 } 182 }
180} 183}
181 184
182 185
183float Ntp::getTimeShift() 186float Ntp::getTimeShift()
184{ 187{
185 QString _offset = "offset"; 188 QString _offset = "offset";
186 QString _sec = "sec"; 189 QString _sec = "sec";
187 QRegExp _reOffset = QRegExp(_offset); 190 QRegExp _reOffset = QRegExp(_offset);
188 QRegExp _reEndOffset = QRegExp(_sec); 191 QRegExp _reEndOffset = QRegExp(_sec);
189 int posOffset = _reOffset.match( _ntpOutput ); 192 int posOffset = _reOffset.match( _ntpOutput );
190 int posEndOffset = _reEndOffset.match( _ntpOutput, posOffset ); 193 int posEndOffset = _reEndOffset.match( _ntpOutput, posOffset );
191 posOffset += _offset.length() + 1; 194 posOffset += _offset.length() + 1;
192 QString diff = _ntpOutput.mid(posOffset, posEndOffset-posOffset-1); 195 QString diff = _ntpOutput.mid(posOffset, posEndOffset-posOffset-1);
193 qDebug("%s", _ntpOutput.latin1()); 196 qDebug("%s", _ntpOutput.latin1());
194 qDebug("diff = >%s<",diff.latin1()); 197 qDebug("diff = >%s<",diff.latin1());
195 return diff.toFloat(); 198 return diff.toFloat();
196} 199}
197 200
198void Ntp::readLookups() 201void Ntp::readLookups()
199{ 202{
200 Config cfg("ntp",Config::User); 203 Config cfg("ntp",Config::User);
201 cfg.setGroup("lookups"); 204 cfg.setGroup("lookups");
202 int lookupCount = cfg.readNumEntry("count",0); 205 int lookupCount = cfg.readNumEntry("count",0);
203 float last, shift, shiftPerSec; 206 float last, shift, shiftPerSec;
204 qDebug("lookupCount = %i",lookupCount); 207 qDebug("lookupCount = %i",lookupCount);
205 TableLookups->setNumCols( 3 ); 208 TableLookups->setNumCols( 3 );
206 TableLookups->setNumRows( lookupCount); 209 TableLookups->setNumRows( lookupCount);
207 TableLookups->horizontalHeader()->setLabel(1,tr("last [h]")); 210 TableLookups->horizontalHeader()->setLabel(1,tr("last [h]"));
208 TableLookups->horizontalHeader()->setLabel(2,tr("offset [s]")); 211 TableLookups->horizontalHeader()->setLabel(2,tr("offset [s]"));
209 TableLookups->horizontalHeader()->setLabel(0,tr("shift [s/h]")); 212 TableLookups->horizontalHeader()->setLabel(0,tr("shift [s/h]"));
210 int cw = TableLookups->width()/4; 213 int cw = TableLookups->width()/4;
211 qDebug("column width %i",cw); 214 qDebug("column width %i",cw);
212 cw = 50; 215 cw = 50;
213 TableLookups->setColumnWidth( 0, cw+30 ); 216 TableLookups->setColumnWidth( 0, cw+30 );
214 TableLookups->setColumnWidth( 1, cw ); 217 TableLookups->setColumnWidth( 1, cw );
215 TableLookups->setColumnWidth( 2, cw ); 218 TableLookups->setColumnWidth( 2, cw );
216 TableLookups->sortColumn(0, false, true ); 219 TableLookups->sortColumn(0, false, true );
217 // TableLookups->setSorting( true ); 220 // TableLookups->setSorting( true );
221 _shiftPerSec = 0;
218 for (int i=0; i < lookupCount; i++) 222 for (int i=0; i < lookupCount; i++)
219 { 223 {
220 cfg.setGroup("lookup_"+QString::number(i)); 224 cfg.setGroup("lookup_"+QString::number(i));
221 last = cfg.readEntry("secsSinceLast",0).toFloat(); 225 last = cfg.readEntry("secsSinceLast",0).toFloat();
222 shift = QString(cfg.readEntry("timeShift",0)).toFloat(); 226 shift = QString(cfg.readEntry("timeShift",0)).toFloat();
223 // qDebug("%i last %f",i,last);
224 // qDebug("%i shift %f",i,shift);
225 shiftPerSec = shift / last; 227 shiftPerSec = shift / last;
228 qDebug("%i shift %f",i,shiftPerSec);
226 _shiftPerSec += shiftPerSec; 229 _shiftPerSec += shiftPerSec;
227 TableLookups->setText( i,0,QString::number(shiftPerSec*60*60)); 230 TableLookups->setText( i,0,QString::number(shiftPerSec*60*60));
228 TableLookups->setText( i,2,QString::number(shift)); 231 TableLookups->setText( i,2,QString::number(shift));
229 TableLookups->setText( i,1,QString::number(last/(60*60))); 232 TableLookups->setText( i,1,QString::number(last/(60*60)));
230 } 233 }
231 _shiftPerSec /= lookupCount; 234 _shiftPerSec /= lookupCount;
232 TextLabelShift->setText(QString::number(_shiftPerSec*60*60)+tr(" s/h")); 235 TextLabelShift->setText(QString::number(_shiftPerSec*60*60)+tr(" s/h"));
233} 236}
234 237
235void Ntp::preditctTime() 238void Ntp::preditctTime()
236{ 239{
237 Config cfg("ntp",Config::User); 240 Config cfg("ntp",Config::User);
238 cfg.setGroup("lookups"); 241 cfg.setGroup("lookups");
239 int lastTime = cfg.readNumEntry("time",0); 242 int lastTime = cfg.readNumEntry("time",0);
240 cfg.writeEntry("lastNtp",true); 243 cfg.writeEntry("lastNtp",true);
241 setenv( "TZ", tz->currentZone(), 1 ); 244 setenv( "TZ", tz->currentZone(), 1 );
242 int now = TimeConversion::toUTC( QDateTime::currentDateTime() ); 245 int now = TimeConversion::toUTC( QDateTime::currentDateTime() );
243 int corr = int((now - lastTime) * _shiftPerSec); 246 int corr = int((now - lastTime) * _shiftPerSec);
244 TextLabelEstimatedShift->setText(QString::number(corr)+tr(" seconds")); 247 TextLabelEstimatedShift->setText(QString::number(corr)+tr(" seconds"));
245 predictedTime = QDateTime::currentDateTime().addSecs(corr); 248 predictedTime = QDateTime::currentDateTime().addSecs(corr);
246 TextLabelPredTime->setText(predictedTime.toString()); 249 TextLabelPredTime->setText(predictedTime.toString());
247 TextLabelMainPredTime->setText(tr("Predicted time:")+"<br><b>"+predictedTime.toString()+"</b>"); 250 TextLabelMainPredTime->setText(tr("Predicted time:")+"<br><b>"+predictedTime.toString()+"</b>");
248} 251}
249 252
250void Ntp::setPredictTime() 253void Ntp::setPredictTime()
251{ 254{
252 preditctTime(); 255 preditctTime();
253 setTime( predictedTime ); 256 setTime( predictedTime );
254} 257}
255 258
256void Ntp::slotCheckNtp(int i) 259void Ntp::slotCheckNtp(int i)
257{ 260{
258 if (i == 0) 261 if (i == 0)
259 { 262 {
260 TextLabelMainPredTime->hide(); 263 TextLabelMainPredTime->hide();
261 ButtonSetTime->setText( tr("Get time from network") ); 264 ButtonSetTime->setText( tr("Get time from network") );
262 connect( ButtonSetTime, SIGNAL(clicked()), SLOT(slotRunNtp()) ); 265 connect( ButtonSetTime, SIGNAL(clicked()), SLOT(slotRunNtp()) );
263 if ( ntpDelayElapsed() ) 266 if ( ntpDelayElapsed() )
264 { 267 {
265 slotRunNtp(); 268 slotRunNtp();
266 disconnect(ntpTimer, SIGNAL( timeout() ), this, SLOT(slotProbeNtpServer()) ); 269 disconnect(ntpTimer, SIGNAL( timeout() ), this, SLOT(slotProbeNtpServer()) );
267 connect(ntpTimer, SIGNAL( timeout() ), SLOT(slotRunNtp()) ); 270 connect(ntpTimer, SIGNAL( timeout() ), SLOT(slotRunNtp()) );
268 }else{ 271 }else{
269 disconnect(ntpTimer, SIGNAL( timeout() ), this, SLOT(slotRunNtp()) ); 272 disconnect(ntpTimer, SIGNAL( timeout() ), this, SLOT(slotRunNtp()) );
270 connect(ntpTimer, SIGNAL( timeout() ), SLOT(slotProbeNtpServer()) ); 273 connect(ntpTimer, SIGNAL( timeout() ), SLOT(slotProbeNtpServer()) );
271 } 274 }
272 }else{ 275 }else{
273 preditctTime(); 276 preditctTime();
274 ButtonSetTime->setText( tr("Set predicted time") ); 277 ButtonSetTime->setText( tr("Set predicted time") );
275 if (i>0)ntpOutPut(tr("Could not connect to server ")+getNtpServer()); 278 if (i>0)ntpOutPut(tr("Could not connect to server ")+getNtpServer());
276 connect( ButtonSetTime, SIGNAL(clicked()), SLOT(setPredictTime()) ); 279 connect( ButtonSetTime, SIGNAL(clicked()), SLOT(setPredictTime()) );
277 connect( ntpTimer, SIGNAL( timeout() ), SLOT(slotProbeNtpServer()) ); 280 connect( ntpTimer, SIGNAL( timeout() ), SLOT(slotProbeNtpServer()) );
278 } 281 }
279} 282}
280 283
281void Ntp::slotProbeNtpServer() 284void Ntp::slotProbeNtpServer()
282{ 285{
283 qDebug("Ntp::slotProbeNtpServer()"); 286 qDebug("Ntp::slotProbeNtpServer()");
284 ntpSock->connectToHost( getNtpServer() ,123); 287 ntpSock->connectToHost( getNtpServer() ,123);
285} 288}
286 289
287void Ntp::slotNtpDelayChanged(int delay) 290void Ntp::slotNtpDelayChanged(int delay)
288{ 291{
289 ntpTimer->changeInterval( delay*1000*60 ); 292 ntpTimer->changeInterval( delay*1000*60 );
290} 293}
291 294
292void Ntp::ntpOutPut(QString out) 295void Ntp::ntpOutPut(QString out)
293{ 296{
294 MultiLineEditntpOutPut->append(out); 297 MultiLineEditntpOutPut->append(out);
295 MultiLineEditntpOutPut->setCursorPosition(MultiLineEditntpOutPut->numLines() + 1,0,FALSE); 298 MultiLineEditntpOutPut->setCursorPosition(MultiLineEditntpOutPut->numLines() + 1,0,FALSE);
296} 299}
297 300
301
302void Ntp::makeChannel()
303 {
304 channel = new QCopChannel( "QPE/Application/netsystemtime", this );
305 connect( channel, SIGNAL(received(const QCString&, const QByteArray&)),
306 this, SLOT(receive(const QCString&, const QByteArray&)) );
307}
308
309
310
311void Ntp::receive(const QCString &msg, const QByteArray &arg)
312{
313 qDebug("QCop "+msg+" "+QCString(arg));
314 if ( msg == "open(QString)" )
315 {
316 //qApp->exec();
317 }else{
318 qDebug("Ntp::receive: Huh what do ya want");
319 }
320}
321
322void Ntp::setDocument(const QString &fileName)
323{
324
325} \ No newline at end of file
diff --git a/noncore/settings/netsystemtime/ntp.h b/noncore/settings/netsystemtime/ntp.h
index c78dc55..56e0131 100644
--- a/noncore/settings/netsystemtime/ntp.h
+++ b/noncore/settings/netsystemtime/ntp.h
@@ -1,47 +1,52 @@
1#ifndef NTP_H 1#ifndef NTP_H
2#define NTP_H 2#define NTP_H
3#include "settime.h" 3#include "settime.h"
4#include <qdatetime.h> 4#include <qdatetime.h>
5 5
6class OProcess; 6class OProcess;
7class QString; 7class QString;
8class QTimer; 8class QTimer;
9class QSocket; 9class QSocket;
10class QCopChannel;
10 11
11class Ntp : public SetDateTime 12class Ntp : public SetDateTime
12{ 13{
13 Q_OBJECT 14 Q_OBJECT
14 15
15public: 16public:
16 Ntp( QWidget* parent = 0, const char* name = 0, WFlags fl = 0 ); 17 Ntp( QWidget* parent = 0, const char* name = 0, WFlags fl = 0 );
17 ~Ntp(); 18 ~Ntp();
18 19
20public slots:
21 void setDocument (const QString &);
19protected: 22protected:
20 QDateTime predictedTime; 23 QDateTime predictedTime;
21 24 void makeChannel();
22 25protected slots:
26 void receive(const QCString &msg, const QByteArray &arg);
23private: 27private:
24 QString _ntpOutput; 28 QString _ntpOutput;
25 float _shiftPerSec; 29 float _shiftPerSec;
26 int _lookupDiff; 30 int _lookupDiff;
27 OProcess *ntpProcess; 31 OProcess *ntpProcess;
28 QTimer *ntpTimer; 32 QTimer *ntpTimer;
29 QSocket *ntpSock; 33 QSocket *ntpSock;
34 QCopChannel *channel;
30 35
31 float getTimeShift(); 36 float getTimeShift();
32 void readLookups(); 37 void readLookups();
33 void ntpOutPut(QString); 38 void ntpOutPut(QString);
34 bool ntpDelayElapsed(); 39 bool ntpDelayElapsed();
35 QString getNtpServer(); 40 QString getNtpServer();
36private slots: 41private slots:
37 void slotRunNtp(); 42 void slotRunNtp();
38 void getNtpOutput(OProcess *proc, char *buffer, int buflen); 43 void getNtpOutput(OProcess *proc, char *buffer, int buflen);
39 void ntpFinished(OProcess*); 44 void ntpFinished(OProcess*);
40 void preditctTime(); 45 void preditctTime();
41 void slotCheckNtp(int); 46 void slotCheckNtp(int);
42 void setPredictTime(); 47 void setPredictTime();
43 void slotProbeNtpServer(); 48 void slotProbeNtpServer();
44 void slotNtpDelayChanged(int); 49 void slotNtpDelayChanged(int);
45}; 50};
46 51
47#endif 52#endif
diff --git a/noncore/settings/netsystemtime/opie-netsystemtime.control b/noncore/settings/netsystemtime/opie-netsystemtime.control
index 9251e5c..e4b744d 100644
--- a/noncore/settings/netsystemtime/opie-netsystemtime.control
+++ b/noncore/settings/netsystemtime/opie-netsystemtime.control
@@ -1,11 +1,11 @@
1Packagename: opie-netsystemtime 1Packagename: opie-netsystemtime
2Files: bin/netsystemtime apps/Settings/ntpdatetime.desktop etc/ntpservers 2Files: bin/netsystemtime apps/Settings/netsystemtime.desktop etc/ntpservers
3Priority: optional 3Priority: optional
4Section: opie/settings 4Section: opie/settings
5Conflicts: opie-systemtime 5Conflicts: opie-systemtime
6Maintainer: Patrick S. Vogt <tille@handhelds.org> 6Maintainer: Patrick S. Vogt <tille@handhelds.org>
7Architecture: arm 7Architecture: arm
8Version: $QPE_VERSION-$SUB_VERSION 8Version: $QPE_VERSION-$SUB_VERSION
9Depends: opie-base ($QPE_VERSION), ntpdate 9Depends: opie-base ($QPE_VERSION), ntpdate
10Description: ntp (Network Time Protocol) gui 10Description: ntp (Network Time Protocol) gui
11This utility syncs system time with a atomic timerserver via internet 11This 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
deleted file mode 100644
index 233cd31..0000000
--- a/noncore/settings/netsystemtime/opie-netsystemtime.postinst
+++ b/dev/null
@@ -1,7 +0,0 @@
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
deleted file mode 100644
index 4b2ab7c..0000000
--- a/noncore/settings/netsystemtime/opie-netsystemtime.postrm
+++ b/dev/null
@@ -1,4 +0,0 @@
1#!/bin/sh -v
2
3cd $QPEDIR/bin/
4rm systemtime