Skip to content

Commit

Permalink
[dconf] Drop usage of gconf and use mlite MGConfItem
Browse files Browse the repository at this point in the history
  • Loading branch information
Mohammed Hassan committed Mar 10, 2014
1 parent becc173 commit 931d07e
Show file tree
Hide file tree
Showing 17 changed files with 54 additions and 54 deletions.
25 changes: 3 additions & 22 deletions filters/declinationfilter/declinationfilter.cpp
Expand Up @@ -24,7 +24,7 @@
</p>
*/

#include <gconf/gconf-client.h>
#include <MGConfItem>
#include "declinationfilter.h"
#include "config.h"
#include "logging.h"
Expand All @@ -35,7 +35,6 @@ DeclinationFilter::DeclinationFilter() :
Filter<CompassData, DeclinationFilter, CompassData>(this, &DeclinationFilter::correct),
declinationCorrection_(0)
{
g_type_init();
updateInterval_ = Config::configuration()->value<quint64>("compass/declination_update_interval", 1000 * 60 * 60) * 1000;
}

Expand Down Expand Up @@ -68,31 +67,13 @@ void DeclinationFilter::correct(unsigned, const CompassData* data)

void DeclinationFilter::loadSettings()
{
GConfClient *client = gconf_client_get_default();
if (! client ) {
sensordLogW() << "Failed to initialise GConf client.";
return;
}
GError *error = NULL;
int value = gconf_client_get_int(client, declinationKey, &error);
if ( error != NULL) {
GError *error2 = NULL;
value = gconf_client_get_float(client, declinationKey, &error2);
if ( error2 != NULL) {
sensordLogW() << "Failed to read value for " << declinationKey << " from GConf: " << error2->message;
g_error_free(error2);
return;
}
g_error_free(error);
}

declinationCorrection_ = value;
MGConfItem item(declinationKey);
declinationCorrection_ = item.value().toInt();
#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0)
sensordLogD() << "Fetched declination correction from GConf: " << declinationCorrection_;
#else
sensordLogD() << "Fetched declination correction from GConf: " << declinationCorrection_.loadAcquire();
#endif
g_object_unref(client);
}

int DeclinationFilter::declinationCorrection()
Expand Down
2 changes: 1 addition & 1 deletion filters/declinationfilter/declinationfilter.pro
Expand Up @@ -2,7 +2,7 @@ TARGET = declinationfilter

CONFIG += link_pkgconfig

PKGCONFIG += gconf-2.0 gobject-2.0
PKGCONFIG += mlite5

HEADERS += declinationfilter.h \
declinationfilterplugin.h
Expand Down
3 changes: 1 addition & 2 deletions rpm/sensorfw-qt5-hybris.spec
Expand Up @@ -11,7 +11,6 @@ Source0: %{name}-%{version}.tar.bz2
Source1: sensord-daemon-conf-setup
Source2: sensorfw-rpmlintrc
Source3: sensord.service
Requires: GConf-dbus
Requires: %{name}-configs
Requires: sensord-qt5
Requires(post): /sbin/ldconfig
Expand All @@ -20,7 +19,7 @@ BuildRequires: pkgconfig(Qt5Core)
BuildRequires: pkgconfig(Qt5DBus)
BuildRequires: pkgconfig(Qt5Network)
BuildRequires: pkgconfig(Qt5Test)
BuildRequires: pkgconfig(gconf-2.0)
BuildRequires: pkgconfig(mlite5)
BuildRequires: pkgconfig(sensord-qt5)
BuildRequires: pkgconfig(libhardware)
BuildRequires: pkgconfig(android-headers)
Expand Down
3 changes: 1 addition & 2 deletions rpm/sensorfw-qt5.spec
Expand Up @@ -10,7 +10,6 @@ Source1: sensorfw-rpmlintrc
Source2: sensord.service
Source3: sensord-daemon-conf-setup
Requires: qt5-qtcore
Requires: GConf-dbus
Requires: sensord-configs
Requires: systemd
Requires(preun): systemd
Expand All @@ -22,7 +21,7 @@ BuildRequires: pkgconfig(Qt5Core)
BuildRequires: pkgconfig(Qt5DBus)
BuildRequires: pkgconfig(Qt5Network)
BuildRequires: pkgconfig(Qt5Test)
BuildRequires: pkgconfig(gconf-2.0)
BuildRequires: pkgconfig(mlite5)
Provides: sensord-qt5
Obsoletes: sensorframework

Expand Down
3 changes: 1 addition & 2 deletions rpm/sensorfw.spec
Expand Up @@ -8,12 +8,11 @@ URL: http://gitorious.org/sensorfw
Source0: %{name}-%{version}.tar.bz2
Source1: sensorfw-rpmlintrc
Requires: qt
Requires: GConf-dbus
Requires: sensorfw-qt5
Requires(post): /sbin/ldconfig
Requires(postun): /sbin/ldconfig
BuildRequires: pkgconfig(QtCore)
BuildRequires: pkgconfig(gconf-2.0)
BuildRequires: pkgconfig(mlite5)
BuildRequires: pkgconfig(QtDeclarative)
BuildRequires: pkgconfig(contextprovider-1.0)

Expand Down
3 changes: 3 additions & 0 deletions tests/client/client.pro
Expand Up @@ -11,6 +11,9 @@ TARGET = sensorapi-test
HEADERS += clientapitest.h
SOURCES += clientapitest.cpp

CONFIG += link_pkgconfig
PKGCONFIG += mlite5

SENSORFW_INCLUDEPATHS = ../.. \
../../include \
../../filters \
Expand Down
9 changes: 7 additions & 2 deletions tests/client/clientapitest.cpp
Expand Up @@ -36,6 +36,7 @@
#include "gyroscopesensor_i.h"

#include "clientapitest.h"
#include <MGConfItem>

ClientApiTest::ClientApiTest()
{
Expand Down Expand Up @@ -299,7 +300,10 @@ void ClientApiTest::testCompassSensor()
QVERIFY(declinationInUse != sensorIfc->useDeclination());
sensorIfc->setUseDeclination(!declinationInUse);

system("gconftool-2 --set /system/osso/location/settings/magneticvariation --type int 50");
MGConfItem item("/system/osso/location/settings/magneticvariation");
item.set(QVariant(50));
item.sync();

sensorIfc->setUseDeclination(true);
QVERIFY(sensorIfc->declinationValue() == 50);
sensorIfc2->setUseDeclination(false);
Expand All @@ -324,7 +328,8 @@ void ClientApiTest::testCompassSensor()
reply = sensorIfc2->stop();
QVERIFY(reply.isValid());

system("gconftool-2 --set /system/osso/location/settings/magneticvariation --type int 0");
item.set(QVariant((int)0));
item.sync();
}

void ClientApiTest::testTapSensor()
Expand Down
2 changes: 1 addition & 1 deletion tests/external/external.pro
Expand Up @@ -5,7 +5,7 @@ TARGET = sensorexternal-test

CONFIG += testcase link_pkgconfig

PKGCONFIG += gconf-2.0 gobject-2.0
PKGCONFIG += mlite5

HEADERS += externaltests.h
SOURCES += externaltests.cpp
18 changes: 5 additions & 13 deletions tests/external/externaltests.cpp
Expand Up @@ -23,26 +23,18 @@
*/

#include "externaltests.h"
#include <gconf/gconf-client.h>
#include <MGConfItem>
#include <QDebug>

void ExternalTest::testDeclinationCorrectionKey()
{
QString gconfkey("/system/osso/location/settings/magneticvariation");

g_type_init();
MGConfItem item(gconfkey);
QVariant value = item.value();
QVERIFY2(value.isValid(), "Failed to read declination key");

GConfClient *client = NULL;
client = gconf_client_get_default();
QVERIFY2(client, "Failed to initialise GConf client.");

GError *error = NULL;
GConfValue* value = gconf_client_get_without_default(client, gconfkey.toLocal8Bit(), &error);
QVERIFY2(value, QString("Failed to read declination key from GConf (%1)").arg(gconfkey).toLocal8Bit());

qDebug() << "Stored value for declination correction:" << gconf_value_get_int(value);

g_object_unref(client);
qDebug() << "Stored value for declination correction:" << value.toInt();
}

QTEST_MAIN(ExternalTest)
2 changes: 1 addition & 1 deletion tests/filters/filters.pro
Expand Up @@ -7,7 +7,7 @@ TARGET = sensorfilters-test

CONFIG += testcase link_pkgconfig

PKGCONFIG += gconf-2.0 gobject-2.0
PKGCONFIG += mlite5

HEADERS += filtertests.h \
../../filters/orientationinterpreter/orientationinterpreter.h \
Expand Down
8 changes: 6 additions & 2 deletions tests/filters/filtertests.cpp
Expand Up @@ -40,6 +40,7 @@
#include "rotationfilter.h"
#include "filtertests.h"
#include "config.h"
#include <MGConfItem>

void FilterApiTest::initTestCase()
{
Expand Down Expand Up @@ -334,7 +335,9 @@ void FilterApiTest::testDeclinationFilter()
FilterBase* declinationFilter = DeclinationFilter::factoryMethod();
QVERIFY(declinationFilter);

system("gconftool-2 --set /system/osso/location/settings/magneticvariation --type int 50");
MGConfItem item("/system/osso/location/settings/magneticvariation");
item.set(QVariant(50));
item.sync();

int key = dynamic_cast<DeclinationFilter*>(declinationFilter)->declinationCorrection();

Expand Down Expand Up @@ -393,7 +396,8 @@ void FilterApiTest::testDeclinationFilter()

delete declinationFilter;

system("gconftool-2 --set /system/osso/location/settings/magneticvariation --type int 0");
item.set(QVariant((int)0));
item.sync();
}

void FilterApiTest::testRotationFilter()
Expand Down
3 changes: 3 additions & 0 deletions tests/metadata/metadata.pro
Expand Up @@ -28,3 +28,6 @@ equals(QT_MAJOR_VERSION, 4):{
equals(QT_MAJOR_VERSION, 5):{
QMAKE_LIBDIR_FLAGS += -lsensordatatypes-qt5 -lsensorclient-qt5
}

CONFIG += link_pkgconfig
PKGCONFIG += mlite5
12 changes: 10 additions & 2 deletions tests/metadata/metadatatest.cpp
Expand Up @@ -34,6 +34,7 @@
#include "orientationsensor_i.h"

#include "metadatatest.h"
#include <MGConfItem>

void MetaDataTest::initTestCase()
{
Expand Down Expand Up @@ -249,9 +250,16 @@ void MetaDataTest::testCompassDeclination()
{
CompassSensorChannelInterface* compass = CompassSensorChannelInterface::interface("compasssensor");
compass->start();
system("gconftool-2 --set /system/osso/location/settings/magneticvariation --type int 50");

MGConfItem item("/system/osso/location/settings/magneticvariation");
item.set(QVariant(50));
item.sync();

QCOMPARE(compass->declinationValue(), 50);
system("gconftool-2 --set /system/osso/location/settings/magneticvariation --type int 0");

item.set(QVariant((int)0));
item.sync();

QCOMPARE(compass->declinationValue(), 0);
compass->stop();
delete compass;
Expand Down
Expand Up @@ -30,9 +30,10 @@
#include <QFile>
#include <QTimer>
#include <QProcess>
#include <MGConfItem>

#define DISABLE_TKLOCK QProcess::execute("gconftool-2 --set /system/osso/dsm/locks/touchscreen_keypad_autolock_enabled --type=bool false");
#define ENABLE_TKLOCK QProcess::execute("gconftool-2 --set /system/osso/dsm/locks/touchscreen_keypad_autolock_enabled --type=bool true");
#define DISABLE_TKLOCK { MGConfItem item("/system/osso/dsm/locks/touchscreen_keypad_autolock_enabled"); item.set(QVariant(false)); item.sync(); }
#define ENABLE_TKLOCK { MGConfItem item("/system/osso/dsm/locks/touchscreen_keypad_autolock_enabled"); item.set(QVariant(true)); item.sync(); }
#define OPEN_TKLOCK QProcess::execute("mcetool --set-tklock-mode=unlocked");
#define BLANK_SCREEN QProcess::execute("mcetool --blank-screen");
#define UNBLANK_SCREEN QProcess::execute("mcetool --unblank-screen");
Expand Down
Expand Up @@ -30,3 +30,6 @@ equals(QT_MAJOR_VERSION, 4):{
equals(QT_MAJOR_VERSION, 5):{
QMAKE_LIBDIR_FLAGS += -lsensordatatypes-qt5 -lsensorclient-qt5
}

CONFIG += link_pkgconfig
PKGCONFIG += mlite5
Expand Up @@ -32,9 +32,10 @@
#include <QTimer>
#include <QProcess>
#include <QDebug>
#include <MGConfItem>

#define DISABLE_TKLOCK QProcess::execute("gconftool-2 --set /system/osso/dsm/locks/touchscreen_keypad_autolock_enabled --type=bool false");
#define ENABLE_TKLOCK QProcess::execute("gconftool-2 --set /system/osso/dsm/locks/touchscreen_keypad_autolock_enabled --type=bool true");
#define DISABLE_TKLOCK { MGConfItem item("/system/osso/dsm/locks/touchscreen_keypad_autolock_enabled"); item.set(QVariant(false)); item.sync(); }
#define ENABLE_TKLOCK { MGConfItem item("/system/osso/dsm/locks/touchscreen_keypad_autolock_enabled"); item.set(QVariant(true)); item.sync(); }
#define OPEN_TKLOCK QProcess::execute("mcetool --set-tklock-mode=unlocked");
#define BLANK_SCREEN QProcess::execute("mcetool --blank-screen");
#define UNBLANK_SCREEN QProcess::execute("mcetool --unblank-screen");
Expand Down
Expand Up @@ -32,3 +32,5 @@ equals(QT_MAJOR_VERSION, 5):{
QMAKE_LIBDIR_FLAGS += -lsensordatatypes-qt5 -lsensorclient-qt5
}

CONFIG += link_pkgconfig
PKGCONFIG += mlite5

0 comments on commit 931d07e

Please sign in to comment.