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