: QObject(parent),
m_autoCenteringEnabled(false),
m_automaticUpdateFirstStart(true),
+ m_automaticUpdateRequest(false),
m_userMoved(false),
m_automaticUpdateIntervalTimer(0),
m_lastUpdatedGPSPosition(QPointF())
{
qDebug() << __PRETTY_FUNCTION__;
- if (m_gps->isRunning() && m_userMoved) {
- requestUpdateLocation();
- m_userMoved = false;
- }
-
- if (!m_mce->isDisplayOn())
- m_gps->requestUpdate();
+ m_gps->requestUpdate();
+ m_automaticUpdateRequest = true;
}
void SituareEngine::changeAutoCenteringSetting(bool enabled)
qDebug() << __PRETTY_FUNCTION__;
m_gps->enablePowerSave(!on);
+
+ if (m_autoCenteringEnabled)
+ enableAutoCentering(on);
}
void SituareEngine::enableAutoCentering(bool enabled)
{
- qWarning() << __PRETTY_FUNCTION__ << enabled;
+ qDebug() << __PRETTY_FUNCTION__;
m_ui->setAutoCenteringButtonEnabled(enabled);
m_mapEngine->setAutoCentering(enabled);
else
m_automaticUpdateIntervalTimer->setInterval(updateIntervalMsecs);
+ connect(m_gps, SIGNAL(position(QPointF,qreal)),
+ this, SLOT(saveGPSPosition(QPointF)));
+
m_automaticUpdateIntervalTimer->start();
} else {
+ disconnect(m_gps, SIGNAL(position(QPointF,qreal)),
+ this, SLOT(saveGPSPosition(QPointF)));
+
m_automaticUpdateIntervalTimer->stop();
}
}
}
}
-bool SituareEngine::isUserMoved()
-{
- qDebug() << __PRETTY_FUNCTION__;
-
- return m_userMoved;
-}
-
void SituareEngine::loginActionPressed()
{
qDebug() << __PRETTY_FUNCTION__;
m_userMoved = true;
}
- if (!m_mce->isDisplayOn()) {
- m_gps->stop();
+ if (m_automaticUpdateRequest && m_userMoved) {
+ requestUpdateLocation(tr("Automatic location update"));
+ m_automaticUpdateRequest = false;
+ m_userMoved = false;
}
}
connect(m_gps, SIGNAL(error(int)),
this, SLOT(error(int)));
-
- connect(m_gps, SIGNAL(position(QPointF,qreal)),
- this, SLOT(saveGPSPosition(QPointF)));
}
void SituareEngine::signalsFromMainWindow()
private:
/**
- * @brief Checks if user is moved enough for position auto update.
- *
- * @return true if moved engouh, false otherwise
- */
- bool isUserMoved();
-
- /**
* @brief Read settings and determine whether to use GPS and autocentering.
* When values does not found on the settings, GPS and autocentering are enabled as a default.
*/
private:
bool m_autoCenteringEnabled; ///< Auto centering flag
bool m_automaticUpdateFirstStart; ///< Automatic location update first start flag
- bool m_userMoved; ///< Flag for user moving
+ bool m_automaticUpdateRequest; ///< Flag for automatic update request
+ bool m_userMoved; ///< Flag for user move
FacebookAuthentication *m_facebookAuthenticator; ///< Instance for facebook authenticator
#include "gpspositionprivateliblocation.h"
#include "liblocationwrapper.h"
+const int POWER_SAVE_START_DELAY_MS = 1000*10;
+
GPSPositionPrivate::GPSPositionPrivate(QObject *parent)
: QObject(parent),
m_liblocationWrapper(0),
qDebug() << __PRETTY_FUNCTION__;
m_parent = static_cast<GPSPosition*>(parent);
+
+ m_delayedPowerSaveTimer = new QTimer(this);
+ m_delayedPowerSaveTimer->setInterval(POWER_SAVE_START_DELAY_MS);
+ connect(m_delayedPowerSaveTimer, SIGNAL(timeout()),
+ this, SLOT(delayedPowerSaveStart()));
+}
+
+void GPSPositionPrivate::delayedPowerSaveStart()
+{
+ qDebug() << __PRETTY_FUNCTION__;
+
+ m_powerSave = true;
+ m_delayedPowerSaveTimer->stop();
+ m_liblocationWrapper->stopUpdates();
}
void GPSPositionPrivate::enablePowerSave(bool enabled)
qDebug() << __PRETTY_FUNCTION__;
if (isRunning()) {
- m_powerSave = enabled;
- if (enabled)
- m_liblocationWrapper->stopUpdates();
- else
+ if (enabled) {
+ m_delayedPowerSaveTimer->start();
+ } else {
+ m_powerSave = false;
+ m_delayedPowerSaveTimer->stop();
m_liblocationWrapper->startUpdates();
+ }
}
else {
m_powerSave = false;
{
qDebug() << __PRETTY_FUNCTION__;
- if (m_powerSave)
+ if (m_powerSave) {
m_liblocationWrapper->startUpdates();
+ qWarning() << __PRETTY_FUNCTION__ << "liblocation:start()";
+ }
+ else {
+ requestLastPosition();
+ }
}
void GPSPositionPrivate::positionUpdated(const GeoPositionInfo &positionInfo)
accuracy(positionInfo));
}
- if (m_powerSave)
+ if (m_powerSave) {
m_liblocationWrapper->stopUpdates();
+ qWarning() << __PRETTY_FUNCTION__ << "liblocation:stop()";
+ }
}
void GPSPositionPrivate::locationError(const QString &errorMessage)
#include "gpsposition.h"
#include "geopositioninfo.h"
+class QTimer;
class LiblocationWrapper;
/**
qreal accuracy(const GeoPositionInfo &positionInfo);
private slots:
+ void delayedPowerSaveStart();
/**
* @brief Slot for received position update.
bool m_powerSave; ///< Power save flag
bool m_running; ///< GPS is running
int m_updateInterval; ///< GPS update interval
+ QTimer *m_delayedPowerSaveTimer; ///< Delayed power save timer
};
const int DEFAULT_UPDATE_INTERVAL = 5000; ///< Default update interval
LiblocationWrapper *wrapper;
wrapper = (LiblocationWrapper*)data;
- if (device) {
+ if (device && wrapper->isRunning()) {
if (device->fix) {
if (device->fix->fields & LOCATION_GPS_DEVICE_TIME_SET) {
+++ /dev/null
-/*
- 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();
-}
+++ /dev/null
-/*
- 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;
-
-class MCE : public QObject
-{
- Q_OBJECT
-
-public:
- friend class MCEPrivate;
-
- MCE(QObject *parent = 0);
-
-public:
- bool isDisplayOn();
-
-signals:
- void displayOn(bool on);
-
-private:
- MCEPrivate *m_mcePrivate;
-};
-
-#endif // MCE_H
+++ /dev/null
-/*
- 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 <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->call(MCE_DISPLAY_STATUS_GET);
-}
-
-bool MCEPrivate::isDisplayOn()
-{
- qDebug() << __PRETTY_FUNCTION__;
-
- return m_displayOn;
-}
-
-void MCEPrivate::displayStateChanged(const QDBusMessage &message)
-{
- qDebug() << __PRETTY_FUNCTION__;
-
- QString content = message.arguments().at(DISPLAY_STATE_INDEX).toString();
-
- if (!content.isEmpty()) {
- if (content == MCE_DISPLAY_ON_STRING) {
- m_displayOn = true;
- emit m_parent->displayOn(true);
- }
- else if (content == MCE_DISPLAY_OFF_STRING) {
- m_displayOn = false;
- emit m_parent->displayOn(false);
- }
- }
-}
+++ /dev/null
-/*
- 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;
-
-class MCEPrivate : public QObject
-{
- Q_OBJECT
-
-public:
- MCEPrivate(QObject *parent);
-
-public:
- bool isDisplayOn();
-
-private slots:
- void displayStateChanged(const QDBusMessage &message);
-
-private:
- QDBusInterface *m_dBusInterface; ///< D-Bus interface
- MCE *m_parent; ///< Parent object
- bool m_displayOn; ///< Flag for display on/off
-};
-
-#endif // MCEPRIVATE_H
ui/zoombuttonpanel.cpp \
user/user.cpp \
ui/fullscreenbutton.cpp \
- mce.cpp
+ engine/mce.cpp
HEADERS += common.h \
engine/engine.h \
facebookservice/facebookauthentication.h \
ui/zoombuttonpanel.h \
user/user.h \
ui/fullscreenbutton.h \
- mce.h
+ engine/mce.h
QT += network \
webkit
DEFINES += ARMEL
INCLUDEPATH += /usr/include/glib-2.0 /usr/lib/glib-2.0/include
SOURCES += network/networkhandlerprivate.cpp \
- mceprivate.cpp
+ engine/mceprivate.cpp
HEADERS += network/networkhandlerprivate.h \
- mceprivate.h
+ engine/mceprivate.h
QT += dbus
CONFIG += icd2 qdbus
SOURCES += gps/gpspositionprivateliblocation.cpp \
} else {
SOURCES += gps/gpspositionprivatestub.cpp \
network/networkhandlerprivatestub.cpp \
- mceprivatestub.cpp
+ engine/mceprivatestub.cpp
HEADERS += gps/gpspositionprivatestub.h \
network/networkhandlerprivatestub.h \
- mceprivatestub.h
+ engine/mceprivatestub.h
}
QT += maemo5