~ubuntuone-control-tower/ubuntu-sso-client/stable-4-0

« back to all changes in this revision

Viewing changes to ubuntu_sso/utils/webclient/qtnetwork.py

  • Committer: Tarmac
  • Author(s): Manuel de la Pena, Rodney Dawes
  • Date: 2012-10-04 19:13:40 UTC
  • mfrom: (973.1.1 update-4-0)
  • Revision ID: tarmac-20121004191340-1afdbrqjgsqiwyfr
[Manuel de la Pena]

    - Set both application and nam proxy to work in all supported Qt versions. (LP: #1061528)

Show diffs side-by-side

added added

removed removed

Lines of Context:
104
104
        self.proxy_retry = False
105
105
        self.setup_proxy()
106
106
 
 
107
    def _set_proxy(self, proxy):
 
108
        """Set the proxy to be used."""
 
109
        QNetworkProxy.setApplicationProxy(proxy)
 
110
        # ensure that we work with the latest qt in ubuntu q
 
111
        self.nam.setProxy(proxy)
 
112
 
107
113
    def setup_proxy(self):
108
114
        """Setup the proxy settings if needed."""
109
115
        # QtNetwork knows how to use the system settings on both Win and Mac
112
118
            enabled = len(settings) > 0
113
119
            if enabled and WebClient.proxy_instance is None:
114
120
                proxy = build_proxy(settings)
115
 
                QNetworkProxy.setApplicationProxy(proxy)
 
121
                self._set_proxy(proxy)
116
122
                WebClient.proxy_instance = proxy
117
123
            elif enabled and WebClient.proxy_instance:
118
124
                logger.info("Proxy already in use.")
123
129
                logger.info("Querying OS for proxy.")
124
130
                query = QNetworkProxyQuery(QUrl(PROXY_REQUEST))
125
131
                proxies = QNetworkProxyFactory.systemProxyForQuery(query)
126
 
                QNetworkProxy.setApplicationProxy(proxies[0])
 
132
                self._set_proxy(proxies[0])
127
133
                WebClient.proxy_instance = proxies[0]
128
134
 
129
135
    def handle_proxy_auth(self, proxy, authenticator):
248
254
        """Setup this webclient to use the given proxy settings."""
249
255
        settings = {"https": https_settings}
250
256
        proxy = build_proxy(settings)
251
 
        QNetworkProxy.setApplicationProxy(proxy)
 
257
        self._set_proxy(proxy)
252
258
        WebClient.proxy_instance = proxy
253
259
 
254
260
    def shutdown(self):