author | drw <drw> | 2004-02-22 16:43:28 (UTC) |
---|---|---|
committer | drw <drw> | 2004-02-22 16:43:28 (UTC) |
commit | a607c211c7ad47f1083fa820da5632a1d2110e44 (patch) (side-by-side diff) | |
tree | 364b2e0cd0e80d409ad4462e00c5b510eb75744a | |
parent | 58c4c8a50f2a30f5736ee53fdd46c3bf6bc4f8c4 (diff) | |
download | opie-a607c211c7ad47f1083fa820da5632a1d2110e44.zip opie-a607c211c7ad47f1083fa820da5632a1d2110e44.tar.gz opie-a607c211c7ad47f1083fa820da5632a1d2110e44.tar.bz2 |
System Time: libopie->libopie2
-rw-r--r-- | noncore/settings/netsystemtime/config.in | 2 | ||||
-rw-r--r-- | noncore/settings/netsystemtime/main.cpp | 4 | ||||
-rw-r--r-- | noncore/settings/netsystemtime/mainwindow.cpp | 543 | ||||
-rw-r--r-- | noncore/settings/netsystemtime/mainwindow.h | 75 | ||||
-rw-r--r-- | noncore/settings/netsystemtime/netsystemtime.pro | 36 | ||||
-rw-r--r-- | noncore/settings/netsystemtime/opie-systemtime.control | 2 |
6 files changed, 330 insertions, 332 deletions
diff --git a/noncore/settings/netsystemtime/config.in b/noncore/settings/netsystemtime/config.in index ea90f65..37ac303 100644 --- a/noncore/settings/netsystemtime/config.in +++ b/noncore/settings/netsystemtime/config.in @@ -3,2 +3,2 @@ default "y" - depends ( LIBQPE || LIBQPE-X11 ) && LIBOPIE + depends ( LIBQPE || LIBQPE-X11 ) && LIBOPIE2CORE && LIBOPIE2UI diff --git a/noncore/settings/netsystemtime/main.cpp b/noncore/settings/netsystemtime/main.cpp index da98eee..4a2d17c 100644 --- a/noncore/settings/netsystemtime/main.cpp +++ b/noncore/settings/netsystemtime/main.cpp @@ -30,5 +30,3 @@ -#include <qpe/qpeapplication.h> -#include <opie/oapplicationfactory.h> - +#include <opie2/oapplicationfactory.h> diff --git a/noncore/settings/netsystemtime/mainwindow.cpp b/noncore/settings/netsystemtime/mainwindow.cpp index 66e1ca3..7df41d4 100644 --- a/noncore/settings/netsystemtime/mainwindow.cpp +++ b/noncore/settings/netsystemtime/mainwindow.cpp @@ -35,5 +35,2 @@ -#include <opie/oprocess.h> -#include <opie/otabwidget.h> - #include <qpe/config.h> @@ -54,62 +51,62 @@ MainWindow::MainWindow( QWidget *parent , const char *name, bool modal, WFlags f ) - : QDialog( 0x0, 0x0, TRUE, 0 ) + : QDialog( 0x0, 0x0, TRUE, 0 ) { - setCaption( tr( "SystemTime" ) ); - - QVBoxLayout *layout = new QVBoxLayout( this ); - layout->setMargin( 2 ); - layout->setSpacing( 4 ); - - // Create main tabbed control - mainWidget = new OTabWidget( this ); - - // Default object pointers to null - ntpProcess = 0x0; - ntpTab = 0x0; - - // Add tab widgets - mainWidget->addTab( timeTab = new TimeTabWidget( mainWidget ), "netsystemtime/DateTime", tr( "Time" ) ); - mainWidget->addTab( formatTab = new FormatTabWidget( mainWidget ), "netsystemtime/formattab", tr( "Format" ) ); - mainWidget->addTab( settingsTab = new SettingsTabWidget( mainWidget ), "SettingsIcon", tr( "Settings" ) ); - mainWidget->addTab( predictTab = new PredictTabWidget( mainWidget ), "netsystemtime/predicttab", tr( "Predict" ) ); - Config config( "ntp" ); - config.setGroup( "settings" ); - slotDisplayNTPTab( config.readBoolEntry( "displayNtpTab", FALSE ) ); - slotDisplayPredictTab( config.readBoolEntry( "displayPredictTab", FALSE ) ); - - mainWidget->setCurrentTab( tr( "Time" ) ); - layout->addWidget( mainWidget ); - - connect( qApp, SIGNAL(appMessage(const QCString&, const QByteArray&)), - this, SLOT(slotQCopReceive(const QCString&, const QByteArray&)) ); - - - // Create NTP socket - ntpSock = new QSocket( this ); - connect( ntpSock, SIGNAL(error(int)),SLOT(slotCheckNtp(int)) ); - slotProbeNTPServer(); - - // Create timer for automatic time lookups - ntpTimer = new QTimer( this ); - - // Connect everything together - connect( timeTab, SIGNAL(getNTPTime()), this, SLOT(slotGetNTPTime()) ); - connect( timeTab, SIGNAL(tzChanged(const QString &)), predictTab, SLOT(slotTZChanged(const QString &)) ); - connect( timeTab, SIGNAL(getPredictedTime()), predictTab, SLOT(slotSetPredictedTime()) ); - connect( formatTab, SIGNAL(show12HourTime(int)), timeTab, SLOT(slotUse12HourTime( int )) ); - connect( formatTab, SIGNAL(dateFormatChanged(const DateFormat &)), - timeTab, SLOT(slotDateFormatChanged(const DateFormat &)) ); - connect( formatTab, SIGNAL(weekStartChanged(int)), timeTab, SLOT(slotWeekStartChanged(int)) ); - connect( settingsTab, SIGNAL(ntpDelayChanged(int)), this, SLOT(slotNTPDelayChanged(int)) ); - connect( settingsTab, SIGNAL(displayNTPTab(bool)), this, SLOT(slotDisplayNTPTab(bool)) ); - connect( settingsTab, SIGNAL(displayPredictTab(bool)), this, SLOT(slotDisplayPredictTab(bool)) ); - connect( predictTab, SIGNAL(setTime(const QDateTime &)), this, SLOT(slotSetTime(const QDateTime &)) ); - - // Do initial time server check - slotNTPDelayChanged( config.readNumEntry( "ntpRefreshFreq", 1440 ) ); - slotCheckNtp( -1 ); - - // Display app - //showMaximized(); - (void)new QPEDialogListener(this); + setCaption( tr( "SystemTime" ) ); + + QVBoxLayout *layout = new QVBoxLayout( this ); + layout->setMargin( 2 ); + layout->setSpacing( 4 ); + + // Create main tabbed control + mainWidget = new OTabWidget( this ); + + // Default object pointers to null + ntpProcess = 0x0; + ntpTab = 0x0; + + // Add tab widgets + mainWidget->addTab( timeTab = new TimeTabWidget( mainWidget ), "netsystemtime/DateTime", tr( "Time" ) ); + mainWidget->addTab( formatTab = new FormatTabWidget( mainWidget ), "netsystemtime/formattab", tr( "Format" ) ); + mainWidget->addTab( settingsTab = new SettingsTabWidget( mainWidget ), "SettingsIcon", tr( "Settings" ) ); + mainWidget->addTab( predictTab = new PredictTabWidget( mainWidget ), "netsystemtime/predicttab", tr( "Predict" ) ); + Config config( "ntp" ); + config.setGroup( "settings" ); + slotDisplayNTPTab( config.readBoolEntry( "displayNtpTab", FALSE ) ); + slotDisplayPredictTab( config.readBoolEntry( "displayPredictTab", FALSE ) ); + + mainWidget->setCurrentTab( tr( "Time" ) ); + layout->addWidget( mainWidget ); + + connect( qApp, SIGNAL(appMessage(const QCString&, const QByteArray&)), + this, SLOT(slotQCopReceive(const QCString&, const QByteArray&)) ); + + + // Create NTP socket + ntpSock = new QSocket( this ); + connect( ntpSock, SIGNAL(error(int)),SLOT(slotCheckNtp(int)) ); + slotProbeNTPServer(); + + // Create timer for automatic time lookups + ntpTimer = new QTimer( this ); + + // Connect everything together + connect( timeTab, SIGNAL(getNTPTime()), this, SLOT(slotGetNTPTime()) ); + connect( timeTab, SIGNAL(tzChanged(const QString &)), predictTab, SLOT(slotTZChanged(const QString &)) ); + connect( timeTab, SIGNAL(getPredictedTime()), predictTab, SLOT(slotSetPredictedTime()) ); + connect( formatTab, SIGNAL(show12HourTime(int)), timeTab, SLOT(slotUse12HourTime( int )) ); + connect( formatTab, SIGNAL(dateFormatChanged(const DateFormat &)), + timeTab, SLOT(slotDateFormatChanged(const DateFormat &)) ); + connect( formatTab, SIGNAL(weekStartChanged(int)), timeTab, SLOT(slotWeekStartChanged(int)) ); + connect( settingsTab, SIGNAL(ntpDelayChanged(int)), this, SLOT(slotNTPDelayChanged(int)) ); + connect( settingsTab, SIGNAL(displayNTPTab(bool)), this, SLOT(slotDisplayNTPTab(bool)) ); + connect( settingsTab, SIGNAL(displayPredictTab(bool)), this, SLOT(slotDisplayPredictTab(bool)) ); + connect( predictTab, SIGNAL(setTime(const QDateTime &)), this, SLOT(slotSetTime(const QDateTime &)) ); + + // Do initial time server check + slotNTPDelayChanged( config.readNumEntry( "ntpRefreshFreq", 1440 ) ); + slotCheckNtp( -1 ); + + // Display app + //showMaximized(); + (void)new QPEDialogListener(this); } @@ -118,4 +115,4 @@ MainWindow::~MainWindow() { - if ( ntpProcess ) - delete ntpProcess; + if ( ntpProcess ) + delete ntpProcess; } @@ -124,27 +121,27 @@ void MainWindow::accept() { - // Turn off the screensaver (Note: needs to be encased in { } so that it deconstructs and sends) - { - QCopEnvelope disableScreenSaver( "QPE/System", "setScreenSaverIntervals(int,int,int)" ); - disableScreenSaver << 0 << 0 << 0; - } + // Turn off the screensaver (Note: needs to be encased in { } so that it deconstructs and sends) + { + QCopEnvelope disableScreenSaver( "QPE/System", "setScreenSaverIntervals(int,int,int)" ); + disableScreenSaver << 0 << 0 << 0; + } - // Update the systemtime - timeTab->saveSettings( TRUE ); + // Update the systemtime + timeTab->saveSettings( TRUE ); - // Save format options - formatTab->saveSettings( TRUE ); + // Save format options + formatTab->saveSettings( TRUE ); - // Save settings options - settingsTab->saveSettings(); + // Save settings options + settingsTab->saveSettings(); - // 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; + // 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; - // Turn back on the screensaver - QCopEnvelope enableScreenSaver( "QPE/System", "setScreenSaverIntervals(int,int,int)" ); - enableScreenSaver << -1 << -1 << -1; + // Turn back on the screensaver + QCopEnvelope enableScreenSaver( "QPE/System", "setScreenSaverIntervals(int,int,int)" ); + enableScreenSaver << -1 << -1 << -1; - // Exit app - qApp->quit(); + // Exit app + qApp->quit(); } @@ -153,10 +150,10 @@ void MainWindow::reject() { - // Reset time settings - timeTab->saveSettings( FALSE ); + // Reset time settings + timeTab->saveSettings( FALSE ); - // Send notifications but do not save settings - formatTab->saveSettings( FALSE ); + // Send notifications but do not save settings + formatTab->saveSettings( FALSE ); - // Exit app - qApp->quit(); + // Exit app + qApp->quit(); } @@ -165,47 +162,47 @@ void MainWindow::runNTP() { - if ( !ntpDelayElapsed() && ntpInteractive ) - { - QString msg = tr( "You asked for a delay of %1 minutes, but only %2 minutes elapsed since last lookup.<br>Continue?" ).arg( QString::number( ntpDelay ) ).arg( QString::number( _lookupDiff / 60 ) ); - - switch ( - QMessageBox::warning( this, tr( "Continue?" ), msg, QMessageBox::Yes, QMessageBox::No ) - ) - { - case QMessageBox::Yes: break; - case QMessageBox::No: return; - default: return; - } - } - - QString srv = settingsTab->ntpServer(); - - // Send information to time server tab if enabled - if ( ntpTabEnabled ) - { - ntpTab->setStartTime( QDateTime::currentDateTime().toString() ); - QString output = tr( "Running:\nntpdate " ); - output.append( srv ); - ntpTab->addNtpOutput( output ); - } - - if ( !ntpProcess ) - { - ntpProcess = new OProcess(); - connect( ntpProcess, SIGNAL(receivedStdout(OProcess*,char*,int)), - this, SLOT(slotNtpOutput(OProcess*,char*,int)) ); - connect( ntpProcess, SIGNAL(processExited(OProcess*)), - this, SLOT(slotNtpFinished(OProcess*)) ); - } - - else - ntpProcess->clearArguments(); - - *ntpProcess << "ntpdate" << srv; - bool ret = ntpProcess->start( OProcess::NotifyOnExit, OProcess::AllOutput ); - if ( !ret ) - { - QMessageBox::critical( this, tr( "Error" ), tr( "Error while getting time from network." ) ); - if ( ntpTabEnabled ) - ntpTab->addNtpOutput( tr( "Error while executing ntpdate" ) ); - } + if ( !ntpDelayElapsed() && ntpInteractive ) + { + QString msg = tr( "You asked for a delay of %1 minutes, but only %2 minutes elapsed since last lookup.<br>Continue?" ).arg( QString::number( ntpDelay ) ).arg( QString::number( _lookupDiff / 60 ) ); + + switch ( + QMessageBox::warning( this, tr( "Continue?" ), msg, QMessageBox::Yes, QMessageBox::No ) + ) + { + case QMessageBox::Yes: break; + case QMessageBox::No: return; + default: return; + } + } + + QString srv = settingsTab->ntpServer(); + + // Send information to time server tab if enabled + if ( ntpTabEnabled ) + { + ntpTab->setStartTime( QDateTime::currentDateTime().toString() ); + QString output = tr( "Running:\nntpdate " ); + output.append( srv ); + ntpTab->addNtpOutput( output ); + } + + if ( !ntpProcess ) + { + ntpProcess = new OProcess(); + connect( ntpProcess, SIGNAL(receivedStdout(OProcess*,char*,int)), + this, SLOT(slotNtpOutput(OProcess*,char*,int)) ); + connect( ntpProcess, SIGNAL(processExited(OProcess*)), + this, SLOT(slotNtpFinished(OProcess*)) ); + } + + else + ntpProcess->clearArguments(); + + *ntpProcess << "ntpdate" << srv; + bool ret = ntpProcess->start( OProcess::NotifyOnExit, OProcess::AllOutput ); + if ( !ret ) + { + QMessageBox::critical( this, tr( "Error" ), tr( "Error while getting time from network." ) ); + if ( ntpTabEnabled ) + ntpTab->addNtpOutput( tr( "Error while executing ntpdate" ) ); + } } @@ -214,9 +211,9 @@ bool MainWindow::ntpDelayElapsed() { - // Determine if time elapsed is greater than time delay - Config config( "ntp" ); - config.setGroup( "lookups" ); - _lookupDiff = TimeConversion::toUTC( QDateTime::currentDateTime() ) - config.readNumEntry( "time", 0 ); - if ( _lookupDiff < 0 ) - return true; - return ( _lookupDiff - ( ntpDelay * 60) ) > 0; + // Determine if time elapsed is greater than time delay + Config config( "ntp" ); + config.setGroup( "lookups" ); + _lookupDiff = TimeConversion::toUTC( QDateTime::currentDateTime() ) - config.readNumEntry( "time", 0 ); + if ( _lookupDiff < 0 ) + return true; + return ( _lookupDiff - ( ntpDelay * 60) ) > 0; } @@ -225,3 +222,3 @@ void MainWindow::slotSetTime( const QDateTime &dt ) { - timeTab->setDateTime( dt ); + timeTab->setDateTime( dt ); } @@ -230,11 +227,11 @@ void MainWindow::slotQCopReceive( const QCString &msg, const QByteArray & ) { - if ( msg == "ntpLookup(QString)" ) - { - ntpInteractive = false; - runNTP(); - } - if ( msg == "setPredictedTime(QString)" ) - { - //setPredictTime(); - } + if ( msg == "ntpLookup(QString)" ) + { + ntpInteractive = false; + runNTP(); + } + if ( msg == "setPredictedTime(QString)" ) + { + //setPredictTime(); + } } @@ -243,14 +240,14 @@ void MainWindow::slotDisplayNTPTab( bool display ) { - ntpTabEnabled = display; - - // Create widget if it hasn't needed - if ( display && !ntpTab ) - { - ntpTab = new NTPTabWidget( mainWidget ); - connect( ntpTab, SIGNAL(getNTPTime()), this, SLOT(slotGetNTPTime()) ); - } - - // Display/hide tab - display ? mainWidget->addTab( ntpTab, "netsystemtime/ntptab", tr( "Time Server" ) ) - : mainWidget->removePage( ntpTab ); + ntpTabEnabled = display; + + // Create widget if it hasn't needed + if ( display && !ntpTab ) + { + ntpTab = new NTPTabWidget( mainWidget ); + connect( ntpTab, SIGNAL(getNTPTime()), this, SLOT(slotGetNTPTime()) ); + } + + // Display/hide tab + display ? mainWidget->addTab( ntpTab, "netsystemtime/ntptab", tr( "Time Server" ) ) + : mainWidget->removePage( ntpTab ); } @@ -259,11 +256,11 @@ void MainWindow::slotDisplayPredictTab( bool display ) { - predictTabEnabled = display; - - // Create widget if it hasn't needed - if ( display && !predictTab ) - { - } - // Display/hide tab - display ? mainWidget->addTab( predictTab, "netsystemtime/predicttab", tr( "Predict" ) ) - : mainWidget->removePage( predictTab ); + predictTabEnabled = display; + + // Create widget if it hasn't needed + if ( display && !predictTab ) + { + } + // Display/hide tab + display ? mainWidget->addTab( predictTab, "netsystemtime/predicttab", tr( "Predict" ) ) + : mainWidget->removePage( predictTab ); } @@ -272,4 +269,4 @@ void MainWindow::slotGetNTPTime() { - ntpInteractive = TRUE; - runNTP(); + ntpInteractive = TRUE; + runNTP(); } @@ -278,4 +275,4 @@ void MainWindow::slotTimerGetNTPTime() { - ntpInteractive = FALSE; - runNTP(); + ntpInteractive = FALSE; + runNTP(); } @@ -284,3 +281,3 @@ void MainWindow::slotProbeNTPServer() { - ntpSock->connectToHost( settingsTab->ntpServer(), 123 ); + ntpSock->connectToHost( settingsTab->ntpServer(), 123 ); } @@ -289,7 +286,7 @@ void MainWindow::slotNtpOutput( OProcess *, char *buffer, int buflen ) { - QString output = QString( buffer ).left( buflen ); - ntpOutput.append( output ); + QString output = QString( buffer ).left( buflen ); + ntpOutput.append( output ); - if ( ntpTabEnabled ) - ntpTab->addNtpOutput( output ); + if ( ntpTabEnabled ) + ntpTab->addNtpOutput( output ); } @@ -298,65 +295,65 @@ void MainWindow::slotNtpFinished( OProcess *p ) { - QString output; - QDateTime dt = QDateTime::currentDateTime(); - - // Verify run was successful - if ( p->exitStatus() != 0 || !p->normalExit() ) - { - if ( isVisible() && ntpInteractive ) - { - output = tr( "Error while getting time from\n server: " ); - output.append( settingsTab->ntpServer() ); - QMessageBox::critical(this, tr( "Error" ), output ); - } - // slotCheckNtp(-1); - return; - } - - // Set controls on time tab to new time value - timeTab->setDateTime( dt ); - - // Write out lookup information - Config config( "ntp" ); - config.setGroup( "lookups" ); - int lastLookup = config.readNumEntry( "time", 0 ); - int lookupCount = config.readNumEntry( "count", 0 ); - bool lastNtp = config.readBoolEntry( "lastNtp", FALSE ); - int time = TimeConversion::toUTC( QDateTime::currentDateTime() ); - config.writeEntry( "time", time ); - - // Calculate new time/time shift - QString _offset = "offset"; - QString _sec = "sec"; - QRegExp _reOffset = QRegExp( _offset ); - QRegExp _reEndOffset = QRegExp( _sec ); - int posOffset = _reOffset.match( ntpOutput ); - int posEndOffset = _reEndOffset.match( ntpOutput, posOffset ); - posOffset += _offset.length() + 1; - QString diff = ntpOutput.mid( posOffset, posEndOffset - posOffset - 1 ); - - float timeShift = diff.toFloat(); - if ( timeShift == 0.0 ) - return; - int secsSinceLast = time - lastLookup; - output = tr( "%1 seconds").arg(QString::number( timeShift )); - - // Display information on time server tab - if ( ntpTabEnabled ) - { - ntpTab->setTimeShift( output ); - ntpTab->setNewTime( dt.toString() ); - } - - if ( lastNtp && lastLookup > 0 && secsSinceLast > 60 * ntpDelay ) - { - QString grpname = QString( "lookup_" ).append( QString::number( lookupCount ) ); - config.setGroup( grpname ); - lookupCount++; - predictTab->setShiftPerSec( timeShift / secsSinceLast ); - config.writeEntry( "secsSinceLast", secsSinceLast ); - config.writeEntry( "timeShift", QString::number( timeShift ) ); - config.setGroup( "lookups" ); - config.writeEntry( "count", lookupCount ); - config.writeEntry( "lastNtp", TRUE ); - } + QString output; + QDateTime dt = QDateTime::currentDateTime(); + + // Verify run was successful + if ( p->exitStatus() != 0 || !p->normalExit() ) + { + if ( isVisible() && ntpInteractive ) + { + output = tr( "Error while getting time from\n server: " ); + output.append( settingsTab->ntpServer() ); + QMessageBox::critical(this, tr( "Error" ), output ); + } + // slotCheckNtp(-1); + return; + } + + // Set controls on time tab to new time value + timeTab->setDateTime( dt ); + + // Write out lookup information + Config config( "ntp" ); + config.setGroup( "lookups" ); + int lastLookup = config.readNumEntry( "time", 0 ); + int lookupCount = config.readNumEntry( "count", 0 ); + bool lastNtp = config.readBoolEntry( "lastNtp", FALSE ); + int time = TimeConversion::toUTC( QDateTime::currentDateTime() ); + config.writeEntry( "time", time ); + + // Calculate new time/time shift + QString _offset = "offset"; + QString _sec = "sec"; + QRegExp _reOffset = QRegExp( _offset ); + QRegExp _reEndOffset = QRegExp( _sec ); + int posOffset = _reOffset.match( ntpOutput ); + int posEndOffset = _reEndOffset.match( ntpOutput, posOffset ); + posOffset += _offset.length() + 1; + QString diff = ntpOutput.mid( posOffset, posEndOffset - posOffset - 1 ); + + float timeShift = diff.toFloat(); + if ( timeShift == 0.0 ) + return; + int secsSinceLast = time - lastLookup; + output = tr( "%1 seconds").arg(QString::number( timeShift )); + + // Display information on time server tab + if ( ntpTabEnabled ) + { + ntpTab->setTimeShift( output ); + ntpTab->setNewTime( dt.toString() ); + } + + if ( lastNtp && lastLookup > 0 && secsSinceLast > 60 * ntpDelay ) + { + QString grpname = QString( "lookup_" ).append( QString::number( lookupCount ) ); + config.setGroup( grpname ); + lookupCount++; + predictTab->setShiftPerSec( timeShift / secsSinceLast ); + config.writeEntry( "secsSinceLast", secsSinceLast ); + config.writeEntry( "timeShift", QString::number( timeShift ) ); + config.setGroup( "lookups" ); + config.writeEntry( "count", lookupCount ); + config.writeEntry( "lastNtp", TRUE ); + } } @@ -365,4 +362,4 @@ void MainWindow::slotNTPDelayChanged( int delay ) { - ntpTimer->changeInterval( delay * 1000 * 60 ); - ntpDelay = delay; + ntpTimer->changeInterval( delay * 1000 * 60 ); + ntpDelay = delay; } @@ -371,29 +368,29 @@ void MainWindow::slotCheckNtp( int i ) { - if ( i == 0 ) - { - if ( ntpDelayElapsed() ) - { - runNTP(); - disconnect( ntpTimer, SIGNAL(timeout()), this, SLOT(slotProbeNTPServer()) ); - connect( ntpTimer, SIGNAL(timeout()), SLOT(slotTimerGetNTPTime()) ); - } - else - { - disconnect(ntpTimer, SIGNAL(timeout()), this, SLOT(slotTimerGetNTPTime()) ); - connect(ntpTimer, SIGNAL(timeout()), SLOT(slotProbeNTPServer()) ); - } - } - else - { - predictTab->slotPredictTime(); - if ( i > 0 ) - { - QString output = tr( "Could not connect to server " ); - output.append( settingsTab->ntpServer() ); - ntpOutput.append( output ); - if ( ntpTabEnabled ) - ntpTab->addNtpOutput( output ); - } - connect( ntpTimer, SIGNAL(timeout()), SLOT(slotProbeNTPServer()) ); - } + if ( i == 0 ) + { + if ( ntpDelayElapsed() ) + { + runNTP(); + disconnect( ntpTimer, SIGNAL(timeout()), this, SLOT(slotProbeNTPServer()) ); + connect( ntpTimer, SIGNAL(timeout()), SLOT(slotTimerGetNTPTime()) ); + } + else + { + disconnect(ntpTimer, SIGNAL(timeout()), this, SLOT(slotTimerGetNTPTime()) ); + connect(ntpTimer, SIGNAL(timeout()), SLOT(slotProbeNTPServer()) ); + } + } + else + { + predictTab->slotPredictTime(); + if ( i > 0 ) + { + QString output = tr( "Could not connect to server " ); + output.append( settingsTab->ntpServer() ); + ntpOutput.append( output ); + if ( ntpTabEnabled ) + ntpTab->addNtpOutput( output ); + } + connect( ntpTimer, SIGNAL(timeout()), SLOT(slotProbeNTPServer()) ); + } } diff --git a/noncore/settings/netsystemtime/mainwindow.h b/noncore/settings/netsystemtime/mainwindow.h index 1cdbc1a..d4a9713 100644 --- a/noncore/settings/netsystemtime/mainwindow.h +++ b/noncore/settings/netsystemtime/mainwindow.h @@ -33,2 +33,5 @@ +#include <opie2/oprocess.h> +#include <opie2/otabwidget.h> + class TimeTabWidget; @@ -39,4 +42,4 @@ class PredictTabWidget; -class OProcess; -class OTabWidget; +using Opie::OTabWidget; + class QDateTime; @@ -47,48 +50,48 @@ class MainWindow : public QDialog { - Q_OBJECT + Q_OBJECT public: - MainWindow( QWidget *parent = 0, const char *name = 0, bool modal = FALSE,WFlags f = 0); - ~MainWindow(); - static QString appName() { return QString::fromLatin1("systemtime"); } + MainWindow( QWidget *parent = 0, const char *name = 0, bool modal = FALSE,WFlags f = 0); + ~MainWindow(); + static QString appName() { return QString::fromLatin1("systemtime"); } protected: - void accept(); - void reject(); + void accept(); + void reject(); private: - OTabWidget *mainWidget; + OTabWidget *mainWidget; - TimeTabWidget *timeTab; - FormatTabWidget *formatTab; - SettingsTabWidget *settingsTab; - NTPTabWidget *ntpTab; - PredictTabWidget *predictTab; + TimeTabWidget *timeTab; + FormatTabWidget *formatTab; + SettingsTabWidget *settingsTab; + NTPTabWidget *ntpTab; + PredictTabWidget *predictTab; - bool ntpTabEnabled; - bool predictTabEnabled; + bool ntpTabEnabled; + bool predictTabEnabled; - OProcess *ntpProcess; - QTimer *ntpTimer; - QSocket *ntpSock; - int ntpDelay; - bool ntpInteractive; - QString ntpOutput; - int _lookupDiff; + OProcess *ntpProcess; + QTimer *ntpTimer; + QSocket *ntpSock; + int ntpDelay; + bool ntpInteractive; + QString ntpOutput; + int _lookupDiff; - void runNTP(); - bool ntpDelayElapsed(); + void runNTP(); + bool ntpDelayElapsed(); private slots: - void slotSetTime( const QDateTime & ); - void slotQCopReceive( const QCString &, const QByteArray & ); - void slotDisplayNTPTab( bool ); - void slotDisplayPredictTab( bool ); - void slotGetNTPTime(); - void slotTimerGetNTPTime(); - void slotProbeNTPServer(); - void slotNtpOutput( OProcess *, char *, int ); - void slotNtpFinished( OProcess* ); - void slotNTPDelayChanged( int ); - void slotCheckNtp( int ); + void slotSetTime( const QDateTime & ); + void slotQCopReceive( const QCString &, const QByteArray & ); + void slotDisplayNTPTab( bool ); + void slotDisplayPredictTab( bool ); + void slotGetNTPTime(); + void slotTimerGetNTPTime(); + void slotProbeNTPServer(); + void slotNtpOutput( OProcess *, char *, int ); + void slotNtpFinished( OProcess* ); + void slotNTPDelayChanged( int ); + void slotCheckNtp( int ); }; diff --git a/noncore/settings/netsystemtime/netsystemtime.pro b/noncore/settings/netsystemtime/netsystemtime.pro index 56f7f6c..70ef67d 100644 --- a/noncore/settings/netsystemtime/netsystemtime.pro +++ b/noncore/settings/netsystemtime/netsystemtime.pro @@ -1,20 +1,20 @@ -CONFIG = qt warn_on release quick-app -HEADERS = mainwindow.h \ - timetabwidget.h \ - formattabwidget.h \ - settingstabwidget.h \ - predicttabwidget.h \ - ntptabwidget.h -SOURCES = main.cpp \ - mainwindow.cpp \ - timetabwidget.cpp \ - formattabwidget.cpp \ - settingstabwidget.cpp \ - predicttabwidget.cpp \ - ntptabwidget.cpp -INCLUDEPATH += $(OPIEDIR)/include -DEPENDPATH += $(OPIEDIR)/include -LIBS += -lqpe -lopie +CONFIG = qt warn_on release quick-app +HEADERS = mainwindow.h \ + timetabwidget.h \ + formattabwidget.h \ + settingstabwidget.h \ + predicttabwidget.h \ + ntptabwidget.h +SOURCES = main.cpp \ + mainwindow.cpp \ + timetabwidget.cpp \ + formattabwidget.cpp \ + settingstabwidget.cpp \ + predicttabwidget.cpp \ + ntptabwidget.cpp +INCLUDEPATH += $(OPIEDIR)/include +DEPENDPATH += $(OPIEDIR)/include +LIBS += -lqpe -lopiecore2 -lopieui2 -TARGET = systemtime +TARGET = systemtime diff --git a/noncore/settings/netsystemtime/opie-systemtime.control b/noncore/settings/netsystemtime/opie-systemtime.control index 1ebc1da..58afc31 100644 --- a/noncore/settings/netsystemtime/opie-systemtime.control +++ b/noncore/settings/netsystemtime/opie-systemtime.control @@ -7,3 +7,3 @@ Maintainer: Patrick S. Vogt <tille@handhelds.org>, Dan Williams <drw@handhelds.o Architecture: arm -Depends: task-opie-minimal, ntpdate, libopie1 +Depends: task-opie-minimal, ntpdate, libopiecore2, libopieui2 Description: System time |