Commit fa51c31f authored by Aard's avatar Aard

[ssu] Add support for libboardname

parent 3a7e008c
......@@ -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
......
......@@ -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}
......
......@@ -11,6 +11,10 @@
#include <sys/utsname.h>
extern "C" {
#include <boardname.h>
}
#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 &section, 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,
......
......@@ -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)
......
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