History

present the OAuth webview only every 5 seconds

Stephen Birarda committed 12 years ago

Commit 66077d51 parent ca214812 files · +21 −1Browse files

Showing the changes to interface/src/ui/OAuthWebViewHandler.cpp (1 of 2 files). Show all

Unified · Split

interface/src/ui/OAuthWebViewHandler.cpp+18−1
@@ -38,8 +38,10 @@ void OAuthWebViewHandler::addHighFidelityRootCAToSSLConfig() { · 37 unmodified lines
3838 QSslConfiguration::setDefaultConfiguration(sslConfig);
3939 }
4040
41+const int WEB_VIEW_REDISPLAY_ELAPSED_MSECS = 5 * 1000;
42+
4143 void OAuthWebViewHandler::displayWebviewForAuthorizationURL(const QUrl& authorizationURL) {
42− if (!_activeWebView) {
44+ if (!_activeWebView && _webViewRedisplayTimer.elapsed() >= WEB_VIEW_REDISPLAY_ELAPSED_MSECS) {
4345 _activeWebView = new QWebView;
4446
4547 // keep the window on top and delete it when it closes
@@ -52,9 +54,24 @@ void OAuthWebViewHandler::displayWebviewForAuthorizationURL(const QUrl& authoriz · 6 unmodified lines
5254
5355 connect(_activeWebView->page()->networkAccessManager(), &QNetworkAccessManager::sslErrors,
5456 this, &OAuthWebViewHandler::handleSSLErrors);
57+ connect(_activeWebView, &QWebView::loadFinished, this, &OAuthWebViewHandler::handleLoadFinished);
58+
59+ // connect to the destroyed signal so after the web view closes we can start a timer
60+ connect(_activeWebView, &QWebView::destroyed, this, &OAuthWebViewHandler::handleWebViewDestroyed);
5561 }
5662 }
5763
5864 void OAuthWebViewHandler::handleSSLErrors(QNetworkReply* networkReply, const QList<QSslError>& errorList) {
5965 qDebug() << "SSL Errors:" << errorList;
6066 }
67+
68+void OAuthWebViewHandler::handleLoadFinished(bool success) {
69+ if (success && _activeWebView->url().host() == NodeList::getInstance()->getDomainHandler().getHostname()) {
70+ qDebug() << "OAuth authorization code passed successfully to domain-server.";
71+ _activeWebView->close();
72+ }
73+}
74+
75+void OAuthWebViewHandler::handleWebViewDestroyed(QObject* destroyedObject) {
76+ _webViewRedisplayTimer.restart();
77+}

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t