mirror of
https://github.com/qgis/QGIS.git
synced 2025-10-07 00:15:48 -04:00
[FEATURE][auth] Add support to Plugin Manager
This commit is contained in:
parent
487be231a4
commit
36e7026c0d
@ -427,6 +427,7 @@ class QgsPluginInstaller(QObject):
|
||||
reposName = reposName + "(2)"
|
||||
# add to settings
|
||||
settings.setValue(reposName + "/url", reposURL)
|
||||
settings.setValue(reposName + "/authcfg", dlg.editAuthCfg.text().strip())
|
||||
settings.setValue(reposName + "/enabled", bool(dlg.checkBoxEnabled.checkState()))
|
||||
# refresh lists and populate widgets
|
||||
plugins.removeRepository(reposName)
|
||||
@ -442,6 +443,7 @@ class QgsPluginInstaller(QObject):
|
||||
dlg = QgsPluginInstallerRepositoryDialog(iface.mainWindow())
|
||||
dlg.editName.setText(reposName)
|
||||
dlg.editURL.setText(repositories.all()[reposName]["url"])
|
||||
dlg.editAuthCfg.setText(repositories.all()[reposName]["authcfg"])
|
||||
dlg.editParams.setText(repositories.urlParams())
|
||||
dlg.checkBoxEnabled.setCheckState(checkState[repositories.all()[reposName]["enabled"]])
|
||||
if repositories.all()[reposName]["valid"]:
|
||||
@ -465,7 +467,10 @@ class QgsPluginInstaller(QObject):
|
||||
if newName in repositories.all() and newName != reposName:
|
||||
newName = newName + "(2)"
|
||||
settings.setValue(newName + "/url", dlg.editURL.text().strip())
|
||||
settings.setValue(newName + "/authcfg", dlg.editAuthCfg.text().strip())
|
||||
settings.setValue(newName + "/enabled", bool(dlg.checkBoxEnabled.checkState()))
|
||||
if dlg.editAuthCfg.text().strip() != repositories.all()[reposName]["authcfg"]:
|
||||
repositories.all()[reposName]["authcfg"] = dlg.editAuthCfg.text().strip()
|
||||
if dlg.editURL.text().strip() == repositories.all()[reposName]["url"] and dlg.checkBoxEnabled.checkState() == checkState[repositories.all()[reposName]["enabled"]]:
|
||||
repositories.rename(reposName, newName)
|
||||
self.exportRepositoriesToManager()
|
||||
|
@ -31,7 +31,8 @@ import os
|
||||
import codecs
|
||||
import ConfigParser
|
||||
import qgis.utils
|
||||
from qgis.core import QGis, QgsNetworkAccessManager
|
||||
from qgis.core import QGis, QgsNetworkAccessManager, QgsAuthManager
|
||||
from qgis.gui import QgsMessageBar
|
||||
from qgis.utils import iface, plugin_paths
|
||||
from version_compare import compareVersions, normalizeVersion, isCompatible
|
||||
|
||||
@ -320,6 +321,7 @@ class Repositories(QObject):
|
||||
for key in settings.childGroups():
|
||||
self.mRepositories[key] = {}
|
||||
self.mRepositories[key]["url"] = settings.value(key + "/url", "", type=unicode)
|
||||
self.mRepositories[key]["authcfg"] = settings.value(key + "/authcfg", "", type=unicode)
|
||||
self.mRepositories[key]["enabled"] = settings.value(key + "/enabled", True, type=bool)
|
||||
self.mRepositories[key]["valid"] = settings.value(key + "/valid", True, type=bool)
|
||||
self.mRepositories[key]["Relay"] = Relay(key)
|
||||
@ -337,6 +339,17 @@ class Repositories(QObject):
|
||||
#url.addQueryItem('qgis', '.'.join([str(int(s)) for s in [v[0], v[1:3]]]) ) # don't include the bugfix version!
|
||||
|
||||
self.mRepositories[key]["QRequest"] = QNetworkRequest(url)
|
||||
authcfg = self.mRepositories[key]["authcfg"]
|
||||
if authcfg and isinstance(authcfg, basestring):
|
||||
if not QgsAuthManager.instance().updateNetworkRequest(
|
||||
self.mRepositories[key]["QRequest"], authcfg.strip()):
|
||||
msg = QCoreApplication.translate(
|
||||
"QgsPluginInstaller",
|
||||
"Update of network request with authentication "
|
||||
"credentials FAILED for configuration '{0}'").format(authcfg)
|
||||
iface.pluginManagerInterface().pushMessage(msg, QgsMessageBar.WARNING)
|
||||
self.mRepositories[key]["QRequest"] = None
|
||||
return
|
||||
self.mRepositories[key]["QRequest"].setAttribute(QNetworkRequest.User, key)
|
||||
self.mRepositories[key]["xmlData"] = QgsNetworkAccessManager.instance().get(self.mRepositories[key]["QRequest"])
|
||||
self.mRepositories[key]["xmlData"].setProperty('reposName', key)
|
||||
|
@ -7,8 +7,8 @@
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>522</width>
|
||||
<height>185</height>
|
||||
<width>496</width>
|
||||
<height>289</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="sizePolicy">
|
||||
@ -27,7 +27,89 @@
|
||||
<string/>
|
||||
</property>
|
||||
<layout class="QGridLayout">
|
||||
<item row="5" column="1" colspan="2">
|
||||
<item row="5" column="2">
|
||||
<spacer>
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeType">
|
||||
<enum>QSizePolicy::Fixed</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>351</width>
|
||||
<height>23</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="label_2">
|
||||
<property name="text">
|
||||
<string>URL</string>
|
||||
</property>
|
||||
<property name="buddy">
|
||||
<cstring>editURL</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="5" column="0">
|
||||
<widget class="QLabel" name="label_4">
|
||||
<property name="text">
|
||||
<string>Enabled</string>
|
||||
</property>
|
||||
<property name="buddy">
|
||||
<cstring>checkBoxEnabled</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1" colspan="2">
|
||||
<widget class="QLineEdit" name="editName">
|
||||
<property name="toolTip">
|
||||
<string>Enter a name for the repository</string>
|
||||
</property>
|
||||
<property name="whatsThis">
|
||||
<string>Enter a name for the repository</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="1" colspan="2">
|
||||
<widget class="QLineEdit" name="editParams">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>?qgis=</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="9" column="0" colspan="3">
|
||||
<widget class="QDialogButtonBox" name="buttonBox">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="standardButtons">
|
||||
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Fixed" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Name</string>
|
||||
</property>
|
||||
<property name="buddy">
|
||||
<cstring>editName</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="7" column="1" colspan="2">
|
||||
<widget class="QLabel" name="labelInfo">
|
||||
<property name="enabled">
|
||||
<bool>true</bool>
|
||||
@ -89,59 +171,17 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="7" column="0" colspan="3">
|
||||
<widget class="QDialogButtonBox" name="buttonBox">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="standardButtons">
|
||||
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Fixed" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<item row="3" column="0">
|
||||
<widget class="QLabel" name="label_3">
|
||||
<property name="text">
|
||||
<string>Name</string>
|
||||
<string>Parameters</string>
|
||||
</property>
|
||||
<property name="buddy">
|
||||
<cstring>editName</cstring>
|
||||
<cstring>editParams</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="1" colspan="2">
|
||||
<spacer name="verticalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>40</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="1" column="1" colspan="2">
|
||||
<widget class="QLineEdit" name="editURL">
|
||||
<property name="toolTip">
|
||||
<string>Enter the repository URL, beginning with "http://"</string>
|
||||
</property>
|
||||
<property name="whatsThis">
|
||||
<string>Enter the repository URL, beginning with "http://"</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="1">
|
||||
<item row="5" column="1">
|
||||
<widget class="QCheckBox" name="checkBoxEnabled">
|
||||
<property name="enabled">
|
||||
<bool>true</bool>
|
||||
@ -166,72 +206,79 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QLabel" name="label_3">
|
||||
<property name="text">
|
||||
<string>Parameters</string>
|
||||
</property>
|
||||
<property name="buddy">
|
||||
<cstring>editParams</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1" colspan="2">
|
||||
<widget class="QLineEdit" name="editParams">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>?qgis=</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1" colspan="2">
|
||||
<widget class="QLineEdit" name="editName">
|
||||
<item row="1" column="1" colspan="2">
|
||||
<widget class="QLineEdit" name="editURL">
|
||||
<property name="toolTip">
|
||||
<string>Enter a name for the repository</string>
|
||||
<string>Enter the repository URL, beginning with "http://"</string>
|
||||
</property>
|
||||
<property name="whatsThis">
|
||||
<string>Enter a name for the repository</string>
|
||||
<string>Enter the repository URL, beginning with "http://"</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="label_2">
|
||||
<property name="text">
|
||||
<string>URL</string>
|
||||
</property>
|
||||
<property name="buddy">
|
||||
<cstring>editURL</cstring>
|
||||
<string/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="2">
|
||||
<spacer>
|
||||
<item row="6" column="1" colspan="2">
|
||||
<spacer name="verticalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeType">
|
||||
<enum>QSizePolicy::Fixed</enum>
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>351</width>
|
||||
<height>23</height>
|
||||
<width>20</width>
|
||||
<height>40</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="3" column="0">
|
||||
<widget class="QLabel" name="label_4">
|
||||
<item row="4" column="0">
|
||||
<widget class="QLabel" name="label_5">
|
||||
<property name="text">
|
||||
<string>Enabled</string>
|
||||
</property>
|
||||
<property name="buddy">
|
||||
<cstring>checkBoxEnabled</cstring>
|
||||
<string>Authentication</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="1" colspan="2">
|
||||
<layout class="QHBoxLayout" name="layoutAuthCfg">
|
||||
<property name="spacing">
|
||||
<number>6</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QLineEdit" name="editAuthCfg">
|
||||
<property name="readOnly">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QToolButton" name="btnClearAuthCfg">
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>16777215</width>
|
||||
<height>22</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Clear</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QToolButton" name="btnEditAuthCfg">
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>16777215</width>
|
||||
<height>22</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Edit</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<tabstops>
|
||||
|
@ -24,7 +24,9 @@
|
||||
***************************************************************************/
|
||||
"""
|
||||
|
||||
from PyQt4.QtGui import QDialog, QDialogButtonBox
|
||||
from qgis.gui import QgsAuthConfigSelect
|
||||
from PyQt4.QtGui import QDialog, QDialogButtonBox, QVBoxLayout
|
||||
from PyQt4.QtCore import Qt
|
||||
|
||||
from ui_qgsplugininstallerrepositorybase import Ui_QgsPluginInstallerRepositoryDetailsDialogBase
|
||||
|
||||
@ -38,9 +40,28 @@ class QgsPluginInstallerRepositoryDialog(QDialog, Ui_QgsPluginInstallerRepositor
|
||||
self.editURL.setText("http://")
|
||||
self.editName.textChanged.connect(self.textChanged)
|
||||
self.editURL.textChanged.connect(self.textChanged)
|
||||
self.btnClearAuthCfg.clicked.connect(self.editAuthCfg.clear)
|
||||
self.btnEditAuthCfg.clicked.connect(self.editAuthCfgId)
|
||||
self.textChanged(None)
|
||||
|
||||
# ----------------------------------------- #
|
||||
def textChanged(self, string):
|
||||
enable = (len(self.editName.text()) > 0 and len(self.editURL.text()) > 0)
|
||||
self.buttonBox.button(QDialogButtonBox.Ok).setEnabled(enable)
|
||||
|
||||
def editAuthCfgId(self):
|
||||
dlg = QDialog(self)
|
||||
dlg.setWindowModality(Qt.WindowModal)
|
||||
layout = QVBoxLayout()
|
||||
selector = QgsAuthConfigSelect(self)
|
||||
if self.editAuthCfg.text():
|
||||
selector.setConfigId(self.editAuthCfg.text())
|
||||
layout.addWidget(selector)
|
||||
buttonBox = QDialogButtonBox(QDialogButtonBox.Ok | QDialogButtonBox.Close)
|
||||
buttonBox.accepted.connect(dlg.accept)
|
||||
buttonBox.rejected.connect(dlg.reject)
|
||||
layout.addWidget(buttonBox)
|
||||
dlg.setLayout(layout)
|
||||
if dlg.exec_():
|
||||
self.editAuthCfg.setText(selector.configId())
|
||||
del dlg
|
||||
|
Loading…
x
Reference in New Issue
Block a user