summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/imports/systeminfo/qdeclarativedeviceprofile.cpp132
-rw-r--r--src/imports/systeminfo/qdeclarativedeviceprofile_p.h101
-rw-r--r--src/imports/systeminfo/qsysteminfo.cpp45
-rw-r--r--src/imports/systeminfo/systeminfo.pro4
-rw-r--r--src/systeminfo/qdeviceprofile.cpp63
-rw-r--r--src/systeminfo/qdeviceprofile.h18
-rw-r--r--src/systeminfo/qdeviceprofile_linux.cpp68
-rw-r--r--src/systeminfo/qdeviceprofile_linux_p.h22
-rw-r--r--src/systeminfo/qjsondbwrapper.cpp483
-rw-r--r--src/systeminfo/qjsondbwrapper_p.h29
10 files changed, 697 insertions, 268 deletions
diff --git a/src/imports/systeminfo/qdeclarativedeviceprofile.cpp b/src/imports/systeminfo/qdeclarativedeviceprofile.cpp
new file mode 100644
index 00000000..42eacc6b
--- /dev/null
+++ b/src/imports/systeminfo/qdeclarativedeviceprofile.cpp
@@ -0,0 +1,132 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtSystems module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this
+** file. Please review the following information to ensure the GNU Lesser
+** General Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qdeclarativedeviceprofile_p.h"
+
+QT_BEGIN_NAMESPACE
+
+/*!
+ \qmlclass DeviceProfile QDeclarativeDeviceProfile
+ \inqmlmodule QtSystemInfo
+ \ingroup qml-systeminfo
+ \brief The DeviceProfile element provides information about the profile of the device.
+*/
+
+/*!
+ \internal
+*/
+QDeclarativeDeviceProfile::QDeclarativeDeviceProfile(QObject *parent)
+ : QObject(parent)
+ , deviceProfile(new QDeviceProfile(this))
+{
+}
+
+/*!
+ \internal
+ */
+QDeclarativeDeviceProfile::~QDeclarativeDeviceProfile()
+{
+}
+
+/*!
+ \qmlproperty bool DeviceProfile::isVibrationActivated
+
+ This property holds whether the vibration is currently activated or deactivated.
+ */
+
+bool QDeclarativeDeviceProfile::isVibrationActivated() const
+{
+ connect(deviceProfile, SIGNAL(vibrationActivatedChanged(bool)),
+ this, SIGNAL(vibrationActivatedChanged()), Qt::UniqueConnection);
+ return deviceProfile->isVibrationActivated();
+}
+
+/*!
+ \qmlproperty int DeviceProfile::messageRingtoneVolume
+
+ This property holds the current message ringtone volume, from 0 to 100.
+ If this information is unknown, voice message volume requested but no result
+ received yet or error occurs, -1 is returned.
+ */
+
+int QDeclarativeDeviceProfile::messageRingtoneVolume() const
+{
+ connect(deviceProfile, SIGNAL(messageRingtoneVolumeChanged(int)),
+ this, SIGNAL(messageRingtoneVolumeChanged()), Qt::UniqueConnection);
+ return deviceProfile->messageRingtoneVolume();
+}
+
+/*!
+ \qmlproperty int DeviceProfile::voiceRingtoneVolume
+
+ This property holds the current voice ringtone volume, from 0 to 100.
+ If this information is unknown, voice ringtone volume requested but no result
+ received yet or error occurs, -1 is returned.
+ */
+
+int QDeclarativeDeviceProfile::voiceRingtoneVolume() const
+{
+ connect(deviceProfile, SIGNAL(voiceRingtoneVolumeChanged(int)),
+ this, SIGNAL(voiceRingtoneVolumeChanged()), Qt::UniqueConnection);
+ return deviceProfile->voiceRingtoneVolume();
+}
+
+/*!
+ \qmlproperty enum DeviceProfile::currentProfileType
+
+ Returns the type of the current profile, possible types are:
+ \list
+ \li UnknownProfile Profile unknown, profile type requested but no result received yet or an error occured.
+ \li SilentProfile Neither sound nor vibration is on.
+ \li NormalProfile Normal sound is on.
+ \li VibrationProfile Only vibration is on, and sound is off.
+ \li BeepProfile Only beep is on.
+ \endlist
+ */
+
+QDeclarativeDeviceProfile::ProfileType QDeclarativeDeviceProfile::currentProfileType() const
+{
+ connect(deviceProfile, SIGNAL(currentProfileTypeChanged(QDeviceProfile::ProfileType)),
+ this, SIGNAL(currentProfileTypeChanged()), Qt::UniqueConnection);
+ return static_cast<QDeclarativeDeviceProfile::ProfileType>(deviceProfile->currentProfileType());
+}
+
+QT_END_NAMESPACE
diff --git a/src/imports/systeminfo/qdeclarativedeviceprofile_p.h b/src/imports/systeminfo/qdeclarativedeviceprofile_p.h
new file mode 100644
index 00000000..c07be0fb
--- /dev/null
+++ b/src/imports/systeminfo/qdeclarativedeviceprofile_p.h
@@ -0,0 +1,101 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtSystems module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this
+** file. Please review the following information to ensure the GNU Lesser
+** General Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists purely as an
+// implementation detail. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
+
+#ifndef QDECLARATIVEDEVICEPROFILE_P_H
+#define QDECLARATIVEDEVICEPROFILE_P_H
+
+#include <qdeviceprofile.h>
+
+QT_BEGIN_HEADER
+QT_BEGIN_NAMESPACE
+
+class QDeclarativeDeviceProfile : public QObject
+{
+ Q_OBJECT
+
+ Q_ENUMS(ProfileType)
+ Q_PROPERTY(bool isVibrationActivated READ isVibrationActivated NOTIFY vibrationActivatedChanged)
+ Q_PROPERTY(int messageRingtoneVolume READ messageRingtoneVolume NOTIFY messageRingtoneVolumeChanged)
+ Q_PROPERTY(int voiceRingtoneVolume READ voiceRingtoneVolume NOTIFY voiceRingtoneVolumeChanged)
+ Q_PROPERTY(ProfileType currentProfileType READ currentProfileType NOTIFY currentProfileTypeChanged)
+
+public:
+ enum ProfileType {
+ UnknownProfile = QDeviceProfile::UnknownProfile,
+ SilentProfile = QDeviceProfile::SilentProfile,
+ NormalProfile = QDeviceProfile::NormalProfile,
+ VibrationProfile = QDeviceProfile::VibrationProfile,
+ BeepProfile = QDeviceProfile::BeepProfile
+ };
+
+ QDeclarativeDeviceProfile(QObject *parent = 0);
+ virtual ~QDeclarativeDeviceProfile();
+
+ bool isVibrationActivated() const;
+ int messageRingtoneVolume() const;
+ int voiceRingtoneVolume() const;
+ ProfileType currentProfileType() const;
+
+Q_SIGNALS:
+ void vibrationActivatedChanged();
+ void messageRingtoneVolumeChanged();
+ void voiceRingtoneVolumeChanged();
+ void currentProfileTypeChanged();
+
+private:
+ QDeviceProfile *deviceProfile;
+};
+
+QT_END_NAMESPACE
+QT_END_HEADER
+
+#endif // QDECLARATIVEDEVICEPROFILE_P_H
diff --git a/src/imports/systeminfo/qsysteminfo.cpp b/src/imports/systeminfo/qsysteminfo.cpp
index 4bbe8822..f3e2eeb8 100644
--- a/src/imports/systeminfo/qsysteminfo.cpp
+++ b/src/imports/systeminfo/qsysteminfo.cpp
@@ -44,7 +44,7 @@
#include "qdeclarativebatteryinfo_p.h"
#include "qdeclarativedeviceinfo_p.h"
-#include <qdeviceprofile.h>
+#include "qdeclarativedeviceprofile_p.h"
#include "qdeclarativedisplayinfo_p.h"
#include "qdeclarativenetworkinfo_p.h"
#include <qscreensaver.h>
@@ -66,7 +66,7 @@ public:
int minor = 0;
qmlRegisterType<QDeclarativeBatteryInfo>(uri, major, minor, "BatteryInfo");
qmlRegisterType<QDeclarativeDeviceInfo>(uri, major, minor, "DeviceInfo");
- qmlRegisterType<QDeviceProfile>(uri, major, minor, "DeviceProfile");
+ qmlRegisterType<QDeclarativeDeviceProfile>(uri, major, minor, "DeviceProfile");
qmlRegisterType<QDeclarativeDisplayInfo>(uri, major, minor, "DisplayInfo");
qmlRegisterType<QDeclarativeNetworkInfo>(uri, major, minor, "NetworkInfo");
qmlRegisterType<QScreenSaver>(uri, major, minor, "ScreenSaver");
@@ -92,45 +92,4 @@ QT_END_NAMESPACE
On certain platforms, if screen saver is disabled, deep system sleep won't be automatically triggered,
and the display won't be automatically turned off, etc.
- */
-
-
-/*!
- \qmlclass DeviceProfile QDeviceProfile
- \inqmlmodule QtSystemInfo
- \ingroup qml-systeminfo
- \brief The DeviceProfile element provides information about the profile of the device.
*/
-
-/*!
- \qmlmethod bool DeviceProfile::isVibrationActivated()
-
- Returns true if the vibration is currently activated, or false otherwise.
- */
-
-/*!
- \qmlmethod int DeviceProfile::messageRingtoneVolume()
-
- Returns the current message ringtone volume, from 0 to 100. If this information is unknown, or
- error occurs, -1 is returned.
- */
-
-/*!
- \qmlmethod int DeviceProfile::voiceRingtoneVolume()
-
- Returns the current voice ringtone volume, from 0 to 100. If this information is unknown, or error
- occurs, -1 is returned.
- */
-
-/*!
- \qmlproperty enum DeviceProfile::currentProfileType
-
- Returns the type of the current profile, possible types are:
- \list
- \li UnknownProfile Profile unknown or on error.
- \li SilentProfile Neither sound nor vibration is on.
- \li NormalProfile Normal sound is on.
- \li VibrationProfile Only vibration is on, and sound is off.
- \li BeepProfile Only beep is on.
- \endlist
- */
diff --git a/src/imports/systeminfo/systeminfo.pro b/src/imports/systeminfo/systeminfo.pro
index 490e2107..e1ddca13 100644
--- a/src/imports/systeminfo/systeminfo.pro
+++ b/src/imports/systeminfo/systeminfo.pro
@@ -16,7 +16,8 @@ HEADERS += \
qdeclarativedeviceinfo_p.h \
qdeclarativedisplayinfo_p.h \
qdeclarativenetworkinfo_p.h \
- qdeclarativestorageinfo_p.h
+ qdeclarativestorageinfo_p.h \
+ qdeclarativedeviceprofile_p.h
SOURCES += \
qdeclarativebatteryinfo.cpp \
@@ -24,4 +25,5 @@ SOURCES += \
qdeclarativedisplayinfo.cpp \
qdeclarativenetworkinfo.cpp \
qdeclarativestorageinfo.cpp \
+ qdeclarativedeviceprofile.cpp \
qsysteminfo.cpp
diff --git a/src/systeminfo/qdeviceprofile.cpp b/src/systeminfo/qdeviceprofile.cpp
index 94912407..f2e82830 100644
--- a/src/systeminfo/qdeviceprofile.cpp
+++ b/src/systeminfo/qdeviceprofile.cpp
@@ -71,7 +71,7 @@ QT_BEGIN_NAMESPACE
\enum QDeviceProfile::ProfileType
This enum describes the type of the current profile.
- \value UnknownProfile Profile unknown or on error.
+ \value UnknownProfile Profile unknown, profile type requested but no result received yet or an error occured.
\value SilentProfile Neither sound nor vibration is on.
\value NormalProfile Normal sound is on.
\value VibrationProfile Only vibration is on, and sound is off.
@@ -79,6 +79,24 @@ QT_BEGIN_NAMESPACE
*/
/*!
+ \fn void QDeviceProfile::vibrationActivatedChanged(bool activated)
+
+ This signal is emitted whenever vibration has been changed to \a activated.
+ */
+
+/*!
+ \fn void QDeviceProfile::messageRingtoneVolumeChanged(int volume)
+
+ This signal is emitted whenever the message ringtone volume has been changed to \a volume.
+ */
+
+/*!
+ \fn void QDeviceProfile::voiceRingtoneVolumeChanged(int volume)
+
+ This signal is emitted whenever the voice ringtone volume has been changed to \a volume.
+ */
+
+/*!
\fn void QDeviceProfile::currentProfileTypeChanged(ProfileType profile)
This signal is emitted whenever the current profile type has been changed to \a profile.
@@ -102,7 +120,10 @@ QDeviceProfile::~QDeviceProfile()
}
/*!
- Returns the whether the vibration is active for this profile.
+ \property QDeviceProfile::isVibrationActivated
+ \brief Vibration activated or deactivated.
+
+ Returns whether the vibration is active for this profile.
*/
bool QDeviceProfile::isVibrationActivated() const
{
@@ -110,8 +131,11 @@ bool QDeviceProfile::isVibrationActivated() const
}
/*!
+ \property QDeviceProfile::messageRingtoneVolume
+ \brief The message ringtone volume.
+
Returns the message ringtone volume for this profile, from 0 to 100. If this information is unknown,
- or error occurs, -1 is returned.
+ message volume requested but no result received yet or error occurs the -1 is returned.
*/
int QDeviceProfile::messageRingtoneVolume() const
{
@@ -119,8 +143,11 @@ int QDeviceProfile::messageRingtoneVolume() const
}
/*!
+ \property QDeviceProfile::voiceRingtoneVolume
+ \brief The voice ringtone volume.
+
Returns the voice ringtone volume for this profile, from 0 to 100. If this information is unknown,
- or error occurs, -1 is returned.
+ voice volume requested but no result received yet or error occurs the -1 is returned.
*/
int QDeviceProfile::voiceRingtoneVolume() const
{
@@ -138,4 +165,32 @@ QDeviceProfile::ProfileType QDeviceProfile::currentProfileType() const
return d_ptr->currentProfileType();
}
+/*!
+ \internal
+*/
+void QDeviceProfile::connectNotify(const char *signal)
+{
+#if defined(Q_OS_LINUX) || defined(QT_SIMULATOR)
+ connect(d_ptr, signal, this, signal, Qt::UniqueConnection);
+#else
+ Q_UNUSED(signal)
+#endif
+}
+
+/*!
+ \internal
+*/
+void QDeviceProfile::disconnectNotify(const char *signal)
+{
+#if defined(Q_OS_LINUX) || defined(QT_SIMULATOR)
+ // We can only disconnect with the private implementation, when there is no receivers for the signal.
+ if (receivers(signal) > 0)
+ return;
+
+ disconnect(d_ptr, signal, this, signal);
+#else
+ Q_UNUSED(signal)
+#endif
+}
+
QT_END_NAMESPACE
diff --git a/src/systeminfo/qdeviceprofile.h b/src/systeminfo/qdeviceprofile.h
index 0e58dcc5..4c9ad312 100644
--- a/src/systeminfo/qdeviceprofile.h
+++ b/src/systeminfo/qdeviceprofile.h
@@ -55,6 +55,9 @@ class Q_SYSTEMINFO_EXPORT QDeviceProfile : public QObject
Q_OBJECT
Q_ENUMS(ProfileType)
+ Q_PROPERTY(bool isVibrationActivated READ isVibrationActivated NOTIFY vibrationActivatedChanged)
+ Q_PROPERTY(int messageRingtoneVolume READ messageRingtoneVolume NOTIFY messageRingtoneVolumeChanged)
+ Q_PROPERTY(int voiceRingtoneVolume READ voiceRingtoneVolume NOTIFY voiceRingtoneVolumeChanged)
Q_PROPERTY(ProfileType currentProfileType READ currentProfileType NOTIFY currentProfileTypeChanged)
public:
@@ -69,13 +72,20 @@ public:
QDeviceProfile(QObject *parent = 0);
virtual ~QDeviceProfile();
- Q_INVOKABLE bool isVibrationActivated() const;
- Q_INVOKABLE int messageRingtoneVolume() const;
- Q_INVOKABLE int voiceRingtoneVolume() const;
+ bool isVibrationActivated() const;
+ int messageRingtoneVolume() const;
+ int voiceRingtoneVolume() const;
ProfileType currentProfileType() const;
Q_SIGNALS:
- void currentProfileTypeChanged(ProfileType profile);
+ void vibrationActivatedChanged(bool activated);
+ void messageRingtoneVolumeChanged(int volume);
+ void voiceRingtoneVolumeChanged(int volume);
+ void currentProfileTypeChanged(QDeviceProfile::ProfileType profile);
+
+protected:
+ void connectNotify(const char *signal);
+ void disconnectNotify(const char *signal);
private:
Q_DISABLE_COPY(QDeviceProfile)
diff --git a/src/systeminfo/qdeviceprofile_linux.cpp b/src/systeminfo/qdeviceprofile_linux.cpp
index 00ecf097..79b6af77 100644
--- a/src/systeminfo/qdeviceprofile_linux.cpp
+++ b/src/systeminfo/qdeviceprofile_linux.cpp
@@ -41,34 +41,26 @@
#include "qdeviceprofile_linux_p.h"
-#if !defined(QT_NO_JSONDB)
-# include "qjsondbwrapper_p.h"
-#endif //QT_NO_JSONDB
-
QT_BEGIN_NAMESPACE
QDeviceProfilePrivate::QDeviceProfilePrivate(QDeviceProfile *parent)
- : q_ptr(parent)
+ : QObject(parent)
+ , q_ptr(parent)
+{
#if !defined(QT_NO_JSONDB)
- , jsondbWrapper(0)
+ // start querying for profile data
+ jsondbWrapper.currentProfileType();
#endif //QT_NO_JSONDB
-{
}
QDeviceProfilePrivate::~QDeviceProfilePrivate()
{
-#if !defined(QT_NO_JSONDB)
- if (jsondbWrapper)
- delete jsondbWrapper;
-#endif //QT_NO_JSONDB
}
bool QDeviceProfilePrivate::isVibrationActivated()
{
#if !defined(QT_NO_JSONDB)
- if (!jsondbWrapper)
- jsondbWrapper = new QJsonDbWrapper();
- return jsondbWrapper->isVibrationActivated();
+ return jsondbWrapper.isVibrationActivated();
#endif //QT_NO_JSONDB
return false;
@@ -77,9 +69,7 @@ bool QDeviceProfilePrivate::isVibrationActivated()
int QDeviceProfilePrivate::messageRingtoneVolume()
{
#if !defined(QT_NO_JSONDB)
- if (!jsondbWrapper)
- jsondbWrapper = new QJsonDbWrapper();
- return jsondbWrapper->getRingtoneVolume();
+ return jsondbWrapper.ringtoneVolume();
#endif //QT_NO_JSONDB
return -1;
@@ -88,9 +78,7 @@ int QDeviceProfilePrivate::messageRingtoneVolume()
int QDeviceProfilePrivate::voiceRingtoneVolume()
{
#if !defined(QT_NO_JSONDB)
- if (!jsondbWrapper)
- jsondbWrapper = new QJsonDbWrapper();
- return jsondbWrapper->getRingtoneVolume();
+ return jsondbWrapper.ringtoneVolume();
#endif //QT_NO_JSONDB
return -1;
@@ -99,20 +87,38 @@ int QDeviceProfilePrivate::voiceRingtoneVolume()
QDeviceProfile::ProfileType QDeviceProfilePrivate::currentProfileType()
{
#if !defined(QT_NO_JSONDB)
- if (!jsondbWrapper)
- jsondbWrapper = new QJsonDbWrapper();
-
- if (jsondbWrapper->getRingtoneVolume() > 0) {
- return QDeviceProfile::NormalProfile;
- } else {
- if (jsondbWrapper->isVibrationActivated())
- return QDeviceProfile::VibrationProfile;
- else
- return QDeviceProfile::SilentProfile;
- }
+ return jsondbWrapper.currentProfileType();
#endif //QT_NO_JSONDB
return QDeviceProfile::UnknownProfile;
}
+void QDeviceProfilePrivate::connectNotify(const char *signal)
+{
+#if !defined(QT_NO_JSONDB)
+ if (strcmp(signal, SIGNAL(vibrationActivatedChanged(bool))) == 0
+ || strcmp(signal, SIGNAL(currentProfileTypeChanged(QDeviceProfile::ProfileType))) == 0) {
+ connect(&jsondbWrapper, signal, this, signal, Qt::UniqueConnection);
+ } else if (strcmp(signal, SIGNAL(messageRingtoneVolumeChanged(int))) == 0) {
+ connect(&jsondbWrapper, SIGNAL(ringtoneVolumeChanged(int)), this, signal, Qt::UniqueConnection);
+ } else if (strcmp(signal, SIGNAL(voiceRingtoneVolumeChanged(int))) == 0) {
+ connect(&jsondbWrapper, SIGNAL(ringtoneVolumeChanged(int)), this, signal, Qt::UniqueConnection);
+ }
+#endif // // QT_NO_JSONDB
+}
+
+void QDeviceProfilePrivate::disconnectNotify(const char *signal)
+{
+#if !defined(QT_NO_JSONDB)
+ if (strcmp(signal, SIGNAL(vibrationActivatedChanged(bool))) == 0
+ || strcmp(signal, SIGNAL(currentProfileTypeChanged(QDeviceProfile::ProfileType))) == 0) {
+ disconnect(&jsondbWrapper, signal, this, signal);
+ } else if (strcmp(signal, SIGNAL(messageRingtoneVolumeChanged(int))) == 0) {
+ disconnect(&jsondbWrapper, SIGNAL(ringtoneVolumeChanged(int)), this, signal);
+ } else if (strcmp(signal, SIGNAL(voiceRingtoneVolumeChanged(int))) == 0) {
+ disconnect(&jsondbWrapper, SIGNAL(ringtoneVolumeChanged(int)), this, signal);
+ }
+#endif // QT_NO_JSONDB
+}
+
QT_END_NAMESPACE
diff --git a/src/systeminfo/qdeviceprofile_linux_p.h b/src/systeminfo/qdeviceprofile_linux_p.h
index 8bdffe08..8cbd0911 100644
--- a/src/systeminfo/qdeviceprofile_linux_p.h
+++ b/src/systeminfo/qdeviceprofile_linux_p.h
@@ -55,14 +55,16 @@
#include <qdeviceprofile.h>
-QT_BEGIN_NAMESPACE
-
#if !defined(QT_NO_JSONDB)
-class QJsonDbWrapper;
+#include <qjsondbwrapper_p.h>
#endif //QT_NO_JSONDB
-class QDeviceProfilePrivate
+QT_BEGIN_NAMESPACE
+
+class QDeviceProfilePrivate : public QObject
{
+ Q_OBJECT
+
public:
QDeviceProfilePrivate(QDeviceProfile *parent);
~QDeviceProfilePrivate();
@@ -72,12 +74,22 @@ public:
int voiceRingtoneVolume();
QDeviceProfile::ProfileType currentProfileType();
+Q_SIGNALS:
+ void vibrationActivatedChanged(bool activated);
+ void messageRingtoneVolumeChanged(int volume);
+ void voiceRingtoneVolumeChanged(int volume);
+ void currentProfileTypeChanged(QDeviceProfile::ProfileType profile);
+
+protected:
+ void connectNotify(const char *signal);
+ void disconnectNotify(const char *signal);
+
private:
QDeviceProfile * const q_ptr;
Q_DECLARE_PUBLIC(QDeviceProfile)
#if !defined(QT_NO_JSONDB)
- QJsonDbWrapper *jsondbWrapper;
+ QJsonDbWrapper jsondbWrapper;
#endif //QT_NO_JSONDB
};
diff --git a/src/systeminfo/qjsondbwrapper.cpp b/src/systeminfo/qjsondbwrapper.cpp
index b15013cb..c75e06f4 100644
--- a/src/systeminfo/qjsondbwrapper.cpp
+++ b/src/systeminfo/qjsondbwrapper.cpp
@@ -45,6 +45,7 @@
#include <QtCore/qtimer.h>
#include <QtJsonDb/qjsondbreadrequest.h>
#include <QtJsonDb/qjsondbwatcher.h>
+
QT_USE_NAMESPACE_JSONDB
QT_BEGIN_NAMESPACE
@@ -54,15 +55,21 @@ const int JSON_EXPIRATION_TIMER(2000);
QJsonDbWrapper::QJsonDbWrapper(QObject *parent)
: QObject(parent)
, locksWatcher(0)
+ , soundSettingsWatcher(0)
, backlightWatcher(0)
, waitLoop(0)
, timer(0)
, watchActivatedLocks(false)
, watchEnabledLocks(false)
+ , watchProfile(false)
, watchBacklightState(false)
, activatedLocks(QDeviceInfo::UnknownLock)
, enabledLocks(QDeviceInfo::UnknownLock)
, isLockTypeRequested(false)
+ , isSoundSettingsRequested(false)
+ , vibrationActivated(false)
+ , ringerVolume(-1)
+ , profileType(QDeviceProfile::UnknownProfile)
{
connect(&jsonDbConnection, SIGNAL(error(QtJsonDb::QJsonDbConnection::ErrorCode,QString)),
this, SLOT(onJsonDbConnectionError(QtJsonDb::QJsonDbConnection::ErrorCode,QString)));
@@ -78,8 +85,9 @@ QDeviceInfo::LockTypeFlags QJsonDbWrapper::activatedLockTypes()
{
if (!isLockTypeRequested && activatedLocks == QDeviceInfo::UnknownLock) {
isLockTypeRequested = true;
- sendJsonDbLockObjectsReadRequest(QStringLiteral("Ephemeral"));
+ sendJsonDbLockObjectsReadRequest();
}
+
return activatedLocks;
}
@@ -87,7 +95,7 @@ QDeviceInfo::LockTypeFlags QJsonDbWrapper::enabledLockTypes()
{
if (!isLockTypeRequested && enabledLocks == QDeviceInfo::UnknownLock) {
isLockTypeRequested = true;
- sendJsonDbLockObjectsReadRequest(QStringLiteral("Ephemeral"));
+ sendJsonDbLockObjectsReadRequest();
}
return enabledLocks;
@@ -107,18 +115,53 @@ QString QJsonDbWrapper::model()
bool QJsonDbWrapper::isVibrationActivated()
{
- return getSystemSettingValue(QString(QStringLiteral("sounds")),
- QString(QStringLiteral("vibrationOn"))).toBool();
+ if (!isSoundSettingsRequested && ringerVolume < 0) {
+ isSoundSettingsRequested = true;
+ sendJsonDbSoundSettingsReadRequest();
+ }
+
+ return vibrationActivated;
+}
+
+int QJsonDbWrapper::ringtoneVolume()
+{
+ if (!isSoundSettingsRequested && ringerVolume < 0) {
+ isSoundSettingsRequested = true;
+ sendJsonDbSoundSettingsReadRequest();
+ }
+
+ return ringerVolume;
+}
+
+QDeviceProfile::ProfileType QJsonDbWrapper::currentProfileType()
+{
+ if (!isSoundSettingsRequested && ringerVolume < 0) {
+ isSoundSettingsRequested = true;
+ sendJsonDbSoundSettingsReadRequest();
+ }
+
+ return profileType;
}
-int QJsonDbWrapper::getRingtoneVolume()
+void QJsonDbWrapper::sendJsonDbLockObjectsReadRequest()
{
- int volume = getSystemSettingValue(QString(QStringLiteral("sounds")),
- QString(QStringLiteral("ringerVolume"))).toDouble();
- if (volume >= 0 && volume <= 100)
- return volume;
+ QJsonDbReadRequest *request = new QtJsonDb::QJsonDbReadRequest();
+ request->setQuery(QString(QStringLiteral("[?_type in [\"com.nokia.mt.system.SecurityLock\",\"com.nokia.mt.system.Lockscreen\"]]")));
+ request->setPartition(QString(QStringLiteral("Ephemeral")));
+ connect(request, SIGNAL(error(QtJsonDb::QJsonDbRequest::ErrorCode,QString)),
+ this, SLOT(onJsonDbReadRequestError(QtJsonDb::QJsonDbRequest::ErrorCode,QString)));
+ connect(request, SIGNAL(finished()), this, SLOT(onJsonDbLockObjectsReadRequestFinished()));
+ jsonDbConnection.send(request);
+}
- return -1;
+void QJsonDbWrapper::sendJsonDbSoundSettingsReadRequest()
+{
+ QJsonDbReadRequest *request = new QJsonDbReadRequest();
+ request->setQuery(QString(QStringLiteral("[?_type=\"com.nokia.mt.settings.SystemSettings\"][?identifier=\"com.nokia.mt.settings.sounds\"][={settings:settings}]")));
+ connect(request, SIGNAL(error(QtJsonDb::QJsonDbRequest::ErrorCode,QString)),
+ this, SLOT(onJsonDbReadRequestError(QtJsonDb::QJsonDbRequest::ErrorCode,QString)));
+ connect(request, SIGNAL(finished()), this, SLOT(onJsonDbSoundSettingsReadRequestFinished()));
+ jsonDbConnection.send(request);
}
QJsonValue QJsonDbWrapper::getSystemSettingValue(const QString &settingId, const QString &setting, const QString &partition)
@@ -129,8 +172,8 @@ QJsonValue QJsonDbWrapper::getSystemSettingValue(const QString &settingId, const
request.setQuery(QString(QStringLiteral("[?_type=\"com.nokia.mt.settings.SystemSettings\"][?identifier=\"com.nokia.mt.settings.%1\"][={settings:settings}]"))
.arg(settingId));
connect(&request, SIGNAL(error(QtJsonDb::QJsonDbRequest::ErrorCode,QString)),
- this, SLOT(onJsonDbRequestError(QtJsonDb::QJsonDbRequest::ErrorCode,QString)));
- connect(&request, SIGNAL(finished()), this, SLOT(onJsonDbRequestFinished()));
+ this, SLOT(onJsonDbSynchronousRequestError(QtJsonDb::QJsonDbRequest::ErrorCode,QString)));
+ connect(&request, SIGNAL(finished()), this, SLOT(onJsonDbSynchronousRequestFinished()));
if (jsonDbConnection.send(&request)) {
waitForResponse();
if (request.status() == QJsonDbRequest::Finished) {
@@ -142,39 +185,9 @@ QJsonValue QJsonDbWrapper::getSystemSettingValue(const QString &settingId, const
return QJsonValue();
}
-bool QJsonDbWrapper::hasSystemObject(const QString &objectType, const QString &partition)
-{
- QJsonDbReadRequest request;
- if (!partition.isEmpty())
- request.setPartition(partition);
- request.setQuery(QString(QStringLiteral("[?_type=\"com.nokia.mt.system.%1\"]")).arg(objectType));
- connect(&request, SIGNAL(error(QtJsonDb::QJsonDbRequest::ErrorCode,QString)),
- this, SLOT(onJsonDbRequestError(QtJsonDb::QJsonDbRequest::ErrorCode,QString)));
- connect(&request, SIGNAL(finished()), this, SLOT(onJsonDbRequestFinished()));
- if (jsonDbConnection.send(&request)) {
- waitForResponse();
- return (request.status() == QJsonDbRequest::Finished && request.takeResults().size() > 0);
- }
- return false;
-}
-
-void QJsonDbWrapper::sendJsonDbLockObjectsReadRequest(const QString &partition)
-{
- QJsonDbReadRequest *request = new QtJsonDb::QJsonDbReadRequest();
- if (!partition.isEmpty())
- request->setPartition(partition);
-
- request->setQuery(QString(QStringLiteral("[?_type in [\"com.nokia.mt.system.SecurityLock\",\"com.nokia.mt.system.Lockscreen\"]]")));
-
- connect(request, SIGNAL(error(QtJsonDb::QJsonDbRequest::ErrorCode,QString)),
- this, SLOT(onJsonDbReadRequestError(QtJsonDb::QJsonDbRequest::ErrorCode,QString)));
- connect(request, SIGNAL(finished()), this, SLOT(onJsonDbLockObjectsReadRequestFinished()));
- jsonDbConnection.send(request);
-}
-
void QJsonDbWrapper::connectNotify(const char *signal)
{
- if (watchActivatedLocks && watchEnabledLocks && watchBacklightState)
+ if (watchActivatedLocks && watchEnabledLocks && watchProfile && watchBacklightState)
return;
bool needWatchActivatedLocks = (strcmp(signal, SIGNAL(activatedLocksChanged(QDeviceInfo::LockTypeFlags))) == 0);
@@ -197,13 +210,23 @@ void QJsonDbWrapper::connectNotify(const char *signal)
if (needWatchEnabledLocks)
watchEnabledLocks = true;
+ bool needWatchProfiles = (strcmp(signal, SIGNAL(vibrationActivatedChanged(bool))) == 0
+ || strcmp(signal, SIGNAL(ringtoneVolumeChanged(int))) == 0
+ || strcmp(signal, SIGNAL(currentProfileTypeChanged(QDeviceProfile::ProfileType))) == 0);
+ if (needWatchProfiles) {
+ if (watchProfile)
+ return;
+ currentProfileType();
+ watchProfile = true;
+ }
+
if (strcmp(signal, SIGNAL(backlightStateChanged(int,QDisplayInfo::BacklightState))) == 0) {
if (!backlightWatcher) {
backlightWatcher = new QtJsonDb::QJsonDbWatcher(this);
- backlightWatcher->setPartition(QStringLiteral("Ephemeral"));
+ backlightWatcher->setPartition(QString(QStringLiteral("Ephemeral")));
backlightWatcher->setWatchedActions(QJsonDbWatcher::Updated);
backlightWatcher->setQuery(QString(QStringLiteral("[?_type=\"com.nokia.mt.system.DisplayState\"]")));
- connect(backlightWatcher, SIGNAL(notificationsAvailable(int)), this, SLOT(onJsonDbWatcherNotificationsBacklightStateAvailable()));
+ connect(backlightWatcher, SIGNAL(notificationsAvailable(int)), this, SLOT(onJsonDbWatcherBacklightStateNotificationsAvailable()));
}
jsonDbConnection.addWatcher(backlightWatcher);
watchBacklightState = true;
@@ -212,7 +235,7 @@ void QJsonDbWrapper::connectNotify(const char *signal)
void QJsonDbWrapper::disconnectNotify(const char *signal)
{
- if (!watchActivatedLocks && !watchEnabledLocks)
+ if (!watchActivatedLocks && !watchEnabledLocks && !watchBacklightState)
return;
if (strcmp(signal, SIGNAL(activatedLocksChanged(QDeviceInfo::LockTypeFlags))) == 0)
@@ -226,130 +249,6 @@ void QJsonDbWrapper::disconnectNotify(const char *signal)
jsonDbConnection.removeWatcher(backlightWatcher);
}
-void QJsonDbWrapper::onJsonDbWatcherNotificationsAvailable()
-{
- if (!watchActivatedLocks && !watchEnabledLocks)
- return;
-
- QList<QJsonDbNotification> notifications = locksWatcher->takeNotifications();
- if (notifications.size() > 0) {
- const QJsonDbNotification notification = notifications.at(0);
- const QByteArray objectType = notification.object().value(QStringLiteral("_type")).toString().toAscii();
- if (watchActivatedLocks) {
- if (notification.action() == QJsonDbWatcher::Removed) {
- if (activatedLocks.testFlag(QDeviceInfo::TouchOrKeyboardLock)
- && strcmp(objectType.constData(), "com.nokia.mt.system.Lockscreen") == 0) {
- activatedLocks &= ~QDeviceInfo::TouchOrKeyboardLock;
- emit activatedLocksChanged(activatedLocks);
- } else if (activatedLocks.testFlag(QDeviceInfo::PinLock)
- && strcmp(objectType.constData(), "com.nokia.mt.system.SecurityLock") == 0) {
- activatedLocks &= ~QDeviceInfo::PinLock;
- emit activatedLocksChanged(activatedLocks);
- }
- } else {
- if (objectType.size() == strlen("com.nokia.mt.system.Lockscreen") &&
- strcmp(objectType.constData(), "com.nokia.mt.system.Lockscreen") == 0) {
- if (notification.object().value(QString(QStringLiteral("isLocked"))).toBool()) {
- if (!activatedLocks.testFlag(QDeviceInfo::TouchOrKeyboardLock)) {
- activatedLocks |= QDeviceInfo::TouchOrKeyboardLock;
- emit activatedLocksChanged(activatedLocks);
- }
- } else {
- if (activatedLocks.testFlag(QDeviceInfo::TouchOrKeyboardLock)) {
- activatedLocks &= ~QDeviceInfo::TouchOrKeyboardLock;
- emit activatedLocksChanged(activatedLocks);
- }
- }
- } else if (objectType.size() == strlen("com.nokia.mt.system.SecurityLock") &&
- strcmp(objectType.constData(), "com.nokia.mt.system.SecurityLock") == 0) {
- if (notification.object().value(QString(QStringLiteral("active"))).toBool()) {
- if (!activatedLocks.testFlag(QDeviceInfo::PinLock)) {
- activatedLocks |= QDeviceInfo::PinLock;
- emit activatedLocksChanged(activatedLocks);
- }
- } else {
- if (activatedLocks.testFlag(QDeviceInfo::PinLock)) {
- activatedLocks &= ~QDeviceInfo::PinLock;
- emit activatedLocksChanged(activatedLocks);
- }
- }
- }
- }
- }
- if (watchEnabledLocks) {
- if (notification.action() == QJsonDbWatcher::Created) {
- if (objectType.size() == strlen("com.nokia.mt.system.Lockscreen") &&
- strcmp(objectType.constData(), "com.nokia.mt.system.Lockscreen") == 0)
- enabledLocks |= QDeviceInfo::TouchOrKeyboardLock;
- else if (objectType.size() == strlen("com.nokia.mt.system.SecurityLock") &&
- strcmp(objectType.constData(), "com.nokia.mt.system.SecurityLock") == 0)
- enabledLocks |= QDeviceInfo::PinLock;
- emit enabledLocksChanged(enabledLocks);
- } else if (notification.action() == QJsonDbWatcher::Removed) {
- if (objectType.size() == strlen("com.nokia.mt.system.Lockscreen") &&
- strcmp(objectType.constData(), "com.nokia.mt.system.Lockscreen") == 0)
- enabledLocks &= ~QDeviceInfo::TouchOrKeyboardLock;
- else if (objectType.size() == strlen("com.nokia.mt.system.SecurityLock") &&
- strcmp(objectType.constData(), "com.nokia.mt.system.SecurityLock") == 0)
- enabledLocks &= ~QDeviceInfo::PinLock;
- emit enabledLocksChanged(enabledLocks);
- }
- }
- }
-}
-
-void QJsonDbWrapper::onJsonDbWatcherNotificationsBacklightStateAvailable()
-{
- QList<QJsonDbNotification> notifications = backlightWatcher->takeNotifications();
- if (notifications.size() > 0) {
- const QJsonDbNotification notification = notifications.at(0);
- const int screen = notification.object().value(QStringLiteral("displayIndex")).toString().toInt();
- QDisplayInfo::BacklightState state;
- if (notification.object().value(QStringLiteral("active")).toBool())
- state = QDisplayInfo::BacklightOn;
- else
- state = QDisplayInfo::BacklightOff;
- emit backlightStateChanged(screen, state);
- }
-}
-
-void QJsonDbWrapper::onJsonDbConnectionError(QtJsonDb::QJsonDbConnection::ErrorCode error, const QString &message)
-{
- Q_UNUSED(error)
- Q_UNUSED(message)
-
- timer->stop();
- waitLoop->exit(0);
-}
-
-void QJsonDbWrapper::onJsonDbSynchronousRequestError(QtJsonDb::QJsonDbRequest::ErrorCode error, const QString &message)
-{
- Q_UNUSED(error)
- Q_UNUSED(message)
-
- timer->stop();
- waitLoop->exit(0);
-}
-
-void QJsonDbWrapper::onJsonDbRequestFinished()
-{
- timer->stop();
- waitLoop->exit(0);
-}
-
-void QJsonDbWrapper::onJsonDbReadRequestError(QtJsonDb::QJsonDbRequest::ErrorCode error, const QString &message)
-{
- Q_UNUSED(error)
- Q_UNUSED(message)
-
- QtJsonDb::QJsonDbRequest *request = qobject_cast<QtJsonDb::QJsonDbRequest *>(sender());
- if (request)
- request->deleteLater();
-
- if (isLockTypeRequested && activatedLocks == QDeviceInfo::UnknownLock)
- isLockTypeRequested = false;
-}
-
void QJsonDbWrapper::onJsonDbLockObjectsReadRequestFinished()
{
QtJsonDb::QJsonDbRequest *request = qobject_cast<QtJsonDb::QJsonDbRequest *>(sender());
@@ -424,13 +323,251 @@ void QJsonDbWrapper::onJsonDbLockObjectsReadRequestFinished()
locksWatcher->setPartition(QStringLiteral("Ephemeral"));
locksWatcher->setWatchedActions(QJsonDbWatcher::All);
locksWatcher->setQuery(QString(QStringLiteral("[?_type in [\"com.nokia.mt.system.SecurityLock\",\"com.nokia.mt.system.Lockscreen\"]]")));
- connect(locksWatcher, SIGNAL(notificationsAvailable(int)), this, SLOT(onJsonDbWatcherNotificationsAvailable()));
+ connect(locksWatcher, SIGNAL(notificationsAvailable(int)), this, SLOT(onJsonDbWatcherLocksNotificationsAvailable()));
jsonDbConnection.addWatcher(locksWatcher);
- watchActivatedLocks = true;
- watchEnabledLocks = true;
}
}
+void QJsonDbWrapper::onJsonDbSoundSettingsReadRequestFinished()
+{
+ QtJsonDb::QJsonDbRequest *request = qobject_cast<QtJsonDb::QJsonDbRequest *>(sender());
+ if (!request)
+ return;
+
+ if (request && request->status() == QJsonDbRequest::Finished) {
+ QList<QJsonObject> results = request->takeResults();
+ request->deleteLater();
+ if (results.size() > 0) {
+ QJsonObject soundSettings = results.at(0).value(QString(QStringLiteral("settings"))).toObject();
+ bool vibration = false;
+ if (!soundSettings.value(QString(QStringLiteral("vibrationOn"))).isUndefined())
+ vibration = soundSettings.value(QString(QStringLiteral("vibrationOn"))).toBool();
+ int volume = -1;
+ if (!soundSettings.value(QString(QStringLiteral("ringerVolume"))).isUndefined())
+ volume = int(soundSettings.value(QString(QStringLiteral("ringerVolume"))).toDouble());
+
+ if (volume > -1) {
+ QDeviceProfile::ProfileType profile = QDeviceProfile::UnknownProfile;
+ if (volume > 0) {
+ profile = QDeviceProfile::NormalProfile;
+ } else {
+ if (vibration)
+ profile = QDeviceProfile::VibrationProfile;
+ else
+ profile = QDeviceProfile::SilentProfile;
+ }
+ if (ringerVolume != volume) {
+ ringerVolume = volume;
+ if (watchProfile)
+ emit ringtoneVolumeChanged(ringerVolume);
+ }
+ if (vibrationActivated != vibration) {
+ vibrationActivated = vibration;
+ if (watchProfile)
+ emit vibrationActivatedChanged(vibrationActivated);
+ }
+ if (profileType != profile) {
+ profileType = profile;
+ if (watchProfile)
+ emit currentProfileTypeChanged(profileType);
+ }
+ }
+ }
+ }
+
+ if (!soundSettingsWatcher) {
+ soundSettingsWatcher = new QJsonDbWatcher(this);
+ soundSettingsWatcher->setWatchedActions(QJsonDbWatcher::Updated);
+ soundSettingsWatcher->setQuery(QString(QStringLiteral("[?_type=\"com.nokia.mt.settings.SystemSettings\"][?identifier=\"com.nokia.mt.settings.sounds\"][={settings:settings}]")));
+ connect(soundSettingsWatcher, SIGNAL(notificationsAvailable(int)),
+ this, SLOT(onJsonDbWatcherSoundSettingsNotificationsAvailable()));
+ jsonDbConnection.addWatcher(soundSettingsWatcher);
+ }
+}
+
+void QJsonDbWrapper::onJsonDbWatcherLocksNotificationsAvailable()
+{
+ QList<QJsonDbNotification> notifications = locksWatcher->takeNotifications();
+ if (notifications.size() > 0) {
+ const QJsonDbNotification notification = notifications.at(0);
+ const QByteArray objectType = notification.object().value(QStringLiteral("_type")).toString().toAscii();
+ if (notification.action() == QJsonDbWatcher::Removed) {
+ if (objectType.size() == strlen("com.nokia.mt.system.Lockscreen")
+ && strcmp(objectType.constData(), "com.nokia.mt.system.Lockscreen") == 0) {
+ if (activatedLocks.testFlag(QDeviceInfo::TouchOrKeyboardLock)) {
+ activatedLocks &= ~QDeviceInfo::TouchOrKeyboardLock;
+ if (watchActivatedLocks)
+ emit activatedLocksChanged(activatedLocks);
+ }
+ if (enabledLocks.testFlag(QDeviceInfo::TouchOrKeyboardLock)) {
+ enabledLocks &= ~QDeviceInfo::TouchOrKeyboardLock;
+ if (watchEnabledLocks)
+ emit enabledLocksChanged(enabledLocks);
+ }
+ } else if (objectType.size() == strlen("com.nokia.mt.system.SecurityLock")
+ && strcmp(objectType.constData(), "com.nokia.mt.system.SecurityLock") == 0) {
+ if (activatedLocks.testFlag(QDeviceInfo::PinLock)) {
+ activatedLocks &= ~QDeviceInfo::PinLock;
+ if (watchActivatedLocks)
+ emit activatedLocksChanged(activatedLocks);
+ }
+ if (enabledLocks.testFlag(QDeviceInfo::PinLock)) {
+ enabledLocks &= ~QDeviceInfo::PinLock;
+ if (watchEnabledLocks)
+ emit enabledLocksChanged(enabledLocks);
+ }
+ }
+ } else {
+ if (objectType.size() == strlen("com.nokia.mt.system.Lockscreen")
+ && strcmp(objectType.constData(), "com.nokia.mt.system.Lockscreen") == 0) {
+ if (notification.object().value(QString(QStringLiteral("isLocked"))).toBool()) {
+ if (!activatedLocks.testFlag(QDeviceInfo::TouchOrKeyboardLock)) {
+ activatedLocks |= QDeviceInfo::TouchOrKeyboardLock;
+ if (watchActivatedLocks)
+ emit activatedLocksChanged(activatedLocks);
+ }
+ } else {
+ if (activatedLocks.testFlag(QDeviceInfo::TouchOrKeyboardLock)) {
+ activatedLocks &= ~QDeviceInfo::TouchOrKeyboardLock;
+ if (watchActivatedLocks)
+ emit activatedLocksChanged(activatedLocks);
+ }
+ }
+ if (notification.action() == QJsonDbWatcher::Created) {
+ if (!enabledLocks.testFlag(QDeviceInfo::TouchOrKeyboardLock)) {
+ enabledLocks |= QDeviceInfo::TouchOrKeyboardLock;
+ if (watchEnabledLocks)
+ emit enabledLocksChanged(enabledLocks);
+ }
+ }
+ } else if (objectType.size() == strlen("com.nokia.mt.system.SecurityLock")
+ && strcmp(objectType.constData(), "com.nokia.mt.system.SecurityLock") == 0) {
+ if (notification.object().value(QString(QStringLiteral("active"))).toBool()) {
+ if (!activatedLocks.testFlag(QDeviceInfo::PinLock)) {
+ activatedLocks |= QDeviceInfo::PinLock;
+ if (watchActivatedLocks)
+ emit activatedLocksChanged(activatedLocks);
+ }
+ } else {
+ if (activatedLocks.testFlag(QDeviceInfo::PinLock)) {
+ activatedLocks &= ~QDeviceInfo::PinLock;
+ if (watchActivatedLocks)
+ emit activatedLocksChanged(activatedLocks);
+ }
+ }
+ if (notification.action() == QJsonDbWatcher::Created) {
+ if (!enabledLocks.testFlag(QDeviceInfo::PinLock)) {
+ enabledLocks |= QDeviceInfo::PinLock;
+ if (watchEnabledLocks)
+ emit enabledLocksChanged(enabledLocks);
+ }
+ }
+ }
+ }
+ }
+}
+
+void QJsonDbWrapper::onJsonDbWatcherSoundSettingsNotificationsAvailable()
+{
+ QList<QJsonDbNotification> notifications = soundSettingsWatcher->takeNotifications();
+ if (notifications.size() > 0) {
+ const QJsonDbNotification notification = notifications.at(0);
+ const QByteArray objectType = notification.object().value(QStringLiteral("_type")).toString().toAscii();
+ if (objectType.size() == strlen("com.nokia.mt.settings.SystemSettings")
+ && strcmp(objectType.constData(), "com.nokia.mt.settings.SystemSettings") == 0) {
+ const QByteArray identifier = notification.object().value(QStringLiteral("identifier")).toString().toAscii();
+ if (identifier.size() == strlen("com.nokia.mt.settings.sounds")
+ && strcmp(identifier.constData(), "com.nokia.mt.settings.sounds") == 0) {
+ bool vibration = notification.object().value(QString(QStringLiteral("settings"))).toObject().value(QString(QStringLiteral("vibrationOn"))).toBool();
+ int volume = int(notification.object().value(QString(QStringLiteral("settings"))).toObject().value(QString(QStringLiteral("ringerVolume"))).toDouble());
+ if (volume != ringerVolume || vibration != vibrationActivated) {
+ QDeviceProfile::ProfileType profile = QDeviceProfile::UnknownProfile;
+ if (volume > 0) {
+ profile = QDeviceProfile::NormalProfile;
+ } else {
+ if (vibration)
+ profile = QDeviceProfile::VibrationProfile;
+ else
+ profile = QDeviceProfile::SilentProfile;
+ }
+ if (ringerVolume != volume) {
+ ringerVolume = volume;
+ if (watchProfile)
+ emit ringtoneVolumeChanged(ringerVolume);
+ }
+ if (vibrationActivated != vibration) {
+ vibrationActivated = vibration;
+ if (watchProfile)
+ emit vibrationActivatedChanged(vibrationActivated);
+ }
+ if (profileType != profile) {
+ profileType = profile;
+ if (watchProfile)
+ emit currentProfileTypeChanged(profileType);
+ }
+ }
+ }
+ }
+ }
+}
+
+void QJsonDbWrapper::onJsonDbWatcherBacklightStateNotificationsAvailable()
+{
+ QList<QJsonDbNotification> notifications = backlightWatcher->takeNotifications();
+ if (notifications.size() > 0) {
+ const QJsonDbNotification notification = notifications.at(0);
+ const int screen = notification.object().value(QStringLiteral("displayIndex")).toString().toInt();
+ QDisplayInfo::BacklightState state;
+ if (notification.object().value(QStringLiteral("active")).toBool())
+ state = QDisplayInfo::BacklightOn;
+ else
+ state = QDisplayInfo::BacklightOff;
+ emit backlightStateChanged(screen, state);
+ }
+}
+
+void QJsonDbWrapper::onJsonDbConnectionError(QtJsonDb::QJsonDbConnection::ErrorCode error, const QString &message)
+{
+ Q_UNUSED(error)
+ Q_UNUSED(message)
+
+ if (timer)
+ timer->stop();
+ if (waitLoop)
+ waitLoop->exit(0);
+}
+
+void QJsonDbWrapper::onJsonDbReadRequestError(QtJsonDb::QJsonDbRequest::ErrorCode error, const QString &message)
+{
+ Q_UNUSED(error)
+ Q_UNUSED(message)
+
+ QtJsonDb::QJsonDbRequest *request = qobject_cast<QtJsonDb::QJsonDbRequest *>(sender());
+ if (request)
+ request->deleteLater();
+
+ if (isLockTypeRequested && activatedLocks == QDeviceInfo::UnknownLock)
+ isLockTypeRequested = false;
+
+ if (isSoundSettingsRequested && ringerVolume == -1)
+ isSoundSettingsRequested = false;
+}
+
+void QJsonDbWrapper::onJsonDbSynchronousRequestError(QtJsonDb::QJsonDbRequest::ErrorCode error, const QString &message)
+{
+ Q_UNUSED(error)
+ Q_UNUSED(message)
+
+ timer->stop();
+ waitLoop->exit(0);
+}
+
+void QJsonDbWrapper::onJsonDbSynchronousRequestFinished()
+{
+ timer->stop();
+ waitLoop->exit(0);
+}
+
bool QJsonDbWrapper::waitForResponse()
{
if (!waitLoop)
diff --git a/src/systeminfo/qjsondbwrapper_p.h b/src/systeminfo/qjsondbwrapper_p.h
index 0ae2085c..7eb2a89a 100644
--- a/src/systeminfo/qjsondbwrapper_p.h
+++ b/src/systeminfo/qjsondbwrapper_p.h
@@ -54,6 +54,7 @@
#define QJSONDBWRAPPER_P_H
#include <qdeviceinfo.h>
+#include <qdeviceprofile.h>
#include <qdisplayinfo.h>
#include <QtJsonDb/qjsondbconnection.h>
#include <QtJsonDb/qjsondbrequest.h>
@@ -78,11 +79,15 @@ public:
// DeviceProfile Interface
bool isVibrationActivated();
- int getRingtoneVolume();
+ int ringtoneVolume();
+ QDeviceProfile::ProfileType currentProfileType();
Q_SIGNALS:
void activatedLocksChanged(QDeviceInfo::LockTypeFlags types);
void enabledLocksChanged(QDeviceInfo::LockTypeFlags types);
+ void vibrationActivatedChanged(bool activated);
+ void ringtoneVolumeChanged(int volume);
+ void currentProfileTypeChanged(QDeviceProfile::ProfileType profile);
void backlightStateChanged(int screen, QDisplayInfo::BacklightState state);
protected:
@@ -92,20 +97,25 @@ protected:
private Q_SLOTS:
void onJsonDbConnectionError(QtJsonDb::QJsonDbConnection::ErrorCode error, const QString &message);
void onJsonDbReadRequestError(QtJsonDb::QJsonDbRequest::ErrorCode error, const QString &message);
- void onJsonDbRequestFinished();
- void onJsonDbWatcherNotificationsAvailable();
- void onJsonDbWatcherNotificationsBacklightStateAvailable();
- void onJsonDbSynchronousRequestError(QtJsonDb::QJsonDbRequest::ErrorCode error, const QString &message);
void onJsonDbLockObjectsReadRequestFinished();
+ void onJsonDbSoundSettingsReadRequestFinished();
+ void onJsonDbWatcherLocksNotificationsAvailable();
+ void onJsonDbWatcherSoundSettingsNotificationsAvailable();
+ void onJsonDbWatcherBacklightStateNotificationsAvailable();
+
+ void onJsonDbSynchronousRequestError(QtJsonDb::QJsonDbRequest::ErrorCode error, const QString &message);
+ void onJsonDbSynchronousRequestFinished();
private:
+ void sendJsonDbLockObjectsReadRequest();
+ void sendJsonDbSoundSettingsReadRequest();
+
QJsonValue getSystemSettingValue(const QString &settingId, const QString &setting, const QString &partition = QStringLiteral(""));
- bool hasSystemObject(const QString &objectType, const QString &partition = QStringLiteral(""));
- void sendJsonDbLockObjectsReadRequest(const QString &partition = QStringLiteral(""));
bool waitForResponse();
QtJsonDb::QJsonDbConnection jsonDbConnection;
QtJsonDb::QJsonDbWatcher *locksWatcher;
+ QtJsonDb::QJsonDbWatcher *soundSettingsWatcher;
QtJsonDb::QJsonDbWatcher *backlightWatcher;
QEventLoop *waitLoop;
@@ -113,10 +123,15 @@ private:
bool watchActivatedLocks;
bool watchEnabledLocks;
+ bool watchProfile;
bool watchBacklightState;
QDeviceInfo::LockTypeFlags activatedLocks;
QDeviceInfo::LockTypeFlags enabledLocks;
bool isLockTypeRequested;
+ bool isSoundSettingsRequested;
+ bool vibrationActivated;
+ int ringerVolume;
+ QDeviceProfile::ProfileType profileType;
};
QT_END_NAMESPACE