Skip to content

Commit

Permalink
Hide more debug noise
Browse files Browse the repository at this point in the history
  • Loading branch information
nyalldawson committed Jan 30, 2021
1 parent 2690510 commit 1f91895
Show file tree
Hide file tree
Showing 10 changed files with 111 additions and 111 deletions.
6 changes: 3 additions & 3 deletions external/o2/src/o0baseauth.cpp
Expand Up @@ -28,12 +28,12 @@ void O0BaseAuth::setStore(O0AbstractStore *store) {
bool O0BaseAuth::linked() {
QString key = QString(O2_KEY_LINKED).arg(clientId_);
bool result = !store_->value(key).isEmpty();
qDebug() << "O0BaseAuth::linked:" << (result? "Yes": "No");
//qDebug() << "O0BaseAuth::linked:" << (result? "Yes": "No");
return result;
}

void O0BaseAuth::setLinked(bool v) {
qDebug() << "O0BaseAuth::setLinked:" << (v? "true": "false");
//qDebug() << "O0BaseAuth::setLinked:" << (v? "true": "false");
bool oldValue = linked();
QString key = QString(O2_KEY_LINKED).arg(clientId_);
store_->setValue(key, v? "1": "");
Expand Down Expand Up @@ -87,7 +87,7 @@ int O0BaseAuth::localPort() {
}

void O0BaseAuth::setLocalPort(int value) {
qDebug() << "O0BaseAuth::setLocalPort:" << value;
//qDebug() << "O0BaseAuth::setLocalPort:" << value;
localPort_ = value;
Q_EMIT localPortChanged();
}
Expand Down
44 changes: 22 additions & 22 deletions external/o2/src/o2.cpp
Expand Up @@ -152,10 +152,10 @@ void O2::setRefreshTokenUrl(const QString &value) {
}

void O2::link() {
qDebug() << "O2::link";
//qDebug() << "O2::link";

if (linked()) {
qDebug() << "O2::link: Linked already";
//qDebug() << "O2::link: Linked already";
Q_EMIT linkingSucceeded();
return;
}
Expand All @@ -171,7 +171,7 @@ void O2::link() {
// Start listening to authentication replies
if (!replyServer_->isListening()) {
if (replyServer_->listen(QHostAddress::Any, localPort_)) {
qDebug() << "O2::link: Reply server listening on port" << localPort();
//qDebug() << "O2::link: Reply server listening on port" << localPort();
} else {
qWarning() << "O2::link: Reply server failed to start listening on port" << localPort();
Q_EMIT linkingFailed();
Expand All @@ -197,7 +197,7 @@ void O2::link() {
// Show authentication URL with a web browser
QUrl url(requestUrl_);
addQueryParametersToUrl(url, parameters);
qDebug() << "O2::link: Emit openBrowser" << url.toString();
//qDebug() << "O2::link: Emit openBrowser" << url.toString();
Q_EMIT openBrowser(url);
} else if (grantFlow_ == GrantFlowResourceOwnerPasswordCredentials) {
QList<O0RequestParameter> parameters;
Expand All @@ -215,7 +215,7 @@ void O2::link() {
}
QByteArray payload = O0BaseAuth::createQueryParameters(parameters);

qDebug() << "O2::link: Sending token request for resource owner flow";
//qDebug() << "O2::link: Sending token request for resource owner flow";
QUrl url(tokenUrl_);
QNetworkRequest tokenRequest(url);
tokenRequest.setHeader(QNetworkRequest::ContentTypeHeader, "application/x-www-form-urlencoded");
Expand All @@ -227,7 +227,7 @@ void O2::link() {
}

void O2::unlink() {
qDebug() << "O2::unlink";
//() << "O2::unlink";
setLinked(false);
setToken(QString());
setRefreshToken(QString());
Expand All @@ -237,8 +237,8 @@ void O2::unlink() {
}

void O2::onVerificationReceived(const QMap<QString, QString> response) {
qDebug() << "O2::onVerificationReceived:" << response;
qDebug() << "O2::onVerificationReceived: Emitting closeBrowser()";
//qDebug() << "O2::onVerificationReceived:" << response;
//qDebug() << "O2::onVerificationReceived: Emitting closeBrowser()";
Q_EMIT closeBrowser();

if (response.contains("error")) {
Expand Down Expand Up @@ -266,7 +266,7 @@ void O2::onVerificationReceived(const QMap<QString, QString> response) {
parameters.insert(O2_OAUTH2_GRANT_TYPE, O2_AUTHORIZATION_CODE);
QByteArray data = buildRequestBody(parameters);

qDebug() << QString("O2::onVerificationReceived: Exchange access code data:\n%1").arg(QString(data));
//qDebug() << QString("O2::onVerificationReceived: Exchange access code data:\n%1").arg(QString(data));

QNetworkReply *tokenReply = getManager()->post(tokenRequest, data);
timedReplies_.add(tokenReply);
Expand All @@ -275,13 +275,13 @@ void O2::onVerificationReceived(const QMap<QString, QString> response) {
} else if (grantFlow_ == GrantFlowImplicit) {
// Check for mandatory tokens
if (response.contains(O2_OAUTH2_ACCESS_TOKEN)) {
qDebug() << "O2::onVerificationReceived: Access token returned for implicit flow";
//qDebug() << "O2::onVerificationReceived: Access token returned for implicit flow";
setToken(response.value(O2_OAUTH2_ACCESS_TOKEN));
if (response.contains(O2_OAUTH2_EXPIRES_IN)) {
bool ok = false;
int expiresIn = response.value(O2_OAUTH2_EXPIRES_IN).toInt(&ok);
if (ok) {
qDebug() << "O2::onVerificationReceived: Token expires in" << expiresIn << "seconds";
//qDebug() << "O2::onVerificationReceived: Token expires in" << expiresIn << "seconds";
setExpires(QDateTime::currentMSecsSinceEpoch() / 1000 + expiresIn);
}
}
Expand All @@ -308,7 +308,7 @@ void O2::setCode(const QString &c) {
}

void O2::onTokenReplyFinished() {
qDebug() << "O2::onTokenReplyFinished";
//qDebug() << "O2::onTokenReplyFinished";
QNetworkReply *tokenReply = qobject_cast<QNetworkReply *>(sender());
if (!tokenReply)
{
Expand All @@ -326,20 +326,20 @@ void O2::onTokenReplyFinished() {
QVariantMap tokens = parseTokenResponse(replyData);

// Dump tokens
qDebug() << "O2::onTokenReplyFinished: Tokens returned:\n";
foreach (QString key, tokens.keys()) {
//qDebug() << "O2::onTokenReplyFinished: Tokens returned:\n";
//foreach (QString key, tokens.keys()) {
// SENSITIVE DATA in RelWithDebInfo or Debug builds, so it is truncated first
qDebug() << key << ": "<< tokens.value( key ).toString().left( 3 ) << "...";
}
//qDebug() << key << ": "<< tokens.value( key ).toString().left( 3 ) << "...";
//}

// Check for mandatory tokens
if (tokens.contains(O2_OAUTH2_ACCESS_TOKEN)) {
qDebug() << "O2::onTokenReplyFinished: Access token returned";
// qDebug() << "O2::onTokenReplyFinished: Access token returned";
setToken(tokens.take(O2_OAUTH2_ACCESS_TOKEN).toString());
bool ok = false;
int expiresIn = tokens.take(O2_OAUTH2_EXPIRES_IN).toInt(&ok);
if (ok) {
qDebug() << "O2::onTokenReplyFinished: Token expires in" << expiresIn << "seconds";
// qDebug() << "O2::onTokenReplyFinished: Token expires in" << expiresIn << "seconds";
setExpires(QDateTime::currentMSecsSinceEpoch() / 1000 + expiresIn);
}
setRefreshToken(tokens.take(O2_OAUTH2_REFRESH_TOKEN).toString());
Expand All @@ -358,7 +358,7 @@ void O2::onTokenReplyFinished() {
void O2::onTokenReplyError(QNetworkReply::NetworkError error) {
QNetworkReply *tokenReply = qobject_cast<QNetworkReply *>(sender());
qWarning() << "O2::onTokenReplyError: " << error << ": " << tokenReply->errorString();
qDebug() << "O2::onTokenReplyError: " << tokenReply->readAll();
// qDebug() << "O2::onTokenReplyError: " << tokenReply->readAll();
setToken(QString());
setRefreshToken(QString());
timedReplies_.remove(tokenReply);
Expand Down Expand Up @@ -401,13 +401,13 @@ QString O2::refreshToken() {
}

void O2::setRefreshToken(const QString &v) {
qDebug() << "O2::setRefreshToken" << v.left(4) << "...";
//qDebug() << "O2::setRefreshToken" << v.left(4) << "...";
QString key = QString(O2_KEY_REFRESH_TOKEN).arg(clientId_);
store_->setValue(key, v);
}

void O2::refresh() {
qDebug() << "O2::refresh: Token: ..." << refreshToken().right(7);
// qDebug() << "O2::refresh: Token: ..." << refreshToken().right(7);

if (refreshToken().isEmpty()) {
qWarning() << "O2::refresh: No refresh token";
Expand Down Expand Up @@ -452,7 +452,7 @@ void O2::onRefreshFinished() {
if ( !refreshToken.isEmpty() )
setRefreshToken(refreshToken);
setLinked(true);
qDebug() << " New token expires in" << expires() << "seconds";
//qDebug() << " New token expires in" << expires() << "seconds";
Q_EMIT linkingSucceeded();
}
timedReplies_.remove(refreshReply);
Expand Down
24 changes: 12 additions & 12 deletions external/o2/src/o2replyserver.cpp
Expand Up @@ -16,13 +16,13 @@

O2ReplyServer::O2ReplyServer(QObject *parent): QTcpServer(parent),
timeout_(15), maxtries_(3), tries_(0) {
qDebug() << "O2ReplyServer: Starting";
//qDebug() << "O2ReplyServer: Starting";
connect(this, SIGNAL(newConnection()), this, SLOT(onIncomingConnection()));
replyContent_ = "<HTML></HTML>";
}

void O2ReplyServer::onIncomingConnection() {
qDebug() << "O2ReplyServer::onIncomingConnection: Receiving...";
//qDebug() << "O2ReplyServer::onIncomingConnection: Receiving...";
QTcpSocket *socket = nextPendingConnection();
connect(socket, SIGNAL(readyRead()), this, SLOT(onBytesReady()), Qt::UniqueConnection);
connect(socket, SIGNAL(disconnected()), socket, SLOT(deleteLater()));
Expand All @@ -44,7 +44,7 @@ void O2ReplyServer::onBytesReady() {
// server has been closed, stop processing queued connections
return;
}
qDebug() << "O2ReplyServer::onBytesReady: Processing request";
//qDebug() << "O2ReplyServer::onBytesReady: Processing request";
// NOTE: on first call, the timeout timer is started
QTcpSocket *socket = qobject_cast<QTcpSocket *>(sender());
if (!socket) {
Expand All @@ -57,13 +57,13 @@ void O2ReplyServer::onBytesReady() {
reply.append(QString("Content-Length: %1\r\n\r\n").arg(replyContent_.size()).toLatin1());
reply.append(replyContent_);
socket->write(reply);
qDebug() << "O2ReplyServer::onBytesReady: Sent reply";
//qDebug() << "O2ReplyServer::onBytesReady: Sent reply";

QByteArray data = socket->readAll();
QMap<QString, QString> queryParams = parseQueryParams(&data);
if (queryParams.isEmpty()) {
if (tries_ < maxtries_ ) {
qDebug() << "O2ReplyServer::onBytesReady: No query params found, waiting for more callbacks";
//qDebug() << "O2ReplyServer::onBytesReady: No query params found, waiting for more callbacks";
++tries_;
return;
} else {
Expand All @@ -73,13 +73,13 @@ void O2ReplyServer::onBytesReady() {
return;
}
}
qDebug() << "O2ReplyServer::onBytesReady: Query params found, closing server";
//qDebug() << "O2ReplyServer::onBytesReady: Query params found, closing server";
closeServer(socket, true);
Q_EMIT verificationReceived(queryParams);
}

QMap<QString, QString> O2ReplyServer::parseQueryParams(QByteArray *data) {
qDebug() << "O2ReplyServer::parseQueryParams";
//qDebug() << "O2ReplyServer::parseQueryParams";

//qDebug() << QString("O2ReplyServer::parseQueryParams data:\n%1").arg(QString(*data));

Expand Down Expand Up @@ -114,13 +114,13 @@ void O2ReplyServer::closeServer(QTcpSocket *socket, bool hasparameters)
return;
}

qDebug() << "O2ReplyServer::closeServer: Initiating";
int port = serverPort();
//qDebug() << "O2ReplyServer::closeServer: Initiating";
//int port = serverPort();

if (!socket && sender()) {
QTimer *timer = qobject_cast<QTimer*>(sender());
if (timer) {
qWarning() << "O2ReplyServer::closeServer: Closing due to timeout";
//qWarning() << "O2ReplyServer::closeServer: Closing due to timeout";
timer->stop();
socket = qobject_cast<QTcpSocket *>(timer->parent());
timer->deleteLater();
Expand All @@ -129,13 +129,13 @@ void O2ReplyServer::closeServer(QTcpSocket *socket, bool hasparameters)
if (socket) {
QTimer *timer = socket->findChild<QTimer*>("timeoutTimer");
if (timer) {
qDebug() << "O2ReplyServer::closeServer: Stopping socket's timeout timer";
//qDebug() << "O2ReplyServer::closeServer: Stopping socket's timeout timer";
timer->stop();
}
socket->disconnectFromHost();
}
close();
qDebug() << "O2ReplyServer::closeServer: Closed, no longer listening on port" << port;
//qDebug() << "O2ReplyServer::closeServer: Closed, no longer listening on port" << port;
Q_EMIT serverClosed(hasparameters);
}

Expand Down
4 changes: 2 additions & 2 deletions src/app/options/qgsoptions.cpp
Expand Up @@ -171,7 +171,7 @@ QgsOptions::QgsOptions( QWidget *parent, Qt::WindowFlags fl, const QList<QgsOpti
mSettings = new QgsSettings();

double identifyValue = mSettings->value( QStringLiteral( "/Map/searchRadiusMM" ), Qgis::DEFAULT_SEARCH_RADIUS_MM ).toDouble();
QgsDebugMsg( QStringLiteral( "Standard Identify radius setting read from settings file: %1" ).arg( identifyValue ) );
QgsDebugMsgLevel( QStringLiteral( "Standard Identify radius setting read from settings file: %1" ).arg( identifyValue ), 3 );
if ( identifyValue <= 0.0 )
identifyValue = Qgis::DEFAULT_SEARCH_RADIUS_MM;
spinBoxIdentifyValue->setMinimum( 0.0 );
Expand Down Expand Up @@ -2344,7 +2344,7 @@ void QgsOptions::loadGdalDriverList()
driversType[myGdalDriverDescription] = QgsMapLayerType::VectorLayer;
}

QgsDebugMsg( QStringLiteral( "driver #%1 - %2" ).arg( i ).arg( myGdalDriverDescription ) );
QgsDebugMsgLevel( QStringLiteral( "driver #%1 - %2" ).arg( i ).arg( myGdalDriverDescription ), 2 );

// get driver R/W flags, adopted from GDALGeneralCmdLineProcessor()
QString driverFlags = "";
Expand Down
20 changes: 10 additions & 10 deletions src/auth/oauth2/qgsauthoauth2method.cpp
Expand Up @@ -328,7 +328,7 @@ void QgsAuthOAuth2Method::onLinkedChanged()
{
// Linking (login) state has changed.
// Use o2->linked() to get the actual state
QgsDebugMsg( QStringLiteral( "Link state changed" ) );
QgsDebugMsgLevel( QStringLiteral( "Link state changed" ), 2 );
}

void QgsAuthOAuth2Method::onLinkingFailed()
Expand Down Expand Up @@ -371,7 +371,7 @@ void QgsAuthOAuth2Method::onLinkingSucceeded()
// don't expose the values in a log (unless they are only 3 chars long, of course)
msg += QStringLiteral( " %1:%2…\n" ).arg( key, extraTokens.value( key ).toString().left( 3 ) );
}
QgsDebugMsg( msg );
QgsDebugMsgLevel( msg, 2 );
}
}

Expand All @@ -381,15 +381,15 @@ void QgsAuthOAuth2Method::onOpenBrowser( const QUrl &url )
// The user will interact with this browser window to
// enter login name, password, and authorize your application
// to access the Twitter account
QgsMessageLog::logMessage( tr( "Open browser requested" ), AUTH_METHOD_KEY, Qgis::MessageLevel::Info );
QgsDebugMsgLevel( QStringLiteral( "Open browser requested %1" ), 2 );

QDesktopServices::openUrl( url );
}

void QgsAuthOAuth2Method::onCloseBrowser()
{
// Close the browser window opened in openBrowser()
QgsMessageLog::logMessage( tr( "Close browser requested" ), AUTH_METHOD_KEY, Qgis::MessageLevel::Info );
QgsDebugMsgLevel( QStringLiteral( "Close browser requested %1" ), 2 );

// Bring focus back to QGIS app
if ( qApp )
Expand Down Expand Up @@ -537,7 +537,7 @@ void QgsAuthOAuth2Method::updateMethodConfig( QgsAuthMethodConfig &mconfig )
{
if ( mconfig.hasConfig( QStringLiteral( "oldconfigstyle" ) ) )
{
QgsDebugMsg( QStringLiteral( "Updating old style auth method config" ) );
QgsDebugMsgLevel( QStringLiteral( "Updating old style auth method config" ), 2 );
}

// NOTE: add updates as method version() increases due to config storage changes
Expand All @@ -555,7 +555,7 @@ QgsO2 *QgsAuthOAuth2Method::getOAuth2Bundle( const QString &authcfg, bool fullco
// check if it is cached
if ( sOAuth2ConfigCache.contains( authcfg ) )
{
QgsDebugMsg( QStringLiteral( "Retrieving OAuth bundle for authcfg: %1" ).arg( authcfg ) );
QgsDebugMsgLevel( QStringLiteral( "Retrieving OAuth bundle for authcfg: %1" ).arg( authcfg ), 2 );
return sOAuth2ConfigCache.value( authcfg );
}

Expand Down Expand Up @@ -662,8 +662,8 @@ QgsO2 *QgsAuthOAuth2Method::getOAuth2Bundle( const QString &authcfg, bool fullco

// TODO: instantiate particular QgsO2 subclassed authenticators relative to config ???

QgsDebugMsg( QStringLiteral( "Loading authenticator object with %1 flow properties of OAuth2 config: %2" )
.arg( QgsAuthOAuth2Config::grantFlowString( config->grantFlow() ), authcfg ) );
QgsDebugMsgLevel( QStringLiteral( "Loading authenticator object with %1 flow properties of OAuth2 config: %2" )
.arg( QgsAuthOAuth2Config::grantFlowString( config->grantFlow() ), authcfg ), 2 );

QgsO2 *o2 = new QgsO2( authcfg, config, nullptr, QgsNetworkAccessManager::instance() );

Expand All @@ -675,7 +675,7 @@ QgsO2 *QgsAuthOAuth2Method::getOAuth2Bundle( const QString &authcfg, bool fullco

void QgsAuthOAuth2Method::putOAuth2Bundle( const QString &authcfg, QgsO2 *bundle )
{
QgsDebugMsg( QStringLiteral( "Putting oauth2 bundle for authcfg: %1" ).arg( authcfg ) );
QgsDebugMsgLevel( QStringLiteral( "Putting oauth2 bundle for authcfg: %1" ).arg( authcfg ), 2 );
sOAuth2ConfigCache.insert( authcfg, bundle );
}

Expand All @@ -685,7 +685,7 @@ void QgsAuthOAuth2Method::removeOAuth2Bundle( const QString &authcfg )
{
sOAuth2ConfigCache.value( authcfg )->deleteLater();
sOAuth2ConfigCache.remove( authcfg );
QgsDebugMsg( QStringLiteral( "Removed oauth2 bundle for authcfg: %1" ).arg( authcfg ) );
QgsDebugMsgLevel( QStringLiteral( "Removed oauth2 bundle for authcfg: %1" ).arg( authcfg ), 2 );
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/auth/oauth2/qgso2.cpp
Expand Up @@ -68,7 +68,7 @@ void QgsO2::initOAuthConfig()

// common properties to all grant flows
QString localpolicy = QStringLiteral( "http://127.0.0.1:% 1/%1" ).arg( mOAuth2Config->redirectUrl() ).replace( QLatin1String( "% 1" ), QLatin1String( "%1" ) );
QgsDebugMsg( QStringLiteral( "localpolicy(w/port): %1" ).arg( localpolicy.arg( mOAuth2Config->redirectPort() ) ) );
QgsDebugMsgLevel( QStringLiteral( "localpolicy(w/port): %1" ).arg( localpolicy.arg( mOAuth2Config->redirectPort() ) ), 2 );
setLocalhostPolicy( localpolicy );
setLocalPort( mOAuth2Config->redirectPort() );
mIsLocalHost = isLocalHost( QUrl( localpolicy.arg( mOAuth2Config->redirectPort() ) ) );
Expand Down

0 comments on commit 1f91895

Please sign in to comment.