diff options
| author | Alexander Kurtakov | 2021-04-24 07:10:50 +0000 |
|---|---|---|
| committer | Alexander Kurtakov | 2021-04-24 07:24:38 +0000 |
| commit | 53f4a42a546347d629c0dac69166acd766e5e8d1 (patch) | |
| tree | d45d11027b42019655cf192892aefc69d92c4e34 | |
| parent | 45855a865e7777c7797ef73367f903ab04a51494 (diff) | |
| download | eclipse.platform.team-53f4a42a546347d629c0dac69166acd766e5e8d1.tar.gz eclipse.platform.team-53f4a42a546347d629c0dac69166acd766e5e8d1.tar.xz eclipse.platform.team-53f4a42a546347d629c0dac69166acd766e5e8d1.zip | |
Bug 566638 - Make linux proxy support work for all archs
Remove C code for linux proxy support.
Change-Id: Icf99bb69787708766e0c7f7c748238804a4ba597
Reviewed-on: https://git.eclipse.org/r/c/platform/eclipse.platform.team/+/179784
Tested-by: Platform Bot <platform-bot@eclipse.org>
Reviewed-by: Alexander Kurtakov <akurtako@redhat.com>
3 files changed, 0 insertions, 316 deletions
diff --git a/bundles/org.eclipse.core.net/natives/unix/gnomeproxy.c b/bundles/org.eclipse.core.net/natives/unix/gnomeproxy.c deleted file mode 100644 index 9ffd828a8..000000000 --- a/bundles/org.eclipse.core.net/natives/unix/gnomeproxy.c +++ /dev/null @@ -1,227 +0,0 @@ -/* - * Copyright 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 - 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 <gio/gio.h> - -#ifdef __linux__ -#include <string.h> -#else -#include <strings.h> -#endif - -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; -static jmethodID proxyInfoConstructor; -static jmethodID toString; - -static jmethodID hostMethod; -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__); } - -/* - * Class: org_eclipse_core_internal_net_proxy_unix_UnixProxyProvider - * Method: gsettingsInit - * Signature: ()V - */ -JNIEXPORT void JNICALL Java_org_eclipse_core_internal_net_proxy_unix_UnixProxyProvider_gsettingsInit( - JNIEnv *env, jclass clazz) { - - 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); - - CHECK_NULL(cls = (*env)->FindClass(env, "java/lang/String")); - stringClass = (*env)->NewGlobalRef(env, cls); - - CHECK_NULL(proxyInfoConstructor = (*env)->GetMethodID(env, proxyInfoClass, "<init>", "(Ljava/lang/String;)V")); - - CHECK_NULL(toString = (*env)->GetMethodID(env, proxyInfoClass, "toString", "()Ljava/lang/String;")); - - CHECK_NULL(hostMethod = (*env)->GetMethodID(env, proxyInfoClass, "setHost", - "(Ljava/lang/String;)V")); - CHECK_NULL(portMethod = (*env)->GetMethodID(env, proxyInfoClass, "setPort", - "(I)V")); - CHECK_NULL(userMethod = (*env)->GetMethodID(env, proxyInfoClass, "setUserid", - "(Ljava/lang/String;)V")); - CHECK_NULL(passwordMethod = (*env)->GetMethodID(env, proxyInfoClass, "setPassword", - "(Ljava/lang/String;)V")); -} - -/* - * Class: org_eclipse_core_internal_net_UnixProxyProvider - * Method: getGSettingsProxyInfo - * Signature: ([Ljava/lang/String); - */ -JNIEXPORT jobject JNICALL Java_org_eclipse_core_internal_net_proxy_unix_UnixProxyProvider_getGSettingsProxyInfo( - JNIEnv *env, jclass clazz, jstring protocol) { - - jboolean isCopy; - const char *cprotocol; - - jobject proxyInfo= NULL; - - if (proxySettings == NULL) { - Java_org_eclipse_core_internal_net_proxy_unix_UnixProxyProvider_gsettingsInit(env, clazz); - } - - CHECK_NULL(proxyInfo = (*env)->NewObject(env, proxyInfoClass, proxyInfoConstructor, protocol)); - - cprotocol = (*env)->GetStringUTFChars(env, protocol, &isCopy); - if (cprotocol == NULL) - return NULL; - - gboolean useSame = g_settings_get_boolean(proxySettings, - "use-same-proxy"); - - if (strcasecmp(cprotocol, "http") == 0 || useSame) { - gboolean useProxy = g_settings_get_boolean(httpProxySettings, - "enabled"); - if (!useProxy) { - proxyInfo = NULL; - goto exit; - } - - 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 = g_settings_get_int(httpProxySettings, "port"); - (*env)->CallVoidMethod(env, proxyInfo, portMethod, port); - - gboolean reqAuth = g_settings_get_boolean(httpProxySettings, - "use-authentication"); - if (reqAuth) { - gchar *user = g_settings_get_string(httpProxySettings, - "authentication-user"); - jobject juser = (*env)->NewStringUTF(env, user); - (*env)->CallVoidMethod(env, proxyInfo, userMethod, juser); - - 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 = g_settings_get_string(proxySettings, "mode"); - if (strcasecmp(mode, "manual") != 0) { - proxyInfo = NULL; - goto exit; - } - g_free(mode); - - gchar *host; - gint port; - if (strcasecmp(cprotocol, "https") == 0) { - host = g_settings_get_string(httpsProxySettings, "host"); - port = g_settings_get_int(httpsProxySettings, "port"); - } else if (strcasecmp(cprotocol, "socks") == 0) { - host = g_settings_get_string(socksProxySettings, "host"); - port = g_settings_get_int(socksProxySettings, "port"); - } else if (strcasecmp(cprotocol, "ftp") == 0) { - host = g_settings_get_string(ftpProxySettings, "host"); - port = g_settings_get_int(ftpProxySettings, "port"); - } else { - proxyInfo = NULL; - goto exit; - } - - jobject jhost = (*env)->NewStringUTF(env, host); - (*env)->CallVoidMethod(env, proxyInfo, hostMethod, jhost); - (*env)->CallVoidMethod(env, proxyInfo, portMethod, port); - g_free(host); - - exit: if (isCopy == JNI_TRUE) - (*env)->ReleaseStringUTFChars(env, protocol, cprotocol); - return proxyInfo; -} - -typedef struct { - jobjectArray npHostArray; - JNIEnv *env; - int index; -} ListProcContext; - -// user_data is the ListProcContext -void listProc(gpointer data, gpointer user_data) { - ListProcContext *lpc = user_data; - jobject jnpHost = (*lpc->env)->NewStringUTF(lpc->env, (char *)data); - (*lpc->env)->SetObjectArrayElement(lpc->env, lpc->npHostArray, - lpc->index++, jnpHost); -} - -/* - * Class: org_eclipse_core_internal_net_UnixProxyProvider - * Method: getGSettingsNonProxyHosts - * Signature: ()[Ljava/lang/String; - */ -JNIEXPORT jobjectArray JNICALL Java_org_eclipse_core_internal_net_proxy_unix_UnixProxyProvider_getGSettingsNonProxyHosts( - JNIEnv *env, jclass clazz) { - - if (proxySettings == NULL) { - Java_org_eclipse_core_internal_net_proxy_unix_UnixProxyProvider_gsettingsInit(env, clazz); - } - - gchar **npfHostsArray; - GSList *npHosts = NULL; - gint size, i; - - npfHostsArray = g_settings_get_strv(proxySettings, "ignore-hosts"); - - for (i = 0; npfHostsArray[i] != NULL; i++) { - npHosts = g_slist_prepend(npHosts, npfHostsArray[i]); - } - - npHosts = g_slist_reverse(npHosts); - size = g_slist_length(npHosts); - jobjectArray ret = (*env)->NewObjectArray(env, size, stringClass, NULL); - - ListProcContext lpc; - lpc.env = env; - lpc.npHostArray = ret; - 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 deleted file mode 100644 index 8dab51c91..000000000 --- a/bundles/org.eclipse.core.net/natives/unix/gnomeproxy.h +++ /dev/null @@ -1,38 +0,0 @@ -/* DO NOT EDIT THIS FILE - it is machine generated */ -#include <jni.h> -/* Header for class org_eclipse_core_internal_net_proxy_unix_UnixProxyProvider */ - -#ifndef _Included_org_eclipse_core_internal_net_proxy_unix_UnixProxyProvider -#define _Included_org_eclipse_core_internal_net_proxy_unix_UnixProxyProvider -#ifdef __cplusplus -extern "C" { -#endif -/* Inaccessible static: isGnomeLibLoaded */ -/* - * Class: org_eclipse_core_internal_net_proxy_unix_UnixProxyProvider - * Method: gsettingsInit - * Signature: ()V - */ -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: getGSettingsProxyInfo - * Signature: (Ljava/lang/String;)Lorg/eclipse/core/internal/net/ProxyData; - */ -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: getGSettingsNonProxyHosts - * Signature: ()[Ljava/lang/String; - */ -JNIEXPORT jobjectArray JNICALL Java_org_eclipse_core_internal_net_proxy_unix_UnixProxyProvider_getGSettingsNonProxyHosts - (JNIEnv *, jclass); - -#ifdef __cplusplus -} -#endif -#endif diff --git a/bundles/org.eclipse.core.net/natives/unix/linux/makefile b/bundles/org.eclipse.core.net/natives/unix/linux/makefile deleted file mode 100644 index 040a594a4..000000000 --- a/bundles/org.eclipse.core.net/natives/unix/linux/makefile +++ /dev/null @@ -1,51 +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 submission -# IBM Corporation - refactoring, bug 245849 -# Red Hat - GSettings implementation and code clean up (bug 394087) -# -#********************************************************************** -# -# makefile for libgnomeproxy-1.0.0.so - -GNOMEPROXY.C = ../gnomeproxy.c -GNOMEPROXY.O = gnomeproxy.o -LIB_NAME = gnomeproxy.so -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 gio-2.0` -COMPILER_FLAGS = -O0 -fPIC -g3 -Wall -c -fmessage-length=0 ${TARGET_ENVIRONMENT} - -LIBS := `pkg-config --libs gio-2.0` -LINKER_FLAGS= ${TARGET_ENVIRONMENT} - -all: link - -compile: - @echo "Building file: $(GNOMEPROXY.O)" - @echo "Invoking: GCC C Compiler" - gcc $(INCLUDE) $(JDK_INCLUDE) $(COMPILER_FLAGS) -o $(GNOMEPROXY.O) $(GNOMEPROXY.C) - @echo "Finished building: $(GNOMEPROXY.O)" - @echo " " - -link: compile - @echo "Building target: $(LIB_NAME_FULL)" - @echo "Invoking: GCC C Linker" - gcc $(LINKER_FLAGS) -shared -Wl,-soname,$(LIB_NAME) -o $(LIB_NAME_FULL) $(LIBS) $(GNOMEPROXY.O) -lc - @echo "Finished building target: $(LIB_NAME_FULL)" - @echo " " - -clean: - -$(RM) $(GNOMEPROXY.O) $(LIB_NAME_FULL) - -@echo " " |
