summaryrefslogtreecommitdiff
path: root/noncore/settings/netsystemtime/ntp.cpp
Side-by-side diff
Diffstat (limited to 'noncore/settings/netsystemtime/ntp.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/settings/netsystemtime/ntp.cpp45
1 files changed, 40 insertions, 5 deletions
diff --git a/noncore/settings/netsystemtime/ntp.cpp b/noncore/settings/netsystemtime/ntp.cpp
index fbd65a2..6f6316c 100644
--- a/noncore/settings/netsystemtime/ntp.cpp
+++ b/noncore/settings/netsystemtime/ntp.cpp
@@ -1,21 +1,24 @@
#include "ntp.h"
#include <qpushbutton.h>
#include <qregexp.h>
#include <qtimer.h>
#include <qtable.h>
#include <qlabel.h>
#include <qsocket.h>
#include <qlineedit.h>
#include <qspinbox.h>
+#include <qcheckbox.h>
+#include <qtabwidget.h>
+#include <qlayout.h>
#include <qmessagebox.h>
#include <qmultilineedit.h>
#include <opie/oprocess.h>
#include <qpe/qpeapplication.h>
#include <qpe/config.h>
#include <qpe/global.h>
#include <qpe/timeconversion.h>
#include <qpe/tzselect.h>
#include <qpe/timestring.h>
#include <qpe/qpedialog.h>
#include <qpe/datebookdb.h>
#include <qpe/qcopenvelope_qws.h>
@@ -30,28 +33,34 @@ 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",41) );
- SpinBoxNtpDelay->setValue( cfg.readNumEntry("ntpRefreshFreq",42) );
+ 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();
@@ -133,25 +142,25 @@ void Ntp::getNtpOutput(OProcess *proc, char *buffer, int buflen)
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();
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;
@@ -268,34 +277,33 @@ void Ntp::slotCheckNtp(int i)
connect( ButtonSetTime, SIGNAL(clicked()), SLOT(slotRunNtp()) );
if ( ntpDelayElapsed() )
{
slotRunNtp();
disconnect(ntpTimer, SIGNAL( timeout() ), this, SLOT(slotProbeNtpServer()) );
connect(ntpTimer, SIGNAL( timeout() ), SLOT(slotRunNtp()) );
}else{
disconnect(ntpTimer, SIGNAL( timeout() ), this, SLOT(slotRunNtp()) );
connect(ntpTimer, SIGNAL( timeout() ), SLOT(slotProbeNtpServer()) );
}
}else{
preditctTime();
- ButtonSetTime->setText( tr("Set predicted time") );
+ ButtonSetTime->setText( tr("Set predicted time: ")+predictedTime.toString() );
if (i>0)ntpOutPut(tr("Could not connect to server ")+getNtpServer());
connect( ButtonSetTime, SIGNAL(clicked()), SLOT(setPredictTime()) );
connect( ntpTimer, SIGNAL( timeout() ), SLOT(slotProbeNtpServer()) );
}
}
void Ntp::slotProbeNtpServer()
{
- qDebug("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);
@@ -321,12 +329,39 @@ void Ntp::receive(const QCString &msg, const QByteArray &arg)
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();
+ }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();
+ };
+}