Clear user information only when logout initiated from logout button.
authorSami Rämö <sami.ramo@ixonos.com>
Wed, 10 Nov 2010 09:36:04 +0000 (11:36 +0200)
committerSami Rämö <sami.ramo@ixonos.com>
Wed, 10 Nov 2010 09:36:04 +0000 (11:36 +0200)
src/engine/engine.cpp
src/facebookservice/facebookauthentication.cpp
src/facebookservice/facebookauthentication.h

index de715c9..bcce69d 100644 (file)
@@ -352,7 +352,7 @@ void SituareEngine::loginActionPressed()
     qDebug() << __PRETTY_FUNCTION__;
 
     if (m_facebookAuthenticator->isLoggedIn())
-        m_facebookAuthenticator->logOut();
+        m_facebookAuthenticator->logOut(true);
     else if (m_networkAccessManager->isConnected())
         m_facebookAuthenticator->login();
     else
index aaeff49..431c412 100644 (file)
@@ -63,21 +63,20 @@ void FacebookAuthentication::browserDestroyed()
     m_browser = 0;
 }
 
-void FacebookAuthentication::clearAccountInformation(bool keepUsername)
+void FacebookAuthentication::clearAccountInformation(bool clearUserInformation)
 {
-    qDebug() << __PRETTY_FUNCTION__;
+    qWarning() << __PRETTY_FUNCTION__ << "clearUserInformation:" << clearUserInformation;
 
     QSettings settings(SETTINGS_ORGANIZATION_NAME, SETTINGS_APPLICATION_NAME);
 
-    if(!keepUsername) {
-        settings.remove(SETTINGS_AUTOMATIC_UPDATE_ENABLED);
-        settings.remove(SETTINGS_AUTOMATIC_UPDATE_INTERVAL);
-    }
-
     settings.remove(USER_UNSEND_MESSAGE);
     settings.remove(USER_UNSEND_MESSAGE_PUBLISH);
 
-    NetworkCookieJar::clearCookiesSetting();
+    if (clearUserInformation) {
+        NetworkCookieJar::clearCookiesSetting();
+        settings.remove(SETTINGS_AUTOMATIC_UPDATE_ENABLED);
+        settings.remove(SETTINGS_AUTOMATIC_UPDATE_INTERVAL);
+    }
 }
 
 void FacebookAuthentication::destroyLogin()
@@ -88,7 +87,7 @@ void FacebookAuthentication::destroyLogin()
     m_browser->deleteLater();
 }
 
-bool FacebookAuthentication::isLoggedIn()
+bool FacebookAuthentication::isLoggedIn() const
 {
     qWarning() << __PRETTY_FUNCTION__;
 
@@ -137,11 +136,11 @@ void FacebookAuthentication::login()
     }
 }
 
-void FacebookAuthentication::logOut()
+void FacebookAuthentication::logOut(bool clearUserInformation)
 {
     qWarning() << __PRETTY_FUNCTION__;
 
-    clearAccountInformation();
+    clearAccountInformation(clearUserInformation);
     m_loggedIn = false;
     emit loggedOut();
 }
index 28725bd..f6969a7 100644 (file)
@@ -63,16 +63,16 @@ public slots:
     /**
     * @brief Clears account information from settings
     *
-    * @param keepUsername keep = true, false otherwise
+    * @param clearUserInformation True if user information should be cleared
     */
-    void clearAccountInformation(bool keepUsername = false);
+    void clearAccountInformation(bool clearUserInformation = false);
 
     /**
       * @brief Is the user currently logged in
       *
       * @returns True if the user is logged in, otherwise false
       */
-    bool isLoggedIn();
+    bool isLoggedIn() const;
 
     /**
       * @brief Initiate login process
@@ -83,8 +83,10 @@ public slots:
 
     /**
       * @brief Log out
+      *
+      * @param clearUserInformation True if user information should be cleared
       */
-    void logOut();
+    void logOut(bool clearUserInformation = false);
 
 private:
     /**