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"
39 class FacebookAuthentication;
40 class FacebookCredentials;
41 class GeocodingService;
47 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 results are ready
94 * @param result list if location search results
96 void locationDataReady(QList<Location> &result);
99 * @brief Slot to intercept signal when location search is issued
101 * @param location QString location
103 void locationSearch(QString location);
106 * @brief Slot to intercept signal when Login/Logout action is pressed
109 void loginActionPressed();
112 * @brief Slot to intercept signal from successful login
118 * @brief Slot to intercept signal when user has cancelled login process
120 void loginProcessCancelled();
123 * @brief Changes application state when logged out
129 * @brief Calls reverseGeo from SituareService to translate coordinates to street address
132 void requestAddress();
135 * @brief Calls updateLocation from SituareService to send the location update to
138 * @param status Status message
139 * @param publish Publish on Facebook
141 void requestUpdateLocation(const QString &status = QString(), bool publish = false);
144 * @brief Slot to refresh user data
146 void refreshUserData();
149 * @brief Slot to intercept signal from successful location update
152 void updateWasSuccessful();
155 * @brief Slot to intercept signal when new user data is available.
156 * Splits User and friendsList data and emits them as two different signals.
158 * @param user instance of User
159 * @param friendsList list of User instances (friends)
161 void userDataChanged(User *user, QList<User *> &friendsList);
165 * @brief Read settings and determine whether to use GPS and autocentering.
166 * When values does not found on the settings, GPS and autocentering are enabled as a default.
168 void initializeGpsAndAutocentering();
171 * @brief Connect signals coming from Facebook authenticator
173 void signalsFromFacebookAuthenticator();
176 * @brief Connect signals coming from GeocodingService
178 void signalsFromGeocodingService();
181 * @brief Connect signals coming from GPS
183 void signalsFromGPS();
186 * @brief Connect signals coming from MainWindow
188 void signalsFromMainWindow();
191 * @brief Connect signals coming from MapEngine
193 void signalsFromMapEngine();
196 * @brief Connect signals coming from MapView
198 void signalsFromMapView();
201 * @brief Connect signals coming from RoutingService
203 void signalsFromRoutingService();
206 * @brief Connect signals coming from Situare
208 void signalsFromSituareService();
212 * @brief Set auto centering feature enabled / disabled
214 * @param enabled true if enabled, false otherwise
216 void changeAutoCenteringSetting(bool enabled);
219 * @brief Slot for disabling automatic centering when map is scrolled manually
221 void disableAutoCentering();
224 * @brief Calls vibration feedback.
226 void draggingModeTriggered();
229 * @brief Enables automatic location update.
231 * @param enabled true if enabled, false otherwise
232 * @param updateIntervalMsecs update interval in milliseconds
234 void enableAutomaticLocationUpdate(bool enabled, int updateIntervalMsecs = 0);
237 * @brief Slot for enabling power saving.
239 * @param enabled true if enabled, false otherwise
241 void enablePowerSave(bool enabled);
244 * @brief Slot to intercept signal when user's/friend's image is downloaded
246 * @param user Instance of user/friend
248 void imageReady(User *user);
251 * @brief Requests automatic update.
253 * Makes automatic location update request if user has moved enough.
255 * @param position geo coordinates
257 void requestAutomaticUpdateIfMoved(GeoCoordinate position);
260 * @brief Slot for setting auto centering state.
262 * Calls gps to send last known position
264 * @param enabled true if auto centering was enabled, false otherwise
266 void setAutoCentering(bool enabled);
269 * @brief Sets zoom level to default when first GPS location is received if autocentering
272 void setFirstStartZoomLevel();
275 * @brief Slot for setting GPS state.
277 * @param enabled true if gps should be enabled, false otherwise
279 void setGPS(bool enabled);
282 * @brief Automatic update interval timer timeout.
284 * Requests update location if user has moved.
286 void startAutomaticUpdate();
288 /*******************************************************************************
290 ******************************************************************************/
293 * @brief Signals when automatic location update was enabled.
295 * @param enabled true if enabled, false otherwise
297 void automaticLocationUpdateEnabled(bool enabled);
300 * @brief Signal to clear locationUpdateDialog's data
303 void clearUpdateLocationDialogData();
306 * @brief Signal when direction and distance from current map center point to current GPS
307 * location is changed
309 * @param direction Direction in degrees
310 * @param distance Distance in meters
311 * @param draw Should the indicator triangle be drawn or not
313 void directionIndicatorValuesUpdate(qreal direction, qreal distance, bool draw);
316 * @brief Signals when new friends data is ready
318 * @param friendList List of User instances (friends)
320 void friendsLocationsReady(QList<User *> &friendList);
323 * @brief Signals when friend's image is ready
325 * @param user Instance of friend
327 void friendImageReady(User *user);
330 * @brief Signals when new user data is ready
332 * @param user Instance of User
334 void userLocationReady(User *user);
336 /*******************************************************************************
338 ******************************************************************************/
340 bool m_autoCenteringEnabled; ///< Auto centering flag
341 bool m_automaticUpdateFirstStart; ///< Automatic location update first start flag
342 bool m_automaticUpdateRequest; ///< Flag for automatic update request
343 bool m_userMoved; ///< Flag for user move
346 Application *m_app; ///< Pointer to Application
348 FacebookAuthentication *m_facebookAuthenticator; ///< Instance for facebook authenticator
349 GeocodingService *m_geocodingService; ///< Instance of the geocoding service
350 GPSPosition *m_gps; ///< Instance of the gps position
351 MainWindow *m_ui; ///< Instance of the MainWindow UI
352 MapEngine *m_mapEngine; ///< MapEngine
353 NetworkAccessManager *m_networkAccessManager; ///< NetworkAccessManager
354 RoutingService *m_routingService; ///< Instance of the routing service
355 SituareService *m_situareService; ///< Instance of the situare server communication service
356 MCE *m_mce; ///< Instance of the MCE
358 QTimer *m_automaticUpdateIntervalTimer; ///< Automatic update interval timer
359 GeoCoordinate m_lastUpdatedGPSPosition; ///< Last updated GPS position