~zeller-benjamin/qtcreator-plugin-ubuntu/displayvar

« back to all changes in this revision

Viewing changes to ubuntuversion.cpp

  • Committer: Juhapekka Piiroinen
  • Date: 2013-09-04 15:30:00 UTC
  • mto: (23.1.14 binary-plugin)
  • mto: This revision was merged to the branch mainline in revision 24.
  • Revision ID: juhapekka.piiroinen@canonical.com-20130904153000-r4lhfhrjlwmop277
Added cordova plugin from ubuntu-qtcreator-plugins.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*
2
 
 * Copyright 2013 Canonical Ltd.
3
 
 *
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.
7
 
 *
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.
12
 
 *
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/>.
15
 
 *
16
 
 * Author: Juhapekka Piiroinen <juhapekka.piiroinen@canonical.com>
17
 
 */
18
 
 
19
 
#include "ubuntuversion.h"
20
 
 
21
 
#include <QFile>
22
 
#include <QStringList>
23
 
 
24
 
using namespace Ubuntu::Internal;
25
 
 
26
 
UbuntuVersion::UbuntuVersion()
27
 
{
28
 
    QFile lsbRelease(QLatin1String(Constants::LSB_RELEASE));
29
 
    if (lsbRelease.open(QIODevice::ReadOnly)) {
30
 
        QByteArray data = lsbRelease.readAll();
31
 
        lsbRelease.close();
32
 
 
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(""));
36
 
 
37
 
            } else if (line.startsWith(QLatin1String(Constants::DISTRIB_RELEASE))) {
38
 
                m_release = line.replace(QLatin1String(Constants::DISTRIB_RELEASE),QLatin1String(""));
39
 
 
40
 
            } else if (line.startsWith(QLatin1String(Constants::DISTRIB_CODENAME))) {
41
 
                m_codename = line.replace(QLatin1String(Constants::DISTRIB_CODENAME),QLatin1String(""));
42
 
 
43
 
            } else if (line.startsWith(QLatin1String(Constants::DISTRIB_DESCRIPTION))) {
44
 
                m_description = line.replace(QLatin1String(Constants::DISTRIB_DESCRIPTION),QLatin1String(""));
45
 
            }
46
 
        }
47
 
    }
48
 
}
49
 
 
50
 
Core::FeatureSet UbuntuVersion::features() {
51
 
   Core::FeatureSet retval;
52
 
    if (codename()==QLatin1String(Constants::PRECISE)) {
53
 
        retval |= Core::FeatureSet(Constants::FEATURE_UBUNTU_PRECISE);
54
 
    } else
55
 
    if (codename()==QLatin1String(Constants::QUANTAL)) {
56
 
        retval |= Core::FeatureSet(Constants::FEATURE_UBUNTU_QUANTAL);
57
 
    } else
58
 
    if (codename()==QLatin1String(Constants::RARING)) {
59
 
        retval |= Core::FeatureSet(Constants::FEATURE_UBUNTU_RARING);
60
 
    } else
61
 
    if (codename()==QLatin1String(Constants::SAUCY)) {
62
 
        retval |= Core::FeatureSet(Constants::FEATURE_UBUNTU_SAUCY);
63
 
        retval |= Core::FeatureSet(Constants::FEATURE_UNITY_SCOPE);
64
 
    }
65
 
    return retval;
66
 
}