Ejemplo n.º 1
0
    def __init__(self, *args):
        QWebView.__init__(self, *args)
        self.gui = None
        self.tags = ''
        self.create_browser = None

        self._page = NPWebPage()
        self.setPage(self._page)
        self.cookie_jar = QNetworkCookieJar()
        self.page().networkAccessManager().setCookieJar(self.cookie_jar)

        http_proxy = get_proxies().get('http', None)
        if http_proxy:
            proxy_parts = urlparse(http_proxy)
            proxy = QNetworkProxy()
            proxy.setType(QNetworkProxy.HttpProxy)
            if proxy_parts.username:
                proxy.setUser(proxy_parts.username)
            if proxy_parts.password:
                proxy.setPassword(proxy_parts.password)
            if proxy_parts.hostname:
                proxy.setHostName(proxy_parts.hostname)
            if proxy_parts.port:
                proxy.setPort(proxy_parts.port)
            self.page().networkAccessManager().setProxy(proxy)

        self.page().setForwardUnsupportedContent(True)
        self.page().unsupportedContent.connect(self.start_download)
        self.page().downloadRequested.connect(self.start_download)
        self.page().networkAccessManager().sslErrors.connect(self.ignore_ssl_errors)
Ejemplo n.º 2
0
    def __init__(self, log):
        QNetworkProxyFactory.__init__(self)
        proxies = get_proxies()
        self.proxies = {}
        for scheme, proxy_string in proxies.iteritems():
            scheme = scheme.lower()
            info = get_proxy_info(scheme, proxy_string)
            if info is None:
                continue
            hn, port = info['hostname'], info['port']
            if not hn or not port:
                continue
            log.debug('JSBrowser using proxy:', pprint.pformat(info))
            pt = {
                'socks5': QNetworkProxy.Socks5Proxy
            }.get(scheme, QNetworkProxy.HttpProxy)
            proxy = QNetworkProxy(pt, hn, port)
            un, pw = info['username'], info['password']
            if un:
                proxy.setUser(un)
            if pw:
                proxy.setPassword(pw)
            self.proxies[scheme] = proxy

        self.default_proxy = QNetworkProxy(QNetworkProxy.DefaultProxy)
Ejemplo n.º 3
0
    def loadSettings(self):
        settings = Settings()
        settings.beginGroup('Language')
        # TODO:
        #langs = settings.value('acceptLanguage', AcceptLanguage.defaultLanguage(), type=[])
        settings.endGroup()
        # TODO:
        #gVar.app.webProfile().setHttpAcceptLanguage(AcceptLanguage.generateHeader(langs))

        proxy = QNetworkProxy()
        settings.beginGroup('Web-Proxy')
        proxyType = settings.value('ProxyType', 2)
        proxy.setHostName(settings.value('HostName', ''))
        proxy.setPort(settings.value('Port', 8080))
        proxy.setUser(settings.value('Username', ''))
        proxy.setPassword(settings.value('Password', ''))
        settings.endGroup()

        if proxyType == 0:
            proxy.setType(QNetworkProxy.NoProxy)
        elif proxyType == 3:
            proxy.setType(QNetworkProxy.HttpProxy)
        elif proxyType == 4:
            proxy.setType(QNetworkProxy.Socks5Proxy)

        if proxyType == 2:
            QNetworkProxy.setApplicationProxy(QNetworkProxy())
            QNetworkProxyFactory.setUseSystemConfiguration(True)
        else:
            QNetworkProxy.setApplicationProxy(proxy)
            QNetworkProxyFactory.setUseSystemConfiguration(False)

        self._urlInterceptor.loadSettings()
Ejemplo n.º 4
0
    def __init__(self, log):
        QNetworkProxyFactory.__init__(self)
        proxies = get_proxies()
        self.proxies = {}
        for scheme, proxy_string in proxies.iteritems():
            scheme = scheme.lower()
            info = get_proxy_info(scheme, proxy_string)
            if info is None:
                continue
            hn, port = info['hostname'], info['port']
            if not hn or not port:
                continue
            log.debug('JSBrowser using proxy:', pprint.pformat(info))
            pt = {'socks5':QNetworkProxy.Socks5Proxy}.get(scheme,
                    QNetworkProxy.HttpProxy)
            proxy = QNetworkProxy(pt, hn, port)
            un, pw = info['username'], info['password']
            if un:
                proxy.setUser(un)
            if pw:
                proxy.setPassword(pw)
            self.proxies[scheme] = proxy

        self.default_proxy = QNetworkProxy(QNetworkProxy.DefaultProxy)