Changeset View
Changeset View
Standalone View
Standalone View
Modules/about-distro/src/OSRelease.cpp
Show First 20 Lines • Show All 134 Lines • ▼ Show 20 Line(s) | 109 | while (!file.atEnd()) { | |||
---|---|---|---|---|---|
135 | } | 135 | } | ||
136 | 136 | | |||
137 | // ID_LIKE is a list and parsed as such (rather than a QString). | 137 | // ID_LIKE is a list and parsed as such (rather than a QString). | ||
138 | if (key == QLatin1String("ID_LIKE")) { | 138 | if (key == QLatin1String("ID_LIKE")) { | ||
139 | setVar(&idLike, value); | 139 | setVar(&idLike, value); | ||
140 | continue; | 140 | continue; | ||
141 | } | 141 | } | ||
142 | 142 | | |||
143 | // os-release explicitly allows for vendor specific aditions. We have no | 143 | // os-release explicitly allows for vendor specific additions, we'll | ||
144 | // interest in those right now. | 144 | // collect them as strings and exposes them as "extras". | ||
145 | QString parsedValue; | ||||
146 | setVar(&parsedValue, value); | ||||
147 | extras.insert(key, parsedValue); | ||||
145 | } | 148 | } | ||
146 | } | 149 | } | ||
147 | 150 | | |||
148 | QString name; | 151 | QString name; | ||
149 | QString version; | 152 | QString version; | ||
150 | QString id; | 153 | QString id; | ||
151 | QStringList idLike; | 154 | QStringList idLike; | ||
152 | QString versionCodename; | 155 | QString versionCodename; | ||
153 | QString versionId; | 156 | QString versionId; | ||
154 | QString prettyName; | 157 | QString prettyName; | ||
155 | QString ansiColor; | 158 | QString ansiColor; | ||
156 | QString cpeName; | 159 | QString cpeName; | ||
157 | QString homeUrl; | 160 | QString homeUrl; | ||
158 | QString documentationUrl; | 161 | QString documentationUrl; | ||
159 | QString supportUrl; | 162 | QString supportUrl; | ||
160 | QString bugReportUrl; | 163 | QString bugReportUrl; | ||
161 | QString privacyPolicyUrl; | 164 | QString privacyPolicyUrl; | ||
162 | QString buildId; | 165 | QString buildId; | ||
163 | QString variant; | 166 | QString variant; | ||
164 | QString variantId; | 167 | QString variantId; | ||
165 | QString logo; | 168 | QString logo; | ||
169 | | ||||
170 | QHash<QString, QString> extras; | ||||
166 | }; | 171 | }; | ||
167 | 172 | | |||
168 | OSRelease::OSRelease(const QString &filePath) | 173 | OSRelease::OSRelease(const QString &filePath) | ||
169 | : d(new Private(filePath)) | 174 | : d(new Private(filePath)) | ||
170 | { | 175 | { | ||
171 | } | 176 | } | ||
172 | 177 | | |||
173 | OSRelease::~OSRelease() | 178 | OSRelease::~OSRelease() | ||
▲ Show 20 Lines • Show All 86 Lines • ▼ Show 20 Line(s) | 264 | { | |||
260 | return d->variantId; | 265 | return d->variantId; | ||
261 | } | 266 | } | ||
262 | 267 | | |||
263 | QString OSRelease::logo() const | 268 | QString OSRelease::logo() const | ||
264 | { | 269 | { | ||
265 | return d->logo; | 270 | return d->logo; | ||
266 | } | 271 | } | ||
267 | 272 | | |||
273 | QStringList OSRelease::extraKeys() const | ||||
274 | { | ||||
275 | return d->extras.keys(); | ||||
276 | } | ||||
277 | | ||||
278 | QString OSRelease::extraValue(const QString &key) const | ||||
279 | { | ||||
280 | return d->extras.value(key); | ||||
281 | } | ||||
282 | | ||||
268 | QString OSRelease::defaultFilePath() | 283 | QString OSRelease::defaultFilePath() | ||
269 | { | 284 | { | ||
270 | if (QFile::exists(QStringLiteral("/etc/os-release"))) { | 285 | if (QFile::exists(QStringLiteral("/etc/os-release"))) { | ||
271 | return QStringLiteral("/etc/os-release"); | 286 | return QStringLiteral("/etc/os-release"); | ||
272 | } else if (QFile::exists(QStringLiteral("/usr/lib/os-release"))) { | 287 | } else if (QFile::exists(QStringLiteral("/usr/lib/os-release"))) { | ||
273 | return QStringLiteral("/usr/lib/os-release"); | 288 | return QStringLiteral("/usr/lib/os-release"); | ||
274 | } else { | 289 | } else { | ||
275 | return QString(); | 290 | return QString(); | ||
276 | } | 291 | } | ||
277 | } | 292 | } |