Frequent update check: read check frequency from config file.

This commit is contained in:
Klaas Freitag 2015-06-15 12:24:18 +02:00
parent c8cb604c18
commit fa0faee8ba
3 changed files with 24 additions and 2 deletions

View file

@ -178,7 +178,8 @@ Application::Application(int &argc, char **argv) :
QTimer::singleShot( 0, this, SLOT( slotCheckConnection() )); QTimer::singleShot( 0, this, SLOT( slotCheckConnection() ));
// Update checks // Update checks
_updaterTimer.setInterval(1000*120*60); // check every two hours _updaterTimer.setInterval(cfg.updateCheckInterval()); // check every two hours
connect(&_updaterTimer, SIGNAL(timeout()), this, SLOT(slotStartUpdateDetector())); connect(&_updaterTimer, SIGNAL(timeout()), this, SLOT(slotStartUpdateDetector()));
QTimer::singleShot( 3000, this, SLOT( slotStartUpdateDetector() )); QTimer::singleShot( 3000, this, SLOT( slotStartUpdateDetector() ));

View file

@ -47,6 +47,7 @@ static const char monoIconsC[] = "monoIcons";
static const char crashReporterC[] = "crashReporter"; static const char crashReporterC[] = "crashReporter";
static const char optionalDesktopNoficationsC[] = "optionalDesktopNotifications"; static const char optionalDesktopNoficationsC[] = "optionalDesktopNotifications";
static const char skipUpdateCheckC[] = "skipUpdateCheck"; static const char skipUpdateCheckC[] = "skipUpdateCheck";
static const char updateCheckIntervalC[] = "updateCheckInterval";
static const char geometryC[] = "geometry"; static const char geometryC[] = "geometry";
static const char timeoutC[] = "timeout"; static const char timeoutC[] = "timeout";
static const char transmissionChecksumC[] = "transmissionChecksum"; static const char transmissionChecksumC[] = "transmissionChecksum";
@ -381,6 +382,24 @@ quint64 ConfigFile::forceSyncInterval(const QString& connection) const
return interval; return interval;
} }
bool ConfigFile::updateCheckInterval( const QString& connection ) const
{
QString con( connection );
if( connection.isEmpty() ) con = defaultConnection();
QSettings settings(configFile(), QSettings::IniFormat);
settings.beginGroup( con );
quint64 defaultInterval = 1000*120*60;
quint64 interval = settings.value( QLatin1String(updateCheckIntervalC), defaultInterval ).toULongLong();
quint64 minInterval = 1000*60*5;
if( interval < minInterval) {
qDebug() << "Update check interval less than fife minutes, setting " << minInterval;
interval = minInterval;
}
return interval;
}
bool ConfigFile::skipUpdateCheck( const QString& connection ) const bool ConfigFile::skipUpdateCheck( const QString& connection ) const
{ {
QString con( connection ); QString con( connection );

View file

@ -112,7 +112,9 @@ public:
void saveGeometry(QWidget *w); void saveGeometry(QWidget *w);
void restoreGeometry(QWidget *w); void restoreGeometry(QWidget *w);
// installer // how often the check about new versions runs, default two hours
bool updateCheckInterval( const QString& connection = QString() ) const;
bool skipUpdateCheck( const QString& connection = QString() ) const; bool skipUpdateCheck( const QString& connection = QString() ) const;
void setSkipUpdateCheck( bool, const QString& ); void setSkipUpdateCheck( bool, const QString& );