author | tille <tille> | 2002-10-21 21:52:48 (UTC) |
---|---|---|
committer | tille <tille> | 2002-10-21 21:52:48 (UTC) |
commit | 5bcd4ccebd86f912c693de16675da44d21e11d94 (patch) (side-by-side diff) | |
tree | 069d23db3e886319f0a76071609d11b814bd4bfb | |
parent | 21d29dbf8a9c1a12c7c23f96b80307e87ffaa50a (diff) | |
download | opie-5bcd4ccebd86f912c693de16675da44d21e11d94.zip opie-5bcd4ccebd86f912c693de16675da44d21e11d94.tar.gz opie-5bcd4ccebd86f912c693de16675da44d21e11d94.tar.bz2 |
saves feature settings now
-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 @@ -33,111 +33,111 @@ Ntp::Ntp( QWidget* parent, const char* name, WFlags fl ) Config ntpSrvs(QPEApplication::qpeDir()+"etc/ntpservers",Config::File); ntpSrvs.setGroup("servers"); int srvCount = ntpSrvs.readNumEntry("count", 0 ); for (int i = 0; i < srvCount; i++) { ntpSrvs.setGroup(QString::number(i)); ComboNtpSrv->insertItem( ntpSrvs.readEntry("name") ); } if ( srvCount==0 ) ComboNtpSrv->insertItem(tr("time.fu-berlin.de")); Config cfg("ntp",Config::User); cfg.setGroup("settings"); SpinBoxMinLookupDelay->setValue( cfg.readNumEntry("minLookupDiff",720) ); SpinBoxNtpDelay->setValue( cfg.readNumEntry("ntpRefreshFreq",1440) ); ComboNtpSrv->setCurrentItem( cfg.readNumEntry("ntpServer", 0) ); bool advMode = cfg.readBoolEntry("advancedFeatures", false ); showAdvancedFeatures(advMode); CheckBoxAdvSettings->setChecked( advMode ); connect( CheckBoxAdvSettings, SIGNAL( toggled( bool ) ), SLOT( showAdvancedFeatures( bool ) ) ); makeChannel(); ntpTimer = new QTimer(this); ntpProcess = new OProcess( ); connect( SpinBoxNtpDelay, SIGNAL( valueChanged(int) ), SLOT(slotNtpDelayChanged(int)) ); ntpSock = new QSocket( this ); connect( ntpSock, SIGNAL( error(int) ), SLOT(slotCheckNtp(int)) ); slotProbeNtpServer(); connect ( ntpProcess, SIGNAL(receivedStdout(OProcess*,char*,int)), this, SLOT(getNtpOutput(OProcess*,char*,int))); connect ( ntpProcess, SIGNAL(processExited(OProcess*)), this, SLOT(ntpFinished(OProcess*))); connect(runNtp, SIGNAL(clicked()), this, SLOT(slotRunNtp())); connect(PushButtonPredict, SIGNAL(clicked()), this, SLOT(preditctTime())); connect(PushButtonSetPredTime, SIGNAL(clicked()), this, SLOT(setPredictTime())); slotCheckNtp(-1); readLookups(); } Ntp::~Ntp() { - delete ntpProcess; - Config ntpSrvs("/etc/ntpservers",Config::File); + delete ntpProcess; + Config ntpSrvs("/etc/ntpservers",Config::File); ntpSrvs.setGroup("servers"); int srvCount = ComboNtpSrv->count(); ntpSrvs.writeEntry("count", srvCount); - for (int i = 0; i < srvCount; i++) - { - ntpSrvs.setGroup(QString::number(i)); - ntpSrvs.writeEntry( "name", ComboNtpSrv->text(i) ); + for (int i = 0; i < srvCount; i++){ + ntpSrvs.setGroup(QString::number(i)); + ntpSrvs.writeEntry( "name", ComboNtpSrv->text(i) ); } - Config cfg("ntp",Config::User); + Config cfg("ntp",Config::User); cfg.setGroup("settings"); cfg.writeEntry("ntpServer", ComboNtpSrv->currentItem()); cfg.writeEntry( "minLookupDiff", SpinBoxMinLookupDelay->value() ); - cfg.writeEntry( "ntpRefreshFreq", SpinBoxNtpDelay->value() ); + cfg.writeEntry( "ntpRefreshFreq", SpinBoxNtpDelay->value() ); + cfg.writeEntry( "advancedFeatures", CheckBoxAdvSettings->isChecked() ); } bool Ntp::ntpDelayElapsed() { Config cfg("ntp",Config::User); cfg.setGroup("lookups"); _lookupDiff = TimeConversion::toUTC(QDateTime::currentDateTime()) - cfg.readNumEntry("time",0); return (_lookupDiff - (SpinBoxNtpDelay->value()*60)) > -60; } QString Ntp::getNtpServer() { return ComboNtpSrv->currentText(); } void Ntp::slotRunNtp() { if ( !ntpDelayElapsed() ) { switch ( QMessageBox::warning(this, tr("Run NTP?"), tr("You asked for a delay of ")+SpinBoxNtpDelay->text()+tr(" minutes, but only ")+ QString::number(_lookupDiff/60)+tr(" minutes elapsed since last lookup.")+ "<br>"+tr("Rerun NTP?"), QMessageBox::Ok,QMessageBox::Cancel) ) { case QMessageBox::Ok: break; case QMessageBox::Cancel: return; default: return; } } TextLabelStartTime->setText(QDateTime::currentDateTime().toString()); ntpOutPut( tr("Running:")+"\nntpdate "+getNtpServer() ); ntpProcess->clearArguments(); *ntpProcess << "ntpdate" << getNtpServer(); bool ret = ntpProcess->start(OProcess::NotifyOnExit,OProcess::AllOutput); if ( !ret ) { qDebug("Error while executing ntpdate"); ntpOutPut( tr("Error while executing ntpdate")); } } void Ntp::getNtpOutput(OProcess *proc, char *buffer, int buflen) { QString lineStr, lineStrOld; lineStr = buffer; lineStr=lineStr.left(buflen); @@ -307,61 +307,64 @@ void Ntp::ntpOutPut(QString out) { MultiLineEditntpOutPut->append(out); MultiLineEditntpOutPut->setCursorPosition(MultiLineEditntpOutPut->numLines() + 1,0,FALSE); } void Ntp::makeChannel() { channel = new QCopChannel( "QPE/Application/netsystemtime", this ); connect( channel, SIGNAL(received(const QCString&, const QByteArray&)), this, SLOT(receive(const QCString&, const QByteArray&)) ); } void Ntp::receive(const QCString &msg, const QByteArray &arg) { qDebug("QCop(Ntp) "+msg+" "+QCString(arg)); if ( msg == "ntpLookup(QString)" ) { slotRunNtp(); } if ( msg == "setPredictedTime(QString)" ) { setPredictTime(); }else{ qDebug("Ntp::receive: Huh what do ya want"); } } void Ntp::setDocument(const QString &fileName) { } void Ntp::showAdvancedFeatures(bool advMode) { if (advMode) { TabWidgetMain->addTab( tabPredict, tr( "Predict" ) ); TabWidgetMain->addTab( tabNtp, tr( "NTP" ) ); TextLabel1_2_2->show(); TextLabel2_3->show(); TextLabel3_3_2->show(); TextLabel1_2->show(); SpinBoxMinLookupDelay->show(); TextLabel2->show(); TextLabel3_3->show(); SpinBoxNtpDelay->show(); + Line1->show(); }else{ TabWidgetMain->removePage( tabPredict ); TabWidgetMain->removePage( tabNtp ); TextLabel1_2_2->hide(); TextLabel2_3->hide(); TextLabel3_3_2->hide(); TextLabel1_2->hide(); SpinBoxMinLookupDelay->hide(); TextLabel2->hide(); TextLabel3_3->hide(); SpinBoxNtpDelay->hide(); + Line1->hide(); }; + TabWidgetMain->show(); } |