void OCUpdater::setDownloadState(DownloadState state) { auto oldState = _state; _state = state; emit downloadStateChanged(); // show the notification if the download is complete (on every check) // or once for system based updates. if (_state == OCUpdater::DownloadComplete || (oldState != OCUpdater::UpdateOnlyAvailableThroughSystem && _state == OCUpdater::UpdateOnlyAvailableThroughSystem)) { emit newUpdateAvailable(tr("Update Check"), statusString()); } }
UpdaterScheduler::UpdaterScheduler(QObject *parent) : QObject(parent) { connect( &_updateCheckTimer, SIGNAL(timeout()), this, SLOT(slotTimerFired()) ); // Note: the sparkle-updater is not an OCUpdater and thus the dynamic_cast // returns NULL. Clever detail. if (OCUpdater *updater = dynamic_cast<OCUpdater*>(Updater::instance())) { connect(updater, SIGNAL(newUpdateAvailable(QString,QString)), this, SIGNAL(updaterAnnouncement(QString,QString)) ); connect(updater, SIGNAL(requestRestart()), SIGNAL(requestRestart())); } // at startup, do a check in any case. QTimer::singleShot(3000, this, SLOT(slotTimerFired())); ConfigFile cfg; auto checkInterval = cfg.updateCheckInterval(); _updateCheckTimer.start(checkInterval); }