ugly workaround for ssl on windows

This commit is contained in:
Jeena Paradies 2013-04-03 00:32:43 +02:00
parent ce9900559d
commit 9019c95f75
3 changed files with 22 additions and 8 deletions

View file

@ -10,9 +10,9 @@ import os
import array
class Helper:
@classmethod
def get_resource_path(cls):
return os.path.dirname(__file__)
@classmethod
def get_resource_path(cls):
return os.path.dirname(sys.argv[0])
class WebPage(QtWebKit.QWebPage):
def __init__(self, parent=0, app=None):
@ -43,6 +43,8 @@ class WebViewCreator(QtWebKit.QWebView):
self.customContextMenuRequested.connect(self.context_menu_requested)
self.actions = []
self.page().networkAccessManager().sslErrors.connect(lambda reply, errors: self.handleSslErrors(reply, errors))
def copy_link():
self.page().triggerAction(QtWebKit.QWebPage.CopyLinkToClipboard)
self.action_copy_link = QtGui.QAction('Copy Lin&k', self, triggered=copy_link)
@ -85,7 +87,10 @@ class WebViewCreator(QtWebKit.QWebView):
def load_finished(self, ok, callback=None):
frame = self.page().mainFrame()
if self.is_local:
frame.evaluateJavaScript("var OS_TYPE = 'linux';")
os_type = "linux"
if os.name == "nt":
os_type = "windows"
frame.evaluateJavaScript("var OS_TYPE = '" + os_type + "';")
js_plugin_path = os.path.expanduser('~/.bungloo/Plugin.js')
if os.access(js_plugin_path, os.R_OK):
@ -100,6 +105,11 @@ class WebViewCreator(QtWebKit.QWebView):
if callback:
callback(ok)
def handleSslErrors(self, reply, errors):
if os.name == "nt": # ignore SSL errors on Windows (yes a uggly workaround, don't know how to fix it yet)
reply.ignoreSslErrors()
pass
class NetworkAccessManager(QNetworkAccessManager):