From fa51c31f18f5f684f3c91cece55ef0c27e1ebddd Mon Sep 17 00:00:00 2001 From: Bernd Wachter Date: Mon, 29 Apr 2013 15:43:06 +0300 Subject: [PATCH] [ssu] Add support for libboardname --- board-mappings.ini | 4 ++++ libssu/libssu.pro | 2 +- libssu/ssudeviceinfo.cpp | 32 ++++++++++++++++++++++++++++++++ rpm/ssu.spec | 1 + 4 files changed, 38 insertions(+), 1 deletion(-) diff --git a/board-mappings.ini b/board-mappings.ini index b7fb83c..2ee95eb 100644 --- a/board-mappings.ini +++ b/board-mappings.ini @@ -13,6 +13,10 @@ # # Valid categories for determining the model: # - file.exists -- checks for existince of a file in the filesystem +# - boardname.equals -- compares with boardname +# - boardname.contains -- searches for substring in boardname +# NOTE: only use boardname if none of the other options match +# use the boardname command to set/check the current value # - systeminfo.equals -- compares the model returned by QSystemInfo # with the value provided # NOTE: systeminfo matching is currently disabled, as this would diff --git a/libssu/libssu.pro b/libssu/libssu.pro index 5cd33e6..ca5899d 100644 --- a/libssu/libssu.pro +++ b/libssu/libssu.pro @@ -34,7 +34,7 @@ SOURCES = \ CONFIG += link_pkgconfig QT += network xml dbus #MOBILITY += systeminfo -PKGCONFIG += libsystemd-journal +PKGCONFIG += libsystemd-journal boardname install_headers.files = $${public_headers} diff --git a/libssu/ssudeviceinfo.cpp b/libssu/ssudeviceinfo.cpp index ec7dfc1..d1a80ce 100644 --- a/libssu/ssudeviceinfo.cpp +++ b/libssu/ssudeviceinfo.cpp @@ -11,6 +11,10 @@ #include +extern "C" { +#include +} + #include "ssudeviceinfo.h" #include "ssucoreconfig.h" #include "ssulog.h" @@ -125,6 +129,7 @@ QString SsuDeviceInfo::deviceModel(){ QDir dir; QFile procCpuinfo; QStringList keys; + QStringList sections; if (!cachedModel.isEmpty()) return cachedModel; @@ -143,6 +148,33 @@ QString SsuDeviceInfo::deviceModel(){ boardMappings->endGroup(); if (!cachedModel.isEmpty()) return cachedModel; + // check if boardname matches/contains + QString boardName(getboardname()); + boardName = boardName.trimmed(); + sections.clear(); + sections << "boardname.equals" << "boardname.contains"; + foreach (const QString §ion, sections){ + boardMappings->beginGroup(section); + keys = boardMappings->allKeys(); + foreach (const QString &key, keys){ + QString value = boardMappings->value(key).toString(); + if (section.endsWith(".contains")){ + if (boardName.contains(value)){ + cachedModel = key; + break; + } + } else if (section.endsWith(".equals")){ + if (boardName == value){ + cachedModel = key; + break; + } + } + } + boardMappings->endGroup(); + if (!cachedModel.isEmpty()) break; + } + if (!cachedModel.isEmpty()) return cachedModel; + // check if the QSystemInfo model is useful //QSystemDeviceInfo devInfo; // TODO Current Mer SystemDeviceInfo only returns cpuinfo stuff, diff --git a/rpm/ssu.spec b/rpm/ssu.spec index 35a659b..d2d76f8 100644 --- a/rpm/ssu.spec +++ b/rpm/ssu.spec @@ -6,6 +6,7 @@ Group: System/Base License: GPLv2 Source0: %{name}-%{version}.tar.gz URL: https://github.com/nemomobile/ssu +BuildRequires: pkgconfig(boardname) BuildRequires: pkgconfig(QtCore) BuildRequires: pkgconfig(QtDBus) BuildRequires: pkgconfig(QtDeclarative)