Merge branch 'master' into login_browser
[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 FacebookLoginBrowser;
30
31 /**
32 * @brief FacebookAuthentication class takes care of parsing and handling of  credentials for
33 *        Facebook. Other components of Situare application needs credentials to communicate with
34 *        facebook.
35 *
36 * @author Ville Tiensuu
37 */
38 class FacebookAuthentication : public QObject
39 {
40     Q_OBJECT
41
42 public:
43     /**
44     * @brief FacebookAuthentication constructor
45     *
46     * -Checks if there is valid credentials stored on the file. If there is emits signal.
47     *
48     * @param parent instance of parent
49     */
50     FacebookAuthentication(QObject *parent = 0);
51
52 /*******************************************************************************
53  * MEMBER FUNCTIONS AND SLOTS
54  ******************************************************************************/
55 public:
56     void login();
57
58 public slots:
59
60     /**
61     * @brief Clears account iformation from settings
62     *
63     * @param keepUsername keep = true, false otherwise
64     */
65     void clearAccountInformation(bool keepUsername = false);
66
67     void setBrowser(FacebookLoginBrowser *browser);
68
69 private:
70     QString parseSession(const QUrl &url);
71
72 private slots:
73     void browserDestroyed();
74
75     void loadFinished(bool ok);
76
77     void urlChanged(const QUrl &url);
78
79 /*******************************************************************************
80  * SIGNALS
81  ******************************************************************************/
82 signals:
83     void buildLoginBrowser();
84
85     /**
86     * @brief Signals error
87     *
88     * @param context error context
89     * @param error error code
90     */
91     void error(const int context, const int error);
92
93     void loggedIn(const QString session);
94
95 /*******************************************************************************
96  * DATA MEMBERS
97  ******************************************************************************/
98 private:
99     FacebookLoginBrowser *m_browser;
100 };
101
102 #endif // FACEBOOKAUTHENTICATION_H