File indexing completed on 2024-05-12 03:54:59

0001 /*
0002     SPDX-FileCopyrightText: 2014-2019 Harald Sitter <sitter@kde.org>
0003 
0004     SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
0005 */
0006 
0007 #ifndef KOSRELEASE_H
0008 #define KOSRELEASE_H
0009 
0010 #include <kcoreaddons_export.h>
0011 
0012 #include <QString>
0013 #include <QStringList>
0014 
0015 #include <memory>
0016 
0017 /**
0018  * @brief The OSRelease class parses /etc/os-release files
0019  *
0020  * https://www.freedesktop.org/software/systemd/man/os-release.html
0021  *
0022  * os-release is a free desktop standard for describing an operating system.
0023  * This class parses and models os-release files.
0024  *
0025  * @since 5.58.0
0026  */
0027 class KCOREADDONS_EXPORT KOSRelease final
0028 {
0029 public:
0030     /**
0031      * Constructs a new OSRelease instance. Parsing happens in the constructor
0032      * and the data is not cached across instances.
0033      *
0034      * @note The format specification makes no assertions about trailing #
0035      *   comments being supported. They result in undefined behavior.
0036      *
0037      * @param filePath The path to the os-release file. By default the first
0038      *   available file of the paths specified in the os-release manpage is
0039      *   parsed.
0040      */
0041     explicit KOSRelease(const QString &filePath = QString());
0042     ~KOSRelease();
0043 
0044     /** @see https://www.freedesktop.org/software/systemd/man/os-release.html#NAME= */
0045     QString name() const;
0046     /** @see https://www.freedesktop.org/software/systemd/man/os-release.html#VERSION= */
0047     QString version() const;
0048     /** @see https://www.freedesktop.org/software/systemd/man/os-release.html#ID= */
0049     QString id() const;
0050     /** @see https://www.freedesktop.org/software/systemd/man/os-release.html#ID_LIKE= */
0051     QStringList idLike() const;
0052     /** @see https://www.freedesktop.org/software/systemd/man/os-release.html#VERSION_CODENAME= */
0053     QString versionCodename() const;
0054     /** @see https://www.freedesktop.org/software/systemd/man/os-release.html#VERSION_ID= */
0055     QString versionId() const;
0056     /** @see https://www.freedesktop.org/software/systemd/man/os-release.html#PRETTY_NAME= */
0057     QString prettyName() const;
0058     /** @see https://www.freedesktop.org/software/systemd/man/os-release.html#ANSI_COLOR= */
0059     QString ansiColor() const;
0060     /** @see https://www.freedesktop.org/software/systemd/man/os-release.html#CPE_NAME= */
0061     QString cpeName() const;
0062     /** @see https://www.freedesktop.org/software/systemd/man/os-release.html#HOME_URL= */
0063     QString homeUrl() const;
0064     /** @see https://www.freedesktop.org/software/systemd/man/os-release.html#HOME_URL= */
0065     QString documentationUrl() const;
0066     /** @see https://www.freedesktop.org/software/systemd/man/os-release.html#HOME_URL= */
0067     QString supportUrl() const;
0068     /** @see https://www.freedesktop.org/software/systemd/man/os-release.html#HOME_URL= */
0069     QString bugReportUrl() const;
0070     /** @see https://www.freedesktop.org/software/systemd/man/os-release.html#HOME_URL= */
0071     QString privacyPolicyUrl() const;
0072     /** @see https://www.freedesktop.org/software/systemd/man/os-release.html#BUILD_ID= */
0073     QString buildId() const;
0074     /** @see https://www.freedesktop.org/software/systemd/man/os-release.html#VARIANT= */
0075     QString variant() const;
0076     /** @see https://www.freedesktop.org/software/systemd/man/os-release.html#VARIANT_ID= */
0077     QString variantId() const;
0078     /** @see https://www.freedesktop.org/software/systemd/man/os-release.html#LOGO= */
0079     QString logo() const;
0080 
0081     /**
0082      * Extra keys are keys that are unknown or specified by a vendor.
0083      */
0084     QStringList extraKeys() const;
0085 
0086     /** Extra values are values assoicated with keys that are unknown. */
0087     QString extraValue(const QString &key) const;
0088 
0089 private:
0090     Q_DISABLE_COPY(KOSRelease)
0091 
0092     std::unique_ptr<class KOSReleasePrivate> const d;
0093 };
0094 
0095 #endif // KOSRELEASE_H