{
qDebug() << __PRETTY_FUNCTION__;
- m_facebookAuthenticator->clearAccountInformation(/*true*/); // keep username = true
- //m_facebookAuthenticator->start();
- m_ui->loginUsingCookies();
+ m_facebookAuthenticator->clearAccountInformation(true); // keep username = true
+ m_ui->clearCookieJar();
+ m_ui->showMaemoInformationBox(tr("Session expired. Please login again"), true);
+ m_facebookAuthenticator->start();
}
void SituareEngine::loginActionPressed()
m_loggedIn = false;
m_ui->loggedIn(m_loggedIn);
- m_facebookAuthenticator->clearAccountInformation();
+ m_facebookAuthenticator->clearAccountInformation(); // clear all
}
void SituareEngine::refreshUserData()
}
-void FacebookAuthentication::clearAccountInformation()
+void FacebookAuthentication::clearAccountInformation(bool keepUsername)
{
qDebug() << __PRETTY_FUNCTION__;
m_loginCredentials.clearCredentials();
QSettings settings(DIRECTORY_NAME, FILE_NAME);
- settings.remove(USERNAME);
+
+ if(!keepUsername)
+ settings.remove(USERNAME);
+
settings.remove(COOKIES);
}
error page (loadingDone() signal is emitted) and we need to avoid that because
at this point we don't have new login parameters */
if(m_loginAttempts % 2) {
- clearAccountInformation();
+ clearAccountInformation(true);
emit loginFailure();
}
}
m_email(),
m_password(),
m_webView(0),
+ m_loginDialog(0),
m_cookieJar(0)
{
qDebug() << __PRETTY_FUNCTION__;
if(!m_cookieJar) {
m_cookieJar = new NetworkCookieJar(new QNetworkCookieJar(this));
- qDebug() << "create cookie jar";
}
QList<QNetworkCookie> emptyList;
emptyList.clear();
}
if(!m_cookieJar) {
m_cookieJar = new NetworkCookieJar(new QNetworkCookieJar(this));
- qDebug() << "create cookie jar";
}
m_cookieJar->setAllCookies(cookieList);
{
qDebug() << __PRETTY_FUNCTION__;
- emit fetchUsernameFromSettings();
+ clearCookieJar();
toggleProgressIndicator(false);
-#ifdef Q_WS_MAEMO_5
- QMaemo5InformationBox::information(this, tr("Invalid E-mail address or password"),
- QMaemo5InformationBox::NoTimeout);
-
-#endif // Q_WS_MAEMO_5
-
- buildLoginDialog();
-
- if(!m_email.isEmpty()) {
- m_loginDialog->setEmailField(m_email);
- }
+ showMaemoInformationBox(tr("Invalid E-mail address or password"), true);
- if(m_loginDialog->exec() != QDialog::Accepted) {
- // if login dialog was canceled we need to stop processing webview
- // stop and disconnect m_webView;
- m_webView->stop();
- connectWebViewSignals(false);
-
- emit cancelLoginProcess();
- }
- else {
- // re-load login page for webview
- toggleProgressIndicator(true);
-
- // connect webview signals again since they might have been disconnected
- connectWebViewSignals(true);
-
- QStringList urlParts;
- urlParts.append(FACEBOOK_LOGINBASE);
- urlParts.append(SITUARE_PUBLIC_FACEBOOKAPI_KEY);
- urlParts.append(INTERVAL1);
- urlParts.append(SITUARE_LOGIN_SUCCESS);
- urlParts.append(INTERVAL2);
- urlParts.append(SITUARE_LOGIN_FAILURE);
- urlParts.append(FACEBOOK_LOGIN_ENDING);
+ QStringList urlParts;
+ urlParts.append(FACEBOOK_LOGINBASE);
+ urlParts.append(SITUARE_PUBLIC_FACEBOOKAPI_KEY);
+ urlParts.append(INTERVAL1);
+ urlParts.append(SITUARE_LOGIN_SUCCESS);
+ urlParts.append(INTERVAL2);
+ urlParts.append(SITUARE_LOGIN_FAILURE);
+ urlParts.append(FACEBOOK_LOGIN_ENDING);
- m_webView->load(QUrl(urlParts.join(EMPTY)));
- }
+ startLoginProcess(urlParts.join(EMPTY));
}
void MainWindow::loginUsingCookies()
m_viewPortHeight = height;
}
-void MainWindow::showMaemoInformationBox(const QString &message)
+void MainWindow::showMaemoInformationBox(const QString &message, bool modal)
{
qDebug() << __PRETTY_FUNCTION__;
#ifdef Q_WS_MAEMO_5
- QMaemo5InformationBox::information(this, message, QMaemo5InformationBox::DefaultTimeout);
+ if(modal) {
+ QMaemo5InformationBox::information(this, message, QMaemo5InformationBox::NoTimeout);
+ }
+ else {
+ QMaemo5InformationBox::information(this, message, QMaemo5InformationBox::DefaultTimeout);
+ }
#else
Q_UNUSED(message);
+ Q_UNUSED(modal);
#endif
}
m_webView->page()->networkAccessManager()->setCookieJar(m_cookieJar);
+ m_loginDialog->clearTextFields();
+
if(!m_email.isEmpty()) {
m_loginDialog->setEmailField(m_email);
}
/*******************************************************************************
* MEMBER FUNCTIONS AND SLOTS
******************************************************************************/
-public:
+public:
+ /**
+ * @brief Clears cookie jar
+ *
+ */
+ void clearCookieJar();
+
/**
* @brief
*
/**
* @brief Show Maemo information box with message.
*
- * @brief message information message
+ * @param message Information message
+ * @param modal Modal = true, non-modal false
*/
- void showMaemoInformationBox(const QString &message);
+ void showMaemoInformationBox(const QString &message, bool modal=false);
/**
* @brief Gets the username from member variable for saving purposes
void buildZoomButtonPanel();
/**
- * @brief Clears cookie jar
- *
- */
- void clearCookieJar();
-
- /**
* @brief connect/disconnect webview signals
*
* @param connectSignals true = connect, false = disconnect