#if defined(BUILD_UPDATER)
auto validUpdateChannels = cfgFile.validUpdateChannels();
_ui->updateChannel->addItems(validUpdateChannels);
- const auto currentUpdateChannelIndex = validUpdateChannels.indexOf(cfgFile.updateChannel());
+ const auto currentUpdateChannelIndex = validUpdateChannels.indexOf(cfgFile.currentUpdateChannel());
_ui->updateChannel->setCurrentIndex(currentUpdateChannelIndex != -1? currentUpdateChannelIndex : 0);
connect(_ui->updateChannel, &QComboBox::currentTextChanged, this, &GeneralSettings::slotUpdateChannelChanged);
#endif
};
const auto channel = updateChannelFromLocalized(_ui->updateChannel->currentIndex());
- if (channel == ConfigFile().updateChannel()) {
+ if (channel == ConfigFile().currentUpdateChannel()) {
return;
}
}
#endif
} else {
- _ui->updateChannel->setCurrentText(updateChannelToLocalized(ConfigFile().updateChannel()));
+ _ui->updateChannel->setCurrentText(updateChannelToLocalized(ConfigFile().currentUpdateChannel()));
}
});
msgBox->open();
query.addQueryItem(QStringLiteral("oem"), Theme::instance()->appName());
query.addQueryItem(QStringLiteral("buildArch"), QSysInfo::buildCpuArchitecture());
query.addQueryItem(QStringLiteral("currentArch"), QSysInfo::currentCpuArchitecture());
-
- const auto suffix = Theme::instance()->versionSuffix();
- query.addQueryItem(QStringLiteral("versionsuffix"), suffix);
+ query.addQueryItem(QStringLiteral("versionsuffix"), Theme::instance()->versionSuffix());
ConfigFile config;
- if (const auto channel = config.updateChannel();
- channel != QLatin1String("stable")) {
- query.addQueryItem(QStringLiteral("channel"), channel);
- }
-
- const auto updateSegment = config.updateSegment();
- query.addQueryItem(QLatin1String("updatesegment"), QString::number(updateSegment));
+ query.addQueryItem(QStringLiteral("channel"), config.currentUpdateChannel());
+ query.addQueryItem(QLatin1String("updatesegment"), QString::number(config.updateSegment()));
return query;
}
-
QString Updater::getSystemInfo()
{
#ifdef Q_OS_LINUX
static constexpr char certPath[] = "http_certificatePath";
static constexpr char certPasswd[] = "http_certificatePasswd";
+
+static const QStringList validUpdateChannelsList { QStringLiteral("stable"), QStringLiteral("beta"), QStringLiteral("daily") };
+static const char stableUpdateChannel[] = "stable";
}
namespace OCC {
return segment;
}
-QString ConfigFile::updateChannel() const
+QStringList ConfigFile::validUpdateChannels() const
{
- auto defaultUpdateChannel = Theme::instance()->versionSuffix();
- 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 config:"
- << channel
- << "defaulting to:"
- << defaultUpdateChannel;
- return defaultUpdateChannel;
+ 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 channel;
+ return stableUpdateChannel;
}
-QStringList ConfigFile::validUpdateChannels() const
+QString ConfigFile::currentUpdateChannel() const
{
- return { QStringLiteral("stable"), QStringLiteral("beta"), QStringLiteral("daily") };
+ QSettings settings(configFile(), QSettings::IniFormat);
+ if (const auto configUpdateChannel = settings.value(QLatin1String(updateChannelC), defaultUpdateChannel()).toString();
+ validUpdateChannels().contains(configUpdateChannel)) {
+ qCWarning(lcConfigFile()) << "Config file has a valid update channel:" << configUpdateChannel;
+ return configUpdateChannel;
+ }
+
+ return defaultUpdateChannel();
}
void ConfigFile::setUpdateChannel(const QString &channel)
See: https://github.com/nextcloud/client_updater_server/pull/36 */
[[nodiscard]] int updateSegment() const;
- [[nodiscard]] QString updateChannel() const;
+ [[nodiscard]] QString currentUpdateChannel() const;
+ [[nodiscard]] QString defaultUpdateChannel() const;
[[nodiscard]] QStringList validUpdateChannels() const;
void setUpdateChannel(const QString &channel);