Added login conter note_problem
authorlampehe-local <henri.lampela@ixonos.com>
Tue, 8 Jun 2010 11:52:36 +0000 (14:52 +0300)
committerlampehe-local <henri.lampela@ixonos.com>
Tue, 8 Jun 2010 11:52:36 +0000 (14:52 +0300)
src/facebookservice/facebookauthentication.cpp
src/facebookservice/facebookauthentication.h

index 00293e2..cba99ed 100644 (file)
@@ -38,7 +38,9 @@
 
 FacebookAuthentication::FacebookAuthentication(QObject *parent)
     : QObject(parent),
-    m_freshLogin(false)
+    m_freshLogin(false),
+    m_loginAttempts(0)
+
 {
     qDebug() << __PRETTY_FUNCTION__;
 
@@ -160,14 +162,20 @@ bool FacebookAuthentication::updateCredentials(const QUrl &url)
         else if ( callbackUrl.indexOf(LOGIN_FAILURE_REPLY) == 0){
             qWarning() << "login failure" << endl;
             qDebug() << callbackUrl;
-            clearAccountInformation(true);
-            if(m_freshLogin) {
-                emit error(LOGIN_FAILED);
-                emit loginFailure();
-            }
-            else {
-                m_freshLogin = true;
-                emit error(SESSION_EXPIRED);
+            ++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);
+                }
             }
         }
         else if(callbackUrl.indexOf(LOGIN_PAGE) == 0) {
index 4ffea66..6f37c71 100644 (file)
@@ -156,6 +156,8 @@ 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.