Power save mode review and iteration.
[situare] / src / engine / engine.h
index cf087ca..fd66a99 100644 (file)
@@ -39,6 +39,7 @@ class MainWindow;
 class MapEngine;
 class SituareService;
 class User;
+class MCE;
 
 class QTimer;
 
@@ -73,7 +74,7 @@ public slots:
     *
     * @param error Error message
     */
-    void error(const QString &error);
+    void error(const int error);
 
     /**
     * @brief Slot to intercept signal when username is fetched from settings
@@ -90,10 +91,8 @@ 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, const FacebookCredentials &credentials);
+    void loginOk();
 
     /**
     * @brief Slot to intercept signal when user has cancelled login process
@@ -143,11 +142,10 @@ public slots:
 
 private:
     /**
-    * @brief Checks if user is moved enough for position auto update.
-    *
-    * @return true if moved engouh, false otherwise
+    * @brief Read settings and determine whether to use GPS and autocentering.
+    * When values does not found on the settings, GPS and autocentering are enabled as a default.
     */
-    bool isUserMoved();
+    void initializeGpsAndAutocentering();
 
     /**
       * @brief Connect signals coming from Facdebook authenticator
@@ -180,20 +178,26 @@ private:
     void signalsFromSituareService();
 
 private slots:
-
-    void automaticUpdateIntervalTimerTimeout();
-
     /**
-      * @brief Set auto centering feature enabled / disabled
-      */
+    * @brief Set auto centering feature enabled / disabled
+    *
+    * @param enabled true if enabled, false otherwise
+    */
     void changeAutoCenteringSetting(bool enabled);
 
     /**
-      * @brief Slot for disabling automatic centering when map is scrolled manually
-      */
+    * @brief Slot for disabling automatic centering when map is scrolled manually
+    */
     void disableAutoCentering();
 
     /**
+    * @brief Slot for display state changed.
+    *
+    * @param enabled true if enabled, false otherwise
+    */
+    void displayStateChanged(bool enabled);
+
+    /**
     * @brief Slot for auto centering enabling.
     *
     * Calls gps to send last known position
@@ -210,32 +214,56 @@ private slots:
     void enableGPS(bool enabled);
 
     /**
-    * @brief Slot for intercepting signal when credentials are invalid
+    * @brief Enables automatic location update.
     *
+    * @param enabled true if enabled, false otherwise
+    * @param updateIntervalMsecs update interval in milliseconds
     */
-    void invalidCredentials();
+    void enableAutomaticLocationUpdate(bool enabled, int updateIntervalMsecs = 0);
 
     /**
-    * @brief Saves GPS position.
+    * @brief Requests automatic update.
     *
-    * Saves GPS position if it has changed enough and sets m_userMoved flag.
+    * Makes automatic location update request if user has moved enough.
     *
     * @param position geo coordinates
     */
-    void saveGPSPosition(QPointF position);
+    void requestAutomaticUpdateIfMoved(QPointF position);
 
     /**
-    * @brief Enables automatic location update.
+     * @brief Sets zoom level to default when first GPS location is received if autocentering
+     * is enabled.
+     *
+     * @param latLonCoordinate own location
+     * @param accuracy accuracy of GPS location
+     */
+    void setFirstStartZoomLevel(QPointF latLonCoordinate, qreal accuracy);
+
+    /**
+    * @brief Automatic update interval timer timeout.
     *
-    * @param enabled true if
+    * Requests update location if user has moved.
     */
-    void enableAutomaticLocationUpdate(bool enabled, int updateIntervalMsecs = -1);
+    void startAutomaticUpdate();
 
 /*******************************************************************************
  * SIGNALS
  ******************************************************************************/
 signals:
     /**
+    * @brief Signals when automatic location update was enabled.
+    *
+    * @param enabled true if enabled, false otherwise
+    */
+    void automaticLocationUpdateEnabled(bool enabled);
+
+    /**
+    * @brief Signal to clear locationUpdateDialog's data
+    *
+    */
+    void clearUpdateLocationDialogData();
+
+    /**
     * @brief Signals when new friends data is ready
     *
     * @param friendList List of User instances (friends)
@@ -253,18 +281,21 @@ signals:
  * DATA MEMBERS
  ******************************************************************************/
 private:
-    bool m_autoCenteringEnabled;  ///< Auto centering enabled
-    bool m_loggedIn;              ///< Login state
+    bool m_autoCenteringEnabled;        ///< Auto centering flag
+    bool m_automaticUpdateFirstStart;   ///< Automatic location update first start flag
+    bool m_automaticUpdateRequest;      ///< Flag for automatic update request
+    bool m_userMoved;                   ///< Flag for user move
+
 
     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
+    MCE *m_mce;                        ///< Instance of the MCE
 
     QTimer *m_automaticUpdateIntervalTimer; ///< Automatic update interval timer
     QPointF m_lastUpdatedGPSPosition;       ///< Last updated GPS position
-    bool m_userMoved;                       ///< Flag for user moving
 };
 
 #endif // ENGINE_H