m_loggedIn = false;
m_facebookAuthenticator = new FacebookAuthentication();
- connect(m_facebookAuthenticator, SIGNAL(credentialsReady()), this, SLOT(loginOk()));
- connect(m_facebookAuthenticator, SIGNAL(userExit()), this, SLOT(loginScreenClosed()));
+ connect(m_facebookAuthenticator, SIGNAL(credentialsReady(FacebookCredentials)),
+ m_situareService, SLOT(credentialsReady(FacebookCredentials)));
+ 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)));
- m_situareService->fetchLocations(); // request user locations
-
start();
}
{
qDebug() << __PRETTY_FUNCTION__;
m_loggedIn = true;
- m_facebookAuthenticator->close();
-}
-
-void SituareEngine::loginScreenClosed()
-{
- qDebug() << __PRETTY_FUNCTION__ << m_loggedIn;
- if (m_loggedIn) {
- m_ui->show();
- return;
- }
- else {
- m_ui->close();
- }
+ m_facebookAuthenticator->hide();
+ m_ui->show();
+ m_situareService->fetchLocations(); // request user locations
}
void SituareEngine::requestAddress()
void start();
public slots:
- /**
- * @brief Slot to intercept signal from login screen closure
- */
- void loginScreenClosed();
/**
* @brief Slot to intercept signal from successful login
this->show();
}
else
- emit credentialsReady();
+ emit credentialsReady(m_loginCredentials);
}
}
m_webView->hide();
- emit credentialsReady();
writeCredentials(m_loginCredentials);
+ emit credentialsReady(m_loginCredentials);
}
else if ( callbackUrl.indexOf(LOGIN_FAILURE_REPLY) == 0){
}
}
- void FacebookAuthentication::closeEvent(QCloseEvent *event)
- {
- qDebug() << __PRETTY_FUNCTION__;
- int eventNumber = 0;
- eventNumber = event->registerEventType();
- qDebug() << "event number" << eventNumber;
- emit userExit();
- event->accept();
- }
-
QString FacebookAuthentication::formLoginPage(const QString & part1, const QString & part2,
const QString & part3, const QString & part4,
const QString & part5, const QString & part6,
*/
void start();
-private:
-
- /**
- * @brief Program cames to this method when user closes login screen by pressing X.
- * method sends userExit() signal in this function
- *
- * @param event without parameter program does not come to this function when user exits by
- * pressing X.
- */
- void closeEvent(QCloseEvent *event);
+private:
/**
* @brief Appends given parts to returned string. Method is used to form facebook login page
* Signal is also emitted at the beginning of the program if there is valid credentials
* in the file.
*
+ * @param credentials New credentials
*/
- void credentialsReady();
+ void credentialsReady(const FacebookCredentials &credentials);
/**
* @brief This signal is emitted if updateCredentials method can't find credentials from URL
*/
void loginFailure();
- /**
- * @brief This signal is emitted if user exits logging in by pressing X
- *
- */
- void userExit();
-
private:
/**
#include <QtGlobal>
#include <QStringList>
#include <QPixmap>
+#include <QNetworkReply>
#include "situareservice.h"
#include "situarecommon.h"
#include "../cookiehandler/cookiehandler.h"
{
qDebug() << __PRETTY_FUNCTION__;
- connect(&m_facebookAuthentication, SIGNAL(credentialsReady()), SLOT(credentialsReady()));
-
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_credentials = m_facebookAuthentication.loginCredentials();
}
SituareService::~SituareService()
qDebug() << __PRETTY_FUNCTION__;
delete m_networkManager;
- delete m_user;
+ if(m_user) {
+ delete m_user;
+ }
}
void SituareService::fetchLocations()
reply->deleteLater();
}
-void SituareService::credentialsReady()
+void SituareService::credentialsReady(const FacebookCredentials &credentials)
{
qDebug() << __PRETTY_FUNCTION__;
- m_credentials = m_facebookAuthentication.loginCredentials();
+ m_credentials = credentials;
+
}
void SituareService::parseUserData(const QByteArray &jsonReply)
exit (1);
}
- //QList<User *> friendsList;
-
QVariant userVariant = result.value("user");
QMap<QString, QVariant> userMap = userVariant.toMap();
#define SITUARESERVICE_H
#include <QObject>
-#include "../facebookservice/facebookauthentication.h"
#include "../facebookservice/facebookcredentials.h"
#include "../user/user.h"
#include "imagefetcher.h"
/**
* @brief Public slot, which indicates when facebook credentials are ready
*
+ * @param credentials New credentials
*/
- void credentialsReady();
+ void credentialsReady(const FacebookCredentials &credentials);
private:
FacebookCredentials m_credentials; ///< handle for FacebookCredentials
QList<QNetworkReply *> m_currentRequests; ///< List of current http requests
- FacebookAuthentication m_facebookAuthentication; ///< Pointer to FacebookAuthentication
QNetworkAccessManager *m_networkManager; ///< Pointer to QNetworkAccessManager
ImageFetcher *m_imageFetcher;