diff options
| author | isanae <14251494+isanae@users.noreply.github.com> | 2019-07-11 01:55:31 -0400 |
|---|---|---|
| committer | isanae <14251494+isanae@users.noreply.github.com> | 2019-07-11 01:55:31 -0400 |
| commit | 5e5681709ab878f3aa6cf1344af44e8ae9544987 (patch) | |
| tree | 31be85b57841c3910e4e7c7bc42def86c60f0b65 /src/settingsdialog.h | |
| parent | f44663d795b5ba4adb9b11474f21337de12a9af5 (diff) | |
reworked the nexus connection panel
moved most of the stuff into a new NexusSSOLogin class
Diffstat (limited to 'src/settingsdialog.h')
| -rw-r--r-- | src/settingsdialog.h | 62 |
1 files changed, 50 insertions, 12 deletions
diff --git a/src/settingsdialog.h b/src/settingsdialog.h index 858a36d4..aee447d7 100644 --- a/src/settingsdialog.h +++ b/src/settingsdialog.h @@ -35,6 +35,52 @@ namespace Ui { class SettingsDialog; } +class NexusSSOLogin +{ +public: + enum States + { + Idle, + ConnectingToSSO, + WaitingForToken, + WaitingForBrowser, + Finished, + Timeout, + ClosedByRemote, + Cancelled, + Error + }; + + std::function<void (QString)> keyChanged; + std::function<void (States, QString)> stateChanged; + + NexusSSOLogin(); + + void start(); + void cancel(); + + bool isActive() const; + +private: + QWebSocket m_socket; + QString m_guid; + bool m_keyReceived; + QString m_token; + bool m_active; + QTimer m_timeout; + + void setState(States s, const QString& error={}); + + void close(); + void abort(); + + void onConnected(); + void onMessage(const QString& s); + void onDisconnected(); + void onError(QAbstractSocket::SocketError e); + void onTimeout(); +}; + /** * dialog used to change settings for Mod Organizer. On top of the * settings managed by the "Settings" class, this offers a button to open the @@ -127,11 +173,6 @@ private slots: void on_resetGeometryBtn_clicked(); void deleteBlacklistItem(); - void dispatchLogin(); - void loginPing(); - void authError(QAbstractSocket::SocketError error); - void receiveApiKey(const QString &apiKey); - void completeApiConnection(); private: Ui::SettingsDialog *ui; @@ -145,16 +186,11 @@ private: QColor m_ContainsColor; QColor m_ContainedColor; - bool m_KeyReceived; - bool m_KeyCleared; bool m_GeometriesReset; - QString m_UUID; - QString m_AuthToken; + bool m_keyChanged; QString m_ExecutableBlacklist; - QWebSocket *m_nexusLogin; - QTimer m_loginTimer; - int m_totalPings = 0; + NexusSSOLogin m_nexusLogin; bool setKey(const QString& key); bool clearKey(); @@ -162,6 +198,8 @@ private: void fetchNexusApiKey(); void testApiKey(); + void onKeyChanged(const QString& key); + void onStateChanged(NexusSSOLogin::States s, const QString& e); }; #endif // SETTINGSDIALOG_H |
