Skip to content

Commit

Permalink
Merge pull request #4881 from boundlessgeo/xyz-auth-gui
Browse files Browse the repository at this point in the history
[feature][needs-docs] XYZ authentication and referer added to GUI
  • Loading branch information
elpaso committed Jul 21, 2017
2 parents 0cba29c + e423eea commit 89ffecb
Show file tree
Hide file tree
Showing 5 changed files with 241 additions and 74 deletions.
16 changes: 16 additions & 0 deletions src/providers/wms/qgsxyzconnection.cpp
Expand Up @@ -27,6 +27,14 @@ QString QgsXyzConnection::encodedUri() const
uri.setParam( QStringLiteral( "zmin" ), QString::number( zMin ) );
if ( zMax != -1 )
uri.setParam( QStringLiteral( "zmax" ), QString::number( zMax ) );
if ( ! authCfg.isEmpty() )
uri.setParam( QStringLiteral( "authcfg" ), authCfg );
if ( ! username.isEmpty() )
uri.setParam( QStringLiteral( "username" ), username );
if ( ! password.isEmpty() )
uri.setParam( QStringLiteral( "password" ), password );
if ( ! referer.isEmpty() )
uri.setParam( QStringLiteral( "referer" ), referer );
return uri.encodedUri();
}

Expand All @@ -47,6 +55,10 @@ QgsXyzConnection QgsXyzConnectionUtils::connection( const QString &name )
conn.url = settings.value( QStringLiteral( "url" ) ).toString();
conn.zMin = settings.value( QStringLiteral( "zmin" ), -1 ).toInt();
conn.zMax = settings.value( QStringLiteral( "zmax" ), -1 ).toInt();
conn.authCfg = settings.value( QStringLiteral( "authcfg" ) ).toString();
conn.username = settings.value( QStringLiteral( "username" ) ).toString();
conn.password = settings.value( QStringLiteral( "password" ) ).toString();
conn.referer = settings.value( QStringLiteral( "referer" ) ).toString();
return conn;
}

Expand All @@ -63,4 +75,8 @@ void QgsXyzConnectionUtils::addConnection( const QgsXyzConnection &conn )
settings.setValue( QStringLiteral( "url" ), conn.url );
settings.setValue( QStringLiteral( "zmin" ), conn.zMin );
settings.setValue( QStringLiteral( "zmax" ), conn.zMax );
settings.setValue( QStringLiteral( "authcfg" ), conn.authCfg );
settings.setValue( QStringLiteral( "username" ), conn.username );
settings.setValue( QStringLiteral( "password" ), conn.password );
settings.setValue( QStringLiteral( "referer" ), conn.referer );
}
8 changes: 8 additions & 0 deletions src/providers/wms/qgsxyzconnection.h
Expand Up @@ -24,6 +24,14 @@ struct QgsXyzConnection
QString url;
int zMin = -1;
int zMax = -1;
// Authentication configuration id
QString authCfg;
// HTTP Basic username
QString username;
// HTTP Basic password
QString password;
// Referer
QString referer;

QString encodedUri() const;
};
Expand Down
21 changes: 20 additions & 1 deletion src/providers/wms/qgsxyzconnectiondialog.cpp
Expand Up @@ -13,15 +13,18 @@
* *
***************************************************************************/

#include "qgsauthconfigselect.h"
#include "qgsxyzconnectiondialog.h"

#include "qgsxyzconnection.h"

QgsXyzConnectionDialog::QgsXyzConnectionDialog( QWidget *parent )
: QDialog( parent )
, mAuthConfigSelect( nullptr )
{
setupUi( this );

mAuthConfigSelect = new QgsAuthConfigSelect( this );
mTabAuth->insertTab( 1, mAuthConfigSelect, tr( "Configurations" ) );
// Behavior for min and max zoom checkbox
connect( mCheckBoxZMin, &QCheckBox::toggled, mSpinZMin, &QSpinBox::setEnabled );
connect( mCheckBoxZMax, &QCheckBox::toggled, mSpinZMax, &QSpinBox::setEnabled );
Expand All @@ -35,6 +38,18 @@ void QgsXyzConnectionDialog::setConnection( const QgsXyzConnection &conn )
mSpinZMin->setValue( conn.zMin != -1 ? conn.zMin : 0 );
mCheckBoxZMax->setChecked( conn.zMax != -1 );
mSpinZMax->setValue( conn.zMax != -1 ? conn.zMax : 18 );
mEditUsername->setText( conn.username );
mEditPassword->setText( conn.password );
mEditReferer->setText( conn.referer );
mAuthConfigSelect->setConfigId( conn.authCfg );
if ( ! conn.authCfg.isEmpty( ) )
{
mTabAuth->setCurrentIndex( mTabAuth->indexOf( mAuthConfigSelect ) );
}
else
{
mTabAuth->setCurrentIndex( 0 );
}
}

QgsXyzConnection QgsXyzConnectionDialog::connection() const
Expand All @@ -46,5 +61,9 @@ QgsXyzConnection QgsXyzConnectionDialog::connection() const
conn.zMin = mSpinZMin->value();
if ( mCheckBoxZMax->isChecked() )
conn.zMax = mSpinZMax->value();
conn.username = mEditUsername->text();
conn.password = mEditPassword->text();
conn.referer = mEditReferer->text();
conn.authCfg = mAuthConfigSelect->configId( );
return conn;
}
8 changes: 8 additions & 0 deletions src/providers/wms/qgsxyzconnectiondialog.h
Expand Up @@ -20,6 +20,8 @@

#include "ui_qgsxyzconnectiondialog.h"

class QgsAuthConfigSelect;

struct QgsXyzConnection;


Expand All @@ -33,6 +35,12 @@ class QgsXyzConnectionDialog : public QDialog, public Ui::QgsXyzConnectionDialog

QgsXyzConnection connection() const;

private:

QString mBaseKey;
QString mCredentialsBaseKey;
QgsAuthConfigSelect *mAuthConfigSelect = nullptr;

};

#endif // QGSXYZCONNECTIONDIALOG_H

0 comments on commit 89ffecb

Please sign in to comment.