2 Situare - A location system for Facebook
3 Copyright (C) 2010 Ixonos Plc. Authors:
5 Kaj Wallin - kaj.wallin@ixonos.com
6 Henri Lampela - henri.lampela@ixonos.com
7 Jussi Laitinen - jussi.laitinen@ixonos.com
8 Sami Rämö - sami.ramo@ixonos.com
10 Situare is free software; you can redistribute it and/or
11 modify it under the terms of the GNU General Public License
12 version 2 as published by the Free Software Foundation.
14 Situare is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU General Public License for more details.
19 You should have received a copy of the GNU General Public License
20 along with Situare; if not, write to the Free Software
21 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
32 #include "coordinates/geocoordinate.h"
38 class FacebookAuthentication;
39 class FacebookCredentials;
40 class GeocodingService;
46 class NetworkAccessManager;
53 * @brief Engine class for Situare Application
55 * This class handles all the underlaying login of the Situare
58 class SituareEngine : public QObject
73 /*******************************************************************************
74 * MEMBER FUNCTIONS AND SLOTS
75 ******************************************************************************/
78 * @brief Slot to intercept error signal from ImageFetcher and SituareService
80 * @param context Error context
81 * @param error Error message
83 void error(const int context, const int error);
86 * @brief Slot to intercept signal when location search is issued
88 * @param location QString location
90 void locationSearch(QString location);
95 * @brief Slot to intercept signal when Login/Logout action is pressed
98 void loginActionPressed();
101 * @brief Slot to intercept signal from successful login
107 * @brief Slot to intercept signal when user has cancelled login process
109 void loginProcessCancelled();
112 * @brief Changes application state when logged out
118 * @brief Calls reverseGeo from SituareService to translate coordinates to street address
121 void requestAddress();
124 * @brief Calls updateLocation from SituareService to send the location update to
127 * @param status Status message
128 * @param publish Publish on Facebook
130 void requestUpdateLocation(const QString &status = QString(), bool publish = false);
133 * @brief Slot to refresh user data
135 void refreshUserData();
138 * @brief Slot to intercept signal from successful location update
141 void updateWasSuccessful();
144 * @brief Slot to intercept signal when new user data is available.
145 * Splits User and friendsList data and emits them as two different signals.
147 * @param user instance of User
148 * @param friendsList list of User instances (friends)
150 void userDataChanged(User *user, QList<User *> &friendsList);
154 * @brief Read settings and determine whether to use GPS and autocentering.
155 * When values does not found on the settings, GPS and autocentering are enabled as a default.
157 void initializeGpsAndAutocentering();
160 * @brief Connect signals coming from Facebook authenticator
162 void signalsFromFacebookAuthenticator();
165 * @brief Connect signals coming from GeocodingService
167 void signalsFromGeocodingService();
170 * @brief Connect signals coming from GPS
172 void signalsFromGPS();
175 * @brief Connect signals coming from MainWindow
177 void signalsFromMainWindow();
180 * @brief Connect signals coming from MapEngine
182 void signalsFromMapEngine();
185 * @brief Connect signals coming from MapView
187 void signalsFromMapView();
190 * @brief Connect signals coming from RoutingService
192 void signalsFromRoutingService();
195 * @brief Connect signals coming from Situare
197 void signalsFromSituareService();
201 * @brief Set auto centering feature enabled / disabled
203 * @param enabled true if enabled, false otherwise
205 void changeAutoCenteringSetting(bool enabled);
208 * @brief Slot for disabling automatic centering when map is scrolled manually
210 void disableAutoCentering();
213 * @brief Calls vibration feedback.
215 void draggingModeTriggered();
218 * @brief Enables automatic location update.
220 * @param enabled true if enabled, false otherwise
221 * @param updateIntervalMsecs update interval in milliseconds
223 void enableAutomaticLocationUpdate(bool enabled, int updateIntervalMsecs = 0);
226 * @brief Slot to intercept signal when user's/friend's image is downloaded
228 * @param user Instance of user/friend
230 void imageReady(User *user);
235 * @brief Requests automatic update.
237 * Makes automatic location update request if user has moved enough.
239 * @param position geo coordinates
241 void requestAutomaticUpdateIfMoved(GeoCoordinate position);
244 * @brief Route is parsed and is ready for further processing.
246 * @param route Route item containing parsed route details
248 void routeParsed(Route &route);
251 * @brief Routes to geo coordinates.
253 * Uses map center coordinates as start point.
254 * @param endPointCoordinates end point geo coordinates
256 void routeTo(const GeoCoordinate &endPointCoordinates);
259 * @brief Route to current cursor position
261 void routeToCursor();
264 * @brief Slot for setting auto centering state.
266 * Calls gps to send last known position
268 * @param enabled true if auto centering was enabled, false otherwise
270 void setAutoCentering(bool enabled);
273 * @brief Sets zoom level to default when first GPS location is received if autocentering
276 void setFirstStartZoomLevel();
279 * @brief Slot for setting GPS state.
281 * @param enabled true if gps should be enabled, false otherwise
283 void setGPS(bool enabled);
286 * @brief Slot for setting power saving state.
288 * @param enabled true if enabled, false otherwise
290 void setPowerSaving(bool enabled);
293 * @brief Shows contact dialog.
295 * Calls MainWindow showContactDialog with contact guid defined by contact's Facebook ID.
296 * @param facebookId contact's facebookId
298 void showContactDialog(const QString &facebookId);
301 * @brief Automatic update interval timer timeout.
303 * Requests update location if user has moved.
305 void startAutomaticUpdate();
308 * @brief Called when topmost window is changed
310 * Does set power saving state.
312 * @param isMainWindow True if MainWindow is the topmost one
314 void topmostWindowChanged(bool isMainWindow);
316 /*******************************************************************************
318 ******************************************************************************/
321 * @brief Signals when automatic location update was enabled.
323 * @param enabled true if enabled, false otherwise
325 void automaticLocationUpdateEnabled(bool enabled);
328 * @brief Signal to clear locationUpdateDialog's data
331 void clearUpdateLocationDialogData();
334 * @brief Signal when direction and distance from current map center point to current GPS
335 * location is changed
337 * @param direction Direction in degrees
338 * @param distance Distance in meters
339 * @param draw Should the indicator triangle be drawn or not
341 void directionIndicatorValuesUpdate(qreal direction, qreal distance, bool draw);
344 * @brief Signals when new friends data is ready
346 * @param friendList List of User instances (friends)
348 void friendsLocationsReady(QList<User *> &friendList);
351 * @brief Signals when friend's image is ready
353 * @param user Instance of friend
355 void friendImageReady(User *user);
358 * @brief Emited when location request is parsed and is ready for further processing
360 * @param result List of Location items
362 void locationDataParsed(QList<Location> &result);
365 * @brief Signals when new user data is ready
367 * @param user Instance of User
369 void userLocationReady(User *user);
371 /*******************************************************************************
373 ******************************************************************************/
375 bool m_autoCenteringEnabled; ///< Auto centering flag
376 bool m_automaticUpdateFirstStart; ///< Automatic location update first start flag
377 bool m_automaticUpdateRequest; ///< Flag for automatic update request
378 bool m_userMoved; ///< Flag for user move
380 QTimer *m_automaticUpdateIntervalTimer; ///< Automatic update interval timer
382 ContactManager *m_contactManager; ///< Instance of contact manager
383 FacebookAuthentication *m_facebookAuthenticator; ///< Instance for facebook authenticator
384 GeocodingService *m_geocodingService; ///< Instance of the geocoding service
385 GeoCoordinate m_lastUpdatedGPSPosition; ///< Last updated GPS position
386 GPSPosition *m_gps; ///< Instance of the gps position
387 MainWindow *m_ui; ///< Instance of the MainWindow UI
388 MapEngine *m_mapEngine; ///< MapEngine
389 NetworkAccessManager *m_networkAccessManager; ///< NetworkAccessManager
390 RoutingService *m_routingService; ///< Instance of the routing service
391 SituareService *m_situareService; ///< Instance of the situare server communication service
392 MCE *m_mce; ///< Instance of the MCE