|
Lines 12-18
Link Here
|
| 12 |
package org.eclipse.mylar.core.net; |
12 |
package org.eclipse.mylar.core.net; |
| 13 |
|
13 |
|
| 14 |
import java.net.InetSocketAddress; |
14 |
import java.net.InetSocketAddress; |
|
|
15 |
import java.net.MalformedURLException; |
| 15 |
import java.net.Proxy; |
16 |
import java.net.Proxy; |
|
|
17 |
import java.net.URL; |
| 16 |
import java.net.Proxy.Type; |
18 |
import java.net.Proxy.Type; |
| 17 |
|
19 |
|
| 18 |
import org.apache.commons.httpclient.Credentials; |
20 |
import org.apache.commons.httpclient.Credentials; |
|
Lines 23-32
Link Here
|
| 23 |
import org.apache.commons.httpclient.params.HttpClientParams; |
25 |
import org.apache.commons.httpclient.params.HttpClientParams; |
| 24 |
import org.apache.commons.httpclient.protocol.Protocol; |
26 |
import org.apache.commons.httpclient.protocol.Protocol; |
| 25 |
import org.apache.commons.httpclient.protocol.ProtocolSocketFactory; |
27 |
import org.apache.commons.httpclient.protocol.ProtocolSocketFactory; |
|
|
28 |
import org.eclipse.jface.resource.ImageDescriptor; |
| 29 |
import org.eclipse.swt.SWTException; |
| 30 |
import org.eclipse.swt.graphics.Image; |
| 31 |
import org.eclipse.swt.graphics.ImageData; |
| 26 |
|
32 |
|
| 27 |
/** |
33 |
/** |
| 28 |
* @author Mik Kersten |
34 |
* @author Mik Kersten |
| 29 |
* @author Steffen Pingel |
35 |
* @author Steffen Pingel |
|
|
36 |
* @author Leo Dos Santos - getFaviconForUrl |
| 30 |
*/ |
37 |
*/ |
| 31 |
public class WebClientUtil { |
38 |
public class WebClientUtil { |
| 32 |
|
39 |
|
|
Lines 147-153
Link Here
|
| 147 |
.getInstance(), WebClientUtil.getPort(repositoryUrl)); |
154 |
.getInstance(), WebClientUtil.getPort(repositoryUrl)); |
| 148 |
client.getHostConfiguration().setHost(WebClientUtil.getDomain(repositoryUrl), |
155 |
client.getHostConfiguration().setHost(WebClientUtil.getDomain(repositoryUrl), |
| 149 |
WebClientUtil.getPort(repositoryUrl), acceptAllSsl); |
156 |
WebClientUtil.getPort(repositoryUrl), acceptAllSsl); |
| 150 |
// Protocol.registerProtocol("https", acceptAllSsl); |
157 |
Protocol.registerProtocol("https", acceptAllSsl); |
| 151 |
} else { |
158 |
} else { |
| 152 |
client.getHostConfiguration().setHost(WebClientUtil.getDomain(repositoryUrl), |
159 |
client.getHostConfiguration().setHost(WebClientUtil.getDomain(repositoryUrl), |
| 153 |
WebClientUtil.getPort(repositoryUrl)); |
160 |
WebClientUtil.getPort(repositoryUrl)); |
|
Lines 180-184
Link Here
|
| 180 |
} |
187 |
} |
| 181 |
return Proxy.NO_PROXY; |
188 |
return Proxy.NO_PROXY; |
| 182 |
} |
189 |
} |
|
|
190 |
|
| 191 |
/** |
| 192 |
* @param repositoryUrl The URL of the web site including protocol. |
| 193 |
* E.g. <code>http://foo.bar</code> or <code>https://foo.bar/baz</code> |
| 194 |
* @return a 16*16 favicon, or null if no favicon found |
| 195 |
* @throws MalformedURLException |
| 196 |
*/ |
| 197 |
public static Image getFaviconForUrl(String repositoryUrl) throws MalformedURLException { |
| 198 |
URL url = new URL(repositoryUrl); |
| 199 |
|
| 200 |
String host = url.getHost(); |
| 201 |
String protocol = url.getProtocol(); |
| 202 |
String favString = protocol + "://" + host + "/favicon.ico"; |
| 203 |
|
| 204 |
URL favUrl = new URL(favString); |
| 205 |
try { |
| 206 |
ImageDescriptor desc = ImageDescriptor.createFromURL(favUrl); |
| 207 |
if (desc.getImageData() != null) { |
| 208 |
if ((desc.getImageData().width != 16) && (desc.getImageData().height != 16)) { |
| 209 |
ImageData data = desc.getImageData().scaledTo(16, 16); |
| 210 |
return ImageDescriptor.createFromImageData(data).createImage(false); |
| 211 |
} |
| 212 |
} |
| 213 |
return ImageDescriptor.createFromURL(favUrl).createImage(false); |
| 214 |
} catch (SWTException e) { |
| 215 |
return null; |
| 216 |
} |
| 217 |
} |
| 183 |
|
218 |
|
| 184 |
} |
219 |
} |