Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEric Williams2018-05-23 14:51:43 +0000
committerAlexander Kurtakov2018-06-06 12:25:03 +0000
commit010ef698fc87044d3f105fa4db68d85b8632940b (patch)
tree1e4d754e928f1906d8ef325bc7f15be3aa9172b5 /bundles
parent5147ed2f5c66369f6abdea0725c76e3de4c2c335 (diff)
downloadeclipse.platform.team-I20180613-0440.tar.gz
eclipse.platform.team-I20180613-0440.tar.xz
eclipse.platform.team-I20180613-0440.zip
Use GSettings instead of GConf2 to fetch proxy settings from GNOME. Instead it now uses the following GSettings schemas for proxies: org.gnome.system.proxy org.gnome.system.proxy.http org.gnome.system.proxy.https org.gnome.system.proxy.socks org.gnome.system.proxy.ftp You can get/set values for the keys in each of these schemas by running gsettings [get/set] schema key value. For example, to set the SOCKS proxy host, run: gsettings set org.gnome.system.proxy.socks host <value> To test in Eclipse, import the org.eclipse.core.net and org.eclipse.core.net.linux.x86_64 projects into your workspace. Launch a child Eclipse that depends on these two workspace plugins, and make sure the child Eclipse launches with the argument: -Dorg.eclipse.core.net.enableGnome as this enables the GNOME proxy functionality. In the child Eclipse, go to Window -> Preferences -> General -> Network connections. Selecting the "native" combo option will pull in proxy/network settings as set via GNOME. Change-Id: I0f620275aa15205245ae4156d9ed63ebf20c3568 Signed-off-by: Eric Williams <ericwill@redhat.com>
Diffstat (limited to 'bundles')
-rw-r--r--bundles/org.eclipse.core.net/fragments/org.eclipse.core.net.linux.x86_64/BUILD_INFO.txt12
-rw-r--r--bundles/org.eclipse.core.net/fragments/org.eclipse.core.net.linux.x86_64/libgnomeproxy-1.0.0.sobin90809 -> 259848 bytes
-rw-r--r--bundles/org.eclipse.core.net/natives/unix/gnomeproxy.c129
-rw-r--r--bundles/org.eclipse.core.net/natives/unix/gnomeproxy.h12
-rw-r--r--bundles/org.eclipse.core.net/natives/unix/linux/makefile11
-rw-r--r--bundles/org.eclipse.core.net/src/org/eclipse/core/internal/net/proxy/unix/UnixProxyProvider.java30
6 files changed, 90 insertions, 104 deletions
diff --git a/bundles/org.eclipse.core.net/fragments/org.eclipse.core.net.linux.x86_64/BUILD_INFO.txt b/bundles/org.eclipse.core.net/fragments/org.eclipse.core.net.linux.x86_64/BUILD_INFO.txt
index 8d7c5cdbd..a312cc736 100644
--- a/bundles/org.eclipse.core.net/fragments/org.eclipse.core.net.linux.x86_64/BUILD_INFO.txt
+++ b/bundles/org.eclipse.core.net/fragments/org.eclipse.core.net.linux.x86_64/BUILD_INFO.txt
@@ -2,9 +2,9 @@ Native Build Info:
------------------
platform: linux.gtk.x86_64
-built by: Tristan Tarrant, tristan.tarrant@gmail.com
-build date: 05-November-2009
-OS Name: CentOS 3.9
-OS Version: Linux 2.4.21-50.EL
-Compiler version: gcc (GCC) 3.2.3 20030502 (Red Hat Linux 3.2.3-59)
-Java version: Java(TM) 2 Runtime Environment, Standard Edition (build Blackdown-1.4.2_03) 64-Bit Server VM \ No newline at end of file
+built by: Eric Williams, ericwill@redhat.com
+build date: 24-May-2018
+OS Name: RHEL Workstation 7.5
+OS Version: Linux 3.10.0
+Compiler version: gcc (GCC) 4.8.5
+Java version: Java(TM) 8 Runtime Environment, Standard Edition (1.8.0.171) \ No newline at end of file
diff --git a/bundles/org.eclipse.core.net/fragments/org.eclipse.core.net.linux.x86_64/libgnomeproxy-1.0.0.so b/bundles/org.eclipse.core.net/fragments/org.eclipse.core.net.linux.x86_64/libgnomeproxy-1.0.0.so
index dea366e47..ab71687a2 100644
--- a/bundles/org.eclipse.core.net/fragments/org.eclipse.core.net.linux.x86_64/libgnomeproxy-1.0.0.so
+++ b/bundles/org.eclipse.core.net/fragments/org.eclipse.core.net.linux.x86_64/libgnomeproxy-1.0.0.so
Binary files differ
diff --git a/bundles/org.eclipse.core.net/natives/unix/gnomeproxy.c b/bundles/org.eclipse.core.net/natives/unix/gnomeproxy.c
index 2417b4eec..f96d15c7c 100644
--- a/bundles/org.eclipse.core.net/natives/unix/gnomeproxy.c
+++ b/bundles/org.eclipse.core.net/natives/unix/gnomeproxy.c
@@ -1,21 +1,21 @@
/*
- * Copyright 2008, 2012 Oakland Software Incorporated and others
- * All rights reserved. This program and the accompanying materials
+ * Copyright 2008, 2018 Oakland Software Incorporated and others
+ * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
- *
+ *
* Contributors:
* Oakland Software Incorporated - initial API and implementation
- * IBM Corporation - enabling JNI calls for gconfInit method (bug 232495)
+ * IBM Corporation - enabling JNI calls for gconfInit method (bug 232495)
* IBM Corporation - gnomeproxy cannot be built with latest versions of glib (bug 385047)
+ * Red Hat - GSettings implementation and code clean up (bug 394087)
*/
#include <jni.h>
#include <glib.h>
-#include <gconf/gconf-value.h>
-#include <gconf/gconf-client.h>
+#include <gio/gio.h>
#ifdef __linux__
#include <string.h>
@@ -23,9 +23,11 @@
#include <strings.h>
#endif
-#include "gnomeproxy.h"
-
-static GConfClient *client= NULL;
+static GSettings *proxySettings = NULL;
+static GSettings *httpProxySettings = NULL;
+static GSettings *httpsProxySettings = NULL;
+static GSettings *socksProxySettings = NULL;
+static GSettings *ftpProxySettings = NULL;
static jclass proxyInfoClass;
static jclass stringClass;
@@ -37,18 +39,21 @@ static jmethodID portMethod;
static jmethodID userMethod;
static jmethodID passwordMethod;
-#define CHECK_NULL(X) { if ((X) == NULL) fprintf (stderr,"JNI error at line %d\n", __LINE__); }
+#define CHECK_NULL(X) { if ((X) == NULL) fprintf (stderr,"JNI error at line %d\n", __LINE__); }
/*
* Class: org_eclipse_core_internal_net_proxy_unix_UnixProxyProvider
- * Method: gconfInit
+ * Method: gsettingsInit
* Signature: ()V
*/
-JNIEXPORT void JNICALL Java_org_eclipse_core_internal_net_proxy_unix_UnixProxyProvider_gconfInit(
+JNIEXPORT void JNICALL Java_org_eclipse_core_internal_net_proxy_unix_UnixProxyProvider_gsettingsInit(
JNIEnv *env, jclass clazz) {
- g_type_init();
- client = gconf_client_get_default();
+ proxySettings = g_settings_new ("org.gnome.system.proxy");
+ httpProxySettings = g_settings_new ("org.gnome.system.proxy.http");
+ httpsProxySettings = g_settings_new ("org.gnome.system.proxy.https");
+ socksProxySettings = g_settings_new ("org.gnome.system.proxy.socks");
+ ftpProxySettings = g_settings_new ("org.gnome.system.proxy.ftp");
jclass cls= NULL;
CHECK_NULL(cls = (*env)->FindClass(env, "org/eclipse/core/internal/net/ProxyData"));
proxyInfoClass = (*env)->NewGlobalRef(env, cls);
@@ -72,10 +77,10 @@ JNIEXPORT void JNICALL Java_org_eclipse_core_internal_net_proxy_unix_UnixProxyPr
/*
* Class: org_eclipse_core_internal_net_UnixProxyProvider
- * Method: getGConfProxyInfo
+ * Method: getGSettingsProxyInfo
* Signature: ([Ljava/lang/String);
*/
-JNIEXPORT jobject JNICALL Java_org_eclipse_core_internal_net_proxy_unix_UnixProxyProvider_getGConfProxyInfo(
+JNIEXPORT jobject JNICALL Java_org_eclipse_core_internal_net_proxy_unix_UnixProxyProvider_getGSettingsProxyInfo(
JNIEnv *env, jclass clazz, jstring protocol) {
jboolean isCopy;
@@ -83,8 +88,8 @@ JNIEXPORT jobject JNICALL Java_org_eclipse_core_internal_net_proxy_unix_UnixProx
jobject proxyInfo= NULL;
- if (client == NULL) {
- Java_org_eclipse_core_internal_net_proxy_unix_UnixProxyProvider_gconfInit(env, clazz);
+ if (proxySettings == NULL) {
+ Java_org_eclipse_core_internal_net_proxy_unix_UnixProxyProvider_gsettingsInit(env, clazz);
}
CHECK_NULL(proxyInfo = (*env)->NewObject(env, proxyInfoClass, proxyInfoConstructor, protocol));
@@ -93,78 +98,73 @@ JNIEXPORT jobject JNICALL Java_org_eclipse_core_internal_net_proxy_unix_UnixProx
if (cprotocol == NULL)
return NULL;
- //printf("cprotocol: %s\n", cprotocol);
-
- // use_same_proxy means we use the http value for everything
- gboolean useSame = gconf_client_get_bool(client,
- "/system/http_proxy/use_same_proxy", NULL);
+ gboolean useSame = g_settings_get_boolean(proxySettings,
+ "use-same-proxy");
if (strcasecmp(cprotocol, "http") == 0 || useSame) {
- gboolean useProxy = gconf_client_get_bool(client,
- "/system/http_proxy/use_http_proxy", NULL);
+ gboolean useProxy = g_settings_get_boolean(httpProxySettings,
+ "enabled");
if (!useProxy) {
proxyInfo = NULL;
goto exit;
}
- gchar *host = gconf_client_get_string(client,
- "/system/http_proxy/host", NULL);
+ gchar *host = g_settings_get_string(httpProxySettings,
+ "host");
jobject jhost = (*env)->NewStringUTF(env, host);
(*env)->CallVoidMethod(env, proxyInfo, hostMethod, jhost);
+ g_free(host);
- gint port = gconf_client_get_int(client, "/system/http_proxy/port",
- NULL);
+ gint port = g_settings_get_int(httpProxySettings, "port");
(*env)->CallVoidMethod(env, proxyInfo, portMethod, port);
- gboolean reqAuth = gconf_client_get_bool(client,
- "/system/http_proxy/use_authentication", NULL);
+ gboolean reqAuth = g_settings_get_boolean(httpProxySettings,
+ "use-authentication");
if (reqAuth) {
-
- gchar *user = gconf_client_get_string(client,
- "/system/http_proxy/authentication_user", NULL);
+ gchar *user = g_settings_get_string(httpProxySettings,
+ "authentication-user");
jobject juser = (*env)->NewStringUTF(env, user);
(*env)->CallVoidMethod(env, proxyInfo, userMethod, juser);
- gchar *password = gconf_client_get_string(client,
- "/system/http_proxy/authentication_password", NULL);
+ gchar *password = g_settings_get_string(httpProxySettings,
+ "authentication-password");
jobject jpassword = (*env)->NewStringUTF(env, password);
(*env)->CallVoidMethod(env, proxyInfo, passwordMethod,
jpassword);
+ g_free(user);
+ g_free(password);
}
goto exit;
}
// Everything else applies only if the system proxy mode is manual
- gchar *mode = gconf_client_get_string(client, "/system/proxy/mode", NULL);
+ gchar *mode = g_settings_get_string(proxySettings, "mode");
if (strcasecmp(mode, "manual") != 0) {
proxyInfo = NULL;
goto exit;
}
+ g_free(mode);
- char selector[100];
-
+ gchar *host;
+ gint port;
if (strcasecmp(cprotocol, "https") == 0) {
- strcpy(selector, "/system/proxy/secure_");
+ host = g_settings_get_string(httpsProxySettings, "host");
+ port = g_settings_get_int(httpsProxySettings, "port");
} else if (strcasecmp(cprotocol, "socks") == 0) {
- strcpy(selector, "/system/proxy/socks_");
+ host = g_settings_get_string(socksProxySettings, "host");
+ port = g_settings_get_int(socksProxySettings, "port");
} else if (strcasecmp(cprotocol, "ftp") == 0) {
- strcpy(selector, "/system/proxy/ftp_");
+ host = g_settings_get_string(ftpProxySettings, "host");
+ port = g_settings_get_int(ftpProxySettings, "port");
} else {
proxyInfo = NULL;
goto exit;
}
- char useSelector[100];
- strcpy(useSelector, selector);
-
- gchar *host = gconf_client_get_string(client, strcat(useSelector, "host"),
- NULL);
jobject jhost = (*env)->NewStringUTF(env, host);
(*env)->CallVoidMethod(env, proxyInfo, hostMethod, jhost);
-
- strcpy(useSelector, selector);
- gint port = gconf_client_get_int(client, strcat(useSelector, "port"), NULL);
(*env)->CallVoidMethod(env, proxyInfo, portMethod, port);
+ g_free(host);
exit: if (isCopy == JNI_TRUE)
(*env)->ReleaseStringUTFChars(env, protocol, cprotocol);
@@ -187,31 +187,28 @@ void listProc(gpointer data, gpointer user_data) {
/*
* Class: org_eclipse_core_internal_net_UnixProxyProvider
- * Method: getGConfNonProxyHosts
+ * Method: getGSettingsNonProxyHosts
* Signature: ()[Ljava/lang/String;
*/
-JNIEXPORT jobjectArray JNICALL Java_org_eclipse_core_internal_net_proxy_unix_UnixProxyProvider_getGConfNonProxyHosts(
+JNIEXPORT jobjectArray JNICALL Java_org_eclipse_core_internal_net_proxy_unix_UnixProxyProvider_getGSettingsNonProxyHosts(
JNIEnv *env, jclass clazz) {
- if (client == NULL) {
- Java_org_eclipse_core_internal_net_proxy_unix_UnixProxyProvider_gconfInit(env, clazz);
+ if (proxySettings == NULL) {
+ Java_org_eclipse_core_internal_net_proxy_unix_UnixProxyProvider_gsettingsInit(env, clazz);
}
- GSList *npHosts;
- int size;
+ gchar **npfHostsArray;
+ GSList *npHosts = NULL;
+ gint size, i;
- npHosts = gconf_client_get_list(client, "/system/http_proxy/ignore_hosts",
- GCONF_VALUE_STRING, NULL);
- size = g_slist_length(npHosts);
+ npfHostsArray = g_settings_get_strv(proxySettings, "ignore-hosts");
- // TODO - I'm not sure this is really valid, it's from the JVM implementation
- // of ProxySelector
- if (size == 0) {
- npHosts = gconf_client_get_list(client, "/system/proxy/no_proxy_for",
- GCONF_VALUE_STRING, NULL);
+ for (i = 0; npfHostsArray[i] != NULL; i++) {
+ npHosts = g_slist_prepend(npHosts, npfHostsArray[i]);
}
- size = g_slist_length(npHosts);
+ npHosts = g_slist_reverse(npHosts);
+ size = g_slist_length(npHosts);
jobjectArray ret = (*env)->NewObjectArray(env, size, stringClass, NULL);
ListProcContext lpc;
@@ -220,6 +217,8 @@ JNIEXPORT jobjectArray JNICALL Java_org_eclipse_core_internal_net_proxy_unix_Uni
lpc.index = 0;
g_slist_foreach(npHosts, listProc, &lpc);
+ g_strfreev(npfHostsArray);
+ g_slist_free(npHosts);
return ret;
}
diff --git a/bundles/org.eclipse.core.net/natives/unix/gnomeproxy.h b/bundles/org.eclipse.core.net/natives/unix/gnomeproxy.h
index cf0e8d712..8dab51c91 100644
--- a/bundles/org.eclipse.core.net/natives/unix/gnomeproxy.h
+++ b/bundles/org.eclipse.core.net/natives/unix/gnomeproxy.h
@@ -10,26 +10,26 @@ extern "C" {
/* Inaccessible static: isGnomeLibLoaded */
/*
* Class: org_eclipse_core_internal_net_proxy_unix_UnixProxyProvider
- * Method: gconfInit
+ * Method: gsettingsInit
* Signature: ()V
*/
-JNIEXPORT void JNICALL Java_org_eclipse_core_internal_net_proxy_unix_UnixProxyProvider_gconfInit
+JNIEXPORT void JNICALL Java_org_eclipse_core_internal_net_proxy_unix_UnixProxyProvider_gsettingsInit
(JNIEnv *, jclass);
/*
* Class: org_eclipse_core_internal_net_proxy_unix_UnixProxyProvider
- * Method: getGConfProxyInfo
+ * Method: getGSettingsProxyInfo
* Signature: (Ljava/lang/String;)Lorg/eclipse/core/internal/net/ProxyData;
*/
-JNIEXPORT jobject JNICALL Java_org_eclipse_core_internal_net_proxy_unix_UnixProxyProvider_getGConfProxyInfo
+JNIEXPORT jobject JNICALL Java_org_eclipse_core_internal_net_proxy_unix_UnixProxyProvider_getGSettingsProxyInfo
(JNIEnv *, jclass, jstring);
/*
* Class: org_eclipse_core_internal_net_proxy_unix_UnixProxyProvider
- * Method: getGConfNonProxyHosts
+ * Method: getGSettingsNonProxyHosts
* Signature: ()[Ljava/lang/String;
*/
-JNIEXPORT jobjectArray JNICALL Java_org_eclipse_core_internal_net_proxy_unix_UnixProxyProvider_getGConfNonProxyHosts
+JNIEXPORT jobjectArray JNICALL Java_org_eclipse_core_internal_net_proxy_unix_UnixProxyProvider_getGSettingsNonProxyHosts
(JNIEnv *, jclass);
#ifdef __cplusplus
diff --git a/bundles/org.eclipse.core.net/natives/unix/linux/makefile b/bundles/org.eclipse.core.net/natives/unix/linux/makefile
index b0e551922..65f682008 100644
--- a/bundles/org.eclipse.core.net/natives/unix/linux/makefile
+++ b/bundles/org.eclipse.core.net/natives/unix/linux/makefile
@@ -1,6 +1,6 @@
#**********************************************************************
-# Copyright (c) 2008, 2012 Oakland Software Incorporated and others.
-# All rights reserved. This program and the accompanying materials
+# Copyright (c) 2008, 2018 Oakland Software Incorporated and others.
+# All rights reserved. This program and the accompanying materials
# are made available under the terms of the Eclipse Public License v1.0
# which accompanies this distribution, and is available at
# http://www.eclipse.org/legal/epl-v10.html
@@ -8,8 +8,9 @@
# Contributors:
# Oakland Software Incorporated - initial submission
# IBM Corporation - refactoring, bug 245849
+# Red Hat - GSettings implementation and code clean up (bug 394087)
#
-#**********************************************************************
+#**********************************************************************
#
# makefile for libgnomeproxy-1.0.0.so
@@ -20,10 +21,10 @@ LIB_NAME_FULL = libgnomeproxy-1.0.0.so
OS_TYPE = linux
JDK_INCLUDE = -I${JAVA_HOME}/include -I${JAVA_HOME}/include/${OS_TYPE}
-INCLUDE = `pkg-config --cflags gconf-2.0`
+INCLUDE = `pkg-config --cflags gio-2.0`
COMPILER_FLAGS = -O0 -fPIC -g3 -Wall -c -fmessage-length=0 ${TARGET_ENVIRONMENT}
-LIBS := `pkg-config --libs gconf-2.0`
+LIBS := `pkg-config --libs gio-2.0`
LINKER_FLAGS= ${TARGET_ENVIRONMENT}
all: link
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
index 1f13abdb3..c430217d6 100644
--- 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
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2008, 2017 Oakland Software Incorporated and others
+ * Copyright (c) 2008, 2018 Oakland Software Incorporated and others
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -8,6 +8,7 @@
* 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;
@@ -28,8 +29,6 @@ import org.eclipse.core.net.proxy.IProxyData;
public class UnixProxyProvider extends AbstractProxyProvider {
- private static final String LIBRARY_GCONF2 = "gconf-2"; //$NON-NLS-1$
-
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$
@@ -37,9 +36,7 @@ public class UnixProxyProvider extends AbstractProxyProvider {
private static boolean isGnomeLibLoaded = false;
static {
- // We have to load this here otherwise gconf seems to have problems
- // causing hangs and various other bad behavior,
- // please don't move this to be initialized on another thread.
+ // 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();
@@ -117,7 +114,7 @@ public class UnixProxyProvider extends AbstractProxyProvider {
if (isGnomeLibLoaded) {
try {
- npHosts = getGConfNonProxyHosts();
+ npHosts = getGSettingsNonProxyHosts();
if (npHosts != null && npHosts.length > 0) {
if (Policy.DEBUG_SYSTEM_PROVIDERS) {
Policy.debug("Got Gnome no_proxy"); //$NON-NLS-1$
@@ -193,7 +190,7 @@ public class UnixProxyProvider extends AbstractProxyProvider {
if (isGnomeLibLoaded) {
try {
// Then ask Gnome
- pd = getGConfProxyInfo(protocol);
+ pd = getGSettingsProxyInfo(protocol);
if (pd != null) {
if (Policy.DEBUG_SYSTEM_PROVIDERS)
Policy.debug("Got Gnome proxy: " + pd); //$NON-NLS-1$
@@ -243,16 +240,6 @@ public class UnixProxyProvider extends AbstractProxyProvider {
private static void loadGnomeLib() {
try {
- System.loadLibrary(LIBRARY_GCONF2);
- } catch (final UnsatisfiedLinkError e) {
- // Expected on systems that are missing Gnome
- if (Policy.DEBUG_SYSTEM_PROVIDERS)
- Policy.debug("Could not load library: " //$NON-NLS-1$
- + System.mapLibraryName(LIBRARY_GCONF2));
- return;
- }
-
- try {
System.loadLibrary(LIBRARY_NAME);
isGnomeLibLoaded = true;
if (Policy.DEBUG_SYSTEM_PROVIDERS)
@@ -266,15 +253,14 @@ public class UnixProxyProvider extends AbstractProxyProvider {
}
}
-
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 gconfInit();
+ protected static native void gsettingsInit();
- protected static native ProxyData getGConfProxyInfo(String protocol);
+ protected static native ProxyData getGSettingsProxyInfo(String protocol);
- protected static native String[] getGConfNonProxyHosts();
+ protected static native String[] getGSettingsNonProxyHosts();
}

Back to the top