First "working" version after 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
9     Situare is free software; you can redistribute it and/or
10     modify it under the terms of the GNU General Public License
11     version 2 as published by the Free Software Foundation.
12
13     Situare is distributed in the hope that it will be useful,
14     but WITHOUT ANY WARRANTY; without even the implied warranty of
15     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16     GNU General Public License for more details.
17
18     You should have received a copy of the GNU General Public License
19     along with Situare; if not, write to the Free Software
20     Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301,
21     USA.
22  */
23
24
25 #ifndef ENGINE_H
26 #define ENGINE_H
27
28 #include <QWidget>
29 #include <QtDebug>
30 #include "facebookservice/facebookauthentication.h"
31 #include "situareservice/situareservice.h"
32 #include "ui/mainwindow.h"
33
34 class GPSPositionInterface;
35 class MapEngine;
36
37 /**
38 * @brief Engine class for Situare Application
39 *
40 * This class handles all the underlaying login of the Situare
41 * application.
42 *
43 * @class SituareEngine engine.h "engine/engine.h"
44 */
45 class SituareEngine : public QObject
46 {
47     Q_OBJECT
48 public:
49     /**
50     * @brief Constructor
51     *
52     * @param parent
53     */
54     SituareEngine(QMainWindow *parent = 0);
55
56     /**
57     * @brief Destructor
58     */
59     ~SituareEngine();
60
61 /*******************************************************************************
62  * MEMBER FUNCTIONS AND SLOTS
63  ******************************************************************************/
64 public slots:
65     /**
66     * @brief Slot to intercept error signal from ImageFetcher and SituareService
67     *
68     * @param error Error message
69     */
70     void error(const QString &error);
71
72     /**
73     * @brief Slot to intercept signal from successful login
74     */
75     void loginOk();
76
77     /**
78     * @brief Calls reverseGeo from SituareService to translate coordinates to street address
79     *
80     */
81     void requestAddress();
82
83     /**
84     * @brief Calls updateLocation from SituareService to send the location update to
85     *        Situare server.
86     *
87     * @param status Status message
88     * @param publish Publish on Facebook
89     */
90     void requestUpdateLocation(const QString &status, bool publish);
91
92     /**
93     * @brief Slot to refresh user data
94     */
95     void refreshUserData();
96
97     /**
98     * @brief Slot to intercept signal from successful location update
99     *
100     */
101     void updateWasSuccessful();
102
103     /**
104     * @brief Slot to intercept signal when new user data is available.
105     *        Splits User and friendsList data and emits them as two different signals.
106     *
107     * @param user instance of User
108     * @param friendsList list of User instances (friends)
109     */
110     void userDataChanged(User *user, QList<User *> &friendsList);
111
112     /**
113     * @brief Slot for auto centering enabling.
114     *
115     * Calls gps to send last known position
116     * @param enabled true if auto centering was enabled, false otherwise
117     */
118     void enableAutoCentering(bool enabled);
119
120     /**
121     * @brief Slot for gps enabling.
122     *
123     * @param enabled true if gps should be enabled, false otherwise
124     */
125     void enableGPS(bool enabled);
126         
127     /**
128     * @brief Slot to intercept signal when user has cancelled login process
129     */
130     void loginProcessCancelled();
131
132 private slots:
133     void disableGPS();
134
135 private:
136     void signalsFromGPS();
137
138     void signalsFromMainWindow();
139
140     void signalsFromMapEngine();
141
142     void signalsFromMapView();
143
144     void signalsFromSituareService();
145
146 /*******************************************************************************
147  * SIGNALS
148  ******************************************************************************/
149 signals:
150
151     /**
152     * @brief Signals when new friends data is ready
153     *
154     * @param friendList List of User instances (friends)
155     */
156     void friendsLocationsReady(QList<User *> &friendList);
157
158     /**
159     * @brief Signals when new user data is ready
160     *
161     * @param user Instance of User
162     */
163     void userLocationReady(User *user);
164
165 /*******************************************************************************
166  * DATA MEMBERS
167  ******************************************************************************/
168 private:
169     bool m_autoCenteringEnabled;    ///< Auto centering enabled
170     bool m_gpsEnabled;              ///< GPS enabled
171
172     QPointF m_latestLocation; ///< Placeholder for user's latest asked location
173
174     FacebookAuthentication *m_facebookAuthenticator; ///< Instance for facebook authenticator
175     GPSPositionInterface *m_gps;   ///< Instance of the gps position
176     MainWindow *m_ui; ///< Instance of the MainWindow UI
177     MapEngine *m_mapEngine;                 ///< MapEngine
178     SituareService *m_situareService; ///< Instance of the situare server communication service    
179 };
180
181 #endif // ENGINE_H