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 username is fetched from settings
89 void fetchUsernameFromSettings();
92 * @brief Slot to intercept signal when location search is issued
94 * @param location QString location
96 void locationSearch(QString location);
99 * @brief Slot to intercept signal when Login/Logout action is pressed
102 void loginActionPressed();
105 * @brief Slot to intercept signal from successful login
111 * @brief Slot to intercept signal when user has cancelled login process
113 void loginProcessCancelled();
116 * @brief Changes application state when logged out
122 * @brief Calls reverseGeo from SituareService to translate coordinates to street address
125 void requestAddress();
128 * @brief Calls updateLocation from SituareService to send the location update to
131 * @param status Status message
132 * @param publish Publish on Facebook
134 void requestUpdateLocation(const QString &status = QString(), bool publish = false);
137 * @brief Slot to refresh user data
139 void refreshUserData();
142 * @brief Slot to intercept signal from successful location update
145 void updateWasSuccessful();
148 * @brief Slot to intercept signal when new user data is available.
149 * Splits User and friendsList data and emits them as two different signals.
151 * @param user instance of User
152 * @param friendsList list of User instances (friends)
154 void userDataChanged(User *user, QList<User *> &friendsList);
158 * @brief Read settings and determine whether to use GPS and autocentering.
159 * When values does not found on the settings, GPS and autocentering are enabled as a default.
161 void initializeGpsAndAutocentering();
164 * @brief Connect signals coming from Facebook authenticator
166 void signalsFromFacebookAuthenticator();
169 * @brief Connect signals coming from GeocodingService
171 void signalsFromGeocodingService();
174 * @brief Connect signals coming from GPS
176 void signalsFromGPS();
179 * @brief Connect signals coming from MainWindow
181 void signalsFromMainWindow();
184 * @brief Connect signals coming from MapEngine
186 void signalsFromMapEngine();
189 * @brief Connect signals coming from MapView
191 void signalsFromMapView();
194 * @brief Connect signals coming from RoutingService
196 void signalsFromRoutingService();
199 * @brief Connect signals coming from Situare
201 void signalsFromSituareService();
205 * @brief Set auto centering feature enabled / disabled
207 * @param enabled true if enabled, false otherwise
209 void changeAutoCenteringSetting(bool enabled);
212 * @brief Slot for disabling automatic centering when map is scrolled manually
214 void disableAutoCentering();
217 * @brief Calls vibration feedback.
219 void draggingModeTriggered();
222 * @brief Enables automatic location update.
224 * @param enabled true if enabled, false otherwise
225 * @param updateIntervalMsecs update interval in milliseconds
227 void enableAutomaticLocationUpdate(bool enabled, int updateIntervalMsecs = 0);
230 * @brief Slot to intercept signal when user's/friend's image is downloaded
232 * @param user Instance of user/friend
234 void imageReady(User *user);
237 * @brief Requests automatic update.
239 * Makes automatic location update request if user has moved enough.
241 * @param position geo coordinates
243 void requestAutomaticUpdateIfMoved(GeoCoordinate position);
246 * @brief Route is parsed and is ready for further processing.
248 * @param route Route item containing parsed route details
250 void routeParsed(Route &route);
253 * @brief Routes to geo coordinates.
255 * Uses map center coordinates as start point.
256 * @param endPointCoordinates end point geo coordinates
258 void routeTo(const GeoCoordinate &endPointCoordinates);
261 * @brief Route to current cursor position
263 void routeToCursor();
266 * @brief Slot for setting auto centering state.
268 * Calls gps to send last known position
270 * @param enabled true if auto centering was enabled, false otherwise
272 void setAutoCentering(bool enabled);
275 * @brief Sets zoom level to default when first GPS location is received if autocentering
278 void setFirstStartZoomLevel();
281 * @brief Slot for setting GPS state.
283 * @param enabled true if gps should be enabled, false otherwise
285 void setGPS(bool enabled);
288 * @brief Slot for setting power saving state.
290 * @param enabled true if enabled, false otherwise
292 void setPowerSaving(bool enabled);
295 * @brief Shows contact dialog.
297 * Calls MainWindow showContactDialog with contact guid defined by contact's Facebook ID.
298 * @param facebookId contact's facebookId
300 void showContactDialog(const QString &facebookId);
303 * @brief Automatic update interval timer timeout.
305 * Requests update location if user has moved.
307 void startAutomaticUpdate();
310 * @brief Called when topmost window is changed
312 * Does set power saving state.
314 * @param isMainWindow True if MainWindow is the topmost one
316 void topmostWindowChanged(bool isMainWindow);
318 /*******************************************************************************
320 ******************************************************************************/
323 * @brief Signals when automatic location update was enabled.
325 * @param enabled true if enabled, false otherwise
327 void automaticLocationUpdateEnabled(bool enabled);
330 * @brief Signal to clear locationUpdateDialog's data
333 void clearUpdateLocationDialogData();
336 * @brief Signal when direction and distance from current map center point to current GPS
337 * location is changed
339 * @param direction Direction in degrees
340 * @param distance Distance in meters
341 * @param draw Should the indicator triangle be drawn or not
343 void directionIndicatorValuesUpdate(qreal direction, qreal distance, bool draw);
346 * @brief Signals when new friends data is ready
348 * @param friendList List of User instances (friends)
350 void friendsLocationsReady(QList<User *> &friendList);
353 * @brief Signals when friend's image is ready
355 * @param user Instance of friend
357 void friendImageReady(User *user);
360 * @brief Emited when location request is parsed and is ready for further processing
362 * @param result List of Location items
364 void locationDataParsed(QList<Location> &result);
367 * @brief Signals when new user data is ready
369 * @param user Instance of User
371 void userLocationReady(User *user);
373 /*******************************************************************************
375 ******************************************************************************/
377 bool m_autoCenteringEnabled; ///< Auto centering flag
378 bool m_automaticUpdateFirstStart; ///< Automatic location update first start flag
379 bool m_automaticUpdateRequest; ///< Flag for automatic update request
380 bool m_userMoved; ///< Flag for user move
382 QTimer *m_automaticUpdateIntervalTimer; ///< Automatic update interval timer
384 ContactManager *m_contactManager; ///< Instance of contact manager
385 FacebookAuthentication *m_facebookAuthenticator; ///< Instance for facebook authenticator
386 GeocodingService *m_geocodingService; ///< Instance of the geocoding service
387 GeoCoordinate m_lastUpdatedGPSPosition; ///< Last updated GPS position
388 GPSPosition *m_gps; ///< Instance of the gps position
389 MainWindow *m_ui; ///< Instance of the MainWindow UI
390 MapEngine *m_mapEngine; ///< MapEngine
391 NetworkAccessManager *m_networkAccessManager; ///< NetworkAccessManager
392 RoutingService *m_routingService; ///< Instance of the routing service
393 SituareService *m_situareService; ///< Instance of the situare server communication service
394 MCE *m_mce; ///< Instance of the MCE