mirror of
				https://github.com/qgis/QGIS.git
				synced 2025-11-04 00:04:25 -05:00 
			
		
		
		
	Use QgsDebugMsgLevel/QgsDebugError
This commit is contained in:
		
							parent
							
								
									0dbf6e730b
								
							
						
					
					
						commit
						c8ba38c794
					
				@ -240,11 +240,11 @@ void QgsO2::link()
 | 
			
		||||
          // Start listening to authentication replies
 | 
			
		||||
          if ( replyServer()->listen( QHostAddress::Any, localPort_ ) )
 | 
			
		||||
          {
 | 
			
		||||
//qDebug() << "O2::link: Reply server listening on port" << localPort();
 | 
			
		||||
            QgsDebugMsgLevel( QStringLiteral( "O2::link: Reply server listening on port %1" ).arg( localPort() ), 2 );
 | 
			
		||||
          }
 | 
			
		||||
          else
 | 
			
		||||
          {
 | 
			
		||||
            qWarning() << "O2::link: Reply server failed to start listening on port" << localPort();
 | 
			
		||||
            QgsDebugError( QStringLiteral( "O2::link: Reply server failed to start listening on port %1" ).arg( localPort() ) );
 | 
			
		||||
            emit linkingFailed();
 | 
			
		||||
            return;
 | 
			
		||||
          }
 | 
			
		||||
@ -408,7 +408,7 @@ void QgsO2::onVerificationReceived( QMap<QString, QString> response )
 | 
			
		||||
    // Check for mandatory tokens
 | 
			
		||||
    if ( response.contains( O2_OAUTH2_ACCESS_TOKEN ) )
 | 
			
		||||
    {
 | 
			
		||||
      qDebug() << "O2::onVerificationReceived: Access token returned for implicit flow";
 | 
			
		||||
      QgsDebugMsgLevel( QStringLiteral( "O2::onVerificationReceived: Access token returned for implicit flow" ), 2 );
 | 
			
		||||
      setToken( response.value( O2_OAUTH2_ACCESS_TOKEN ) );
 | 
			
		||||
      if ( response.contains( O2_OAUTH2_EXPIRES_IN ) )
 | 
			
		||||
      {
 | 
			
		||||
@ -416,7 +416,7 @@ void QgsO2::onVerificationReceived( QMap<QString, QString> response )
 | 
			
		||||
        const int expiresIn = response.value( O2_OAUTH2_EXPIRES_IN ).toInt( &ok );
 | 
			
		||||
        if ( ok )
 | 
			
		||||
        {
 | 
			
		||||
          qDebug() << "O2::onVerificationReceived: Token expires in" << expiresIn << "seconds";
 | 
			
		||||
          QgsDebugMsgLevel( QStringLiteral( "O2::onVerificationReceived: Token expires in %1 seconds" ).arg( expiresIn ), 2 );
 | 
			
		||||
          setExpires( QDateTime::currentMSecsSinceEpoch() / 1000 + expiresIn );
 | 
			
		||||
        }
 | 
			
		||||
      }
 | 
			
		||||
@ -425,7 +425,7 @@ void QgsO2::onVerificationReceived( QMap<QString, QString> response )
 | 
			
		||||
    }
 | 
			
		||||
    else
 | 
			
		||||
    {
 | 
			
		||||
      qWarning() << "O2::onVerificationReceived: Access token missing from response for implicit flow";
 | 
			
		||||
      QgsDebugError( QStringLiteral( "O2::onVerificationReceived: Access token missing from response for implicit flow" ) );
 | 
			
		||||
      Q_EMIT linkingFailed();
 | 
			
		||||
    }
 | 
			
		||||
  }
 | 
			
		||||
@ -448,13 +448,13 @@ static QVariantMap parseTokenResponse( const QByteArray &data )
 | 
			
		||||
  const QJsonDocument doc = QJsonDocument::fromJson( data, &err );
 | 
			
		||||
  if ( err.error != QJsonParseError::NoError )
 | 
			
		||||
  {
 | 
			
		||||
    qWarning() << "parseTokenResponse: Failed to parse token response due to err:" << err.errorString();
 | 
			
		||||
    QgsDebugError( QStringLiteral( "parseTokenResponse: Failed to parse token response due to err: %1" ).arg( err.errorString() ) );
 | 
			
		||||
    return QVariantMap();
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  if ( !doc.isObject() )
 | 
			
		||||
  {
 | 
			
		||||
    qWarning() << "parseTokenResponse: Token response is not an object";
 | 
			
		||||
    QgsDebugError( QStringLiteral( "parseTokenResponse: Token response is not an object" ) );
 | 
			
		||||
    return QVariantMap();
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
@ -464,17 +464,17 @@ static QVariantMap parseTokenResponse( const QByteArray &data )
 | 
			
		||||
// Code adapted from O2::refresh(), but using QgsBlockingNetworkRequest
 | 
			
		||||
void QgsO2::refreshSynchronous()
 | 
			
		||||
{
 | 
			
		||||
  qDebug() << "O2::refresh: Token: ..." << refreshToken().right( 7 );
 | 
			
		||||
  QgsDebugMsgLevel( QStringLiteral( "O2::refresh: Token: ... %1" ).arg( refreshToken().right( 7 ) ), 2 );
 | 
			
		||||
 | 
			
		||||
  if ( refreshToken().isEmpty() )
 | 
			
		||||
  {
 | 
			
		||||
    qWarning() << "O2::refresh: No refresh token";
 | 
			
		||||
    QgsDebugError( QStringLiteral( "O2::refresh: No refresh token" ) );
 | 
			
		||||
    onRefreshError( QNetworkReply::AuthenticationRequiredError );
 | 
			
		||||
    return;
 | 
			
		||||
  }
 | 
			
		||||
  if ( refreshTokenUrl_.isEmpty() )
 | 
			
		||||
  {
 | 
			
		||||
    qWarning() << "O2::refresh: Refresh token URL not set";
 | 
			
		||||
    QgsDebugError( QStringLiteral( "O2::refresh: Refresh token URL not set" ) );
 | 
			
		||||
    onRefreshError( QNetworkReply::AuthenticationRequiredError );
 | 
			
		||||
    return;
 | 
			
		||||
  }
 | 
			
		||||
@ -501,7 +501,7 @@ void QgsO2::refreshSynchronous()
 | 
			
		||||
    const QVariantMap tokens = parseTokenResponse( reply );
 | 
			
		||||
    if ( tokens.contains( QStringLiteral( "error" ) ) )
 | 
			
		||||
    {
 | 
			
		||||
      qDebug() << " Error refreshing token" << tokens.value( QStringLiteral( "error" ) ).toMap().value( QStringLiteral( "message" ) ).toString().toLocal8Bit().constData();
 | 
			
		||||
      QgsDebugError( QStringLiteral( "Error refreshing token %1" ).arg( tokens.value( QStringLiteral( "error" ) ).toMap().value( QStringLiteral( "message" ) ).toString().toLocal8Bit().constData() ) );
 | 
			
		||||
      unlink();
 | 
			
		||||
    }
 | 
			
		||||
    else
 | 
			
		||||
@ -512,7 +512,7 @@ void QgsO2::refreshSynchronous()
 | 
			
		||||
      if ( !refreshToken.isEmpty() )
 | 
			
		||||
        setRefreshToken( refreshToken );
 | 
			
		||||
      setLinked( true );
 | 
			
		||||
      qDebug() << " New token expires in" << expires() << "seconds";
 | 
			
		||||
      QgsDebugMsgLevel( QStringLiteral( "New token expires in %1 seconds" ).arg( expires() ), 2 );
 | 
			
		||||
      emit linkingSucceeded();
 | 
			
		||||
    }
 | 
			
		||||
    emit refreshFinished( QNetworkReply::NoError );
 | 
			
		||||
@ -520,7 +520,7 @@ void QgsO2::refreshSynchronous()
 | 
			
		||||
  else
 | 
			
		||||
  {
 | 
			
		||||
    unlink();
 | 
			
		||||
    qDebug() << "O2::onRefreshFinished: Error" << blockingRequest.errorMessage();
 | 
			
		||||
    QgsDebugError( QStringLiteral( "O2::onRefreshFinished: Error %1" ).arg( blockingRequest.errorMessage() ) );
 | 
			
		||||
    emit refreshFinished( blockingRequest.reply().error() );
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user