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 error Error message
76 void error(const QString &error);
79 * @brief Slot to intercept signal when username is fetched from settings
82 void fetchUsernameFromSettings();
85 * @brief Slot to intercept signal when Login/Logout action is pressed
88 void loginActionPressed();
91 * @brief Slot to intercept signal from successful login
93 * @param freshLogin Was login done via login dialog
94 * @param credentials Facebook credentials
96 void loginOk(bool freshLogin, const FacebookCredentials &credentials);
99 * @brief Slot to intercept signal when user has cancelled login process
101 void loginProcessCancelled();
104 * @brief Changes application state when logged out
110 * @brief Calls reverseGeo from SituareService to translate coordinates to street address
113 void requestAddress();
116 * @brief Calls updateLocation from SituareService to send the location update to
119 * @param status Status message
120 * @param publish Publish on Facebook
122 void requestUpdateLocation(const QString &status = QString(), bool publish = false);
125 * @brief Slot to refresh user data
127 void refreshUserData();
130 * @brief Slot to intercept signal from successful location update
133 void updateWasSuccessful();
136 * @brief Slot to intercept signal when new user data is available.
137 * Splits User and friendsList data and emits them as two different signals.
139 * @param user instance of User
140 * @param friendsList list of User instances (friends)
142 void userDataChanged(User *user, QList<User *> &friendsList);
146 * @brief Checks if user is moved enough for position auto update.
148 * @return true if moved engouh, false otherwise
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 void automaticUpdateIntervalTimerTimeout();
187 * @brief Set auto centering feature enabled / disabled
189 void changeAutoCenteringSetting(bool enabled);
192 * @brief Slot for disabling automatic centering when map is scrolled manually
194 void disableAutoCentering();
197 * @brief Slot for auto centering enabling.
199 * Calls gps to send last known position
201 * @param enabled true if auto centering was enabled, false otherwise
203 void enableAutoCentering(bool enabled);
206 * @brief Slot for gps enabling.
208 * @param enabled true if gps should be enabled, false otherwise
210 void enableGPS(bool enabled);
213 * @brief Slot for intercepting signal when credentials are invalid
216 void invalidCredentials();
219 * @brief Saves GPS position.
221 * Saves GPS position if it has changed enough and sets m_userMoved flag.
223 * @param position geo coordinates
225 void saveGPSPosition(QPointF position);
228 * @brief Enables automatic location update.
230 * @param enabled true if
232 void enableAutomaticLocationUpdate(bool enabled, int updateIntervalMsecs = -1);
234 /*******************************************************************************
236 ******************************************************************************/
239 * @brief Signals when new friends data is ready
241 * @param friendList List of User instances (friends)
243 void friendsLocationsReady(QList<User *> &friendList);
246 * @brief Signals when new user data is ready
248 * @param user Instance of User
250 void userLocationReady(User *user);
252 /*******************************************************************************
254 ******************************************************************************/
256 bool m_autoCenteringEnabled; ///< Auto centering enabled
257 bool m_loggedIn; ///< Login state
259 FacebookAuthentication *m_facebookAuthenticator; ///< Instance for facebook authenticator
260 GPSPosition *m_gps; ///< Instance of the gps position
261 MainWindow *m_ui; ///< Instance of the MainWindow UI
262 MapEngine *m_mapEngine; ///< MapEngine
263 SituareService *m_situareService; ///< Instance of the situare server communication service
265 QTimer *m_automaticUpdateIntervalTimer; ///< Automatic update interval timer
266 QPointF m_lastUpdatedGPSPosition; ///< Last updated GPS position
267 bool m_userMoved; ///< Flag for user moving