165 include $(topsrcdir)/config/rules.mk |
165 include $(topsrcdir)/config/rules.mk |
166 diff --git a/toolkit/system/unixproxy/nsLibProxySettings.cpp b/toolkit/system/unixproxy/nsLibProxySettings.cpp |
166 diff --git a/toolkit/system/unixproxy/nsLibProxySettings.cpp b/toolkit/system/unixproxy/nsLibProxySettings.cpp |
167 new file mode 100644 |
167 new file mode 100644 |
168 --- /dev/null |
168 --- /dev/null |
169 +++ b/toolkit/system/unixproxy/nsLibProxySettings.cpp |
169 +++ b/toolkit/system/unixproxy/nsLibProxySettings.cpp |
170 @@ -0,0 +1,170 @@ |
170 @@ -0,0 +1,178 @@ |
171 +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ |
171 +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ |
172 +/* ***** BEGIN LICENSE BLOCK ***** |
172 +/* ***** BEGIN LICENSE BLOCK ***** |
173 + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 |
173 + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 |
174 + * |
174 + * |
175 + * The contents of this file are subject to the Mozilla Public License Version |
175 + * The contents of this file are subject to the Mozilla Public License Version |
271 + char **proxyArray = nsnull; |
270 + char **proxyArray = nsnull; |
272 + proxyArray = px_proxy_factory_get_proxies(mProxyFactory, (char*)(spec.get())); |
271 + proxyArray = px_proxy_factory_get_proxies(mProxyFactory, (char*)(spec.get())); |
273 + NS_ENSURE_TRUE(proxyArray, NS_ERROR_NOT_AVAILABLE); |
272 + NS_ENSURE_TRUE(proxyArray, NS_ERROR_NOT_AVAILABLE); |
274 + |
273 + |
275 + // Translate libproxy's output to PAC string as expected |
274 + // Translate libproxy's output to PAC string as expected |
276 + // libproxy's prefixes: http, proxy, socks, socks4, socks5, direct, unknown |
275 + // libproxy returns an array of proxies in the format: |
277 + // PAC format: "PROXY proxy1.foo.com:8080; PROXY proxy2.foo.com:8080; // DIRECT" |
276 + // <procotol>://[username:password@]proxy:port |
|
277 + // or |
|
278 + // direct:// |
|
279 + // |
|
280 + // PAC format: "PROXY proxy1.foo.com:8080; PROXY proxy2.foo.com:8080; DIRECT" |
278 + int c = 0; |
281 + int c = 0; |
279 + while (proxyArray[c] != NULL) { |
282 + while (proxyArray[c] != NULL) { |
280 + if (c != 0) { |
283 + if (!aResult.IsEmpty()) { |
281 + aResult.AppendLiteral("; "); |
284 + aResult.AppendLiteral("; "); |
282 + } |
285 + } |
283 + |
286 + |
284 + PRBool isScheme = PR_FALSE; |
287 + PRBool isScheme = PR_FALSE; |
285 + nsXPIDLCString schemeString; |
288 + nsXPIDLCString schemeString; |
286 + nsXPIDLCString hostPortString; |
289 + nsXPIDLCString hostPortString; |
287 + nsCOMPtr<nsIURI> proxyURI; |
290 + nsCOMPtr<nsIURI> proxyURI; |
288 + |
291 + |
289 + rv = ios->NewURI(nsDependentCString(proxyArray[c]), |
292 + rv = ios->NewURI(nsDependentCString(proxyArray[c]), |
290 + nsnull, |
293 + nsnull, |
291 + nsnull, |
294 + nsnull, |
292 + getter_AddRefs(proxyURI)); |
295 + getter_AddRefs(proxyURI)); |
293 + NS_ENSURE_SUCCESS(rv, rv); |
296 + if (NS_FAILED(rv)) { |
|
297 + c++; |
|
298 + continue; |
|
299 + } |
294 + |
300 + |
295 + proxyURI->GetScheme(schemeString); |
301 + proxyURI->GetScheme(schemeString); |
296 + if (NS_SUCCEEDED(proxyURI->SchemeIs("http", &isScheme)) && isScheme) { |
302 + if (NS_SUCCEEDED(proxyURI->SchemeIs("http", &isScheme)) && isScheme) { |
297 + schemeString.AssignLiteral("proxy"); |
303 + schemeString.AssignLiteral("proxy"); |
298 + } |
304 + } |