-rw-r--r-- | noncore/settings/netsystemtime/ntp.cpp | 19 |
1 files changed, 11 insertions, 8 deletions
diff --git a/noncore/settings/netsystemtime/ntp.cpp b/noncore/settings/netsystemtime/ntp.cpp index 6f6316c..f60e38d 100644 --- a/noncore/settings/netsystemtime/ntp.cpp +++ b/noncore/settings/netsystemtime/ntp.cpp | |||
@@ -49,79 +49,79 @@ Ntp::Ntp( QWidget* parent, const char* name, WFlags fl ) | |||
49 | bool advMode = cfg.readBoolEntry("advancedFeatures", false ); | 49 | bool advMode = cfg.readBoolEntry("advancedFeatures", false ); |
50 | showAdvancedFeatures(advMode); | 50 | showAdvancedFeatures(advMode); |
51 | CheckBoxAdvSettings->setChecked( advMode ); | 51 | CheckBoxAdvSettings->setChecked( advMode ); |
52 | connect( CheckBoxAdvSettings, SIGNAL( toggled( bool ) ), | 52 | connect( CheckBoxAdvSettings, SIGNAL( toggled( bool ) ), |
53 | SLOT( showAdvancedFeatures( bool ) ) ); | 53 | SLOT( showAdvancedFeatures( bool ) ) ); |
54 | 54 | ||
55 | makeChannel(); | 55 | makeChannel(); |
56 | 56 | ||
57 | ntpTimer = new QTimer(this); | 57 | ntpTimer = new QTimer(this); |
58 | 58 | ||
59 | ntpProcess = new OProcess( ); | 59 | ntpProcess = new OProcess( ); |
60 | connect( SpinBoxNtpDelay, SIGNAL( valueChanged(int) ), | 60 | connect( SpinBoxNtpDelay, SIGNAL( valueChanged(int) ), |
61 | SLOT(slotNtpDelayChanged(int)) ); | 61 | SLOT(slotNtpDelayChanged(int)) ); |
62 | 62 | ||
63 | ntpSock = new QSocket( this ); | 63 | ntpSock = new QSocket( this ); |
64 | connect( ntpSock, SIGNAL( error(int) ), | 64 | connect( ntpSock, SIGNAL( error(int) ), |
65 | SLOT(slotCheckNtp(int)) ); | 65 | SLOT(slotCheckNtp(int)) ); |
66 | slotProbeNtpServer(); | 66 | slotProbeNtpServer(); |
67 | 67 | ||
68 | connect ( ntpProcess, SIGNAL(receivedStdout(OProcess*,char*,int)), | 68 | connect ( ntpProcess, SIGNAL(receivedStdout(OProcess*,char*,int)), |
69 | this, SLOT(getNtpOutput(OProcess*,char*,int))); | 69 | this, SLOT(getNtpOutput(OProcess*,char*,int))); |
70 | connect ( ntpProcess, SIGNAL(processExited(OProcess*)), | 70 | connect ( ntpProcess, SIGNAL(processExited(OProcess*)), |
71 | this, SLOT(ntpFinished(OProcess*))); | 71 | this, SLOT(ntpFinished(OProcess*))); |
72 | connect(runNtp, SIGNAL(clicked()), this, SLOT(slotRunNtp())); | 72 | connect(runNtp, SIGNAL(clicked()), this, SLOT(slotRunNtp())); |
73 | connect(PushButtonPredict, SIGNAL(clicked()), this, SLOT(preditctTime())); | 73 | connect(PushButtonPredict, SIGNAL(clicked()), this, SLOT(preditctTime())); |
74 | connect(PushButtonSetPredTime, SIGNAL(clicked()), this, SLOT(setPredictTime())); | 74 | connect(PushButtonSetPredTime, SIGNAL(clicked()), this, SLOT(setPredictTime())); |
75 | slotCheckNtp(-1); | 75 | slotCheckNtp(-1); |
76 | readLookups(); | 76 | readLookups(); |
77 | } | 77 | } |
78 | 78 | ||
79 | Ntp::~Ntp() | 79 | Ntp::~Ntp() |
80 | { | 80 | { |
81 | delete ntpProcess; | 81 | delete ntpProcess; |
82 | Config ntpSrvs("/etc/ntpservers",Config::File); | 82 | Config ntpSrvs("/etc/ntpservers",Config::File); |
83 | ntpSrvs.setGroup("servers"); | 83 | ntpSrvs.setGroup("servers"); |
84 | int srvCount = ComboNtpSrv->count(); | 84 | int srvCount = ComboNtpSrv->count(); |
85 | ntpSrvs.writeEntry("count", srvCount); | 85 | ntpSrvs.writeEntry("count", srvCount); |
86 | for (int i = 0; i < srvCount; i++) | 86 | for (int i = 0; i < srvCount; i++){ |
87 | { | 87 | ntpSrvs.setGroup(QString::number(i)); |
88 | ntpSrvs.setGroup(QString::number(i)); | 88 | ntpSrvs.writeEntry( "name", ComboNtpSrv->text(i) ); |
89 | ntpSrvs.writeEntry( "name", ComboNtpSrv->text(i) ); | ||
90 | } | 89 | } |
91 | Config cfg("ntp",Config::User); | 90 | Config cfg("ntp",Config::User); |
92 | cfg.setGroup("settings"); | 91 | cfg.setGroup("settings"); |
93 | cfg.writeEntry("ntpServer", ComboNtpSrv->currentItem()); | 92 | cfg.writeEntry("ntpServer", ComboNtpSrv->currentItem()); |
94 | cfg.writeEntry( "minLookupDiff", SpinBoxMinLookupDelay->value() ); | 93 | cfg.writeEntry( "minLookupDiff", SpinBoxMinLookupDelay->value() ); |
95 | cfg.writeEntry( "ntpRefreshFreq", SpinBoxNtpDelay->value() ); | 94 | cfg.writeEntry( "ntpRefreshFreq", SpinBoxNtpDelay->value() ); |
95 | cfg.writeEntry( "advancedFeatures", CheckBoxAdvSettings->isChecked() ); | ||
96 | } | 96 | } |
97 | 97 | ||
98 | bool Ntp::ntpDelayElapsed() | 98 | bool Ntp::ntpDelayElapsed() |
99 | { | 99 | { |
100 | Config cfg("ntp",Config::User); | 100 | Config cfg("ntp",Config::User); |
101 | cfg.setGroup("lookups"); | 101 | cfg.setGroup("lookups"); |
102 | _lookupDiff = TimeConversion::toUTC(QDateTime::currentDateTime()) - cfg.readNumEntry("time",0); | 102 | _lookupDiff = TimeConversion::toUTC(QDateTime::currentDateTime()) - cfg.readNumEntry("time",0); |
103 | return (_lookupDiff - (SpinBoxNtpDelay->value()*60)) > -60; | 103 | return (_lookupDiff - (SpinBoxNtpDelay->value()*60)) > -60; |
104 | } | 104 | } |
105 | 105 | ||
106 | QString Ntp::getNtpServer() | 106 | QString Ntp::getNtpServer() |
107 | { | 107 | { |
108 | return ComboNtpSrv->currentText(); | 108 | return ComboNtpSrv->currentText(); |
109 | } | 109 | } |
110 | 110 | ||
111 | void Ntp::slotRunNtp() | 111 | void Ntp::slotRunNtp() |
112 | { | 112 | { |
113 | if ( !ntpDelayElapsed() ) | 113 | if ( !ntpDelayElapsed() ) |
114 | { | 114 | { |
115 | switch ( | 115 | switch ( |
116 | QMessageBox::warning(this, tr("Run NTP?"), | 116 | QMessageBox::warning(this, tr("Run NTP?"), |
117 | tr("You asked for a delay of ")+SpinBoxNtpDelay->text()+tr(" minutes, but only ")+ | 117 | tr("You asked for a delay of ")+SpinBoxNtpDelay->text()+tr(" minutes, but only ")+ |
118 | QString::number(_lookupDiff/60)+tr(" minutes elapsed since last lookup.")+ | 118 | QString::number(_lookupDiff/60)+tr(" minutes elapsed since last lookup.")+ |
119 | "<br>"+tr("Rerun NTP?"), | 119 | "<br>"+tr("Rerun NTP?"), |
120 | QMessageBox::Ok,QMessageBox::Cancel) | 120 | QMessageBox::Ok,QMessageBox::Cancel) |
121 | ) { | 121 | ) { |
122 | case QMessageBox::Ok: break; | 122 | case QMessageBox::Ok: break; |
123 | case QMessageBox::Cancel: return; | 123 | case QMessageBox::Cancel: return; |
124 | default: return; | 124 | default: return; |
125 | } | 125 | } |
126 | } | 126 | } |
127 | TextLabelStartTime->setText(QDateTime::currentDateTime().toString()); | 127 | TextLabelStartTime->setText(QDateTime::currentDateTime().toString()); |
@@ -323,45 +323,48 @@ void Ntp::receive(const QCString &msg, const QByteArray &arg) | |||
323 | { | 323 | { |
324 | qDebug("QCop(Ntp) "+msg+" "+QCString(arg)); | 324 | qDebug("QCop(Ntp) "+msg+" "+QCString(arg)); |
325 | if ( msg == "ntpLookup(QString)" ) | 325 | if ( msg == "ntpLookup(QString)" ) |
326 | { | 326 | { |
327 | slotRunNtp(); | 327 | slotRunNtp(); |
328 | } | 328 | } |
329 | if ( msg == "setPredictedTime(QString)" ) | 329 | if ( msg == "setPredictedTime(QString)" ) |
330 | { | 330 | { |
331 | setPredictTime(); | 331 | setPredictTime(); |
332 | }else{ | 332 | }else{ |
333 | qDebug("Ntp::receive: Huh what do ya want"); | 333 | qDebug("Ntp::receive: Huh what do ya want"); |
334 | } | 334 | } |
335 | } | 335 | } |
336 | 336 | ||
337 | void Ntp::setDocument(const QString &fileName) | 337 | void Ntp::setDocument(const QString &fileName) |
338 | { | 338 | { |
339 | 339 | ||
340 | } | 340 | } |
341 | 341 | ||
342 | void Ntp::showAdvancedFeatures(bool advMode) | 342 | void Ntp::showAdvancedFeatures(bool advMode) |
343 | { | 343 | { |
344 | if (advMode) { | 344 | if (advMode) { |
345 | TabWidgetMain->addTab( tabPredict, tr( "Predict" ) ); | 345 | TabWidgetMain->addTab( tabPredict, tr( "Predict" ) ); |
346 | TabWidgetMain->addTab( tabNtp, tr( "NTP" ) ); | 346 | TabWidgetMain->addTab( tabNtp, tr( "NTP" ) ); |
347 | TextLabel1_2_2->show(); | 347 | TextLabel1_2_2->show(); |
348 | TextLabel2_3->show(); | 348 | TextLabel2_3->show(); |
349 | TextLabel3_3_2->show(); | 349 | TextLabel3_3_2->show(); |
350 | TextLabel1_2->show(); | 350 | TextLabel1_2->show(); |
351 | SpinBoxMinLookupDelay->show(); | 351 | SpinBoxMinLookupDelay->show(); |
352 | TextLabel2->show(); | 352 | TextLabel2->show(); |
353 | TextLabel3_3->show(); | 353 | TextLabel3_3->show(); |
354 | SpinBoxNtpDelay->show(); | 354 | SpinBoxNtpDelay->show(); |
355 | Line1->show(); | ||
355 | }else{ | 356 | }else{ |
356 | TabWidgetMain->removePage( tabPredict ); | 357 | TabWidgetMain->removePage( tabPredict ); |
357 | TabWidgetMain->removePage( tabNtp ); | 358 | TabWidgetMain->removePage( tabNtp ); |
358 | TextLabel1_2_2->hide(); | 359 | TextLabel1_2_2->hide(); |
359 | TextLabel2_3->hide(); | 360 | TextLabel2_3->hide(); |
360 | TextLabel3_3_2->hide(); | 361 | TextLabel3_3_2->hide(); |
361 | TextLabel1_2->hide(); | 362 | TextLabel1_2->hide(); |
362 | SpinBoxMinLookupDelay->hide(); | 363 | SpinBoxMinLookupDelay->hide(); |
363 | TextLabel2->hide(); | 364 | TextLabel2->hide(); |
364 | TextLabel3_3->hide(); | 365 | TextLabel3_3->hide(); |
365 | SpinBoxNtpDelay->hide(); | 366 | SpinBoxNtpDelay->hide(); |
367 | Line1->hide(); | ||
366 | }; | 368 | }; |
369 | TabWidgetMain->show(); | ||
367 | } | 370 | } |