if (gpsEnabled.toBool() && autoCenteringEnabled.toBool())
m_ui->showMaemoInformationBox(tr("Auto centering enabled"));
+ //Request network connection.
- m_networkHandler->connect();
++// m_networkHandler->connect();
+ m_facebookAuthenticator->start();
}
SituareEngine::~SituareEngine()
connect(m_mapEngine, SIGNAL(minZoomLevelReached()),
m_ui, SIGNAL(minZoomLevelReached()));
+
+ connect(m_mapEngine, SIGNAL(locationItemClicked(QList<QString>)),
+ m_ui, SIGNAL(locationItemClicked(QList<QString>)));
}
+void SituareEngine::signalsFromNetworkHandler()
+{
+ qDebug() << __PRETTY_FUNCTION__;
+
+ connect(m_networkHandler, SIGNAL(connected()),
+ this, SLOT(connectedToNetwork()));
+
+ connect(m_networkHandler, SIGNAL(disconnected()),
+ this, SLOT(disconnectedFromNetwork()));
+}
+
void SituareEngine::signalsFromSituareService()
{
qDebug() << __PRETTY_FUNCTION__;
--- /dev/null
--- /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 <QNetworkRequest>
++
++#include "networkhandler.h"
++#include "networkaccessmanager.h"
++
++NetworkAccessManager::NetworkAccessManager(QObject *parent)
++ : QNetworkAccessManager(parent),
++ m_networkHandler(0)
++{
++ m_networkHandler = new NetworkHandler(this);
++
++ connect(m_networkHandler, SIGNAL(connected()),
++ this, SLOT(connected()));
++}
++
++QNetworkReply *NetworkAccessManager::getti(const QNetworkRequest &request)
++{
++ if (!m_networkHandler->isConnected()) {
++ m_requestQueue.append(request);
++ m_networkHandler->connect();
++ }
++
++ return createRequest(QNetworkAccessManager::GetOperation, request);
++}
++
++void NetworkAccessManager::connected()
++{
++ foreach (QNetworkRequest request, m_requestQueue)
++ get(request);
++
++ m_requestQueue.clear();
++}
--- /dev/null
--- /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 NETWORKACCESSMANAGER_H
++#define NETWORKACCESSMANAGER_H
++
++#include <QNetworkAccessManager>
++#include <QList>
++#include <QNetworkReply>
++#include <QNetworkRequest>
++
++class NetworkHandler;
++
++class NetworkAccessManager : public QNetworkAccessManager
++{
++ Q_OBJECT
++
++public:
++ NetworkAccessManager(QObject *parent = 0);
++
++ QNetworkReply *getti(const QNetworkRequest &request);
++
++private slots:
++ void connected();
++
++private:
++ NetworkHandler *m_networkHandler;
++ QList<QNetworkRequest> m_requestQueue;
++};
++
++#endif // NETWORKACCESSMANAGER_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 <icd/dbus_api.h>
+
+#include "networkhandler.h"
+
+static QDBusConnection dBusConnection = QDBusConnection::systemBus();
+const int CONNECTION_STATE_INDEX = 7;
+enum ConnectionState {DISCONNECTED, CONNECTING, CONNECTED, DISCONNECTING};
+
+NetworkHandler::NetworkHandler(QObject *parent)
- : QObject(parent)
++ : QObject(parent),
++ m_connected(false)
+{
+ dBusInterface = new QDBusInterface(ICD_DBUS_API_INTERFACE, ICD_DBUS_API_PATH,
+ ICD_DBUS_API_INTERFACE, dBusConnection);
+
+ dBusConnection.connect(ICD_DBUS_API_INTERFACE, ICD_DBUS_API_PATH, ICD_DBUS_API_INTERFACE,
+ ICD_DBUS_API_STATE_SIG,
+ this, SLOT(stateChanged(const QDBusMessage &)));
+}
+
+void NetworkHandler::stateChanged(const QDBusMessage &message)
+{
+ qDebug() << __PRETTY_FUNCTION__;
+
+ if (message.arguments().count() >= 8) {
+
+ bool conversionOk;
+ int connectionState = message.arguments().at(CONNECTION_STATE_INDEX).toInt(&conversionOk);
+
+ if (conversionOk) {
- if (connectionState == DISCONNECTED)
++ if (connectionState == DISCONNECTED) {
++ m_connected = false;
+ emit disconnected();
- else if (connectionState == CONNECTED)
++ }
++ else if (connectionState == CONNECTED) {
++ m_connected = true;
+ emit connected();
++ }
+ }
+ }
+}
+
+void NetworkHandler::connect()
+{
+ qDebug() << __PRETTY_FUNCTION__;
+
+ dBusInterface->call(ICD_DBUS_API_CONNECT_REQ,
+ QVariant((unsigned int)ICD_CONNECTION_FLAG_USER_EVENT));
+}
+
+void NetworkHandler::disconnect()
+{
+ qDebug() << __PRETTY_FUNCTION__;
+
+ dBusInterface->call(ICD_DBUS_API_DISCONNECT_REQ,
+ QVariant((unsigned int)ICD_CONNECTION_FLAG_USER_EVENT));
+}
++
++bool NetworkHandler::isConnected()
++{
++ return m_connected;
++}
--- /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 NETWORKHANDLER_H
+#define NETWORKHANDLER_H
+
+#include <QtDBus>
+
+/**
+* @brief NetworkHandler class.
+*
+* This class handles network connection. Class notifies about
+* network connection states.
+*/
+class NetworkHandler : public QObject
+{
+ Q_OBJECT
+
+public:
+ /**
+ * @brief Constructor.
+ *
+ * Creates ICD D-Bus interface.
+ */
+ NetworkHandler(QObject *parent = 0);
+
+/*******************************************************************************
+ * MEMBER FUNCTIONS AND SLOTS
+ ******************************************************************************/
+public:
+ /**
+ * @brief Requests network connection.
+ *
+ * Request is done via ICD D-Bus.
+ */
+ void connect();
+
+ /**
+ * @brief Requests to disconnect a connection.
+ *
+ * Request is done via ICD D-Bus.
+ */
+ void disconnect();
+
++ /**
++ * @brief Checks if connected to network.
++ *
++ * @return true if connected, false otherwise
++ */
++ bool isConnected();
++
+private slots:
+ /**
+ * @brief Slot for ICD D-Bus state change.
+ *
+ * @param message received D-Bus message
+ */
+ void stateChanged(const QDBusMessage &message);
+
+/*******************************************************************************
+ * SIGNALS
+ ******************************************************************************/
+signals:
+ /**
+ * @brief Signals when connected to network.
+ */
+ void connected();
+
+ /**
+ * @brief Signals when disconnected from network.
+ */
+ void disconnected();
+
+/*******************************************************************************
+ * DATA MEMBERS
+ ******************************************************************************/
+private:
+ QDBusInterface *dBusInterface; ///< D-Bus interface
++ bool m_connected; ///< Connection state variable
+};
+
+#endif // NETWORKHANDLER_H
map/gpslocationitem.cpp \
ui/zoombuttonpanel.cpp \
ui/userinfo.cpp \
- engine/networkhandler.cpp
- ui/sidepanel.cpp
++ engine/networkhandler.cpp \
++ ui/sidepanel.cpp \
++ engine/networkaccessmanager.cpp
HEADERS += ui/mainwindow.h \
map/mapengine.h \
map/mapview.h \
ui/zoombuttonpanel.h \
common.h \
ui/userinfo.h \
- engine/networkhandler.h
- ui/sidepanel.h
++ engine/networkhandler.h \
++ ui/sidepanel.h \
++ engine/networkaccessmanager.h
QT += network \
webkit