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()
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...
#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
* @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);
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()
m_credentials.sig(), EN_LOCALE);
QUrl url = formUrl(SITUARE_URL, GET_LOCATIONS);
--
sendRequest(url, COOKIE, cookie);
}
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);
urlString.append(baseUrl);
urlString.append(phpScript);
-- if(urlParameters != NULL)
++ if(!urlParameters.isEmpty())
urlString.append(urlParameters);
QUrl url = QUrl(urlString);
parameters.append(PUBLISH_FALSE);
}
-- if(status != NULL) {
++ if(!status.isEmpty()) {
parameters.append(AMBERSAND_MARK);
parameters.append(DATA);
parameters.append(EQUAL_MARK);
* @param parent instance of parent
* @param manager instance of QNetworkAccessManager
*/
-- SituareService(QObject *parent = 0, QNetworkAccessManager *manager = 0);
++ SituareService(QObject *parent = 0);
/**
* @brief Destructor
/*******************************************************************************
* MEMBER FUNCTIONS AND SLOTS
******************************************************************************/
--
/**
* @brief Retrieves location user and friends information from Situare server
*