44 +#endif |
44 +#endif |
45 + |
45 + |
46 diff --git a/configure.in b/configure.in |
46 diff --git a/configure.in b/configure.in |
47 --- a/configure.in |
47 --- a/configure.in |
48 +++ b/configure.in |
48 +++ b/configure.in |
49 @@ -5536,16 +5536,39 @@ then |
49 @@ -5535,16 +5535,39 @@ then |
50 fi |
50 fi |
51 |
51 |
52 AC_SUBST(MOZ_ENABLE_GCONF) |
52 AC_SUBST(MOZ_ENABLE_GCONF) |
53 AC_SUBST(MOZ_GCONF_CFLAGS) |
53 AC_SUBST(MOZ_GCONF_CFLAGS) |
54 AC_SUBST(MOZ_GCONF_LIBS) |
54 AC_SUBST(MOZ_GCONF_LIBS) |
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,173 @@ |
170 @@ -0,0 +1,170 @@ |
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 |
184 + * |
184 + * |
185 + * The Original Code is Mozilla libproxy integration code. |
185 + * The Original Code is Mozilla libproxy integration code. |
186 + * |
186 + * |
187 + * The Initial Developer of the Original Code is |
187 + * The Initial Developer of the Original Code is |
188 + * Wolfgang Rosenauer <wr@rosenauer.org>. |
188 + * Wolfgang Rosenauer <wr@rosenauer.org>. |
189 + * Portions created by the Initial Developer are Copyright (C) 2009 |
189 + * Portions created by the Initial Developer are Copyright (C) 2010 |
190 + * the Initial Developer. All Rights Reserved. |
190 + * the Initial Developer. All Rights Reserved. |
191 + * |
191 + * |
192 + * Contributor(s): |
192 + * Contributor(s): |
193 + * |
193 + * |
194 + * Alternatively, the contents of this file may be used under the terms of |
194 + * Alternatively, the contents of this file may be used under the terms of |
258 + nsresult rv; |
257 + nsresult rv; |
259 + |
258 + |
260 + if (!mProxyFactory) { |
259 + if (!mProxyFactory) { |
261 + mProxyFactory = px_proxy_factory_new(); |
260 + mProxyFactory = px_proxy_factory_new(); |
262 + } |
261 + } |
263 + NS_ENSURE_TRUE(mProxyFactory, NS_ERROR_OUT_OF_MEMORY); |
262 + NS_ENSURE_TRUE(mProxyFactory, NS_ERROR_NOT_AVAILABLE); |
264 + |
263 + |
265 + if (!mIOService) { |
264 + nsCOMPtr<nsIIOService> ios = do_GetIOService(&rv); |
266 + mIOService = do_GetIOService(); |
265 + NS_ENSURE_SUCCESS(rv, rv); |
267 + } |
|
268 + NS_ENSURE_TRUE(mIOService, NS_ERROR_FAILURE); |
|
269 + |
266 + |
270 + nsCAutoString spec; |
267 + nsCAutoString spec; |
271 + rv = aURI->GetSpec(spec); |
268 + rv = aURI->GetSpec(spec); |
272 + NS_ENSURE_SUCCESS(rv, rv); |
269 + NS_ENSURE_SUCCESS(rv, rv); |
273 + |
270 + |
274 + char **proxyArray = nsnull; |
271 + char **proxyArray = nsnull; |
275 + proxyArray = px_proxy_factory_get_proxies(mProxyFactory, (char*)(spec.get())); |
272 + proxyArray = px_proxy_factory_get_proxies(mProxyFactory, (char*)(spec.get())); |
276 + NS_ENSURE_TRUE(proxyArray, NS_ERROR_FAILURE); |
273 + NS_ENSURE_TRUE(proxyArray, NS_ERROR_NOT_AVAILABLE); |
277 + |
274 + |
278 + // PAC string accepts |
275 + // Translate libproxy's output to PAC string as expected |
279 + // http, proxy, socks, socks4, socks5, direct, unknown |
276 + // libproxy's prefixes: http, proxy, socks, socks4, socks5, direct, unknown |
280 + // example: "PROXY proxy1.foo.com:8080; PROXY proxy2.foo.com:8080; DIRECT" |
277 + // PAC format: "PROXY proxy1.foo.com:8080; PROXY proxy2.foo.com:8080; // DIRECT" |
281 + int c = 0; |
278 + int c = 0; |
282 + while (proxyArray[c] != NULL) { |
279 + while (proxyArray[c] != NULL) { |
283 + if (c != 0) { |
280 + if (c != 0) { |
284 + aResult.AppendLiteral("; "); |
281 + aResult.AppendLiteral("; "); |
285 + } |
282 + } |
287 + PRBool isScheme = PR_FALSE; |
284 + PRBool isScheme = PR_FALSE; |
288 + nsXPIDLCString schemeString; |
285 + nsXPIDLCString schemeString; |
289 + nsXPIDLCString hostPortString; |
286 + nsXPIDLCString hostPortString; |
290 + nsCOMPtr<nsIURI> proxyURI; |
287 + nsCOMPtr<nsIURI> proxyURI; |
291 + |
288 + |
292 + rv = mIOService->NewURI(nsDependentCString(proxyArray[c]), |
289 + rv = ios->NewURI(nsDependentCString(proxyArray[c]), |
293 + nsnull, |
290 + nsnull, |
294 + nsnull, |
291 + nsnull, |
295 + getter_AddRefs(proxyURI)); |
292 + getter_AddRefs(proxyURI)); |
296 + NS_ENSURE_SUCCESS(rv, rv); |
293 + NS_ENSURE_SUCCESS(rv, rv); |
297 + |
294 + |
298 + proxyURI->GetScheme(schemeString); |
295 + proxyURI->GetScheme(schemeString); |
299 + if (NS_SUCCEEDED(proxyURI->SchemeIs("http", &isScheme)) && isScheme) { |
296 + if (NS_SUCCEEDED(proxyURI->SchemeIs("http", &isScheme)) && isScheme) { |
300 + schemeString.AssignLiteral("proxy"); |
297 + schemeString.AssignLiteral("proxy"); |