Added missing mce files to src/engine.
authorJussi Laitinen <jupe@l3l7588.ixonos.local>
Tue, 22 Jun 2010 12:50:59 +0000 (15:50 +0300)
committerJussi Laitinen <jupe@l3l7588.ixonos.local>
Tue, 22 Jun 2010 12:50:59 +0000 (15:50 +0300)
src/engine/mce.cpp [new file with mode: 0644]
src/engine/mce.h [new file with mode: 0644]
src/engine/mceprivate.cpp [new file with mode: 0644]
src/engine/mceprivate.h [new file with mode: 0644]
src/engine/mceprivatestub.cpp [new file with mode: 0644]
src/engine/mceprivatestub.h [new file with mode: 0644]

diff --git a/src/engine/mce.cpp b/src/engine/mce.cpp
new file mode 100644 (file)
index 0000000..54b39eb
--- /dev/null
@@ -0,0 +1,45 @@
+/*
+   Situare - A location system for Facebook
+   Copyright (C) 2010  Ixonos Plc. Authors:
+
+       Jussi Laitinen - jussi.laitinen@ixonos.com
+
+   Situare is free software; you can redistribute it and/or
+   modify it under the terms of the GNU General Public License
+   version 2 as published by the Free Software Foundation.
+
+   Situare is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with Situare; if not, write to the Free Software
+   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301,
+   USA.
+*/
+
+#include <QDebug>
+
+#include "mce.h"
+
+#if defined(Q_WS_MAEMO_5) & defined(ARMEL)
+#include "mceprivate.h"
+#else
+#include "mceprivatestub.h"
+#endif
+
+MCE::MCE(QObject *parent)
+    : QObject(parent)
+{
+    qDebug() << __PRETTY_FUNCTION__;
+
+    m_mcePrivate = new MCEPrivate(this);
+}
+
+bool MCE::isDisplayOn()
+{
+    qDebug() << __PRETTY_FUNCTION__;
+
+    return m_mcePrivate->isDisplayOn();
+}
diff --git a/src/engine/mce.h b/src/engine/mce.h
new file mode 100644 (file)
index 0000000..637d5ff
--- /dev/null
@@ -0,0 +1,80 @@
+/*
+   Situare - A location system for Facebook
+   Copyright (C) 2010  Ixonos Plc. Authors:
+
+       Jussi Laitinen - jussi.laitinen@ixonos.com
+
+   Situare is free software; you can redistribute it and/or
+   modify it under the terms of the GNU General Public License
+   version 2 as published by the Free Software Foundation.
+
+   Situare is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with Situare; if not, write to the Free Software
+   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301,
+   USA.
+*/
+
+#ifndef MCE_H
+#define MCE_H
+
+#include <QObject>
+
+class MCEPrivate;
+
+/**
+* @brief MCE class.
+*
+* Mode Control Entity (MCE) listens changes in phone state.
+*/
+class MCE : public QObject
+{
+    Q_OBJECT
+
+public:
+    /**
+    * @brief Friend class for MCEPrivate.
+    */
+    friend class MCEPrivate;
+
+    /**
+    * @brief Constructor.
+    *
+    * @param parent QObject
+    */
+    MCE(QObject *parent = 0);
+
+/*******************************************************************************
+ * MEMBER FUNCTIONS AND SLOTS
+ ******************************************************************************/
+public:
+    /**
+    * @brief Is the display on.
+    *
+    * @return true if on, false if off.
+    */
+    bool isDisplayOn();
+
+/*******************************************************************************
+ * SIGNALS
+ ******************************************************************************/
+signals:
+    /**
+    * @brief Signal for the display state change.
+    *
+    * @param on true if on, false if off
+    */
+    void displayStateChanged(bool on);
+
+/*******************************************************************************
+ * DATA MEMBERS
+ ******************************************************************************/
+private:
+    MCEPrivate *m_mcePrivate;   ///< Instance of MCEPrivate
+};
+
+#endif // MCE_H
diff --git a/src/engine/mceprivate.cpp b/src/engine/mceprivate.cpp
new file mode 100644 (file)
index 0000000..e1e026a
--- /dev/null
@@ -0,0 +1,91 @@
+/*
+   Situare - A location system for Facebook
+   Copyright (C) 2010  Ixonos Plc. Authors:
+
+       Jussi Laitinen - jussi.laitinen@ixonos.com
+
+   Situare is free software; you can redistribute it and/or
+   modify it under the terms of the GNU General Public License
+   version 2 as published by the Free Software Foundation.
+
+   Situare is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with Situare; if not, write to the Free Software
+   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301,
+   USA.
+*/
+
+#include <QString>
+#include <QDebug>
+#include <QTimer>
+
+#include <mce/dbus-names.h>
+#include <mce/mode-names.h>
+
+#include "mce.h"
+#include "mceprivate.h"
+
+const int DISPLAY_STATE_INDEX = 0;
+
+static QDBusConnection dBusConnection = QDBusConnection::systemBus();
+
+MCEPrivate::MCEPrivate(QObject *parent)
+    : QObject(parent),
+      m_displayOn(true)
+{
+    qDebug() << __PRETTY_FUNCTION__;
+
+    m_parent = static_cast<MCE*>(parent);
+
+    m_dBusInterface = new QDBusInterface(MCE_SERVICE, MCE_REQUEST_PATH,
+                                       MCE_REQUEST_IF, dBusConnection, this);
+
+    dBusConnection.connect(MCE_SERVICE, MCE_SIGNAL_PATH, MCE_SIGNAL_IF,
+                           MCE_DISPLAY_SIG, this, SLOT(displayStateChanged(const QDBusMessage &)));
+
+    m_dBusInterface->callWithCallback(MCE_DISPLAY_STATUS_GET, QList<QVariant>(), this,
+                                      SLOT(setDisplayState(QString)),
+                                      SLOT(displayStateError(QDBusError)));
+}
+
+void MCEPrivate::displayStateChanged(const QDBusMessage &message)
+{
+    qDebug() << __PRETTY_FUNCTION__;
+
+    QString state = message.arguments().at(DISPLAY_STATE_INDEX).toString();
+    setDisplayState(state);
+}
+
+void MCEPrivate::displayStateError(const QDBusError &error)
+{
+    qDebug() << __PRETTY_FUNCTION__;
+
+    Q_UNUSED(error);
+}
+
+bool MCEPrivate::isDisplayOn()
+{
+    qDebug() << __PRETTY_FUNCTION__;
+
+    return m_displayOn;
+}
+
+void MCEPrivate::setDisplayState(const QString &state)
+{
+    qDebug() << __PRETTY_FUNCTION__;
+
+    if (!state.isEmpty()) {
+        if (state == MCE_DISPLAY_ON_STRING) {
+            m_displayOn = true;
+            emit m_parent->displayStateChanged(true);
+        }
+        else if (state == MCE_DISPLAY_OFF_STRING) {
+            m_displayOn = false;
+            emit m_parent->displayStateChanged(false);
+        }
+    }
+}
diff --git a/src/engine/mceprivate.h b/src/engine/mceprivate.h
new file mode 100644 (file)
index 0000000..095ee5e
--- /dev/null
@@ -0,0 +1,89 @@
+/*
+   Situare - A location system for Facebook
+   Copyright (C) 2010  Ixonos Plc. Authors:
+
+       Jussi Laitinen - jussi.laitinen@ixonos.com
+
+   Situare is free software; you can redistribute it and/or
+   modify it under the terms of the GNU General Public License
+   version 2 as published by the Free Software Foundation.
+
+   Situare is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with Situare; if not, write to the Free Software
+   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301,
+   USA.
+*/
+
+#ifndef MCEPRIVATE_H
+#define MCEPRIVATE_H
+
+#include <QtDBus/QDBusInterface>
+#include <QtDBus/QDBusMessage>
+
+class MCE;
+
+/**
+* @brief MCEPrivate class.
+*
+* Mode Control Entity (MCE) listens changes in phone state.
+*/
+class MCEPrivate : public QObject
+{
+    Q_OBJECT
+
+public:
+    /**
+    * @brief Constructor.
+    *
+    * @param parent QObject
+    */
+    MCEPrivate(QObject *parent);
+
+/*******************************************************************************
+ * MEMBER FUNCTIONS AND SLOTS
+ ******************************************************************************/
+public:
+    /**
+    * @brief Is the display on.
+    *
+    * @return true if on, false if off.
+    */
+    bool isDisplayOn();
+
+private slots:
+    /**
+    * @brief Slot for display state changed.
+    *
+    * @return message QDBusMessage
+    */
+    void displayStateChanged(const QDBusMessage &message);
+
+    /**
+    * @brief Display state error.
+    *
+    * @param error QDBusError
+    */
+    void displayStateError(const QDBusError &error);
+
+    /**
+    * @brief Sets display state.
+    *
+    * @param state display state
+    */
+    void setDisplayState(const QString &state);
+
+/*******************************************************************************
+ * DATA MEMBERS
+ ******************************************************************************/
+private:
+    bool m_displayOn;                 ///< Flag for display on/off
+    QDBusInterface *m_dBusInterface;  ///< D-Bus interface
+    MCE *m_parent;                    ///< Parent object
+};
+
+#endif // MCEPRIVATE_H
diff --git a/src/engine/mceprivatestub.cpp b/src/engine/mceprivatestub.cpp
new file mode 100644 (file)
index 0000000..e6273db
--- /dev/null
@@ -0,0 +1,38 @@
+/*
+   Situare - A location system for Facebook
+   Copyright (C) 2010  Ixonos Plc. Authors:
+
+       Jussi Laitinen - jussi.laitinen@ixonos.com
+
+   Situare is free software; you can redistribute it and/or
+   modify it under the terms of the GNU General Public License
+   version 2 as published by the Free Software Foundation.
+
+   Situare is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with Situare; if not, write to the Free Software
+   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301,
+   USA.
+*/
+
+#include <QObject>
+#include <QDebug>
+
+#include "mceprivatestub.h"
+
+MCEPrivate::MCEPrivate(QObject *parent)
+    : QObject(parent)
+{
+    qDebug() << __PRETTY_FUNCTION__;
+}
+
+bool MCEPrivate::isDisplayOn()
+{
+    qDebug() << __PRETTY_FUNCTION__;
+
+    return true;
+}
diff --git a/src/engine/mceprivatestub.h b/src/engine/mceprivatestub.h
new file mode 100644 (file)
index 0000000..25e9b1c
--- /dev/null
@@ -0,0 +1,58 @@
+/*
+   Situare - A location system for Facebook
+   Copyright (C) 2010  Ixonos Plc. Authors:
+
+       Jussi Laitinen - jussi.laitinen@ixonos.com
+
+   Situare is free software; you can redistribute it and/or
+   modify it under the terms of the GNU General Public License
+   version 2 as published by the Free Software Foundation.
+
+   Situare is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with Situare; if not, write to the Free Software
+   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301,
+   USA.
+*/
+
+#ifndef MCEPRIVATESTUB_H
+#define MCEPRIVATESTUB_H
+
+#include <QObject>
+
+/**
+* @brief MCEPrivate class does nothing.
+*
+* Class is used when not compiling to Maemo.
+*/
+class MCEPrivate : public QObject
+{
+    Q_OBJECT
+
+public:
+    /**
+    * @brief Constructor.
+    *
+    * @param parent QObject
+    */
+    MCEPrivate(QObject *parent);
+
+/*******************************************************************************
+ * MEMBER FUNCTIONS AND SLOTS
+ ******************************************************************************/
+public:
+    /**
+    * @brief Is the display on.
+    *
+    * RETURNS TRUE.
+    *
+    * @return true if on, false if off.
+    */
+    bool isDisplayOn();
+};
+
+#endif // MCEPRIVATESTUB_H