[QGIS Commit] r10456 - in trunk/qgis: python/core src/app src/core
src/plugins/spit src/ui
svn_qgis at osgeo.org
svn_qgis at osgeo.org
Thu Apr 2 17:32:14 EDT 2009
Author: jef
Date: 2009-04-02 17:32:13 -0400 (Thu, 02 Apr 2009)
New Revision: 10456
Modified:
trunk/qgis/python/core/qgsdatasourceuri.sip
trunk/qgis/src/app/qgsdbsourceselect.cpp
trunk/qgis/src/app/qgsnewconnection.cpp
trunk/qgis/src/core/qgsdatasourceuri.cpp
trunk/qgis/src/core/qgsdatasourceuri.h
trunk/qgis/src/plugins/spit/qgsspit.cpp
trunk/qgis/src/ui/qgsnewconnectionbase.ui
Log:
make SSL mode of PostgreSQL connections configuable
Modified: trunk/qgis/python/core/qgsdatasourceuri.sip
===================================================================
--- trunk/qgis/python/core/qgsdatasourceuri.sip 2009-04-02 12:52:34 UTC (rev 10455)
+++ trunk/qgis/python/core/qgsdatasourceuri.sip 2009-04-02 21:32:13 UTC (rev 10456)
@@ -12,6 +12,7 @@
%End
public:
+ enum SSLmode { SSLprefer, SSLdisable, SSLallow, SSLrequire };
//! default constructor
QgsDataSourceURI();
@@ -33,7 +34,8 @@
const QString& aPort,
const QString& aDatabase,
const QString& aUsername,
- const QString& aPassword);
+ const QString& aPassword,
+ SSLmode sslmode );
//! Set all data source related members at once
void setDataSource(const QString& aSchema,
Modified: trunk/qgis/src/app/qgsdbsourceselect.cpp
===================================================================
--- trunk/qgis/src/app/qgsdbsourceselect.cpp 2009-04-02 12:52:34 UTC (rev 10455)
+++ trunk/qgis/src/app/qgsdbsourceselect.cpp 2009-04-02 21:32:13 UTC (rev 10456)
@@ -240,6 +240,7 @@
settings.remove( key + "/username" );
settings.remove( key + "/password" );
settings.remove( key + "/port" );
+ settings.remove( key + "/sslmode" );
settings.remove( key + "/save" );
settings.remove( key );
//if(!success){
@@ -373,8 +374,11 @@
settings.value( key + "/port" ).toString(),
database,
settings.value( key + "/username" ).toString(),
- password );
+ password,
+ (QgsDataSourceURI::SSLmode) settings.value( key + "/sslmode", QgsDataSourceURI::SSLprefer ).toInt() );
+
+
bool searchPublicOnly = settings.value( key + "/publicOnly" ).toBool();
bool searchGeometryColumnsOnly = settings.value( key + "/geometryColumnsOnly" ).toBool();
@@ -410,7 +414,8 @@
settings.value( key + "/port" ).toString(),
database,
settings.value( key + "/username" ).toString(),
- password );
+ password,
+ (QgsDataSourceURI::SSLmode) settings.value( key + "/sslmode", QgsDataSourceURI::SSLprefer ).toInt() );
m_connectionInfo = uri.connectionInfo();
PQfinish( pd );
Modified: trunk/qgis/src/app/qgsnewconnection.cpp
===================================================================
--- trunk/qgis/src/app/qgsnewconnection.cpp 2009-04-02 12:52:34 UTC (rev 10455)
+++ trunk/qgis/src/app/qgsnewconnection.cpp 2009-04-02 21:32:13 UTC (rev 10456)
@@ -61,6 +61,12 @@
// Ensure that cb_plublicSchemaOnly is set correctly
on_cb_geometryColumnsOnly_clicked();
+ cbxSSLmode->insertItem( QgsDataSourceURI::SSLprefer, tr("prefer") );
+ cbxSSLmode->insertItem( QgsDataSourceURI::SSLrequire, tr("require") );
+ cbxSSLmode->insertItem( QgsDataSourceURI::SSLallow, tr("allow") );
+ cbxSSLmode->insertItem( QgsDataSourceURI::SSLdisable, tr("disable") );
+ cbxSSLmode->setCurrentIndex( settings.value( key + "/sslmode", QgsDataSourceURI::SSLprefer ).toInt() );
+
if ( settings.value( key + "/save" ).toString() == "true" )
{
txtPassword->setText( settings.value( key + "/password" ).toString() );
@@ -108,7 +114,7 @@
void QgsNewConnection::testConnection()
{
QgsDataSourceURI uri;
- uri.setConnection( txtHost->text(), txtPort->text(), txtDatabase->text(), txtUsername->text(), txtPassword->text() );
+ uri.setConnection( txtHost->text(), txtPort->text(), txtDatabase->text(), txtUsername->text(), txtPassword->text(), (QgsDataSourceURI::SSLmode) cbxSSLmode->currentIndex() );
QgsLogger::debug( "PQconnectdb(" + uri.connectionInfo() + ");" );
@@ -142,6 +148,7 @@
settings.setValue( baseKey + "/publicOnly", cb_publicSchemaOnly->isChecked() );
settings.setValue( baseKey + "/geometryColumnsOnly", cb_geometryColumnsOnly->isChecked() );
settings.setValue( baseKey + "/save", chkStorePassword->isChecked() ? "true" : "false" );
+ settings.setValue( baseKey + "/sslmode", cbxSSLmode->currentIndex() );
accept();
}
Modified: trunk/qgis/src/core/qgsdatasourceuri.cpp
===================================================================
--- trunk/qgis/src/core/qgsdatasourceuri.cpp 2009-04-02 12:52:34 UTC (rev 10455)
+++ trunk/qgis/src/core/qgsdatasourceuri.cpp 2009-04-02 21:32:13 UTC (rev 10456)
@@ -23,12 +23,12 @@
#include <QStringList>
#include <QRegExp>
-QgsDataSourceURI::QgsDataSourceURI()
+QgsDataSourceURI::QgsDataSourceURI() : mSSLmode(SSLprefer)
{
// do nothing
}
-QgsDataSourceURI::QgsDataSourceURI( QString uri )
+QgsDataSourceURI::QgsDataSourceURI( QString uri ) : mSSLmode(SSLprefer)
{
int i = 0;
while ( i < uri.length() )
@@ -146,8 +146,22 @@
}
else if ( pname == "sslmode" )
{
- QgsDebugMsg( "sslmode ignored" );
+ if( pval == "disable" )
+ mSSLmode = SSLdisable;
+ else if( pval == "allow" )
+ mSSLmode = SSLallow;
+ else if( pval == "prefer" )
+ mSSLmode = SSLprefer;
+ else if( pval == "require" )
+ mSSLmode = SSLrequire;
}
+ else if ( pname == "requiressl" )
+ {
+ if( pval == "0" )
+ mSSLmode = SSLdisable;
+ else
+ mSSLmode = SSLprefer;
+ }
else if ( pname == "krbsrvname" )
{
QgsDebugMsg( "kerberos server name ignored" );
@@ -293,6 +307,15 @@
}
}
+ if ( mSSLmode == SSLdisable )
+ connectionInfo += " sslmode=disable";
+ else if ( mSSLmode == SSLallow )
+ connectionInfo += " sslmode=allow";
+ else if ( mSSLmode == SSLrequire )
+ connectionInfo += " sslmode=require";
+ else if ( mSSLmode == SSLprefer )
+ connectionInfo += " sslmode=prefer";
+
return connectionInfo;
}
@@ -317,13 +340,15 @@
const QString &port,
const QString &database,
const QString &username,
- const QString &password )
+ const QString &password,
+ SSLmode sslmode )
{
mHost = host;
mDatabase = database;
mPort = port;
mUsername = username;
mPassword = password;
+ mSSLmode = sslmode;
}
void QgsDataSourceURI::setDataSource( const QString &schema,
Modified: trunk/qgis/src/core/qgsdatasourceuri.h
===================================================================
--- trunk/qgis/src/core/qgsdatasourceuri.h 2009-04-02 12:52:34 UTC (rev 10455)
+++ trunk/qgis/src/core/qgsdatasourceuri.h 2009-04-02 21:32:13 UTC (rev 10456)
@@ -29,8 +29,8 @@
*/
class CORE_EXPORT QgsDataSourceURI
{
-
public:
+ enum SSLmode { SSLprefer, SSLdisable, SSLallow, SSLrequire };
//! default constructor
QgsDataSourceURI();
@@ -52,7 +52,8 @@
const QString& aPort,
const QString& aDatabase,
const QString& aUsername,
- const QString& aPassword );
+ const QString& aPassword,
+ SSLmode sslmode );
//! Set all data source related members at once
void setDataSource( const QString& aSchema,
@@ -60,11 +61,13 @@
const QString& aGeometryColumn,
const QString& aSql = QString() );
+
QString username() const;
QString schema() const;
QString table() const;
QString sql() const;
QString geometryColumn() const;
+ enum SSLmode sslMode() const;
void clearSchema();
void setSql( QString sql );
@@ -93,6 +96,8 @@
QString mUsername;
//! password
QString mPassword;
+ //! ssl mode
+ enum SSLmode mSSLmode;
};
#endif //QGSDATASOURCEURI_H
Modified: trunk/qgis/src/plugins/spit/qgsspit.cpp
===================================================================
--- trunk/qgis/src/plugins/spit/qgsspit.cpp 2009-04-02 12:52:34 UTC (rev 10455)
+++ trunk/qgis/src/plugins/spit/qgsspit.cpp 2009-04-02 21:32:13 UTC (rev 10456)
@@ -413,7 +413,8 @@
settings.value( key + "/port" ).toString(),
database,
settings.value( key + "/username" ).toString(),
- password );
+ password,
+ (QgsDataSourceURI::SSLmode) settings.value( key + "/sslmode", QgsDataSourceURI::SSLprefer ).toInt() );
conn = PQconnectdb( uri.connectionInfo().toUtf8() );
}
Modified: trunk/qgis/src/ui/qgsnewconnectionbase.ui
===================================================================
--- trunk/qgis/src/ui/qgsnewconnectionbase.ui 2009-04-02 12:52:34 UTC (rev 10455)
+++ trunk/qgis/src/ui/qgsnewconnectionbase.ui 2009-04-02 21:32:13 UTC (rev 10456)
@@ -6,13 +6,11 @@
<x>0</x>
<y>0</y>
<width>509</width>
- <height>335</height>
+ <height>402</height>
</rect>
</property>
<property name="sizePolicy" >
- <sizepolicy>
- <hsizetype>3</hsizetype>
- <vsizetype>3</vsizetype>
+ <sizepolicy vsizetype="MinimumExpanding" hsizetype="MinimumExpanding" >
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
@@ -93,12 +91,12 @@
</item>
<item row="1" column="1" >
<layout class="QHBoxLayout" >
+ <property name="spacing" >
+ <number>6</number>
+ </property>
<property name="margin" >
<number>0</number>
</property>
- <property name="spacing" >
- <number>6</number>
- </property>
<item>
<widget class="QCheckBox" name="chkStorePassword" >
<property name="text" >
@@ -117,20 +115,20 @@
</item>
<item row="0" column="1" >
<layout class="QHBoxLayout" >
+ <property name="spacing" >
+ <number>6</number>
+ </property>
<property name="margin" >
<number>0</number>
</property>
- <property name="spacing" >
- <number>6</number>
- </property>
<item>
<layout class="QVBoxLayout" >
+ <property name="spacing" >
+ <number>6</number>
+ </property>
<property name="margin" >
<number>0</number>
</property>
- <property name="spacing" >
- <number>6</number>
- </property>
<item>
<widget class="QLabel" name="TextLabel1_2" >
<property name="text" >
@@ -191,16 +189,23 @@
</property>
</widget>
</item>
+ <item>
+ <widget class="QLabel" name="TextLabel3_3" >
+ <property name="text" >
+ <string>SSL mode</string>
+ </property>
+ </widget>
+ </item>
</layout>
</item>
<item>
<layout class="QVBoxLayout" >
+ <property name="spacing" >
+ <number>6</number>
+ </property>
<property name="margin" >
<number>0</number>
</property>
- <property name="spacing" >
- <number>6</number>
- </property>
<item>
<widget class="QLineEdit" name="txtName" >
<property name="toolTip" >
@@ -231,6 +236,9 @@
</property>
</widget>
</item>
+ <item>
+ <widget class="QComboBox" name="cbxSSLmode" />
+ </item>
</layout>
</item>
</layout>
@@ -240,12 +248,12 @@
</item>
<item row="0" column="1" >
<layout class="QVBoxLayout" >
+ <property name="spacing" >
+ <number>6</number>
+ </property>
<property name="margin" >
<number>0</number>
</property>
- <property name="spacing" >
- <number>6</number>
- </property>
<item>
<widget class="QPushButton" name="btnOk" >
<property name="text" >
@@ -299,7 +307,7 @@
<property name="sizeType" >
<enum>QSizePolicy::Expanding</enum>
</property>
- <property name="sizeHint" >
+ <property name="sizeHint" stdset="0" >
<size>
<width>87</width>
<height>150</height>
More information about the QGIS-commit
mailing list