X-Git-Url: http://git.maemo.org/git/?a=blobdiff_plain;f=src%2Fengine%2Fengine.h;h=88c738c946cd864af85aec0358f7c7f0bdab6a92;hb=0030c3b81fecacab17b5283094db6afe6feb6766;hp=7e4374e39b6fd3993489eeb460c25e1e84c99b45;hpb=0019fe0811a0585c9558ca543b2143857acb421b;p=situare diff --git a/src/engine/engine.h b/src/engine/engine.h index 7e4374e..88c738c 100644 --- a/src/engine/engine.h +++ b/src/engine/engine.h @@ -4,6 +4,8 @@ Kaj Wallin - kaj.wallin@ixonos.com Henri Lampela - henri.lampela@ixonos.com + Jussi Laitinen - jussi.laitinen@ixonos.com + Sami Rämö - sami.ramo@ixonos.com Situare is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License @@ -24,20 +26,29 @@ #ifndef ENGINE_H #define ENGINE_H -#include -#include -#include "facebookservice/facebookauthentication.h" -#include "situareservice/situareservice.h" -#include -#include "../ui/mainwindow.h" +#include +#include +#include + +class QMainWindow; + +class FacebookAuthentication; +class FacebookCredentials; +class GPSPosition; +class MainWindow; +class MapEngine; +class NetworkAccessManager; +class SituareService; +class User; +class MCE; + +class QTimer; /** * @brief Engine class for Situare Application * * This class handles all the underlaying login of the Situare * application. -* -* @class SituareEngine engine.h "engine/engine.h" */ class SituareEngine : public QObject { @@ -58,27 +69,45 @@ public: /******************************************************************************* * MEMBER FUNCTIONS AND SLOTS ******************************************************************************/ -public: +public slots: /** - * @brief Function to start engine component + * @brief Slot to intercept error signal from ImageFetcher and SituareService + * + * @param context Error context + * @param error Error message */ - void start(); + void error(const int context, const int error); -public slots: + /** + * @brief Slot to intercept signal when username is fetched from settings + * + */ + void fetchUsernameFromSettings(); /** - * @brief Slot to intercept error signal from ImageFetcher and SituareService + * @brief Slot to intercept signal when Login/Logout action is pressed * - * @param error Error message */ - void error(const QString &error); + void loginActionPressed(); /** * @brief Slot to intercept signal from successful login + * */ void loginOk(); /** + * @brief Slot to intercept signal when user has cancelled login process + */ + void loginProcessCancelled(); + + /** + * @brief Changes application state when logged out + * + */ + void logout(); + + /** * @brief Calls reverseGeo from SituareService to translate coordinates to street address * */ @@ -91,33 +120,185 @@ public slots: * @param status Status message * @param publish Publish on Facebook */ - void requestUpdateLocation(const QString &status, const bool &publish); + void requestUpdateLocation(const QString &status = QString(), bool publish = false); - void updateFriendsList(); + /** + * @brief Slot to refresh user data + */ + void refreshUserData(); + + /** + * @brief Slot to intercept signal from successful location update + * + */ + void updateWasSuccessful(); + + /** + * @brief Slot to intercept signal when new user data is available. + * Splits User and friendsList data and emits them as two different signals. + * + * @param user instance of User + * @param friendsList list of User instances (friends) + */ + void userDataChanged(User *user, QList &friendsList); + +private: + /** + * @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. + */ + void initializeGpsAndAutocentering(); + + /** + * @brief Connect signals coming from Facdebook authenticator + */ + void signalsFromFacebookAuthenticator(); + + /** + * @brief Connect signals coming from GPS + */ + void signalsFromGPS(); + + /** + * @brief Connect signals coming from MainWindow + */ + void signalsFromMainWindow(); + + /** + * @brief Connect signals coming from MapEngine + */ + void signalsFromMapEngine(); + + /** + * @brief Connect signals coming from MapView + */ + void signalsFromMapView(); + + /** + * @brief Connect signals coming from Situare + */ + void signalsFromSituareService(); + +private slots: + /** + * @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 + */ + 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 + * + * @param enabled true if auto centering was enabled, false otherwise + */ + void enableAutoCentering(bool enabled); + + /** + * @brief Slot for gps enabling. + * + * @param enabled true if gps should be enabled, false otherwise + */ + void enableGPS(bool enabled); + + /** + * @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 Requests automatic update. + * + * Makes automatic location update request if user has moved enough. + * + * @param position geo coordinates + */ + void requestAutomaticUpdateIfMoved(QPointF position); + + /** + * @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. + * + * Requests update location if user has moved. + */ + void startAutomaticUpdate(); /******************************************************************************* * SIGNALS ******************************************************************************/ signals: /** - * @brief Signal that is emitted when UI must be showed + * @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) */ - void engine_showMainWindow(); + void friendsLocationsReady(QList &friendList); /** - * @brief Signal that is emitted when UI must be closed + * @brief Signals when new user data is ready + * + * @param user Instance of User */ - void engine_closeMainWindow(); + void userLocationReady(User *user); /******************************************************************************* * DATA MEMBERS ******************************************************************************/ private: - MainWindow *m_ui; + 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 - QNetworkAccessManager *m_networkManager; ///< NetworkManager that is passed on to SituareService - SituareService *m_situareService; ///< Instance of the situare server communication service - bool m_loggedIn; ///< Boolean value to indicate whether login has been successfull or not + GPSPosition *m_gps; ///< Instance of the gps position + MainWindow *m_ui; ///< Instance of the MainWindow UI + MapEngine *m_mapEngine; ///< MapEngine + NetworkAccessManager *m_networkAccessManager; ///< NetworkAccessManager + 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