Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTomasz Zarna2008-04-25 14:08:02 +0000
committerTomasz Zarna2008-04-25 14:08:02 +0000
commitbcc7457688a8f5dcf025adf7cd471bc527b5df5f (patch)
tree81a8034b4184123613f06144bd6af89f55f8e599 /bundles/org.eclipse.core.net/natives/unix
parent3d936c395c2e52bcaf250dc400a87918433302c9 (diff)
downloadeclipse.platform.team-bcc7457688a8f5dcf025adf7cd471bc527b5df5f.tar.gz
eclipse.platform.team-bcc7457688a8f5dcf025adf7cd471bc527b5df5f.tar.xz
eclipse.platform.team-bcc7457688a8f5dcf025adf7cd471bc527b5df5f.zip
bug 228738: support automatic proxy lookup mechanism for gnome
Diffstat (limited to 'bundles/org.eclipse.core.net/natives/unix')
-rw-r--r--bundles/org.eclipse.core.net/natives/unix/Debug/getsystemproxy.d226
-rw-r--r--bundles/org.eclipse.core.net/natives/unix/GetProxyGnome/makefile (renamed from bundles/org.eclipse.core.net/natives/unix/Debug/makefile)8
-rw-r--r--bundles/org.eclipse.core.net/natives/unix/GetProxyGnome/objects.mk (renamed from bundles/org.eclipse.core.net/natives/unix/Debug/objects.mk)0
-rw-r--r--bundles/org.eclipse.core.net/natives/unix/GetProxyGnome/sources.mk (renamed from bundles/org.eclipse.core.net/natives/unix/Debug/sources.mk)0
-rw-r--r--bundles/org.eclipse.core.net/natives/unix/GetProxyGnome/subdir.mk24
-rw-r--r--bundles/org.eclipse.core.net/natives/unix/getproxygnome.c214
6 files changed, 242 insertions, 230 deletions
diff --git a/bundles/org.eclipse.core.net/natives/unix/Debug/getsystemproxy.d b/bundles/org.eclipse.core.net/natives/unix/Debug/getsystemproxy.d
deleted file mode 100644
index 54ffd65ec..000000000
--- a/bundles/org.eclipse.core.net/natives/unix/Debug/getsystemproxy.d
+++ /dev/null
@@ -1,226 +0,0 @@
-getsystemproxy.d getsystemproxy.o: ../getsystemproxy.c \
- /usr/include/glib-2.0/glib.h /usr/include/glib-2.0/glib/galloca.h \
- /usr/include/glib-2.0/glib/gtypes.h \
- /usr/lib/glib-2.0/include/glibconfig.h \
- /usr/include/glib-2.0/glib/gmacros.h \
- /usr/include/glib-2.0/glib/garray.h \
- /usr/include/glib-2.0/glib/gasyncqueue.h \
- /usr/include/glib-2.0/glib/gthread.h \
- /usr/include/glib-2.0/glib/gerror.h /usr/include/glib-2.0/glib/gquark.h \
- /usr/include/glib-2.0/glib/gutils.h \
- /usr/include/glib-2.0/glib/gatomic.h \
- /usr/include/glib-2.0/glib/gbacktrace.h \
- /usr/include/glib-2.0/glib/gbase64.h \
- /usr/include/glib-2.0/glib/gbookmarkfile.h \
- /usr/include/glib-2.0/glib/gcache.h /usr/include/glib-2.0/glib/glist.h \
- /usr/include/glib-2.0/glib/gmem.h /usr/include/glib-2.0/glib/gslice.h \
- /usr/include/glib-2.0/glib/gcompletion.h \
- /usr/include/glib-2.0/glib/gconvert.h \
- /usr/include/glib-2.0/glib/gdataset.h \
- /usr/include/glib-2.0/glib/gdate.h /usr/include/glib-2.0/glib/gdir.h \
- /usr/include/glib-2.0/glib/gfileutils.h \
- /usr/include/glib-2.0/glib/ghash.h /usr/include/glib-2.0/glib/ghook.h \
- /usr/include/glib-2.0/glib/giochannel.h \
- /usr/include/glib-2.0/glib/gmain.h /usr/include/glib-2.0/glib/gslist.h \
- /usr/include/glib-2.0/glib/gstring.h \
- /usr/include/glib-2.0/glib/gunicode.h \
- /usr/include/glib-2.0/glib/gkeyfile.h \
- /usr/include/glib-2.0/glib/gmappedfile.h \
- /usr/include/glib-2.0/glib/gmarkup.h \
- /usr/include/glib-2.0/glib/gmessages.h \
- /usr/include/glib-2.0/glib/gnode.h /usr/include/glib-2.0/glib/goption.h \
- /usr/include/glib-2.0/glib/gpattern.h \
- /usr/include/glib-2.0/glib/gprimes.h \
- /usr/include/glib-2.0/glib/gqsort.h /usr/include/glib-2.0/glib/gqueue.h \
- /usr/include/glib-2.0/glib/grand.h /usr/include/glib-2.0/glib/grel.h \
- /usr/include/glib-2.0/glib/gregex.h \
- /usr/include/glib-2.0/glib/gscanner.h \
- /usr/include/glib-2.0/glib/gsequence.h \
- /usr/include/glib-2.0/glib/gshell.h /usr/include/glib-2.0/glib/gspawn.h \
- /usr/include/glib-2.0/glib/gstrfuncs.h \
- /usr/include/glib-2.0/glib/gthreadpool.h \
- /usr/include/glib-2.0/glib/gtimer.h /usr/include/glib-2.0/glib/gtree.h \
- /usr/include/gconf/2/gconf/gconf-value.h \
- /usr/include/gconf/2/gconf/gconf-error.h \
- /usr/include/gconf/2/gconf/gconf-client.h \
- /usr/include/glib-2.0/glib-object.h \
- /usr/include/glib-2.0/gobject/gboxed.h \
- /usr/include/glib-2.0/gobject/gtype.h \
- /usr/include/glib-2.0/gobject/genums.h \
- /usr/include/glib-2.0/gobject/gobject.h \
- /usr/include/glib-2.0/gobject/gvalue.h \
- /usr/include/glib-2.0/gobject/gparam.h \
- /usr/include/glib-2.0/gobject/gclosure.h \
- /usr/include/glib-2.0/gobject/gsignal.h \
- /usr/include/glib-2.0/gobject/gmarshal.h \
- /usr/include/glib-2.0/gobject/gparamspecs.h \
- /usr/include/glib-2.0/gobject/gsourceclosure.h \
- /usr/include/glib-2.0/gobject/gtypemodule.h \
- /usr/include/glib-2.0/gobject/gtypeplugin.h \
- /usr/include/glib-2.0/gobject/gvaluearray.h \
- /usr/include/glib-2.0/gobject/gvaluetypes.h \
- /usr/include/gconf/2/gconf/gconf.h \
- /usr/include/gconf/2/gconf/gconf-schema.h \
- /usr/include/gconf/2/gconf/gconf-engine.h \
- /usr/include/gconf/2/gconf/gconf-error.h \
- /usr/include/gconf/2/gconf/gconf-enum-types.h \
- /usr/include/gconf/2/gconf/gconf-listeners.h \
- /usr/include/gconf/2/gconf/gconf-changeset.h
-
-/usr/include/glib-2.0/glib.h:
-
-/usr/include/glib-2.0/glib/galloca.h:
-
-/usr/include/glib-2.0/glib/gtypes.h:
-
-/usr/lib/glib-2.0/include/glibconfig.h:
-
-/usr/include/glib-2.0/glib/gmacros.h:
-
-/usr/include/glib-2.0/glib/garray.h:
-
-/usr/include/glib-2.0/glib/gasyncqueue.h:
-
-/usr/include/glib-2.0/glib/gthread.h:
-
-/usr/include/glib-2.0/glib/gerror.h:
-
-/usr/include/glib-2.0/glib/gquark.h:
-
-/usr/include/glib-2.0/glib/gutils.h:
-
-/usr/include/glib-2.0/glib/gatomic.h:
-
-/usr/include/glib-2.0/glib/gbacktrace.h:
-
-/usr/include/glib-2.0/glib/gbase64.h:
-
-/usr/include/glib-2.0/glib/gbookmarkfile.h:
-
-/usr/include/glib-2.0/glib/gcache.h:
-
-/usr/include/glib-2.0/glib/glist.h:
-
-/usr/include/glib-2.0/glib/gmem.h:
-
-/usr/include/glib-2.0/glib/gslice.h:
-
-/usr/include/glib-2.0/glib/gcompletion.h:
-
-/usr/include/glib-2.0/glib/gconvert.h:
-
-/usr/include/glib-2.0/glib/gdataset.h:
-
-/usr/include/glib-2.0/glib/gdate.h:
-
-/usr/include/glib-2.0/glib/gdir.h:
-
-/usr/include/glib-2.0/glib/gfileutils.h:
-
-/usr/include/glib-2.0/glib/ghash.h:
-
-/usr/include/glib-2.0/glib/ghook.h:
-
-/usr/include/glib-2.0/glib/giochannel.h:
-
-/usr/include/glib-2.0/glib/gmain.h:
-
-/usr/include/glib-2.0/glib/gslist.h:
-
-/usr/include/glib-2.0/glib/gstring.h:
-
-/usr/include/glib-2.0/glib/gunicode.h:
-
-/usr/include/glib-2.0/glib/gkeyfile.h:
-
-/usr/include/glib-2.0/glib/gmappedfile.h:
-
-/usr/include/glib-2.0/glib/gmarkup.h:
-
-/usr/include/glib-2.0/glib/gmessages.h:
-
-/usr/include/glib-2.0/glib/gnode.h:
-
-/usr/include/glib-2.0/glib/goption.h:
-
-/usr/include/glib-2.0/glib/gpattern.h:
-
-/usr/include/glib-2.0/glib/gprimes.h:
-
-/usr/include/glib-2.0/glib/gqsort.h:
-
-/usr/include/glib-2.0/glib/gqueue.h:
-
-/usr/include/glib-2.0/glib/grand.h:
-
-/usr/include/glib-2.0/glib/grel.h:
-
-/usr/include/glib-2.0/glib/gregex.h:
-
-/usr/include/glib-2.0/glib/gscanner.h:
-
-/usr/include/glib-2.0/glib/gsequence.h:
-
-/usr/include/glib-2.0/glib/gshell.h:
-
-/usr/include/glib-2.0/glib/gspawn.h:
-
-/usr/include/glib-2.0/glib/gstrfuncs.h:
-
-/usr/include/glib-2.0/glib/gthreadpool.h:
-
-/usr/include/glib-2.0/glib/gtimer.h:
-
-/usr/include/glib-2.0/glib/gtree.h:
-
-/usr/include/gconf/2/gconf/gconf-value.h:
-
-/usr/include/gconf/2/gconf/gconf-error.h:
-
-/usr/include/gconf/2/gconf/gconf-client.h:
-
-/usr/include/glib-2.0/glib-object.h:
-
-/usr/include/glib-2.0/gobject/gboxed.h:
-
-/usr/include/glib-2.0/gobject/gtype.h:
-
-/usr/include/glib-2.0/gobject/genums.h:
-
-/usr/include/glib-2.0/gobject/gobject.h:
-
-/usr/include/glib-2.0/gobject/gvalue.h:
-
-/usr/include/glib-2.0/gobject/gparam.h:
-
-/usr/include/glib-2.0/gobject/gclosure.h:
-
-/usr/include/glib-2.0/gobject/gsignal.h:
-
-/usr/include/glib-2.0/gobject/gmarshal.h:
-
-/usr/include/glib-2.0/gobject/gparamspecs.h:
-
-/usr/include/glib-2.0/gobject/gsourceclosure.h:
-
-/usr/include/glib-2.0/gobject/gtypemodule.h:
-
-/usr/include/glib-2.0/gobject/gtypeplugin.h:
-
-/usr/include/glib-2.0/gobject/gvaluearray.h:
-
-/usr/include/glib-2.0/gobject/gvaluetypes.h:
-
-/usr/include/gconf/2/gconf/gconf.h:
-
-/usr/include/gconf/2/gconf/gconf-schema.h:
-
-/usr/include/gconf/2/gconf/gconf-engine.h:
-
-/usr/include/gconf/2/gconf/gconf-error.h:
-
-/usr/include/gconf/2/gconf/gconf-enum-types.h:
-
-/usr/include/gconf/2/gconf/gconf-listeners.h:
-
-/usr/include/gconf/2/gconf/gconf-changeset.h:
diff --git a/bundles/org.eclipse.core.net/natives/unix/Debug/makefile b/bundles/org.eclipse.core.net/natives/unix/GetProxyGnome/makefile
index c102989ca..a74fa321a 100644
--- a/bundles/org.eclipse.core.net/natives/unix/Debug/makefile
+++ b/bundles/org.eclipse.core.net/natives/unix/GetProxyGnome/makefile
@@ -22,19 +22,19 @@ endif
# Add inputs and outputs from these tool invocations to the build variables
# All Target
-all: libproxysupport.so
+all: libproxygnome.so
# Tool invocations
-libproxysupport.so: $(OBJS) $(USER_OBJS)
+libproxygnome.so: $(OBJS) $(USER_OBJS)
@echo 'Building target: $@'
@echo 'Invoking: GCC C Linker'
- gcc -m32 -shared -o"libproxysupport.so" $(OBJS) $(USER_OBJS) $(LIBS)
+ gcc -m32 -shared -o"libproxygnome.so" $(OBJS) $(USER_OBJS) $(LIBS)
@echo 'Finished building target: $@'
@echo ' '
# Other Targets
clean:
- -$(RM) $(OBJS)$(C_DEPS)$(LIBRARIES) libproxysupport.so
+ -$(RM) $(OBJS)$(C_DEPS)$(LIBRARIES) libproxygnome.so
-@echo ' '
.PHONY: all clean dependents
diff --git a/bundles/org.eclipse.core.net/natives/unix/Debug/objects.mk b/bundles/org.eclipse.core.net/natives/unix/GetProxyGnome/objects.mk
index a9828db0f..a9828db0f 100644
--- a/bundles/org.eclipse.core.net/natives/unix/Debug/objects.mk
+++ b/bundles/org.eclipse.core.net/natives/unix/GetProxyGnome/objects.mk
diff --git a/bundles/org.eclipse.core.net/natives/unix/Debug/sources.mk b/bundles/org.eclipse.core.net/natives/unix/GetProxyGnome/sources.mk
index 2b71575c4..2b71575c4 100644
--- a/bundles/org.eclipse.core.net/natives/unix/Debug/sources.mk
+++ b/bundles/org.eclipse.core.net/natives/unix/GetProxyGnome/sources.mk
diff --git a/bundles/org.eclipse.core.net/natives/unix/GetProxyGnome/subdir.mk b/bundles/org.eclipse.core.net/natives/unix/GetProxyGnome/subdir.mk
new file mode 100644
index 000000000..d4d2e6854
--- /dev/null
+++ b/bundles/org.eclipse.core.net/natives/unix/GetProxyGnome/subdir.mk
@@ -0,0 +1,24 @@
+################################################################################
+# Automatically-generated file. Do not edit!
+################################################################################
+
+# Add inputs and outputs from these tool invocations to the build variables
+C_SRCS += \
+../getproxygnome.c
+
+OBJS += \
+./getproxygnome.o
+
+C_DEPS += \
+./getproxygnome.d
+
+
+# Each subdirectory must supply rules for building sources it contributes
+%.o: ../%.c
+ @echo 'Building file: $<'
+ @echo 'Invoking: GCC C Compiler'
+ gcc -I/usr/include/gconf/2 -I/usr/include/orbit-2.0 -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include/ -O0 -fPIC -g3 -Wall -c -fmessage-length=0 -m32 -MMD -MP -MF"$(@:%.o=%.d)" -MT"$(@:%.o=%.d)" -o"$@" "$<"
+ @echo 'Finished building: $<'
+ @echo ' '
+
+
diff --git a/bundles/org.eclipse.core.net/natives/unix/getproxygnome.c b/bundles/org.eclipse.core.net/natives/unix/getproxygnome.c
new file mode 100644
index 000000000..1444fb34c
--- /dev/null
+++ b/bundles/org.eclipse.core.net/natives/unix/getproxygnome.c
@@ -0,0 +1,214 @@
+/*
+ * Copyright 2008 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
+ */
+
+#include <jni.h>
+
+#include <glib.h>
+#include <glib/gslist.h>
+#include <gconf/gconf-value.h>
+#include <gconf/gconf-client.h>
+
+#ifdef __linux__
+#include <string.h>
+#else
+#include <strings.h>
+#endif
+
+static GConfClient *client= 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__); }
+
+static void gconfInit(JNIEnv *env) {
+ client = gconf_client_get_default();
+ 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: getGConfProxyInfo
+ * Signature: ([Ljava/lang/String);
+ */
+JNIEXPORT jobject JNICALL Java_org_eclipse_core_internal_net_proxy_unix_UnixProxyProvider_getGConfProxyInfo(
+ JNIEnv *env, jclass clazz, jstring protocol) {
+
+ jboolean isCopy;
+ const char *cprotocol;
+
+ jobject proxyInfo= NULL;
+
+ if (client == NULL) {
+ gconfInit(env);
+ }
+
+ CHECK_NULL(proxyInfo = (*env)->NewObject(env, proxyInfoClass, proxyInfoConstructor, protocol));
+
+ cprotocol = (*env)->GetStringUTFChars(env, protocol, &isCopy);
+ 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);
+
+ if (strcasecmp(cprotocol, "http") == 0 || useSame) {
+ gboolean useProxy = gconf_client_get_bool(client,
+ "/system/http_proxy/use_http_proxy", NULL);
+ if (!useProxy) {
+ proxyInfo = NULL;
+ goto exit;
+ }
+
+ gchar *host = gconf_client_get_string(client,
+ "/system/http_proxy/host", NULL);
+ jobject jhost = (*env)->NewStringUTF(env, host);
+ (*env)->CallVoidMethod(env, proxyInfo, hostMethod, jhost);
+
+ gint port = gconf_client_get_int(client, "/system/http_proxy/port",
+ NULL);
+ (*env)->CallVoidMethod(env, proxyInfo, portMethod, port);
+
+ gboolean reqAuth = gconf_client_get_bool(client,
+ "/system/http_proxy/use_authentication", NULL);
+ if (reqAuth) {
+
+ gchar *user = gconf_client_get_string(client,
+ "/system/http_proxy/authentication_user", NULL);
+ 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);
+ jobject jpassword = (*env)->NewStringUTF(env, password);
+ (*env)->CallVoidMethod(env, proxyInfo, passwordMethod,
+ jpassword);
+ }
+ goto exit;
+ }
+
+ // Everything else applies only if the system proxy mode is manual
+ gchar *mode = gconf_client_get_string(client, "/system/proxy/mode", NULL);
+ if (strcasecmp(mode, "manual") != 0) {
+ proxyInfo = NULL;
+ goto exit;
+ }
+
+ char selector[100];
+
+ if (strcasecmp(cprotocol, "https") == 0) {
+ strcpy(selector, "/system/proxy/secure_");
+ } else if (strcasecmp(cprotocol, "socks") == 0) {
+ strcpy(selector, "/system/proxy/socks_");
+ } else if (strcasecmp(cprotocol, "ftp") == 0) {
+ strcpy(selector, "/system/proxy/ftp_");
+ } 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);
+
+ 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: getGConfNonProxyHosts
+ * Signature: ()[Ljava/lang/String;
+ */
+JNIEXPORT jobjectArray JNICALL Java_org_eclipse_core_internal_net_proxy_unix_UnixProxyProvider_getGConfNonProxyHosts(
+ JNIEnv *env, jclass clazz) {
+
+ if (client == NULL) {
+ gconfInit(env);
+ }
+
+ GSList *npHosts;
+ int size;
+
+ npHosts = gconf_client_get_list(client, "/system/http_proxy/ignore_hosts",
+ GCONF_VALUE_STRING, NULL);
+ size = g_slist_length(npHosts);
+
+ // 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);
+ }
+ 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);
+ return ret;
+}
+

Back to the top