parent
676313e7ae
commit
cafb487ac9
@ -105,13 +105,15 @@ class NetworkManager(QNetworkAccessManager):
|
|||||||
self.setCache(cache)
|
self.setCache(cache)
|
||||||
cache.setParent(app)
|
cache.setParent(app)
|
||||||
|
|
||||||
def _ask(self, win_id, text, mode):
|
def _ask(self, win_id, text, mode, owners=()):
|
||||||
"""Ask a blocking question in the statusbar.
|
"""Ask a blocking question in the statusbar.
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
win_id: The ID of the window which is calling this function.
|
win_id: The ID of the window which is calling this function.
|
||||||
text: The text to display to the user.
|
text: The text to display to the user.
|
||||||
mode: A PromptMode.
|
mode: A PromptMode.
|
||||||
|
owners: An iterable of objects which will abort the question if
|
||||||
|
destroyed.
|
||||||
|
|
||||||
Return:
|
Return:
|
||||||
The answer the user gave or None if the prompt was cancelled.
|
The answer the user gave or None if the prompt was cancelled.
|
||||||
@ -120,6 +122,8 @@ class NetworkManager(QNetworkAccessManager):
|
|||||||
q.text = text
|
q.text = text
|
||||||
q.mode = mode
|
q.mode = mode
|
||||||
self.shutting_down.connect(q.abort)
|
self.shutting_down.connect(q.abort)
|
||||||
|
for owner in owners:
|
||||||
|
owner.destroyed.connect(q.abort)
|
||||||
bridge = objreg.get('message-bridge', scope='window', window=win_id)
|
bridge = objreg.get('message-bridge', scope='window', window=win_id)
|
||||||
bridge.ask(q, blocking=True)
|
bridge.ask(q, blocking=True)
|
||||||
q.deleteLater()
|
q.deleteLater()
|
||||||
@ -158,7 +162,8 @@ class NetworkManager(QNetworkAccessManager):
|
|||||||
err_string = '\n'.join('- ' + err.errorString() for err in errors)
|
err_string = '\n'.join('- ' + err.errorString() for err in errors)
|
||||||
answer = self._ask(self._win_id,
|
answer = self._ask(self._win_id,
|
||||||
'SSL errors - continue?\n{}'.format(err_string),
|
'SSL errors - continue?\n{}'.format(err_string),
|
||||||
mode=usertypes.PromptMode.yesno)
|
mode=usertypes.PromptMode.yesno,
|
||||||
|
owners=(reply,))
|
||||||
if answer:
|
if answer:
|
||||||
reply.ignoreSslErrors()
|
reply.ignoreSslErrors()
|
||||||
elif ssl_strict:
|
elif ssl_strict:
|
||||||
@ -172,18 +177,20 @@ class NetworkManager(QNetworkAccessManager):
|
|||||||
reply.ignoreSslErrors()
|
reply.ignoreSslErrors()
|
||||||
|
|
||||||
@pyqtSlot('QNetworkReply', 'QAuthenticator')
|
@pyqtSlot('QNetworkReply', 'QAuthenticator')
|
||||||
def on_authentication_required(self, _reply, authenticator):
|
def on_authentication_required(self, reply, authenticator):
|
||||||
"""Called when a website needs authentication."""
|
"""Called when a website needs authentication."""
|
||||||
answer = self._ask(self._win_id,
|
answer = self._ask(self._win_id,
|
||||||
"Username ({}):".format(authenticator.realm()),
|
"Username ({}):".format(authenticator.realm()),
|
||||||
mode=usertypes.PromptMode.user_pwd)
|
mode=usertypes.PromptMode.user_pwd,
|
||||||
|
owners=(reply, authenticator))
|
||||||
self._fill_authenticator(authenticator, answer)
|
self._fill_authenticator(authenticator, answer)
|
||||||
|
|
||||||
@pyqtSlot('QNetworkProxy', 'QAuthenticator')
|
@pyqtSlot('QNetworkProxy', 'QAuthenticator')
|
||||||
def on_proxy_authentication_required(self, _proxy, authenticator):
|
def on_proxy_authentication_required(self, proxy, authenticator):
|
||||||
"""Called when a proxy needs authentication."""
|
"""Called when a proxy needs authentication."""
|
||||||
answer = self._ask(self._win_id, "Proxy username ({}):".format(
|
answer = self._ask(self._win_id, "Proxy username ({}):".format(
|
||||||
authenticator.realm()), mode=usertypes.PromptMode.user_pwd)
|
authenticator.realm()), mode=usertypes.PromptMode.user_pwd,
|
||||||
|
owners=(proxy, authenticator))
|
||||||
self._fill_authenticator(authenticator, answer)
|
self._fill_authenticator(authenticator, answer)
|
||||||
|
|
||||||
@config.change_filter('general', 'private-browsing')
|
@config.change_filter('general', 'private-browsing')
|
||||||
|
Loading…
Reference in New Issue
Block a user