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 is issued
93 * @param location QString location
95 void locationSearch(QString location);
98 * @brief Slot to intercept signal when Login/Logout action is pressed
101 void loginActionPressed();
104 * @brief Slot to intercept signal from successful login
110 * @brief Slot to intercept signal when user has cancelled login process
112 void loginProcessCancelled();
115 * @brief Changes application state when logged out
121 * @brief Calls reverseGeo from SituareService to translate coordinates to street address
124 void requestAddress();
127 * @brief Calls updateLocation from SituareService to send the location update to
130 * @param status Status message
131 * @param publish Publish on Facebook
133 void requestUpdateLocation(const QString &status = QString(), bool publish = false);
136 * @brief Slot to refresh user data
138 void refreshUserData();
141 * @brief Slot to intercept signal from successful location update
144 void updateWasSuccessful();
147 * @brief Slot to intercept signal when new user data is available.
148 * Splits User and friendsList data and emits them as two different signals.
150 * @param user instance of User
151 * @param friendsList list of User instances (friends)
153 void userDataChanged(User *user, QList<User *> &friendsList);
157 * @brief Read settings and determine whether to use GPS and autocentering.
158 * When values does not found on the settings, GPS and autocentering are enabled as a default.
160 void initializeGpsAndAutocentering();
163 * @brief Connect signals coming from Facdebook authenticator
165 void signalsFromFacebookAuthenticator();
168 * @brief Connect signals coming from GPS
170 void signalsFromGPS();
173 * @brief Connect signals coming from MainWindow
175 void signalsFromMainWindow();
178 * @brief Connect signals coming from MapEngine
180 void signalsFromMapEngine();
183 * @brief Connect signals coming from MapView
185 void signalsFromMapView();
188 * @brief Connect signals coming from RoutingService
190 void signalsFromRoutingService();
193 * @brief Connect signals coming from Situare
195 void signalsFromSituareService();
199 * @brief Set auto centering feature enabled / disabled
201 * @param enabled true if enabled, false otherwise
203 void changeAutoCenteringSetting(bool enabled);
206 * @brief Slot for disabling automatic centering when map is scrolled manually
208 void disableAutoCentering();
211 * @brief Calls vibration feedback.
213 void draggingModeTriggered();
216 * @brief Enables automatic location update.
218 * @param enabled true if enabled, false otherwise
219 * @param updateIntervalMsecs update interval in milliseconds
221 void enableAutomaticLocationUpdate(bool enabled, int updateIntervalMsecs = 0);
224 * @brief Slot for enabling power saving.
226 * @param enabled true if enabled, false otherwise
228 void enablePowerSave(bool enabled);
231 * @brief Slot to intercept signal when user's/friend's image is downloaded
233 * @param user Instance of user/friend
235 void imageReady(User *user);
238 * @brief Requests automatic update.
240 * Makes automatic location update request if user has moved enough.
242 * @param position geo coordinates
244 void requestAutomaticUpdateIfMoved(GeoCoordinate position);
247 * @brief Slot for setting auto centering state.
249 * Calls gps to send last known position
251 * @param enabled true if auto centering was enabled, false otherwise
253 void setAutoCentering(bool enabled);
256 * @brief Sets zoom level to default when first GPS location is received if autocentering
259 void setFirstStartZoomLevel();
262 * @brief Slot for setting GPS state.
264 * @param enabled true if gps should be enabled, false otherwise
266 void setGPS(bool enabled);
269 * @brief Automatic update interval timer timeout.
271 * Requests update location if user has moved.
273 void startAutomaticUpdate();
275 /*******************************************************************************
277 ******************************************************************************/
280 * @brief Signals when automatic location update was enabled.
282 * @param enabled true if enabled, false otherwise
284 void automaticLocationUpdateEnabled(bool enabled);
287 * @brief Signal to clear locationUpdateDialog's data
290 void clearUpdateLocationDialogData();
293 * @brief Signals when new friends data is ready
295 * @param friendList List of User instances (friends)
297 void friendsLocationsReady(QList<User *> &friendList);
300 * @brief Signals when friend's image is ready
302 * @param user Instance of friend
304 void friendImageReady(User *user);
307 * @brief Emited when location request is parsed and is ready for further processing
309 * @param result List of Location items
311 void locationDataParsed(QList<Location> &result);
314 * @brief Signals when new user data is ready
316 * @param user Instance of User
318 void userLocationReady(User *user);
320 /*******************************************************************************
322 ******************************************************************************/
324 bool m_autoCenteringEnabled; ///< Auto centering flag
325 bool m_automaticUpdateFirstStart; ///< Automatic location update first start flag
326 bool m_automaticUpdateRequest; ///< Flag for automatic update request
327 bool m_userMoved; ///< Flag for user move
330 Application *m_app; ///< Pointer to Application
332 FacebookAuthentication *m_facebookAuthenticator; ///< Instance for facebook authenticator
333 GPSPosition *m_gps; ///< Instance of the gps position
334 MainWindow *m_ui; ///< Instance of the MainWindow UI
335 MapEngine *m_mapEngine; ///< MapEngine
336 NetworkAccessManager *m_networkAccessManager; ///< NetworkAccessManager
337 RoutingService *m_routingService; ///< Instance of the routing service
338 SituareService *m_situareService; ///< Instance of the situare server communication service
339 MCE *m_mce; ///< Instance of the MCE
341 QTimer *m_automaticUpdateIntervalTimer; ///< Automatic update interval timer
342 GeoCoordinate m_lastUpdatedGPSPosition; ///< Last updated GPS position