5c13c87a0f780c8a6361c9e8d4be15331889b6c2
[situare] / src / facebookservice / facebookauthentication.h
1 /*
2    Situare - A location system for Facebook
3    Copyright (C) 2010  Ixonos Plc. Authors:
4
5        Ville Tiensuu - ville.tiensuu@ixonos.com
6        Kaj Wallin - kaj.wallin@ixonos.com
7        Henri Lampela - henri.lampela@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 #ifndef FACEBOOKAUTHENTICATION_H
25 #define FACEBOOKAUTHENTICATION_H
26
27 #include <QUrl>
28
29 class QNetworkReply;
30
31 class FacebookLoginBrowser;
32
33 /**
34 * @brief FacebookAuthentication class takes care of parsing and handling of  credentials for
35 *        Facebook. Other components of Situare application needs credentials to communicate with
36 *        facebook.
37 *
38 * @author Ville Tiensuu
39 */
40 class FacebookAuthentication : public QObject
41 {
42     Q_OBJECT
43
44 public:
45     /**
46     * @brief FacebookAuthentication constructor
47     *
48     * -Checks if there is valid credentials stored on the file. If there is emits signal.
49     *
50     * @param parent instance of parent
51     */
52     FacebookAuthentication(QObject *parent = 0);
53
54 /*******************************************************************************
55  * MEMBER FUNCTIONS AND SLOTS
56  ******************************************************************************/
57 public:
58     void login();
59
60 public slots:
61
62     /**
63     * @brief Clears account iformation from settings
64     *
65     * @param keepUsername keep = true, false otherwise
66     */
67     void clearAccountInformation(bool keepUsername = false);
68
69     void setBrowser(FacebookLoginBrowser *browser);
70
71 private:
72     QString parseSession(const QUrl &url);
73
74 private slots:
75     void browserDestroyed();
76
77     void loadFinished(bool ok);
78
79     void networkReplyHandler(QNetworkReply *reply);
80
81     void urlChanged(const QUrl &url);
82
83 /*******************************************************************************
84  * SIGNALS
85  ******************************************************************************/
86 signals:
87     void buildLoginBrowser();
88
89     /**
90     * @brief Signals error
91     *
92     * @param context error context
93     * @param error error code
94     */
95     void error(const int context, const int error);
96
97     void loggedIn(const QString session);
98
99 /*******************************************************************************
100  * DATA MEMBERS
101  ******************************************************************************/
102 private:
103     FacebookLoginBrowser *m_browser;
104 };
105
106 #endif // FACEBOOKAUTHENTICATION_H