Commit 29ea45ce authored by Slava Monich's avatar Slava Monich

[mce-qt5] Initial commit. JB#36523

parents
*~
build
.DS_Store
*.pro.user
Qt client for mce, and a declarative plugin for it.
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE node PUBLIC
"-//freedesktop//DTD D-Bus Object Introspection 1.0//EN"
"http://standards.freedesktop.org/dbus/1.0/introspect.dtd">
<node name="/com/nokia/mce/request">
<interface name="com.nokia.mce.request">
<method name="get_display_status">
<arg direction="out" name="display_state" type="s"/>
</method>
<method name="get_tklock_mode">
<arg direction="out" name="mode_name" type="s"/>
</method>
</interface>
</node>
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE node PUBLIC
"-//freedesktop//DTD D-Bus Object Introspection 1.0//EN"
"http://standards.freedesktop.org/dbus/1.0/introspect.dtd">
<node name="/com/nokia/mce/signal">
<interface name="com.nokia.mce.signal">
<signal name="display_status_ind">
<arg name="display_state" type="s"/>
</signal>
<signal name="tklock_mode_ind">
<arg name="tklock_mode" type="s"/>
</signal>
</interface>
</node>
/*
* Copyright (C) 2016 Jolla Ltd.
* Contact: Slava Monich <slava.monich@jolla.com>
*
* You may use this file under the terms of BSD license as follows:
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of Jolla Ltd nor the names of its contributors may
* be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
* THE POSSIBILITY OF SUCH DAMAGE.
*
* The views and conclusions contained in the software and documentation
* are those of the authors and should not be interpreted as representing
* any official policies, either expressed or implied.
*/
#ifndef QMCE_DISPLAY_H
#define QMCE_DISPLAY_H
#include "qmcetypes.h"
class QMCE_EXPORT QMceDisplay : public QObject
{
Q_OBJECT
Q_PROPERTY(bool valid READ valid NOTIFY validChanged)
Q_PROPERTY(State state READ state NOTIFY stateChanged)
Q_ENUMS(State)
public:
enum State {
DisplayOff,
DisplayDim,
DisplayOn
};
QMceDisplay(QObject* aParent = NULL);
bool valid() const;
State state() const;
Q_SIGNALS:
void validChanged();
void stateChanged();
private:
class Private;
Private* iPrivate;
};
#endif // QMCE_DISPLAY_H
/*
* Copyright (C) 2016 Jolla Ltd.
* Contact: Slava Monich <slava.monich@jolla.com>
*
* You may use this file under the terms of BSD license as follows:
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of Jolla Ltd nor the names of its contributors may
* be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
* THE POSSIBILITY OF SUCH DAMAGE.
*
* The views and conclusions contained in the software and documentation
* are those of the authors and should not be interpreted as representing
* any official policies, either expressed or implied.
*/
#ifndef QMCE_TKLOCK_H
#define QMCE_TKLOCK_H
#include "qmcetypes.h"
class QMCE_EXPORT QMceTkLock : public QObject
{
Q_OBJECT
Q_PROPERTY(bool valid READ valid NOTIFY validChanged)
Q_PROPERTY(bool locked READ locked NOTIFY lockedChanged)
Q_PROPERTY(Mode mode READ mode NOTIFY modeChanged)
Q_ENUMS(Mode)
public:
enum Mode {
Locked,
SilentLocked,
LockedDim,
LockedDelay,
SilentLockedDim,
Unlocked,
SilentUnlocked
};
QMceTkLock(QObject* aParent = NULL);
bool valid() const;
bool locked() const;
Mode mode() const;
Q_SIGNALS:
void validChanged();
void lockedChanged();
void modeChanged();
private:
class Private;
Private* iPrivate;
};
#endif // QMCE_TKLOCK_H
/*
* Copyright (C) 2016 Jolla Ltd.
* Contact: Slava Monich <slava.monich@jolla.com>
*
* You may use this file under the terms of BSD license as follows:
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of Jolla Ltd nor the names of its contributors may
* be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
* THE POSSIBILITY OF SUCH DAMAGE.
*
* The views and conclusions contained in the software and documentation
* are those of the authors and should not be interpreted as representing
* any official policies, either expressed or implied.
*/
#ifndef QMCE_TYPES_H
#define QMCE_TYPES_H
#include <QtCore>
#ifdef QMCE_LIBRARY
# define QMCE_EXPORT Q_DECL_EXPORT
#else
# define QMCE_EXPORT Q_DECL_IMPORT
#endif
#endif // QMCE_TYPES_H
TARGET = mce-qt5
CONFIG += create_pc create_prl no_install_prl link_pkgconfig
PKGCONFIG += mce
QT += dbus
QT -= gui
QMAKE_CXXFLAGS += -Wno-unused-parameter -Wno-psabi
INCLUDEPATH += include
include(version.pri)
TEMPLATE = lib
DEFINES += QMCE_LIBRARY
isEmpty(PREFIX) {
PREFIX=/usr
}
XML_FILES += \
dbus/com.nokia.mce.request.xml \
dbus/com.nokia.mce.signal.xml
OTHER_FILES += $$XML_FILES
SOURCES += \
src/qmcedisplay.cpp \
src/qmceproxy.cpp \
src/qmcetklock.cpp
PUBLIC_HEADERS += \
include/qmcedisplay.h \
include/qmcetypes.h \
include/qmcetklock.h
HEADERS += \
$$PUBLIC_HEADERS \
src/qmceproxy.h
DBUS_INTERFACES += com_nokia_mce_request
com_nokia_mce_request.files = dbus/com.nokia.mce.request.xml
com_nokia_mce_request.header_flags = -N -c QMceRequestProxy
com_nokia_mce_request.source_flags = -N -c QMceRequestProxy
DBUS_INTERFACES += com_nokia_mce_signal
com_nokia_mce_signal.files = dbus/com.nokia.mce.signal.xml
com_nokia_mce_signal.header_flags = -N -c QMceSignalProxy
com_nokia_mce_signal.source_flags = -N -c QMceSignalProxy
target.path = $$[QT_INSTALL_LIBS]
headers.files = $$PUBLIC_HEADERS
headers.path = $$INSTALL_ROOT$$PREFIX/include/mce-qt5
pkgconfig.files = mce-qt5.pc
pkgconfig.path = $$[QT_INSTALL_LIBS]/pkgconfig
QMAKE_PKGCONFIG_NAME = $$TARGET
QMAKE_PKGCONFIG_DESTDIR = pkgconfig
QMAKE_PKGCONFIG_INCDIR = $$headers.path
QMAKE_PKGCONFIG_DESCRIPTION = Qt bindings for mce
QMAKE_PKGCONFIG_PREFIX = $$PREFIX
QMAKE_PKGCONFIG_VERSION = $$VERSION
INSTALLS += target headers pkgconfig
/*
* Copyright (C) 2016 Jolla Ltd.
* Contact: Slava Monich <slava.monich@jolla.com>
*
* You may use this file under the terms of BSD license as follows:
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of Jolla Ltd nor the names of its contributors may
* be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
* THE POSSIBILITY OF SUCH DAMAGE.
*
* The views and conclusions contained in the software and documentation
* are those of the authors and should not be interpreted as representing
* any official policies, either expressed or implied.
*/
#include "qmcedisplay.h"
#include "qmceproxy.h"
#include "mce/mode-names.h"
class QMceDisplay::Private : public QObject {
Q_OBJECT
public:
Private(QMceDisplay* aParent);
void queryDisplayStatus();
private Q_SLOTS:
void onProxyValidChanged();
void onQueryFinished(QDBusPendingCallWatcher* aWatcher);
void updateDisplayStatus(QString aStatus);
public:
QMceDisplay* iParent;
QSharedPointer<QMceProxy> iProxy;
bool iValid;
QMceDisplay::State iState;
};
QMceDisplay::Private::Private(QMceDisplay* aParent) :
QObject(aParent),
iParent(aParent),
iProxy(QMceProxy::instance()),
iValid(false),
iState(DisplayOff)
{
connect(iProxy->signalProxy(),
SIGNAL(display_status_ind(QString)),
SLOT(updateDisplayStatus(QString)));
connect(iProxy.data(),
SIGNAL(validChanged()),
SLOT(onProxyValidChanged()));
if (iProxy->valid()) {
queryDisplayStatus();
}
}
void QMceDisplay::Private::queryDisplayStatus()
{
connect(new QDBusPendingCallWatcher(
iProxy->requestProxy()->get_display_status(), this),
SIGNAL(finished(QDBusPendingCallWatcher*)),
SLOT(onQueryFinished(QDBusPendingCallWatcher*)));
}
void QMceDisplay::Private::updateDisplayStatus(QString aStatus)
{
static const QString MCE_DISPLAY_OFF(MCE_DISPLAY_OFF_STRING);
static const QString MCE_DISPLAY_DIM(MCE_DISPLAY_DIM_STRING);
static const QString MCE_DISPLAY_ON(MCE_DISPLAY_ON_STRING);
QMceDisplay::State state;
if (aStatus == MCE_DISPLAY_OFF) {
state = DisplayOff;
} else if (aStatus == MCE_DISPLAY_DIM) {
state = DisplayDim;
} else {
state = DisplayOn;
}
if (iState != state) {
iState = state;
Q_EMIT iParent->stateChanged();
}
}
void QMceDisplay::Private::onQueryFinished(QDBusPendingCallWatcher* aWatcher)
{
QDBusPendingReply<QString> reply(*aWatcher);
if (!reply.isError()) {
updateDisplayStatus(reply.value());
if (!iValid) {
iValid = true;
Q_EMIT iParent->validChanged();
}
}
aWatcher->deleteLater();
}
void QMceDisplay::Private::onProxyValidChanged()
{
if (iProxy->valid()) {
queryDisplayStatus();
} else {
if (iValid) {
iValid = false;
Q_EMIT iParent->validChanged();
}
}
}
// ==========================================================================
// QMceDisplay
// ==========================================================================
QMceDisplay::QMceDisplay(QObject* aParent) :
QObject(aParent),
iPrivate(new Private(this))
{
}
bool QMceDisplay::valid() const
{
return iPrivate->iValid;
}
QMceDisplay::State QMceDisplay::state() const
{
return iPrivate->iState;
}
#include "qmcedisplay.moc"
/*
* Copyright (C) 2016 Jolla Ltd.
* Contact: Slava Monich <slava.monich@jolla.com>
*
* You may use this file under the terms of BSD license as follows:
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of Jolla Ltd nor the names of its contributors may
* be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
* THE POSSIBILITY OF SUCH DAMAGE.
*
* The views and conclusions contained in the software and documentation
* are those of the authors and should not be interpreted as representing
* any official policies, either expressed or implied.
*/
#include "qmceproxy.h"
#include "mce/dbus-names.h"
class QMceProxy::Private : public QObject {
Q_OBJECT
public:
Private(QMceProxy* aParent);
QMceRequestProxy* requestProxy();
QMceSignalProxy* signalProxy();
private Q_SLOTS:
void onServiceRegistered();
void onServiceUnregistered();
public:
QMceProxy* iParent;
bool iValid;
private:
QDBusConnection iBus;
QString iService;
QMceRequestProxy* iRequestProxy;
QMceSignalProxy* iSignalProxy;
};
QMceProxy::Private::Private(QMceProxy* aParent) :
QObject(aParent),
iParent(aParent),
iBus(QDBusConnection::systemBus()),
iService(MCE_SERVICE),
iRequestProxy(NULL),
iSignalProxy(NULL)
{
iValid = iBus.interface()->isServiceRegistered(iService);
QDBusServiceWatcher* watcher = new QDBusServiceWatcher(iService, iBus,
QDBusServiceWatcher::WatchForRegistration |
QDBusServiceWatcher::WatchForUnregistration, this);
connect(watcher,
SIGNAL(serviceRegistered(QString)),
SLOT(onServiceRegistered()));
connect(watcher,
SIGNAL(serviceUnregistered(QString)),
SLOT(onServiceUnregistered()));
}
QMceRequestProxy* QMceProxy::Private::requestProxy()
{
if (!iRequestProxy) {
iRequestProxy = new QMceRequestProxy(iService,
MCE_REQUEST_PATH, iBus, this);
}
return iRequestProxy;
}
QMceSignalProxy* QMceProxy::Private::signalProxy()
{
if (!iSignalProxy) {
iSignalProxy = new QMceSignalProxy(iService,
MCE_SIGNAL_PATH, iBus, this);
}
return iSignalProxy;
}
void QMceProxy::Private::onServiceRegistered()
{
if (!iValid) {
iValid = true;
Q_EMIT iParent->validChanged();
}
}
void QMceProxy::Private::onServiceUnregistered()
{
if (iValid) {
iValid = false;
Q_EMIT iParent->validChanged();
}
}
// ==========================================================================
// QMceProxy
// ==========================================================================
QMceProxy::QMceProxy() :
iPrivate(new Private(this))
{
}
bool QMceProxy::valid() const
{
return iPrivate->iValid;
}
QMceRequestProxy* QMceProxy::requestProxy()
{
return iPrivate->requestProxy();
}
QMceSignalProxy* QMceProxy::signalProxy()
{
return iPrivate->signalProxy();
}
QSharedPointer<QMceProxy> QMceProxy::instance()
{
static QWeakPointer<QMceProxy> sSharedInstance;
QSharedPointer<QMceProxy> ref = sSharedInstance;
if (ref.isNull()) {
ref = QSharedPointer<QMceProxy>(new QMceProxy, &QObject::deleteLater);
sSharedInstance = ref;
}
return ref;
}
#include "qmceproxy.moc"
/*
* Copyright (C) 2016 Jolla Ltd.
* Contact: Slava Monich <slava.monich@jolla.com>
*
* You may use this file under the terms of BSD license as follows:
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of Jolla Ltd nor the names of its contributors may
* be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
* THE POSSIBILITY OF SUCH DAMAGE.
*
* The views and conclusions contained in the software and documentation
* are those of the authors and should not be interpreted as representing
* any official policies, either expressed or implied.
*/
#ifndef QMCE_PROXY_H
#define QMCE_PROXY_H
#include "qmcetypes.h"
// Generated headers
#include "request_interface.h"
#include "signal_interface.h"
class QMceProxy : public QObject
{
Q_OBJECT
QMceProxy();
public:
static QSharedPointer<QMceProxy> instance();
bool valid() const;
QMceRequestProxy* requestProxy();
QMceSignalProxy* signalProxy();
Q_SIGNALS:
void validChanged();
private:
class Private;
Private* iPrivate;
};
#endif // QMCE_PROXY_H
/*
* Copyright (C) 2016 Jolla Ltd.
* Contact: Slava Monich <slava.monich@jolla.com>
*
* You may use this file under the terms of BSD license as follows:
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of Jolla Ltd nor the names of its contributors may
* be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
* THE POSSIBILITY OF SUCH DAMAGE.
*
* The views and conclusions contained in the software and documentation
* are those of the authors and should not be interpreted as representing
* any official policies, either expressed or implied.
*/
#include "qmcetklock.h"
#include "qmceproxy.h"
#include "mce/mode-names.h"
class QMceTkLock::Private : public QObject {
Q_OBJECT
public:
Private(QMceTkLock* aParent);
void queryMode();
private Q_SLOTS:
void onProxyValidChanged();
void onQueryFinished(QDBusPendingCallWatcher* aWatcher);
void updateMode(QString aStatus);
public:
QMceTkLock* iParent;
QSharedPointer<QMceProxy> iProxy;
bool iValid;
bool iLocked;
Mode iMode;
};
QMceTkLock::Private::Private(QMceTkLock* aParent) :
QObject(aParent),
iParent(aParent),
iProxy(QMceProxy::instance()),
iValid(false),
iLocked(true),
iMode(Locked)
{
connect(iProxy->signalProxy(),
SIGNAL(tklock_mode_ind(QString)),
SLOT(updateMode(QString)));
connect(iProxy.data(),