From ff8057d34bb4e9cf12f5d39b5c1b79ac092b387f Mon Sep 17 00:00:00 2001 From: Tannin Date: Sun, 9 Aug 2015 12:40:57 +0200 Subject: - MO now validates session cookie on startup - It also retrieves account status - rewrote how MO decides when to log-in/when to give up on logging in --- src/nxmaccessmanager.h | 40 ++++++++++++++++++++++++++++++++-------- 1 file changed, 32 insertions(+), 8 deletions(-) (limited to 'src/nxmaccessmanager.h') diff --git a/src/nxmaccessmanager.h b/src/nxmaccessmanager.h index 9d692bba..2b615cdc 100644 --- a/src/nxmaccessmanager.h +++ b/src/nxmaccessmanager.h @@ -25,6 +25,7 @@ along with Mod Organizer. If not, see . #include #include #include +#include /** @@ -43,12 +44,18 @@ public: bool loggedIn() const; - bool loginAttempted() const { return m_LoginAttempted; } + bool loginAttempted() const; bool loginWaiting() const; void login(const QString &username, const QString &password); - void showCookies(); + void showCookies() const; + + QString userAgent(const QString &subModule = QString()) const; + + void startLoginCheck(); + + void refuseLogin(); signals: @@ -68,11 +75,14 @@ signals: void loginFailed(const QString &message); - private slots: + void credentialsReceived(const QString &userName, bool premium); + +private slots: - void loginFinished(); - void loginError(QNetworkReply::NetworkError errorCode); - void loginTimeout(); + void loginChecked(); + void loginFinished(); + void loginError(QNetworkReply::NetworkError errorCode); + void loginTimeout(); public slots: @@ -84,10 +94,16 @@ protected: private: - void pageLogin(); + void pageLogin(); // void dlLogin(); - bool hasLoginCookies() const; + bool hasLoginCookies() const; + + void retrieveCredentials(); + +private: + + static const std::set s_PremiumAccountStates; private: @@ -102,6 +118,14 @@ private: QString m_Password; bool m_LoginAttempted; + enum { + LOGIN_NOT_CHECKED, + LOGIN_CHECKING, + LOGIN_NOT_VALID, + LOGIN_ATTEMPT_FAILED, + LOGIN_REFUSED, + LOGIN_VALID + } m_LoginState = LOGIN_NOT_CHECKED; }; -- cgit v1.3.1