summaryrefslogtreecommitdiff
path: root/noncore/settings/netsystemtime/ntp.cpp
Unidiff
Diffstat (limited to 'noncore/settings/netsystemtime/ntp.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/settings/netsystemtime/ntp.cpp15
1 files changed, 9 insertions, 6 deletions
diff --git a/noncore/settings/netsystemtime/ntp.cpp b/noncore/settings/netsystemtime/ntp.cpp
index 04b113b..ddb1372 100644
--- a/noncore/settings/netsystemtime/ntp.cpp
+++ b/noncore/settings/netsystemtime/ntp.cpp
@@ -18,7 +18,7 @@
18 18
19 19
20Ntp::Ntp( QWidget* parent, const char* name, WFlags fl ) 20Ntp::Ntp( QWidget* parent, const char* name, WFlags fl )
21 : NtpBase( parent, name, fl ) 21 : SetDateTime( parent, name, fl )
22{ 22{
23 Config cfg("ntp",Config::User); 23 Config cfg("ntp",Config::User);
24 cfg.setGroup("settings"); 24 cfg.setGroup("settings");
@@ -40,6 +40,11 @@ Ntp::Ntp( QWidget* parent, const char* name, WFlags fl )
40 40
41Ntp::~Ntp() 41Ntp::~Ntp()
42{ 42{
43
44}
45
46void Ntp::accept()
47{
43 Config cfg("ntp",Config::User); 48 Config cfg("ntp",Config::User);
44 cfg.setGroup("settings"); 49 cfg.setGroup("settings");
45 cfg.writeEntry("ntpServer", LineEditNtpServer->text()); 50 cfg.writeEntry("ntpServer", LineEditNtpServer->text());
@@ -54,7 +59,6 @@ void Ntp::slotRunNtp()
54 bool ret = ntpProcess->start(OProcess::NotifyOnExit,OProcess::AllOutput); 59 bool ret = ntpProcess->start(OProcess::NotifyOnExit,OProcess::AllOutput);
55 if ( !ret ) { 60 if ( !ret ) {
56 qDebug("Error while executing ntp"); 61 qDebug("Error while executing ntp");
57 outPut->append("\nError while executing\n\n");
58 } 62 }
59} 63}
60 64
@@ -65,7 +69,7 @@ void Ntp::getNtpOutput(OProcess *proc, char *buffer, int buflen)
65 lineStr=lineStr.left(buflen); 69 lineStr=lineStr.left(buflen);
66 if (lineStr!=lineStrOld) 70 if (lineStr!=lineStrOld)
67 { 71 {
68 outPut->append(lineStr); 72 // outPut->append(lineStr);
69 _ntpOutput += lineStr; 73 _ntpOutput += lineStr;
70 } 74 }
71 lineStrOld = lineStr; 75 lineStrOld = lineStr;
@@ -90,7 +94,7 @@ void Ntp::ntpFinished(OProcess*)
90 cfg.writeEntry("count",lookupCount); 94 cfg.writeEntry("count",lookupCount);
91 cfg.setGroup("lookup_"+QString::number(lookupCount)); 95 cfg.setGroup("lookup_"+QString::number(lookupCount));
92 _shiftPerSec = timeShift / secsSinceLast; 96 _shiftPerSec = timeShift / secsSinceLast;
93 float nextCorr = _maxOffset / _shiftPerSec; 97// float nextCorr = _maxOffset / _shiftPerSec;
94 qDebug("secs since last lookup %i", secsSinceLast);qDebug("timeshift since last lookup %f", timeShift);qDebug("timeshift since per sec %f", _shiftPerSec); 98 qDebug("secs since last lookup %i", secsSinceLast);qDebug("timeshift since last lookup %f", timeShift);qDebug("timeshift since per sec %f", _shiftPerSec);
95 cfg.writeEntry("secsSinceLast",secsSinceLast); 99 cfg.writeEntry("secsSinceLast",secsSinceLast);
96 cfg.writeEntry("timeShift",QString::number(timeShift)); 100 cfg.writeEntry("timeShift",QString::number(timeShift));
@@ -105,7 +109,6 @@ void Ntp::correctClock()
105 int lastTime = cfg.readNumEntry("time",0); 109 int lastTime = cfg.readNumEntry("time",0);
106 int now = TimeConversion::toUTC( QDateTime::currentDateTime() ); 110 int now = TimeConversion::toUTC( QDateTime::currentDateTime() );
107 int corr = int((now - lastTime) * _shiftPerSec); 111 int corr = int((now - lastTime) * _shiftPerSec);
108 outPut->append( "time will be shifted by "+QString::number(corr)+ "secs");
109 struct timeval myTv; 112 struct timeval myTv;
110 myTv.tv_sec = TimeConversion::toUTC( QDateTime::currentDateTime().addSecs(corr) ); 113 myTv.tv_sec = TimeConversion::toUTC( QDateTime::currentDateTime().addSecs(corr) );
111 myTv.tv_usec = 0; 114 myTv.tv_usec = 0;
@@ -173,8 +176,8 @@ void Ntp::preditctTime()
173 Config cfg("ntp",Config::User); 176 Config cfg("ntp",Config::User);
174 cfg.setGroup("lookups"); 177 cfg.setGroup("lookups");
175 int lastTime = cfg.readNumEntry("time",0); 178 int lastTime = cfg.readNumEntry("time",0);
179 setenv( "TZ", tz->currentZone(), 1 );
176 int now = TimeConversion::toUTC( QDateTime::currentDateTime() ); 180 int now = TimeConversion::toUTC( QDateTime::currentDateTime() );
177 int corr = int((now - lastTime) * _shiftPerSec); 181 int corr = int((now - lastTime) * _shiftPerSec);
178 outPut->append( "time will be shifted by "+QString::number(corr)+ "secs");
179 TextLabelPredTime->setText(QDateTime::currentDateTime().addSecs(corr).toString()); 182 TextLabelPredTime->setText(QDateTime::currentDateTime().addSecs(corr).toString());
180} 183}