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
38 QSslConfiguration::setDefaultConfiguration(sslConfig);38 QSslConfiguration::setDefaultConfiguration(sslConfig);
39}39}
40 40
41const int WEB_VIEW_REDISPLAY_ELAPSED_MSECS = 5 * 1000;
42
41void OAuthWebViewHandler::displayWebviewForAuthorizationURL(const QUrl& authorizationURL) {43void OAuthWebViewHandler::displayWebviewForAuthorizationURL(const QUrl& authorizationURL) {
42 if (!_activeWebView) {44 if (!_activeWebView && _webViewRedisplayTimer.elapsed() >= WEB_VIEW_REDISPLAY_ELAPSED_MSECS) {
43 _activeWebView = new QWebView;45 _activeWebView = new QWebView;
44 46
45 // keep the window on top and delete it when it closes47 // keep the window on top and delete it when it closes
@@ -52,9 +54,24 @@ void OAuthWebViewHandler::displayWebviewForAuthorizationURL(const QUrl& authoriz · 6 unmodified lines
52 54
53 connect(_activeWebView->page()->networkAccessManager(), &QNetworkAccessManager::sslErrors,55 connect(_activeWebView->page()->networkAccessManager(), &QNetworkAccessManager::sslErrors,
54 this, &OAuthWebViewHandler::handleSSLErrors);56 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);
55 }61 }
56}62}
57 63
58void OAuthWebViewHandler::handleSSLErrors(QNetworkReply* networkReply, const QList<QSslError>& errorList) {64void OAuthWebViewHandler::handleSSLErrors(QNetworkReply* networkReply, const QList<QSslError>& errorList) {
59 qDebug() << "SSL Errors:" << errorList;65 qDebug() << "SSL Errors:" << errorList;
60}66}
67
68void 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
75void 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