Bug 566638 - Make linux proxy support work for all archs

- add new o.e.core.net.linux fragment that is implemented using
  JNA and can support multiple architectures
- make o.e.core.net.linux.x86_64 an empty fragment that requires
  new o.e.core.net.linux
- remove UnixProxyProvider as it is no longer used

Change-Id: I612371fa1d664f2b312eefb1554d599ff583d44b
Signed-off-by: Jeff Johnston <jjohnstn@redhat.com>
Reviewed-on: https://git.eclipse.org/r/c/platform/eclipse.platform.team/+/175195
Tested-by: Platform Bot <platform-bot@eclipse.org>
Reviewed-by: Alexander Kurtakov <akurtako@redhat.com>
diff --git a/bundles/org.eclipse.core.net.linux.x86_64/.classpath b/bundles/org.eclipse.core.net.linux.x86_64/.classpath
index 01836c4..2a66455 100644
--- a/bundles/org.eclipse.core.net.linux.x86_64/.classpath
+++ b/bundles/org.eclipse.core.net.linux.x86_64/.classpath
@@ -1,7 +1,10 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <classpath>
-	<classpathentry kind="src" path="src"/>
 	<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
-	<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/>
+	<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8">
+		<attributes>
+			<attribute name="module" value="true"/>
+		</attributes>
+	</classpathentry>
 	<classpathentry kind="output" path="bin"/>
 </classpath>
diff --git a/bundles/org.eclipse.core.net.linux.x86_64/META-INF/MANIFEST.MF b/bundles/org.eclipse.core.net.linux.x86_64/META-INF/MANIFEST.MF
index 6cd2dc6..c213d60 100644
--- a/bundles/org.eclipse.core.net.linux.x86_64/META-INF/MANIFEST.MF
+++ b/bundles/org.eclipse.core.net.linux.x86_64/META-INF/MANIFEST.MF
@@ -4,7 +4,7 @@
 Bundle-Vendor: %providerName
 Bundle-Localization: fragment
 Bundle-SymbolicName: org.eclipse.core.net.linux.x86_64;singleton:=true
-Bundle-Version: 1.2.400.qualifier
+Bundle-Version: 1.2.500.qualifier
 Fragment-Host: org.eclipse.core.net;bundle-version="1.1.0"
 Eclipse-PlatformFilter: (& (osgi.os=linux) (osgi.arch=x86_64))
 Bundle-RequiredExecutionEnvironment: JavaSE-1.8
diff --git a/bundles/org.eclipse.core.net.linux.x86_64/META-INF/p2.inf b/bundles/org.eclipse.core.net.linux.x86_64/META-INF/p2.inf
new file mode 100644
index 0000000..b1c1746
--- /dev/null
+++ b/bundles/org.eclipse.core.net.linux.x86_64/META-INF/p2.inf
@@ -0,0 +1 @@
+requires.0.namespace=org.eclipse.core.net.linux
diff --git a/bundles/org.eclipse.core.net.linux.x86_64/build.properties b/bundles/org.eclipse.core.net.linux.x86_64/build.properties
index 4a611fc..18f77db 100644
--- a/bundles/org.eclipse.core.net.linux.x86_64/build.properties
+++ b/bundles/org.eclipse.core.net.linux.x86_64/build.properties
@@ -1,5 +1,5 @@
 ###############################################################################
-# Copyright (c) 2008, 2009 IBM Corporation and others.
+# Copyright (c) 2008, 2021 IBM Corporation and others.
 #
 # This program and the accompanying materials
 # are made available under the terms of the Eclipse Public License 2.0
@@ -14,7 +14,5 @@
 bin.includes = fragment.properties,\
                .,\
                META-INF/,\
-               about.html,\
-               libgnomeproxy-1.0.0.so
+               about.html
 src.includes = about.html
-source.. = src/
diff --git a/bundles/org.eclipse.core.net.linux.x86_64/libgnomeproxy-1.0.0.so b/bundles/org.eclipse.core.net.linux.x86_64/libgnomeproxy-1.0.0.so
deleted file mode 100644
index ab71687..0000000
--- a/bundles/org.eclipse.core.net.linux.x86_64/libgnomeproxy-1.0.0.so
+++ /dev/null
Binary files differ
diff --git a/bundles/org.eclipse.core.net.linux.x86_64/pom.xml b/bundles/org.eclipse.core.net.linux.x86_64/pom.xml
index d46b1ab..5ad38b6 100644
--- a/bundles/org.eclipse.core.net.linux.x86_64/pom.xml
+++ b/bundles/org.eclipse.core.net.linux.x86_64/pom.xml
@@ -1,6 +1,6 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <!--
-  Copyright (c) 2012, 2015 Eclipse Foundation and others.
+  Copyright (c) 2012, 2021 Eclipse Foundation and others.
   All rights reserved. This program and the accompanying materials
   are made available under the terms of the Eclipse Distribution License v1.0
   which accompanies this distribution, and is available at
@@ -19,63 +19,11 @@
   </parent>
   <groupId>org.eclipse.core</groupId>
   <artifactId>org.eclipse.core.net.linux.x86_64</artifactId>
-  <version>1.2.400-SNAPSHOT</version>
+  <version>1.2.500-SNAPSHOT</version>
   <packaging>eclipse-plugin</packaging>
 
-  <build>
-    <plugins>
-      <plugin>
-        <groupId>org.eclipse.tycho</groupId>
-        <artifactId>target-platform-configuration</artifactId>
-        <configuration>
-          <environments>
-            <environment>
-              <os>linux</os>
-              <ws>gtk</ws>
-              <arch>x86_64</arch>
-            </environment>
-          </environments>
-        </configuration>
-      </plugin>
-    </plugins>
-  </build>
+  <properties>
+    <skipAPIAnalysis>true</skipAPIAnalysis>
+  </properties>
 
-  <profiles>
-    <profile>
-      <id>build-natives</id>
-      <activation>
-        <property>
-          <!-- This has to be hardcoded. Profiles are not allowed to use pom defined properties :-( -->
-          <name>native</name>
-          <value>gtk.linux.x86_64</value>
-        </property>
-      </activation>
-      <build>
-        <plugins>
-          <plugin>
-            <artifactId>maven-antrun-plugin</artifactId>
-            <executions>
-              <execution>
-                <id>natives</id>
-                <phase>process-resources</phase>
-                <configuration>
-                  <target>
-                    <exec executable="make" newenvironment="false" dir="../org.eclipse.core.net/natives/unix/linux/"/>
-                    <copy todir=".">
-                      <fileset dir="../org.eclipse.core.net/natives/unix/linux/">
-                        <include name="libgnomeproxy-*.so"/>
-                      </fileset>
-                    </copy>
-                  </target>
-                </configuration>
-                <goals>
-                  <goal>run</goal>
-                </goals>
-              </execution>
-            </executions>
-          </plugin>
-        </plugins>
-      </build>
-    </profile>
-  </profiles>
 </project>
diff --git a/bundles/org.eclipse.core.net.linux.x86_64/src/org/eclipse/core/net/ProxyProvider.java b/bundles/org.eclipse.core.net.linux.x86_64/src/org/eclipse/core/net/ProxyProvider.java
deleted file mode 100644
index f2f9a4b..0000000
--- a/bundles/org.eclipse.core.net.linux.x86_64/src/org/eclipse/core/net/ProxyProvider.java
+++ /dev/null
@@ -1,19 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008, 2009 Oakland Software Incorporated and others
- *
- * This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License 2.0
- * which accompanies this distribution, and is available at
- * https://www.eclipse.org/legal/epl-2.0/
- *
- * SPDX-License-Identifier: EPL-2.0
- *
- * Contributors:
- *     Oakland Software Incorporated - initial API and implementation
- *******************************************************************************/
-package org.eclipse.core.net;
-
-import org.eclipse.core.internal.net.proxy.unix.UnixProxyProvider;
-
-public class ProxyProvider extends UnixProxyProvider {
-}
diff --git a/bundles/org.eclipse.core.net.linux/.classpath b/bundles/org.eclipse.core.net.linux/.classpath
new file mode 100644
index 0000000..01836c4
--- /dev/null
+++ b/bundles/org.eclipse.core.net.linux/.classpath
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+	<classpathentry kind="src" path="src"/>
+	<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
+	<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/>
+	<classpathentry kind="output" path="bin"/>
+</classpath>
diff --git a/bundles/org.eclipse.core.net.linux/.project b/bundles/org.eclipse.core.net.linux/.project
new file mode 100644
index 0000000..4cf8c2f
--- /dev/null
+++ b/bundles/org.eclipse.core.net.linux/.project
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+	<name>org.eclipse.core.net.linux</name>
+	<comment></comment>
+	<projects>
+	</projects>
+	<buildSpec>
+		<buildCommand>
+			<name>org.eclipse.jdt.core.javabuilder</name>
+			<arguments>
+			</arguments>
+		</buildCommand>
+		<buildCommand>
+			<name>org.eclipse.pde.ManifestBuilder</name>
+			<arguments>
+			</arguments>
+		</buildCommand>
+		<buildCommand>
+			<name>org.eclipse.pde.SchemaBuilder</name>
+			<arguments>
+			</arguments>
+		</buildCommand>
+	</buildSpec>
+	<natures>
+		<nature>org.eclipse.pde.PluginNature</nature>
+		<nature>org.eclipse.jdt.core.javanature</nature>
+	</natures>
+</projectDescription>
diff --git a/bundles/org.eclipse.core.net.linux/META-INF/MANIFEST.MF b/bundles/org.eclipse.core.net.linux/META-INF/MANIFEST.MF
new file mode 100644
index 0000000..749024a
--- /dev/null
+++ b/bundles/org.eclipse.core.net.linux/META-INF/MANIFEST.MF
@@ -0,0 +1,12 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: %fragmentName
+Bundle-Vendor: %providerName
+Bundle-Localization: fragment
+Bundle-SymbolicName: org.eclipse.core.net.linux;singleton:=true
+Bundle-Version: 1.0.0.qualifier
+Fragment-Host: org.eclipse.core.net;bundle-version="1.1.0"
+Eclipse-PlatformFilter: (osgi.os=linux)
+Bundle-RequiredExecutionEnvironment: JavaSE-11
+Automatic-Module-Name: org.eclipse.core.net.linux
+Require-Bundle: com.sun.jna
diff --git a/bundles/org.eclipse.core.net.linux/about.html b/bundles/org.eclipse.core.net.linux/about.html
new file mode 100644
index 0000000..164f781
--- /dev/null
+++ b/bundles/org.eclipse.core.net.linux/about.html
@@ -0,0 +1,36 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
+    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml">
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
+<title>About</title>
+</head>
+<body lang="EN-US">
+	<h2>About This Content</h2>
+
+	<p>November 30, 2017</p>
+	<h3>License</h3>
+
+	<p>
+		The Eclipse Foundation makes available all content in this plug-in
+		(&quot;Content&quot;). Unless otherwise indicated below, the Content
+		is provided to you under the terms and conditions of the Eclipse
+		Public License Version 2.0 (&quot;EPL&quot;). A copy of the EPL is
+		available at <a href="http://www.eclipse.org/legal/epl-2.0">http://www.eclipse.org/legal/epl-2.0</a>.
+		For purposes of the EPL, &quot;Program&quot; will mean the Content.
+	</p>
+
+	<p>
+		If you did not receive this Content directly from the Eclipse
+		Foundation, the Content is being redistributed by another party
+		(&quot;Redistributor&quot;) and different terms and conditions may
+		apply to your use of any object code in the Content. Check the
+		Redistributor's license that was provided with the Content. If no such
+		license exists, contact the Redistributor. Unless otherwise indicated
+		below, the terms and conditions of the EPL still apply to any source
+		code in the Content and such source code may be obtained at <a
+			href="http://www.eclipse.org/">http://www.eclipse.org</a>.
+	</p>
+
+</body>
+</html>
\ No newline at end of file
diff --git a/bundles/org.eclipse.core.net.linux/build.properties b/bundles/org.eclipse.core.net.linux/build.properties
new file mode 100644
index 0000000..aeb64d8
--- /dev/null
+++ b/bundles/org.eclipse.core.net.linux/build.properties
@@ -0,0 +1,19 @@
+###############################################################################
+# Copyright (c) 2021 Red Hat Inc. and others.
+#
+# This program and the accompanying materials
+# are made available under the terms of the Eclipse Public License 2.0
+# which accompanies this distribution, and is available at
+# https://www.eclipse.org/legal/epl-2.0/
+#
+# SPDX-License-Identifier: EPL-2.0
+# 
+# Contributors:
+#     Red Hat Inc. - initial API and implementation
+###############################################################################
+bin.includes = fragment.properties,\
+               .,\
+               META-INF/,\
+               about.html
+src.includes = about.html
+source.. = src/
diff --git a/bundles/org.eclipse.core.net.linux/fragment.properties b/bundles/org.eclipse.core.net.linux/fragment.properties
new file mode 100644
index 0000000..cbcfcd7
--- /dev/null
+++ b/bundles/org.eclipse.core.net.linux/fragment.properties
@@ -0,0 +1,15 @@
+###############################################################################
+# Copyright (c) 2021 Red Hat Inc. and others.
+#
+# This program and the accompanying materials
+# are made available under the terms of the Eclipse Public License 2.0
+# which accompanies this distribution, and is available at
+# https://www.eclipse.org/legal/epl-2.0/
+#
+# SPDX-License-Identifier: EPL-2.0
+#
+# Contributors:
+#     Red Hat Inc. - initial API and implementation
+###############################################################################
+fragmentName = Proxy for Linux
+providerName = Eclipse.org
diff --git a/bundles/org.eclipse.core.net.linux/pom.xml b/bundles/org.eclipse.core.net.linux/pom.xml
new file mode 100644
index 0000000..10ac8f2
--- /dev/null
+++ b/bundles/org.eclipse.core.net.linux/pom.xml
@@ -0,0 +1,46 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  Copyright (c) 2012, 2021 Eclipse Foundation and others.
+  All rights reserved. This program and the accompanying materials
+  are made available under the terms of the Eclipse Distribution License v1.0
+  which accompanies this distribution, and is available at
+  http://www.eclipse.org/org/documents/edl-v10.php
+ 
+  Contributors:
+     Igor Fedorenko - initial implementation
+     Red Hat Inc. - modified for use in org.eclipse.core.net.linux
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+  <modelVersion>4.0.0</modelVersion>
+  <parent>
+    <artifactId>eclipse.platform.team</artifactId>
+    <groupId>eclipse.platform.team</groupId>
+    <version>4.20.0-SNAPSHOT</version>
+    <relativePath>../../</relativePath>
+  </parent>
+  <groupId>org.eclipse.core</groupId>
+  <artifactId>org.eclipse.core.net.linux</artifactId>
+  <version>1.0.0-SNAPSHOT</version>
+  <packaging>eclipse-plugin</packaging>
+
+  <properties>
+    <skipAPIAnalysis>true</skipAPIAnalysis>
+  </properties>
+
+  <build>
+    <plugins>
+      <plugin>
+        <groupId>org.eclipse.tycho</groupId>
+        <artifactId>target-platform-configuration</artifactId>
+        <configuration>
+          <environments>
+            <environment>
+              <os>linux</os>
+              <ws>gtk</ws>
+            </environment>
+          </environments>
+        </configuration>
+      </plugin>
+    </plugins>
+  </build>
+</project>
diff --git a/bundles/org.eclipse.core.net.linux/src/org/eclipse/core/net/ProxyProvider.java b/bundles/org.eclipse.core.net.linux/src/org/eclipse/core/net/ProxyProvider.java
new file mode 100644
index 0000000..e9e4992
--- /dev/null
+++ b/bundles/org.eclipse.core.net.linux/src/org/eclipse/core/net/ProxyProvider.java
@@ -0,0 +1,376 @@
+/*******************************************************************************
+ * Copyright (c) 2021 Red Hat Inc. and others
+ *
+ * This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License 2.0
+ * which accompanies this distribution, and is available at
+ * https://www.eclipse.org/legal/epl-2.0/
+ *
+ * SPDX-License-Identifier: EPL-2.0
+ *
+ * Contributors:
+ *     Red Hat Inc. - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.core.net;
+
+import java.io.IOException;
+import java.net.URI;
+import java.util.ArrayList;
+import java.util.Locale;
+import java.util.Objects;
+import java.util.Properties;
+
+import org.eclipse.core.internal.net.AbstractProxyProvider;
+import org.eclipse.core.internal.net.Activator;
+import org.eclipse.core.internal.net.Policy;
+import org.eclipse.core.internal.net.ProxyData;
+import org.eclipse.core.internal.net.StringUtil;
+import org.eclipse.core.net.proxy.IProxyData;
+
+import com.sun.jna.Library;
+import com.sun.jna.Native;
+import com.sun.jna.Pointer;
+import com.sun.jna.ptr.PointerByReference;
+
+/**
+ * JNA version of org.eclipse.core.internal.net.UnixProxyProvider
+ *
+ * @author jjohnstn
+ *
+ */
+public class ProxyProvider extends AbstractProxyProvider {
+
+	private static LibGio fLibGio;
+
+	private static Pointer proxySettings = Pointer.NULL;
+	private static Pointer httpProxySettings = Pointer.NULL;
+	private static Pointer httpsProxySettings = Pointer.NULL;
+	private static Pointer socksProxySettings = Pointer.NULL;
+	private static Pointer ftpProxySettings = Pointer.NULL;
+
+	private static final String ENABLE_GNOME = Activator.ID + ".enableGnome"; //$NON-NLS-1$
+
+	private static final String LIBRARY_NAME = "gio-2.0"; //$NON-NLS-1$
+
+	private static boolean isGnomeLibLoaded = false;
+
+	static {
+		// Load the GSettings JNI library if org.eclipse.core.net.enableGnome is specified
+		String value = System.getProperty(ENABLE_GNOME);
+		if ("".equals(value) || "true".equals(value)) { //$NON-NLS-1$ //$NON-NLS-2$
+			initializeSettings();
+		}
+	}
+
+	public ProxyProvider() {
+		// no initialization required
+	}
+
+	@Override
+	public IProxyData[] select(URI uri) {
+		String[] nonProxyHosts = getNonProxiedHosts();
+		if (nonProxyHosts != null) {
+			String host = uri.getHost();
+			for (String nonProxyHost : nonProxyHosts) {
+				if (StringUtil.hostMatchesFilter(host, nonProxyHost)) {
+					return new IProxyData[0];
+				}
+			}
+		}
+		IProxyData[] proxies = new IProxyData[0];
+		if (uri.getScheme() != null) {
+			ProxyData pd = getSystemProxyInfo(uri.getScheme());
+			proxies = pd != null ? new IProxyData[] { pd } : new IProxyData[0];
+		} else {
+			proxies = getProxyData();
+		}
+		if (Policy.DEBUG) {
+			Policy.debug("LinuxProxyProvider#select result for [" + uri + "]"); //$NON-NLS-1$ //$NON-NLS-2$
+			for (IProxyData proxy : proxies) {
+				System.out.println("	" + proxy); //$NON-NLS-1$
+			}
+		}
+		return proxies;
+	}
+
+	@Override
+	public IProxyData[] getProxyData() {
+		String[] commonTypes = new String[] { IProxyData.HTTP_PROXY_TYPE,
+				IProxyData.SOCKS_PROXY_TYPE, IProxyData.HTTPS_PROXY_TYPE };
+		return getProxyForTypes(commonTypes);
+	}
+
+	private IProxyData[] getProxyForTypes(String[] types) {
+		ArrayList<IProxyData> allData = new ArrayList<>();
+		for (String type : types) {
+			ProxyData pd = getSystemProxyInfo(type);
+			if (pd != null && pd.getHost() != null) {
+				allData.add(pd);
+			}
+		}
+		return allData.toArray(new IProxyData[0]);
+	}
+
+	@Override
+	public String[] getNonProxiedHosts() {
+		String[] npHosts;
+
+		if (Policy.DEBUG_SYSTEM_PROVIDERS)
+			Policy.debug("Getting no_proxy"); //$NON-NLS-1$
+
+		// First try the environment variable which is a URL
+		String npEnv = getEnv("no_proxy"); //$NON-NLS-1$
+		if (npEnv != null) {
+			npHosts = StringUtil.split(npEnv, new String[] { "," }); //$NON-NLS-1$
+			for (int i = 0; i < npHosts.length; i++)
+				npHosts[i] = npHosts[i].trim();
+			if (Policy.DEBUG_SYSTEM_PROVIDERS) {
+				Policy.debug("Got Env no_proxy: " + npEnv); //$NON-NLS-1$
+				debugPrint(npHosts);
+			}
+			return npHosts;
+		}
+
+		if (isGnomeLibLoaded) {
+			try {
+				npHosts = getGSettingsNonProxyHosts();
+				if (npHosts != null && npHosts.length > 0) {
+					if (Policy.DEBUG_SYSTEM_PROVIDERS) {
+						Policy.debug("Got Gnome no_proxy"); //$NON-NLS-1$
+						debugPrint(npHosts);
+					}
+					return npHosts;
+				}
+			} catch (UnsatisfiedLinkError e) {
+				// The library should be loaded, so this is a real exception
+				Activator.logError(
+						"Problem during accessing Gnome library", e); //$NON-NLS-1$
+			}
+		}
+
+		return new String[0];
+	}
+
+	// Returns null if something wrong or there is no proxy for the protocol
+	protected ProxyData getSystemProxyInfo(String protocol) {
+		ProxyData pd = null;
+		String envName = null;
+
+		if (Policy.DEBUG_SYSTEM_PROVIDERS)
+			Policy.debug("Getting proxies for: " + protocol); //$NON-NLS-1$
+
+		try {
+			// protocol schemes are ISO 8859 (ASCII)
+			protocol = protocol.toLowerCase(Locale.ENGLISH);
+
+			// First try the environment variable which is a URL
+			envName = protocol + "_proxy"; //$NON-NLS-1$
+			String proxyEnv = getEnv(envName);
+			if (Policy.DEBUG_SYSTEM_PROVIDERS)
+				Policy.debug("Got proxyEnv: " + proxyEnv); //$NON-NLS-1$
+
+			if (proxyEnv != null) {
+				int colonInd = proxyEnv.indexOf(":"); //$NON-NLS-1$
+				if (colonInd !=-1 && proxyEnv.length() > colonInd + 2 && !"//".equals(proxyEnv.substring(colonInd + 1, colonInd + 3))) { //$NON-NLS-1$
+					proxyEnv = "http://" + proxyEnv; //$NON-NLS-1$
+				}
+				URI uri = new URI(proxyEnv);
+				pd = new ProxyData(protocol);
+				pd.setHost(Objects.requireNonNull(uri.getHost(), "no host in " + proxyEnv)); //$NON-NLS-1$
+				int port = uri.getPort();
+				if (port == -1) {
+					throw new IllegalStateException("no port in " + proxyEnv); //$NON-NLS-1$
+				}
+				pd.setPort(port);
+				String userInfo = uri.getUserInfo();
+				if (userInfo != null) {
+					String user = null;
+					String password = null;
+					int pwInd = userInfo.indexOf(':');
+					if (pwInd >= 0) {
+						user = userInfo.substring(0, pwInd);
+						password = userInfo.substring(pwInd + 1);
+					} else {
+						user = userInfo;
+					}
+					pd.setUserid(user);
+					pd.setPassword(password);
+				}
+				pd.setSource("LINUX_ENV"); //$NON-NLS-1$
+				if (Policy.DEBUG_SYSTEM_PROVIDERS)
+					Policy.debug("Got Env proxy: " + pd); //$NON-NLS-1$
+				return pd;
+			}
+		} catch (Exception e) {
+			Activator.logError(
+					"Problem during accessing system variable: " + envName, e); //$NON-NLS-1$
+		}
+
+		if (isGnomeLibLoaded) {
+			try {
+				// Then ask Gnome
+				pd = getGSettingsProxyInfo(protocol);
+				if (pd != null) {
+					if (Policy.DEBUG_SYSTEM_PROVIDERS)
+						Policy.debug("Got Gnome proxy: " + pd); //$NON-NLS-1$
+					pd.setSource("LINUX_GNOME"); //$NON-NLS-1$
+					return pd;
+				}
+			} catch (UnsatisfiedLinkError e) {
+				// The library should be loaded, so this is a real exception
+				Activator.logError(
+						"Problem during accessing Gnome library", e); //$NON-NLS-1$
+			}
+		}
+
+		return null;
+	}
+
+	private static String getEnv(String env) {
+		try {
+			return System.getenv(env);
+		} catch (Throwable t) {
+			// Fall-back to running 'env' directly. Warning this is very slow...
+			// up to 200ms
+			String cmd[] = { "/bin/sh", //$NON-NLS-1$
+					"-c", //$NON-NLS-1$
+					"env | grep -i proxy" }; //$NON-NLS-1$
+			Properties props = new Properties();
+			Process proc = null;
+			try {
+				proc = Runtime.getRuntime().exec(cmd);
+				props.load(proc.getInputStream());
+			} catch (IOException e) {
+				Activator.logError(
+						"Problem during accessing system variable: " + env, e); //$NON-NLS-1$
+			} catch (IllegalArgumentException e) {
+				Activator.logError(
+						"Problem during accessing system variable: " + env, e); //$NON-NLS-1$
+			} finally {
+				if (proc != null) {
+					proc.destroy();
+				}
+			}
+			return props.getProperty(env);
+		}
+	}
+
+	private void debugPrint(String[] strs) {
+		for (int i = 0; i < strs.length; i++)
+			System.out.println(i + ": " + strs[i]); //$NON-NLS-1$
+	}
+
+	private interface LibGio extends Library {
+		Pointer g_settings_new(String schema);
+		boolean g_settings_get_boolean(Pointer settings, String key);
+		Pointer g_settings_get_string(Pointer settings, String key);
+		int g_settings_get_int(Pointer settings, String key);
+		PointerByReference g_settings_get_strv(Pointer Settings, String key);
+		void g_strfreev(PointerByReference p);
+		void g_free(Pointer p);
+	}
+
+	private static void initializeSettings() {
+		try {
+			fLibGio = Native.load(LIBRARY_NAME, LibGio.class);
+			proxySettings = fLibGio.g_settings_new ("org.gnome.system.proxy"); //$NON-NLS-1$
+			httpProxySettings = fLibGio.g_settings_new ("org.gnome.system.proxy.http"); //$NON-NLS-1$
+			httpsProxySettings = fLibGio.g_settings_new ("org.gnome.system.proxy.https"); //$NON-NLS-1$
+			socksProxySettings = fLibGio.g_settings_new ("org.gnome.system.proxy.socks"); //$NON-NLS-1$
+			ftpProxySettings = fLibGio.g_settings_new ("org.gnome.system.proxy.ftp"); //$NON-NLS-1$
+			isGnomeLibLoaded= true;
+			if (Policy.DEBUG_SYSTEM_PROVIDERS)
+				Policy.debug("Loaded " + //$NON-NLS-1$
+						System.mapLibraryName(LIBRARY_NAME) + " library"); //$NON-NLS-1$
+		} catch (UnsatisfiedLinkError e) {
+			isGnomeLibLoaded= false;
+			if (Policy.DEBUG_SYSTEM_PROVIDERS)
+				Policy.debug("Could not load library: " //$NON-NLS-1$
+						+ System.mapLibraryName(LIBRARY_NAME));
+		}
+	}
+
+	protected static ProxyData getGSettingsProxyInfo(String protocol) {
+
+		if (protocol == null) {
+			return null;
+		}
+
+		if (proxySettings == Pointer.NULL) {
+			initializeSettings();
+		}
+
+		ProxyData proxyData = new ProxyData(protocol);
+		boolean useSame = fLibGio.g_settings_get_boolean(proxySettings, "use-same-proxy"); //$NON-NLS-1$
+
+		if (protocol.equalsIgnoreCase("http") || useSame) { //$NON-NLS-1$
+			boolean useProxy = fLibGio.g_settings_get_boolean(httpProxySettings, "enabled"); //$NON-NLS-1$
+			if (!useProxy) {
+				return null;
+			}
+			Pointer host = fLibGio.g_settings_get_string(httpProxySettings, "host"); //$NON-NLS-1$
+			proxyData.setHost(host.getString(0));
+			fLibGio.g_free(host);
+
+			int port = fLibGio.g_settings_get_int(httpProxySettings, "port"); //$NON-NLS-1$
+			proxyData.setPort(port);
+
+			boolean reqAuth = fLibGio.g_settings_get_boolean(httpProxySettings, "use-authentication"); //$NON-NLS-1$
+			if (reqAuth) {
+				Pointer user = fLibGio.g_settings_get_string(httpProxySettings,	"authentication-user"); //$NON-NLS-1$
+				proxyData.setUserid(user.getString(0));
+				fLibGio.g_free(user);
+
+				Pointer password = fLibGio.g_settings_get_string(httpProxySettings,	"authentication-password"); //$NON-NLS-1$
+				proxyData.setPassword(password.getString(0));
+				fLibGio.g_free(password);
+			}
+			return proxyData;
+		}
+
+		// Everything else applies only if the system proxy mode is manual
+		Pointer mode = fLibGio.g_settings_get_string(proxySettings, "mode"); //$NON-NLS-1$
+		if (!mode.getString(0).equalsIgnoreCase("manual")) { //$NON-NLS-1$
+			fLibGio.g_free(mode);
+			return null;
+		}
+		fLibGio.g_free(mode);
+
+		Pointer host;
+		int port;
+
+		if (protocol.equalsIgnoreCase("https")) { //$NON-NLS-1$
+			host = fLibGio.g_settings_get_string(httpsProxySettings, "host"); //$NON-NLS-1$
+			port = fLibGio.g_settings_get_int(httpsProxySettings, "port"); //$NON-NLS-1$
+		} else if (protocol.equalsIgnoreCase("socks")) { //$NON-NLS-1$
+			host = fLibGio.g_settings_get_string(socksProxySettings, "host"); //$NON-NLS-1$
+			port = fLibGio.g_settings_get_int(socksProxySettings, "port"); //$NON-NLS-1$
+		} else if (protocol.equalsIgnoreCase("ftp")) { //$NON-NLS-1$
+			host = fLibGio.g_settings_get_string(ftpProxySettings, "host"); //$NON-NLS-1$
+			port = fLibGio.g_settings_get_int(ftpProxySettings, "port"); //$NON-NLS-1$
+		} else {
+			return null;
+		}
+
+		proxyData.setHost(host.getString(0));
+		fLibGio.g_free(host);
+		proxyData.setPort(port);
+
+		return proxyData;
+	}
+
+	protected static String[] getGSettingsNonProxyHosts() {
+		if (proxySettings == Pointer.NULL) {
+			initializeSettings();
+		}
+
+		PointerByReference npHostsArray = fLibGio.g_settings_get_strv(proxySettings, "ignore-hosts"); //$NON-NLS-1$
+		String[] npHosts = npHostsArray.getPointer().getStringArray(0);
+
+		fLibGio.g_strfreev(npHostsArray);
+
+		return npHosts;
+	}
+
+}
+
diff --git a/bundles/org.eclipse.core.net/src/org/eclipse/core/internal/net/proxy/unix/UnixProxyProvider.java b/bundles/org.eclipse.core.net/src/org/eclipse/core/internal/net/proxy/unix/UnixProxyProvider.java
deleted file mode 100644
index fffc477..0000000
--- a/bundles/org.eclipse.core.net/src/org/eclipse/core/internal/net/proxy/unix/UnixProxyProvider.java
+++ /dev/null
@@ -1,268 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008, 2018 Oakland Software Incorporated and others
- *
- * This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License 2.0
- * which accompanies this distribution, and is available at
- * https://www.eclipse.org/legal/epl-2.0/
- *
- * SPDX-License-Identifier: EPL-2.0
- *
- * Contributors:
- *		Oakland Software Incorporated - initial API and implementation
- *		IBM Corporation - implementation
- *		Red Hat - GSettings implementation and code clean up (bug 394087)
- *******************************************************************************/
-package org.eclipse.core.internal.net.proxy.unix;
-
-import java.io.IOException;
-import java.lang.reflect.Method;
-import java.net.URI;
-import java.util.ArrayList;
-import java.util.Locale;
-import java.util.Objects;
-import java.util.Properties;
-
-import org.eclipse.core.internal.net.AbstractProxyProvider;
-import org.eclipse.core.internal.net.Activator;
-import org.eclipse.core.internal.net.Policy;
-import org.eclipse.core.internal.net.ProxyData;
-import org.eclipse.core.internal.net.StringUtil;
-import org.eclipse.core.net.proxy.IProxyData;
-
-public class UnixProxyProvider extends AbstractProxyProvider {
-
-	private static final String LIBRARY_NAME = "gnomeproxy-1.0.0"; //$NON-NLS-1$
-
-	private static final String ENABLE_GNOME = Activator.ID + ".enableGnome"; //$NON-NLS-1$
-
-	private static boolean isGnomeLibLoaded = false;
-
-	static {
-		// Load the GSettings JNI library if org.eclipse.core.net.enableGnome is specified
-		String value = System.getProperty(ENABLE_GNOME);
-		if ("".equals(value) || "true".equals(value)) { //$NON-NLS-1$ //$NON-NLS-2$
-			loadGnomeLib();
-		}
-	}
-
-	public UnixProxyProvider() {
-		// Nothing to initialize
-	}
-
-	@Override
-	public IProxyData[] select(URI uri) {
-		String[] nonProxyHosts = getNonProxiedHosts();
-		if (nonProxyHosts != null) {
-			String host = uri.getHost();
-			for (String nonProxyHost : nonProxyHosts) {
-				if (StringUtil.hostMatchesFilter(host, nonProxyHost)) {
-					return new IProxyData[0];
-				}
-			}
-		}
-		IProxyData[] proxies = new IProxyData[0];
-		if (uri.getScheme() != null) {
-			ProxyData pd = getSystemProxyInfo(uri.getScheme());
-			proxies = pd != null ? new IProxyData[] { pd } : new IProxyData[0];
-		} else {
-			proxies = getProxyData();
-		}
-		if (Policy.DEBUG) {
-			Policy.debug("UnixProxyProvider#select result for [" + uri + "]"); //$NON-NLS-1$ //$NON-NLS-2$
-			for (IProxyData proxy : proxies) {
-				System.out.println("	" + proxy); //$NON-NLS-1$
-			}
-		}
-		return proxies;
-	}
-
-	@Override
-	public IProxyData[] getProxyData() {
-		String[] commonTypes = new String[] { IProxyData.HTTP_PROXY_TYPE,
-				IProxyData.SOCKS_PROXY_TYPE, IProxyData.HTTPS_PROXY_TYPE };
-		return getProxyForTypes(commonTypes);
-	}
-
-	private IProxyData[] getProxyForTypes(String[] types) {
-		ArrayList<IProxyData> allData = new ArrayList<>();
-		for (String type : types) {
-			ProxyData pd = getSystemProxyInfo(type);
-			if (pd != null && pd.getHost() != null) {
-				allData.add(pd);
-			}
-		}
-		return allData.toArray(new IProxyData[0]);
-	}
-
-	@Override
-	public String[] getNonProxiedHosts() {
-		String[] npHosts;
-
-		if (Policy.DEBUG_SYSTEM_PROVIDERS)
-			Policy.debug("Getting no_proxy"); //$NON-NLS-1$
-
-		// First try the environment variable which is a URL
-		String npEnv = getEnv("no_proxy"); //$NON-NLS-1$
-		if (npEnv != null) {
-			npHosts = StringUtil.split(npEnv, new String[] { "," }); //$NON-NLS-1$
-			for (int i = 0; i < npHosts.length; i++)
-				npHosts[i] = npHosts[i].trim();
-			if (Policy.DEBUG_SYSTEM_PROVIDERS) {
-				Policy.debug("Got Env no_proxy: " + npEnv); //$NON-NLS-1$
-				debugPrint(npHosts);
-			}
-			return npHosts;
-		}
-
-		if (isGnomeLibLoaded) {
-			try {
-				npHosts = getGSettingsNonProxyHosts();
-				if (npHosts != null && npHosts.length > 0) {
-					if (Policy.DEBUG_SYSTEM_PROVIDERS) {
-						Policy.debug("Got Gnome no_proxy"); //$NON-NLS-1$
-						debugPrint(npHosts);
-					}
-					return npHosts;
-				}
-			} catch (UnsatisfiedLinkError e) {
-				// The library should be loaded, so this is a real exception
-				Activator.logError(
-						"Problem during accessing Gnome library", e); //$NON-NLS-1$
-			}
-		}
-
-		return new String[0];
-	}
-
-	// Returns null if something wrong or there is no proxy for the protocol
-	protected ProxyData getSystemProxyInfo(String protocol) {
-		ProxyData pd = null;
-		String envName = null;
-
-		if (Policy.DEBUG_SYSTEM_PROVIDERS)
-			Policy.debug("Getting proxies for: " + protocol); //$NON-NLS-1$
-
-		try {
-			// protocol schemes are ISO 8859 (ASCII)
-			protocol = protocol.toLowerCase(Locale.ENGLISH);
-
-			// First try the environment variable which is a URL
-			envName = protocol + "_proxy"; //$NON-NLS-1$
-			String proxyEnv = getEnv(envName);
-			if (Policy.DEBUG_SYSTEM_PROVIDERS)
-				Policy.debug("Got proxyEnv: " + proxyEnv); //$NON-NLS-1$
-
-			if (proxyEnv != null) {
-				int colonInd = proxyEnv.indexOf(":"); //$NON-NLS-1$
-				if (colonInd !=-1 && proxyEnv.length() > colonInd + 2 && !"//".equals(proxyEnv.substring(colonInd + 1, colonInd + 3))) { //$NON-NLS-1$
-					proxyEnv = "http://" + proxyEnv; //$NON-NLS-1$
-				}
-				URI uri = new URI(proxyEnv);
-				pd = new ProxyData(protocol);
-				pd.setHost(Objects.requireNonNull(uri.getHost(), "no host in " + proxyEnv)); //$NON-NLS-1$
-				int port = uri.getPort();
-				if (port == -1) {
-					throw new IllegalStateException("no port in " + proxyEnv); //$NON-NLS-1$
-				}
-				pd.setPort(port);
-				String userInfo = uri.getUserInfo();
-				if (userInfo != null) {
-					String user = null;
-					String password = null;
-					int pwInd = userInfo.indexOf(':');
-					if (pwInd >= 0) {
-						user = userInfo.substring(0, pwInd);
-						password = userInfo.substring(pwInd + 1);
-					} else {
-						user = userInfo;
-					}
-					pd.setUserid(user);
-					pd.setPassword(password);
-				}
-				pd.setSource("LINUX_ENV"); //$NON-NLS-1$
-				if (Policy.DEBUG_SYSTEM_PROVIDERS)
-					Policy.debug("Got Env proxy: " + pd); //$NON-NLS-1$
-				return pd;
-			}
-		} catch (Exception e) {
-			Activator.logError(
-					"Problem during accessing system variable: " + envName, e); //$NON-NLS-1$
-		}
-
-		if (isGnomeLibLoaded) {
-			try {
-				// Then ask Gnome
-				pd = getGSettingsProxyInfo(protocol);
-				if (pd != null) {
-					if (Policy.DEBUG_SYSTEM_PROVIDERS)
-						Policy.debug("Got Gnome proxy: " + pd); //$NON-NLS-1$
-					pd.setSource("LINUX_GNOME"); //$NON-NLS-1$
-					return pd;
-				}
-			} catch (UnsatisfiedLinkError e) {
-				// The library should be loaded, so this is a real exception
-				Activator.logError(
-						"Problem during accessing Gnome library", e); //$NON-NLS-1$
-			}
-		}
-
-		return null;
-	}
-
-	private static String getEnv(String env) {
-		try {
-			Method m = System.class.getMethod("getenv", String.class); //$NON-NLS-1$
-			return (String) m.invoke(null, env);
-		} catch (Throwable t) {
-			// Fall-back to running 'env' directly. Warning this is very slow...
-			// up to 200ms
-			String cmd[] = { "/bin/sh", //$NON-NLS-1$
-					"-c", //$NON-NLS-1$
-					"env | grep -i proxy" }; //$NON-NLS-1$
-			Properties props = new Properties();
-			Process proc = null;
-			try {
-				proc = Runtime.getRuntime().exec(cmd);
-				props.load(proc.getInputStream());
-			} catch (IOException e) {
-				Activator.logError(
-						"Problem during accessing system variable: " + env, e); //$NON-NLS-1$
-			} catch (IllegalArgumentException e) {
-				Activator.logError(
-						"Problem during accessing system variable: " + env, e); //$NON-NLS-1$
-			} finally {
-				if (proc != null) {
-					proc.destroy();
-				}
-			}
-			return props.getProperty(env);
-		}
-	}
-
-	private static void loadGnomeLib() {
-		try {
-			System.loadLibrary(LIBRARY_NAME);
-			isGnomeLibLoaded = true;
-			if (Policy.DEBUG_SYSTEM_PROVIDERS)
-				Policy.debug("Loaded " + //$NON-NLS-1$
-						System.mapLibraryName(LIBRARY_NAME) + " library"); //$NON-NLS-1$
-		} catch (final UnsatisfiedLinkError e) {
-			// Expected on systems that are missing Gnome library
-			if (Policy.DEBUG_SYSTEM_PROVIDERS)
-				Policy.debug("Could not load library: " //$NON-NLS-1$
-						+ System.mapLibraryName(LIBRARY_NAME));
-		}
-	}
-
-	private void debugPrint(String[] strs) {
-		for (int i = 0; i < strs.length; i++)
-			System.out.println(i + ": " + strs[i]); //$NON-NLS-1$
-	}
-
-	protected static native void gsettingsInit();
-
-	protected static native ProxyData getGSettingsProxyInfo(String protocol);
-
-	protected static native String[] getGSettingsNonProxyHosts();
-}
diff --git a/pom.xml b/pom.xml
index 2c183c4..818c12c 100644
--- a/pom.xml
+++ b/pom.xml
@@ -73,6 +73,7 @@
     <module>features/org.eclipse.cvs-feature</module>
 
     <!-- fragments -->
+    <module>bundles/org.eclipse.core.net.linux</module>
     <module>bundles/org.eclipse.core.net.linux.x86_64</module>
     <module>bundles/org.eclipse.core.net.win32.x86_64</module>
     <module>tests</module>