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,
33 #include "coordinates/geocoordinate.h"
34 #include "situareservice/situareservice.h"
40 class FacebookAuthentication;
41 class FacebookCredentials;
42 class GeocodingService;
48 class NetworkAccessManager;
55 * @brief Engine class for Situare Application
57 * This class handles all the underlaying login of the Situare
60 class SituareEngine : public QObject
75 /*******************************************************************************
76 * MEMBER FUNCTIONS AND SLOTS
77 ******************************************************************************/
80 * @brief Slot to intercept error signal from ImageFetcher and SituareService
82 * @param context Error context
83 * @param error Error message
85 void error(const int context, const int error);
88 * @brief Slot to intercept signal when username is fetched from settings
91 void fetchUsernameFromSettings();
94 * @brief Slot to intercept signal when location search is issued
96 * @param location QString location
98 void locationSearch(QString location);
101 * @brief Slot to intercept signal when Login/Logout action is pressed
104 void loginActionPressed();
107 * @brief Slot to intercept signal from successful login
113 * @brief Slot to intercept signal when user has cancelled login process
115 void loginProcessCancelled();
118 * @brief Changes application state when logged out
124 * @brief Calls reverseGeo from SituareService to translate coordinates to street address
127 void requestAddress();
130 * @brief Calls updateLocation from SituareService to send the location update to
133 * @param status Status message
134 * @param publish Publish on Facebook
136 void requestUpdateLocation(const QString &status = QString(), bool publish = false);
139 * @brief Slot to refresh user data
141 void refreshUserData();
144 * @brief Slot to intercept signal from successful location update
146 * @param successfulMethod which method was successful
148 void updateWasSuccessful(SituareService::SuccessfulMethod successfulMethod);
151 * @brief Slot to intercept signal when new user data is available.
152 * Splits User and friendsList data and emits them as two different signals.
154 * @param user instance of User
155 * @param friendsList list of User instances (friends)
157 void userDataChanged(User *user, QList<User *> &friendsList);
161 * @brief Read settings and determine whether to use GPS and autocentering.
162 * When values does not found on the settings, GPS and autocentering are enabled as a default.
164 void initializeGpsAndAutocentering();
167 * @brief Connect signals coming from Facebook authenticator
169 void signalsFromFacebookAuthenticator();
172 * @brief Connect signals coming from GeocodingService
174 void signalsFromGeocodingService();
177 * @brief Connect signals coming from GPS
179 void signalsFromGPS();
182 * @brief Connect signals coming from MainWindow
184 void signalsFromMainWindow();
187 * @brief Connect signals coming from MapEngine
189 void signalsFromMapEngine();
192 * @brief Connect signals coming from MapView
194 void signalsFromMapView();
197 * @brief Connect signals coming from RoutingService
199 void signalsFromRoutingService();
202 * @brief Connect signals coming from Situare
204 void signalsFromSituareService();
208 * @brief Set auto centering feature enabled / disabled
210 * @param enabled true if enabled, false otherwise
212 void changeAutoCenteringSetting(bool enabled);
215 * @brief Slot for disabling automatic centering when map is scrolled manually
217 void disableAutoCentering();
220 * @brief Calls vibration feedback.
222 void draggingModeTriggered();
225 * @brief Enables automatic location update.
227 * @param enabled true if enabled, false otherwise
228 * @param updateIntervalMsecs update interval in milliseconds
230 void enableAutomaticLocationUpdate(bool enabled, int updateIntervalMsecs = 0);
233 * @brief Slot for image ready
236 * @param image image pixmap
238 void imageReady(const QString &id, const QPixmap &image);
241 * @brief Requests automatic update.
243 * Makes automatic location update request if user has moved enough.
245 * @param position geo coordinates
247 void requestAutomaticUpdateIfMoved(GeoCoordinate position);
250 * @brief Requests interesting people from current map viewport.
252 * Interesting people is defined by people with same tags as user has.
254 void requestInterestingPeople();
257 * @brief Route is parsed and is ready for further processing.
259 * @param route Route item containing parsed route details
261 void routeParsed(Route &route);
264 * @brief Routes to geo coordinates.
266 * Uses map center coordinates as start point.
267 * @param endPointCoordinates end point geo coordinates
269 void routeTo(const GeoCoordinate &endPointCoordinates);
272 * @brief Route to current cursor position
274 void routeToCursor();
277 * @brief Slot for setting auto centering state.
279 * Calls gps to send last known position
281 * @param enabled true if auto centering was enabled, false otherwise
283 void setAutoCentering(bool enabled);
286 * @brief Sets zoom level to default when first GPS location is received if autocentering
289 void setFirstStartZoomLevel();
292 * @brief Slot for setting GPS state.
294 * @param enabled true if gps should be enabled, false otherwise
296 void setGPS(bool enabled);
299 * @brief Slot for setting power saving state.
301 * @param enabled true if enabled, false otherwise
303 void setPowerSaving(bool enabled);
306 * @brief Shows contact dialog.
308 * Calls MainWindow showContactDialog with contact guid defined by contact's Facebook ID.
309 * @param facebookId contact's facebookId
311 void showContactDialog(const QString &facebookId);
314 * @brief Shows message dialog.
316 * If contact is a friend, show contact dialog instead.
317 * @param receiver receiver facebook ID and name
319 void showMessageDialog(const QPair<QString, QString> &receiver);
322 * @brief Automatic update interval timer timeout.
324 * Requests update location if user has moved.
326 void startAutomaticUpdate();
329 * @brief Called when topmost window is changed
331 * Does set power saving state.
333 * @param isMainWindow True if MainWindow is the topmost one
335 void topmostWindowChanged(bool isMainWindow);
337 /*******************************************************************************
339 ******************************************************************************/
342 * @brief Signals when automatic location update was enabled.
344 * @param enabled true if enabled, false otherwise
346 void automaticLocationUpdateEnabled(bool enabled);
349 * @brief Signal to clear locationUpdateDialog's data
352 void clearUpdateLocationDialogData();
355 * @brief Signal when direction and distance from current map center point to current GPS
356 * location is changed
358 * @param direction Direction in degrees
359 * @param distance Distance in meters
360 * @param draw Should the indicator triangle be drawn or not
362 void directionIndicatorValuesUpdate(qreal direction, qreal distance, bool draw);
365 * @brief Signals when new friends data is ready
367 * @param friendList List of User instances (friends)
369 void friendsLocationsReady(QList<User *> &friendList);
372 * @brief Signals when friend's image is ready
374 * @param user Instance of friend
376 void friendImageReady(const QString &id, const QPixmap &image);
379 * @brief Emited when location request is parsed and is ready for further processing
381 * @param result List of Location items
383 void locationDataParsed(QList<Location> &result);
386 * @brief Signals when users's image is ready
388 * @param user Instance of friend
390 void userImageReady(const QString &id, const QPixmap &image);
393 * @brief Signals when new user data is ready
395 * @param user Instance of User
397 void userLocationReady(User *user);
399 /*******************************************************************************
401 ******************************************************************************/
403 bool m_autoCenteringEnabled; ///< Auto centering flag
404 bool m_automaticUpdateFirstStart; ///< Automatic location update first start flag
405 bool m_automaticUpdateRequest; ///< Flag for automatic update request
406 bool m_userMoved; ///< Flag for user move
408 QTimer *m_automaticUpdateIntervalTimer; ///< Automatic update interval timer
410 ContactManager *m_contactManager; ///< Instance of contact manager
411 FacebookAuthentication *m_facebookAuthenticator; ///< Instance for facebook authenticator
412 GeocodingService *m_geocodingService; ///< Instance of the geocoding service
413 GeoCoordinate m_lastUpdatedGPSPosition; ///< Last updated GPS position
414 GPSPosition *m_gps; ///< Instance of the gps position
415 MainWindow *m_ui; ///< Instance of the MainWindow UI
416 MapEngine *m_mapEngine; ///< MapEngine
417 NetworkAccessManager *m_networkAccessManager; ///< NetworkAccessManager
418 RoutingService *m_routingService; ///< Instance of the routing service
419 SituareService *m_situareService; ///< Instance of the situare server communication service
420 MCE *m_mce; ///< Instance of the MCE