mirror of
https://github.com/qgis/QGIS.git
synced 2025-04-17 00:04:02 -04:00
QgsCredentials: fix sip bindings
dbmanager: QgsCredentials is in core (fixes #8345)
This commit is contained in:
parent
5d3223127d
commit
aa7c428775
@ -8,7 +8,7 @@ class QgsCredentials
|
|||||||
//! virtual destructor
|
//! virtual destructor
|
||||||
virtual ~QgsCredentials();
|
virtual ~QgsCredentials();
|
||||||
|
|
||||||
bool get( QString realm, QString &username, QString &password, QString message = QString::null );
|
bool get( QString realm, QString &username /In,Out/, QString &password /In,Out/, QString message = QString::null );
|
||||||
void put( QString realm, QString username, QString password );
|
void put( QString realm, QString username, QString password );
|
||||||
|
|
||||||
//! retrieves instance
|
//! retrieves instance
|
||||||
|
@ -34,6 +34,8 @@ except ImportError:
|
|||||||
|
|
||||||
from ..html_elems import HtmlParagraph, HtmlList, HtmlTable
|
from ..html_elems import HtmlParagraph, HtmlList, HtmlTable
|
||||||
|
|
||||||
|
from qgis.core import QgsCredentials
|
||||||
|
|
||||||
|
|
||||||
def classFactory():
|
def classFactory():
|
||||||
return PostGisDBPlugin
|
return PostGisDBPlugin
|
||||||
@ -98,19 +100,10 @@ class PostGisDBPlugin(DBPlugin):
|
|||||||
except ConnectionError, e:
|
except ConnectionError, e:
|
||||||
err = str(e)
|
err = str(e)
|
||||||
|
|
||||||
hasCredentialDlg = True
|
|
||||||
try:
|
|
||||||
from qgis.gui import QgsCredentials
|
|
||||||
except ImportError: # no credential dialog
|
|
||||||
hasCredentialDlg = False
|
|
||||||
|
|
||||||
# ask for valid credentials
|
# ask for valid credentials
|
||||||
max_attempts = 3
|
max_attempts = 3
|
||||||
for i in range(max_attempts):
|
for i in range(max_attempts):
|
||||||
if hasCredentialDlg:
|
(ok, username, password) = QgsCredentials.instance().get(uri.connectionInfo(), username, password, err)
|
||||||
(ok, username, password) = QgsCredentials.instance().get(uri.connectionInfo(), username, password, err)
|
|
||||||
else:
|
|
||||||
(password, ok) = QInputDialog.getText(parent, self.tr("Enter password"), self.tr('Enter password for connection "%s":') % conn_name, QLineEdit.Password)
|
|
||||||
|
|
||||||
if not ok:
|
if not ok:
|
||||||
return False
|
return False
|
||||||
@ -128,8 +121,8 @@ class PostGisDBPlugin(DBPlugin):
|
|||||||
err = str(e)
|
err = str(e)
|
||||||
continue
|
continue
|
||||||
|
|
||||||
if hasCredentialDlg:
|
QgsCredentials.instance().put(uri.connectionInfo(), username, password)
|
||||||
QgsCredentials.instance().put(uri.connectionInfo(), username, password)
|
|
||||||
return True
|
return True
|
||||||
|
|
||||||
return False
|
return False
|
||||||
|
Loading…
x
Reference in New Issue
Block a user