Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add daily update channel. #6658

Merged
merged 16 commits into from
Jul 3, 2024
Merged
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
2 changes: 1 addition & 1 deletion VERSION.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ set(NEXTCLOUD_SERVER_VERSION_MOUNT_ROOT_PROPERTY_SUPPORTED_MINOR 0)
set(NEXTCLOUD_SERVER_VERSION_MOUNT_ROOT_PROPERTY_SUPPORTED_PATCH 3)

if ( NOT DEFINED MIRALL_VERSION_SUFFIX )
set( MIRALL_VERSION_SUFFIX "git") #e.g. beta1, beta2, rc1
set( MIRALL_VERSION_SUFFIX "daily") #e.g. beta1, beta2, rc1
endif( NOT DEFINED MIRALL_VERSION_SUFFIX )

if( NOT DEFINED MIRALL_VERSION_BUILD )
Expand Down
79 changes: 40 additions & 39 deletions src/gui/generalsettings.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/*

Check notice on line 1 in src/gui/generalsettings.cpp

View workflow job for this annotation

GitHub Actions / build

Run clang-format on src/gui/generalsettings.cpp

File src/gui/generalsettings.cpp does not conform to Custom style guidelines. (lines 287, 366, 385, 386, 387, 388, 389, 390)
* Copyright (C) by Daniel Molkentin <[email protected]>
*
* This program is free software; you can redistribute it and/or modify
Expand Down Expand Up @@ -190,8 +190,6 @@
});

loadMiscSettings();
// updater info now set in: customizeStyle
//slotUpdateInfo();

// misc
connect(_ui->monoIconsCheckBox, &QAbstractButton::toggled, this, &GeneralSettings::saveMiscSettings);
Expand Down Expand Up @@ -281,13 +279,22 @@
_ui->stopExistingFolderNowBigSyncCheckBox->setChecked(_ui->existingFolderLimitCheckBox->isChecked() && cfgFile.stopSyncingExistingFoldersOverLimit());
_ui->newExternalStorage->setChecked(cfgFile.confirmExternalStorage());
_ui->monoIconsCheckBox->setChecked(cfgFile.monoIcons());

#if defined(BUILD_UPDATER)
auto validUpdateChannels = cfgFile.validUpdateChannels();
_ui->updateChannel->addItems(validUpdateChannels);
const auto currentUpdateChannelIndex = validUpdateChannels.indexOf(cfgFile.currentUpdateChannel());
_ui->updateChannel->setCurrentIndex(currentUpdateChannelIndex != -1? currentUpdateChannelIndex : 0);
connect(_ui->updateChannel, &QComboBox::currentTextChanged, this, &GeneralSettings::slotUpdateChannelChanged);
#endif
}

#if defined(BUILD_UPDATER)
void GeneralSettings::slotUpdateInfo()
{
ConfigFile config;
const auto updater = Updater::instance();
if (ConfigFile().skipUpdateCheck() || !updater) {
if (config.skipUpdateCheck() || !updater) {
// updater disabled on compile
_ui->updatesContainer->setVisible(false);
return;
Expand All @@ -297,32 +304,28 @@
connect(_ui->updateButton,
&QAbstractButton::clicked,
this,

&GeneralSettings::slotUpdateCheckNow,
Qt::UniqueConnection);
connect(_ui->autoCheckForUpdatesCheckBox, &QAbstractButton::toggled, this,
&GeneralSettings::slotToggleAutoUpdateCheck, Qt::UniqueConnection);
_ui->autoCheckForUpdatesCheckBox->setChecked(ConfigFile().autoUpdateCheck());
_ui->autoCheckForUpdatesCheckBox->setChecked(config.autoUpdateCheck());
}

// Note: the sparkle-updater is not an OCUpdater
auto *ocupdater = qobject_cast<OCUpdater *>(updater);
const auto ocupdater = qobject_cast<OCUpdater *>(updater);
if (ocupdater) {
connect(ocupdater, &OCUpdater::downloadStateChanged, this, &GeneralSettings::slotUpdateInfo, Qt::UniqueConnection);
connect(_ui->restartButton, &QAbstractButton::clicked, ocupdater, &OCUpdater::slotStartInstaller, Qt::UniqueConnection);
//connect(_ui->restartButton, &QAbstractButton::clicked, qApp, &QApplication::quit, Qt::UniqueConnection);

QString status = ocupdater->statusString(OCUpdater::UpdateStatusStringFormat::Html);
auto status = ocupdater->statusString(OCUpdater::UpdateStatusStringFormat::Html);
Theme::replaceLinkColorStringBackgroundAware(status);

_ui->updateStateLabel->setOpenExternalLinks(false);
connect(_ui->updateStateLabel, &QLabel::linkActivated, this, [](const QString &link) {
Utility::openBrowser(QUrl(link));
});
_ui->updateStateLabel->setText(status);

_ui->restartButton->setVisible(ocupdater->downloadState() == OCUpdater::DownloadComplete);

_ui->updateButton->setEnabled(ocupdater->downloadState() != OCUpdater::CheckingServer &&
ocupdater->downloadState() != OCUpdater::Downloading &&
ocupdater->downloadState() != OCUpdater::DownloadComplete);
Expand All @@ -339,57 +342,55 @@
_ui->updateButton->setEnabled(enableUpdateButton);
}
#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 auto updateChannelToLocalized = [](const QString &channel) {
auto decodedTranslatedChannel = QString{};

if (channel == QStringLiteral("stable")) {
decodedTranslatedChannel = tr("stable");
} else if (channel == QStringLiteral("beta")) {
decodedTranslatedChannel = tr("beta");
return tr("stable");
}

if (channel == QStringLiteral("beta")) {
return tr("beta");
}

return decodedTranslatedChannel;
if (channel == QStringLiteral("daily")) {
return tr("daily");
}

return QString{};
};

const auto updateChannelFromLocalized = [](const int index) {
if (index == 1) {
switch(index) {
case 1:
return QStringLiteral("beta");
break;
case 2:
return QStringLiteral("daily");
break;
default:
return QStringLiteral("stable");
}

return QStringLiteral("stable");
};

const auto channel = updateChannelFromLocalized(_ui->updateChannel->currentIndex());
if (channel == ConfigFile().updateChannel()) {
if (channel == ConfigFile().currentUpdateChannel()) {
return;
}

auto msgBox = new QMessageBox(
QMessageBox::Warning,
tr("Change update channel?"),
tr("The update channel determines which client updates will be offered "
"for installation. The \"stable\" channel contains only upgrades that "
"are considered reliable, while the versions in the \"beta\" channel "
"may contain newer features and bugfixes, but have not yet been tested "
"thoroughly."
"\n\n"
"Note that this selects only what pool upgrades are taken from, and that "
"there are no downgrades: So going back from the beta channel to "
"the stable channel usually cannot be done immediately and means waiting "
"for a stable version that is newer than the currently installed beta "
"version."),
tr("Changing update channel?"),
tr("The channel determines which upgrades will be offered to install:\n"
"- stable: contains tested versions considered reliable\n"
"- beta: contains versions with new features that may not be tested thoroughly\n"
"- daily: contains versions created daily only for testing and development\n\n"
"Downgrading versions is not possible immediately: changing from beta to stable means waiting for the new stable version."),
QMessageBox::NoButton,
this);
auto acceptButton = msgBox->addButton(tr("Change update channel"), QMessageBox::AcceptRole);
const 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, updateChannelToLocalized] {
msgBox->deleteLater();
Expand All @@ -406,7 +407,7 @@
}
#endif
} else {
_ui->updateChannel->setCurrentText(updateChannelToLocalized(ConfigFile().updateChannel()));
_ui->updateChannel->setCurrentText(updateChannelToLocalized(ConfigFile().currentUpdateChannel()));
}
});
msgBox->open();
Expand Down
32 changes: 11 additions & 21 deletions src/gui/generalsettings.ui
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<rect>
<x>0</x>
<y>0</y>
<width>601</width>
<width>667</width>
<height>663</height>
</rect>
</property>
Expand Down Expand Up @@ -40,10 +40,10 @@
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
<enum>Qt::Orientation::Horizontal</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Fixed</enum>
<enum>QSizePolicy::Policy::Fixed</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
Expand Down Expand Up @@ -77,10 +77,10 @@
<item>
<spacer name="horizontalSpacer_3">
<property name="orientation">
<enum>Qt::Horizontal</enum>
<enum>Qt::Orientation::Horizontal</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Fixed</enum>
<enum>QSizePolicy::Policy::Fixed</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
Expand All @@ -104,10 +104,10 @@
<item>
<spacer name="horizontalSpacer_5">
<property name="orientation">
<enum>Qt::Horizontal</enum>
<enum>Qt::Orientation::Horizontal</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Fixed</enum>
<enum>QSizePolicy::Policy::Fixed</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
Expand Down Expand Up @@ -197,7 +197,7 @@
<item>
<spacer name="horizontalSpacer_4">
<property name="orientation">
<enum>Qt::Horizontal</enum>
<enum>Qt::Orientation::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
Expand Down Expand Up @@ -269,16 +269,6 @@
<verstretch>0</verstretch>
</sizepolicy>
</property>
<item>
<property name="text">
<string>stable</string>
</property>
</item>
<item>
<property name="text">
<string>beta</string>
</property>
</item>
</widget>
</item>
<item>
Expand Down Expand Up @@ -343,7 +333,7 @@
<item>
<spacer name="horizontalSpacer_6">
<property name="orientation">
<enum>Qt::Horizontal</enum>
<enum>Qt::Orientation::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
Expand Down Expand Up @@ -374,7 +364,7 @@
<item>
<spacer name="horizontalSpacer_2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
<enum>Qt::Orientation::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
Expand All @@ -395,7 +385,7 @@
<item row="4" column="0">
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
<enum>Qt::Orientation::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
Expand Down
26 changes: 6 additions & 20 deletions src/gui/updater/updater.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
* for more details.
*/

#include <QUrl>

Check failure on line 15 in src/gui/updater/updater.cpp

View workflow job for this annotation

GitHub Actions / build

src/gui/updater/updater.cpp:15:10 [clang-diagnostic-error]

'QUrl' file not found
#include <QUrlQuery>
#include <QProcess>

Expand Down Expand Up @@ -75,9 +75,7 @@

QUrlQuery Updater::getQueryParams()
{
QUrlQuery query;
Theme *theme = Theme::instance();
QString platform = QStringLiteral("stranger");
auto platform = QStringLiteral("stranger");
if (Utility::isLinux()) {
platform = QStringLiteral("linux");
} else if (Utility::isBSD()) {
Expand All @@ -88,36 +86,24 @@
platform = QStringLiteral("macos");
}

QString sysInfo = getSystemInfo();
if (!sysInfo.isEmpty()) {
QUrlQuery query;
if (const auto sysInfo = getSystemInfo(); !sysInfo.isEmpty()) {
query.addQueryItem(QStringLiteral("client"), sysInfo);
}
query.addQueryItem(QStringLiteral("version"), clientVersion());
query.addQueryItem(QStringLiteral("platform"), platform);
query.addQueryItem(QStringLiteral("osRelease"), QSysInfo::productType());
query.addQueryItem(QStringLiteral("osVersion"), QSysInfo::productVersion());
query.addQueryItem(QStringLiteral("kernelVersion"), QSysInfo::kernelVersion());
query.addQueryItem(QStringLiteral("oem"), theme->appName());
query.addQueryItem(QStringLiteral("oem"), Theme::instance()->appName());
query.addQueryItem(QStringLiteral("buildArch"), QSysInfo::buildCpuArchitecture());
query.addQueryItem(QStringLiteral("currentArch"), QSysInfo::currentCpuArchitecture());

QString suffix = QStringLiteral(MIRALL_STRINGIFY(MIRALL_VERSION_SUFFIX));
query.addQueryItem(QStringLiteral("versionsuffix"), suffix);

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

// updateSegment (see configfile.h)
ConfigFile cfg;
auto updateSegment = cfg.updateSegment();
query.addQueryItem(QLatin1String("updatesegment"), QString::number(updateSegment));
query.addQueryItem(QStringLiteral("versionsuffix"), Theme::instance()->versionSuffix());
query.addQueryItem(QStringLiteral("channel"), ConfigFile().currentUpdateChannel());

return query;
}


QString Updater::getSystemInfo()
{
#ifdef Q_OS_LINUX
Expand Down
45 changes: 25 additions & 20 deletions src/libsync/configfile.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/*

Check notice on line 1 in src/libsync/configfile.cpp

View workflow job for this annotation

GitHub Actions / build

Run clang-format on src/libsync/configfile.cpp

File src/libsync/configfile.cpp does not conform to Custom style guidelines. (lines 113, 697)
* Copyright (C) by Klaas Freitag <[email protected]>
*
* This program is free software; you can redistribute it and/or modify
Expand All @@ -12,7 +12,7 @@
* for more details.
*/

#include "config.h"

Check failure on line 15 in src/libsync/configfile.cpp

View workflow job for this annotation

GitHub Actions / build

src/libsync/configfile.cpp:15:10 [clang-diagnostic-error]

'config.h' file not found

#include "configfile.h"
#include "theme.h"
Expand Down Expand Up @@ -110,7 +110,8 @@
static constexpr char certPath[] = "http_certificatePath";
static constexpr char certPasswd[] = "http_certificatePasswd";

static const QSet validUpdateChannels { QStringLiteral("stable"), QStringLiteral("beta") };
static const QStringList validUpdateChannelsList { QStringLiteral("stable"), QStringLiteral("beta"), QStringLiteral("daily") };

Check warning on line 113 in src/libsync/configfile.cpp

View workflow job for this annotation

GitHub Actions / build

src/libsync/configfile.cpp:113:26 [readability-static-definition-in-anonymous-namespace]

'validUpdateChannelsList' is a static definition in anonymous namespace; static is redundant here
static constexpr char defaultUpdateChannelName[] = "stable";

Check warning on line 114 in src/libsync/configfile.cpp

View workflow job for this annotation

GitHub Actions / build

src/libsync/configfile.cpp:114:23 [readability-static-definition-in-anonymous-namespace]

'defaultUpdateChannelName' is a static definition in anonymous namespace; static is redundant here
}

namespace OCC {
Expand Down Expand Up @@ -686,37 +687,41 @@
return segment;
}

QString ConfigFile::updateChannel() const
QStringList ConfigFile::validUpdateChannels() const
{
QString defaultUpdateChannel = QStringLiteral("stable");
QString suffix = QString::fromLatin1(MIRALL_STRINGIFY(MIRALL_VERSION_SUFFIX));
if (suffix.startsWith("daily")
|| suffix.startsWith("nightly")
|| suffix.startsWith("alpha")
|| suffix.startsWith("rc")
|| suffix.startsWith("beta")) {
defaultUpdateChannel = QStringLiteral("beta");
return validUpdateChannelsList;
}

QString ConfigFile::defaultUpdateChannel() const
{
if (const auto currentVersionSuffix = Theme::instance()->versionSuffix();
validUpdateChannels().contains(currentVersionSuffix)) {
qCWarning(lcConfigFile()) << "Enforcing update channel" << currentVersionSuffix << "because of the version suffix of the current client.";
return currentVersionSuffix;
}

return defaultUpdateChannelName;
}

QString ConfigFile::currentUpdateChannel() const
{
auto updateChannel = defaultUpdateChannel();
QSettings settings(configFile(), QSettings::IniFormat);
const auto channel = settings.value(QLatin1String(updateChannelC), defaultUpdateChannel).toString();
if (!validUpdateChannels.contains(channel)) {
qCWarning(lcConfigFile()) << "Received invalid update channel from confog:"
<< channel
<< "defaulting to:"
<< defaultUpdateChannel;
return defaultUpdateChannel;
if (const auto configUpdateChannel = settings.value(QLatin1String(updateChannelC), updateChannel).toString();
validUpdateChannels().contains(configUpdateChannel)) {
qCWarning(lcConfigFile()) << "Config file has a valid update channel:" << configUpdateChannel;
updateChannel = configUpdateChannel;
}

return channel;
return updateChannel;
}

void ConfigFile::setUpdateChannel(const QString &channel)
{
if (!validUpdateChannels.contains(channel)) {
if (!validUpdateChannels().contains(channel)) {
qCWarning(lcConfigFile()) << "Received invalid update channel:"
<< channel
<< "can only accept 'stable' or 'beta'. Ignoring.";
<< "can only accept 'stable', 'beta' or 'daily'. Ignoring.";
return;
}

Expand Down
Loading
Loading