Added touchscreen enabled settings read.
authorJussi Laitinen <jupe@l3l7588.ixonos.local>
Fri, 30 Jul 2010 08:47:41 +0000 (11:47 +0300)
committerJussi Laitinen <jupe@l3l7588.ixonos.local>
Fri, 30 Jul 2010 08:47:41 +0000 (11:47 +0300)
src/engine/mceprivate.cpp
src/engine/mceprivate.h
src/src.pro

index 5befc6c..4a0c9b2 100644 (file)
@@ -22,6 +22,8 @@
 #include <QString>
 #include <QDebug>
 #include <QTimer>
+#include <QFile>
+#include <QtXml/QDomDocument>
 
 #include <mce/dbus-names.h>
 #include <mce/mode-names.h>
@@ -51,7 +53,8 @@ MCEPrivate::MCEPrivate(QObject *parent)
                                       SLOT(setDisplayState(QString)),
                                       SLOT(displayStateError(QDBusError)));
 
-    m_dBusInterface->call(MCE_ENABLE_VIBRATOR);
+    if (isTouchscreenVibrationEnabled())
+        m_dBusInterface->call(MCE_ENABLE_VIBRATOR);
 }
 
 void MCEPrivate::displayStateChanged(const QDBusMessage &message)
@@ -92,6 +95,30 @@ void MCEPrivate::setDisplayState(const QString &state)
     }
 }
 
+bool MCEPrivate::isTouchscreenVibrationEnabled()
+{
+    QDomDocument doc("document");
+    QFile file("/var/lib/gconf/system/osso/dsm/vibra/\%gconf.xml");
+
+    if (!file.open(QIODevice::ReadOnly))
+        return false;
+    if (!doc.setContent(&file)) {
+        file.close();
+        return false;
+    }
+
+    file.close();
+
+    QDomNodeList domNodeList = doc.elementsByTagName("entry");
+
+    if (domNodeList.count() == 1) {
+        QDomElement element = domNodeList.at(0).toElement();
+        return QVariant(element.attribute("value", "false")).toBool();
+    } else {
+        return false;
+    }
+}
+
 void MCEPrivate::stopVibration()
 {
     qDebug() << __PRETTY_FUNCTION__;
index cb4faf0..11fb32d 100644 (file)
@@ -71,6 +71,15 @@ public:
     */
     void vibrationFeedback();
 
+private:
+    /**
+    * @brief Is the touchscreen vibration enabled.
+    *
+    * Reads settings from file.
+    * @return true if enabled, false otherwise
+    */
+    bool isTouchscreenVibrationEnabled();
+
 private slots:
     /**
     * @brief Slot for display state changed.
index 785be90..28aa856 100644 (file)
@@ -155,7 +155,7 @@ simulator {
                    engine/mceprivate.cpp
         HEADERS += network/networkhandlerprivate.h \
                    engine/mceprivate.h
-        QT += dbus
+        QT += dbus xml
         CONFIG += icd2 qdbus
         SOURCES += gps/gpspositionprivateliblocation.cpp \
                    gps/liblocationwrapper.cpp \