summaryrefslogtreecommitdiff
path: root/noncore/settings/netsystemtime/ntp.cpp
Unidiff
Diffstat (limited to 'noncore/settings/netsystemtime/ntp.cpp') (more/less context) (show whitespace changes)
-rw-r--r--noncore/settings/netsystemtime/ntp.cpp60
1 files changed, 30 insertions, 30 deletions
diff --git a/noncore/settings/netsystemtime/ntp.cpp b/noncore/settings/netsystemtime/ntp.cpp
index b2f192a..52fc6be 100644
--- a/noncore/settings/netsystemtime/ntp.cpp
+++ b/noncore/settings/netsystemtime/ntp.cpp
@@ -8,2 +8,3 @@
8#include <qspinbox.h> 8#include <qspinbox.h>
9#include <qmessagebox.h>
9#include <qmultilineedit.h> 10#include <qmultilineedit.h>
@@ -28,4 +29,4 @@ Ntp::Ntp( QWidget* parent, const char* name, WFlags fl )
28// _minLookupDiff = cfg.readNumEntry("minLookupDiff",10); 29// _minLookupDiff = cfg.readNumEntry("minLookupDiff",10);
29 SpinBoxMinDelay->setValue( cfg.readNumEntry("minLookupDiff",10) ); 30 SpinBoxMinLookupDelay->setValue( cfg.readNumEntry("minLookupDiff",60) );
30 SpinBoxMinDelay->setMinValue( 7 ); 31 SpinBoxNtpDelay->setValue( cfg.readNumEntry("ntpRefreshFreq",60) );
31 LineEditNtpSrv->setText( cfg.readEntry("ntpServer", tr("time.fu-berlin.de")) ); 32 LineEditNtpSrv->setText( cfg.readEntry("ntpServer", tr("time.fu-berlin.de")) );
@@ -54,3 +55,4 @@ Ntp::~Ntp()
54 cfg.writeEntry("ntpServer", LineEditNtpSrv->text()); 55 cfg.writeEntry("ntpServer", LineEditNtpSrv->text());
55 cfg.writeEntry( "minLookupDiff", SpinBoxMinDelay->value() ); 56 cfg.writeEntry( "minLookupDiff", SpinBoxMinLookupDelay->value() );
57 cfg.writeEntry( "ntpRefreshFreq", SpinBoxNtpDelay->value() );
56} 58}
@@ -60,2 +62,20 @@ void Ntp::slotRunNtp()
60{ 62{
63 Config cfg("ntp",Config::User);
64 cfg.setGroup("lookups");
65 int lookupDiff = TimeConversion::toUTC(QDateTime::currentDateTime()) - cfg.readNumEntry("time",0);
66
67 if ( lookupDiff < SpinBoxNtpDelay->value()*60 )
68 {
69 switch (
70 QMessageBox::warning(this, tr("Run ntp?"),
71 tr("You asked for a delay of ")+SpinBoxNtpDelay->text()+tr(" minutes, but only ")+
72 QString::number(lookupDiff%60)+tr(" minutes elapsed since last loopup.")+
73 "<br>"+tr("Rerun ntp?"),
74 QMessageBox::Ok,QMessageBox::Cancel)
75 ) {
76 case QMessageBox::Ok: break;
77 case QMessageBox::Cancel: return;
78 default: return;
79 }
80 }
61 TextLabelStartTime->setText(QDateTime::currentDateTime().toString()); 81 TextLabelStartTime->setText(QDateTime::currentDateTime().toString());
@@ -97,3 +117,4 @@ void Ntp::ntpFinished(OProcess*)
97 TextLabelNewTime->setText(QDateTime::currentDateTime().toString()); 117 TextLabelNewTime->setText(QDateTime::currentDateTime().toString());
98 if ( lastLookup > 0 && secsSinceLast > 60*24* SpinBoxMinDelay->value()) 118 TextLabelTimeShift->setText(QString::number(timeShift)+tr(" seconds"));
119 if ( lastLookup > 0 && secsSinceLast > 60* SpinBoxMinLookupDelay->value())
99 { 120 {
@@ -110,24 +131,2 @@ void Ntp::ntpFinished(OProcess*)
110 131
111//void Ntp::correctClock()
112//{
113 //qDebug("current time: %s",QDateTime::currentDateTime().toString().latin1());
114 //Config cfg("ntp",Config::User);
115// cfg.setGroup("correction");
116 // int lastTime = cfg.readNumEntry("time",0);
117// if ( lastTime == 0 )
118// {
119 // return;
120// }
121// int now = TimeConversion::toUTC( QDateTime::currentDateTime() );
122// int corr = int((now - lastTime) * _shiftPerSec);
123// struct timeval myTv;
124// myTv.tv_sec = TimeConversion::toUTC( QDateTime::currentDateTime().addSecs(corr) );
125// myTv.tv_usec = 0;
126//
127// if ( myTv.tv_sec != -1 )
128// ::settimeofday( &myTv, 0 );
129// Global::writeHWClock();
130// cfg.writeEntry("time",now);
131 //qDebug("current time: %s",QDateTime::currentDateTime().toString().latin1());
132//}
133 132
@@ -145,3 +144,2 @@ float Ntp::getTimeShift()
145 qDebug("diff = >%s<",diff.latin1()); 144 qDebug("diff = >%s<",diff.latin1());
146 TextLabelTimeShift->setText(diff);
147 return diff.toFloat(); 145 return diff.toFloat();
@@ -166,2 +164,4 @@ void Ntp::readLookups()
166 TableLookups->setColumnWidth( 2, cw ); 164 TableLookups->setColumnWidth( 2, cw );
165 TableLookups->sortColumn(0, false, true );
166 // TableLookups->setSorting( true );
167 for (int i=0; i < lookupCount; i++) 167 for (int i=0; i < lookupCount; i++)
@@ -180,3 +180,3 @@ void Ntp::readLookups()
180 _shiftPerSec /= lookupCount+1; 180 _shiftPerSec /= lookupCount+1;
181 TextLabelShift->setText(QString::number(_shiftPerSec)); 181 TextLabelShift->setText(QString::number(_shiftPerSec)+tr(" seconds"));
182} 182}
@@ -194,3 +194,3 @@ void Ntp::preditctTime()
194 TextLabelPredTime->setText(predictedTime.toString()); 194 TextLabelPredTime->setText(predictedTime.toString());
195 TextLabelMainPredTime->setText(predictedTime.toString()); 195 TextLabelMainPredTime->setText(tr("Predicted time:")+"<br><b>"+predictedTime.toString()+"</b>");
196} 196}
@@ -212,3 +212,3 @@ void Ntp::slotCheckNtp(int i)
212 preditctTime(); 212 preditctTime();
213 ButtonSetTime->setText( tr("Predict time") ); 213 ButtonSetTime->setText( tr("Set predicted time") );
214 connect( ButtonSetTime, SIGNAL(clicked()), SLOT(setPredictTime()) ); 214 connect( ButtonSetTime, SIGNAL(clicked()), SLOT(setPredictTime()) );