summaryrefslogtreecommitdiff
Side-by-side diff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/settings/netsystemtime/ntp.cpp12
-rw-r--r--noncore/settings/netsystemtime/opie-netsystemtime.control3
-rw-r--r--noncore/settings/netsystemtime/opie-netsystemtime.postinst7
-rw-r--r--noncore/settings/netsystemtime/opie-netsystemtime.postrm4
-rw-r--r--noncore/settings/netsystemtime/settime.cpp21
5 files changed, 34 insertions, 13 deletions
diff --git a/noncore/settings/netsystemtime/ntp.cpp b/noncore/settings/netsystemtime/ntp.cpp
index 083b50f..830c0c3 100644
--- a/noncore/settings/netsystemtime/ntp.cpp
+++ b/noncore/settings/netsystemtime/ntp.cpp
@@ -4,49 +4,48 @@
#include <qtimer.h>
#include <qtable.h>
#include <qlabel.h>
#include <qsocket.h>
#include <qlineedit.h>
#include <qspinbox.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 <sys/time.h>
#include <time.h>
#include <stdlib.h>
Ntp::Ntp( QWidget* parent, const char* name, WFlags fl )
: SetDateTime( parent, name, fl )
{
- qDebug("%s", QPEApplication::qpeDir().latin1());
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) );
ComboNtpSrv->setCurrentItem( cfg.readNumEntry("ntpServer", 0) );
ntpTimer = new QTimer(this);
ntpProcess = new OProcess( );
connect( SpinBoxNtpDelay, SIGNAL( valueChanged(int) ),
SLOT(slotNtpDelayChanged(int)) );
ntpSock = new QSocket( this );
connect( ntpSock, SIGNAL( error(int) ),
@@ -178,70 +177,71 @@ float Ntp::getTimeShift()
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);
qDebug("%s", _ntpOutput.latin1());
qDebug("diff = >%s<",diff.latin1());
return diff.toFloat();
}
void Ntp::readLookups()
{
Config cfg("ntp",Config::User);
cfg.setGroup("lookups");
int lookupCount = cfg.readNumEntry("count",0);
float last, shift, shiftPerSec;
qDebug("lookupCount = %i",lookupCount);
TableLookups->setNumCols( 3 );
TableLookups->setNumRows( lookupCount);
TableLookups->horizontalHeader()->setLabel(1,tr("last [h]"));
TableLookups->horizontalHeader()->setLabel(2,tr("offset [s]"));
TableLookups->horizontalHeader()->setLabel(0,tr("shift [s/h]"));
- int cw = 50;//TableLookups->width()/4;
+ int cw = TableLookups->width()/4;
qDebug("column width %i",cw);
+ cw = 50;
TableLookups->setColumnWidth( 0, cw+30 );
TableLookups->setColumnWidth( 1, cw );
TableLookups->setColumnWidth( 2, cw );
TableLookups->sortColumn(0, false, true );
// TableLookups->setSorting( true );
for (int i=0; i < lookupCount; i++)
{
cfg.setGroup("lookup_"+QString::number(i));
last = cfg.readEntry("secsSinceLast",0).toFloat();
shift = QString(cfg.readEntry("timeShift",0)).toFloat();
// qDebug("%i last %f",i,last);
// qDebug("%i shift %f",i,shift);
shiftPerSec = shift / last;
_shiftPerSec += shiftPerSec;
- TableLookups->setText( i,0,QString::number(shiftPerSec*60));
+ TableLookups->setText( i,0,QString::number(shiftPerSec*60*60));
TableLookups->setText( i,2,QString::number(shift));
- TableLookups->setText( i,1,QString::number(last/60));
+ TableLookups->setText( i,1,QString::number(last/(60*60)));
}
- _shiftPerSec /= lookupCount+1;
- TextLabelShift->setText(QString::number(_shiftPerSec)+tr(" seconds"));
+ _shiftPerSec /= lookupCount;
+ TextLabelShift->setText(QString::number(_shiftPerSec*60*60)+tr(" s/h"));
}
void Ntp::preditctTime()
{
Config cfg("ntp",Config::User);
cfg.setGroup("lookups");
int lastTime = cfg.readNumEntry("time",0);
setenv( "TZ", tz->currentZone(), 1 );
int now = TimeConversion::toUTC( QDateTime::currentDateTime() );
int corr = int((now - lastTime) * _shiftPerSec);
TextLabelEstimatedShift->setText(QString::number(corr)+tr(" seconds"));
predictedTime = QDateTime::currentDateTime().addSecs(corr);
TextLabelPredTime->setText(predictedTime.toString());
TextLabelMainPredTime->setText(tr("Predicted time:")+"<br><b>"+predictedTime.toString()+"</b>");
}
void Ntp::setPredictTime()
{
preditctTime();
setTime( predictedTime );
}
void Ntp::slotCheckNtp(int i)
{
diff --git a/noncore/settings/netsystemtime/opie-netsystemtime.control b/noncore/settings/netsystemtime/opie-netsystemtime.control
index d3290e9..8fd7da5 100644
--- a/noncore/settings/netsystemtime/opie-netsystemtime.control
+++ b/noncore/settings/netsystemtime/opie-netsystemtime.control
@@ -1,11 +1,12 @@
+Packagename: opie-netsystemtime
Files: bin/netsystemtime apps/Settings/ntpdatetime.desktop etc/ntpservers
Priority: optional
Section: opie/settings
Depends: ntpdate
Conflicts: opie-systemtime
Maintainer: Patrick S. Vogt <tille@handhelds.org>
Architecture: arm
Version: $QPE_VERSION-$SUB_VERSION
Depends: opie-base ($QPE_VERSION), ntpdate
-Description: ntp ( Network Time Protocol) gui
+Description: ntp (Network Time Protocol) gui
This utility syncs system time with a atomic timerserver via internet
diff --git a/noncore/settings/netsystemtime/opie-netsystemtime.postinst b/noncore/settings/netsystemtime/opie-netsystemtime.postinst
new file mode 100644
index 0000000..233cd31
--- a/dev/null
+++ b/noncore/settings/netsystemtime/opie-netsystemtime.postinst
@@ -0,0 +1,7 @@
+#!/bin/sh -v
+
+systime=`ipkg status | grep Package | grep -i systemtime | sed "s/Package://"`
+ipkg remove $pack
+
+cd $QPEDIR/bin/
+ln -s netsystemtime systemtime
diff --git a/noncore/settings/netsystemtime/opie-netsystemtime.postrm b/noncore/settings/netsystemtime/opie-netsystemtime.postrm
new file mode 100644
index 0000000..4b2ab7c
--- a/dev/null
+++ b/noncore/settings/netsystemtime/opie-netsystemtime.postrm
@@ -0,0 +1,4 @@
+#!/bin/sh -v
+
+cd $QPEDIR/bin/
+rm systemtime
diff --git a/noncore/settings/netsystemtime/settime.cpp b/noncore/settings/netsystemtime/settime.cpp
index 93543cd..e7e604f 100644
--- a/noncore/settings/netsystemtime/settime.cpp
+++ b/noncore/settings/netsystemtime/settime.cpp
@@ -210,86 +210,95 @@ SetDateTime::~SetDateTime()
}
void SetDateTime::writeSettings()
{
Config config("qpe");
config.setGroup( "Time" );
config.writeEntry( "AMPM", ampmCombo->currentItem() );
config.writeEntry( "MONDAY", weekStartCombo->currentItem() );
config.setGroup( "Date" );
DateFormat df = date_formats[dateFormatCombo->currentItem()];
config.writeEntry( "Separator", QString(df.separator()));
config.writeEntry( "ShortOrder", df.shortOrder());
config.writeEntry( "LongOrder", df.longOrder());
config.writeEntry( "ClockApplet", clockAppletCombo->currentItem() );
Config lconfig("locale");
lconfig.setGroup( "Location" );
lconfig.writeEntry( "Timezone", tz->currentZone() );
}
void SetDateTime::commitTime()
{
tz->setFocus();
- // really turn off the screensaver before doing anything
- {
- // Needs to be encased in { } so that it deconstructs and sends
- QCopEnvelope disableScreenSaver( "QPE/System", "setScreenSaverIntervals(int,int,int)" );
- disableScreenSaver << 0 << 0 << 0;
- }
// Need to process the QCOP event generated above before proceeding
qApp->processEvents();
// before we progress further, set our TZ!
setenv( "TZ", tz->currentZone(), 1 );
// now set the time...
QDateTime dt( dateButton->date(), timeButton->time() );
if ( dt.isValid() ) setTime(dt);
}
void SetDateTime::setTime(QDateTime dt)
{
+ // really turn off the screensaver before doing anything
+ {
+ // Needs to be encased in { } so that it deconstructs and sends
+ QCopEnvelope disableScreenSaver( "QPE/System", "setScreenSaverIntervals(int,int,int)" );
+ disableScreenSaver << 0 << 0 << 0;
+ }
Config cfg("ntp",Config::User);
cfg.setGroup("correction");
int t = TimeConversion::toUTC(dt);
struct timeval myTv;
myTv.tv_sec = t;
cfg.writeEntry("time", t );
myTv.tv_usec = 0;
if ( myTv.tv_sec != -1 )
::settimeofday( &myTv, 0 );
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;
+ // Restore screensaver
+ QCopEnvelope enableScreenSaver( "QPE/System", "setScreenSaverIntervals(int,int,int)" );
+ enableScreenSaver << -1 << -1 << -1;
}
void SetDateTime::updateSystem(int i)
{
+ // really turn off the screensaver before doing anything
+ {
+ // Needs to be encased in { } so that it deconstructs and sends
+ QCopEnvelope disableScreenSaver( "QPE/System", "setScreenSaverIntervals(int,int,int)" );
+ disableScreenSaver << 0 << 0 << 0;
+ }
qDebug("SetDateTime::updateSystem(int %i)",i);
writeSettings();
// set the timezone for everyone else...
QCopEnvelope setTimeZone( "QPE/System", "timeChange(QString)" );
setTimeZone << tz->currentZone();
// AM/PM setting and notify time changed
QCopEnvelope setClock( "QPE/System", "clockChange(bool)" );
setClock << ampmCombo->currentItem();
// Notify everyone what day we prefer to start the week on.
QCopEnvelope setWeek( "QPE/System", "weekChange(bool)" );
setWeek << weekStartCombo->currentItem();
// Notify everyone what date format to use
QCopEnvelope setDateFormat( "QPE/System", "setDateFormat(DateFormat)" );
setDateFormat << date_formats[dateFormatCombo->currentItem()];
// Restore screensaver
QCopEnvelope enableScreenSaver( "QPE/System", "setScreenSaverIntervals(int,int,int)" );
enableScreenSaver << -1 << -1 << -1;
// since time has changed quickly load in the datebookdb
// to allow the alarm server to get a better grip on itself