summaryrefslogtreecommitdiff
path: root/noncore/settings/netsystemtime/ntp.cpp
Side-by-side diff
Diffstat (limited to 'noncore/settings/netsystemtime/ntp.cpp') (more/less context) (show whitespace changes)
-rw-r--r--noncore/settings/netsystemtime/ntp.cpp36
1 files changed, 32 insertions, 4 deletions
diff --git a/noncore/settings/netsystemtime/ntp.cpp b/noncore/settings/netsystemtime/ntp.cpp
index 40805a0..111f7d4 100644
--- a/noncore/settings/netsystemtime/ntp.cpp
+++ b/noncore/settings/netsystemtime/ntp.cpp
@@ -37,24 +37,41 @@ Ntp::Ntp( QWidget* parent, const char* name, WFlags fl )
{
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) );
+ //make tab order
+
+ TabWidgetMain->removePage( tabMain );
+ TabWidgetMain->removePage( tabManualSetTime );
+ TabWidgetMain->removePage( TabSettings );
+ TabWidgetMain->removePage( tabPredict );
+ TabWidgetMain->removePage( tabNtp );
+
+ TabWidgetMain->insertTab( tabMain, tr( "Main" ) );
+ TabWidgetMain->insertTab( tabManualSetTime, tr( "Manual" ) );
+ TabWidgetMain->insertTab( TabSettings, tr( "Settings" ) );
+ TabWidgetMain->insertTab( tabPredict, tr( "Predict" ) );
+ TabWidgetMain->insertTab( tabNtp, tr( "NTP" ) );
+ NtpBaseLayout->addWidget( TabWidgetMain, 0, 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) ),
@@ -103,69 +120,78 @@ bool Ntp::ntpDelayElapsed()
if (_lookupDiff < 0) return true;
int i =_lookupDiff - (SpinBoxNtpDelay->value()*60);
return i > -60;
}
QString Ntp::getNtpServer()
{
return ComboNtpSrv->currentText();
}
void Ntp::slotRunNtp()
{
- if ( !ntpDelayElapsed() )
+ if ( !ntpDelayElapsed() && CheckBoxAdvSettings->isChecked() )
{
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 ) {
+ QMessageBox::critical(this, tr("ntp error"),
+ tr("Error while getting time form network!"));
qDebug("Error while executing ntpdate");
ntpOutPut( tr("Error while executing ntpdate"));
}
}
void Ntp::getNtpOutput(OProcess *proc, char *buffer, int buflen)
{
+ if (! proc ) qDebug("Ntp::getNtpOutput OProcess is null");
QString lineStr, lineStrOld;
lineStr = buffer;
lineStr=lineStr.left(buflen);
if (lineStr!=lineStrOld)
{
ntpOutPut(lineStr);
_ntpOutput += lineStr;
}
lineStrOld = lineStr;
}
void Ntp::ntpFinished(OProcess *p)
{
- // qDebug("p->exitStatus() %i",p->exitStatus());
+ qDebug("p->exitStatus() %i",p->exitStatus());
if (p->exitStatus()!=0 || !p->normalExit())
{
- slotProbeNtpServer();
+ QMessageBox::critical(this, tr("ntp error"),
+ tr("Error while getting time form\n server")+
+ getNtpServer()+"\n"+
+ _ntpOutput );
+ // TabWidgetMain->setCurrentPage( 1 );
+ TabWidgetMain->showPage( tabManualSetTime );
+
return;
}
Global::writeHWClock();
// since time has changed quickly load in the datebookdb
// to allow the alarm server to get a better grip on itself
// (example re-trigger alarms for when we travel back in time)
DateBookDB db;
// QCopEnvelope timeApplet( "QPE/TaskBar", "reloadApplets()" );
// timeApplet << "";
@@ -298,24 +324,25 @@ void Ntp::slotCheckNtp(int i)
void Ntp::slotProbeNtpServer()
{
ntpSock->connectToHost( getNtpServer() ,123);
}
void Ntp::slotNtpDelayChanged(int delay)
{
ntpTimer->changeInterval( delay*1000*60 );
}
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&)) );
}
@@ -329,30 +356,31 @@ void Ntp::receive(const QCString &msg, const QByteArray &arg)
slotRunNtp();
}
if ( msg == "setPredictedTime(QString)" )
{
setPredictTime();
}else{
qDebug("Ntp::receive: Huh what do ya want");
}
}
void Ntp::setDocument(const QString &fileName)
{
-
+ qDebug("Ntp::setDocument( %s )",fileName.latin1());
}
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{