2 Situare - A location system for Facebook
3 Copyright (C) 2010 Ixonos Plc. Authors:
5 Jussi Laitinen - jussi.laitinen@ixonos.com
7 Situare is free software; you can redistribute it and/or
8 modify it under the terms of the GNU General Public License
9 version 2 as published by the Free Software Foundation.
11 Situare is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with Situare; if not, write to the Free Software
18 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
26 #include <mce/dbus-names.h>
27 #include <mce/mode-names.h>
30 #include "mceprivate.h"
32 const int DISPLAY_STATE_INDEX = 0;
34 static QDBusConnection dBusConnection = QDBusConnection::systemBus();
36 MCEPrivate::MCEPrivate(QObject *parent)
40 qDebug() << __PRETTY_FUNCTION__;
42 m_parent = static_cast<MCE*>(parent);
44 m_dBusInterface = new QDBusInterface(MCE_SERVICE, MCE_REQUEST_PATH,
45 MCE_REQUEST_IF, dBusConnection, this);
47 dBusConnection.connect(MCE_SERVICE, MCE_SIGNAL_PATH, MCE_SIGNAL_IF,
48 MCE_DISPLAY_SIG, this, SLOT(displayStateChanged(const QDBusMessage &)));
50 m_dBusInterface->callWithCallback(MCE_DISPLAY_STATUS_GET, QList<QVariant>(), this,
51 SLOT(setDisplayState(QString)),
52 SLOT(displayStateError(QDBusError)));
55 void MCEPrivate::displayStateChanged(const QDBusMessage &message)
57 qDebug() << __PRETTY_FUNCTION__;
59 QString state = message.arguments().at(DISPLAY_STATE_INDEX).toString();
60 setDisplayState(state);
63 void MCEPrivate::displayStateError(const QDBusError &error)
65 qDebug() << __PRETTY_FUNCTION__;
70 bool MCEPrivate::isDisplayOn()
72 qDebug() << __PRETTY_FUNCTION__;
77 void MCEPrivate::setDisplayState(const QString &state)
79 qDebug() << __PRETTY_FUNCTION__;
81 if (!state.isEmpty()) {
82 if (state == MCE_DISPLAY_ON_STRING) {
84 emit m_parent->displayStateChanged(true);
86 else if (state == MCE_DISPLAY_OFF_STRING) {
88 emit m_parent->displayStateChanged(false);