mirror of
https://github.com/nextcloud/desktop.git
synced 2024-11-29 12:19:03 +03:00
Modernize ConfigFile::updateChannel and Updater::getQueryParams.
Signed-off-by: Camila Ayres <hello@camilasan.com>
This commit is contained in:
parent
60174c63d5
commit
e2f71e6fb3
2 changed files with 13 additions and 16 deletions
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Reference in a new issue