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