Updated user and friendslist signals and image fetching
[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
8     Situare is free software; you can redistribute it and/or
9     modify it under the terms of the GNU General Public License
10     version 2 as published by the Free Software Foundation.
11
12     Situare is distributed in the hope that it will be useful,
13     but WITHOUT ANY WARRANTY; without even the implied warranty of
14     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15     GNU General Public License for more details.
16
17     You should have received a copy of the GNU General Public License
18     along with Situare; if not, write to the Free Software
19     Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301,
20     USA.
21  */
22
23
24 #ifndef ENGINE_H
25 #define ENGINE_H
26
27 #include <QWidget>
28 #include <QtDebug>
29 #include "facebookservice/facebookauthentication.h"
30 #include "situareservice/situareservice.h"
31 #include "ui/mainwindow.h"
32
33 /**
34 * @brief Engine class for Situare Application
35 *
36 * This class handles all the underlaying login of the Situare
37 * application.
38 *
39 * @class SituareEngine engine.h "engine/engine.h"
40 */
41 class SituareEngine : public QObject
42 {
43     Q_OBJECT
44 public:
45     /**
46     * @brief Constructor
47     *
48     * @param parent
49     */
50     SituareEngine(QMainWindow *parent = 0);
51
52     /**
53     * @brief Destructor
54     */
55     ~SituareEngine();
56
57 /*******************************************************************************
58  * MEMBER FUNCTIONS AND SLOTS
59  ******************************************************************************/
60 public slots:
61
62     /**
63     * @brief Slot to intercept error signal from ImageFetcher and SituareService
64     *
65     * @param error Error message
66     */
67     void error(const QString &error);
68
69     /**
70     * @brief Slot to intercept signal from successful login
71     */
72     void loginOk();
73
74     /**
75     * @brief Calls reverseGeo from SituareService to translate coordinates to street address
76     *
77     */
78     void requestAddress();
79
80     /**
81     * @brief Calls updateLocation from SituareService to send the location update to
82     *        Situare server.
83     *
84     * @param status Status message
85     * @param publish Publish on Facebook
86     */
87     void requestUpdateLocation(const QString &status, bool publish);
88
89     /**
90     * @brief Slot to initiate update friends list function
91     */
92     void updateFriendsList();
93
94         /**
95     * @brief Slot to intercept signal from successful location update
96     *
97     */
98     void updateWasSuccessful();
99
100     /**
101     * @brief Slot to intercept signal when new user data is available.
102     *        Splits User and friendsList data and emits them as two different signals.
103     *
104     * @param user instance of User
105     * @param friendsList list of User instances (friends)
106     */
107     void userDataChanged(User *user, QList<User *> &friendsList);
108
109 /*******************************************************************************
110  * SIGNALS
111  ******************************************************************************/
112 signals:
113
114     /**
115     * @brief Signals when new user data is ready
116     *
117     * @param user Instance of User
118     */
119     void userLocationReady(User *user);
120
121     /**
122     * @brief Signals when new friends data is ready
123     *
124     * @param friendList List of User instances (friends)
125     */
126     void friendsLocationsReady(QList<User *> &friendList);
127
128 /*******************************************************************************
129  * DATA MEMBERS
130  ******************************************************************************/
131 private:
132     MainWindow *m_ui; ///< Instance of the MainWindow UI
133     FacebookAuthentication *m_facebookAuthenticator; ///< Instance for facebook authenticator
134     SituareService *m_situareService; ///< Instance of the situare server communication service
135 };
136
137 #endif // ENGINE_H