2
* Copyright 2013 Canonical Ltd.
4
* This program is free software; you can redistribute it and/or modify
5
* it under the terms of the GNU Lesser General Public License as published by
6
* the Free Software Foundation; version 2.1.
8
* This program is distributed in the hope that it will be useful,
9
* but WITHOUT ANY WARRANTY; without even the implied warranty of
10
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11
* GNU Lesser General Public License for more details.
13
* You should have received a copy of the GNU Lesser General Public License
14
* along with this program. If not, see <http://www.gnu.org/licenses/>.
16
* Author: Juhapekka Piiroinen <juhapekka.piiroinen@canonical.com>
19
#include "ubuntuversion.h"
22
#include <QStringList>
24
using namespace Ubuntu::Internal;
26
UbuntuVersion::UbuntuVersion()
28
QFile lsbRelease(QLatin1String(Constants::LSB_RELEASE));
29
if (lsbRelease.open(QIODevice::ReadOnly)) {
30
QByteArray data = lsbRelease.readAll();
33
foreach(QString line, QString::fromLatin1(data).split(QLatin1String("\n"))) {
34
if (line.startsWith(QLatin1String(Constants::DISTRIB_ID))) {
35
m_id = line.replace(QLatin1String(Constants::DISTRIB_ID),QLatin1String(""));
37
} else if (line.startsWith(QLatin1String(Constants::DISTRIB_RELEASE))) {
38
m_release = line.replace(QLatin1String(Constants::DISTRIB_RELEASE),QLatin1String(""));
40
} else if (line.startsWith(QLatin1String(Constants::DISTRIB_CODENAME))) {
41
m_codename = line.replace(QLatin1String(Constants::DISTRIB_CODENAME),QLatin1String(""));
43
} else if (line.startsWith(QLatin1String(Constants::DISTRIB_DESCRIPTION))) {
44
m_description = line.replace(QLatin1String(Constants::DISTRIB_DESCRIPTION),QLatin1String(""));
50
Core::FeatureSet UbuntuVersion::features() {
51
Core::FeatureSet retval;
52
if (codename()==QLatin1String(Constants::PRECISE)) {
53
retval |= Core::FeatureSet(Constants::FEATURE_UBUNTU_PRECISE);
55
if (codename()==QLatin1String(Constants::QUANTAL)) {
56
retval |= Core::FeatureSet(Constants::FEATURE_UBUNTU_QUANTAL);
58
if (codename()==QLatin1String(Constants::RARING)) {
59
retval |= Core::FeatureSet(Constants::FEATURE_UBUNTU_RARING);
61
if (codename()==QLatin1String(Constants::SAUCY)) {
62
retval |= Core::FeatureSet(Constants::FEATURE_UBUNTU_SAUCY);
63
retval |= Core::FeatureSet(Constants::FEATURE_UNITY_SCOPE);