Added progress indicator
authorSami Rämö <sami.ramo@ixonos.com>
Tue, 9 Nov 2010 10:36:41 +0000 (12:36 +0200)
committerSami Rämö <sami.ramo@ixonos.com>
Tue, 9 Nov 2010 10:36:41 +0000 (12:36 +0200)
src/facebookservice/facebookauthentication.cpp
src/facebookservice/facebookauthentication.h

index ca8ac04..40f4309 100644 (file)
@@ -58,6 +58,7 @@ void FacebookAuthentication::browserDestroyed()
 {
     qWarning() << __PRETTY_FUNCTION__;
 
+    m_mainWindow->toggleProgressIndicator(false);
     m_browser = 0;
 }
 
@@ -79,6 +80,14 @@ void FacebookAuthentication::clearAccountInformation(bool keepUsername)
     NetworkCookieJar::clearCookiesSetting();
 }
 
+void FacebookAuthentication::destroyLogin()
+{
+    qWarning() << __PRETTY_FUNCTION__;
+
+    m_mainWindow->destroyLoginDialog();
+    m_browser->deleteLater();
+}
+
 void FacebookAuthentication::loadFinished(bool ok)
 {
     qWarning() << __PRETTY_FUNCTION__ << ok;
@@ -122,6 +131,8 @@ void FacebookAuthentication::login()
         url.append("req_perms=publish_stream");
 
         m_browser->load(QUrl(url));
+
+        m_mainWindow->toggleProgressIndicator(true);
     }
 }
 
@@ -131,6 +142,7 @@ void FacebookAuthentication::networkReplyHandler(QNetworkReply *reply)
 
     if (reply->error() != QNetworkReply::NoError) {
         qCritical() << __PRETTY_FUNCTION__ << "error:" << reply->error() << reply->errorString();
+        destroyLogin();
         /// @todo Emit error signal
     }
 }
@@ -176,8 +188,7 @@ void FacebookAuthentication::urlChanged(const QUrl &url)
         const QString session = parseSession(url);
         qWarning() << __PRETTY_FUNCTION__ << "login finished, parsed session:" << session;
         if (!session.isEmpty()) {
-            m_mainWindow->destroyLoginDialog();
-            m_browser->deleteLater();
+            destroyLogin();
             emit loggedIn(session);
         }
     }
index 5d12838..3699687 100644 (file)
@@ -71,6 +71,8 @@ public slots:
     void clearAccountInformation(bool keepUsername = false);
 
 private:
+    void destroyLogin();
+
     QString parseSession(const QUrl &url);
 
 private slots: