Commit 5ee46d82 authored by spiiroin's avatar spiiroin

[config] Rename Config class to SensorFrameworkConfig. Fixes JB#43217

Sensorfwd crashes on exit in h3113 devices (Xperia XA2). This happens
because of Config class related symbol name clash between sensorfwd
and android dynamic loader / libhybris: Destructor from sensorfwd
code base ends up used for cleaning up libhybris objects - which then
leads to segfault.

As runtime loader is what it is, rename "Config" class in sensorfwd
to less generic "SensorFrameworkConfig".
Signed-off-by: spiiroin's avatarSimo Piiroinen <simo.piiroinen@jollamobile.com>
parent 7af22d7d
......@@ -44,8 +44,8 @@ AccelerometerAdaptor::AccelerometerAdaptor(const QString& id) :
accelerometerBuffer_ = new DeviceAdaptorRingBuffer<OrientationData>(1);
setAdaptedSensor("accelerometer", "Internal accelerometer coordinates", accelerometerBuffer_);
setDescription("Input device accelerometer adaptor");
powerStatePath_ = Config::configuration()->value("accelerometer/powerstate_path").toByteArray();
accelMultiplier = Config::configuration()->value("accelerometer/multiplier", QVariant(1)).toReal();
powerStatePath_ = SensorFrameworkConfig::configuration()->value("accelerometer/powerstate_path").toByteArray();
accelMultiplier = SensorFrameworkConfig::configuration()->value("accelerometer/multiplier", QVariant(1)).toReal();
}
AccelerometerAdaptor::~AccelerometerAdaptor()
......
......@@ -52,7 +52,7 @@ ALSAdaptorAscii::ALSAdaptorAscii(const QString& id) : SysfsAdaptor(id, SysfsAdap
setDescription("Ambient light");
// Get range from a file, if the path is found in configuration
QString rangeFilePath_ = Config::configuration()->value("als/range_file_path",QVariant("")).toString();
QString rangeFilePath_ = SensorFrameworkConfig::configuration()->value("als/range_file_path",QVariant("")).toString();
if (rangeFilePath_ != "") {
QFile sysFile(rangeFilePath_);
......@@ -66,8 +66,8 @@ ALSAdaptorAscii::ALSAdaptorAscii(const QString& id) : SysfsAdaptor(id, SysfsAdap
sensordLogT() << "Ambient light range: " << range;
}
}
powerStatePath = Config::configuration()->value("als/powerstate_path").toByteArray();
powerMode = Config::configuration()->value("als/mode").toByteArray();
powerStatePath = SensorFrameworkConfig::configuration()->value("als/powerstate_path").toByteArray();
powerMode = SensorFrameworkConfig::configuration()->value("als/mode").toByteArray();
}
ALSAdaptorAscii::~ALSAdaptorAscii()
......
......@@ -43,7 +43,7 @@ ALSAdaptorEvdev::ALSAdaptorEvdev(const QString& id) :
alsBuffer_ = new DeviceAdaptorRingBuffer<TimedUnsigned>(1);
setAdaptedSensor("als", "Internal ambient light sensor lux values", alsBuffer_);
setDescription("Input device als adaptor");
powerStatePath_ = Config::configuration()->value("als/powerstate_path").toByteArray();
powerStatePath_ = SensorFrameworkConfig::configuration()->value("als/powerstate_path").toByteArray();
introduceAvailableDataRange(DataRange(0, 4095, 1));
setDefaultInterval(10);
}
......
......@@ -62,8 +62,8 @@ ALSAdaptor::ALSAdaptor(const QString& id):
alsBuffer_ = new DeviceAdaptorRingBuffer<TimedUnsigned>(1);
setAdaptedSensor("als", "Internal ambient light sensor lux values", alsBuffer_);
setDescription("Ambient light");
deviceType_ = (DeviceType)Config::configuration()->value<int>("als/driver_type", DeviceUnknown);
powerStatePath_ = Config::configuration()->value("als/powerstate_path").toByteArray();
deviceType_ = (DeviceType)SensorFrameworkConfig::configuration()->value<int>("als/driver_type", DeviceUnknown);
powerStatePath_ = SensorFrameworkConfig::configuration()->value("als/powerstate_path").toByteArray();
#ifdef SENSORFW_MCE_WATCHER
dbusIfc = new QDBusInterface(MCE_SERVICE, MCE_REQUEST_PATH, MCE_REQUEST_IF,
......
......@@ -43,7 +43,7 @@ GyroAdaptorEvdev::GyroAdaptorEvdev(const QString& id) :
gyroscopeBuffer_ = new DeviceAdaptorRingBuffer<TimedXyzData>(1);
setAdaptedSensor("gyroscope", "Internal gyroscope values", gyroscopeBuffer_);
setDescription("Input device gyroscope adaptor");
powerStatePath_ = Config::configuration()->value("gyroscope/powerstate_path").toByteArray();
powerStatePath_ = SensorFrameworkConfig::configuration()->value("gyroscope/powerstate_path").toByteArray();
// introduceAvailableDataRange(DataRange(0, 4095, 1));
setDefaultInterval(10);
}
......
......@@ -41,7 +41,7 @@ GyroscopeAdaptor::GyroscopeAdaptor(const QString& id) :
gyroscopeBuffer_ = new DeviceAdaptorRingBuffer<TimedXyzData>(1);
setAdaptedSensor("gyroscope", "l3g4200dh", gyroscopeBuffer_);
setDescription("Sysfs Gyroscope adaptor (l3g4200dh)");
dataRatePath_ = Config::configuration()->value("gyroscope/path_datarate").toByteArray();
dataRatePath_ = SensorFrameworkConfig::configuration()->value("gyroscope/path_datarate").toByteArray();
}
GyroscopeAdaptor::~GyroscopeAdaptor()
......
......@@ -40,7 +40,7 @@ HumidityAdaptor::HumidityAdaptor(const QString& id) :
humidityBuffer_ = new DeviceAdaptorRingBuffer<TimedUnsigned>(1);
setAdaptedSensor("humidity", "Relative Humidity values", humidityBuffer_);
setDescription("Input device humidity adaptor");
powerStatePath_ = Config::configuration()->value("humidity/powerstate_path").toByteArray();
powerStatePath_ = SensorFrameworkConfig::configuration()->value("humidity/powerstate_path").toByteArray();
introduceAvailableDataRange(DataRange(0, 4095, 1));
setDefaultInterval(10);
}
......
......@@ -33,7 +33,7 @@ HybrisAccelerometerAdaptor::HybrisAccelerometerAdaptor(const QString& id) :
setAdaptedSensor("accelerometer", "Internal accelerometer coordinates", buffer);
setDescription("Hybris accelerometer");
powerStatePath = Config::configuration()->value("accelerometer/powerstate_path").toByteArray();
powerStatePath = SensorFrameworkConfig::configuration()->value("accelerometer/powerstate_path").toByteArray();
// setDefaultInterval(50);
}
......
......@@ -37,7 +37,7 @@ HybrisAlsAdaptor::HybrisAlsAdaptor(const QString& id) :
buffer = new DeviceAdaptorRingBuffer<TimedUnsigned>(1);
setAdaptedSensor("als", "Internal ambient light sensor lux values", buffer);
setDescription("Hybris als");
powerStatePath = Config::configuration()->value("als/powerstate_path").toByteArray();
powerStatePath = SensorFrameworkConfig::configuration()->value("als/powerstate_path").toByteArray();
if (!powerStatePath.isEmpty() && !QFile::exists(powerStatePath))
{
sensordLogW() << "Path does not exists: " << powerStatePath;
......
......@@ -35,7 +35,7 @@ HybrisGyroscopeAdaptor::HybrisGyroscopeAdaptor(const QString& id) :
setAdaptedSensor("gyroscopeadaptor", "Internal gyroscope coordinates", buffer);
setDescription("Hybris gyroscope");
powerStatePath = Config::configuration()->value("gyroscope/powerstate_path").toByteArray();
powerStatePath = SensorFrameworkConfig::configuration()->value("gyroscope/powerstate_path").toByteArray();
if (!powerStatePath.isEmpty() && !QFile::exists(powerStatePath))
{
sensordLogW() << "Path does not exists: " << powerStatePath;
......
......@@ -31,7 +31,7 @@ HybrisMagnetometerAdaptor::HybrisMagnetometerAdaptor(const QString& id) :
setAdaptedSensor("magnetometer", "Internal magnetometer coordinates", buffer);
setDescription("Hybris magnetometer");
powerStatePath = Config::configuration()->value("magnetometer/powerstate_path").toByteArray();
powerStatePath = SensorFrameworkConfig::configuration()->value("magnetometer/powerstate_path").toByteArray();
if (!powerStatePath.isEmpty() && !QFile::exists(powerStatePath))
{
sensordLogW() << "Path does not exists: " << powerStatePath;
......
......@@ -48,7 +48,7 @@ HybrisOrientationAdaptor::HybrisOrientationAdaptor(const QString& id) :
setAdaptedSensor("hybrisorientation", "Internal orientation coordinates", buffer);
setDescription("Hybris orientation");
powerStatePath = Config::configuration()->value("orientation/powerstate_path").toByteArray();
powerStatePath = SensorFrameworkConfig::configuration()->value("orientation/powerstate_path").toByteArray();
if (!powerStatePath.isEmpty() && !QFile::exists(powerStatePath))
{
sensordLogW() << "Path does not exists: " << powerStatePath;
......
......@@ -35,7 +35,7 @@ HybrisPressureAdaptor::HybrisPressureAdaptor(const QString& id) :
buffer = new DeviceAdaptorRingBuffer<TimedUnsigned>(1);
setAdaptedSensor("pressure", "Internal ambient pressure sensor values", buffer);
setDescription("Hybris pressure");
powerStatePath = Config::configuration()->value("pressure/powerstate_path").toByteArray();
powerStatePath = SensorFrameworkConfig::configuration()->value("pressure/powerstate_path").toByteArray();
if (!powerStatePath.isEmpty() && !QFile::exists(powerStatePath))
{
sensordLogW() << "Path does not exists: " << powerStatePath;
......
......@@ -39,7 +39,7 @@ HybrisProximityAdaptor::HybrisProximityAdaptor(const QString& id) :
setAdaptedSensor("proximity", "Internal proximity coordinates", buffer);
setDescription("Hybris proximity");
powerStatePath = Config::configuration()->value("proximity/powerstate_path").toByteArray();
powerStatePath = SensorFrameworkConfig::configuration()->value("proximity/powerstate_path").toByteArray();
if (!powerStatePath.isEmpty() && !QFile::exists(powerStatePath))
{
sensordLogW() << "Path does not exists: " << powerStatePath;
......
......@@ -41,7 +41,7 @@ HybrisStepCounterAdaptor::HybrisStepCounterAdaptor(const QString& id) :
buffer = new DeviceAdaptorRingBuffer<TimedUnsigned>(1);
setAdaptedSensor("stepcounter", "Internal step counter steps since reboot", buffer);
setDescription("Hybris step counter");
powerStatePath = Config::configuration()->value("stepcounter/powerstate_path").toByteArray();
powerStatePath = SensorFrameworkConfig::configuration()->value("stepcounter/powerstate_path").toByteArray();
if (!powerStatePath.isEmpty() && !QFile::exists(powerStatePath))
{
sensordLogW() << "Path does not exists: " << powerStatePath;
......
......@@ -81,7 +81,7 @@ void IioAdaptor::setup()
if (deviceId.startsWith("accel")) {
const QString name = "accelerometer";
const QString inputMatch = Config::configuration()->value<QString>(name + "/input_match");
const QString inputMatch = SensorFrameworkConfig::configuration()->value<QString>(name + "/input_match");
qDebug() << "input_match" << inputMatch;
devNodeNumber = findSensor(inputMatch);
......@@ -96,7 +96,7 @@ void IioAdaptor::setup()
}
else if (deviceId.startsWith("gyro")) {
const QString name = "gyroscope";
const QString inputMatch = Config::configuration()->value<QString>(name + "/input_match");
const QString inputMatch = SensorFrameworkConfig::configuration()->value<QString>(name + "/input_match");
qDebug() << "input_match" << inputMatch;
devNodeNumber = findSensor(inputMatch);
......@@ -110,7 +110,7 @@ void IioAdaptor::setup()
}
else if (deviceId.startsWith("mag")) {
const QString name = "magnetometer";
const QString inputMatch = Config::configuration()->value<QString>(name + "/input_match");
const QString inputMatch = SensorFrameworkConfig::configuration()->value<QString>(name + "/input_match");
qDebug() << "input_match" << inputMatch;
devNodeNumber = findSensor(inputMatch);
......@@ -125,7 +125,7 @@ void IioAdaptor::setup()
}
else if (deviceId.startsWith("als")) {
const QString name = "als";
const QString inputMatch = Config::configuration()->value<QString>(name + "/input_match");
const QString inputMatch = SensorFrameworkConfig::configuration()->value<QString>(name + "/input_match");
devNodeNumber = findSensor(inputMatch);
if (devNodeNumber!= -1) {
......
......@@ -47,7 +47,7 @@ LidSensorAdaptorEvdev::LidSensorAdaptorEvdev(const QString& id) :
{
lidBuffer_ = new DeviceAdaptorRingBuffer<LidData>(1);
setAdaptedSensor("lidsensor", "Lid state", lidBuffer_);
powerStatePath_ = Config::configuration()->value("lidsensor/powerstate_path").toByteArray();
powerStatePath_ = SensorFrameworkConfig::configuration()->value("lidsensor/powerstate_path").toByteArray();
}
......@@ -76,7 +76,7 @@ LidSensorAdaptorEvdev::~LidSensorAdaptorEvdev()
void LidSensorAdaptorEvdev::init()
{
qDebug() << Q_FUNC_INFO << name();
QStringList strList = Config::configuration()->value<QStringList>(name() + "/input_match");
QStringList strList = SensorFrameworkConfig::configuration()->value<QStringList>(name() + "/input_match");
qDebug() << strList;
foreach (const QString str, strList) {
if (!getInputDevices(str)) {
......
......@@ -42,7 +42,7 @@ MagAdaptorEvdev::MagAdaptorEvdev(const QString& id) :
magnetometerBuffer_ = new DeviceAdaptorRingBuffer<CalibratedMagneticFieldData>(1);
setAdaptedSensor("magnetometer", "Internal magnetometer coordinates", magnetometerBuffer_);
setDescription("Input device magnetometer adaptor");
powerStatePath_ = Config::configuration()->value("magnetometer/powerstate_path").toByteArray();
powerStatePath_ = SensorFrameworkConfig::configuration()->value("magnetometer/powerstate_path").toByteArray();
// introduceAvailableDataRange(DataRange(0, 4095, 1));
setDefaultInterval(10);
}
......
......@@ -34,9 +34,9 @@ MagnetometerAdaptorNCDK::MagnetometerAdaptorNCDK(const QString& id) :
SysfsAdaptor(id, SysfsAdaptor::IntervalMode),
powerState_(false)
{
intervalCompensation_ = Config::configuration()->value<int>("magnetometer/interval_compensation", 0);
powerStateFilePath_ = Config::configuration()->value<QByteArray>("magnetometer/path_power_state", "");
sensAdjFilePath_ = Config::configuration()->value<QByteArray>("magnetometer/path_sens_adjust", "");
intervalCompensation_ = SensorFrameworkConfig::configuration()->value<int>("magnetometer/interval_compensation", 0);
powerStateFilePath_ = SensorFrameworkConfig::configuration()->value<QByteArray>("magnetometer/path_power_state", "");
sensAdjFilePath_ = SensorFrameworkConfig::configuration()->value<QByteArray>("magnetometer/path_sens_adjust", "");
magnetometerBuffer_ = new DeviceAdaptorRingBuffer<CalibratedMagneticFieldData>(128);
setAdaptedSensor("magnetometer", "Internal magnetometer coordinates", magnetometerBuffer_);
setDescription("Magnetometer adaptor (ak8975) for NCDK");
......@@ -44,7 +44,7 @@ MagnetometerAdaptorNCDK::MagnetometerAdaptorNCDK(const QString& id) :
//get sensitivity adjustment
getSensitivityAdjustment(x_adj, y_adj, z_adj);
overflowLimit_ = Config::configuration()->value<int>("magnetometer/overflow_limit", 8000);
overflowLimit_ = SensorFrameworkConfig::configuration()->value<int>("magnetometer/overflow_limit", 8000);
}
MagnetometerAdaptorNCDK::~MagnetometerAdaptorNCDK()
......
......@@ -46,10 +46,10 @@ struct ak8974_data {
MagnetometerAdaptor::MagnetometerAdaptor(const QString& id) :
SysfsAdaptor(id, SysfsAdaptor::IntervalMode, false)
{
intervalCompensation_ = Config::configuration()->value<int>("magnetometer/interval_compensation", 0);
intervalCompensation_ = SensorFrameworkConfig::configuration()->value<int>("magnetometer/interval_compensation", 0);
magnetometerBuffer_ = new DeviceAdaptorRingBuffer<CalibratedMagneticFieldData>(1);
setAdaptedSensor("magnetometer", "Internal magnetometer coordinates", magnetometerBuffer_);
overflowLimit_ = Config::configuration()->value<int>("magnetometer/overflow_limit", 8000);
overflowLimit_ = SensorFrameworkConfig::configuration()->value<int>("magnetometer/overflow_limit", 8000);
setDescription("Input device Magnetometer adaptor (ak897x)");
}
......
......@@ -40,21 +40,21 @@ Mpu6050AccelAdaptor::Mpu6050AccelAdaptor (const QString& id) :
{
struct stat st;
QString xAxisPath = Config::configuration()->value("accelerometer/x_axis_path").toString ();
QString xAxisPath = SensorFrameworkConfig::configuration()->value("accelerometer/x_axis_path").toString ();
if ( lstat (xAxisPath.toLatin1().constData(), &st) < 0 ) {
sensordLogW () << "x_axis_path: " << xAxisPath << " not found";
return;
}
addPath(xAxisPath, X_AXIS);
QString yAxisPath = Config::configuration()->value("accelerometer/y_axis_path").toString ();
QString yAxisPath = SensorFrameworkConfig::configuration()->value("accelerometer/y_axis_path").toString ();
if ( lstat (yAxisPath.toLatin1().constData(), &st) < 0 ) {
sensordLogW () << "y_axis_path: " << yAxisPath << " not found";
return;
}
addPath(yAxisPath, Y_AXIS);
QString zAxisPath = Config::configuration()->value("accelerometer/z_axis_path").toString ();
QString zAxisPath = SensorFrameworkConfig::configuration()->value("accelerometer/z_axis_path").toString ();
if ( lstat (zAxisPath.toLatin1().constData(), &st) < 0 ) {
sensordLogW () << "z_axis_path: " << zAxisPath << " not found";
return;
......
......@@ -13,7 +13,7 @@ OaktrailAccelAdaptor::OaktrailAccelAdaptor (const QString& id) :
{
struct stat st;
devPath = Config::configuration ()->value ("oaktrail_acc_sys_path").toString ();
devPath = SensorFrameworkConfig::configuration ()->value ("oaktrail_acc_sys_path").toString ();
if ( lstat (devPath.toLatin1().constData(), &st) < 0 ) {
sensordLogW () << devPath << "no found";
return;
......
......@@ -13,7 +13,7 @@ OemtabletAccelAdaptor::OemtabletAccelAdaptor (const QString& id) :
{
struct stat st;
devPath = Config::configuration ()->value ("oem_tablet_acc_sys_path").toString ();
devPath = SensorFrameworkConfig::configuration ()->value ("oem_tablet_acc_sys_path").toString ();
if ( lstat (devPath.toLatin1().constData(), &st) < 0 ) {
sensordLogW () << devPath << "no found";
return;
......
......@@ -16,7 +16,7 @@ OEMTabletALSAdaptorAscii::OEMTabletALSAdaptorAscii(const QString& id) : SysfsAda
const unsigned int DEFAULT_RANGE = 65535;
int range = DEFAULT_RANGE;
QFile sysFile(Config::configuration()->value("als-ascii_range_sysfs_path").toString());
QFile sysFile(SensorFrameworkConfig::configuration()->value("als-ascii_range_sysfs_path").toString());
if (!(sysFile.open(QIODevice::ReadOnly))) {
sensordLogW() << "Unable to config ALS range from sysfs, using default value: " << DEFAULT_RANGE;
......@@ -28,7 +28,7 @@ OEMTabletALSAdaptorAscii::OEMTabletALSAdaptorAscii(const QString& id) : SysfsAda
sensordLogT() << "Ambient light range: " << range;
// Locate the actual handle
QString devPath = Config::configuration()->value("als-ascii_sysfs_path").toString();
QString devPath = SensorFrameworkConfig::configuration()->value("als-ascii_sysfs_path").toString();
if (devPath.isEmpty())
{
......
......@@ -40,7 +40,7 @@ PressureAdaptor::PressureAdaptor(const QString& id) :
pressureBuffer_ = new DeviceAdaptorRingBuffer<TimedUnsigned>(1);
setAdaptedSensor("pressure", "Pressure values", pressureBuffer_);
setDescription("Input device pressure adaptor");
powerStatePath_ = Config::configuration()->value("pressure/powerstate_path").toByteArray();
powerStatePath_ = SensorFrameworkConfig::configuration()->value("pressure/powerstate_path").toByteArray();
introduceAvailableDataRange(DataRange(0, 4095, 1));
setDefaultInterval(10);
}
......
......@@ -46,7 +46,7 @@ ProximityAdaptorEvdev::ProximityAdaptorEvdev(const QString& id) :
{
proximityBuffer_ = new DeviceAdaptorRingBuffer<ProximityData>(1);
setAdaptedSensor("proximity", "Proximity state", proximityBuffer_);
powerStatePath_ = Config::configuration()->value("proximity/powerstate_path").toByteArray();
powerStatePath_ = SensorFrameworkConfig::configuration()->value("proximity/powerstate_path").toByteArray();
}
ProximityAdaptorEvdev::~ProximityAdaptorEvdev()
......
......@@ -53,9 +53,9 @@ struct apds990x_data {
ProximityAdaptor::ProximityAdaptor(const QString& id) :
SysfsAdaptor(id, SysfsAdaptor::SelectMode, false)
{
deviceType_ = (DeviceType)Config::configuration()->value<int>("proximity/driver_type", 0);
threshold_ = Config::configuration()->value<int>("proximity/threshold", 35);
powerStatePath_ = Config::configuration()->value("proximity/powerstate_path").toByteArray();
deviceType_ = (DeviceType)SensorFrameworkConfig::configuration()->value<int>("proximity/driver_type", 0);
threshold_ = SensorFrameworkConfig::configuration()->value<int>("proximity/threshold", 35);
powerStatePath_ = SensorFrameworkConfig::configuration()->value("proximity/powerstate_path").toByteArray();
proximityBuffer_ = new DeviceAdaptorRingBuffer<ProximityData>(1);
setAdaptedSensor("proximity", "Proximity state", proximityBuffer_);
setDescription("Proximity sensor readings (Dipro sensor)");
......
......@@ -26,8 +26,8 @@ range
1: +/- 4g (2 mg/LSB)
2: +/- 8g (4 mg/LSB)
*/
QByteArray rangePath = Config::configuration()->value("accelerometer/range_path").toByteArray();
range = Config::configuration()->value("accelerometer/range_mode").toByteArray();
QByteArray rangePath = SensorFrameworkConfig::configuration()->value("accelerometer/range_path").toByteArray();
range = SensorFrameworkConfig::configuration()->value("accelerometer/range_mode").toByteArray();
if(!rangePath.isEmpty()) {
writeToFile(rangePath, range);
}
......@@ -44,8 +44,8 @@ power_state/frequency
7: 400 Hz
*/
powerStatePath = Config::configuration()->value("accelerometer/mode_path").toByteArray();
frequency = Config::configuration()->value("accelerometer/frequency_mode").toInt();
powerStatePath = SensorFrameworkConfig::configuration()->value("accelerometer/mode_path").toByteArray();
frequency = SensorFrameworkConfig::configuration()->value("accelerometer/frequency_mode").toInt();
setDescription("ste accelerometer");
}
......
......@@ -40,7 +40,7 @@ TemperatureAdaptor::TemperatureAdaptor(const QString& id) :
temperatureBuffer_ = new DeviceAdaptorRingBuffer<TimedUnsigned>(1);
setAdaptedSensor("temperature", "Temperature values", temperatureBuffer_);
setDescription("Input device temperature adaptor");
powerStatePath_ = Config::configuration()->value("temperature/powerstate_path").toByteArray();
powerStatePath_ = SensorFrameworkConfig::configuration()->value("temperature/powerstate_path").toByteArray();
introduceAvailableDataRange(DataRange(0, 4095, 1));
setDefaultInterval(10);
}
......
......@@ -52,7 +52,7 @@ AccelerometerChain::AccelerometerChain(const QString& id) :
accelerometerReader_ = new BufferReader<AccelerationData>(1);
// Get the transformation matrix from config file
QString aconvString = Config::configuration()->value<QString>("accelerometer/transformation_matrix", "");
QString aconvString = SensorFrameworkConfig::configuration()->value<QString>("accelerometer/transformation_matrix", "");
if (aconvString.size() > 0)
{
if (!setMatrixFromString(aconvString))
......
......@@ -37,7 +37,7 @@ void CompassChainPlugin::Register(class Loader&)
}
QStringList CompassChainPlugin::Dependencies() {
QByteArray orientationConfiguration = Config::configuration()->value("plugins/orientationadaptor").toByteArray();
QByteArray orientationConfiguration = SensorFrameworkConfig::configuration()->value("plugins/orientationadaptor").toByteArray();
if (orientationConfiguration.isEmpty()) {
return QString("accelerometerchain:magcalibrationchain:declinationfilter:downsamplefilter:avgaccfilter").split(":", QString::SkipEmptyParts);
} else {
......
......@@ -47,7 +47,7 @@ CalibrationFilter::CalibrationFilter() :
minMaxList.insert(1,qMakePair(0,0));
minMaxList.insert(2,qMakePair(0,0));
manualCalibration = Config::configuration()->value<bool>("magnetometer/needs_calibration", false);
manualCalibration = SensorFrameworkConfig::configuration()->value<bool>("magnetometer/needs_calibration", false);
qDebug() << Q_FUNC_INFO << manualCalibration;
#ifdef CALIBRATE_DATA
......
......@@ -54,16 +54,16 @@ MagCalibrationChain::MagCalibrationChain(const QString& id) :
if (magAdaptor)
setValid(magAdaptor->isValid());
// Config::configuration()->value<int>("magnetometer/interval_compensation", 16);
// SensorFrameworkConfig::configuration()->value<int>("magnetometer/interval_compensation", 16);
// Get the transformation matrix from config file
QString aconvString = Config::configuration()->value<QString>("magnetometer/transformation_matrix", "");
QString aconvString = SensorFrameworkConfig::configuration()->value<QString>("magnetometer/transformation_matrix", "");
if (aconvString.size() > 0) {
if (!setMatrixFromString(aconvString)) {
sensordLogW() << "Failed to parse 'transformation_matrix' configuration key. Coordinate alignment may be invalid";
}
}
needsCalibration = Config::configuration()->value<bool>("magnetometer/needs_calibration", true);
needsCalibration = SensorFrameworkConfig::configuration()->value<bool>("magnetometer/needs_calibration", true);
calibratedMagnetometerData = new RingBuffer<CalibratedMagneticFieldData>(1);
nameOutputBuffer("calibratedmagnetometerdata", calibratedMagnetometerData);
......
......@@ -33,23 +33,23 @@
#include <QDir>
#include <QList>
static Config *static_configuration = 0;
static SensorFrameworkConfig *static_configuration = 0;
Config::Config() {
SensorFrameworkConfig::SensorFrameworkConfig() {
}
Config::~Config() {
SensorFrameworkConfig::~SensorFrameworkConfig() {
}
void Config::clearConfig() {
void SensorFrameworkConfig::clearConfig() {
m_settings.clear();
}
bool Config::loadConfig(const QString &defConfigPath, const QString &configDPath) {
bool SensorFrameworkConfig::loadConfig(const QString &defConfigPath, const QString &configDPath) {
/* Not having config files is ok, failing to load one that exists is not */
bool ret = true;
if (!static_configuration) {
static_configuration = new Config();
static_configuration = new SensorFrameworkConfig();
}
/* Process config.d dir in alnum order */
if (!configDPath.isEmpty()) {
......@@ -68,7 +68,7 @@ bool Config::loadConfig(const QString &defConfigPath, const QString &configDPath
return ret;
}
bool Config::loadConfigFile(const QString &configFileName) {
bool SensorFrameworkConfig::loadConfigFile(const QString &configFileName) {
/* Success means the file was loaded and processed without hiccups */
bool loaded = false;
if (!QFile::exists(configFileName)) {
......@@ -90,7 +90,7 @@ bool Config::loadConfigFile(const QString &configFileName) {
return loaded;
}
QVariant Config::value(const QString &key) const {
QVariant SensorFrameworkConfig::value(const QString &key) const {
QVariant var = m_settings.value(key, QVariant());
if(var.isValid()) {
sensordLogT() << "Value for key" << key << ":" << var.toString();
......@@ -98,25 +98,25 @@ QVariant Config::value(const QString &key) const {
return var;
}
QStringList Config::groups() const
QStringList SensorFrameworkConfig::groups() const
{
QStringList groups = m_settings.childGroups();
return groups;
}
Config *Config::configuration() {
SensorFrameworkConfig *SensorFrameworkConfig::configuration() {
if (!static_configuration) {
sensordLogW() << "Configuration has not been loaded";
}
return static_configuration;
}
void Config::close() {
void SensorFrameworkConfig::close() {
delete static_configuration;
static_configuration = 0;
}
bool Config::exists(const QString &key) const
bool SensorFrameworkConfig::exists(const QString &key) const
{
return value(key).isValid();
}
......@@ -35,16 +35,16 @@
/**
* Sensord configuration parser. Configuration is read and parsed with
* the QSettings class. Config is a singleton instance to which configuration
* the QSettings class. SensorFrameworkConfig is a singleton instance to which configuration
* is loaded once during startup.
*/
class Config
class SensorFrameworkConfig
{
public:
/**
* Destructor.
*/
~Config();
~SensorFrameworkConfig();
/**
* Find value for given key. Default QVariant is returned if key does
......@@ -86,7 +86,7 @@ public:
*
* @return configuration instance.
*/
static Config *configuration();
static SensorFrameworkConfig *configuration();
/**
* Load configuration from given paths and append them to singleton
......@@ -106,14 +106,14 @@ private:
/**
* Constructor.
*/
Config();
SensorFrameworkConfig();
/**
* Copy constructor.
*
* @param c source object.
*/
Config(const Config &c);
SensorFrameworkConfig(const SensorFrameworkConfig &c);
/**
* Assignment operator.
......@@ -121,7 +121,7 @@ private:
* @param c source object.
* @return current object.
*/
Config& operator=(const Config &c);
SensorFrameworkConfig& operator=(const SensorFrameworkConfig &c);
/**
* Load configuration file from given path.
......@@ -140,7 +140,7 @@ private:
};
template<typename T>
T Config::value(const QString &key, const T &def) const
T SensorFrameworkConfig::value(const QString &key, const T &def) const
{
QVariant val(value(key));
if(!val.isValid())
......
......@@ -59,14 +59,14 @@ InputDevAdaptor::~InputDevAdaptor()
int InputDevAdaptor::getInputDevices(const QString& typeName)
{
qDebug() << Q_FUNC_INFO << typeName;
QString deviceSysPathString = Config::configuration()->value("global/device_sys_path").toString();
QString devicePollFilePath = Config::configuration()->value("global/device_poll_file_path").toString();
QString deviceSysPathString = SensorFrameworkConfig::configuration()->value("global/device_sys_path").toString();
QString devicePollFilePath = SensorFrameworkConfig::configuration()->value("global/device_poll_file_path").toString();
int deviceNumber = 0;
deviceString_ = typeName;
// Check if this device name is defined in configuration
QString deviceName = Config::configuration()->value<QString>(typeName + "/device", "");
QString deviceName = SensorFrameworkConfig::configuration()->value<QString>(typeName + "/device", "");
// Do not perform strict checks for the input device
if (deviceName.size() && checkInputDevice(deviceName, typeName, false)) {
......@@ -90,8 +90,8 @@ qDebug() << deviceNumber << deviceCount_ << maxDeviceCount_;
}
QString pollConfigKey = QString(typeName + "/poll_file");
if (Config::configuration()->exists(pollConfigKey)) {
usedDevicePollFilePath_ = Config::configuration()->value<QString>(pollConfigKey, "");
if (SensorFrameworkConfig::configuration()->exists(pollConfigKey)) {
usedDevicePollFilePath_ = SensorFrameworkConfig::configuration()->value<QString>(pollConfigKey, "");
} else {
usedDevicePollFilePath_ = devicePollFilePath.arg(deviceNumber);
}
......@@ -191,7 +191,7 @@ bool InputDevAdaptor::setInterval(const unsigned int value, const int sessionId)
void InputDevAdaptor::init()
{
qDebug() << Q_FUNC_INFO << name();
if (!getInputDevices(Config::configuration()->value<QString>(name() + "/input_match", name()))) {
if (!getInputDevices(SensorFrameworkConfig::configuration()->value<QString>(name() + "/input_match", name()))) {
sensordLogW() << "Input device not found.";
SysfsAdaptor::init();
}
......
......@@ -192,7 +192,7 @@ void Loader::scanAvailablePlugins()
int end = file.size() - suffix.size();
const QString name(file.mid(beg, end-beg));
QString key = QString("available/%1").arg(name);
QString val = Config::configuration()->value(key).toString();
QString val = SensorFrameworkConfig::configuration()->value(key).toString();
if( evaluateAvailabilityValue(name, val) ) {
res.append(name);
}
......@@ -235,7 +235,7 @@ void Loader::invalidatePlugin(const QString &name)
QString Loader::resolveRealPluginName(const QString& pluginName) const
{
QString key = QString("plugins/%1").arg(pluginName);
QString nameFromConfig = Config::configuration()->value(key).toString();
QString nameFromConfig = SensorFrameworkConfig::configuration()->value(key).toString();
if (nameFromConfig.isEmpty()) {
sensordLogT() << "Plugin setting for " << pluginName << " not found from configuration. Using key as value.";
return pluginName;
......
......@@ -87,7 +87,7 @@ void NodeBase::introduceAvailableDataRange(const DataRange& range)
void NodeBase::introduceAvailableDataRanges(const QString& typeName)
{
QVariant ranges = Config::configuration()->value(typeName + "/dataranges");
QVariant ranges = SensorFrameworkConfig::configuration()->value(typeName + "/dataranges");
if(ranges.isValid())
{
DataRangeList list(parseDataRangeList(ranges.toString(), 1));
......@@ -280,7 +280,7 @@ void NodeBase::introduceAvailableInterval(const DataRange& interval)
void NodeBase::introduceAvailableIntervals(const QString& typeName)
{
QVariant ranges = Config::configuration()->value(typeName + "/intervals");
QVariant ranges = SensorFrameworkConfig::configuration()->value(typeName + "/intervals");
if(ranges.isValid())
{
DataRangeList list(parseDataRangeList(ranges.toString(), 0));
......
......@@ -478,7 +478,7 @@ void SysfsAdaptorReader::run()
void SysfsAdaptor::init()
{
QString path = Config::configuration()->value(name() + "/path").toString();
QString path = SensorFrameworkConfig::configuration()->value(name() + "/path").toString();
if(!path.isEmpty())
{
addPath(path);
......@@ -487,10 +487,10 @@ void SysfsAdaptor::init()
{
sensordLogW() << "No sysfs path defined for: " << name();
}
mode_ = (PollMode)Config::configuration()->value<int>(name() + "/mode", mode_);
doSeek_ = Config::configuration()->value<bool>(name() + "/seek", doSeek_);
mode_ = (PollMode)SensorFrameworkConfig::configuration()->value<int>(name() + "/mode", mode_);
doSeek_ = SensorFrameworkConfig::configuration()->value<bool>(name() + "/seek", doSeek_);