Skip to content

Commit ba9b340

Browse files
authored
Merge pull request #6658 from nextcloud/feature/update-channel
Add daily update channel.
2 parents 56ff5fb + 4de3107 commit ba9b340

File tree

8 files changed

+92
-102
lines changed

8 files changed

+92
-102
lines changed

VERSION.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ set(NEXTCLOUD_SERVER_VERSION_MOUNT_ROOT_PROPERTY_SUPPORTED_MINOR 0)
1818
set(NEXTCLOUD_SERVER_VERSION_MOUNT_ROOT_PROPERTY_SUPPORTED_PATCH 3)
1919

2020
if ( NOT DEFINED MIRALL_VERSION_SUFFIX )
21-
set( MIRALL_VERSION_SUFFIX "git") #e.g. beta1, beta2, rc1
21+
set( MIRALL_VERSION_SUFFIX "daily") #e.g. beta1, beta2, rc1
2222
endif( NOT DEFINED MIRALL_VERSION_SUFFIX )
2323

2424
if( NOT DEFINED MIRALL_VERSION_BUILD )

src/gui/generalsettings.cpp

Lines changed: 40 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -190,8 +190,6 @@ GeneralSettings::GeneralSettings(QWidget *parent)
190190
});
191191

192192
loadMiscSettings();
193-
// updater info now set in: customizeStyle
194-
//slotUpdateInfo();
195193

196194
// misc
197195
connect(_ui->monoIconsCheckBox, &QAbstractButton::toggled, this, &GeneralSettings::saveMiscSettings);
@@ -281,13 +279,22 @@ void GeneralSettings::loadMiscSettings()
281279
_ui->stopExistingFolderNowBigSyncCheckBox->setChecked(_ui->existingFolderLimitCheckBox->isChecked() && cfgFile.stopSyncingExistingFoldersOverLimit());
282280
_ui->newExternalStorage->setChecked(cfgFile.confirmExternalStorage());
283281
_ui->monoIconsCheckBox->setChecked(cfgFile.monoIcons());
282+
283+
#if defined(BUILD_UPDATER)
284+
auto validUpdateChannels = cfgFile.validUpdateChannels();
285+
_ui->updateChannel->addItems(validUpdateChannels);
286+
const auto currentUpdateChannelIndex = validUpdateChannels.indexOf(cfgFile.currentUpdateChannel());
287+
_ui->updateChannel->setCurrentIndex(currentUpdateChannelIndex != -1? currentUpdateChannelIndex : 0);
288+
connect(_ui->updateChannel, &QComboBox::currentTextChanged, this, &GeneralSettings::slotUpdateChannelChanged);
289+
#endif
284290
}
285291

286292
#if defined(BUILD_UPDATER)
287293
void GeneralSettings::slotUpdateInfo()
288294
{
295+
ConfigFile config;
289296
const auto updater = Updater::instance();
290-
if (ConfigFile().skipUpdateCheck() || !updater) {
297+
if (config.skipUpdateCheck() || !updater) {
291298
// updater disabled on compile
292299
_ui->updatesContainer->setVisible(false);
293300
return;
@@ -297,32 +304,28 @@ void GeneralSettings::slotUpdateInfo()
297304
connect(_ui->updateButton,
298305
&QAbstractButton::clicked,
299306
this,
300-
301307
&GeneralSettings::slotUpdateCheckNow,
302308
Qt::UniqueConnection);
303309
connect(_ui->autoCheckForUpdatesCheckBox, &QAbstractButton::toggled, this,
304310
&GeneralSettings::slotToggleAutoUpdateCheck, Qt::UniqueConnection);
305-
_ui->autoCheckForUpdatesCheckBox->setChecked(ConfigFile().autoUpdateCheck());
311+
_ui->autoCheckForUpdatesCheckBox->setChecked(config.autoUpdateCheck());
306312
}
307313

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

315-
QString status = ocupdater->statusString(OCUpdater::UpdateStatusStringFormat::Html);
320+
auto status = ocupdater->statusString(OCUpdater::UpdateStatusStringFormat::Html);
316321
Theme::replaceLinkColorStringBackgroundAware(status);
317322

318323
_ui->updateStateLabel->setOpenExternalLinks(false);
319324
connect(_ui->updateStateLabel, &QLabel::linkActivated, this, [](const QString &link) {
320325
Utility::openBrowser(QUrl(link));
321326
});
322327
_ui->updateStateLabel->setText(status);
323-
324328
_ui->restartButton->setVisible(ocupdater->downloadState() == OCUpdater::DownloadComplete);
325-
326329
_ui->updateButton->setEnabled(ocupdater->downloadState() != OCUpdater::CheckingServer &&
327330
ocupdater->downloadState() != OCUpdater::Downloading &&
328331
ocupdater->downloadState() != OCUpdater::DownloadComplete);
@@ -339,57 +342,55 @@ void GeneralSettings::slotUpdateInfo()
339342
_ui->updateButton->setEnabled(enableUpdateButton);
340343
}
341344
#endif
342-
343-
// Channel selection
344-
_ui->updateChannel->setCurrentIndex(ConfigFile().updateChannel() == "beta" ? 1 : 0);
345-
connect(_ui->updateChannel, &QComboBox::currentTextChanged,
346-
this, &GeneralSettings::slotUpdateChannelChanged, Qt::UniqueConnection);
347345
}
348346

349347
void GeneralSettings::slotUpdateChannelChanged()
350348
{
351349
const auto updateChannelToLocalized = [](const QString &channel) {
352-
auto decodedTranslatedChannel = QString{};
353-
354350
if (channel == QStringLiteral("stable")) {
355-
decodedTranslatedChannel = tr("stable");
356-
} else if (channel == QStringLiteral("beta")) {
357-
decodedTranslatedChannel = tr("beta");
351+
return tr("stable");
352+
}
353+
354+
if (channel == QStringLiteral("beta")) {
355+
return tr("beta");
358356
}
359357

360-
return decodedTranslatedChannel;
358+
if (channel == QStringLiteral("daily")) {
359+
return tr("daily");
360+
}
361+
362+
return QString{};
361363
};
362364

363365
const auto updateChannelFromLocalized = [](const int index) {
364-
if (index == 1) {
366+
switch(index) {
367+
case 1:
365368
return QStringLiteral("beta");
369+
break;
370+
case 2:
371+
return QStringLiteral("daily");
372+
break;
373+
default:
374+
return QStringLiteral("stable");
366375
}
367-
368-
return QStringLiteral("stable");
369376
};
370377

371378
const auto channel = updateChannelFromLocalized(_ui->updateChannel->currentIndex());
372-
if (channel == ConfigFile().updateChannel()) {
379+
if (channel == ConfigFile().currentUpdateChannel()) {
373380
return;
374381
}
375382

376383
auto msgBox = new QMessageBox(
377384
QMessageBox::Warning,
378-
tr("Change update channel?"),
379-
tr("The update channel determines which client updates will be offered "
380-
"for installation. The \"stable\" channel contains only upgrades that "
381-
"are considered reliable, while the versions in the \"beta\" channel "
382-
"may contain newer features and bugfixes, but have not yet been tested "
383-
"thoroughly."
384-
"\n\n"
385-
"Note that this selects only what pool upgrades are taken from, and that "
386-
"there are no downgrades: So going back from the beta channel to "
387-
"the stable channel usually cannot be done immediately and means waiting "
388-
"for a stable version that is newer than the currently installed beta "
389-
"version."),
385+
tr("Changing update channel?"),
386+
tr("The channel determines which upgrades will be offered to install:\n"
387+
"- stable: contains tested versions considered reliable\n"
388+
"- beta: contains versions with new features that may not be tested thoroughly\n"
389+
"- daily: contains versions created daily only for testing and development\n\n"
390+
"Downgrading versions is not possible immediately: changing from beta to stable means waiting for the new stable version."),
390391
QMessageBox::NoButton,
391392
this);
392-
auto acceptButton = msgBox->addButton(tr("Change update channel"), QMessageBox::AcceptRole);
393+
const auto acceptButton = msgBox->addButton(tr("Change update channel"), QMessageBox::AcceptRole);
393394
msgBox->addButton(tr("Cancel"), QMessageBox::RejectRole);
394395
connect(msgBox, &QMessageBox::finished, msgBox, [this, channel, msgBox, acceptButton, updateChannelToLocalized] {
395396
msgBox->deleteLater();
@@ -406,7 +407,7 @@ void GeneralSettings::slotUpdateChannelChanged()
406407
}
407408
#endif
408409
} else {
409-
_ui->updateChannel->setCurrentText(updateChannelToLocalized(ConfigFile().updateChannel()));
410+
_ui->updateChannel->setCurrentText(updateChannelToLocalized(ConfigFile().currentUpdateChannel()));
410411
}
411412
});
412413
msgBox->open();

src/gui/generalsettings.ui

Lines changed: 11 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
<rect>
77
<x>0</x>
88
<y>0</y>
9-
<width>601</width>
9+
<width>667</width>
1010
<height>663</height>
1111
</rect>
1212
</property>
@@ -40,10 +40,10 @@
4040
<item>
4141
<spacer name="horizontalSpacer">
4242
<property name="orientation">
43-
<enum>Qt::Horizontal</enum>
43+
<enum>Qt::Orientation::Horizontal</enum>
4444
</property>
4545
<property name="sizeType">
46-
<enum>QSizePolicy::Fixed</enum>
46+
<enum>QSizePolicy::Policy::Fixed</enum>
4747
</property>
4848
<property name="sizeHint" stdset="0">
4949
<size>
@@ -77,10 +77,10 @@
7777
<item>
7878
<spacer name="horizontalSpacer_3">
7979
<property name="orientation">
80-
<enum>Qt::Horizontal</enum>
80+
<enum>Qt::Orientation::Horizontal</enum>
8181
</property>
8282
<property name="sizeType">
83-
<enum>QSizePolicy::Fixed</enum>
83+
<enum>QSizePolicy::Policy::Fixed</enum>
8484
</property>
8585
<property name="sizeHint" stdset="0">
8686
<size>
@@ -104,10 +104,10 @@
104104
<item>
105105
<spacer name="horizontalSpacer_5">
106106
<property name="orientation">
107-
<enum>Qt::Horizontal</enum>
107+
<enum>Qt::Orientation::Horizontal</enum>
108108
</property>
109109
<property name="sizeType">
110-
<enum>QSizePolicy::Fixed</enum>
110+
<enum>QSizePolicy::Policy::Fixed</enum>
111111
</property>
112112
<property name="sizeHint" stdset="0">
113113
<size>
@@ -197,7 +197,7 @@
197197
<item>
198198
<spacer name="horizontalSpacer_4">
199199
<property name="orientation">
200-
<enum>Qt::Horizontal</enum>
200+
<enum>Qt::Orientation::Horizontal</enum>
201201
</property>
202202
<property name="sizeHint" stdset="0">
203203
<size>
@@ -269,16 +269,6 @@
269269
<verstretch>0</verstretch>
270270
</sizepolicy>
271271
</property>
272-
<item>
273-
<property name="text">
274-
<string>stable</string>
275-
</property>
276-
</item>
277-
<item>
278-
<property name="text">
279-
<string>beta</string>
280-
</property>
281-
</item>
282272
</widget>
283273
</item>
284274
<item>
@@ -343,7 +333,7 @@
343333
<item>
344334
<spacer name="horizontalSpacer_6">
345335
<property name="orientation">
346-
<enum>Qt::Horizontal</enum>
336+
<enum>Qt::Orientation::Horizontal</enum>
347337
</property>
348338
<property name="sizeHint" stdset="0">
349339
<size>
@@ -374,7 +364,7 @@
374364
<item>
375365
<spacer name="horizontalSpacer_2">
376366
<property name="orientation">
377-
<enum>Qt::Horizontal</enum>
367+
<enum>Qt::Orientation::Horizontal</enum>
378368
</property>
379369
<property name="sizeHint" stdset="0">
380370
<size>
@@ -395,7 +385,7 @@
395385
<item row="4" column="0">
396386
<spacer name="verticalSpacer">
397387
<property name="orientation">
398-
<enum>Qt::Vertical</enum>
388+
<enum>Qt::Orientation::Vertical</enum>
399389
</property>
400390
<property name="sizeHint" stdset="0">
401391
<size>

src/gui/updater/updater.cpp

Lines changed: 6 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -75,9 +75,7 @@ QUrl Updater::updateUrl()
7575

7676
QUrlQuery Updater::getQueryParams()
7777
{
78-
QUrlQuery query;
79-
Theme *theme = Theme::instance();
80-
QString platform = QStringLiteral("stranger");
78+
auto platform = QStringLiteral("stranger");
8179
if (Utility::isLinux()) {
8280
platform = QStringLiteral("linux");
8381
} else if (Utility::isBSD()) {
@@ -88,36 +86,24 @@ QUrlQuery Updater::getQueryParams()
8886
platform = QStringLiteral("macos");
8987
}
9088

91-
QString sysInfo = getSystemInfo();
92-
if (!sysInfo.isEmpty()) {
89+
QUrlQuery query;
90+
if (const auto sysInfo = getSystemInfo(); !sysInfo.isEmpty()) {
9391
query.addQueryItem(QStringLiteral("client"), sysInfo);
9492
}
9593
query.addQueryItem(QStringLiteral("version"), clientVersion());
9694
query.addQueryItem(QStringLiteral("platform"), platform);
9795
query.addQueryItem(QStringLiteral("osRelease"), QSysInfo::productType());
9896
query.addQueryItem(QStringLiteral("osVersion"), QSysInfo::productVersion());
9997
query.addQueryItem(QStringLiteral("kernelVersion"), QSysInfo::kernelVersion());
100-
query.addQueryItem(QStringLiteral("oem"), theme->appName());
98+
query.addQueryItem(QStringLiteral("oem"), Theme::instance()->appName());
10199
query.addQueryItem(QStringLiteral("buildArch"), QSysInfo::buildCpuArchitecture());
102100
query.addQueryItem(QStringLiteral("currentArch"), QSysInfo::currentCpuArchitecture());
103-
104-
QString suffix = QStringLiteral(MIRALL_STRINGIFY(MIRALL_VERSION_SUFFIX));
105-
query.addQueryItem(QStringLiteral("versionsuffix"), suffix);
106-
107-
auto channel = ConfigFile().updateChannel();
108-
if (channel != QLatin1String("stable")) {
109-
query.addQueryItem(QStringLiteral("channel"), channel);
110-
}
111-
112-
// updateSegment (see configfile.h)
113-
ConfigFile cfg;
114-
auto updateSegment = cfg.updateSegment();
115-
query.addQueryItem(QLatin1String("updatesegment"), QString::number(updateSegment));
101+
query.addQueryItem(QStringLiteral("versionsuffix"), Theme::instance()->versionSuffix());
102+
query.addQueryItem(QStringLiteral("channel"), ConfigFile().currentUpdateChannel());
116103

117104
return query;
118105
}
119106

120-
121107
QString Updater::getSystemInfo()
122108
{
123109
#ifdef Q_OS_LINUX

src/libsync/configfile.cpp

Lines changed: 25 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,8 @@ static constexpr char forceLoginV2C[] = "forceLoginV2";
110110
static constexpr char certPath[] = "http_certificatePath";
111111
static constexpr char certPasswd[] = "http_certificatePasswd";
112112

113-
static const QSet validUpdateChannels { QStringLiteral("stable"), QStringLiteral("beta") };
113+
static const QStringList validUpdateChannelsList { QStringLiteral("stable"), QStringLiteral("beta"), QStringLiteral("daily") };
114+
static constexpr char defaultUpdateChannelName[] = "stable";
114115
}
115116

116117
namespace OCC {
@@ -686,37 +687,41 @@ int ConfigFile::updateSegment() const
686687
return segment;
687688
}
688689

689-
QString ConfigFile::updateChannel() const
690+
QStringList ConfigFile::validUpdateChannels() const
690691
{
691-
QString defaultUpdateChannel = QStringLiteral("stable");
692-
QString suffix = QString::fromLatin1(MIRALL_STRINGIFY(MIRALL_VERSION_SUFFIX));
693-
if (suffix.startsWith("daily")
694-
|| suffix.startsWith("nightly")
695-
|| suffix.startsWith("alpha")
696-
|| suffix.startsWith("rc")
697-
|| suffix.startsWith("beta")) {
698-
defaultUpdateChannel = QStringLiteral("beta");
692+
return validUpdateChannelsList;
693+
}
694+
695+
QString ConfigFile::defaultUpdateChannel() const
696+
{
697+
if (const auto currentVersionSuffix = Theme::instance()->versionSuffix();
698+
validUpdateChannels().contains(currentVersionSuffix)) {
699+
qCWarning(lcConfigFile()) << "Enforcing update channel" << currentVersionSuffix << "because of the version suffix of the current client.";
700+
return currentVersionSuffix;
699701
}
700702

703+
return defaultUpdateChannelName;
704+
}
705+
706+
QString ConfigFile::currentUpdateChannel() const
707+
{
708+
auto updateChannel = defaultUpdateChannel();
701709
QSettings settings(configFile(), QSettings::IniFormat);
702-
const auto channel = settings.value(QLatin1String(updateChannelC), defaultUpdateChannel).toString();
703-
if (!validUpdateChannels.contains(channel)) {
704-
qCWarning(lcConfigFile()) << "Received invalid update channel from confog:"
705-
<< channel
706-
<< "defaulting to:"
707-
<< defaultUpdateChannel;
708-
return defaultUpdateChannel;
710+
if (const auto configUpdateChannel = settings.value(QLatin1String(updateChannelC), updateChannel).toString();
711+
validUpdateChannels().contains(configUpdateChannel)) {
712+
qCWarning(lcConfigFile()) << "Config file has a valid update channel:" << configUpdateChannel;
713+
updateChannel = configUpdateChannel;
709714
}
710715

711-
return channel;
716+
return updateChannel;
712717
}
713718

714719
void ConfigFile::setUpdateChannel(const QString &channel)
715720
{
716-
if (!validUpdateChannels.contains(channel)) {
721+
if (!validUpdateChannels().contains(channel)) {
717722
qCWarning(lcConfigFile()) << "Received invalid update channel:"
718723
<< channel
719-
<< "can only accept 'stable' or 'beta'. Ignoring.";
724+
<< "can only accept 'stable', 'beta' or 'daily'. Ignoring.";
720725
return;
721726
}
722727

0 commit comments

Comments
 (0)