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,
35 class FacebookAuthentication;
36 class FacebookCredentials;
46 * @brief Engine class for Situare Application
48 * This class handles all the underlaying login of the Situare
51 class SituareEngine : public QObject
60 SituareEngine(QMainWindow *parent = 0);
67 /*******************************************************************************
68 * MEMBER FUNCTIONS AND SLOTS
69 ******************************************************************************/
72 * @brief Slot to intercept error signal from ImageFetcher and SituareService
74 * @param context Error context
75 * @param error Error message
77 void error(const int context, const int error);
80 * @brief Slot to intercept signal when username is fetched from settings
83 void fetchUsernameFromSettings();
86 * @brief Slot to intercept signal when Login/Logout action is pressed
89 void loginActionPressed();
92 * @brief Slot to intercept signal from successful login
98 * @brief Slot to intercept signal when user has cancelled login process
100 void loginProcessCancelled();
103 * @brief Changes application state when logged out
109 * @brief Calls reverseGeo from SituareService to translate coordinates to street address
112 void requestAddress();
115 * @brief Calls updateLocation from SituareService to send the location update to
118 * @param status Status message
119 * @param publish Publish on Facebook
121 void requestUpdateLocation(const QString &status = QString(), bool publish = false);
124 * @brief Slot to refresh user data
126 void refreshUserData();
129 * @brief Slot to intercept signal from successful location update
132 void updateWasSuccessful();
135 * @brief Slot to intercept signal when new user data is available.
136 * Splits User and friendsList data and emits them as two different signals.
138 * @param user instance of User
139 * @param friendsList list of User instances (friends)
141 void userDataChanged(User *user, QList<User *> &friendsList);
145 * @brief Checks if user is moved enough for position auto update.
147 * @return true if moved engouh, false otherwise
152 * @brief Read settings and determine whether to use GPS and autocentering.
153 * When values does not found on the settings, GPS and autocentering are enabled as a default.
155 void initializeGpsAndAutocentering();
158 * @brief Connect signals coming from Facdebook authenticator
160 void signalsFromFacebookAuthenticator();
163 * @brief Connect signals coming from GPS
165 void signalsFromGPS();
168 * @brief Connect signals coming from MainWindow
170 void signalsFromMainWindow();
173 * @brief Connect signals coming from MapEngine
175 void signalsFromMapEngine();
178 * @brief Connect signals coming from MapView
180 void signalsFromMapView();
183 * @brief Connect signals coming from Situare
185 void signalsFromSituareService();
189 * @brief Automatic update interval timer timeout.
191 * Requests update location if user has moved.
193 void automaticUpdateIntervalTimerTimeout();
196 * @brief Set auto centering feature enabled / disabled
198 * @param enabled true if enabled, false otherwise
200 void changeAutoCenteringSetting(bool enabled);
203 * @brief Slot for disabling automatic centering when map is scrolled manually
205 void disableAutoCentering();
208 * @brief Slot for auto centering enabling.
210 * Calls gps to send last known position
212 * @param enabled true if auto centering was enabled, false otherwise
214 void enableAutoCentering(bool enabled);
217 * @brief Slot for gps enabling.
219 * @param enabled true if gps should be enabled, false otherwise
221 void enableGPS(bool enabled);
224 * @brief Enables automatic location update.
226 * @param enabled true if enabled, false otherwise
227 * @param updateIntervalMsecs update interval in milliseconds
229 void enableAutomaticLocationUpdate(bool enabled, int updateIntervalMsecs = 0);
232 * @brief Sets zoom level to default when first GPS location is received if autocentering
235 * @param latLonCoordinate own location
236 * @param accuracy accuracy of GPS location
238 void setFirstStartZoomLevel(QPointF latLonCoordinate, qreal accuracy);
241 * @brief Saves GPS position.
243 * Saves GPS position if it has changed enough and sets m_userMoved flag.
245 * @param position geo coordinates
247 void saveGPSPosition(QPointF position);
249 /*******************************************************************************
251 ******************************************************************************/
254 * @brief Signals when automatic location update was enabled.
256 * @param enabled true if enabled, false otherwise
258 void automaticLocationUpdateEnabled(bool enabled);
261 * @brief Signal to clear locationUpdateDialog's data
264 void clearUpdateLocationDialogData();
267 * @brief Signals when new friends data is ready
269 * @param friendList List of User instances (friends)
271 void friendsLocationsReady(QList<User *> &friendList);
274 * @brief Signals when new user data is ready
276 * @param user Instance of User
278 void userLocationReady(User *user);
280 /*******************************************************************************
282 ******************************************************************************/
284 bool m_autoCenteringEnabled; ///< Auto centering flag
285 bool m_automaticUpdateFirstStart; ///< Automatic location update first start flag
286 bool m_userMoved; ///< Flag for user moving
288 FacebookAuthentication *m_facebookAuthenticator; ///< Instance for facebook authenticator
289 GPSPosition *m_gps; ///< Instance of the gps position
290 MainWindow *m_ui; ///< Instance of the MainWindow UI
291 MapEngine *m_mapEngine; ///< MapEngine
292 SituareService *m_situareService; ///< Instance of the situare server communication service
294 QTimer *m_automaticUpdateIntervalTimer; ///< Automatic update interval timer
295 QPointF m_lastUpdatedGPSPosition; ///< Last updated GPS position