Second draft, credentials are not saved to settings anymore. WebView is
[situare] / src / engine / engine.h
1  /*
2     Situare - A location system for Facebook
3     Copyright (C) 2010  Ixonos Plc. Authors:
4
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
9
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.
13
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.
18
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,
22     USA.
23  */
24
25
26 #ifndef ENGINE_H
27 #define ENGINE_H
28
29 #include <QObject>
30
31 class QMainWindow;
32
33 class FacebookAuthentication;
34 class FacebookCredentials;
35 class GPSPosition;
36 class MainWindow;
37 class MapEngine;
38 class SituareService;
39 class User;
40
41 /**
42 * @brief Engine class for Situare Application
43 *
44 * This class handles all the underlaying login of the Situare
45 * application.
46 */
47 class SituareEngine : public QObject
48 {
49     Q_OBJECT
50 public:
51     /**
52     * @brief Constructor
53     *
54     * @param parent
55     */
56     SituareEngine(QMainWindow *parent = 0);
57
58     /**
59     * @brief Destructor
60     */
61     ~SituareEngine();
62
63 /*******************************************************************************
64  * MEMBER FUNCTIONS AND SLOTS
65  ******************************************************************************/
66 public slots:
67     /**
68     * @brief Slot to intercept error signal from ImageFetcher and SituareService
69     *
70     * @param error Error message
71     */
72     void error(const QString &error);
73
74     /**
75     * @brief Slot to intercept signal when username is fetched from settings
76     *
77     */
78     void fetchUsernameFromSettings();
79
80     /**
81     * @brief Slot to intercept signal when Login/Logout action is pressed
82     *
83     */
84     void loginActionPressed();
85
86     /**
87     * @brief Slot to intercept signal from successful login
88     *
89     */
90     void loginOk();
91
92     /**
93     * @brief Slot to intercept signal when user has cancelled login process
94     */
95     void loginProcessCancelled();
96
97     /**
98     * @brief Changes application state when logged out
99     *
100     */
101     void logout();
102
103     /**
104     * @brief Calls reverseGeo from SituareService to translate coordinates to street address
105     *
106     */
107     void requestAddress();
108
109     /**
110     * @brief Calls updateLocation from SituareService to send the location update to
111     *        Situare server.
112     *
113     * @param status Status message
114     * @param publish Publish on Facebook
115     */
116     void requestUpdateLocation(const QString &status, bool publish);
117
118     /**
119     * @brief Slot to refresh user data
120     */
121     void refreshUserData();
122
123     /**
124     * @brief Slot to intercept signal from successful location update
125     *
126     */
127     void updateWasSuccessful();
128
129     /**
130     * @brief Slot to intercept signal when new user data is available.
131     *        Splits User and friendsList data and emits them as two different signals.
132     *
133     * @param user instance of User
134     * @param friendsList list of User instances (friends)
135     */
136     void userDataChanged(User *user, QList<User *> &friendsList);
137
138 private:
139     /**
140       * @brief Connect signals coming from Facdebook authenticator
141       */
142     void signalsFromFacebookAuthenticator();
143
144     /**
145       * @brief Connect signals coming from GPS
146       */
147     void signalsFromGPS();
148
149     /**
150       * @brief Connect signals coming from MainWindow
151       */
152     void signalsFromMainWindow();
153
154     /**
155       * @brief Connect signals coming from MapEngine
156       */
157     void signalsFromMapEngine();
158
159     /**
160       * @brief Connect signals coming from MapView
161       */
162     void signalsFromMapView();
163
164     /**
165       * @brief Connect signals coming from Situare
166       */
167     void signalsFromSituareService();
168
169 private slots:
170     /**
171       * @brief Set auto centering feature enabled / disabled
172       */
173     void changeAutoCenteringSetting(bool enabled);
174
175     /**
176       * @brief Slot for disabling automatic centering when map is scrolled manually
177       */
178     void disableAutoCentering();
179
180     /**
181     * @brief Slot for auto centering enabling.
182     *
183     * Calls gps to send last known position
184     *
185     * @param enabled true if auto centering was enabled, false otherwise
186     */
187     void enableAutoCentering(bool enabled);
188
189     /**
190     * @brief Slot for gps enabling.
191     *
192     * @param enabled true if gps should be enabled, false otherwise
193     */
194     void enableGPS(bool enabled);
195
196     /**
197     * @brief Slot for intercepting signal when credentials are invalid
198     *
199     */
200     void invalidCredentials();
201
202 /*******************************************************************************
203  * SIGNALS
204  ******************************************************************************/
205 signals:
206     /**
207     * @brief Signals when new friends data is ready
208     *
209     * @param friendList List of User instances (friends)
210     */
211     void friendsLocationsReady(QList<User *> &friendList);
212
213     /**
214     * @brief Signals when new user data is ready
215     *
216     * @param user Instance of User
217     */
218     void userLocationReady(User *user);
219
220 /*******************************************************************************
221  * DATA MEMBERS
222  ******************************************************************************/
223 private:
224     bool m_autoCenteringEnabled;  ///< Auto centering enabled
225     bool m_loggedIn;              ///< Login state
226
227     FacebookAuthentication *m_facebookAuthenticator; ///< Instance for facebook authenticator
228     GPSPosition *m_gps;                              ///< Instance of the gps position
229     MainWindow *m_ui;                                ///< Instance of the MainWindow UI
230     MapEngine *m_mapEngine;                          ///< MapEngine
231     SituareService *m_situareService;  ///< Instance of the situare server communication service
232
233 };
234
235 #endif // ENGINE_H