X-Git-Url: https://vcs.maemo.org/git/?a=blobdiff_plain;f=src%2Ffacebookservice%2Ffacebookauthentication.h;h=5d12838b70c9d1b687b7a943893c533e5be3beb2;hb=179f8ad0934bd7b3f35d2d760e9822d15b218cf2;hp=9ad879fa65ceb713d81105a285cf89cbfb7e6b3b;hpb=428f8e23c8b22e0cf5872b65a93d3176fb446703;p=situare diff --git a/src/facebookservice/facebookauthentication.h b/src/facebookservice/facebookauthentication.h index 9ad879f..5d12838 100644 --- a/src/facebookservice/facebookauthentication.h +++ b/src/facebookservice/facebookauthentication.h @@ -4,6 +4,7 @@ Ville Tiensuu - ville.tiensuu@ixonos.com Kaj Wallin - kaj.wallin@ixonos.com + Henri Lampela - henri.lampela@ixonos.com Situare is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License @@ -23,19 +24,23 @@ #ifndef FACEBOOKAUTHENTICATION_H #define FACEBOOKAUTHENTICATION_H -#include -#include -#include -#include -#include -#include "facebookcredentials.h" +#include + +class QNetworkReply; +class QWebView; + +class MainWindow; /** -* @brief FacebookAuthentication class takes care of transmitting username and password to facebook. And it also receives credentials from Facebook. Other components of Situare application needs credentials to communicate with facebook. +* @brief FacebookAuthentication class takes care of Facebook login process. It creates + QWebView instance and tries to login with cookies using hidden browser. + If failed, then visible login browser dialog is invoked. Class also does parse the + accuired credentials. * -* @class FacebookAuthentication facebookauthentication.h "facebookauthentication.h" +* @author Ville Tiensuu +* @author Sami Rämö - sami.ramo (at) ixonos.com */ -class FacebookAuthentication : public QMainWindow +class FacebookAuthentication : public QObject { Q_OBJECT @@ -43,135 +48,60 @@ public: /** * @brief FacebookAuthentication constructor * - * -Composes Loginpage from pieces of strings. - * -Checks if there is valid credentials stored on the file. If there is emits signal. If not it calls start method. - * -Connects signal from webview to UpdateCredentials() method. With this feature it is verified that class tries always update credentials when web page changes. - * -Allocates memory for webView and mainlayout + * -Checks if there is valid credentials stored on the file. If there is emits signal. * - * @fn FacebookAuthentication - * @param parent + * @param mainWindow MainWindow instance + * @param parent instance of parent */ - FacebookAuthentication(QWidget *parent = 0); + FacebookAuthentication(MainWindow *mainWindow, QObject *parent = 0); - /** - * @brief Releases allocated memory for webView and mainLayout - * - * @fn ~FacebookAuthentication - */ - ~FacebookAuthentication(); - - /** - * @brief Getter for loginCredentials - * - * @fn getLoginCredentials - * @return FacebookCredentials - */ - FacebookCredentials getLoginCredentials() const; +/******************************************************************************* + * MEMBER FUNCTIONS AND SLOTS + ******************************************************************************/ +public: + void login(); public slots: - /** - * @brief shows the webView and loads page that is specified in the facebookLoginPage variable. Specifies font size for the page. - * - * @fn start - */ - void start(); -private slots: /** - * @brief search credentials from URL that is given parameter. If credentials are found thay are stored to loginCredentials variable. + * @brief Clears account iformation from settings * - * @fn updateCredentials - * @param url, URL where this method tries to find credentials. - * @return bool, if credentials are found return true, if credentials are not found return false. + * @param keepUsername keep = true, false otherwise */ - bool updateCredentials(const QUrl & url); - -signals: - - /** - * @brief this signal is emitted if user exits logging in by pressing X - * - * @fn userExit - */ - void userExit(); - - /** - * @brief this signal is emitted updateCredentials method finds credentials from URL. signal is also emitted at the beginning of the program if there is valid credentials in the file. - * - * @fn credentialsReady - */ - void credentialsReady(); - - /** - * @brief this signal is emitted if updateCredentials method can't find credentials from URL - * - * @fn loginFailure - */ - void loginFailure(); + void clearAccountInformation(bool keepUsername = false); private: + QString parseSession(const QUrl &url); - /** - * @brief Program cames to this method when user closes login screen by pressing X. - * method send userExit() signal in this function - * - * @fn closeEvent - * @param event, without parameter programs does not come to this function when user exits by pressing X. - */ - void closeEvent(QCloseEvent *event); +private slots: + void browserDestroyed(); - /** - * @brief checks expiration time of credentials and compares it to current time. - * - * @fn verifyCredentials - * @param credentials, this parameter represents credentials that will be verified. - * @return bool, returns true if expiration time is after current time. in other cases returns false. - */ - bool verifyCredentials(const FacebookCredentials &credentials) const; + void loadFinished(bool ok); - /** - * @brief Reads previous stored credentials from file. - * - * @fn readCredentials - * @param credentialsFromFile, This dataclass is the place where method stores credentials. Corrent parameter here is loginCredentials (private member of FacebookAuthentication class) - */ - void readCredentials(FacebookCredentials &credentialsFromFile); + void networkReplyHandler(QNetworkReply *reply); - /** - * @brief Writes credentials to File - * - * @fn writeCredentials - * @param credentials, Contents of this dataclass is stored to file - */ - void writeCredentials(const FacebookCredentials &credentials); - - /** - * @brief, shows facebook login page. - * - * @var webView - */ - QWebView *webView; + void urlChanged(const QUrl &url); +/******************************************************************************* + * SIGNALS + ******************************************************************************/ +signals: /** - * @brief, lays out webview in window. + * @brief Signals error * - * @var mainlayout + * @param context error context + * @param error error code */ - QHBoxLayout *mainlayout; + void error(const int context, const int error); - /** - * @brief string that contantains URL of facebook loginpage. - * - * @var facebookLoginPage - */ - QString facebookLoginPage; + void loggedIn(const QString session); - /** - * @brief Dataclass that contains authorization to use facebook. Dataclass is composed of five QStrings and setters and getters. - * - * @var loginCredentials - */ - FacebookCredentials loginCredentials; +/******************************************************************************* + * DATA MEMBERS + ******************************************************************************/ +private: + QWebView *m_browser; + MainWindow *m_mainWindow; }; #endif // FACEBOOKAUTHENTICATION_H