X-Git-Url: https://vcs.maemo.org/git/?a=blobdiff_plain;f=src%2Ffacebookservice%2Ffacebookauthentication.h;h=a3ea7d5794354cb371b65483815ca4fec84502c0;hb=49b5e403e51174df27d0e737148868689456f78a;hp=5c13c87a0f780c8a6361c9e8d4be15331889b6c2;hpb=69c89315a2b796b9140a1b222dd3a26f3c929936;p=situare diff --git a/src/facebookservice/facebookauthentication.h b/src/facebookservice/facebookauthentication.h index 5c13c87..a3ea7d5 100644 --- a/src/facebookservice/facebookauthentication.h +++ b/src/facebookservice/facebookauthentication.h @@ -27,15 +27,19 @@ #include class QNetworkReply; +class QSslError; +class QWebView; -class FacebookLoginBrowser; +class MainWindow; /** -* @brief FacebookAuthentication class takes care of parsing and handling of credentials for -* 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. * * @author Ville Tiensuu +* @author Sami Rämö - sami.ramo (at) ixonos.com */ class FacebookAuthentication : public QObject { @@ -43,49 +47,95 @@ class FacebookAuthentication : public QObject public: /** - * @brief FacebookAuthentication constructor + * @brief Constructor * - * -Checks if there is valid credentials stored on the file. If there is emits signal. + * Initiates internal data members. * - * @param parent instance of parent + * @param mainWindow MainWindow instance + * @param parent Instance of the parent */ - FacebookAuthentication(QObject *parent = 0); + FacebookAuthentication(MainWindow *mainWindow, QObject *parent = 0); /******************************************************************************* * MEMBER FUNCTIONS AND SLOTS ******************************************************************************/ -public: - void login(); - public slots: - /** - * @brief Clears account iformation from settings + * @brief Clears account information from settings * - * @param keepUsername keep = true, false otherwise + * @param clearUserInformation True if user information should be cleared */ - void clearAccountInformation(bool keepUsername = false); + void clearAccountInformation(bool clearUserInformation = false); + + /** + * @brief Is the user currently logged in + * + * @returns True if the user is logged in, otherwise false + */ + bool isLoggedIn() const; - void setBrowser(FacebookLoginBrowser *browser); + /** + * @brief Initiate login process + * + * Builds login browser and starts loading login URL. + */ + void login(); + + /** + * @brief Log out + * + * @param clearUserInformation True if user information should be cleared + */ + void logOut(bool clearUserInformation = false); private: + /** + * @brief Destroy login dialog and browser + */ + void destroyLogin(); + + /** + * @brief Parses the session information from the URL + * + * @param url URL + * @returns Parsed session, or empty string if parsing failed. + */ QString parseSession(const QUrl &url); private slots: + /** + * @brief Cleanup after browser is destructed + * + * Clears the pointer to the browser and disables the progress indicator. + */ void browserDestroyed(); - void loadFinished(bool ok); - + /** + * @brief Handler for login page loading errors + * + * @param reply Network reply + */ void networkReplyHandler(QNetworkReply *reply); + /** + * @brief Handler for SSL errors, ignores the error + */ + void sslErrors(QNetworkReply *reply, const QList &errors); + + /** + * @brief Handler for browser URL changes + * + * Does check the new URL and based on that invokes the login dialog with visible browser view + * or parses the session from the new URL. + * + * @param url New URL + */ void urlChanged(const QUrl &url); /******************************************************************************* * SIGNALS ******************************************************************************/ signals: - void buildLoginBrowser(); - /** * @brief Signals error * @@ -94,13 +144,30 @@ signals: */ void error(const int context, const int error); - void loggedIn(const QString session); + /** + * @brief Emitted when logged in successfully + * + * All login related actions should be connected to this signal. + * + * @param session Session data + * @param wallPostPermission Has the user granted rights for posting to wall + */ + void loggedIn(const QString session, bool wallPostPermission); + + /** + * @brief Emitted when logged out + * + * All logout related actions should be connected to this signal. + */ + void loggedOut(); /******************************************************************************* * DATA MEMBERS ******************************************************************************/ private: - FacebookLoginBrowser *m_browser; + bool m_loggedIn; ///< Is the user currently logged in + QWebView *m_browser; ///< Login browser + MainWindow *m_mainWindow; ///< MainWindow }; #endif // FACEBOOKAUTHENTICATION_H