summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorKai Koehne <kai.koehne@theqtcompany.com>2014-12-03 10:41:48 +0100
committerKai Koehne <kai.koehne@theqtcompany.com>2014-12-05 14:02:38 +0100
commitde748023e53ce84afd01cde0ca380cddad057a4d (patch)
tree9f20ee8f0e374ac97ac37f8df2fa8ba56341481b /src
parent587bc6fb7c905422c3f09bc8ea2ac91c91d25cc8 (diff)
Expose systemInfo API
Add systemInfo as a wrapper for QSystemInfo. Task-number: QTIFW-592 Change-Id: Ib54fcea8b0ef3a397a74f5315202f3000abd63cd Reviewed-by: Niels Weber <niels.weber@theqtcompany.com> Reviewed-by: Jarek Kobus <jaroslaw.kobus@theqtcompany.com>
Diffstat (limited to 'src')
-rw-r--r--src/libs/installer/installer.pro6
-rw-r--r--src/libs/installer/scriptengine.cpp3
-rw-r--r--src/libs/installer/systeminfo.cpp185
-rw-r--r--src/libs/installer/systeminfo.h68
4 files changed, 260 insertions, 2 deletions
diff --git a/src/libs/installer/installer.pro b/src/libs/installer/installer.pro
index 700943739..34c7adba9 100644
--- a/src/libs/installer/installer.pro
+++ b/src/libs/installer/installer.pro
@@ -121,7 +121,8 @@ HEADERS += packagemanagercore.h \
componentchecker.h \
proxycredentialsdialog.h \
serverauthenticationdialog.h \
- keepaliveobject.h
+ keepaliveobject.h \
+ systeminfo.h
SOURCES += packagemanagercore.cpp \
packagemanagercore_p.cpp \
@@ -192,7 +193,8 @@ SOURCES += packagemanagercore.cpp \
componentchecker.cpp \
proxycredentialsdialog.cpp \
serverauthenticationdialog.cpp \
- keepaliveobject.cpp
+ keepaliveobject.cpp \
+ systeminfo.cpp
FORMS += proxycredentialsdialog.ui \
serverauthenticationdialog.ui
diff --git a/src/libs/installer/scriptengine.cpp b/src/libs/installer/scriptengine.cpp
index 428e95a8f..c67295f57 100644
--- a/src/libs/installer/scriptengine.cpp
+++ b/src/libs/installer/scriptengine.cpp
@@ -36,6 +36,7 @@
#include "messageboxhandler.h"
#include "errors.h"
#include "scriptengine_p.h"
+#include "systeminfo.h"
#include <QMetaEnum>
#include <QQmlEngine>
@@ -262,6 +263,8 @@ ScriptEngine::ScriptEngine(PackageManagerCore *core)
#else
m_engine.installTranslatorFunctions();
#endif
+ global.setProperty(QLatin1String("systemInfo"), m_engine.newQObject(new SystemInfo));
+
global.setProperty(QLatin1String("QInstaller"), generateQInstallerObject());
global.setProperty(QLatin1String("buttons"), generateWizardButtonsObject());
global.setProperty(QLatin1String("QMessageBox"), generateMessageBoxObject());
diff --git a/src/libs/installer/systeminfo.cpp b/src/libs/installer/systeminfo.cpp
new file mode 100644
index 000000000..0cf9cd935
--- /dev/null
+++ b/src/libs/installer/systeminfo.cpp
@@ -0,0 +1,185 @@
+/**************************************************************************
+**
+** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the Qt Installer Framework.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 or version 3 as published by the Free
+** Software Foundation and appearing in the file LICENSE.LGPLv21 and
+** LICENSE.LGPLv3 included in the packaging of this file. Please review the
+** following information to ensure the GNU Lesser General Public License
+** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+**
+** $QT_END_LICENSE$
+**
+**************************************************************************/
+
+#include "systeminfo.h"
+#include <QSysInfo>
+
+namespace QInstaller {
+
+/*!
+ \qmltype systemInfo
+ \inqmlmodule scripting
+
+ \brief Provides information about the operating system.
+*/
+
+
+SystemInfo::SystemInfo(QObject *parent) : QObject(parent)
+{
+}
+
+
+/*!
+ \qmlproperty string systemInfo::currentCpuArchitecture
+
+ The architecture of the CPU that the application is running on, in text format.
+
+ Possible values include
+ \list
+ \li "i386"
+ \li "x86_64"
+ \endlist
+
+ Note that this function depends on what the OS will report and may not detect the actual CPU
+ architecture if the OS hides that information or is unable to provide it. For example, a 32-bit
+ OS running on a 64-bit CPU is usually unable to determine whether the CPU is actually capable
+ of running 64-bit programs.
+
+ \sa QSysInfo::currentCpuArchitecture()
+*/
+QString SystemInfo::currentCpuArchitecture() const
+{
+ return QSysInfo::currentCpuArchitecture();
+}
+
+/*!
+ \qmlproperty string systemInfo::kernelType
+
+ The type of the operating system kernel the installer was compiled for. It is also the
+ kernel the installer is running on, unless the host operating system is running a form of
+ compatibility or virtualization layer.
+
+ For Windows, Linux, and OS X this will return
+ \list
+ \li "winnt"
+ \li "linux"
+ \li "darwin"
+ \endlist
+
+ On Unix systems, it returns the same as the output of \c {uname -s} (lowercased).
+
+ \sa QSysInfo::kernelType()
+*/
+QString SystemInfo::kernelType() const
+{
+ return QSysInfo::kernelType();
+}
+
+/*!
+ \qmlproperty string systemInfo::kernelVersion
+
+ Example values are
+
+ \list
+ \li "6.1.7601" for Windows 7 with Service Pack 1
+ \li "3.16.6-2-desktop" for openSUSE 13.2 kernel 3.16.6-2
+ \li "12.5.0" last release of OS X "Mountain Lion"
+ \endlist
+
+ The release version of the operating system kernel. On Windows, it returns the version of the
+ NT or CE kernel. On Unix systems, including OS X, it returns the same as the \c {uname -r}
+ command would return.
+
+ \sa QSysInfo::kernelVersion()
+*/
+QString SystemInfo::kernelVersion() const
+{
+ return QSysInfo::kernelVersion();
+}
+
+/*!
+ \qmlproperty string systemInfo::productType
+
+ The product name of the operating system this application is running in.
+
+ Example values are
+
+ \list
+ \li "windows"
+ \li "opensuse" (for the Linux openSUSE distribution)
+ \li "osx"
+ \endlist
+
+ \sa QSysInfo::productType()
+*/
+QString SystemInfo::productType() const
+{
+ return QSysInfo::productType();
+}
+
+/*!
+ \qmlproperty string systemInfo::productVersion
+
+ The product version of the operating system in string form. If the version could not be
+ determined, this function returns "unknown".
+
+ Example values are
+
+ \list
+ \li "7" for Windows 7
+ \li "13.2" for openSUSE 13.2
+ \li "10.8" for OS X Mountain Lion
+ \endlist
+
+ \sa QSysInfo::productVersion()
+*/
+QString SystemInfo::productVersion() const
+{
+ return QSysInfo::productVersion();
+}
+
+/*!
+ \qmlproperty string systemInfo::prettyProductName
+
+ A prettier form of systemInfo::productType and systemInfo::productVersion, containing other
+ tokens like the operating system type, codenames and other information. The result of this
+ function is suitable for displaying to the user.
+
+ Example values are
+
+ \list
+ \li "Windows 7"
+ \li "openSUSE 13.2 (Harlequin) (x86_64)"
+ \li "OS X Mountain Lion (10.8)"
+ \endlist
+
+
+ \sa QSysInfo::prettyProductName()
+*/
+QString SystemInfo::prettyProductName() const
+{
+ return QSysInfo::prettyProductName();
+}
+
+} // namespace QInstaller
diff --git a/src/libs/installer/systeminfo.h b/src/libs/installer/systeminfo.h
new file mode 100644
index 000000000..b352d3f72
--- /dev/null
+++ b/src/libs/installer/systeminfo.h
@@ -0,0 +1,68 @@
+/**************************************************************************
+**
+** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the Qt Installer Framework.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 or version 3 as published by the Free
+** Software Foundation and appearing in the file LICENSE.LGPLv21 and
+** LICENSE.LGPLv3 included in the packaging of this file. Please review the
+** following information to ensure the GNU Lesser General Public License
+** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+**
+** $QT_END_LICENSE$
+**
+**************************************************************************/
+
+#ifndef SYSTEMINFO_H
+#define SYSTEMINFO_H
+
+#include <QObject>
+
+namespace QInstaller {
+
+class SystemInfo : public QObject
+{
+ Q_OBJECT
+ Q_DISABLE_COPY(SystemInfo)
+
+ Q_PROPERTY(QString currentCpuArchitecture READ currentCpuArchitecture CONSTANT)
+ Q_PROPERTY(QString kernelType READ kernelType CONSTANT)
+ Q_PROPERTY(QString kernelVersion READ kernelVersion CONSTANT)
+ Q_PROPERTY(QString productType READ productType CONSTANT)
+ Q_PROPERTY(QString productVersion READ productVersion CONSTANT)
+ Q_PROPERTY(QString prettyProductName READ prettyProductName CONSTANT)
+
+public:
+ explicit SystemInfo(QObject *parent = 0);
+
+ QString currentCpuArchitecture() const;
+
+ QString kernelType() const;
+ QString kernelVersion() const;
+ QString productType() const;
+ QString productVersion() const;
+ QString prettyProductName() const;
+};
+
+} // namespace QInstaller
+
+#endif // SYSTEMINFO_H