Skip to content
Permalink
Browse files

Clean up with prepare commit script

  • Loading branch information
dakcarto authored and luipir committed Jan 13, 2016
1 parent 5fb798e commit e7a1e2c2ec9e99ad737b747bc61df5d423d96892
@@ -36,7 +36,7 @@ QgsAuthBasicMethod::QgsAuthBasicMethod()
<< "ows"
<< "wfs" // convert to lowercase
<< "wcs"
<< "wms");
<< "wms" );
}

QgsAuthBasicMethod::~QgsAuthBasicMethod()
@@ -122,23 +122,23 @@ bool QgsAuthIdentCertMethod::updateDataSourceUriItems( QStringList &connectionIt

if ( !amConfig.isValid() )
{
QgsDebugMsg( QString( "Update URI items: FAILED retrieved invalid Auth method for authcfg: %1" ).arg( authcfg ) );
return false;
QgsDebugMsg( QString( "Update URI items: FAILED retrieved invalid Auth method for authcfg: %1" ).arg( authcfg ) );
return false;
}

// get client cent and key
QSslCertificate clientCert = QgsAuthManager::instance()->getCertIdentityBundle( amConfig.config( "certid" ) ).first;
QSslKey clientKey = QgsAuthManager::instance()->getCertIdentityBundle( amConfig.config( "certid" ) ).second;

// get common name of the client certificate
QString commonName = QgsAuthCertUtils::resolvedCertName( clientCert, false);
QString commonName = QgsAuthCertUtils::resolvedCertName( clientCert, false );

// get CA
QByteArray caCert = QgsAuthManager::instance()->getTrustedCaCertsPemText();

// save client cert to temp file
QFile certFile( QDir::tempPath() + QDir::separator() + pkiTempFilePrefix + QUuid::createUuid() + ".pem" );
if( certFile.open( QIODevice::WriteOnly ) )
if ( certFile.open( QIODevice::WriteOnly ) )
{
certFile.write( clientCert.toPem() );
}
@@ -152,7 +152,7 @@ bool QgsAuthIdentCertMethod::updateDataSourceUriItems( QStringList &connectionIt

// save key cert to temp file setting it's permission only read to the current user
QFile keyFile( QDir::tempPath() + QDir::separator() + pkiTempFilePrefix + QUuid::createUuid() + ".pem" );
if( keyFile.open( QIODevice::WriteOnly ) )
if ( keyFile.open( QIODevice::WriteOnly ) )
{
keyFile.write( clientKey.toPem() );
}
@@ -166,7 +166,7 @@ bool QgsAuthIdentCertMethod::updateDataSourceUriItems( QStringList &connectionIt

// save CA to tempo file
QFile caFile( QDir::tempPath() + QDir::separator() + pkiTempFilePrefix + QUuid::createUuid() + ".pem" );
if( caFile.open( QIODevice::WriteOnly ) )
if ( caFile.open( QIODevice::WriteOnly ) )
{
caFile.write( caCert );
}
@@ -123,23 +123,23 @@ bool QgsAuthPkiPathsMethod::updateDataSourceUriItems( QStringList &connectionIte

if ( !amConfig.isValid() )
{
QgsDebugMsg( QString( "Update URI items: FAILED retrieved invalid Auth method for authcfg: %1" ).arg( authcfg ) );
return false;
QgsDebugMsg( QString( "Update URI items: FAILED retrieved invalid Auth method for authcfg: %1" ).arg( authcfg ) );
return false;
}

// get client cent and key
QSslCertificate clientCert = QgsAuthManager::instance()->getCertIdentityBundle( amConfig.config( "certid" ) ).first;
QSslKey clientKey = QgsAuthManager::instance()->getCertIdentityBundle( amConfig.config( "certid" ) ).second;

// get common name of the client certificate
QString commonName = QgsAuthCertUtils::resolvedCertName( clientCert, false);
QString commonName = QgsAuthCertUtils::resolvedCertName( clientCert, false );

// get CA
QByteArray caCert = QgsAuthManager::instance()->getTrustedCaCertsPemText();

// save client cert to temp file
QFile certFile( QDir::tempPath() + QDir::separator() + pkiTempFilePrefix + QUuid::createUuid() + ".pem" );
if( certFile.open( QIODevice::WriteOnly ) )
if ( certFile.open( QIODevice::WriteOnly ) )
{
certFile.write( clientCert.toPem() );
}
@@ -153,7 +153,7 @@ bool QgsAuthPkiPathsMethod::updateDataSourceUriItems( QStringList &connectionIte

// save key cert to temp file setting it's permission only read to the current user
QFile keyFile( QDir::tempPath() + QDir::separator() + pkiTempFilePrefix + QUuid::createUuid() + ".pem" );
if( keyFile.open( QIODevice::WriteOnly ) )
if ( keyFile.open( QIODevice::WriteOnly ) )
{
keyFile.write( clientKey.toPem() );
}
@@ -167,7 +167,7 @@ bool QgsAuthPkiPathsMethod::updateDataSourceUriItems( QStringList &connectionIte

// save CA to tempo file
QFile caFile( QDir::tempPath() + QDir::separator() + pkiTempFilePrefix + QUuid::createUuid() + ".pem" );
if( caFile.open( QIODevice::WriteOnly ) )
if ( caFile.open( QIODevice::WriteOnly ) )
{
caFile.write( caCert );
}
@@ -123,23 +123,23 @@ bool QgsAuthPkcs12Method::updateDataSourceUriItems( QStringList &connectionItems

if ( !amConfig.isValid() )
{
QgsDebugMsg( QString( "Update URI items: FAILED retrieved invalid Auth method for authcfg: %1" ).arg( authcfg ) );
return false;
QgsDebugMsg( QString( "Update URI items: FAILED retrieved invalid Auth method for authcfg: %1" ).arg( authcfg ) );
return false;
}

// get client cent and key
QSslCertificate clientCert = QgsAuthManager::instance()->getCertIdentityBundle( amConfig.config( "certid" ) ).first;
QSslKey clientKey = QgsAuthManager::instance()->getCertIdentityBundle( amConfig.config( "certid" ) ).second;

// get common name of the client certificate
QString commonName = QgsAuthCertUtils::resolvedCertName( clientCert, false);
QString commonName = QgsAuthCertUtils::resolvedCertName( clientCert, false );

// get CA
QByteArray caCert = QgsAuthManager::instance()->getTrustedCaCertsPemText();

// save client cert to temp file
QFile certFile( QDir::tempPath() + QDir::separator() + pkiTempFilePrefix + QUuid::createUuid() + ".pem" );
if( certFile.open( QIODevice::WriteOnly ) )
if ( certFile.open( QIODevice::WriteOnly ) )
{
certFile.write( clientCert.toPem() );
}
@@ -153,7 +153,7 @@ bool QgsAuthPkcs12Method::updateDataSourceUriItems( QStringList &connectionItems

// save key cert to temp file setting it's permission only read to the current user
QFile keyFile( QDir::tempPath() + QDir::separator() + pkiTempFilePrefix + QUuid::createUuid() + ".pem" );
if( keyFile.open( QIODevice::WriteOnly ) )
if ( keyFile.open( QIODevice::WriteOnly ) )
{
keyFile.write( clientKey.toPem() );
}
@@ -167,7 +167,7 @@ bool QgsAuthPkcs12Method::updateDataSourceUriItems( QStringList &connectionItems

// save CA to tempo file
QFile caFile( QDir::tempPath() + QDir::separator() + pkiTempFilePrefix + QUuid::createUuid() + ".pem" );
if( caFile.open( QIODevice::WriteOnly ) )
if ( caFile.open( QIODevice::WriteOnly ) )
{
caFile.write( caCert );
}
@@ -53,7 +53,7 @@ QgsTransaction* QgsTransaction::create( const QStringList& layerIds )
if ( !layer )
return nullptr;

QString connStr = QgsDataSourceURI( layer->source() ).connectionInfo(false);
QString connStr = QgsDataSourceURI( layer->source() ).connectionInfo( false );
QString providerKey = layer->dataProvider()->name();
QgsTransaction* ts = QgsTransaction::create( connStr, providerKey );
if ( !ts )
@@ -109,10 +109,10 @@ bool QgsTransaction::addLayer( QgsVectorLayer* layer )
return false;

//connection string not compatible
if ( QgsDataSourceURI( layer->source() ).connectionInfo(false) != mConnString )
if ( QgsDataSourceURI( layer->source() ).connectionInfo( false ) != mConnString )
{
QgsDebugMsg( QString( "Couldn't start transaction because connection string for layer %1 : '%2' does not match '%3'" ).arg(
layer->id(), QgsDataSourceURI( layer->source() ).connectionInfo(false), mConnString ) );
layer->id(), QgsDataSourceURI( layer->source() ).connectionInfo( false ), mConnString ) );
return false;
}

@@ -44,10 +44,10 @@ void QgsGeomColumnTypeThread::stop()
void QgsGeomColumnTypeThread::run()
{
QgsDataSourceURI uri = QgsPostgresConn::connUri( mName );
mConn = QgsPostgresConn::connectDb( uri.connectionInfo(false), true );
mConn = QgsPostgresConn::connectDb( uri.connectionInfo( false ), true );
if ( !mConn )
{
QgsDebugMsg( "Connection failed - " + uri.connectionInfo(false) );
QgsDebugMsg( "Connection failed - " + uri.connectionInfo( false ) );
return;
}

@@ -197,7 +197,7 @@ void QgsPgNewConnection::testConnection()
mAuthConfigSelect->configId() );
}

QgsPostgresConn *conn = QgsPostgresConn::connectDb( uri.connectionInfo(false), true );
QgsPostgresConn *conn = QgsPostgresConn::connectDb( uri.connectionInfo( false ), true );

if ( conn )
{
@@ -531,7 +531,7 @@ void QgsPgSourceSelect::on_btnConnect_clicked()
// populate the table list
QgsDataSourceURI uri = QgsPostgresConn::connUri( cmbConnections->currentText() );

QgsDebugMsg( "Connection info: " + uri.connectionInfo(false) );
QgsDebugMsg( "Connection info: " + uri.connectionInfo( false ) );

mDataSrcUri = uri;
mUseEstimatedMetadata = uri.useEstimatedMetadata();
@@ -604,7 +604,7 @@ void QgsPgSourceSelect::setSql( const QModelIndex &index )
QModelIndex idx = mProxyModel.mapToSource( index );
QString tableName = mTableModel.itemFromIndex( idx.sibling( idx.row(), QgsPgTableModel::dbtmTable ) )->text();

QString uri = mTableModel.layerURI( idx, connectionInfo(false), mUseEstimatedMetadata );
QString uri = mTableModel.layerURI( idx, connectionInfo( false ), mUseEstimatedMetadata );
if ( uri.isNull() )
{
QgsDebugMsg( "no uri" );
@@ -203,24 +203,24 @@ QgsPostgresConn::QgsPostgresConn( const QString& conninfo, bool readOnly, bool s
QgsDebugMsg( QString( "New PostgreSQL connection for " ) + conninfo );

// expand connectionInfo
QgsDataSourceURI uri(conninfo);
QString expandedConnectionInfo = uri.connectionInfo(true);
QgsDataSourceURI uri( conninfo );
QString expandedConnectionInfo = uri.connectionInfo( true );

mConn = PQconnectdb( expandedConnectionInfo.toLocal8Bit() ); // use what is set based on locale; after connecting, use Utf8

// remove temporary cert/key/CA
QgsDataSourceURI expandedUri(expandedConnectionInfo);
QString sslCertFile = expandedUri.param("sslcert");
sslCertFile.remove("'");
QFile::remove(sslCertFile);
QgsDataSourceURI expandedUri( expandedConnectionInfo );
QString sslCertFile = expandedUri.param( "sslcert" );
sslCertFile.remove( "'" );
QFile::remove( sslCertFile );

QString sslKeyFile = expandedUri.param("sslkey");
sslKeyFile.remove("'");
QFile::remove(sslKeyFile);
QString sslKeyFile = expandedUri.param( "sslkey" );
sslKeyFile.remove( "'" );
QFile::remove( sslKeyFile );

QString sslCAFile = expandedUri.param("sslrootcert");
sslCAFile.remove("'");
QFile::remove(sslCAFile);
QString sslCAFile = expandedUri.param( "sslrootcert" );
sslCAFile.remove( "'" );
QFile::remove( sslCAFile );

// check the connection status
if ( PQstatus() != CONNECTION_OK )
@@ -246,7 +246,7 @@ QgsPostgresConn::QgsPostgresConn( const QString& conninfo, bool readOnly, bool s
if ( !password.isEmpty() )
uri.setPassword( password );

QgsDebugMsg( "Connecting to " + uri.connectionInfo(false) );
QgsDebugMsg( "Connecting to " + uri.connectionInfo( false ) );
mConn = PQconnectdb( uri.connectionInfo().toLocal8Bit() );
}

@@ -52,11 +52,11 @@ QVector<QgsDataItem*> QgsPGConnectionItem::createChildren()

QgsDataSourceURI uri = QgsPostgresConn::connUri( mName );
// TODO: wee need to cancel somehow acquireConnection() if deleteLater() was called on this item to avoid later credential dialog if connection failed
QgsPostgresConn *conn = QgsPostgresConnPool::instance()->acquireConnection( uri.connectionInfo(false) );
QgsPostgresConn *conn = QgsPostgresConnPool::instance()->acquireConnection( uri.connectionInfo( false ) );
if ( !conn )
{
items.append( new QgsErrorItem( this, tr( "Connection failed" ), mPath + "/error" ) );
QgsDebugMsg( "Connection failed - " + uri.connectionInfo(false) );
QgsDebugMsg( "Connection failed - " + uri.connectionInfo( false ) );
return items;
}

@@ -162,7 +162,7 @@ void QgsPGConnectionItem::createSchema()
return;

QgsDataSourceURI uri = QgsPostgresConn::connUri( mName );
QgsPostgresConn *conn = QgsPostgresConn::connectDb( uri.connectionInfo(false), false );
QgsPostgresConn *conn = QgsPostgresConn::connectDb( uri.connectionInfo( false ), false );
if ( !conn )
{
QMessageBox::warning( nullptr, tr( "Create Schema" ), tr( "Unable to create schema." ) );
@@ -223,7 +223,7 @@ bool QgsPGConnectionItem::handleDrop( const QMimeData * data, QString toSchema )
if ( srcLayer->isValid() )
{
uri.setDataSource( QString(), u.name, "geom" );
QgsDebugMsg( "URI " + uri.uri(false) );
QgsDebugMsg( "URI " + uri.uri( false ) );

if ( !toSchema.isNull() )
{
@@ -232,7 +232,7 @@ bool QgsPGConnectionItem::handleDrop( const QMimeData * data, QString toSchema )

QgsVectorLayerImport::ImportError err;
QString importError;
err = QgsVectorLayerImport::importLayer( srcLayer, uri.uri(false), "postgres", &srcLayer->crs(), false, &importError, false, nullptr, progress );
err = QgsVectorLayerImport::importLayer( srcLayer, uri.uri( false ), "postgres", &srcLayer->crs(), false, &importError, false, nullptr, progress );
if ( err == QgsVectorLayerImport::NoError )
importResults.append( tr( "%1: OK!" ).arg( u.name ) );
else
@@ -355,7 +355,7 @@ void QgsPGLayerItem::renameLayer()
QString newName = QgsPostgresConn::quotedIdentifier( dlg.name() );

QgsDataSourceURI dsUri( mUri );
QgsPostgresConn *conn = QgsPostgresConn::connectDb( dsUri.connectionInfo(false), false );
QgsPostgresConn *conn = QgsPostgresConn::connectDb( dsUri.connectionInfo( false ), false );
if ( !conn )
{
QMessageBox::warning( nullptr, tr( "Rename %1" ).arg( typeName ), tr( "Unable to rename %1." ).arg( lowerTypeName ) );
@@ -396,7 +396,7 @@ void QgsPGLayerItem::truncateTable()
return;

QgsDataSourceURI dsUri( mUri );
QgsPostgresConn *conn = QgsPostgresConn::connectDb( dsUri.connectionInfo(false), false );
QgsPostgresConn *conn = QgsPostgresConn::connectDb( dsUri.connectionInfo( false ), false );
if ( !conn )
{
QMessageBox::warning( nullptr, tr( "Truncate Table" ), tr( "Unable to truncate table." ) );
@@ -466,11 +466,11 @@ QVector<QgsDataItem*> QgsPGSchemaItem::createChildren()
QVector<QgsDataItem*>items;

QgsDataSourceURI uri = QgsPostgresConn::connUri( mConnectionName );
QgsPostgresConn *conn = QgsPostgresConnPool::instance()->acquireConnection( uri.connectionInfo(false) );
QgsPostgresConn *conn = QgsPostgresConnPool::instance()->acquireConnection( uri.connectionInfo( false ) );
if ( !conn )
{
items.append( new QgsErrorItem( this, tr( "Connection failed" ), mPath + "/error" ) );
QgsDebugMsg( "Connection failed - " + uri.connectionInfo(false) );
QgsDebugMsg( "Connection failed - " + uri.connectionInfo( false ) );
return items;
}

@@ -545,7 +545,7 @@ void QgsPGSchemaItem::deleteSchema()
{
// check if schema contains tables/views
QgsDataSourceURI uri = QgsPostgresConn::connUri( mConnectionName );
QgsPostgresConn *conn = QgsPostgresConn::connectDb( uri.connectionInfo(false), false );
QgsPostgresConn *conn = QgsPostgresConn::connectDb( uri.connectionInfo( false ), false );
if ( !conn )
{
QMessageBox::warning( nullptr, tr( "Delete Schema" ), tr( "Unable to delete schema." ) );
@@ -618,7 +618,7 @@ void QgsPGSchemaItem::renameSchema()

QString schemaName = QgsPostgresConn::quotedIdentifier( mName );
QgsDataSourceURI uri = QgsPostgresConn::connUri( mConnectionName );
QgsPostgresConn *conn = QgsPostgresConn::connectDb( uri.connectionInfo(false), false );
QgsPostgresConn *conn = QgsPostgresConn::connectDb( uri.connectionInfo( false ), false );
if ( !conn )
{
QMessageBox::warning( nullptr, tr( "Rename Schema" ), tr( "Unable to rename schema." ) );
@@ -734,7 +734,7 @@ void QgsPostgresFeatureIterator::getFeatureAttribute( int idx, QgsPostgresResult
// ------------------

QgsPostgresFeatureSource::QgsPostgresFeatureSource( const QgsPostgresProvider* p )
: mConnInfo( p->mUri.connectionInfo(false) )
: mConnInfo( p->mUri.connectionInfo( false ) )
, mGeometryColumn( p->mGeometryColumn )
, mFields( p->mAttributeFields )
, mSpatialColType( p->mSpatialColType )

0 comments on commit e7a1e2c

Please sign in to comment.
You can’t perform that action at this time.