Added engine to master
authorKaj Wallin <kaj.wallin@ixonos.com>
Thu, 29 Apr 2010 13:03:02 +0000 (16:03 +0300)
committerKaj Wallin <kaj.wallin@ixonos.com>
Thu, 29 Apr 2010 13:03:02 +0000 (16:03 +0300)
Reviewed by: Marko Niemelä

Merge branch 'engine'

Conflicts:
src/engine/engine.cpp

1  2 
src/engine/engine.cpp
src/engine/engine.h
src/situareservice/situareservice.cpp
src/situareservice/situareservice.h
src/ui/mainwindow.h

  SituareEngine::SituareEngine(QMainWindow *parent)
      : QObject(parent)
  {
++    qDebug() << __PRETTY_FUNCTION__;
      m_ui = new MainWindow;
  
--    m_networkManager = new QNetworkAccessManager;
--    m_situareService = new SituareService(this, m_networkManager);
++    m_situareService = new SituareService(this);
  
-     m_loggedIn = false;
      m_facebookAuthenticator = new FacebookAuthentication();
  
      connect(m_facebookAuthenticator, SIGNAL(credentialsReady(FacebookCredentials)),
              this, SLOT(loginOk()));
  
      connect(m_ui, SIGNAL(requestReverseGeo()), this, SLOT(requestAddress()));
--    connect(m_situareService, SIGNAL(reverseGeoReady(QString)), m_ui, SIGNAL(reverseGeoReady(QString)));
--    connect(m_ui, SIGNAL(statusUpdate(QString,bool)), this, SLOT(requestUpdateLocation(QString,bool)));
++    connect(m_situareService, SIGNAL(reverseGeoReady(QString)),
++            m_ui, SIGNAL(reverseGeoReady(QString)));
++    connect(m_ui, SIGNAL(statusUpdate(QString,bool)),
++            this, SLOT(requestUpdateLocation(QString,bool)));
  
-     start();
+     m_facebookAuthenticator->start();
  }
  
  SituareEngine::~SituareEngine()
@@@ -75,7 -67,7 +69,7 @@@ void SituareEngine::requestAddress(
      m_situareService->reverseGeo(coordinates);
  }
  
--void SituareEngine::requestUpdateLocation(const QString &status, const bool &publish)
++void SituareEngine::requestUpdateLocation(const QString &status, bool publish)
  {
      qDebug() << __PRETTY_FUNCTION__;
      QPointF coordinates(65, 25.5); // this will be get from somewhere, map etc...
@@@ -28,8 -28,8 +28,7 @@@
  #include <QtDebug>
  #include "facebookservice/facebookauthentication.h"
  #include "situareservice/situareservice.h"
--#include <QNetworkAccessManager>
--#include "../ui/mainwindow.h"
++#include "ui/mainwindow.h"
  
  /**
  * @brief Engine class for Situare Application
@@@ -84,33 -77,21 +76,20 @@@ public slots
      * @param status Status message
      * @param publish Publish on Facebook
      */
--    void requestUpdateLocation(const QString &status, const bool &publish);
-     void updateFriendsList();
- /*******************************************************************************
-  * SIGNALS
-  ******************************************************************************/
- signals:
-     /**
-     * @brief Signal that is emitted when UI must be showed
-     */
-     void engine_showMainWindow();
++    void requestUpdateLocation(const QString &status, bool publish);
  
      /**
-     * @brief Signal that is emitted when UI must be closed
+     * @brief Slot to initiate update friends list function
      */
-     void engine_closeMainWindow();
+     void updateFriendsList();
  
  /*******************************************************************************
   * DATA MEMBERS
   ******************************************************************************/
  private:
-     MainWindow *m_ui;
+     MainWindow *m_ui; ///< Instance of the MainWindow UI
      FacebookAuthentication *m_facebookAuthenticator; ///< Instance for facebook authenticator
--    QNetworkAccessManager *m_networkManager; ///< NetworkManager that is passed on to SituareService
      SituareService *m_situareService; ///< Instance of the situare server communication service
-     bool m_loggedIn; ///< Boolean value to indicate whether login has been successfull or not
  };
  
  #endif // ENGINE_H
  #include "../cookiehandler/cookiehandler.h"
  #include "parser.h"
  
--SituareService::SituareService(QObject *parent, QNetworkAccessManager *manager)
--        : QObject(parent), m_networkManager(manager)
++SituareService::SituareService(QObject *parent)
++        : QObject(parent)
  {
      qDebug() << __PRETTY_FUNCTION__;
  
++    m_networkManager = new QNetworkAccessManager;
      connect(m_networkManager, SIGNAL(finished(QNetworkReply*)), SLOT(requestFinished(QNetworkReply*)));
  
      m_imageFetcher = new ImageFetcher(new QNetworkAccessManager(this), this);
@@@ -42,7 -41,6 +43,7 @@@
      connect(m_imageFetcher, SIGNAL(imageReceived(QUrl,QPixmap)), this,
              SLOT(imageReceived(QUrl, QPixmap)));
  
-     m_user = NULL;
++    m_user = 0;
  }
  
  SituareService::~SituareService()
      qDebug() << __PRETTY_FUNCTION__;
  
      delete m_networkManager;
-     m_networkManager = NULL;
++    m_networkManager = 0;
      if(m_user) {
          delete m_user;
-         m_user = NULL;
++        m_user = 0;
      }
 +    delete m_imageFetcher;
-     m_imageFetcher = NULL;
++    m_imageFetcher = 0;
 +
 +    qDeleteAll(m_friendsList.begin(), m_friendsList.end());
 +    m_friendsList.clear();
  }
  
  void SituareService::fetchLocations()
@@@ -73,7 -64,7 +74,6 @@@
                                                m_credentials.sig(), EN_LOCALE);
  
      QUrl url = formUrl(SITUARE_URL, GET_LOCATIONS);
--
      sendRequest(url, COOKIE, cookie);
  }
  
@@@ -86,7 -77,7 +86,6 @@@ void SituareService::reverseGeo(const Q
      QString cookie = cookieHandler.formCookie(API_KEY, m_credentials.expires(), m_credentials.userID(),
                                                m_credentials.sessionKey(), m_credentials.sessionSecret(),
                                                m_credentials.sig(), EN_LOCALE);
--
      QString urlParameters = formUrlParameters(coordinates);
      QUrl url = formUrl(SITUARE_URL, REVERSE_GEO, urlParameters);
  
@@@ -125,7 -116,7 +124,7 @@@ QUrl SituareService::formUrl(const QStr
  
      urlString.append(baseUrl);
      urlString.append(phpScript);
--    if(urlParameters != NULL)
++    if(!urlParameters.isEmpty())
          urlString.append(urlParameters);
  
      QUrl url = QUrl(urlString);
@@@ -161,7 -152,7 +160,7 @@@ QString SituareService::formUrlParamete
          parameters.append(PUBLISH_FALSE);
      }
  
--    if(status != NULL) {
++    if(!status.isEmpty()) {
          parameters.append(AMBERSAND_MARK);
          parameters.append(DATA);
          parameters.append(EQUAL_MARK);
@@@ -52,7 -52,7 +52,7 @@@ public
      * @param parent instance of parent
      * @param manager instance of QNetworkAccessManager
      */
--    SituareService(QObject *parent = 0, QNetworkAccessManager *manager = 0);
++    SituareService(QObject *parent = 0);
  
      /**
      * @brief Destructor
@@@ -63,7 -63,7 +63,6 @@@
  /*******************************************************************************
   * MEMBER FUNCTIONS AND SLOTS
   ******************************************************************************/
--
      /**
      * @brief Retrieves location user and friends information from Situare server
      *
Simple merge