KUserFeedback

platforminfosource.cpp
1/*
2 SPDX-FileCopyrightText: 2016 Volker Krause <vkrause@kde.org>
3
4 SPDX-License-Identifier: MIT
5*/
6
7#include "platforminfosource.h"
8
9#include <QSysInfo>
10#include <QVariant>
11
12using namespace KUserFeedback;
13
15 AbstractDataSource(QStringLiteral("platform"), Provider::BasicSystemInformation)
16{
17}
18
20{
21 return tr("Type and version of the operating system.");
22}
23
25{
26 QVariantMap m;
27#if (defined(Q_OS_LINUX) && !defined(Q_OS_ANDROID))
28 // on Linux productType() is the distro name
29 m.insert(QStringLiteral("os"), QStringLiteral("linux"));
30
31 // openSUSE Tumbleweed has the current date as version number, that is a bit too precise for us
32 if (QSysInfo::productType() == QLatin1String("opensuse") && QSysInfo::productVersion().startsWith(QLatin1String("201"))) {
33 // old form in use until early 2018
34 m.insert(QStringLiteral("version"), QString(QSysInfo::productType() + QLatin1String("-tumbleweed")));
35 } else if (QSysInfo::productType() == QLatin1String("opensuse-tumbleweed")) {
36 // new form in use since early 2018
37 m.insert(QStringLiteral("version"), QSysInfo::productType());
38 }
39 // Arch and other rolling-release distros set productVersion to "unknown"
40 else if (QSysInfo::productVersion() == QLatin1String("unknown")) {
41 m.insert(QStringLiteral("version"), QSysInfo::productType());
42 } else {
43 m.insert(QStringLiteral("version"), QString(QSysInfo::productType() + QLatin1Char('-') + QSysInfo::productVersion()));
44 }
45#elif defined(Q_OS_MAC)
46 // QSysInfo::productType() on macOS alternates between "osx" and "macos"...
47 m.insert(QStringLiteral("os"), QStringLiteral("macos"));
48 m.insert(QStringLiteral("version"), QSysInfo::productVersion());
49#else
50 m.insert(QStringLiteral("os"), QSysInfo::productType());
51 m.insert(QStringLiteral("version"), QSysInfo::productVersion());
52#endif
53 return m;
54}
55
57{
58 return tr("Platform information");
59}
Base class for data sources for telemetry data.
QVariant data() override
Returns the data gathered by this source.
PlatformInfoSource()
Create a new platform information source.
QString name() const override
Returns a short name of this data source.
QString description() const override
Returns a human-readable, translated description of what this source provides.
The central object managing data sources and transmitting feedback to the server.
Definition provider.h:32
Classes for integrating telemetry collection, survey targeting, and contribution encouragenemt and co...
QString productType()
QString productVersion()
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Mon Nov 18 2024 12:19:03 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.