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
71 /*******************************************************************************
72 * MEMBER FUNCTIONS AND SLOTS
73 ******************************************************************************/
76 * @brief Slot to intercept error signal from ImageFetcher and SituareService
78 * @param context Error context
79 * @param error Error message
81 void error(const int context, const int error);
84 * @brief Slot to intercept signal when username is fetched from settings
87 void fetchUsernameFromSettings();
90 * @brief Slot to intercept signal when Login/Logout action is pressed
93 void loginActionPressed();
96 * @brief Slot to intercept signal from successful login
102 * @brief Slot to intercept signal when user has cancelled login process
104 void loginProcessCancelled();
107 * @brief Changes application state when logged out
113 * @brief Calls reverseGeo from SituareService to translate coordinates to street address
116 void requestAddress();
119 * @brief Calls updateLocation from SituareService to send the location update to
122 * @param status Status message
123 * @param publish Publish on Facebook
125 void requestUpdateLocation(const QString &status = QString(), bool publish = false);
128 * @brief Slot to refresh user data
130 void refreshUserData();
133 * @brief Slot to intercept signal from successful location update
136 void updateWasSuccessful();
139 * @brief Slot to intercept signal when new user data is available.
140 * Splits User and friendsList data and emits them as two different signals.
142 * @param user instance of User
143 * @param friendsList list of User instances (friends)
145 void userDataChanged(User *user, QList<User *> &friendsList);
149 * @brief Read settings and determine whether to use GPS and autocentering.
150 * When values does not found on the settings, GPS and autocentering are enabled as a default.
152 void initializeGpsAndAutocentering();
155 * @brief Connect signals coming from Facdebook authenticator
157 void signalsFromFacebookAuthenticator();
160 * @brief Connect signals coming from GPS
162 void signalsFromGPS();
165 * @brief Connect signals coming from MainWindow
167 void signalsFromMainWindow();
170 * @brief Connect signals coming from MapEngine
172 void signalsFromMapEngine();
175 * @brief Connect signals coming from MapView
177 void signalsFromMapView();
180 * @brief Connect signals coming from Situare
182 void signalsFromSituareService();
186 * @brief Set auto centering feature enabled / disabled
188 * @param enabled true if enabled, false otherwise
190 void changeAutoCenteringSetting(bool enabled);
193 * @brief Slot for disabling automatic centering when map is scrolled manually
195 void disableAutoCentering();
198 * @brief Slot for auto centering enabling.
200 * Calls gps to send last known position
202 * @param enabled true if auto centering was enabled, false otherwise
204 void enableAutoCentering(bool enabled);
207 * @brief Slot for gps enabling.
209 * @param enabled true if gps should be enabled, false otherwise
211 void enableGPS(bool enabled);
214 * @brief Enables automatic location update.
216 * @param enabled true if enabled, false otherwise
217 * @param updateIntervalMsecs update interval in milliseconds
219 void enableAutomaticLocationUpdate(bool enabled, int updateIntervalMsecs = 0);
222 * @brief Slot for enabling power saving.
224 * @param enabled true if enabled, false otherwise
226 void enablePowerSave(bool enabled);
229 * @brief Slot to intercept signal when user's/friend's image is downloaded
231 * @param user Instance of user/friend
233 void imageReady(User *user);
236 * @brief Requests automatic update.
238 * Makes automatic location update request if user has moved enough.
240 * @param position geo coordinates
242 void requestAutomaticUpdateIfMoved(GeoCoordinate position);
245 * @brief Sets zoom level to default when first GPS location is received if autocentering
248 void setFirstStartZoomLevel();
251 * @brief Automatic update interval timer timeout.
253 * Requests update location if user has moved.
255 void startAutomaticUpdate();
257 /*******************************************************************************
259 ******************************************************************************/
262 * @brief Signals when automatic location update was enabled.
264 * @param enabled true if enabled, false otherwise
266 void automaticLocationUpdateEnabled(bool enabled);
269 * @brief Signal to clear locationUpdateDialog's data
272 void clearUpdateLocationDialogData();
275 * @brief Signals when new friends data is ready
277 * @param friendList List of User instances (friends)
279 void friendsLocationsReady(QList<User *> &friendList);
282 * @brief Signals when friend's image is ready
284 * @param user Instance of friend
286 void friendImageReady(User *user);
289 * @brief Signals when new user data is ready
291 * @param user Instance of User
293 void userLocationReady(User *user);
295 /*******************************************************************************
297 ******************************************************************************/
299 bool m_autoCenteringEnabled; ///< Auto centering flag
300 bool m_automaticUpdateFirstStart; ///< Automatic location update first start flag
301 bool m_automaticUpdateRequest; ///< Flag for automatic update request
302 bool m_userMoved; ///< Flag for user move
305 Application *m_app; ///< Pointer to Application
307 FacebookAuthentication *m_facebookAuthenticator; ///< Instance for facebook authenticator
308 GPSPosition *m_gps; ///< Instance of the gps position
309 MainWindow *m_ui; ///< Instance of the MainWindow UI
310 MapEngine *m_mapEngine; ///< MapEngine
311 NetworkAccessManager *m_networkAccessManager; ///< NetworkAccessManager
312 SituareService *m_situareService; ///< Instance of the situare server communication service
313 MCE *m_mce; ///< Instance of the MCE
315 QTimer *m_automaticUpdateIntervalTimer; ///< Automatic update interval timer
316 GeoCoordinate m_lastUpdatedGPSPosition; ///< Last updated GPS position