Modernize ConfigFile::updateChannel and Updater::getQueryParams.

Signed-off-by: Camila Ayres <hello@camilasan.com>
This commit is contained in:
Camila Ayres 2024-06-03 16:08:59 +02:00
parent 60174c63d5
commit e2f71e6fb3
No known key found for this signature in database
GPG key ID: 7A4A6121E88E2AD4
2 changed files with 13 additions and 16 deletions

View file

@ -75,9 +75,7 @@ QUrl Updater::updateUrl()
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()) {
@ -88,8 +86,8 @@ QUrlQuery Updater::getQueryParams()
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());
@ -97,21 +95,20 @@ QUrlQuery Updater::getQueryParams()
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));
const auto suffix = QStringLiteral(MIRALL_STRINGIFY(MIRALL_VERSION_SUFFIX));
query.addQueryItem(QStringLiteral("versionsuffix"), suffix);
auto channel = ConfigFile().updateChannel();
if (channel != QLatin1String("stable")) {
ConfigFile config;
if (const auto channel = config.updateChannel();
channel != QLatin1String("stable")) {
query.addQueryItem(QStringLiteral("channel"), channel);
}
// updateSegment (see configfile.h)
ConfigFile cfg;
auto updateSegment = cfg.updateSegment();
const auto updateSegment = config.updateSegment();
query.addQueryItem(QLatin1String("updatesegment"), QString::number(updateSegment));
return query;

View file

@ -686,9 +686,9 @@ int ConfigFile::updateSegment() const
QString ConfigFile::updateChannel() const
{
QString defaultUpdateChannel = QStringLiteral("stable");
QString suffix = QString::fromLatin1(MIRALL_STRINGIFY(MIRALL_VERSION_SUFFIX));
if (suffix.startsWith("daily")
auto defaultUpdateChannel = QStringLiteral("stable");
if (const auto suffix = QString::fromLatin1(MIRALL_STRINGIFY(MIRALL_VERSION_SUFFIX));
suffix.startsWith("daily")
|| suffix.startsWith("nightly")
|| suffix.startsWith("alpha")
|| suffix.startsWith("rc")
@ -699,7 +699,7 @@ QString ConfigFile::updateChannel() const
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:"
qCWarning(lcConfigFile()) << "Received invalid update channel from config:"
<< channel
<< "defaulting to:"
<< defaultUpdateChannel;