From: Christian Kamm Date: Fri, 18 May 2018 12:17:13 +0000 (+0200) Subject: Updater: Make sparkle updater respect release channel X-Git-Tag: archive/raspbian/3.16.7-1_deb13u1+rpi1~1^2~12^2~22^2~46^2~23 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=4b39731c274d37b305a041bbfa165277f85b50d6;p=nextcloud-desktop.git Updater: Make sparkle updater respect release channel --- diff --git a/src/gui/generalsettings.cpp b/src/gui/generalsettings.cpp index b9081da43..789bc27b3 100644 --- a/src/gui/generalsettings.cpp +++ b/src/gui/generalsettings.cpp @@ -252,7 +252,7 @@ void GeneralSettings::loadMiscSettings() #if defined(BUILD_UPDATER) void GeneralSettings::slotUpdateInfo() { - if (ConfigFile().skipUpdateCheck()) { + if (ConfigFile().skipUpdateCheck() || !Updater::instance()) { // updater disabled on compile _ui->updatesGroupBox->setVisible(false); return; @@ -278,24 +278,18 @@ void GeneralSettings::slotUpdateInfo() ocupdater->downloadState() != OCUpdater::DownloadComplete); _ui->autoCheckForUpdatesCheckBox->setChecked(ConfigFile().autoUpdateCheck()); - - // Channel selection - _ui->updateChannel->setCurrentIndex(ConfigFile().updateChannel() == "beta" ? 1 : 0); - connect(_ui->updateChannel, &QComboBox::currentTextChanged, - this, &GeneralSettings::slotUpdateChannelChanged, Qt::UniqueConnection); } #ifdef Q_OS_MAC else if (auto sparkleUpdater = qobject_cast(Updater::instance())) { _ui->updateStateLabel->setText(sparkleUpdater->statusString()); _ui->restartButton->setVisible(false); - - // Channel selection - _ui->updateChannel->setCurrentIndex(ConfigFile().updateChannel() == "beta" ? 1 : 0); - connect(_ui->updateChannel, &QComboBox::currentTextChanged, - this, &GeneralSettings::slotUpdateChannelChanged, Qt::UniqueConnection); } #endif + // Channel selection + _ui->updateChannel->setCurrentIndex(ConfigFile().updateChannel() == "beta" ? 1 : 0); + connect(_ui->updateChannel, &QComboBox::currentTextChanged, + this, &GeneralSettings::slotUpdateChannelChanged, Qt::UniqueConnection); } void GeneralSettings::slotUpdateChannelChanged(const QString &channel) @@ -306,6 +300,12 @@ void GeneralSettings::slotUpdateChannelChanged(const QString &channel) updater->setUpdateUrl(Updater::updateUrl()); updater->checkForUpdate(); } +#ifdef Q_OS_MAC + else if (auto *updater = qobject_cast(Updater::instance())) { + updater->setUpdateUrl(Updater::updateUrl()); + updater->checkForUpdate(); + } +#endif } void GeneralSettings::slotUpdateCheckNow() diff --git a/src/gui/updater/sparkleupdater.h b/src/gui/updater/sparkleupdater.h index d565c6f6e..d03e76360 100644 --- a/src/gui/updater/sparkleupdater.h +++ b/src/gui/updater/sparkleupdater.h @@ -25,9 +25,11 @@ class SparkleUpdater : public Updater { Q_OBJECT public: - SparkleUpdater(const QString &appCastUrl); + SparkleUpdater(const QUrl &appCastUrl); ~SparkleUpdater(); + void setUpdateUrl(const QUrl &url); + // unused in this updater void checkForUpdate() override; void backgroundCheckForUpdate() override; diff --git a/src/gui/updater/sparkleupdater_mac.mm b/src/gui/updater/sparkleupdater_mac.mm index 5bf43efdb..1ba1e2c23 100644 --- a/src/gui/updater/sparkleupdater_mac.mm +++ b/src/gui/updater/sparkleupdater_mac.mm @@ -83,7 +83,7 @@ class SparkleUpdater::Private }; // Delete ~/Library//Preferences/com.owncloud.desktopclient.plist to re-test -SparkleUpdater::SparkleUpdater(const QString& appCastUrl) +SparkleUpdater::SparkleUpdater(const QUrl& appCastUrl) : Updater() { d = new Private; @@ -99,9 +99,7 @@ SparkleUpdater::SparkleUpdater(const QString& appCastUrl) [d->updater resetUpdateCycle]; [d->updater retain]; - NSURL* url = [NSURL URLWithString: - [NSString stringWithUTF8String: appCastUrl.toUtf8().data()]]; - [d->updater setFeedURL: url]; + setUpdateUrl(appCastUrl); // Sparkle 1.8 required NSString *userAgent = [NSString stringWithUTF8String: Utility::userAgentString().data()]; @@ -114,6 +112,13 @@ SparkleUpdater::~SparkleUpdater() delete d; } +void SparkleUpdater::setUpdateUrl(const QUrl &url) +{ + NSURL* nsurl = [NSURL URLWithString: + [NSString stringWithUTF8String: url.toString().toUtf8().data()]]; + [d->updater setFeedURL: nsurl]; +} + // FIXME: Should be changed to not instanicate the SparkleUpdater at all in this case bool autoUpdaterAllowed() { diff --git a/src/gui/updater/updater.cpp b/src/gui/updater/updater.cpp index 36fd3f06f..9867db7f8 100644 --- a/src/gui/updater/updater.cpp +++ b/src/gui/updater/updater.cpp @@ -130,7 +130,7 @@ Updater *Updater::create() } #if defined(Q_OS_MAC) && defined(HAVE_SPARKLE) - return new SparkleUpdater(url.toString()); + return new SparkleUpdater(url); #elif defined(Q_OS_WIN32) // the best we can do is notify about updates return new NSISUpdater(url);