Commit ed61394b authored by Aard's avatar Aard

[sysinfo] Include the interesting bits of QSystemInfo to avoid depending on...

[sysinfo] Include the interesting bits of QSystemInfo to avoid depending on the whole graphics stack
parent aa0adee6
......@@ -15,6 +15,9 @@
# - file.exists -- checks for existince of a file in the filesystem
# - systeminfo.equals -- compares the model returned by QSystemInfo
# with the value provided
# NOTE: systeminfo matching is currently disabled, as this would
# pull in the whole X11 stack, and on Mer/Nemo does cpuinfo
# matching only anyway, which ssu can do better already.
# - cpuinfo.contains -- searches /proc/cpuinfo for a string
# - arch.equals -- compares with zyppers arch (like i586)
#
......
......@@ -13,7 +13,10 @@ public_headers = \
HEADERS = \
$${public_headers} \
sandbox_p.h \
ssucoreconfig.h
ssucoreconfig.h \
mobility-booty/qofonoservice_linux_p.h \
mobility-booty/qsysteminfo_linux_common_p.h \
mobility-booty/qsysteminfo_dbus_p.h
SOURCES = \
sandbox.cpp \
......@@ -23,11 +26,14 @@ SOURCES = \
ssulog.cpp \
ssuvariables.cpp \
ssurepomanager.cpp \
ssusettings.cpp
ssusettings.cpp \
mobility-booty/qofonoservice_linux.cpp \
mobility-booty/qsysteminfo_linux_common.cpp \
CONFIG += mobility link_pkgconfig
QT += network xml
MOBILITY += systeminfo
#CONFIG += mobility link_pkgconfig
CONFIG += link_pkgconfig
QT += network xml dbus
#MOBILITY += systeminfo
PKGCONFIG += libsystemd-journal
install_headers.files = $${public_headers}
......
This directory contains the handful of bits used from QtSystemInfo, to avoid
pulling in the whole X11 stack.
This diff is collapsed.
/****************************************************************************
**
** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/legal
**
** This file is part of the plugins of the Qt Toolkit.
**
** $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 as published by the Free Software
** Foundation and appearing in the file LICENSE.LGPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: 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.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU
** General Public License version 3.0 as published by the Free Software
** Foundation and appearing in the file LICENSE.GPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU General Public License version 3.0 requirements will be
** met: http://www.gnu.org/copyleft/gpl.html.
**
**
** $QT_END_LICENSE$
**
****************************************************************************/
#ifndef QOFONOSERVICE_H
#define QOFONOSERVICE_H
//
// W A R N I N G
// -------------
//
// This file is not part of the Qt API. It exists purely as an
// implementation detail. This header file may change from version to
// version without notice, or even be removed.
//
// We mean it.
//
//#include "qmobilityglobal.h"
#include <QtDBus/qdbusabstractinterface.h>
#include <QtDBus/qdbuscontext.h>
struct QOfonoProperties
{
QDBusObjectPath path;
QVariantMap properties;
};
Q_DECLARE_METATYPE(QOfonoProperties)
typedef QList<QOfonoProperties> QOfonoPropertyMap;
Q_DECLARE_METATYPE(QOfonoPropertyMap)
//QTM_BEGIN_NAMESPACE
class QOfonoManagerInterface : public QDBusAbstractInterface
{
Q_OBJECT
public:
QOfonoManagerInterface( QObject *parent = 0);
~QOfonoManagerInterface();
QDBusObjectPath currentModem();
QList<QDBusObjectPath> getModems();
Q_SIGNALS:
void propertyChangedContext(const QString &path, const QString &item, const QDBusVariant &value);
protected:
void connectNotify(const char *signal);
void disconnectNotify(const char *signal);
private:
QVariant getProperty(const QString &property);
};
class QOfonoDBusHelper: public QObject, protected QDBusContext
{
Q_OBJECT
public:
QOfonoDBusHelper(QObject *parent = 0);
~QOfonoDBusHelper();
public Q_SLOTS:
void propertyChanged(const QString &item, const QDBusVariant &value);
Q_SIGNALS:
void propertyChangedContext(const QString &path, const QString &item, const QDBusVariant &value);
};
class QOfonoModemInterface : public QDBusAbstractInterface
{
Q_OBJECT
public:
QOfonoModemInterface(const QString &dbusModemPathName, QObject *parent = 0);
~QOfonoModemInterface();
bool isPowered();
QString getSerial();
private:
QVariant getProperty(const QString &property);
};
class QOfonoNetworkRegistrationInterface : public QDBusAbstractInterface
{
Q_OBJECT
public:
QOfonoNetworkRegistrationInterface(const QString &dbusModemPathName, QObject *parent = 0);
~QOfonoNetworkRegistrationInterface();
int getSignalStrength();
QList<QDBusObjectPath> getOperators();
QString getOperatorName();
QString getStatus();
QString getTechnology();
quint16 getLac();
quint32 getCellId();
protected:
void connectNotify(const char *signal);
void disconnectNotify(const char *signal);
private:
QVariant getProperty(const QString &property);
Q_SIGNALS:
void propertyChangedContext(const QString &path, const QString &item, const QDBusVariant &value);
};
class QOfonoNetworkOperatorInterface : public QDBusAbstractInterface
{
Q_OBJECT
public:
QOfonoNetworkOperatorInterface(const QString &dbusPathName, QObject *parent = 0);
~QOfonoNetworkOperatorInterface();
QString getMcc();
QString getMnc();
QString getStatus();
QStringList getTechnologies();
private:
QVariant getProperty(const QString &property);
};
class QOfonoSimInterface : public QDBusAbstractInterface
{
Q_OBJECT
public:
QOfonoSimInterface(const QString &dbusModemPathName, QObject *parent = 0);
~QOfonoSimInterface();
bool isPresent();
QString getHomeMcc();
QString getHomeMnc();
QString getImsi();
QString pinRequired();
private:
QVariant getProperty(const QString &property);
};
class QOfonoConnectionManagerInterface : public QDBusAbstractInterface
{
Q_OBJECT
public:
QOfonoConnectionManagerInterface(const QString &dbusPathName, QObject *parent = 0);
~QOfonoConnectionManagerInterface();
QString bearer();
private:
QVariant getProperty(const QString &);
};
//QTM_END_NAMESPACE
#endif //QOFONOSERVICE_H
/****************************************************************************
**
** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/legal
**
** This file is part of the Qt Mobility Components.
**
** $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 as published by the Free Software
** Foundation and appearing in the file LICENSE.LGPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: 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.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU
** General Public License version 3.0 as published by the Free Software
** Foundation and appearing in the file LICENSE.GPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU General Public License version 3.0 requirements will be
** met: http://www.gnu.org/copyleft/gpl.html.
**
**
** $QT_END_LICENSE$
**
****************************************************************************/
#ifndef QSYSTEMINFO_DBUS_P_H
#define QSYSTEMINFO_DBUS_P_H
static bool ofonoAvailable()
{
if (QDBusConnection::systemBus().isConnected()) {
QDBusReply<bool> reply = QDBusConnection::systemBus().interface()->isServiceRegistered("org.ofono");
if (reply.isValid() && reply.value())
return reply.value();
}
return false;
}
#endif // QSYSTEMINFO_DBUS_P_H
/****************************************************************************
**
** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/legal
**
** This file is part of the Qt Mobility Components.
**
** $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 as published by the Free Software
** Foundation and appearing in the file LICENSE.LGPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: 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.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU
** General Public License version 3.0 as published by the Free Software
** Foundation and appearing in the file LICENSE.GPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU General Public License version 3.0 requirements will be
** met: http://www.gnu.org/copyleft/gpl.html.
**
**
** $QT_END_LICENSE$
**
****************************************************************************/
#include "qsysteminfo_linux_common_p.h"
#include <QTimer>
#include <QFile>
#include <QDir>
#include <QCryptographicHash>
#include <QVariantMap>
#include <QTextStream>
#include <QDebug>
#include <QDBusReply>
#include <QDBusConnectionInterface>
#include <sys/ioctl.h>
#include <sys/socket.h>
#include <unistd.h>
#include "qofonoservice_linux_p.h"
#include "qsysteminfo_dbus_p.h"
//QTM_BEGIN_NAMESPACE
QSystemDeviceInfoLinuxCommonPrivate::QSystemDeviceInfoLinuxCommonPrivate(QObject *parent)
: QObject(parent)
{
}
QSystemDeviceInfoLinuxCommonPrivate::~QSystemDeviceInfoLinuxCommonPrivate()
{
}
QString QSystemDeviceInfoLinuxCommonPrivate::imei()
{
#if !defined(QT_NO_CONNMAN)
if (ofonoAvailable()) {
QOfonoManagerInterface ofonoManager;
QString modem = ofonoManager.currentModem().path();
if (!modem.isEmpty()) {
QOfonoModemInterface modemIface(modem,this);
QString imei = modemIface.getSerial();
if (!imei.isEmpty())
return imei;
}
}
#endif // QT_NO_CONNMAN
return QString();
}
QString QSystemDeviceInfoLinuxCommonPrivate::manufacturer()
{
QFile vendorId("/sys/devices/virtual/dmi/id/board_vendor");
if (vendorId.open(QIODevice::ReadOnly)) {
QTextStream cpuinfo(&vendorId);
return cpuinfo.readLine().trimmed();
} else {
QFile file("/proc/cpuinfo");
if (!file.open(QIODevice::ReadOnly)) {
qDebug() << "Could not open /proc/cpuinfo";
} else {
QTextStream cpuinfo(&file);
QString line = cpuinfo.readLine();
while (!line.isNull()) {
line = cpuinfo.readLine();
if (line.contains("vendor_id"))
return line.split(": ").at(1).trimmed();
}
}
}
return QString();
}
QByteArray QSystemDeviceInfoLinuxCommonPrivate::uniqueDeviceID()
{
QCryptographicHash hash(QCryptographicHash::Sha1);
// Return the DBUS machine ID
QByteArray dbusId = QDBusConnection::localMachineId();
hash.addData(dbusId);
return hash.result().toHex();
}
//#include "moc_qsysteminfo_linux_common_p.cpp"
//QTM_END_NAMESPACE
/****************************************************************************
**
** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/legal
**
** This file is part of the Qt Mobility Components.
**
** $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 as published by the Free Software
** Foundation and appearing in the file LICENSE.LGPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: 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.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU
** General Public License version 3.0 as published by the Free Software
** Foundation and appearing in the file LICENSE.GPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU General Public License version 3.0 requirements will be
** met: http://www.gnu.org/copyleft/gpl.html.
**
**
** $QT_END_LICENSE$
**
****************************************************************************/
#ifndef QSYSTEMINFO_LINUX_COMMON_P_H
#define QSYSTEMINFO_LINUX_COMMON_P_H
//
// W A R N I N G
// -------------
//
// This file is not part of the Qt API. It exists purely as an
// implementation detail. This header file may change from version to
// version without notice, or even be removed.
//
// We mean it.
//
/*
#include "qsysteminfo.h"
#include "qsystemdeviceinfo.h"
*/
#include "qofonoservice_linux_p.h"
//QTM_BEGIN_NAMESPACE
class QSystemDeviceInfoLinuxCommonPrivate : public QObject
{
Q_OBJECT
public:
QSystemDeviceInfoLinuxCommonPrivate(QObject *parent = 0);
virtual ~QSystemDeviceInfoLinuxCommonPrivate();
QByteArray uniqueDeviceID(); //1.2
QString imei();
QString manufacturer();
};
//QTM_END_NAMESPACE
#endif // QSYSTEMINFO_LINUX_COMMON_P_H
......@@ -5,7 +5,7 @@
* @date 2013
*/
#include <QSystemDeviceInfo>
#include <QTextStream>
#include <QDir>
......@@ -15,7 +15,10 @@
#include "../constants.h"
QTM_USE_NAMESPACE
#include "mobility-booty/qsysteminfo_linux_common_p.h"
//#include <QSystemDeviceInfo>
//QTM_USE_NAMESPACE
SsuDeviceInfo::SsuDeviceInfo(QString model): QObject(){
......@@ -139,7 +142,14 @@ QString SsuDeviceInfo::deviceModel(){
if (!cachedModel.isEmpty()) return cachedModel;
// check if the QSystemInfo model is useful
QSystemDeviceInfo devInfo;
//QSystemDeviceInfo devInfo;
// TODO Current Mer SystemDeviceInfo only returns cpuinfo stuff,
// which is what we can do with cpuinfo matching in a more
// flexible way, so there's not really any need to pull in the
// whole X11 stack just for this. Can be enabled once systeminfo
// is less insane
/*
QSystemDeviceInfoLinuxCommonPrivate devInfo;
QString model = devInfo.model();
boardMappings->beginGroup("systeminfo.equals");
keys = boardMappings->allKeys();
......@@ -152,6 +162,7 @@ QString SsuDeviceInfo::deviceModel(){
}
boardMappings->endGroup();
if (!cachedModel.isEmpty()) return cachedModel;
*/
// check if the device can be identified by a string in /proc/cpuinfo
procCpuinfo.setFileName("/proc/cpuinfo");
......@@ -195,7 +206,8 @@ QString SsuDeviceInfo::deviceModel(){
QString SsuDeviceInfo::deviceUid(){
QString IMEI;
QSystemDeviceInfo devInfo;
//QSystemDeviceInfo devInfo;
QSystemDeviceInfoLinuxCommonPrivate devInfo;
IMEI = devInfo.imei();
......
......@@ -7,8 +7,11 @@ License: GPLv2
Source0: %{name}-%{version}.tar.gz
URL: https://github.com/nemomobile/ssu
BuildRequires: pkgconfig(QtCore)
BuildRequires: pkgconfig(QtDBus)
BuildRequires: pkgconfig(QtDeclarative)
BuildRequires: pkgconfig(QtNetwork)
BuildRequires: pkgconfig(QtXml)
BuildRequires: pkgconfig(libzypp)
BuildRequires: pkgconfig(QtSystemInfo)
BuildRequires: pkgconfig(qt-boostable)
BuildRequires: pkgconfig(libsystemd-journal)
BuildRequires: oneshot
......
CONFIG -= gui
QT -= gui
INCLUDEPATH *= $$PWD
DEPENDPATH *= $$PWD
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment