25QString
createDatabaseURI(
const QString &connectionType,
const QString &host,
const QString &database, QString port,
const QString &configId, QString username, QString password,
bool expandAuthConfig )
31 if ( ! configId.isEmpty() )
40 if ( connectionType == QLatin1String(
"ESRI Personal GeoDatabase" ) )
42 uri =
"PGeo:" + database;
44 else if ( connectionType == QLatin1String(
"ESRI ArcSDE" ) )
47 port = QStringLiteral(
"5151" );
49 uri =
"SDE:" + host +
",PORT:" + port +
',' + database +
',' + username +
',' + password;
51 else if ( connectionType == QLatin1String(
"Informix DataBlade" ) )
54 uri =
"IDB:dbname=" + database;
56 if ( !host.isEmpty() )
57 uri += QStringLiteral(
" server=%1" ).arg( host );
59 if ( !username.isEmpty() )
61 uri += QStringLiteral(
" user=%1" ).arg( username );
63 if ( !password.isEmpty() )
64 uri += QStringLiteral(
" pass=%1" ).arg( password );
67 else if ( connectionType == QLatin1String(
"Ingres" ) )
70 uri =
"@driver=ingres,dbname=" + database;
71 if ( !username.isEmpty() )
73 uri += QStringLiteral(
",userid=%1" ).arg( username );
75 if ( !password.isEmpty() )
76 uri += QStringLiteral(
",password=%1" ).arg( password );
79 else if ( connectionType == QLatin1String(
"MySQL" ) )
81 uri =
"MySQL:" + database;
83 if ( !host.isEmpty() )
85 uri += QStringLiteral(
",host=%1" ).arg( host );
87 if ( !port.isEmpty() )
88 uri += QStringLiteral(
",port=%1" ).arg( port );
91 if ( !username.isEmpty() )
93 uri += QStringLiteral(
",user=%1" ).arg( username );
95 if ( !password.isEmpty() )
96 uri += QStringLiteral(
",password=%1" ).arg( password );
99 else if ( connectionType == QLatin1String(
"MSSQL" ) )
101 uri = QStringLiteral(
"MSSQL:" );
103 if ( !host.isEmpty() )
105 uri += QStringLiteral(
";server=%1" ).arg( host );
107 if ( !port.isEmpty() )
108 uri += QStringLiteral(
",%1" ).arg( port );
111 if ( !username.isEmpty() )
113 uri += QStringLiteral(
";uid=%1" ).arg( username );
115 if ( !password.isEmpty() )
116 uri += QStringLiteral(
";pwd=%1" ).arg( password );
119 uri += QLatin1String(
";trusted_connection=yes" );
121 if ( !database.isEmpty() )
122 uri += QStringLiteral(
";database=%1" ).arg( database );
124 else if ( connectionType == QLatin1String(
"Oracle Spatial" ) )
126 uri =
"OCI:" + username;
128 if ( ( !username.isEmpty() && !password.isEmpty() ) ||
129 ( username.isEmpty() && password.isEmpty() ) )
132 if ( !password.isEmpty() )
136 if ( !host.isEmpty() || !database.isEmpty() )
140 if ( !host.isEmpty() )
143 if ( !port.isEmpty() )
147 if ( !database.isEmpty() )
149 if ( !host.isEmpty() )
155 else if ( connectionType == QLatin1String(
"ODBC" ) )
157 if ( !username.isEmpty() )
159 if ( password.isEmpty() )
161 uri =
"ODBC:" + username +
'@' + database;
165 uri =
"ODBC:" + username +
'/' + password +
'@' + database;
171 uri =
"ODBC:" + database;
174 else if ( connectionType == QLatin1String(
"OGDI Vectors" ) )
177 else if ( connectionType == QLatin1String(
"PostgreSQL" ) )
179 uri =
"PG:dbname='" + database +
'\'';
181 if ( !host.isEmpty() )
183 uri += QStringLiteral(
" host='%1'" ).arg( host );
185 if ( !port.isEmpty() )
186 uri += QStringLiteral(
" port='%1'" ).arg( port );
189 if ( !username.isEmpty() )
191 uri += QStringLiteral(
" user='%1'" ).arg( username );
193 if ( !password.isEmpty() )
194 uri += QStringLiteral(
" password='%1'" ).arg( password );
200 if ( !( configId.isEmpty() ) )
202 if ( ! expandAuthConfig )
204 uri += QStringLiteral(
" authcfg='%1'" ).arg( configId );
208 QStringList connectionItems;
209 connectionItems << uri;
212 uri = connectionItems.join( QString() );
216 QgsDebugMsgLevel(
"Connection type is=" + connectionType +
" and uri=" + uri, 2 );
221QString
createProtocolURI(
const QString &type,
const QString &url,
const QString &configId,
const QString &username,
const QString &password,
bool expandAuthConfig )
224 if ( type == QLatin1String(
"HTTP/HTTPS/FTP" ) )
228 if ( !uri.startsWith(
"http://" ) && !uri.startsWith(
"https://" ) && !uri.startsWith(
"ftp://" ) )
230 uri.prepend( QStringLiteral(
"http://" ) );
232 uri.prepend( QStringLiteral(
"/vsicurl/" ) );
234 else if ( type == QLatin1String(
"AWS S3" ) )
237 uri.prepend( QStringLiteral(
"/vsis3/" ) );
239 else if ( type == QLatin1String(
"Google Cloud Storage" ) )
242 uri.prepend( QStringLiteral(
"/vsigs/" ) );
244 else if ( type == QLatin1String(
"Microsoft Azure Blob" ) )
247 uri.prepend( QStringLiteral(
"/vsiaz/" ) );
249 else if ( type == QLatin1String(
"Alibaba Cloud OSS" ) )
252 uri.prepend( QStringLiteral(
"/vsioss/" ) );
254 else if ( type == QLatin1String(
"OpenStack Swift Object Storage" ) )
257 uri.prepend( QStringLiteral(
"/vsiswift/" ) );
260 else if ( type.startsWith( QLatin1String(
"GeoJSON" ) ) )
264 else if ( type == QLatin1String(
"CouchDB" ) )
266 uri = QStringLiteral(
"couchdb:%1" ).arg( url );
268 else if ( type == QLatin1String(
"DODS/OPeNDAP" ) )
270 uri = QStringLiteral(
"DODS:%1" ).arg( url );
273 else if ( type.startsWith( QLatin1String(
"WFS3" ) ) )
275 uri = QStringLiteral(
"WFS3:%1" ).arg( url );
279 if ( ! configId.isEmpty() )
281 if ( expandAuthConfig )
283 QStringList connectionItems;
284 connectionItems << uri;
287 uri = connectionItems.join( QString() );
292 uri += QStringLiteral(
" authcfg='%1'" ).arg( configId );
295 else if ( !( username.isEmpty() || password.isEmpty( ) ) )
297 uri.replace( QLatin1String(
"://" ), QStringLiteral(
"://%1:%2@" ).arg( username, password ) );
QString createDatabaseURI(const QString &connectionType, const QString &host, const QString &database, QString port, const QString &configId, QString username, QString password, bool expandAuthConfig)
CreateDatabaseURI.
QString createProtocolURI(const QString &type, const QString &url, const QString &configId, const QString &username, const QString &password, bool expandAuthConfig)
CreateProtocolURI.