Merge branch 'master' into network_handler
authorJussi Laitinen <jupe@l3l7588.ixonos.local>
Mon, 24 May 2010 11:03:32 +0000 (14:03 +0300)
committerJussi Laitinen <jupe@l3l7588.ixonos.local>
Mon, 24 May 2010 11:03:32 +0000 (14:03 +0300)
Conflicts:
src/src.pro

1  2 
src/engine/engine.cpp
src/engine/engine.h
src/engine/networkaccessmanager.cpp
src/engine/networkaccessmanager.h
src/engine/networkhandler.cpp
src/engine/networkhandler.h
src/src.pro

@@@ -99,8 -94,7 +99,9 @@@ SituareEngine::SituareEngine(QMainWindo
      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()
@@@ -339,19 -319,11 +340,22 @@@ void SituareEngine::signalsFromMapEngin
  
      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__;
Simple merge
index 0000000,0000000..5d8463e
new file mode 100644 (file)
--- /dev/null
--- /dev/null
@@@ -1,0 -1,0 +1,53 @@@
++/*
++   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();
++}
index 0000000,0000000..cf67745
new file mode 100644 (file)
--- /dev/null
--- /dev/null
@@@ -1,0 -1,0 +1,49 @@@
++/*
++   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
index bab737d,0000000..f28cc08
mode 100644,000000..100644
--- /dev/null
@@@ -1,73 -1,0 +1,83 @@@
 +/*
 +   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;
++}
index d70410d,0000000..5ef7aa8
mode 100644,000000..100644
--- /dev/null
@@@ -1,92 -1,0 +1,100 @@@
 +/*
 +   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
diff --cc src/src.pro
@@@ -42,7 -41,7 +42,9 @@@ SOURCES += main.cpp 
      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 \
@@@ -83,7 -82,7 +85,9 @@@
      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