Few fixes and improvements
authorlampehe-local <henri.lampela@ixonos.com>
Fri, 28 May 2010 12:30:58 +0000 (15:30 +0300)
committerlampehe-local <henri.lampela@ixonos.com>
Fri, 28 May 2010 12:30:58 +0000 (15:30 +0300)
src/engine/engine.cpp
src/facebookservice/facebookauthentication.cpp
src/facebookservice/facebookauthentication.h
src/src.pro
src/ui/mainwindow.cpp
src/ui/mainwindow.h
src/ui/userinfopanel.h

index 4700c20..7319abf 100644 (file)
@@ -194,9 +194,10 @@ void SituareEngine::invalidCredentials()
 {
     qDebug() << __PRETTY_FUNCTION__;
 
-    m_facebookAuthenticator->clearAccountInformation(/*true*/); // keep username = true
-    //m_facebookAuthenticator->start();
-    m_ui->loginUsingCookies();
+    m_facebookAuthenticator->clearAccountInformation(true); // keep username = true
+    m_ui->clearCookieJar();
+    m_ui->showMaemoInformationBox(tr("Session expired. Please login again"), true);
+    m_facebookAuthenticator->start();
 }
 
 void SituareEngine::loginActionPressed()
@@ -240,7 +241,7 @@ void SituareEngine::logout()
 
     m_loggedIn = false;
     m_ui->loggedIn(m_loggedIn);
-    m_facebookAuthenticator->clearAccountInformation();
+    m_facebookAuthenticator->clearAccountInformation(); // clear all
 }
 
 void SituareEngine::refreshUserData()
index 420c591..1eefd6f 100644 (file)
@@ -45,13 +45,16 @@ FacebookAuthentication::FacebookAuthentication(QObject *parent)
 
 }
 
-void FacebookAuthentication::clearAccountInformation()
+void FacebookAuthentication::clearAccountInformation(bool keepUsername)
 {
     qDebug() << __PRETTY_FUNCTION__;
 
     m_loginCredentials.clearCredentials();
     QSettings settings(DIRECTORY_NAME, FILE_NAME);
-    settings.remove(USERNAME);
+
+    if(!keepUsername)
+        settings.remove(USERNAME);
+
     settings.remove(COOKIES);
 }
 
@@ -177,7 +180,7 @@ bool FacebookAuthentication::updateCredentials(const QUrl &url)
                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();
+                clearAccountInformation(true);
                 emit loginFailure();
             }
         }
index 2ccf229..ba32fef 100644 (file)
@@ -64,8 +64,9 @@ public slots:
     /**
     * @brief Clears account iformation from settings
     *
+    * @param keepUsername keep = true, false otherwise
     */
-    void clearAccountInformation();
+    void clearAccountInformation(bool keepUsername = false);
 
     /**
     * @brief Loads username from settings
index fe92caf..5a7ba41 100644 (file)
@@ -44,7 +44,6 @@ SOURCES += main.cpp \
     ui/sidepanel.cpp \
     networkcookiejar.cpp \
     ui/zoombutton.cpp \
-    ui/zoombutton.cpp \
     network/networkaccessmanager.cpp \
     network/networkhandler.cpp \
     network/networkreply.cpp
@@ -97,7 +96,7 @@ HEADERS += ui/mainwindow.h \
 QT += network \
     webkit
 
-DEFINES += QT_NO_DEBUG_OUTPUT
+#DEFINES += QT_NO_DEBUG_OUTPUT
 
 maemo5 | simulator {
     INCLUDEPATH += /usr/include/glib-2.0 /usr/lib/glib-2.0/include
index 6af3a8d..de42553 100644 (file)
@@ -58,6 +58,7 @@ MainWindow::MainWindow(QWidget *parent)
     m_email(),    
     m_password(),
     m_webView(0),
+    m_loginDialog(0),
     m_cookieJar(0)
 {
     qDebug() << __PRETTY_FUNCTION__;
@@ -278,7 +279,6 @@ void MainWindow::clearCookieJar()
 
     if(!m_cookieJar) {
         m_cookieJar = new NetworkCookieJar(new QNetworkCookieJar(this));
-        qDebug() << "create cookie jar";
     }
     QList<QNetworkCookie> emptyList;
     emptyList.clear();
@@ -438,7 +438,6 @@ void MainWindow::loadCookies()
         }
         if(!m_cookieJar) {
             m_cookieJar = new NetworkCookieJar(new QNetworkCookieJar(this));
-            qDebug() << "create cookie jar";
         }
 
         m_cookieJar->setAllCookies(cookieList);
@@ -524,48 +523,22 @@ void MainWindow::loginFailed()
 {
     qDebug() << __PRETTY_FUNCTION__;
 
-    emit fetchUsernameFromSettings();
+    clearCookieJar();
 
     toggleProgressIndicator(false);
 
-#ifdef Q_WS_MAEMO_5
-    QMaemo5InformationBox::information(this, tr("Invalid E-mail address or password"),
-                                       QMaemo5InformationBox::NoTimeout);
-
-#endif // Q_WS_MAEMO_5
-
-    buildLoginDialog();
-
-    if(!m_email.isEmpty()) {
-        m_loginDialog->setEmailField(m_email);
-    }
+    showMaemoInformationBox(tr("Invalid E-mail address or password"), true);
 
-    if(m_loginDialog->exec() != QDialog::Accepted) {
-        // if login dialog was canceled we need to stop processing webview
-        // stop and disconnect m_webView;
-        m_webView->stop();
-        connectWebViewSignals(false);
-
-        emit cancelLoginProcess();
-    }
-    else {
-        // re-load login page for webview
-        toggleProgressIndicator(true);
-
-        // connect webview signals again since they might have been disconnected
-        connectWebViewSignals(true);
-
-        QStringList urlParts;
-        urlParts.append(FACEBOOK_LOGINBASE);
-        urlParts.append(SITUARE_PUBLIC_FACEBOOKAPI_KEY);
-        urlParts.append(INTERVAL1);
-        urlParts.append(SITUARE_LOGIN_SUCCESS);
-        urlParts.append(INTERVAL2);
-        urlParts.append(SITUARE_LOGIN_FAILURE);
-        urlParts.append(FACEBOOK_LOGIN_ENDING);
+    QStringList urlParts;
+    urlParts.append(FACEBOOK_LOGINBASE);
+    urlParts.append(SITUARE_PUBLIC_FACEBOOKAPI_KEY);
+    urlParts.append(INTERVAL1);
+    urlParts.append(SITUARE_LOGIN_SUCCESS);
+    urlParts.append(INTERVAL2);
+    urlParts.append(SITUARE_LOGIN_FAILURE);
+    urlParts.append(FACEBOOK_LOGIN_ENDING);
 
-        m_webView->load(QUrl(urlParts.join(EMPTY)));
-    }
+    startLoginProcess(urlParts.join(EMPTY));
 }
 
 void MainWindow::loginUsingCookies()
@@ -671,14 +644,20 @@ void MainWindow::setViewPortSize(int width, int height)
     m_viewPortHeight = height;
 }
 
-void MainWindow::showMaemoInformationBox(const QString &message)
+void MainWindow::showMaemoInformationBox(const QString &message, bool modal)
 {
     qDebug() << __PRETTY_FUNCTION__;
 
 #ifdef Q_WS_MAEMO_5
-    QMaemo5InformationBox::information(this, message, QMaemo5InformationBox::DefaultTimeout);
+    if(modal) {
+        QMaemo5InformationBox::information(this, message, QMaemo5InformationBox::NoTimeout);
+    }
+    else {
+        QMaemo5InformationBox::information(this, message, QMaemo5InformationBox::DefaultTimeout);
+    }
 #else
     Q_UNUSED(message);
+    Q_UNUSED(modal);
 #endif
 }
 
@@ -715,6 +694,8 @@ void MainWindow::startLoginProcess(const QUrl &url)
 
     m_webView->page()->networkAccessManager()->setCookieJar(m_cookieJar);
 
+    m_loginDialog->clearTextFields();
+
     if(!m_email.isEmpty()) {
         m_loginDialog->setEmailField(m_email);
     }
index 05c98eb..48afa60 100644 (file)
@@ -77,7 +77,13 @@ private:
 /*******************************************************************************
  * MEMBER FUNCTIONS AND SLOTS
  ******************************************************************************/
-public:    
+public:
+    /**
+    * @brief Clears cookie jar
+    *
+    */
+    void clearCookieJar();
+
     /**
     * @brief
     *
@@ -111,9 +117,10 @@ public:
     /**
     * @brief Show Maemo information box with message.
     *
-    * @brief message information message
+    * @param message Information message
+    * @param modal Modal = true, non-modal false
     */
-    void showMaemoInformationBox(const QString &message);
+    void showMaemoInformationBox(const QString &message, bool modal=false);
 
     /**
     * @brief Gets the username from member variable for saving purposes
@@ -221,12 +228,6 @@ private:
     void buildZoomButtonPanel();
 
     /**
-    * @brief Clears cookie jar
-    *
-    */
-    void clearCookieJar();
-
-    /**
     * @brief connect/disconnect webview signals
     *
     * @param connectSignals true = connect, false = disconnect
index 7aabce7..c0ab604 100644 (file)
@@ -33,7 +33,7 @@ class UserInfo;
 * @brief Class for sliding user information panel
 *
 * @author Kaj Wallin - kaj.wallin (at) ixonos.com
-* @class UserInfoPanel userpanel.h "ui/userpanel.h"
+* @class UserInfoPanel
 */
 class UserInfoPanel : public SidePanel
 {