mirror of
https://github.com/nextcloud/desktop.git
synced 2024-11-25 22:46:04 +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 Updater::getQueryParams()
|
||||||
{
|
{
|
||||||
QUrlQuery query;
|
auto platform = QStringLiteral("stranger");
|
||||||
Theme *theme = Theme::instance();
|
|
||||||
QString platform = QStringLiteral("stranger");
|
|
||||||
if (Utility::isLinux()) {
|
if (Utility::isLinux()) {
|
||||||
platform = QStringLiteral("linux");
|
platform = QStringLiteral("linux");
|
||||||
} else if (Utility::isBSD()) {
|
} else if (Utility::isBSD()) {
|
||||||
|
@ -88,8 +86,8 @@ QUrlQuery Updater::getQueryParams()
|
||||||
platform = QStringLiteral("macos");
|
platform = QStringLiteral("macos");
|
||||||
}
|
}
|
||||||
|
|
||||||
QString sysInfo = getSystemInfo();
|
QUrlQuery query;
|
||||||
if (!sysInfo.isEmpty()) {
|
if (const auto sysInfo = getSystemInfo(); !sysInfo.isEmpty()) {
|
||||||
query.addQueryItem(QStringLiteral("client"), sysInfo);
|
query.addQueryItem(QStringLiteral("client"), sysInfo);
|
||||||
}
|
}
|
||||||
query.addQueryItem(QStringLiteral("version"), clientVersion());
|
query.addQueryItem(QStringLiteral("version"), clientVersion());
|
||||||
|
@ -97,21 +95,20 @@ QUrlQuery Updater::getQueryParams()
|
||||||
query.addQueryItem(QStringLiteral("osRelease"), QSysInfo::productType());
|
query.addQueryItem(QStringLiteral("osRelease"), QSysInfo::productType());
|
||||||
query.addQueryItem(QStringLiteral("osVersion"), QSysInfo::productVersion());
|
query.addQueryItem(QStringLiteral("osVersion"), QSysInfo::productVersion());
|
||||||
query.addQueryItem(QStringLiteral("kernelVersion"), QSysInfo::kernelVersion());
|
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("buildArch"), QSysInfo::buildCpuArchitecture());
|
||||||
query.addQueryItem(QStringLiteral("currentArch"), QSysInfo::currentCpuArchitecture());
|
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);
|
query.addQueryItem(QStringLiteral("versionsuffix"), suffix);
|
||||||
|
|
||||||
auto channel = ConfigFile().updateChannel();
|
ConfigFile config;
|
||||||
if (channel != QLatin1String("stable")) {
|
if (const auto channel = config.updateChannel();
|
||||||
|
channel != QLatin1String("stable")) {
|
||||||
query.addQueryItem(QStringLiteral("channel"), channel);
|
query.addQueryItem(QStringLiteral("channel"), channel);
|
||||||
}
|
}
|
||||||
|
|
||||||
// updateSegment (see configfile.h)
|
const auto updateSegment = config.updateSegment();
|
||||||
ConfigFile cfg;
|
|
||||||
auto updateSegment = cfg.updateSegment();
|
|
||||||
query.addQueryItem(QLatin1String("updatesegment"), QString::number(updateSegment));
|
query.addQueryItem(QLatin1String("updatesegment"), QString::number(updateSegment));
|
||||||
|
|
||||||
return query;
|
return query;
|
||||||
|
|
|
@ -686,9 +686,9 @@ int ConfigFile::updateSegment() const
|
||||||
|
|
||||||
QString ConfigFile::updateChannel() const
|
QString ConfigFile::updateChannel() const
|
||||||
{
|
{
|
||||||
QString defaultUpdateChannel = QStringLiteral("stable");
|
auto defaultUpdateChannel = QStringLiteral("stable");
|
||||||
QString suffix = QString::fromLatin1(MIRALL_STRINGIFY(MIRALL_VERSION_SUFFIX));
|
if (const auto suffix = QString::fromLatin1(MIRALL_STRINGIFY(MIRALL_VERSION_SUFFIX));
|
||||||
if (suffix.startsWith("daily")
|
suffix.startsWith("daily")
|
||||||
|| suffix.startsWith("nightly")
|
|| suffix.startsWith("nightly")
|
||||||
|| suffix.startsWith("alpha")
|
|| suffix.startsWith("alpha")
|
||||||
|| suffix.startsWith("rc")
|
|| suffix.startsWith("rc")
|
||||||
|
@ -699,7 +699,7 @@ QString ConfigFile::updateChannel() const
|
||||||
QSettings settings(configFile(), QSettings::IniFormat);
|
QSettings settings(configFile(), QSettings::IniFormat);
|
||||||
const auto channel = settings.value(QLatin1String(updateChannelC), defaultUpdateChannel).toString();
|
const auto channel = settings.value(QLatin1String(updateChannelC), defaultUpdateChannel).toString();
|
||||||
if (!validUpdateChannels().contains(channel)) {
|
if (!validUpdateChannels().contains(channel)) {
|
||||||
qCWarning(lcConfigFile()) << "Received invalid update channel from confog:"
|
qCWarning(lcConfigFile()) << "Received invalid update channel from config:"
|
||||||
<< channel
|
<< channel
|
||||||
<< "defaulting to:"
|
<< "defaulting to:"
|
||||||
<< defaultUpdateChannel;
|
<< defaultUpdateChannel;
|
||||||
|
|
Loading…
Reference in a new issue