Fixed GPS/manual states when logging in
[situare] / src / ui / mainwindow.h
index c7a4fea..c8b1231 100644 (file)
 #include <QtGui/QMainWindow>
 #include <QUrl>
 
+#include "network/networkcookiejar.h"
+#include "panelsidebar.h"
+
 class QGraphicsScene;
 class QLabel;
 class QWebView;
 
 class FacebookAuthentication;
 class FriendListPanel;
-class LoginDialog;
 class MapScene;
 class MapView;
 class SituareService;
@@ -76,6 +78,19 @@ private:
  ******************************************************************************/
 public:
     /**
+    * @brief Clears cookie jar
+    *
+    */
+    void clearCookieJar();
+
+    /**
+    * @brief
+    *
+    * @param logged
+    */
+    void loggedIn(bool logged);
+
+    /**
     * @brief Enable / disable auto centering button.
     *
     * @param enabled true if shoud be enabled, false otherwise
@@ -101,9 +116,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
@@ -113,19 +129,18 @@ public:
     const QString username();
 
 public slots:
+
     /**
-    * @brief Slot to intercept signal when user has pressed connect button from loginDialog
+    * @brief Slot to intercept signal when login has failed (loginFailure signal)
     *
-    * @param email E-mail
-    * @param password Password
     */
-    void loginDialogDone(const QString &email, const QString &password);
+    void loginFailed();
 
     /**
-    * @brief Slot to intercept signal when login has failed (loginFailure signal)
+    * @brief Slot to intercept signal when login with cookies is requested
     *
     */
-    void loginFailed();
+    void loginUsingCookies();
 
     /**
     * @brief Public slot, which open settings dialog
@@ -154,6 +169,13 @@ public slots:
     */
     void toggleProgressIndicator(bool state);
 
+    /**
+    * @brief Shows / hides Situare related UI items
+    *
+    * @param show
+    */
+    void updateItemVisibility(bool show);
+
 private:
     /**
       * @brief Build friend list panel and connect slots
@@ -181,6 +203,12 @@ private:
     void buildUserInfoPanel();
 
     /**
+    * @brief Build webview and connect slots
+    *
+    */
+    void buildWebView();
+
+    /**
       * @brief Build zoom button panel and connect slots
       */
     void buildZoomButtonPanel();
@@ -235,6 +263,12 @@ private slots:
     void gpsTimeout();
 
     /**
+    * @brief Slot to load cookies from settings
+    *
+    */
+    void loadCookies();
+
+    /**
     * @brief Slot to intercept signal when webview has finished loading webpage
     *
     * @param done Status of the loading
@@ -242,6 +276,12 @@ private slots:
     void loadDone(bool done);
 
     /**
+    * @brief Slot to save cookies to settings
+    *
+    */
+    void saveCookies();
+
+    /**
     * @brief Set correnct view port size to datamembers
     *
     * @param width Width of the viewport
@@ -280,6 +320,13 @@ signals:
     void fetchUsernameFromSettings();
 
     /**
+    * @brief Signal for finding user.
+    *
+    * @param coordinates user geo coordinates
+    */
+    void findUser(const QPointF &coordinates);
+
+    /**
     * @brief GPS setting changed
     *
     * @param enabled True if GPS is enabled, otherwise false
@@ -301,6 +348,19 @@ signals:
     void friendsLocationsReady(QList<User *> &friendsList);
 
     /**
+    * @brief Signal is emitted when location item is clicked.
+    *
+    * @param userIDs list of friends user IDs in the group
+    */
+    void locationItemClicked(const QList<QString> &userIDs);
+
+    /**
+    * @brief Signals when Login/Logout action is pressed
+    *
+    */
+    void loginActionPressed();
+
+    /**
     * @brief MapView has been resized
     *
     * @param size view size
@@ -391,6 +451,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 +459,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
@@ -408,13 +470,13 @@ private:
     QString m_email;                        ///< Placeholder for email
     QString m_password;                     ///< Placeholder for password
 
-    QUrl m_loginUrl;                        ///< Placeholder for login page url
-
     QWebView *m_webView;                    ///< Shows facebook login page
 
     FriendListPanel *m_friendsListPanel;    ///< Instance of friends list panel
-    LoginDialog *m_loginDialog;             ///< Login dialog
     MapView *m_mapView;                     ///< Instance of the map view
+    NetworkCookieJar *m_cookieJar;          ///< Placeholder for QNetworkCookies
+    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
 };