backup
authorlampehe-local <henri.lampela@ixonos.com>
Tue, 8 Jun 2010 08:02:29 +0000 (11:02 +0300)
committerlampehe-local <henri.lampela@ixonos.com>
Tue, 8 Jun 2010 08:02:29 +0000 (11:02 +0300)
src/facebookservice/facebookauthentication.cpp
src/facebookservice/facebookauthentication.h
src/ui/mainwindow.cpp
src/ui/mainwindow.h

index cba99ed..00293e2 100644 (file)
@@ -38,9 +38,7 @@
 
 FacebookAuthentication::FacebookAuthentication(QObject *parent)
     : QObject(parent),
-    m_freshLogin(false),
-    m_loginAttempts(0)
-
+    m_freshLogin(false)
 {
     qDebug() << __PRETTY_FUNCTION__;
 
@@ -162,20 +160,14 @@ bool FacebookAuthentication::updateCredentials(const QUrl &url)
         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) {
index 6f37c71..4ffea66 100644 (file)
@@ -156,8 +156,6 @@ private:
 
     bool m_freshLogin;
 
-    int m_loginAttempts; ///< Indicates login attempts
-
     /**
     * @brief Dataclass that contains authorization to use facebook. Dataclass is composed of five
     *        QStrings and setters and getters.
index b0ae04b..021eaea 100644 (file)
@@ -282,6 +282,13 @@ void MainWindow::buildWebView()
     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)),
@@ -371,20 +378,13 @@ void MainWindow::createMenus()
 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);
@@ -395,11 +395,10 @@ void MainWindow::dialogFinished(int status)
             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();
         }
     }
@@ -620,14 +619,7 @@ void MainWindow::queueDialog(QDialog *dialog)
 {
     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();
@@ -735,7 +727,6 @@ void MainWindow::startLoginProcess()
     qDebug() << __PRETTY_FUNCTION__;
 
     LoginDialog *loginDialog = new LoginDialog();
-
     loginDialog->setObjectName(QString("loginDialog"));
 
     emit fetchUsernameFromSettings();
@@ -792,36 +783,13 @@ const QString MainWindow::username()
     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();
-}
index 3ddadcf..5cd97b4 100644 (file)
@@ -245,8 +245,6 @@ private:
       */
     void setOwnLocationCrosshairVisibility(bool visible);
 
-    void showErrorNote();
-
     /**
     * @brief Shows queued information box
     *
@@ -325,8 +323,6 @@ private slots:
 
     void webViewRequestFinished(QNetworkReply* reply);
 
-    void errorNoteFinished();
-
 /*******************************************************************************
  * SIGNALS
  ******************************************************************************/
@@ -537,7 +533,6 @@ private:
     SettingsDialog *m_settingsDialog;       ///< Settings dialog
 
     QList<QDialog *> m_queue;
-    QList<QDialog *> m_modal_queue;
 };
 
 #endif // MAINWINDOW_H