FacebookAuthentication::FacebookAuthentication(QObject *parent)
: QObject(parent),
- m_freshLogin(false),
- m_loginAttempts(0)
-
+ m_freshLogin(false)
{
qDebug() << __PRETTY_FUNCTION__;
else if ( callbackUrl.indexOf(LOGIN_FAILURE_REPLY) == 0){
qWarning() << "login failure" << endl;
qDebug() << callbackUrl;
- ++m_loginAttempts;
- /* emit loginFailure for every second login attemps, since webview loads login
- 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(true);
- if(m_freshLogin) {
- emit error(LOGIN_FAILED);
- emit loginFailure();
- }
- else {
- m_freshLogin = true;
- emit error(SESSION_EXPIRED);
- }
+ clearAccountInformation(true);
+ if(m_freshLogin) {
+ emit error(LOGIN_FAILED);
+ emit loginFailure();
+ }
+ else {
+ m_freshLogin = true;
+ emit error(SESSION_EXPIRED);
}
}
else if(callbackUrl.indexOf(LOGIN_PAGE) == 0) {
if(!m_webView) {
m_webView = new QWebView;
+ if(!m_cookieJar)
+ m_cookieJar = new NetworkCookieJar(new QNetworkCookieJar(this));
+
+ m_webView->page()->networkAccessManager()->setCookieJar(m_cookieJar);
+
+ connect(m_webView->page()->networkAccessManager(), SIGNAL(finished(QNetworkReply*)),
+ this, SLOT(webViewRequestFinished(QNetworkReply*)));
connect(m_webView, SIGNAL(urlChanged(const QUrl &)),
this, SIGNAL(updateCredentials(QUrl)));
connect(m_webView, SIGNAL(loadFinished(bool)),
void MainWindow::dialogFinished(int status)
{
qDebug() << __PRETTY_FUNCTION__;
-
+ qDebug() << status;
QDialog *dialog = m_queue.takeFirst();
if(!dialog->objectName().isEmpty()) {
- buildWebView();
if(status != 0) {
+ buildWebView();
static_cast<LoginDialog *>(dialog)->userInput(m_email, m_password);
- if(!m_cookieJar)
- m_cookieJar = new NetworkCookieJar(new QNetworkCookieJar(this));
-
- m_webView->page()->networkAccessManager()->setCookieJar(m_cookieJar);
- connect(m_webView->page()->networkAccessManager(), SIGNAL(finished(QNetworkReply*)),
- this, SLOT(webViewRequestFinished(QNetworkReply*)));
-
QStringList urlParts;
urlParts.append(FACEBOOK_LOGINBASE);
urlParts.append(SITUARE_PUBLIC_FACEBOOKAPI_KEY);
urlParts.append(FACEBOOK_LOGIN_ENDING);
emit saveUsername(m_email);
+ m_refresh = true;
m_webView->load(QUrl(urlParts.join(EMPTY)));
toggleProgressIndicator(true);
- m_refresh = true;
} else {
- m_webView->stop();
emit cancelLoginProcess();
}
}
{
qDebug() << __PRETTY_FUNCTION__;
-// if(dialog->isModal()) {
-// m_modal_queue.append(dialog);
-// } else {
- m_queue.append(dialog);
-// }
-
-// if(m_modal_queue.count() == 1)
-// showErrorNote();
+ m_queue.append(dialog);
if(m_queue.count() == 1)
showInformationBox();
qDebug() << __PRETTY_FUNCTION__;
LoginDialog *loginDialog = new LoginDialog();
-
loginDialog->setObjectName(QString("loginDialog"));
emit fetchUsernameFromSettings();
return m_email;
}
-void MainWindow::showErrorNote()
-{
- qDebug() << __PRETTY_FUNCTION__;
-
- QDialog *dialog = m_modal_queue.takeFirst();
- connect(dialog, SIGNAL(finished(int)),
- this, SLOT(errorNoteFinished()));
- dialog->show();
- m_queue.insert(0, dialog);
-}
-
void MainWindow::webViewRequestFinished(QNetworkReply *reply)
{
qDebug() << __PRETTY_FUNCTION__;
if(reply->error()) {
- // todo: emit error to engine
- qDebug() << reply->errorString();
- m_webView->stop();
+ qDebug() << reply->error() << reply->errorString();
toggleProgressIndicator(false);
}
}
-void MainWindow::errorNoteFinished()
-{
- qDebug() << __PRETTY_FUNCTION__;
-
- QDialog *dialog = m_queue.takeFirst();
- dialog->deleteLater();
-
- if(!m_modal_queue.isEmpty())
- showErrorNote();
-}