-rw-r--r-- | noncore/settings/netsystemtime/ntp.cpp | 50 | ||||
-rw-r--r-- | noncore/settings/netsystemtime/ntp.h | 4 | ||||
-rw-r--r-- | noncore/settings/netsystemtime/settime.cpp | 20 | ||||
-rw-r--r-- | noncore/settings/netsystemtime/settime.h | 1 |
4 files changed, 43 insertions, 32 deletions
diff --git a/noncore/settings/netsystemtime/ntp.cpp b/noncore/settings/netsystemtime/ntp.cpp index ddb1372..87b20ec 100644 --- a/noncore/settings/netsystemtime/ntp.cpp +++ b/noncore/settings/netsystemtime/ntp.cpp | |||
@@ -33,6 +33,6 @@ Ntp::Ntp( QWidget* parent, const char* name, WFlags fl ) | |||
33 | connect(runNtp, SIGNAL(clicked()), this, SLOT(slotRunNtp())); | 33 | connect(runNtp, SIGNAL(clicked()), this, SLOT(slotRunNtp())); |
34 | connect(PushButtonPredict, SIGNAL(clicked()), this, SLOT(preditctTime())); | 34 | connect(PushButtonPredict, SIGNAL(clicked()), this, SLOT(preditctTime())); |
35 | _nextCorrection = new QTimer( this ); | 35 | // _nextCorrection = new QTimer( this ); |
36 | connect( _nextCorrection, SIGNAL(timeout()), SLOT(correctClock()) ); | 36 | // connect( _nextCorrection, SIGNAL(timeout()), SLOT(correctClock()) ); |
37 | slotRunNtp(); | 37 | slotRunNtp(); |
38 | readLookups(); | 38 | readLookups(); |
@@ -84,4 +84,6 @@ void Ntp::ntpFinished(OProcess*) | |||
84 | int time = TimeConversion::toUTC( QDateTime::currentDateTime() ); | 84 | int time = TimeConversion::toUTC( QDateTime::currentDateTime() ); |
85 | cfg.writeEntry("time", time); | 85 | cfg.writeEntry("time", time); |
86 | cfg.setGroup("correction"); | ||
87 | cfg.writeEntry("time", time); | ||
86 | 88 | ||
87 | float timeShift = getTimeShift(); | 89 | float timeShift = getTimeShift(); |
@@ -102,22 +104,26 @@ void Ntp::ntpFinished(OProcess*) | |||
102 | } | 104 | } |
103 | 105 | ||
104 | void Ntp::correctClock() | 106 | //void Ntp::correctClock() |
105 | { | 107 | //{ |
106 | qDebug("current time: %s",QDateTime::currentDateTime().toString().latin1()); | 108 | //qDebug("current time: %s",QDateTime::currentDateTime().toString().latin1()); |
107 | Config cfg("ntp",Config::User); | 109 | //Config cfg("ntp",Config::User); |
108 | cfg.setGroup("correction"); | 110 | // cfg.setGroup("correction"); |
109 | int lastTime = cfg.readNumEntry("time",0); | 111 | // int lastTime = cfg.readNumEntry("time",0); |
110 | int now = TimeConversion::toUTC( QDateTime::currentDateTime() ); | 112 | // if ( lastTime == 0 ) |
111 | int corr = int((now - lastTime) * _shiftPerSec); | 113 | // { |
112 | struct timeval myTv; | 114 | // return; |
113 | myTv.tv_sec = TimeConversion::toUTC( QDateTime::currentDateTime().addSecs(corr) ); | 115 | // } |
114 | myTv.tv_usec = 0; | 116 | // int now = TimeConversion::toUTC( QDateTime::currentDateTime() ); |
115 | 117 | // int corr = int((now - lastTime) * _shiftPerSec); | |
116 | if ( myTv.tv_sec != -1 ) | 118 | // struct timeval myTv; |
117 | ::settimeofday( &myTv, 0 ); | 119 | // myTv.tv_sec = TimeConversion::toUTC( QDateTime::currentDateTime().addSecs(corr) ); |
118 | Global::writeHWClock(); | 120 | // myTv.tv_usec = 0; |
119 | cfg.writeEntry("time",now); | 121 | // |
120 | qDebug("current time: %s",QDateTime::currentDateTime().toString().latin1()); | 122 | // if ( myTv.tv_sec != -1 ) |
121 | } | 123 | // ::settimeofday( &myTv, 0 ); |
124 | // Global::writeHWClock(); | ||
125 | // cfg.writeEntry("time",now); | ||
126 | //qDebug("current time: %s",QDateTime::currentDateTime().toString().latin1()); | ||
127 | //} | ||
122 | 128 | ||
123 | float Ntp::getTimeShift() | 129 | float Ntp::getTimeShift() |
@@ -180,4 +186,6 @@ void Ntp::preditctTime() | |||
180 | int now = TimeConversion::toUTC( QDateTime::currentDateTime() ); | 186 | int now = TimeConversion::toUTC( QDateTime::currentDateTime() ); |
181 | int corr = int((now - lastTime) * _shiftPerSec); | 187 | int corr = int((now - lastTime) * _shiftPerSec); |
182 | TextLabelPredTime->setText(QDateTime::currentDateTime().addSecs(corr).toString()); | 188 | QDateTime dt = QDateTime::currentDateTime().addSecs(corr); |
189 | setTime(dt); | ||
190 | TextLabelPredTime->setText(dt.toString()); | ||
183 | } | 191 | } |
diff --git a/noncore/settings/netsystemtime/ntp.h b/noncore/settings/netsystemtime/ntp.h index fc233bf..d2e238d 100644 --- a/noncore/settings/netsystemtime/ntp.h +++ b/noncore/settings/netsystemtime/ntp.h | |||
@@ -26,5 +26,5 @@ private: | |||
26 | int _maxOffset; | 26 | int _maxOffset; |
27 | float _shiftPerSec; | 27 | float _shiftPerSec; |
28 | QTimer *_nextCorrection; | 28 | // QTimer *_nextCorrection; |
29 | int _minLookupDiff; | 29 | int _minLookupDiff; |
30 | 30 | ||
@@ -35,5 +35,5 @@ private slots: | |||
35 | void getNtpOutput(OProcess *proc, char *buffer, int buflen); | 35 | void getNtpOutput(OProcess *proc, char *buffer, int buflen); |
36 | void ntpFinished(OProcess*); | 36 | void ntpFinished(OProcess*); |
37 | void correctClock(); | 37 | // void correctClock(); |
38 | void preditctTime(); | 38 | void preditctTime(); |
39 | }; | 39 | }; |
diff --git a/noncore/settings/netsystemtime/settime.cpp b/noncore/settings/netsystemtime/settime.cpp index dac5bd4..01268c9 100644 --- a/noncore/settings/netsystemtime/settime.cpp +++ b/noncore/settings/netsystemtime/settime.cpp | |||
@@ -209,8 +209,4 @@ void SetDateTime::accept() | |||
209 | void SetDateTime::commitTime() | 209 | void SetDateTime::commitTime() |
210 | { | 210 | { |
211 | Config cfg("ntp",Config::User); | ||
212 | cfg.setGroup("lookups"); | ||
213 | int time = TimeConversion::toUTC( QDateTime::currentDateTime() ); | ||
214 | cfg.writeEntry("time", time); | ||
215 | tz->setFocus(); | 211 | tz->setFocus(); |
216 | // really turn off the screensaver before doing anything | 212 | // really turn off the screensaver before doing anything |
@@ -228,7 +224,15 @@ void SetDateTime::commitTime() | |||
228 | QDateTime dt( dateButton->date(), timeButton->time() ); | 224 | QDateTime dt( dateButton->date(), timeButton->time() ); |
229 | 225 | ||
230 | if ( dt.isValid() ) { | 226 | if ( dt.isValid() ) setTime(dt); |
227 | } | ||
228 | |||
229 | void SetDateTime::setTime(QDateTime dt) | ||
230 | { | ||
231 | Config cfg("ntp",Config::User); | ||
232 | cfg.setGroup("correction"); | ||
233 | int t = TimeConversion::toUTC(dt); | ||
231 | struct timeval myTv; | 234 | struct timeval myTv; |
232 | myTv.tv_sec = TimeConversion::toUTC( dt ); | 235 | myTv.tv_sec = t; |
236 | cfg.writeEntry("time", t ); | ||
233 | myTv.tv_usec = 0; | 237 | myTv.tv_usec = 0; |
234 | 238 | ||
@@ -240,7 +244,5 @@ void SetDateTime::commitTime() | |||
240 | // (example re-trigger alarms for when we travel back in time) | 244 | // (example re-trigger alarms for when we travel back in time) |
241 | DateBookDB db; | 245 | DateBookDB db; |
242 | } else { | 246 | |
243 | qWarning( "Invalid date/time" ); | ||
244 | } | ||
245 | // set the timezone for everyone else... | 247 | // set the timezone for everyone else... |
246 | QCopEnvelope setTimeZone( "QPE/System", "timeChange(QString)" ); | 248 | QCopEnvelope setTimeZone( "QPE/System", "timeChange(QString)" ); |
diff --git a/noncore/settings/netsystemtime/settime.h b/noncore/settings/netsystemtime/settime.h index 053d17a..729bf4b 100644 --- a/noncore/settings/netsystemtime/settime.h +++ b/noncore/settings/netsystemtime/settime.h | |||
@@ -77,4 +77,5 @@ protected slots: | |||
77 | protected: | 77 | protected: |
78 | void commitTime(); | 78 | void commitTime(); |
79 | void setTime(QDateTime dt); | ||
79 | virtual void accept(); | 80 | virtual void accept(); |
80 | virtual void done(int); | 81 | virtual void done(int); |