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;
42 class NetworkAccessManager;
50 * @brief Engine class for Situare Application
52 * This class handles all the underlaying login of the Situare
55 class SituareEngine : public QObject
69 /*******************************************************************************
70 * MEMBER FUNCTIONS AND SLOTS
71 ******************************************************************************/
74 * @brief Slot to intercept error signal from ImageFetcher and SituareService
76 * @param context Error context
77 * @param error Error message
79 void error(const int context, const int error);
82 * @brief Slot to intercept signal when username is fetched from settings
85 void fetchUsernameFromSettings();
88 * @brief Slot to intercept signal when Login/Logout action is pressed
91 void loginActionPressed();
94 * @brief Slot to intercept signal from successful login
100 * @brief Slot to intercept signal when user has cancelled login process
102 void loginProcessCancelled();
105 * @brief Changes application state when logged out
111 * @brief Calls reverseGeo from SituareService to translate coordinates to street address
114 void requestAddress();
117 * @brief Calls updateLocation from SituareService to send the location update to
120 * @param status Status message
121 * @param publish Publish on Facebook
123 void requestUpdateLocation(const QString &status = QString(), bool publish = false);
126 * @brief Slot to refresh user data
128 void refreshUserData();
131 * @brief Slot to intercept signal from successful location update
134 void updateWasSuccessful();
137 * @brief Slot to intercept signal when new user data is available.
138 * Splits User and friendsList data and emits them as two different signals.
140 * @param user instance of User
141 * @param friendsList list of User instances (friends)
143 void userDataChanged(User *user, QList<User *> &friendsList);
147 * @brief Read settings and determine whether to use GPS and autocentering.
148 * When values does not found on the settings, GPS and autocentering are enabled as a default.
150 void initializeGpsAndAutocentering();
153 * @brief Connect signals coming from Facdebook authenticator
155 void signalsFromFacebookAuthenticator();
158 * @brief Connect signals coming from GPS
160 void signalsFromGPS();
163 * @brief Connect signals coming from MainWindow
165 void signalsFromMainWindow();
168 * @brief Connect signals coming from MapEngine
170 void signalsFromMapEngine();
173 * @brief Connect signals coming from MapView
175 void signalsFromMapView();
178 * @brief Connect signals coming from Situare
180 void signalsFromSituareService();
184 * @brief Set auto centering feature enabled / disabled
186 * @param enabled true if enabled, false otherwise
188 void changeAutoCenteringSetting(bool enabled);
191 * @brief Slot for disabling automatic centering when map is scrolled manually
193 void disableAutoCentering();
196 * @brief Slot for auto centering enabling.
198 * Calls gps to send last known position
200 * @param enabled true if auto centering was enabled, false otherwise
202 void enableAutoCentering(bool enabled);
205 * @brief Slot for gps enabling.
207 * @param enabled true if gps should be enabled, false otherwise
209 void enableGPS(bool enabled);
212 * @brief Enables automatic location update.
214 * @param enabled true if enabled, false otherwise
215 * @param updateIntervalMsecs update interval in milliseconds
217 void enableAutomaticLocationUpdate(bool enabled, int updateIntervalMsecs = 0);
220 * @brief Slot for enabling power saving.
222 * @param enabled true if enabled, false otherwise
224 void enablePowerSave(bool enabled);
227 * @brief Slot to intercept signal when user's/friend's image is downloaded
229 * @param user Instance of user/friend
231 void imageReady(User *user);
234 * @brief Requests automatic update.
236 * Makes automatic location update request if user has moved enough.
238 * @param position geo coordinates
240 void requestAutomaticUpdateIfMoved(GeoCoordinate position);
243 * @brief Sets zoom level to default when first GPS location is received if autocentering
246 void setFirstStartZoomLevel();
249 * @brief Automatic update interval timer timeout.
251 * Requests update location if user has moved.
253 void startAutomaticUpdate();
255 /*******************************************************************************
257 ******************************************************************************/
260 * @brief Signals when automatic location update was enabled.
262 * @param enabled true if enabled, false otherwise
264 void automaticLocationUpdateEnabled(bool enabled);
267 * @brief Signal to clear locationUpdateDialog's data
270 void clearUpdateLocationDialogData();
273 * @brief Signals when new friends data is ready
275 * @param friendList List of User instances (friends)
277 void friendsLocationsReady(QList<User *> &friendList);
280 * @brief Signals when friend's image is ready
282 * @param user Instance of friend
284 void friendImageReady(User *user);
287 * @brief Signals when new user data is ready
289 * @param user Instance of User
291 void userLocationReady(User *user);
293 /*******************************************************************************
295 ******************************************************************************/
297 bool m_autoCenteringEnabled; ///< Auto centering flag
298 bool m_automaticUpdateFirstStart; ///< Automatic location update first start flag
299 bool m_automaticUpdateRequest; ///< Flag for automatic update request
300 bool m_userMoved; ///< Flag for user move
303 Application *m_app; ///< Pointer to Application
305 FacebookAuthentication *m_facebookAuthenticator; ///< Instance for facebook authenticator
306 GPSPosition *m_gps; ///< Instance of the gps position
307 MainWindow *m_ui; ///< Instance of the MainWindow UI
308 MapEngine *m_mapEngine; ///< MapEngine
309 NetworkAccessManager *m_networkAccessManager; ///< NetworkAccessManager
310 SituareService *m_situareService; ///< Instance of the situare server communication service
311 MCE *m_mce; ///< Instance of the MCE
313 QTimer *m_automaticUpdateIntervalTimer; ///< Automatic update interval timer
314 GeoCoordinate m_lastUpdatedGPSPosition; ///< Last updated GPS position