Merge branch 'master' into situare_interact
[situare] / src / ui / mainwindow.h
index a056ae4..ee71579 100644 (file)
@@ -28,6 +28,7 @@
 #define MAINWINDOW_H
 
 #include <QtGui/QMainWindow>
+#include <QSslError>
 #include <QUrl>
 
 //Remove this
@@ -37,6 +38,7 @@
 #include "situareservice/message.h"
 #include "network/networkcookiejar.h"
 
+class QDialog;
 class QGraphicsScene;
 class QLabel;
 class QMessageBox;
@@ -44,7 +46,6 @@ class QNetworkReply;
 class QToolButton;
 class QWebView;
 
-class FacebookAuthentication;
 class FriendListPanel;
 class FullScreenButton;
 class GeoCoordinate;
@@ -62,6 +63,7 @@ class SceneCoordinate;
 class SettingsDialog;
 class SituareService;
 class TabbedPanel;
+class UpdateLocation;
 class User;
 class UserInfoPanel;
 class ZoomButtonPanel;
@@ -100,10 +102,11 @@ private:
  ******************************************************************************/
 public:
     /**
-     * @brief Clears cookie jar
-     *
-     */
-    void clearCookieJar();
+      * @brief Build and show login dialog with login browser
+      *
+      * @param browser Login browser instance
+      */
+    void buildLoginDialog(QWebView *browser);
 
     /**
      * @brief
@@ -113,13 +116,6 @@ public:
     void loggedIn(bool logged);
 
     /**
-     * @brief Gets the login state (logged in/logged out)
-     *
-     * @return bool Login state
-     */
-    bool loginState();
-
-    /**
      * @brief Reads automatic location update settings.
      */
     void readAutomaticLocationUpdateSettings();
@@ -154,13 +150,6 @@ public:
      */
     void showEnableAutomaticUpdateLocationDialog(const QString &text);
 
-    /**
-     * @brief Gets the username from member variable for saving purposes
-     *
-     * @return QString Username
-     */
-    const QString username();
-
 public slots:
     /**
      * @brief Builds information box with message.
@@ -171,14 +160,9 @@ public slots:
     void buildInformationBox(const QString &message, bool modal=false);
 
     /**
-     * @brief Slot for failed login
-     */
-    void loginFailed();
-
-    /**
-     * @brief Slot to intercept signal when login with cookies is requested
-     */
-    void loginUsingCookies();
+      * @brief Hides and deletes login dialog
+      */
+    void destroyLoginDialog();
 
     /**
      * @brief Public slot, which open settings dialog
@@ -193,13 +177,6 @@ public slots:
     void setCrosshairVisibility(bool visible);
 
     /**
-     * @brief Sets username to member variable for login dialog
-     *
-     * @param username Username to be set
-     */
-    void setUsername(const QString &username);
-
-    /**
     * @brief Shows contact dialog.
     *
     * Shows contact dialog with contact's information.
@@ -215,12 +192,6 @@ public slots:
     void showMessageDialog(const QPair<QString, QString> &receiver);
 
     /**
-     * @brief Public slot to intercept signal when old cerdentials are invalid or credentials
-     *        doesn't exist yet
-     */
-    void startLoginProcess();
-
-    /**
      * @brief Toggle progress indicator.
      *
      * @param state true if progress indicator should be shown, false otherwise
@@ -228,10 +199,11 @@ public slots:
     void toggleProgressIndicator(bool state);
 
     /**
-     * @brief Shows / hides Situare related UI items
+     * @brief Shows / hides Situare related UI items based on login state
      *
+     * @param loggedIn Is the user currently logged in
      */
-    void updateItemVisibility();
+    void updateItemVisibility(bool loggedIn);
 
 private:
     /**
@@ -300,11 +272,6 @@ private:
     void buildUserInfoPanel();
 
     /**
-     * @brief Build webview and connect slots
-     */
-    void buildWebView();
-
-    /**
      * @brief Build zoom button panel and connect slots
      */
     void buildZoomButtonPanel();
@@ -392,18 +359,6 @@ 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
-     */
-    void loadDone(bool done);
-
-    /**
     * @brief Called when map center point horizontal shifting is changed
     *
     * @param shifting New shifting value
@@ -416,14 +371,14 @@ private slots:
     void moveCrosshair();
 
     /**
-     * @brief Slot to save cookies to settings
+     * @brief Slot for settings dialog accepted.
      */
-    void saveCookies();
+    void settingsDialogAccepted();
 
     /**
-     * @brief Slot for settings dialog accepted.
+     * @brief Show update location dialog
      */
-    void settingsDialogAccepted();
+    void showUpdateLocationDialog();
 
     /**
      * @brief Start location search (open search dialog)
@@ -441,13 +396,6 @@ private slots:
     void toggleFullScreen();
 
     /**
-     * @brief Slot to intercept signal from webview's networkaccessmanager
-     *
-     * @param reply Network reply (contains errors)
-     */
-    void webViewRequestFinished(QNetworkReply* reply);
-
-    /**
      * REMOVE THIS, FIXES WEBVIEW BUG IN SCRATCHBOX
      */
     void sslErrors(QNetworkReply *reply, const QList<QSslError> &errors);
@@ -471,12 +419,6 @@ signals:
     void autoCenteringTriggered(bool enabled);
 
     /**
-     * @brief Signal that indicates when user has cancelled login process
-     *
-     */
-    void cancelLoginProcess();
-
-    /**
      * @brief Signal for centering to coordinates.
      *
      * @param coordinates geo coordinates to center to.
@@ -522,12 +464,6 @@ signals:
     void error(const int context, const int error);
 
     /**
-     * @brief Signal for requesting username from settings
-     *
-     */
-    void fetchUsernameFromSettings();
-
-    /**
      * @brief Signals when friend's profile image is ready
      *
      * @param user Friend
@@ -587,6 +523,14 @@ signals:
     void locationItemClicked(const GeoCoordinate &swBound, const GeoCoordinate &neBound);
 
     /**
+    * @brief Send location update
+    *
+    * @param status Status message
+    * @param publish Publish on Facebook?
+    */
+    void locationUpdate(const QString &status, bool publish);
+
+    /**
      * @brief Signals when Login/Logout action is pressed
      *
      */
@@ -713,13 +657,6 @@ signals:
     void routeToCursor();
 
     /**
-     * @brief Signal to save username to settings
-     *
-     * @param username Username
-     */
-    void saveUsername(const QString &username);
-
-    /**
      * @brief Signal for location search
      *
      * @param location QString location
@@ -743,21 +680,6 @@ signals:
     void sendMessage(const QString &receiverId, const QString &message, bool addCoordinates);
 
     /**
-     * @brief Signal for requestLocationUpdate from SituareEngine
-     *
-     * @param status Status message
-     * @param publish Publish on Facebook
-     */
-    void statusUpdate(const QString &status, const bool &publish);
-
-    /**
-     * @brief Signals when webview's urlChanged signal is emitted
-     *
-     * @param url New url
-     */
-    void updateCredentials(const QUrl &url);
-
-    /**
     * @brief Signals when image is downloaded
     *
     * @param id image ID
@@ -766,12 +688,6 @@ signals:
     void userImageReady(const QString &id, const QPixmap &image);
 
     /**
-     * @brief Signals when updateLocationDialog's data must be cleared
-     *
-     */
-    void clearUpdateLocationDialogData();
-
-    /**
     * @brief Dragging mode triggered.
     */
     void draggingModeTriggered();
@@ -794,6 +710,11 @@ signals:
     void requestMessages();
 
     /**
+    * @brief Signals when updateLocation request finished successfully
+    */
+    void updateWasSuccessful();
+
+    /**
      * @brief Signal for use location ready.
      *
      * @param user User object
@@ -830,6 +751,8 @@ private:
     QAction *m_loginAct;                    ///< Action to Login/Logout
     QAction *m_toSettingsAct;               ///< Action to trigger switch to settings dialog
 
+    QDialog *m_loginDialog;                 ///< Login dialog
+
     QLabel *m_crosshair;                    ///< Label for center point crosshair
     QLabel *m_osmLicense;                   ///< Label for Open Street Map license
 
@@ -841,11 +764,6 @@ private:
 
     QMessageBox *m_automaticUpdateLocationDialog;   ///< Automatic update location dialog
 
-    QString m_email;                        ///< Placeholder for email
-    QString m_password;                     ///< Placeholder for password
-
-    QWebView *m_webView;                    ///< Shows facebook login page
-
     FriendListPanel *m_friendsListPanel;    ///< Instance of friends list panel
     FullScreenButton *m_fullScreenButton;   ///< Instance of the fullscreen toggle button
     IndicatorButtonPanel *m_indicatorButtonPanel;   ///< Instance of direction indicator button
@@ -853,10 +771,10 @@ private:
     MapScale *m_mapScale;                   ///< Instance of the map scale
     MapView *m_mapView;                     ///< Instance of the map view
     MeetPeoplePanel *m_meetPeoplePanel;     ///< Instance of MeetPeoplePanel
-    NetworkCookieJar *m_cookieJar;          ///< Placeholder for QNetworkCookies
     MessagePanel *m_messagePanel;          ///< Instance of MessagePanel
     RoutingPanel *m_routingPanel;           ///< Instance of routing panel
     TabbedPanel *m_tabbedPanel;             ///< Widget for tabbed panels
+    UpdateLocation *m_updateLocationController;     ///< Controller for update location dialog
     UserInfoPanel *m_userInfoPanel;         ///< Instance of the user information panel
     ZoomButtonPanel *m_zoomButtonPanel;     ///< Instance of zoom button panel
 };