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;
40 class NetworkAccessManager;
48 * @brief Engine class for Situare Application
50 * This class handles all the underlaying login of the Situare
53 class SituareEngine : public QObject
62 SituareEngine(QMainWindow *parent = 0);
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 display state changed.
198 * @param enabled true if enabled, false otherwise
200 void displayStateChanged(bool enabled);
203 * @brief Slot for auto centering enabling.
205 * Calls gps to send last known position
207 * @param enabled true if auto centering was enabled, false otherwise
209 // void enableAutoCentering(bool enabled);
212 * @brief Slot for gps enabling.
214 * @param enabled true if gps should be enabled, false otherwise
216 void enableGPS(bool enabled);
219 * @brief Enables automatic location update.
221 * @param enabled true if enabled, false otherwise
222 * @param updateIntervalMsecs update interval in milliseconds
224 void enableAutomaticLocationUpdate(bool enabled, int updateIntervalMsecs = 0);
227 * @brief Requests automatic update.
229 * Makes automatic location update request if user has moved enough.
231 * @param position geo coordinates
233 void requestAutomaticUpdateIfMoved(QPointF position);
236 * @brief Sets zoom level to default when first GPS location is received if autocentering
239 * @param latLonCoordinate own location
240 * @param accuracy accuracy of GPS location
242 void setFirstStartZoomLevel(QPointF latLonCoordinate, qreal accuracy);
245 * @brief Automatic update interval timer timeout.
247 * Requests update location if user has moved.
249 void startAutomaticUpdate();
251 /*******************************************************************************
253 ******************************************************************************/
256 * @brief Signals when automatic location update was enabled.
258 * @param enabled true if enabled, false otherwise
260 void automaticLocationUpdateEnabled(bool enabled);
263 * @brief Signal to clear locationUpdateDialog's data
266 void clearUpdateLocationDialogData();
269 * @brief Signals when new friends data is ready
271 * @param friendList List of User instances (friends)
273 void friendsLocationsReady(QList<User *> &friendList);
276 * @brief Signals when new user data is ready
278 * @param user Instance of User
280 void userLocationReady(User *user);
282 /*******************************************************************************
284 ******************************************************************************/
286 // bool m_autoCenteringEnabled; ///< Auto centering flag
287 bool m_automaticUpdateFirstStart; ///< Automatic location update first start flag
288 bool m_automaticUpdateRequest; ///< Flag for automatic update request
289 bool m_userMoved; ///< Flag for user move
292 FacebookAuthentication *m_facebookAuthenticator; ///< Instance for facebook authenticator
293 GPSPosition *m_gps; ///< Instance of the gps position
294 MainWindow *m_ui; ///< Instance of the MainWindow UI
295 MapEngine *m_mapEngine; ///< MapEngine
296 NetworkAccessManager *m_networkAccessManager; ///< NetworkAccessManager
297 SituareService *m_situareService; ///< Instance of the situare server communication service
298 MCE *m_mce; ///< Instance of the MCE
300 QTimer *m_automaticUpdateIntervalTimer; ///< Automatic update interval timer
301 QPointF m_lastUpdatedGPSPosition; ///< Last updated GPS position