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
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.
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.
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,
23 #ifndef FACEBOOKAUTHENTICATION_H
24 #define FACEBOOKAUTHENTICATION_H
30 #include "facebookcredentials.h"
33 * @brief FacebookAuthentication class takes care of transmitting username and password to facebook.
34 * And it also receives credentials from Facebook. Other components of Situare application
35 * needs credentials to communicate with facebook.
37 * @author Ville Tiensuu
38 * @class FacebookAuthentication facebookauthentication.h "facebookauthentication.h"
40 class FacebookAuthentication : public QMainWindow
46 * @brief FacebookAuthentication constructor
48 * -Composes Loginpage from pieces of strings.
49 * -Checks if there is valid credentials stored on the file. If there is emits signal. If not it
51 * -Connects signal from m_webView to UpdateCredentials() method. With this feature it is
52 * verified that class tries always update credentials when web page changes.
53 * -Allocates memory for m_webView and m_mainlayout
55 * @param parent instance of parent
57 FacebookAuthentication(QWidget *parent = 0);
60 * @brief Releases allocated memory for m_webView and m_mainlayout
63 ~FacebookAuthentication();
66 * @brief Getter for m_loginCredentials
68 * @return FacebookCredentials
70 FacebookCredentials loginCredentials() const;
74 * @brief Shows the m_webView and loads page that is specified in the m_facebookLoginPage
75 * variable. Specifies font size for the page.
82 * @brief Search credentials from URL that is given as parameter.
83 * If credentials are found thay are stored to loginCredentials variable.
85 * @param url, URL where this method tries to find credentials.
86 * @return bool, if credentials are found returns true,
87 * if credentials are not found returns false.
89 bool updateCredentials(const QUrl & url);
94 * @brief This signal is emitted if user exits logging in by pressing X
100 * @brief This signal is emitted if updateCredentials method finds credentials from URL.
101 * Signal is also emitted at the beginning of the program if there is valid credentials
105 void credentialsReady();
108 * @brief This signal is emitted if updateCredentials method can't find credentials from URL
116 * @brief Program cames to this method when user closes login screen by pressing X.
117 * method sends userExit() signal in this function
119 * @param event, without parameter program does not come to this function when user exits by
122 void closeEvent(QCloseEvent *event);
125 * @brief Checks expiration time of credentials and compares it to current time.
127 * @param credentials, this parameter represents credentials that will be verified.
128 * @return bool, returns true if expiration time is after current time. in other cases returns
131 bool verifyCredentials(const FacebookCredentials &credentials) const;
134 * @brief Reads previous stored credentials from file.
136 * @param CredentialsFromFile, This dataclass is the place where method stores credentials.
137 * Corrent parameter here is m_loginCredentials
139 void readCredentials(FacebookCredentials &credentialsFromFile);
142 * @brief Writes credentials to File
144 * @param credentials, Contents of this dataclass is stored to file
146 void writeCredentials(const FacebookCredentials &credentials);
149 * @brief Shows facebook login page.
156 * @brief Lays out m_webView in window.
160 QHBoxLayout *m_mainlayout;
163 * @brief String that contantains URL of facebook loginpage.
165 * @var m_facebookLoginPage
167 QString m_facebookLoginPage;
170 * @brief Dataclass that contains authorization to use facebook. Dataclass is composed of five
171 * QStrings and setters and getters.
173 * @var m_loginCredentials
175 FacebookCredentials m_loginCredentials;
178 #endif // FACEBOOKAUTHENTICATION_H