Merged logout implementation to new refactored master
authorlampehe-local <henri.lampela@ixonos.com>
Fri, 21 May 2010 13:45:40 +0000 (16:45 +0300)
committerlampehe-local <henri.lampela@ixonos.com>
Fri, 21 May 2010 13:45:40 +0000 (16:45 +0300)
16 files changed:
src/engine/engine.cpp
src/engine/engine.h
src/facebookservice/facebookauthentication.cpp
src/facebookservice/facebookauthentication.h
src/facebookservice/facebookcredentials.cpp
src/facebookservice/facebookcredentials.h
src/map/mapengine.cpp
src/situareservice/situareservice.cpp
src/situareservice/situareservice.h
src/ui/logindialog.cpp
src/ui/logindialog.h
src/ui/mainwindow.cpp
src/ui/mainwindow.h
src/ui/settingsdialog.cpp
src/ui/settingsdialog.h
src/ui/userinfopanel.cpp

index 873ff5a..1afe38c 100644 (file)
@@ -37,7 +37,8 @@ const QString SETTINGS_AUTO_CENTERING_ENABLED = "AUTO_CENTERING_ENABLED";
 
 SituareEngine::SituareEngine(QMainWindow *parent)
     : QObject(parent),
-      m_autoCenteringEnabled(false)
+      m_autoCenteringEnabled(false),
+      m_loggedIn(false)
 {
     qDebug() << __PRETTY_FUNCTION__;
     m_ui = new MainWindow;
@@ -167,23 +168,49 @@ void SituareEngine::fetchUsernameFromSettings()
     m_ui->setUsername(m_facebookAuthenticator->loadUsername());
 }
 
-void SituareEngine::loginOk(bool freshLogin)
+void SituareEngine::loginOk(bool freshLogin, const FacebookCredentials &credentials)
 {
     qDebug() << __PRETTY_FUNCTION__;
 
+    m_loggedIn = true;
+    m_ui->loggedIn(m_loggedIn);
+
     if(freshLogin) {
         m_facebookAuthenticator->saveUsername(m_ui->username());
     }
     m_ui->show();
+    m_situareService->credentialsReady(credentials);
     m_situareService->fetchLocations(); // request user locations
 }
 
+void SituareEngine::loginPressed()
+{
+    qDebug() << __PRETTY_FUNCTION__;
+
+    if(m_loggedIn) {
+        logout();
+        m_situareService->clearUserData();
+    }
+    else {
+        m_facebookAuthenticator->start();
+    }
+}
+
 void SituareEngine::loginProcessCancelled()
 {
     qDebug() << __PRETTY_FUNCTION__;
 
     m_ui->toggleProgressIndicator(false);
-    //ToDo: do something
+    m_ui->showPanels(m_loggedIn);
+}
+
+void SituareEngine::logout()
+{
+    qDebug() << __PRETTY_FUNCTION__;
+
+    m_loggedIn = false;
+    m_ui->loggedIn(m_loggedIn);
+    m_facebookAuthenticator->clearAccountInformation();
 }
 
 void SituareEngine::refreshUserData()
@@ -221,11 +248,11 @@ void SituareEngine::signalsFromFacebookAuthenticator()
 {
     qDebug() << __PRETTY_FUNCTION__;
 
-    connect(m_facebookAuthenticator, SIGNAL(credentialsReady(bool, FacebookCredentials)),
-            m_situareService, SLOT(credentialsReady(bool, FacebookCredentials)));
+    connect(m_facebookAuthenticator, SIGNAL(credentialsChanged(FacebookCredentials)),
+            m_situareService, SLOT(credentialsReady(FacebookCredentials)));
 
     connect(m_facebookAuthenticator, SIGNAL(credentialsReady(bool, FacebookCredentials)),
-            this, SLOT(loginOk(bool)));
+            this, SLOT(loginOk(bool, FacebookCredentials)));
 
     connect(m_facebookAuthenticator, SIGNAL(newLoginRequest(QUrl)),
             m_ui, SLOT(startLoginProcess(QUrl)));
@@ -252,6 +279,9 @@ void SituareEngine::signalsFromMainWindow()
 {
     qDebug() << __PRETTY_FUNCTION__;
 
+    connect(m_ui, SIGNAL(loginPressed()),
+            this, SLOT(loginPressed()));
+
     connect(m_ui, SIGNAL(updateCredentials(QUrl)),
             m_facebookAuthenticator, SLOT(updateCredentials(QUrl)));
 
@@ -325,15 +355,18 @@ void SituareEngine::signalsFromSituareService()
 {
     qDebug() << __PRETTY_FUNCTION__;
 
+    connect(m_situareService, SIGNAL(error(QString)),
+            this, SLOT(error(QString)));
+
+    connect(m_situareService, SIGNAL(invalidSessionCredentials()),
+            m_facebookAuthenticator, SLOT(start()));
+
     connect(m_situareService, SIGNAL(reverseGeoReady(QString)),
             m_ui, SIGNAL(reverseGeoReady(QString)));
 
     connect(m_situareService, SIGNAL(userDataChanged(User*, QList<User*>&)),
             this, SLOT(userDataChanged(User*, QList<User*>&)));
 
-    connect(m_situareService, SIGNAL(error(QString)),
-            this, SLOT(error(QString)));
-
     connect(m_situareService, SIGNAL(updateWasSuccessful()),
             this, SLOT(updateWasSuccessful()));
 }
index da9750c..c2e22be 100644 (file)
@@ -31,6 +31,7 @@
 class QMainWindow;
 
 class FacebookAuthentication;
+class FacebookCredentials;
 class GPSPosition;
 class MainWindow;
 class MapEngine;
@@ -80,8 +81,15 @@ public slots:
     * @brief Slot to intercept signal from successful login
     *
     * @param freshLogin Was login done via login dialog
+    * @param credentials Facebook credentials
     */
-    void loginOk(bool freshLogin);
+    void loginOk(bool freshLogin, const FacebookCredentials &credentials);
+
+    /**
+    * @brief Slot to intercept signal when Login/Logout action is pressed
+    *
+    */
+    void loginPressed();
 
     /**
     * @brief Slot to intercept signal when user has cancelled login process
@@ -89,6 +97,12 @@ public slots:
     void loginProcessCancelled();
 
     /**
+    * @brief Changes application state when logged out
+    *
+    */
+    void logout();
+
+    /**
     * @brief Calls reverseGeo from SituareService to translate coordinates to street address
     *
     */
@@ -205,12 +219,14 @@ signals:
  ******************************************************************************/
 private:
     bool m_autoCenteringEnabled;  ///< Auto centering enabled
+    bool m_loggedIn;              ///< Login state
 
     FacebookAuthentication *m_facebookAuthenticator; ///< Instance for facebook authenticator
     GPSPosition *m_gps;                              ///< Instance of the gps position
     MainWindow *m_ui;                                ///< Instance of the MainWindow UI
     MapEngine *m_mapEngine;                          ///< MapEngine
     SituareService *m_situareService;  ///< Instance of the situare server communication service
+
 };
 
 #endif // ENGINE_H
index e8c9ef2..6526502 100644 (file)
@@ -62,8 +62,10 @@ void FacebookAuthentication::start()
 
         emit newLoginRequest(formLoginPageUrl(list));
     }
-    else
+    else {
         emit credentialsReady(false, m_loginCredentials);
+    }
+
 }
 
 bool FacebookAuthentication::updateCredentials(const QUrl &url)
@@ -234,3 +236,19 @@ void FacebookAuthentication::readCredentials(FacebookCredentials &credentialsFro
      QSettings settings(DIRECTORY_NAME, FILE_NAME);
      return settings.value(USERNAME, EMPTY).toString();
  }
+
+ void FacebookAuthentication::clearAccountInformation()
+ {
+     qDebug() << __PRETTY_FUNCTION__;
+
+     m_loginCredentials.clearCredentials();
+     QSettings settings(DIRECTORY_NAME, FILE_NAME);
+     settings.remove(USERNAME);
+     settings.remove(USER_ID);
+     settings.remove(SESSION_KEY);
+     settings.remove(SESSION_SECRET);
+     settings.remove(EXPIRES);
+     settings.remove(SIGNATURE);
+
+     emit credentialsChanged(m_loginCredentials);
+ }
index e4c5883..653c2fd 100644 (file)
@@ -82,6 +82,12 @@ public slots:
     */
     void start();
 
+    /**
+    * @brief Clears account iformation from settings
+    *
+    */
+    void clearAccountInformation();
+
 private: 
 
     /**
@@ -145,6 +151,13 @@ signals:
     void credentialsReady(bool freshLogin, const FacebookCredentials &credentials);
 
     /**
+    * @brief Signals changed credentials
+    *
+    * @param credentials New credentials
+    */
+    void credentialsChanged(const FacebookCredentials &credentials);
+
+    /**
     * @brief This signal is emitted if updateCredentials method can't find credentials from URL
     *
     */
index b7e6b33..52f2927 100644 (file)
@@ -87,3 +87,12 @@ bool FacebookCredentials::operator==(const FacebookCredentials &credentials)
 
     return expireBool && sessionKeyBool && sessionSecretBool && sigBool && userIdBool;
 }
+
+void FacebookCredentials::clearCredentials()
+{
+    m_expires.clear();
+    m_sessionKey.clear();
+    m_sessionSecret.clear();
+    m_sig.clear();
+    m_userID.clear();
+}
index 08f48e1..b93378d 100644 (file)
@@ -40,6 +40,12 @@ public:
     FacebookCredentials();
 
     /**
+    * @brief Clears credentials
+    *
+    */
+    void clearCredentials();
+
+    /**
     * @brief Set funtion for m_expires member
     *
     * @param expiresParameter value of parameter is set to m_expires member
index 06c2526..2722075 100644 (file)
@@ -269,13 +269,18 @@ void MapEngine::receiveOwnLocation(User *user)
 {
     qDebug() << __PRETTY_FUNCTION__;
 
-    QPoint newPosition = convertLatLonToSceneCoordinate(user->coordinates());
-    if (m_ownLocation->pos().toPoint() != newPosition) {
-        m_ownLocation->setPos(newPosition);
-    }
+    if(user) {
+        QPoint newPosition = convertLatLonToSceneCoordinate(user->coordinates());
+        if (m_ownLocation->pos().toPoint() != newPosition) {
+            m_ownLocation->setPos(newPosition);
+        }
 
-    if (!m_ownLocation->isVisible())
-        m_ownLocation->show();
+        if (!m_ownLocation->isVisible())
+            m_ownLocation->show();
+    }
+    else {
+        m_ownLocation->hide();
+    }
 }
 
 QGraphicsScene* MapEngine::scene()
index 009b073..a2ee813 100644 (file)
@@ -31,7 +31,8 @@
 #include "ui/avatarimage.h"
 
 SituareService::SituareService(QObject *parent)
-        : QObject(parent)
+        : QObject(parent),
+        m_user(0)
 {
     qDebug() << __PRETTY_FUNCTION__;
 
@@ -43,8 +44,6 @@ SituareService::SituareService(QObject *parent)
     connect(m_imageFetcher, SIGNAL(imageReceived(QUrl,QPixmap)), this,
             SLOT(imageReceived(QUrl, QPixmap)));
     connect(m_imageFetcher, SIGNAL(error(QString)), this, SIGNAL(error(QString)));
-
-    m_user = 0;
 }
 
 SituareService::~SituareService()
@@ -276,7 +275,8 @@ void SituareService::requestFinished(QNetworkReply *reply)
                 emit updateWasSuccessful();
             }
             else {
-                // server error!
+                // session credentials are invalid
+                emit invalidSessionCredentials();
             }
         }
         else {
@@ -289,12 +289,11 @@ void SituareService::requestFinished(QNetworkReply *reply)
     reply->deleteLater();
 }
 
-void SituareService::credentialsReady(bool freshLogin, const FacebookCredentials &credentials)
+void SituareService::credentialsReady(const FacebookCredentials &credentials)
 {
     qDebug() << __PRETTY_FUNCTION__;
-    Q_UNUSED(freshLogin);
-    m_credentials = credentials;
-    
+
+    m_credentials = credentials;    
 }
 
 void SituareService::parseUserData(const QByteArray &jsonReply)
@@ -421,3 +420,18 @@ void SituareService::addProfileImages()
         }
     }
 }
+
+void SituareService::clearUserData()
+{
+    qDebug() << __PRETTY_FUNCTION__;
+
+    qDeleteAll(m_friendsList.begin(), m_friendsList.end());
+    m_friendsList.clear();
+
+    if(m_user) {
+        delete m_user;
+        m_user = 0;
+    }
+
+    emit userDataChanged(m_user, m_friendsList);
+}
index 179d6b8..7d799ac 100644 (file)
@@ -88,23 +88,35 @@ public:
 public slots:
 
     /**
-    * @brief Public slot, which indicates when http request has been completed
+    * @brief Public slot, to clear user data
     *
-    * @param reply storage for http reply
     */
-    void requestFinished(QNetworkReply *reply);
+    void clearUserData();
 
     /**
     * @brief Public slot, which indicates when facebook credentials are ready
     *
-    * @param freshLogin Was login done via login dialog
     * @param credentials New credentials
     */
-    void credentialsReady(bool freshLogin, const FacebookCredentials &credentials);
+    void credentialsReady(const FacebookCredentials &credentials);
+
+    /**
+    * @brief Public slot, which indicates when http request has been completed
+    *
+    * @param reply storage for http reply
+    */
+    void requestFinished(QNetworkReply *reply);
 
 private:
 
     /**
+    * @brief Requests ImageFetcher if user/friend has a profile image
+    *        uses members: m_user and m_friendsList
+    *
+    */
+    void addProfileImages();
+
+    /**
     * @brief Forms a http cookie
     *
     * @param apiKeyValue application key
@@ -128,7 +140,8 @@ private:
     * @param urlParameters optional parameters for url
     * @return QUrl formed url
     */
-    QUrl formUrl(const QString &baseUrl, const QString &phpScript, QString urlParameters = QString());
+    QUrl formUrl(const QString &baseUrl, const QString &phpScript,
+                 QString urlParameters = QString());
 
     /**
     * @brief Forms url parameters
@@ -138,7 +151,8 @@ private:
     * @param publish optional publish location on Facebook wall (true/false)
     * @return QString
     */
-    QString formUrlParameters(const QPointF &coordinates, QString status = QString(), QString publish = QString());
+    QString formUrlParameters(const QPointF &coordinates, QString status = QString(),
+                              QString publish = QString());
 
     /**
     * @brief Parses user and friend data from JSON string
@@ -156,13 +170,6 @@ private:
     */
     void sendRequest(const QUrl &url, const QString &cookieType, const QString &cookie);
 
-    /**
-    * @brief Requests ImageFetcher if user/friend has a profile image
-    *        uses members: m_user and m_friendsList
-    *
-    */
-    void addProfileImages();
-
 private slots:
 
     /**
@@ -194,6 +201,12 @@ signals:
     void fetchImage(const QUrl &url);
 
     /**
+    * @brief Signals when credentials are invalid
+    *
+    */
+    void invalidSessionCredentials();
+
+    /**
     * @brief Signals when address data is retrieved
     *
     * @param address Street address
@@ -220,16 +233,22 @@ signals:
 
 private:
 
-    FacebookCredentials m_credentials; ///< handle for FacebookCredentials
-    QList<QNetworkReply *> m_currentRequests; ///< List of current http requests
-    QNetworkAccessManager *m_networkManager; ///< Pointer to QNetworkAccessManager
-    ImageFetcher *m_imageFetcher; ///< Instance of the image fetcher
+    int m_nbrOfImages;      ///< Indicates number of friends whose images has been downloaded
+    int m_visited;          ///< Indicates number of friends with images
+
+    bool m_defaultImage;    ///< Indicates if some of the friends/user doesn't have a image
+
+    QList<QNetworkReply *> m_currentRequests;   ///< List of current http requests
+    QList<User *> m_friendsList;                ///< List of friends(User)
+
+    QNetworkAccessManager *m_networkManager;    ///< Pointer to QNetworkAccessManager
+
+    FacebookCredentials m_credentials;          ///< handle for FacebookCredentials
+    ImageFetcher *m_imageFetcher;               ///< Instance of the image fetcher
+    User *m_user;                               ///< Pointer to User
+
+
 
-    User *m_user; ///< Pointer to User
-    QList<User *> m_friendsList; ///< List of friends(User)
-    int m_visited; ///< Indicates number of friends with profile images
-    int m_nbrOfImages; ///< Indicates number of friends whose profile images have been downloaded
-    bool m_defaultImage; ///< Indicates if some of the friends or the user does not have a profile image
 };
 
 #endif // SITUARESERVICE_H
index 6cadf64..9aa66b7 100644 (file)
@@ -73,3 +73,14 @@ void LoginDialog::setEmailField(const QString &email)
         m_passwordEdit->setFocus(Qt::OtherFocusReason);
     }
 }
+
+void LoginDialog::clearTextFields()
+{
+    qDebug() << __PRETTY_FUNCTION__;
+
+    m_passwordEdit->clearFocus();
+    m_emailEdit->setText(""); // clear() method bugging in Qt 4.6.0, it leaves "dead" cursor
+    m_emailEdit->setFocus(Qt::OtherFocusReason);
+    m_passwordEdit->setText("");
+
+}
index a518c7f..50a9046 100644 (file)
@@ -61,6 +61,12 @@ public slots:
     */
     void setEmailField(const QString &email);
 
+    /**
+    * @brief Clears line edits
+    *
+    */
+    void clearTextFields();
+
 private slots:
 
     /**
index 125dee1..cdd70f9 100644 (file)
@@ -34,7 +34,6 @@
 #include "friendlistpanel.h"
 #include "logindialog.h"
 #include "map/mapview.h"
-#include "panelsidebar.h"
 #include "settingsdialog.h"
 #include "userinfopanel.h"
 #include "zoombuttonpanel.h"
@@ -52,6 +51,7 @@ const int N900_APP_HEIGHT = 449;
 MainWindow::MainWindow(QWidget *parent)
     : QMainWindow(parent),
     m_drawOwnLocationCrosshair(false),
+    m_loggedIn(false),
     m_refresh(false),
     m_email(),    
     m_password(),
@@ -104,9 +104,9 @@ void MainWindow::buildFriendListPanel()
     qDebug() << __PRETTY_FUNCTION__;
 
     m_friendsListPanel = new FriendListPanel(this);
-    PanelSideBar *friendsListPanelSidebar = new PanelSideBar(this, RIGHT);
+    m_friendsListPanelSidebar = new PanelSideBar(this, RIGHT);
 
-    m_friendsListPanel->stackUnder(friendsListPanelSidebar);
+    m_friendsListPanel->stackUnder(m_friendsListPanelSidebar);
 
     connect(this, SIGNAL(friendsLocationsReady(QList<User*>&)),
             m_friendsListPanel, SLOT(friendInfoReceived(QList<User*>&)));
@@ -118,7 +118,7 @@ void MainWindow::buildFriendListPanel()
             m_friendsListPanel, SLOT(screenResized(QSize)));
 
     connect(m_mapView, SIGNAL(viewResizedNewSize(int, int)),
-            friendsListPanelSidebar, SLOT(reDrawSidebar(int, int)));
+            m_friendsListPanelSidebar, SLOT(reDrawSidebar(int, int)));
 }
 
 void MainWindow::buildManualLocationCrosshair()
@@ -188,10 +188,10 @@ void MainWindow::buildUserInfoPanel()
     qDebug() << __PRETTY_FUNCTION__;
 
     m_userPanel = new UserInfoPanel(this);
-    PanelSideBar *userPanelSidebar = new PanelSideBar(this, LEFT);
+    m_userPanelSidebar = new PanelSideBar(this, LEFT);
 
-    userPanelSidebar->stackUnder(m_friendsListPanel);
-    m_userPanel->stackUnder(userPanelSidebar);
+    m_userPanelSidebar->stackUnder(m_friendsListPanel);
+    m_userPanel->stackUnder(m_userPanelSidebar);
 
     connect(this, SIGNAL(userLocationReady(User*)),
             m_userPanel, SLOT(userDataReceived(User*)));
@@ -239,6 +239,11 @@ void MainWindow::createMenus()
 {
     qDebug() << __PRETTY_FUNCTION__;
 
+    // login/logout
+    m_loginAct = new QAction(tr("Login"), this);
+    connect(m_loginAct, SIGNAL(triggered()),
+            this, SIGNAL(loginPressed()));
+
     // settings
     m_toSettingsAct = new QAction(tr("Settings"), this);
     m_toSettingsAct->setObjectName(tr("Settings"));
@@ -260,6 +265,7 @@ void MainWindow::createMenus()
 
     // build the actual menu
     m_viewMenu = menuBar()->addMenu(tr("Main"));
+    m_viewMenu->addAction(m_loginAct);
     m_viewMenu->addAction(m_toSettingsAct);
     m_viewMenu->addAction(m_gpsToggleAct);
     m_viewMenu->addAction(m_autoCenteringAct);
@@ -388,6 +394,23 @@ void MainWindow::loadDone(bool done)
     }
 }
 
+void MainWindow::loggedIn(bool logged)
+{
+    qDebug() << __PRETTY_FUNCTION__;
+
+    m_loggedIn = logged;
+
+    if(m_loginAct) {
+        if(logged) {
+            m_loginAct->setText(tr("Logout"));
+        }
+        else {
+            m_loginAct->setText(tr("Login"));
+        }
+        showPanels(m_loggedIn);
+    }
+}
+
 void MainWindow::loginDialogDone(const QString &email, const QString &password)
 {
     qDebug() << __PRETTY_FUNCTION__;
@@ -438,6 +461,9 @@ void MainWindow::openSettingsDialog()
     qDebug() << __PRETTY_FUNCTION__;
 
     SettingsDialog *dialog = new SettingsDialog(this);
+    if(!m_loggedIn) {
+        dialog->disableSituareSettings();
+    }
     dialog->show();
 }
 
@@ -504,6 +530,24 @@ void MainWindow::showMaemoInformationBox(const QString &message)
 #endif
 }
 
+void MainWindow::showPanels(bool show)
+{
+    qDebug() << __PRETTY_FUNCTION__;
+    if(show) {
+        // ToDo: opening panels when needed
+        m_friendsListPanel->show();
+        m_friendsListPanelSidebar->show();
+        m_userPanel->show();
+        m_userPanelSidebar->show();
+    }
+    else {
+        m_friendsListPanel->hide();
+        m_friendsListPanelSidebar->hide();
+        m_userPanel->hide();
+        m_userPanelSidebar->hide();
+    }
+}
+
 void MainWindow::startLoginProcess(const QUrl &url)
 {
     qDebug() << __PRETTY_FUNCTION__;
index c7a4fea..ebeb9d4 100644 (file)
@@ -27,6 +27,8 @@
 #include <QtGui/QMainWindow>
 #include <QUrl>
 
+#include "panelsidebar.h"
+
 class QGraphicsScene;
 class QLabel;
 class QWebView;
@@ -76,6 +78,13 @@ private:
  ******************************************************************************/
 public:
     /**
+    * @brief
+    *
+    * @param logged
+    */
+    void loggedIn(bool logged);
+
+    /**
     * @brief Enable / disable auto centering button.
     *
     * @param enabled true if shoud be enabled, false otherwise
@@ -140,6 +149,13 @@ public slots:
     void setUsername(const QString &username);
 
     /**
+    * @brief
+    *
+    * @param show
+    */
+    void showPanels(bool show);
+
+    /**
     * @brief Public slot to intercept signal when old cerdentials are invalid or credentials
     *        doesn't exist yet
     *
@@ -301,6 +317,12 @@ signals:
     void friendsLocationsReady(QList<User *> &friendsList);
 
     /**
+    * @brief Signals when Login/Logout action is pressed
+    *
+    */
+    void loginPressed();
+
+    /**
     * @brief MapView has been resized
     *
     * @param size view size
@@ -391,6 +413,7 @@ signals:
 private:
 
     bool m_drawOwnLocationCrosshair;        ///< Flag for making ownLocationCrosshair visible or not
+    bool m_loggedIn;                        ///< Indicates login state
     bool m_refresh;                         ///< Indicates when webpage is refreshed
 
     int m_viewPortHeight;                   ///< Height of view port
@@ -398,6 +421,7 @@ private:
 
     QAction *m_autoCenteringAct;            ///< Action to auto center map using gps position
     QAction *m_gpsToggleAct;                ///< Action to trigger gps toggle
+    QAction *m_loginAct;                    ///< Action to Login/Logout
     QAction *m_toSettingsAct;               ///< Action to trigger switch to settings dialog
 
     QLabel *m_osmLicense;                   ///< Label for Open Street Map license
@@ -415,6 +439,8 @@ private:
     FriendListPanel *m_friendsListPanel;    ///< Instance of friends list panel
     LoginDialog *m_loginDialog;             ///< Login dialog
     MapView *m_mapView;                     ///< Instance of the map view
+    PanelSideBar *m_userPanelSidebar;       ///< User panel side bar
+    PanelSideBar *m_friendsListPanelSidebar;///< Friends panel side bar
     UserInfoPanel *m_userPanel;             ///< Instance of the user information panel
     ZoomButtonPanel *m_zoomButtonPanel;     ///< Instance of zoom button panel
 };
index 98d0d1f..3590523 100644 (file)
@@ -76,8 +76,15 @@ void SettingsDialog::dialogFinished(int /* reason */)
 void SettingsDialog::saveValues()
 {
     qDebug() << __PRETTY_FUNCTION__;
-//    QSettings settings(DIRECTORY_NAME, FILE_NAME);
-//    settings.setValue(AUTOMATIC_LOCATION_UPDATE, m_automaticLocationUpdate->isChecked());
+
+    QSettings settings(DIRECTORY_NAME, FILE_NAME);
+    settings.setValue(AUTOMATIC_LOCATION_UPDATE, m_automaticLocationUpdate->isChecked());
     accept();
+}
+
+void SettingsDialog::disableSituareSettings()
+{
+    qDebug() << __PRETTY_FUNCTION__;
 
+    m_automaticLocationUpdate->setDisabled(true);
 }
index a4681e9..1224129 100644 (file)
@@ -48,6 +48,12 @@ public:
     */
     ~SettingsDialog();
 
+    /**
+    * @brief Disables Situare related settings from settings dialog
+    *
+    */
+    void disableSituareSettings();
+
 /*******************************************************************************
 * MEMBER FUNCTIONS AND SLOTS
 ******************************************************************************/
index 66a9a2a..7d76313 100644 (file)
@@ -46,11 +46,13 @@ UserInfoPanel::UserInfoPanel(QWidget *parent)
 
 void UserInfoPanel::userDataReceived(User *user)
 {
-    qDebug() << __PRETTY_FUNCTION__ << " " << user->name();
+    qDebug() << __PRETTY_FUNCTION__;
 
-    m_userInfo->setUserName(user->name());
-    m_userInfo->setAvatar(user->profileImage());
-    m_userInfo->setMessageText(user->note());
-    m_userInfo->setAddress(user->address());
-    m_userInfo->setTime(user->timestamp());
+    if(user) {
+        m_userInfo->setUserName(user->name());
+        m_userInfo->setAvatar(user->profileImage());
+        m_userInfo->setMessageText(user->note());
+        m_userInfo->setAddress(user->address());
+        m_userInfo->setTime(user->timestamp());
+    }
 }