Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
68 changes: 0 additions & 68 deletions src/gui/aboutdialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,27 +75,10 @@ void AboutDialog::setupUpdaterWidget()
if (Utility::isMac()) {
// Because we don't have any statusString from the SparkleUpdater anyway we can hide the whole thing
ui->updaterWidget->hide();
} else {
ui->updateChannelLabel->hide();
ui->updateChannel->hide();
if (ConfigFile().updateChannel() != QLatin1String("stable")) {
ConfigFile().setUpdateChannel(QStringLiteral("stable"));
}
}
}
// we want to attach the known english identifiers which are also used within the configuration file as user data inside the data model
// that way, when we intend to reset to the original selection when the dialog, we can look up the config file's stored value in the data model
ui->updateChannel->addItem(QStringLiteral("ownCloud 10 LTS"), QStringLiteral("stable"));
ui->updateChannel->addItem(QStringLiteral("ownCloud Infinite Scale stable"), QStringLiteral("ocis"));
if (!Resources::isVanillaTheme()) {
ui->updateChannel->addItem(tr("beta"), QStringLiteral("beta"));
}

if (!ConfigFile().skipUpdateCheck() && Updater::instance()) {
// Channel selection
ui->updateChannel->setCurrentIndex(ui->updateChannel->findData(ConfigFile().updateChannel()));
connect(ui->updateChannel, static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged), this, &AboutDialog::slotUpdateChannelChanged);

// Note: the sparkle-updater is not an OCUpdater
if (auto *ocupdater = qobject_cast<OCUpdater *>(Updater::instance())) {
auto updateInfo = [ocupdater, this] {
Expand Down Expand Up @@ -142,55 +125,4 @@ void AboutDialog::setupUpdaterWidget()
#endif
}

void AboutDialog::slotUpdateChannelChanged([[maybe_unused]] int index)
{
#ifdef WITH_AUTO_UPDATER
QString channel;
if (index < 0) {
// invalid index, reset to stable
channel = QStringLiteral("stable");
} else {
channel = ui->updateChannel->itemData(index).toString();
}
if (channel == ConfigFile().updateChannel()) {
return;
}

auto msgBox = new QMessageBox(QMessageBox::Warning, tr("Change update channel?"),
tr("<html>The update channel determines which client updates will be offered for installation.<ul>"
"<li>\"ownCloud 10 LTS\" contains only upgrades that are considered reliable</li>"
"<li>\"ownCloud Infinite Scale stable\" contains only upgrades that are considered reliable but <b>removes support for \"ownCloud 10\"</b></li>"
"%1"
"</ul>"
"<br>⚠️Downgrades are not supported. If you switch to a stable channel this change will only be applied with the next major release.</html>")
.arg(
isTestPilotCloudTheme() ? tr("<li>\"beta\" may contain newer features and bugfixes, but have not yet been tested thoroughly</li>") : QString()),
QMessageBox::NoButton, this);
auto acceptButton = msgBox->addButton(tr("Change update channel"), QMessageBox::AcceptRole);
msgBox->addButton(tr("Cancel"), QMessageBox::RejectRole);
connect(msgBox, &QMessageBox::finished, msgBox, [this, channel, msgBox, acceptButton] {
msgBox->deleteLater();
if (msgBox->clickedButton() == acceptButton) {
ConfigFile().setUpdateChannel(channel);
if (OCUpdater *updater = qobject_cast<OCUpdater *>(Updater::instance())) {
updater->setUpdateUrl(Updater::updateUrl());
updater->checkForUpdate();
}
#if defined(Q_OS_MAC) && defined(HAVE_SPARKLE)
else if (SparkleUpdater *updater = qobject_cast<SparkleUpdater *>(Updater::instance())) {
updater->setUpdateUrl(Updater::updateUrl());
updater->checkForUpdate();
}
#endif
} else {
const auto oldChannel = ui->updateChannel->findData(ConfigFile().updateChannel());
Q_ASSERT(oldChannel >= 0);
Q_ASSERT(oldChannel <= 1);
ui->updateChannel->setCurrentIndex(oldChannel);
}
});
msgBox->open();
#endif
}

} // OCC namespace
7 changes: 1 addition & 6 deletions src/gui/aboutdialog.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* for more details.
*/
#ifndef ABOUTDIALOG_H
#define ABOUTDIALOG_H
#pragma once

#include <QDialog>

Expand All @@ -36,12 +35,8 @@ class AboutDialog : public QDialog
void openBrowserFromUrl(const QUrl &s);
void setupUpdaterWidget();

private Q_SLOTS:
void slotUpdateChannelChanged(int index);

private:
Ui::AboutDialog *ui;
};

}
#endif // ABOUTDIALOG_H
35 changes: 4 additions & 31 deletions src/gui/aboutdialog.ui
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
<item>
<spacer name="verticalSpacer_2">
<property name="orientation">
<enum>Qt::Vertical</enum>
<enum>Qt::Orientation::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
Expand Down Expand Up @@ -66,7 +66,7 @@
<item>
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
<enum>Qt::Orientation::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
Expand Down Expand Up @@ -96,32 +96,6 @@
<string/>
</property>
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<widget class="QLabel" name="updateChannelLabel">
<property name="sizePolicy">
<sizepolicy hsizetype="Maximum" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>&amp;Update Channel</string>
</property>
<property name="buddy">
<cstring>updateChannel</cstring>
</property>
</widget>
</item>
<item>
<widget class="QComboBox" name="updateChannel">
<property name="sizePolicy">
<sizepolicy hsizetype="Maximum" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="updateStateLabel"/>
</item>
Expand Down Expand Up @@ -165,10 +139,10 @@
<item>
<widget class="QDialogButtonBox" name="buttonBox">
<property name="orientation">
<enum>Qt::Horizontal</enum>
<enum>Qt::Orientation::Horizontal</enum>
</property>
<property name="standardButtons">
<set>QDialogButtonBox::Ok</set>
<set>QDialogButtonBox::StandardButton::Ok</set>
</property>
</widget>
</item>
Expand All @@ -177,7 +151,6 @@
<tabstops>
<tabstop>tabWidget</tabstop>
<tabstop>versionInfo</tabstop>
<tabstop>updateChannel</tabstop>
<tabstop>restartButton</tabstop>
</tabstops>
<resources/>
Expand Down
7 changes: 0 additions & 7 deletions src/gui/updater/ocupdater.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@

#include "accessmanager.h"
#include "application.h"
#include "common/restartmanager.h"
#include "common/utility.h"
#include "common/version.h"
#include "configfile.h"
Expand Down Expand Up @@ -109,12 +108,6 @@ OCUpdater::OCUpdater(const QUrl &url)
{
}

void OCUpdater::setUpdateUrl(const QUrl &url)
{
_updateUrl = url;
}


void OCUpdater::backgroundCheckForUpdate()
{
int dlState = downloadState();
Expand Down
2 changes: 0 additions & 2 deletions src/gui/updater/ocupdater.h
Original file line number Diff line number Diff line change
Expand Up @@ -117,8 +117,6 @@ class OWNCLOUDGUI_EXPORT OCUpdater : public Updater

explicit OCUpdater(const QUrl &url);

void setUpdateUrl(const QUrl &url);

void checkForUpdate() override;

QString statusString() const;
Expand Down
32 changes: 27 additions & 5 deletions src/gui/updater/updater.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,30 @@ namespace OCC {

Q_LOGGING_CATEGORY(lcUpdater, "gui.updater", QtInfoMsg)

[[deprecated("updateChannel is no longer supported. the key will be removed in 8.0")]]
const QString updateChannelC() { return QStringLiteral("updateChannel"); }

QString updateChannel()
{
// remove deprecated updateChannel setting once we hit 8.0
auto settings = ConfigFile::makeQSettings();
QString updateChannelKey = updateChannelC();
// until then, migrate old setting if present
settings.setValue(updateChannelKey, QStringLiteral("stable"));

// By now only two channels are supported: stable and stable-beta
const QString suffix = OCC::Version::suffix();
if (suffix.startsWith(QLatin1String("daily"))
|| suffix.startsWith(QLatin1String("nightly"))
|| suffix.startsWith(QLatin1String("alpha"))
|| suffix.startsWith(QLatin1String("rc"))
|| suffix.startsWith(QLatin1String("beta"))) {
return QStringLiteral("stable-beta");
}

return QStringLiteral("stable");
}

Updater *Updater::_instance = nullptr;

Updater *Updater::instance()
Expand Down Expand Up @@ -106,10 +130,8 @@ QUrlQuery Updater::getQueryParams()

query.addQueryItem(QStringLiteral("versionsuffix"), OCC::Version::suffix());

auto channel = ConfigFile().updateChannel();
if (channel != QLatin1String("stable")) {
query.addQueryItem(QStringLiteral("channel"), channel);
}
auto channel = updateChannel();
query.addQueryItem(QStringLiteral("channel"), channel);

// requested by #11328
// we use the names Qt gives us instead of inventing our own labels
Expand All @@ -126,7 +148,7 @@ QUrlQuery Updater::getQueryParams()
Updater *Updater::create()
{
auto url = updateUrl();
qCDebug(lcUpdater) << url;
qCDebug(lcUpdater) << "Updater URL: "<< url.toDisplayString();
if (url.isEmpty()) {
qCWarning(lcUpdater) << "Not a valid updater URL, will not do update check";
return nullptr;
Expand Down
23 changes: 0 additions & 23 deletions src/libsync/configfile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@ const QString optionalDesktopNoficationsC()
}
const QString skipUpdateCheckC() { return QStringLiteral("skipUpdateCheck"); }
const QString updateCheckIntervalC() { return QStringLiteral("updateCheckInterval"); }
const QString updateChannelC() { return QStringLiteral("updateChannel"); }
const QString uiLanguageC() { return QStringLiteral("uiLanguage"); }
const QString geometryC() { return QStringLiteral("geometry"); }
const QString timeoutC() { return QStringLiteral("timeout"); }
Expand Down Expand Up @@ -541,28 +540,6 @@ void ConfigFile::setSkipUpdateCheck(bool skip, const QString &connection)
settings.sync();
}

QString ConfigFile::updateChannel() const
{
QString defaultUpdateChannel = QStringLiteral("stable");
const QString suffix = OCC::Version::suffix();
if (suffix.startsWith(QLatin1String("daily"))
|| suffix.startsWith(QLatin1String("nightly"))
|| suffix.startsWith(QLatin1String("alpha"))
|| suffix.startsWith(QLatin1String("rc"))
|| suffix.startsWith(QLatin1String("beta"))) {
defaultUpdateChannel = QStringLiteral("beta");
}

auto settings = makeQSettings();
return settings.value(updateChannelC(), defaultUpdateChannel).toString();
}

void ConfigFile::setUpdateChannel(const QString &channel)
{
auto settings = makeQSettings();
settings.setValue(updateChannelC(), channel);
}

QString ConfigFile::uiLanguage() const
{
auto settings = makeQSettings();
Expand Down
3 changes: 0 additions & 3 deletions src/libsync/configfile.h
Original file line number Diff line number Diff line change
Expand Up @@ -169,9 +169,6 @@ class OWNCLOUDSYNC_EXPORT ConfigFile
bool skipUpdateCheck(const QString &connection = QString()) const;
void setSkipUpdateCheck(bool, const QString &);

QString updateChannel() const;
void setUpdateChannel(const QString &channel);

QString uiLanguage() const;
void setUiLanguage(const QString &uiLanguage);

Expand Down
5 changes: 2 additions & 3 deletions test/testupdater.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,7 @@ private Q_SLOTS:
{
QTest::addColumn<QString>("url");
QTest::addColumn<OCUpdater::DownloadState>("result");
// a redirect to attic
QTest::newRow("redirect") << "https://download.owncloud.com/desktop/stable/ownCloud-2.2.4.6408-setup.exe" << OCUpdater::DownloadComplete;
QTest::newRow("redirect") << "https://download.owncloud.com/desktop/ownCloud/stable/6.0.3.18040/win/ownCloud-6.0.3.18040.x64.msi" << OCUpdater::DownloadComplete;
QTest::newRow("broken url") << "https://&" << OCUpdater::DownloadFailed;
}

Expand All @@ -32,7 +31,7 @@ private Q_SLOTS:
UpdateInfo info;
info.setDownloadUrl(url);
info.setVersionString(QStringLiteral("ownCloud 2.2.4 (build 6408)"));
// esnure we do the update
// ensure we do the update
info.setVersion(QStringLiteral("100.2.4.6408"));
auto *updater = new WindowsUpdater({});
QSignalSpy downloadSpy(updater, &WindowsUpdater::downloadStateChanged);
Expand Down