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"
37 class FacebookAuthentication;
38 class FacebookCredentials;
43 class NetworkAccessManager;
52 * @brief Engine class for Situare Application
54 * This class handles all the underlaying login of the Situare
57 class SituareEngine : public QObject
72 /*******************************************************************************
73 * MEMBER FUNCTIONS AND SLOTS
74 ******************************************************************************/
77 * @brief Slot to intercept error signal from ImageFetcher and SituareService
79 * @param context Error context
80 * @param error Error message
82 void error(const int context, const int error);
85 * @brief Slot to intercept signal when username is fetched from settings
88 void fetchUsernameFromSettings();
91 * @brief Slot to intercept signal when location search results are ready
93 * @param result list if location search results
95 void locationDataReady(QList<Location> &result);
98 * @brief Slot to intercept signal when location search is issued
100 * @param location QString location
102 void locationSearch(QString location);
105 * @brief Slot to intercept signal when Login/Logout action is pressed
108 void loginActionPressed();
111 * @brief Slot to intercept signal from successful login
117 * @brief Slot to intercept signal when user has cancelled login process
119 void loginProcessCancelled();
122 * @brief Changes application state when logged out
128 * @brief Calls reverseGeo from SituareService to translate coordinates to street address
131 void requestAddress();
134 * @brief Calls updateLocation from SituareService to send the location update to
137 * @param status Status message
138 * @param publish Publish on Facebook
140 void requestUpdateLocation(const QString &status = QString(), bool publish = false);
143 * @brief Slot to refresh user data
145 void refreshUserData();
148 * @brief Slot to intercept signal from successful location update
151 void updateWasSuccessful();
154 * @brief Slot to intercept signal when new user data is available.
155 * Splits User and friendsList data and emits them as two different signals.
157 * @param user instance of User
158 * @param friendsList list of User instances (friends)
160 void userDataChanged(User *user, QList<User *> &friendsList);
164 * @brief Read settings and determine whether to use GPS and autocentering.
165 * When values does not found on the settings, GPS and autocentering are enabled as a default.
167 void initializeGpsAndAutocentering();
170 * @brief Connect signals coming from Facdebook authenticator
172 void signalsFromFacebookAuthenticator();
175 * @brief Connect signals coming from GPS
177 void signalsFromGPS();
180 * @brief Connect signals coming from MainWindow
182 void signalsFromMainWindow();
185 * @brief Connect signals coming from MapEngine
187 void signalsFromMapEngine();
190 * @brief Connect signals coming from MapView
192 void signalsFromMapView();
195 * @brief Connect signals coming from RoutingService
197 void signalsFromRoutingService();
200 * @brief Connect signals coming from Situare
202 void signalsFromSituareService();
206 * @brief Set auto centering feature enabled / disabled
208 * @param enabled true if enabled, false otherwise
210 void changeAutoCenteringSetting(bool enabled);
213 * @brief Slot for disabling automatic centering when map is scrolled manually
215 void disableAutoCentering();
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 for enabling power saving.
228 * @param enabled true if enabled, false otherwise
230 void enablePowerSave(bool enabled);
233 * @brief Slot to intercept signal when user's/friend's image is downloaded
235 * @param user Instance of user/friend
237 void imageReady(User *user);
240 * @brief Requests automatic update.
242 * Makes automatic location update request if user has moved enough.
244 * @param position geo coordinates
246 void requestAutomaticUpdateIfMoved(GeoCoordinate position);
249 * @brief Slot for setting auto centering state.
251 * Calls gps to send last known position
253 * @param enabled true if auto centering was enabled, false otherwise
255 void setAutoCentering(bool enabled);
258 * @brief Sets zoom level to default when first GPS location is received if autocentering
261 void setFirstStartZoomLevel();
264 * @brief Slot for setting GPS state.
266 * @param enabled true if gps should be enabled, false otherwise
268 void setGPS(bool enabled);
271 * @brief Automatic update interval timer timeout.
273 * Requests update location if user has moved.
275 void startAutomaticUpdate();
277 /*******************************************************************************
279 ******************************************************************************/
282 * @brief Signals when automatic location update was enabled.
284 * @param enabled true if enabled, false otherwise
286 void automaticLocationUpdateEnabled(bool enabled);
289 * @brief Signal to clear locationUpdateDialog's data
292 void clearUpdateLocationDialogData();
295 * @brief Signal when direction and distance from current map center point to current GPS
296 * location is changed
298 * @param direction Direction in degrees
299 * @param distance Distance in kilometers
300 * @param draw Should the indicator triangle be drawn or not
302 void directionIndicatorValuesUpdate(qreal direction, qreal distance, bool draw);
305 * @brief Signals when new friends data is ready
307 * @param friendList List of User instances (friends)
309 void friendsLocationsReady(QList<User *> &friendList);
312 * @brief Signals when friend's image is ready
314 * @param user Instance of friend
316 void friendImageReady(User *user);
319 * @brief Signals when new user data is ready
321 * @param user Instance of User
323 void userLocationReady(User *user);
325 /*******************************************************************************
327 ******************************************************************************/
329 bool m_autoCenteringEnabled; ///< Auto centering flag
330 bool m_automaticUpdateFirstStart; ///< Automatic location update first start flag
331 bool m_automaticUpdateRequest; ///< Flag for automatic update request
332 bool m_userMoved; ///< Flag for user move
335 Application *m_app; ///< Pointer to Application
337 FacebookAuthentication *m_facebookAuthenticator; ///< Instance for facebook authenticator
338 GPSPosition *m_gps; ///< Instance of the gps position
339 MainWindow *m_ui; ///< Instance of the MainWindow UI
340 MapEngine *m_mapEngine; ///< MapEngine
341 NetworkAccessManager *m_networkAccessManager; ///< NetworkAccessManager
342 RoutingService *m_routingService; ///< Instance of the routing service
343 SituareService *m_situareService; ///< Instance of the situare server communication service
344 MCE *m_mce; ///< Instance of the MCE
346 QTimer *m_automaticUpdateIntervalTimer; ///< Automatic update interval timer
347 GeoCoordinate m_lastUpdatedGPSPosition; ///< Last updated GPS position