1 | /* |
---|---|
2 | SPDX-FileCopyrightText: 2014-2019 Harald Sitter <sitter@kde.org> |
3 | |
4 | SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL |
5 | */ |
6 | |
7 | #ifndef KOSRELEASE_H |
8 | #define KOSRELEASE_H |
9 | |
10 | #include <kcoreaddons_export.h> |
11 | |
12 | #include <QString> |
13 | #include <QStringList> |
14 | |
15 | #include <memory> |
16 | |
17 | /*! |
18 | * \class KOSRelease |
19 | * \inmodule KCoreAddons |
20 | * |
21 | * \brief The OSRelease class parses /etc/os-release files. |
22 | * |
23 | * https://www.freedesktop.org/software/systemd/man/os-release.html |
24 | * |
25 | * os-release is a free desktop standard for describing an operating system. |
26 | * This class parses and models os-release files. |
27 | * |
28 | * \since 5.58.0 |
29 | */ |
30 | class KCOREADDONS_EXPORT KOSRelease final |
31 | { |
32 | public: |
33 | /*! |
34 | * Constructs a new OSRelease instance. Parsing happens in the constructor |
35 | * and the data is not cached across instances. |
36 | * |
37 | * \note The format specification makes no assertions about trailing # |
38 | * comments being supported. They result in undefined behavior. |
39 | * |
40 | * \a filePath The path to the os-release file. By default the first |
41 | * available file of the paths specified in the os-release manpage is |
42 | * parsed. |
43 | */ |
44 | explicit KOSRelease(const QString &filePath = QString()); |
45 | ~KOSRelease(); |
46 | |
47 | /*! See \l https://www.freedesktop.org/software/systemd/man/os-release.html#NAME= */ |
48 | QString name() const; |
49 | /*! See \l https://www.freedesktop.org/software/systemd/man/os-release.html#VERSION= */ |
50 | QString version() const; |
51 | /*! See \l https://www.freedesktop.org/software/systemd/man/os-release.html#ID= */ |
52 | QString id() const; |
53 | /*! See \l https://www.freedesktop.org/software/systemd/man/os-release.html#ID_LIKE= */ |
54 | QStringList idLike() const; |
55 | /*! See \l https://www.freedesktop.org/software/systemd/man/os-release.html#VERSION_CODENAME= */ |
56 | QString versionCodename() const; |
57 | /*! See \l https://www.freedesktop.org/software/systemd/man/os-release.html#VERSION_ID= */ |
58 | QString versionId() const; |
59 | /*! See \l https://www.freedesktop.org/software/systemd/man/os-release.html#PRETTY_NAME= */ |
60 | QString prettyName() const; |
61 | /*! See \l https://www.freedesktop.org/software/systemd/man/os-release.html#ANSI_COLOR= */ |
62 | QString ansiColor() const; |
63 | /*! See \l https://www.freedesktop.org/software/systemd/man/os-release.html#CPE_NAME= */ |
64 | QString cpeName() const; |
65 | /*! See \l https://www.freedesktop.org/software/systemd/man/os-release.html#HOME_URL= */ |
66 | QString homeUrl() const; |
67 | /*! See \l https://www.freedesktop.org/software/systemd/man/os-release.html#HOME_URL= */ |
68 | QString documentationUrl() const; |
69 | /*! See \l https://www.freedesktop.org/software/systemd/man/os-release.html#HOME_URL= */ |
70 | QString supportUrl() const; |
71 | /*! See \l https://www.freedesktop.org/software/systemd/man/os-release.html#HOME_URL= */ |
72 | QString bugReportUrl() const; |
73 | /*! See \l https://www.freedesktop.org/software/systemd/man/os-release.html#HOME_URL= */ |
74 | QString privacyPolicyUrl() const; |
75 | /*! See \l https://www.freedesktop.org/software/systemd/man/os-release.html#BUILD_ID= */ |
76 | QString buildId() const; |
77 | /*! See \l https://www.freedesktop.org/software/systemd/man/os-release.html#VARIANT= */ |
78 | QString variant() const; |
79 | /*! See \l https://www.freedesktop.org/software/systemd/man/os-release.html#VARIANT_ID= */ |
80 | QString variantId() const; |
81 | /*! See \l https://www.freedesktop.org/software/systemd/man/os-release.html#LOGO= */ |
82 | QString logo() const; |
83 | |
84 | /*! |
85 | * Extra keys are keys that are unknown or specified by a vendor. |
86 | */ |
87 | QStringList extraKeys() const; |
88 | |
89 | /*! Extra values are values associated with keys that are unknown. */ |
90 | QString extraValue(const QString &key) const; |
91 | |
92 | private: |
93 | Q_DISABLE_COPY(KOSRelease) |
94 | |
95 | std::unique_ptr<class KOSReleasePrivate> const d; |
96 | }; |
97 | |
98 | #endif // KOSRELEASE_H |
99 |