Added GPSPositionInterface and GPSPositionMockup classes.
authorJussi Laitinen <jupe@l3l7588.ixonos.local>
Wed, 12 May 2010 06:38:07 +0000 (09:38 +0300)
committerJussi Laitinen <jupe@l3l7588.ixonos.local>
Wed, 12 May 2010 06:38:07 +0000 (09:38 +0300)
src/engine/engine.cpp
src/engine/engine.h
src/gps/gpsposition.cpp
src/gps/gpsposition.h
src/gps/gpspositioninterface.cpp [new file with mode: 0644]
src/gps/gpspositioninterface.h [new file with mode: 0644]
src/gps/gpspositionmockup.cpp [new file with mode: 0644]
src/gps/gpspositionmockup.h [new file with mode: 0644]
src/map/mapengine.cpp
src/src.pro
src/ui/mainwindow.cpp

index 5a5fe38..1a6d116 100644 (file)
 
 #include "engine.h"
 #include "ui/mainwindow.h"
+#include "gps/gpspositioninterface.h"
+
+#ifdef Q_WS_MAEMO_5
 #include "gps/gpsposition.h"
+#else
+#include "gps/gpspositionmockup.h"
+#endif
 
 SituareEngine::SituareEngine(QMainWindow *parent)
     : QObject(parent)
@@ -35,7 +41,11 @@ SituareEngine::SituareEngine(QMainWindow *parent)
 
     m_facebookAuthenticator = new FacebookAuthentication();
 
+#ifdef Q_WS_MAEMO_5
     m_gps = new GPSPosition(this);
+#else
+    m_gps = new GPSPositionMockup(this);
+#endif
 
     connect(m_facebookAuthenticator, SIGNAL(credentialsReady(FacebookCredentials)),
             m_situareService, SLOT(credentialsReady(FacebookCredentials)));
index fe30675..edb3b27 100644 (file)
@@ -31,7 +31,7 @@
 #include "situareservice/situareservice.h"
 #include "ui/mainwindow.h"
 
-class GPSPosition;
+class GPSPositionInterface;
 
 /**
 * @brief Engine class for Situare Application
@@ -146,7 +146,7 @@ signals:
  ******************************************************************************/
 private:
     FacebookAuthentication *m_facebookAuthenticator; ///< Instance for facebook authenticator
-    GPSPosition *m_gps;   ///< Instance of the gps position
+    GPSPositionInterface *m_gps;   ///< Instance of the gps position
     MainWindow *m_ui; ///< Instance of the MainWindow UI
     SituareService *m_situareService; ///< Instance of the situare server communication service
 };
index f650101..6f43d9b 100644 (file)
 #include <QDebug>
 
 #include "gpsposition.h"
+#include "gpspositioninterface.h"
 
 GPSPosition::GPSPosition(QObject *parent)
-    : QObject(parent),
+    : GPSPositionInterface(parent),
       m_running(false),
       m_updateInterval(DEFAULT_UPDATE_INTERVAL)
 {
index d433fa7..5c38c2a 100644 (file)
@@ -25,6 +25,8 @@
 #include <QGeoPositionInfoSource>
 #include <QPointF>
 
+#include "gpspositioninterface.h"
+
 QTM_USE_NAMESPACE
 
 /**
@@ -32,7 +34,7 @@ QTM_USE_NAMESPACE
 *
 * @class GPSPosition engine.h "gps/gpsposition.h"
 */
-class GPSPosition : public QObject
+class GPSPosition : public GPSPositionInterface
 {
     Q_OBJECT
 
@@ -98,29 +100,6 @@ private slots:
     */
     void updateTimeout();
 
-/******************************************************************************
-* SIGNALS
-******************************************************************************/
-signals:
-    /**
-    * @brief Signal for position information.
-    *
-    * @param latLonCoordinate latitude and longitude values
-    */
-    void position(QPointF latLonCoordinate);
-
-    /**
-    * @brief Signal for timeout.
-    */
-    void timeout();
-
-    /**
-    * @brief Signal for error.
-    *
-    * @param message error message
-    */
-    void error(const QString &message);
-
 private:
     QGeoPositionInfoSource *m_gpsSource;        ///< GPS position info source
     bool m_running;                             ///< GPS is running
diff --git a/src/gps/gpspositioninterface.cpp b/src/gps/gpspositioninterface.cpp
new file mode 100644 (file)
index 0000000..fbd8c0c
--- /dev/null
@@ -0,0 +1,31 @@
+/*
+   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 "gpspositioninterface.h"
+
+GPSPositionInterface::GPSPositionInterface(QObject *parent)
+    : QObject(parent)
+{
+}
+
+GPSPositionInterface::~GPSPositionInterface()
+{
+}
diff --git a/src/gps/gpspositioninterface.h b/src/gps/gpspositioninterface.h
new file mode 100644 (file)
index 0000000..99b1a2a
--- /dev/null
@@ -0,0 +1,92 @@
+/*
+   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 GPSPOSITIONINTERFACE_H
+#define GPSPOSITIONINTERFACE_H
+
+#include <QObject>
+#include <QPointF>
+
+class GPSPositionInterface : public QObject
+{
+    Q_OBJECT
+
+public:
+
+    GPSPositionInterface(QObject *parent = 0);
+
+    virtual ~GPSPositionInterface();
+
+    /**
+    * @brief Checks if GPS is running.
+    *
+    * @return true if GPS running, false otherwise
+    */
+    virtual bool isRunning() = 0;
+
+    /**
+    * @brief Set GPS update interval
+    *
+    * @return interval interval in milliseconds
+    */
+    virtual void setUpdateInterval(int interval) = 0;
+
+    /**
+    * @brief Start GPS.
+    */
+    virtual void start() = 0;
+
+    /**
+    * @brief Stop GPS.
+    */
+    virtual void stop() = 0;
+
+private slots:
+    /**
+    * @brief Slot for GPS update request.
+    */
+    virtual void update() = 0;
+
+/******************************************************************************
+* SIGNALS
+******************************************************************************/
+signals:
+    /**
+    * @brief Signal for position information.
+    *
+    * @param latLonCoordinate latitude and longitude values
+    */
+    void position(QPointF latLonCoordinate);
+
+    /**
+    * @brief Signal for timeout.
+    */
+    void timeout();
+
+    /**
+    * @brief Signal for error.
+    *
+    * @param message error message
+    */
+    void error(const QString &message);
+};
+
+#endif // GPSPOSITIONINTERFACE_H
diff --git a/src/gps/gpspositionmockup.cpp b/src/gps/gpspositionmockup.cpp
new file mode 100644 (file)
index 0000000..127ec77
--- /dev/null
@@ -0,0 +1,62 @@
+/*
+   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 "gpspositionmockup.h"
+
+GPSPositionMockup::GPSPositionMockup(QObject *parent)
+    : GPSPositionInterface(parent)
+{
+}
+
+GPSPositionMockup::~GPSPositionMockup()
+{
+}
+
+bool GPSPositionMockup::isRunning()
+{
+    qDebug() << __PRETTY_FUNCTION__;
+
+    return false;
+}
+
+void GPSPositionMockup::setUpdateInterval(int interval)
+{
+    qDebug() << __PRETTY_FUNCTION__;
+
+    Q_UNUSED(interval);
+}
+
+void GPSPositionMockup::start()
+{
+    qDebug() << __PRETTY_FUNCTION__;
+}
+
+void GPSPositionMockup::stop()
+{
+    qDebug() << __PRETTY_FUNCTION__;
+}
+
+void GPSPositionMockup::update()
+{
+    qDebug() << __PRETTY_FUNCTION__;
+}
diff --git a/src/gps/gpspositionmockup.h b/src/gps/gpspositionmockup.h
new file mode 100644 (file)
index 0000000..e3722c6
--- /dev/null
@@ -0,0 +1,76 @@
+/*
+   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 GPSPOSITIONMOCKUP_H
+#define GPSPOSITIONMOCKUP_H
+
+#include "gpspositioninterface.h"
+
+class GPSPositionMockup : public GPSPositionInterface
+{
+    Q_OBJECT
+
+public:
+    /**
+    * @brief Constructor creates GPS source.
+    *
+    * @param parent QObject
+    */
+    GPSPositionMockup(QObject *parent = 0);
+
+    /**
+    * @brief Destructor stops GPS.
+    */
+    ~GPSPositionMockup();
+
+/******************************************************************************
+* MEMBER FUNCTIONS AND SLOTS
+******************************************************************************/
+public:
+    /**
+    * @brief Checks if GPS is running.
+    *
+    * @return true if GPS running, false otherwise
+    */
+    bool isRunning();
+
+    /**
+    * @brief Set GPS update interval
+    *
+    * @return interval interval in milliseconds
+    */
+    void setUpdateInterval(int interval);
+
+    /**
+    * @brief Start GPS.
+    */
+    void start();
+
+    /**
+    * @brief Stop GPS.
+    */
+    void stop();
+
+private slots:
+    void update();
+};
+
+#endif // GPSPOSITIONMOCKUP_H
index 40210b4..8cd40d2 100644 (file)
@@ -35,8 +35,6 @@
 #include "mapengine.h"
 #include "maptile.h"
 
-#include "gps/gpsposition.h"
-
 MapEngine::MapEngine(QObject *parent)
     : QObject(parent)
     , m_centerTile(QPoint(UNDEFINED, UNDEFINED))
index 0003224..91ba69d 100644 (file)
@@ -40,7 +40,7 @@ SOURCES += main.cpp \
     ui/panelsliderbar.cpp \
     map/friendgroupitem.cpp \
     map/frienditemshandler.cpp \
-       gps/gpsposition.cpp
+    gps/gpspositioninterface.cpp
 HEADERS += ui/mainwindow.h \
     ui/mapviewscreen.h \
     map/mapengine.h \
@@ -78,29 +78,35 @@ HEADERS += ui/mainwindow.h \
     ui/panelsliderbar.h \
     map/friendgroupitem.h \
     map/frienditemshandler.h \
-        gps/gpsposition.h
+    gps/gpspositioninterface.h
 QT += network \
     webkit
 
-CONFIG += mobility
-
-MOBILITY = location
-
 DEFINES += QT_NO_DEBUG_OUTPUT
 
 !maemo5 {
+    SOURCES += gps/gpspositionmockup.cpp
+    HEADERS += gps/gpspositionmockup.h
     message(QJson built in)
     message(Make sure you have QJson development headers installed)
     message(install headers with: sudo apt-get install libqjson-dev)
+
 }
 maemo5 {
+    SOURCES += gps/gpsposition.cpp
+    HEADERS += gps/gpsposition.h
     QT += maemo5
+    CONFIG += mobility
+    MOBILITY = location
     message(QJson built in)
     message(Make sure you have QJson development headers installed)
     message(add: deb http://repository.maemo.org/extras-devel fremantle free non-free)
     message(to scratchbox's sources.list in /etc/apt)
     message(run: apt-get update)
     message(install headers with: apt-get install libqjson-dev)
+    message(QtMobility)
+    message(Make sure you have QtMobility development headers installed)
+    message(install headers with: apt-get install libqtm-dev)
 }
 
 # -----------------------------------------------------------------
index 30595be..a6274ea 100644 (file)
@@ -166,7 +166,8 @@ void MainWindow::showMaemoInformationBox(const QString &message)
     qDebug() << __PRETTY_FUNCTION__;
 
 #ifdef Q_WS_MAEMO_5
-        QMaemo5InformationBox::information(this, message,
-                                           QMaemo5InformationBox::DefaultTimeout);
-#endif // Q_WS_MAEMO_5
+    QMaemo5InformationBox::information(this, message, QMaemo5InformationBox::DefaultTimeout);
+#else
+    Q_UNUSED(message);
+#endif
 }