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
28 #include "facebookcredentials.h"
31 * @brief FacebookAuthentication class takes care of parsing and handling of credentials for
32 * Facebook. Other components of Situare application needs credentials to communicate with
35 * @author Ville Tiensuu
37 class FacebookAuthentication : public QObject
43 * @brief FacebookAuthentication constructor
45 * -Checks if there is valid credentials stored on the file. If there is emits signal.
47 * @param parent instance of parent
49 FacebookAuthentication(QObject *parent = 0);
51 /*******************************************************************************
52 * MEMBER FUNCTIONS AND SLOTS
53 ******************************************************************************/
56 * @brief Getter for m_loginCredentials
58 * @return FacebookCredentials
60 FacebookCredentials loginCredentials() const;
65 * @brief Shows the m_webView and loads page that is specified in the m_facebookLoginPage
66 * variable. Specifies font size for the page.
74 * @brief Creates login url with given parameters
76 * @param urlParts Url parts
77 * @return QUrl Login page url
79 QUrl formLoginPageUrl(const QStringList & urlParts) const;
82 * @brief Reads previous stored credentials from file.
84 * @param credentialsFromFile This dataclass is the place where method stores credentials.
85 * Corrent parameter here is m_loginCredentials
87 void readCredentials(FacebookCredentials &credentialsFromFile);
90 * @brief Checks expiration time of credentials and compares it to current time.
92 * @param credentials this parameter represents credentials that will be verified.
93 * @return bool returns true if expiration time is after current time. in other cases returns
96 bool verifyCredentials(const FacebookCredentials &credentials) const;
99 * @brief Writes credentials to File
101 * @param credentials Contents of this dataclass is stored to file
103 void writeCredentials(const FacebookCredentials &credentials);
107 * @brief Search credentials from URL that is given as parameter.
108 * If credentials are found thay are stored to loginCredentials variable.
110 * @param url URL where this method tries to find credentials.
111 * @return bool if credentials are found returns true,
112 * if credentials are not found returns false.
114 bool updateCredentials(const QUrl & url);
116 /*******************************************************************************
118 ******************************************************************************/
123 * @brief This signal is emitted if updateCredentials method finds credentials from URL.
124 * Signal is also emitted at the beginning of the program if there is valid credentials
127 * @param credentials New credentials
129 void credentialsReady(const FacebookCredentials &credentials);
132 * @brief This signal is emitted if updateCredentials method can't find credentials from URL
138 * @brief Signals when credentials are invalid new login is needed
140 * @param url Login page url
142 void newLoginRequest(const QUrl &url);
144 /*******************************************************************************
146 ******************************************************************************/
151 * @brief Dataclass that contains authorization to use facebook. Dataclass is composed of five
152 * QStrings and setters and getters.
154 * @var m_loginCredentials
156 FacebookCredentials m_loginCredentials;
158 int m_loginAttempts; ///< Indicates login attempts
161 #endif // FACEBOOKAUTHENTICATION_H