fixed review issues
[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
36 /**
37 * @brief Engine class for Situare Application
38 *
39 * This class handles all the underlaying login of the Situare
40 * application.
41 *
42 * @class SituareEngine engine.h "engine/engine.h"
43 */
44 class SituareEngine : public QObject
45 {
46     Q_OBJECT
47 public:
48     /**
49     * @brief Constructor
50     *
51     * @param parent
52     */
53     SituareEngine(QMainWindow *parent = 0);
54
55     /**
56     * @brief Destructor
57     */
58     ~SituareEngine();
59
60 /*******************************************************************************
61  * MEMBER FUNCTIONS AND SLOTS
62  ******************************************************************************/
63 public slots:
64     /**
65     * @brief Slot to intercept error signal from ImageFetcher and SituareService
66     *
67     * @param error Error message
68     */
69     void error(const QString &error);
70
71     /**
72     * @brief Slot to intercept signal from successful login
73     */
74     void loginOk();
75
76     /**
77     * @brief Slot to receive location of crosshair
78     *
79     * @param ownLocation (Latitude and Longitude)
80     */
81     void receiveOwnLocation(QPointF ownLocation);
82
83     /**
84     * @brief Calls reverseGeo from SituareService to translate coordinates to street address
85     *
86     */
87     void requestAddress();
88
89     /**
90     * @brief Calls updateLocation from SituareService to send the location update to
91     *        Situare server.
92     *
93     * @param status Status message
94     * @param publish Publish on Facebook
95     */
96     void requestUpdateLocation(const QString &status, bool publish);
97
98     /**
99     * @brief Slot to refresh user data
100     */
101     void refreshUserData();
102
103     /**
104     * @brief Slot to intercept signal from successful location update
105     *
106     */
107     void updateWasSuccessful();
108
109     /**
110     * @brief Slot to intercept signal when new user data is available.
111     *        Splits User and friendsList data and emits them as two different signals.
112     *
113     * @param user instance of User
114     * @param friendsList list of User instances (friends)
115     */
116     void userDataChanged(User *user, QList<User *> &friendsList);
117
118     /**
119     * @brief Slot for auto centering enabling.
120     *
121     * Calls gps to send last known position
122     * @param enabled true if auto centering was enabled, false otherwise
123     */
124     void enableAutoCentering(bool enabled);
125
126     /**
127     * @brief Slot for gps enabling.
128     *
129     * @param enabled true if gps should be enabled, false otherwise
130     */
131     void enableGPS(bool enabled);
132         
133     /**
134     * @brief Slot to intercept signal when user has cancelled login process
135     */
136     void loginProcessCancelled();
137
138 /*******************************************************************************
139  * SIGNALS
140  ******************************************************************************/
141 signals:
142     /**
143     * @brief Signals when new friends data is ready
144     *
145     * @param friendList List of User instances (friends)
146     */
147     void friendsLocationsReady(QList<User *> &friendList);
148
149     /**
150     * @brief Signal causes mapengine to send updated location of crosshair.
151     *
152     */
153     void requestOwnLocation();
154
155     /**
156     * @brief Signals when new user data is ready
157     *
158     * @param user Instance of User
159     */
160     void userLocationReady(User *user);
161
162 /*******************************************************************************
163  * DATA MEMBERS
164  ******************************************************************************/
165 private:
166     bool m_autoCenteringEnabled;    ///< Auto centering enabled
167     bool m_gpsEnabled;              ///< GPS enabled
168     FacebookAuthentication *m_facebookAuthenticator; ///< Instance for facebook authenticator
169     GPSPositionInterface *m_gps;   ///< Instance of the gps position
170     MainWindow *m_ui; ///< Instance of the MainWindow UI
171     SituareService *m_situareService; ///< Instance of the situare server communication service
172     QPointF m_latestLocation; ///< Placeholder for user's latest asked location
173 };
174
175 #endif // ENGINE_H