SituareEngine::SituareEngine(QMainWindow *parent)
: QObject(parent),
- m_autoCenteringEnabled(false)
+ m_autoCenteringEnabled(false),
+ m_loggedIn(false)
{
qDebug() << __PRETTY_FUNCTION__;
m_ui = new MainWindow;
m_ui->setUsername(m_facebookAuthenticator->loadUsername());
}
-void SituareEngine::loginOk(bool freshLogin)
+void SituareEngine::loginOk(bool freshLogin, const FacebookCredentials &credentials)
{
qDebug() << __PRETTY_FUNCTION__;
+ m_loggedIn = true;
+ m_ui->loggedIn(m_loggedIn);
+
if(freshLogin) {
m_facebookAuthenticator->saveUsername(m_ui->username());
}
m_ui->show();
+ m_situareService->credentialsReady(credentials);
m_situareService->fetchLocations(); // request user locations
}
+void SituareEngine::loginPressed()
+{
+ qDebug() << __PRETTY_FUNCTION__;
+
+ if(m_loggedIn) {
+ logout();
+ m_situareService->clearUserData();
+ }
+ else {
+ m_facebookAuthenticator->start();
+ }
+}
+
void SituareEngine::loginProcessCancelled()
{
qDebug() << __PRETTY_FUNCTION__;
m_ui->toggleProgressIndicator(false);
- //ToDo: do something
+ m_ui->showPanels(m_loggedIn);
+}
+
+void SituareEngine::logout()
+{
+ qDebug() << __PRETTY_FUNCTION__;
+
+ m_loggedIn = false;
+ m_ui->loggedIn(m_loggedIn);
+ m_facebookAuthenticator->clearAccountInformation();
}
void SituareEngine::refreshUserData()
{
qDebug() << __PRETTY_FUNCTION__;
- connect(m_facebookAuthenticator, SIGNAL(credentialsReady(bool, FacebookCredentials)),
- m_situareService, SLOT(credentialsReady(bool, FacebookCredentials)));
+ connect(m_facebookAuthenticator, SIGNAL(credentialsChanged(FacebookCredentials)),
+ m_situareService, SLOT(credentialsReady(FacebookCredentials)));
connect(m_facebookAuthenticator, SIGNAL(credentialsReady(bool, FacebookCredentials)),
- this, SLOT(loginOk(bool)));
+ this, SLOT(loginOk(bool, FacebookCredentials)));
connect(m_facebookAuthenticator, SIGNAL(newLoginRequest(QUrl)),
m_ui, SLOT(startLoginProcess(QUrl)));
{
qDebug() << __PRETTY_FUNCTION__;
+ connect(m_ui, SIGNAL(loginPressed()),
+ this, SLOT(loginPressed()));
+
connect(m_ui, SIGNAL(updateCredentials(QUrl)),
m_facebookAuthenticator, SLOT(updateCredentials(QUrl)));
{
qDebug() << __PRETTY_FUNCTION__;
+ connect(m_situareService, SIGNAL(error(QString)),
+ this, SLOT(error(QString)));
+
+ connect(m_situareService, SIGNAL(invalidSessionCredentials()),
+ m_facebookAuthenticator, SLOT(start()));
+
connect(m_situareService, SIGNAL(reverseGeoReady(QString)),
m_ui, SIGNAL(reverseGeoReady(QString)));
connect(m_situareService, SIGNAL(userDataChanged(User*, QList<User*>&)),
this, SLOT(userDataChanged(User*, QList<User*>&)));
- connect(m_situareService, SIGNAL(error(QString)),
- this, SLOT(error(QString)));
-
connect(m_situareService, SIGNAL(updateWasSuccessful()),
this, SLOT(updateWasSuccessful()));
}