Power save mode review and iteration.
[situare] / src / gps / gpspositionprivateliblocation.h
index 89dfa2e..eae5141 100644 (file)
@@ -27,6 +27,7 @@
 #include "gpsposition.h"
 #include "geopositioninfo.h"
 
+class QTimer;
 class LiblocationWrapper;
 
 /**
@@ -49,6 +50,13 @@ public:
 ******************************************************************************/
 public:
     /**
+    * @brief Returns is GPS initialized.
+    *
+    * @return true if initialized, false otherwise
+    */
+    bool isInitialized();
+
+    /**
     * @brief Checks if GPS is running.
     *
     * @return true if GPS running, false otherwise
@@ -66,6 +74,13 @@ public:
     void requestLastPosition();
 
     /**
+    * @brief Requests update from GPS.
+    *
+    * Enables GPS if it is disabled
+    */
+    void requestUpdate();
+
+    /**
     * @brief Set GPS mode.
     *
     * Modes: default and simulation.
@@ -75,6 +90,13 @@ public:
     void setMode(GPSPosition::Mode mode, const QString &filePath = 0);
 
     /**
+    * @brief Sets power save mode.
+    *
+    * Starts GPS for position update and then stops it.
+    */
+    void setPowerSave(bool enabled);
+
+    /**
     * @brief Set GPS update interval
     *
     * @return interval interval in milliseconds
@@ -102,6 +124,10 @@ private:
     qreal accuracy(const GeoPositionInfo &positionInfo);
 
 private slots:
+    /**
+    * @brief Start power save.
+    */
+    void delayedPowerSaveStart();
 
     /**
     * @brief Slot for received position update.
@@ -123,8 +149,11 @@ private slots:
 private:
     LiblocationWrapper *m_liblocationWrapper;    ///< Liblocation wrapper object
     GPSPosition *m_parent;                      ///< Parent object
+    bool m_initialized;                         ///< GPS is initialized
+    bool m_powerSave;                           ///< Power save flag
     bool m_running;                             ///< GPS is running
     int m_updateInterval;                       ///< GPS update interval
+    QTimer *m_delayedPowerSaveTimer;            ///< Delayed power save timer
 };
 
 const int DEFAULT_UPDATE_INTERVAL = 5000;       ///< Default update interval