Added coordinates to sendMessage.
[situare] / src / engine / engine.h
index c5ae5a4..2cd2341 100644 (file)
 
 #include <QObject>
 #include <QTime>
-#include <QPointF>
+#include <QPair>
 
-class QMainWindow;
+#include "coordinates/geocoordinate.h"
+#include "situareservice/situareservice.h"
 
+class QTimer;
+
+class Application;
+class ContactManager;
 class FacebookAuthentication;
 class FacebookCredentials;
+class GeocodingService;
 class GPSPosition;
+class Location;
 class MainWindow;
 class MapEngine;
+class MCE;
+class NetworkAccessManager;
+class Route;
+class RoutingService;
 class SituareService;
 class User;
-class MCE;
-
-class QTimer;
 
 /**
 * @brief Engine class for Situare Application
@@ -56,9 +64,8 @@ public:
     /**
     * @brief Constructor
     *
-    * @param parent
     */
-    SituareEngine(QMainWindow *parent = 0);
+    SituareEngine();
 
     /**
     * @brief Destructor
@@ -72,9 +79,10 @@ public slots:
     /**
     * @brief Slot to intercept error signal from ImageFetcher and SituareService
     *
+    * @param context Error context
     * @param error Error message
     */
-    void error(const int error);
+    void error(const int context, const int error);
 
     /**
     * @brief Slot to intercept signal when username is fetched from settings
@@ -83,6 +91,13 @@ public slots:
     void fetchUsernameFromSettings();
 
     /**
+    * @brief Slot to intercept signal when location search is issued
+    *
+    * @param location QString location
+    */
+    void locationSearch(QString location);
+
+    /**
     * @brief Slot to intercept signal when Login/Logout action is pressed
     *
     */
@@ -128,8 +143,9 @@ public slots:
     /**
     * @brief Slot to intercept signal from successful location update
     *
+    * @param successfulMethod which method was successful
     */
-    void updateWasSuccessful();
+    void updateWasSuccessful(SituareService::SuccessfulMethod successfulMethod);
 
     /**
     * @brief Slot to intercept signal when new user data is available.
@@ -148,11 +164,16 @@ private:
     void initializeGpsAndAutocentering();
 
     /**
-      * @brief Connect signals coming from Facdebook authenticator
+      * @brief Connect signals coming from Facebook authenticator
       */
     void signalsFromFacebookAuthenticator();
 
     /**
+      * @brief Connect signals coming from GeocodingService
+      */
+    void signalsFromGeocodingService();
+
+    /**
       * @brief Connect signals coming from GPS
       */
     void signalsFromGPS();
@@ -173,19 +194,17 @@ private:
     void signalsFromMapView();
 
     /**
+      * @brief Connect signals coming from RoutingService
+      */
+    void signalsFromRoutingService();
+
+    /**
       * @brief Connect signals coming from Situare
       */
     void signalsFromSituareService();
 
 private slots:
     /**
-    * @brief Automatic update interval timer timeout.
-    *
-    * Requests update location if user has moved.
-    */
-    void automaticUpdateIntervalTimerTimeout();
-
-    /**
     * @brief Set auto centering feature enabled / disabled
     *
     * @param enabled true if enabled, false otherwise
@@ -198,53 +217,132 @@ private slots:
     void disableAutoCentering();
 
     /**
-    * @brief Slot for auto centering enabling.
+    * @brief Calls vibration feedback.
+    */
+    void draggingModeTriggered();
+
+    /**
+    * @brief Enables automatic location update.
+    *
+    * @param enabled true if enabled, false otherwise
+    * @param updateIntervalMsecs update interval in milliseconds
+    */
+    void enableAutomaticLocationUpdate(bool enabled, int updateIntervalMsecs = 0);
+
+    /**
+    * @brief Slot for image ready
+    *
+    * @param id image ID
+    * @param image image pixmap
+    */
+    void imageReady(const QString &id, const QPixmap &image);
+
+    /**
+    * @brief Requests automatic update.
+    *
+    * Makes automatic location update request if user has moved enough.
+    *
+    * @param position geo coordinates
+    */
+    void requestAutomaticUpdateIfMoved(GeoCoordinate position);
+
+    /**
+    * @brief Requests interesting people from current map viewport.
+    *
+    * Interesting people is defined by people with same tags as user has.
+    */
+    void requestInterestingPeople();
+
+    /**
+    * @brief Route is parsed and is ready for further processing.
+    *
+    * @param route Route item containing parsed route details
+    */
+    void routeParsed(Route &route);
+
+    /**
+    * @brief Routes to geo coordinates.
+    *
+    * Uses map center coordinates as start point.
+    * @param endPointCoordinates end point geo coordinates
+    */
+    void routeTo(const GeoCoordinate &endPointCoordinates);
+
+    /**
+    * @brief Route to current cursor position
+    */
+    void routeToCursor();
+
+    /**
+    * @brief Requests to send a message to a person.
+    *
+    * Adds coordinates to to message if selected.
+    * @param receiverId Facebook user ID
+    * @param message message text
+    * @param addCoordinates true if coordinates should be added, false otherwise
+    */
+    void requestSendMessage(const QString &receiverId, const QString &message, bool addCoordinates);
+
+    /**
+    * @brief Slot for setting auto centering state.
     *
     * Calls gps to send last known position
     *
     * @param enabled true if auto centering was enabled, false otherwise
     */
-    void enableAutoCentering(bool enabled);
+    void setAutoCentering(bool enabled);
+
+    /**
+     * @brief Sets zoom level to default when first GPS location is received if autocentering
+     * is enabled.
+     */
+    void setFirstStartZoomLevel();
 
     /**
-    * @brief Slot for gps enabling.
+    * @brief Slot for setting GPS state.
     *
     * @param enabled true if gps should be enabled, false otherwise
     */
-    void enableGPS(bool enabled);
+    void setGPS(bool enabled);
 
     /**
-    * @brief Enables automatic location update.
+    * @brief Slot for setting power saving state.
     *
     * @param enabled true if enabled, false otherwise
-    * @param updateIntervalMsecs update interval in milliseconds
     */
-    void enableAutomaticLocationUpdate(bool enabled, int updateIntervalMsecs = 0);
+    void setPowerSaving(bool enabled);
 
     /**
-    * @brief Slot for display on.
+    * @brief Shows contact dialog.
     *
-    * @param on true if on, false otherwise
+    * Calls MainWindow showContactDialog with contact guid defined by contact's Facebook ID.
+    * @param facebookId contact's facebookId
     */
-    void displayOn(bool on);
+    void showContactDialog(const QString &facebookId);
 
     /**
-     * @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 Shows message dialog.
+    *
+    * If contact is a friend, show contact dialog instead.
+    * @param receiver receiver facebook ID and name
+    */
+    void showMessageDialog(const QPair<QString, QString> &receiver);
 
     /**
-    * @brief Requests automatic update.
+    * @brief Automatic update interval timer timeout.
     *
-    * Makes automatic location update request if user has moved enough.
+    * Requests update location if user has moved.
+    */
+    void startAutomaticUpdate();
+
+    /**
+    * @brief Called when topmost window is changed
     *
-    * @param position geo coordinates
+    * Does set power saving state.
+    *
+    * @param isMainWindow True if MainWindow is the topmost one
     */
-    void requestAutomaticUpdateIfMoved(QPointF position);
+    void topmostWindowChanged(bool isMainWindow);
 
 /*******************************************************************************
  * SIGNALS
@@ -264,6 +362,16 @@ signals:
     void clearUpdateLocationDialogData();
 
     /**
+    * @brief Signal when direction and distance from current map center point to current GPS
+    *        location is changed
+    *
+    * @param direction Direction in degrees
+    * @param distance Distance in meters
+    * @param draw Should the indicator triangle be drawn or not
+    */
+    void directionIndicatorValuesUpdate(qreal direction, qreal distance, bool draw);
+
+    /**
     * @brief Signals when new friends data is ready
     *
     * @param friendList List of User instances (friends)
@@ -271,6 +379,27 @@ signals:
     void friendsLocationsReady(QList<User *> &friendList);
 
     /**
+    * @brief Signals when friend's image is ready
+    *
+    * @param user Instance of friend
+    */
+    void friendImageReady(const QString &id, const QPixmap &image);
+
+    /**
+    * @brief Emited when location request is parsed and is ready for further processing
+    *
+    * @param result List of Location items
+    */
+    void locationDataParsed(QList<Location> &result);
+
+    /**
+    * @brief Signals when users's image is ready
+    *
+    * @param user Instance of friend
+    */
+    void userImageReady(const QString &id, const QPixmap &image);
+
+    /**
     * @brief Signals when new user data is ready
     *
     * @param user Instance of User
@@ -286,16 +415,19 @@ private:
     bool m_automaticUpdateRequest;      ///< Flag for automatic update request
     bool m_userMoved;                   ///< Flag for user move
 
+    QTimer *m_automaticUpdateIntervalTimer; ///< Automatic update interval timer
 
+    ContactManager *m_contactManager;                ///< Instance of contact manager
     FacebookAuthentication *m_facebookAuthenticator; ///< Instance for facebook authenticator
+    GeocodingService *m_geocodingService;            ///< Instance of the geocoding service
+    GeoCoordinate m_lastUpdatedGPSPosition;          ///< Last updated GPS position
     GPSPosition *m_gps;                              ///< Instance of the gps position
     MainWindow *m_ui;                                ///< Instance of the MainWindow UI
     MapEngine *m_mapEngine;                          ///< MapEngine
+    NetworkAccessManager *m_networkAccessManager;    ///< NetworkAccessManager
+    RoutingService *m_routingService;  ///< Instance of the routing service
     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
 };
 
 #endif // ENGINE_H