Skip to content

Commit

Permalink
[ssu] Add support for libboardname
Browse files Browse the repository at this point in the history
  • Loading branch information
Bernd Wachter committed Apr 29, 2013
1 parent 3a7e008 commit fa51c31
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 1 deletion.
4 changes: 4 additions & 0 deletions board-mappings.ini
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion libssu/libssu.pro
Expand Up @@ -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}

Expand Down
32 changes: 32 additions & 0 deletions libssu/ssudeviceinfo.cpp
Expand Up @@ -11,6 +11,10 @@

#include <sys/utsname.h>

extern "C" {
#include <boardname.h>
}

#include "ssudeviceinfo.h"
#include "ssucoreconfig.h"
#include "ssulog.h"
Expand Down Expand Up @@ -125,6 +129,7 @@ QString SsuDeviceInfo::deviceModel(){
QDir dir;
QFile procCpuinfo;
QStringList keys;
QStringList sections;

if (!cachedModel.isEmpty())
return cachedModel;
Expand All @@ -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,
Expand Down
1 change: 1 addition & 0 deletions rpm/ssu.spec
Expand Up @@ -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)
Expand Down

0 comments on commit fa51c31

Please sign in to comment.