2 Situare - A location system for Facebook
3 Copyright (C) 2010 Ixonos Plc. Authors:
5 Ville Tiensuu - ville.tiensuu@ixonos.com
6 Kaj Wallin - kaj.wallin@ixonos.com
7 Henri Lampela - henri.lampela@ixonos.com
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.
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.
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,
24 #ifndef FACEBOOKAUTHENTICATION_H
25 #define FACEBOOKAUTHENTICATION_H
32 #include "facebookcredentials.h"
33 #include "ui/logindialog.h"
36 * @brief FacebookAuthentication class takes care of transmitting username and password to facebook.
37 * And it also receives credentials from Facebook. Other components of Situare application
38 * needs credentials to communicate with facebook.
40 * @author Ville Tiensuu
41 * @class FacebookAuthentication facebookauthentication.h "facebookauthentication.h"
43 class FacebookAuthentication : public QMainWindow
49 * @brief FacebookAuthentication constructor
51 * -Composes Loginpage from pieces of strings.
52 * -Checks if there is valid credentials stored on the file. If there is emits signal. If not it
54 * -Connects signal from m_webView to UpdateCredentials() method. With this feature it is
55 * verified that class tries always update credentials when web page changes.
56 * -Allocates memory for m_webView and m_mainlayout
58 * @param parent instance of parent
60 FacebookAuthentication(QWidget *parent = 0);
63 * @brief Releases allocated memory for m_webView and m_mainlayout
66 ~FacebookAuthentication();
68 /*******************************************************************************
69 * MEMBER FUNCTIONS AND SLOTS
70 ******************************************************************************/
73 * @brief Getter for m_loginCredentials
75 * @return FacebookCredentials
77 FacebookCredentials loginCredentials() const;
82 * @brief Shows the m_webView and loads page that is specified in the m_facebookLoginPage
83 * variable. Specifies font size for the page.
89 * @brief Slot to intercept signal when user has pressed connect button from loginDialog
92 * @param password Password
94 void loginDialogDone(const QString &email, const QString &password);
97 * @brief Toggle progress indicator.
99 * @param state true if progress indicator should be shown, false otherwise
101 void toggleProgressIndicator(bool state);
106 * @brief Creates login url with given parameters
108 * @param urlParts Url parts
109 * @return QUrl Login page url
111 QUrl formLoginPageUrl(const QStringList & urlParts) const;
114 * @brief Reads previous stored credentials from file.
116 * @param credentialsFromFile This dataclass is the place where method stores credentials.
117 * Corrent parameter here is m_loginCredentials
119 void readCredentials(FacebookCredentials &credentialsFromFile);
122 * @brief Checks expiration time of credentials and compares it to current time.
124 * @param credentials this parameter represents credentials that will be verified.
125 * @return bool returns true if expiration time is after current time. in other cases returns
128 bool verifyCredentials(const FacebookCredentials &credentials) const;
131 * @brief Writes credentials to File
133 * @param credentials Contents of this dataclass is stored to file
135 void writeCredentials(const FacebookCredentials &credentials);
139 * @brief Search credentials from URL that is given as parameter.
140 * If credentials are found thay are stored to loginCredentials variable.
142 * @param url URL where this method tries to find credentials.
143 * @return bool if credentials are found returns true,
144 * if credentials are not found returns false.
146 bool updateCredentials(const QUrl & url);
149 * @brief Slot to intercept signal when webview has finished loading webpage
151 * @param done Status of the loading
153 void loadDone(bool done);
156 * @brief Slot to intercept signal when login has failed (loginFailure signal)
161 /*******************************************************************************
163 ******************************************************************************/
168 * @brief This signal is emitted if updateCredentials method finds credentials from URL.
169 * Signal is also emitted at the beginning of the program if there is valid credentials
172 * @param credentials New credentials
174 void credentialsReady(const FacebookCredentials &credentials);
177 * @brief This signal is emitted if updateCredentials method can't find credentials from URL
183 * @brief Signal that indicates when user has cancelled login process
188 /*******************************************************************************
190 ******************************************************************************/
195 * @brief Dataclass that contains authorization to use facebook. Dataclass is composed of five
196 * QStrings and setters and getters.
198 * @var m_loginCredentials
200 FacebookCredentials m_loginCredentials;
202 QString m_email; ///< Placeholder for email
203 int m_loginAttempts; ///< Indicates login attempts
204 LoginDialog *m_loginDialog; ///< Login dialog
205 QHBoxLayout *m_mainlayout; ///< Lays out m_webView in window.
206 QString m_password; ///< Placeholder for password
207 bool m_refresh; ///< Indicates when webpage is refreshed
208 QWebView *m_webView; ///< Shows facebook login page.
211 #endif // FACEBOOKAUTHENTICATION_H