Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
View | Details | Raw Unified | Return to bug 226462 | Differences between
and this patch

Collapse All | Expand All

(-)src/org/eclipse/core/tests/net/NetTest.java (-1 / +103 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2007 IBM Corporation and others.
2
 * Copyright (c) 2007, 2008 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 7-20 Link Here
7
 *
7
 *
8
 * Contributors:
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
9
 *     IBM Corporation - initial API and implementation
10
 *     Oakland Software Incorporated - added proxy test
10
 *******************************************************************************/
11
 *******************************************************************************/
11
package org.eclipse.core.tests.net;
12
package org.eclipse.core.tests.net;
12
13
14
import java.net.URI;
13
import java.util.*;
15
import java.util.*;
14
16
15
import junit.framework.*;
17
import junit.framework.*;
16
18
19
import org.eclipse.core.internal.net.AbstractProxyProvider;
17
import org.eclipse.core.internal.net.ProxyType;
20
import org.eclipse.core.internal.net.ProxyType;
21
import org.eclipse.core.internal.net.proxy.unix.UnixProxyProvider;
18
import org.eclipse.core.net.proxy.IProxyData;
22
import org.eclipse.core.net.proxy.IProxyData;
19
import org.eclipse.core.net.proxy.IProxyService;
23
import org.eclipse.core.net.proxy.IProxyService;
20
import org.eclipse.core.runtime.CoreException;
24
import org.eclipse.core.runtime.CoreException;
Lines 298-301 Link Here
298
		this.getProxyManager().setNonProxiedHosts(oldHosts);
302
		this.getProxyManager().setNonProxiedHosts(oldHosts);
299
	}
303
	}
300
304
305
	// This test case has to be manually setup and run because it depends on
306
	// whether the proxy is set in the native environment. It is here as
307
	// a convenience to test the native support.
308
	public void testProxyNativeLinux() throws Exception {
309
310
		// Leave this test off for the automatic test runs so we don't
311
		// get confused by the settings that happen to be on the test machine
312
		if (true)
313
			return;
314
		
315
		UnixProxyProvider._debug = true;
316
317
		AbstractProxyProvider pp = new UnixProxyProvider();
318
319
		IProxyData[] pd;
320
321
		// Test the following cases
322
		// 1) No proxy set anywhere
323
		// 2) http_proxy environment variable (use proxyIsSet)
324
		// 3) gconf-edit proxy (use proxyIsSet and proxyAuthIsSet)
325
		// 4) KDE proxy (use proxyIsSet and proxyAuthIsSet)
326
327
		// Toggle this if you have the proxy set up in the native environment
328
		boolean proxyNativeIsSet = true;
329
330
		// Toggle this if you have the proxy authentication information setup
331
		boolean proxyAuthIsSet = true;
332
333
		// Toggle this if you have the proxy set up in GNOME
334
		boolean proxyGnomeIsSet = !true;
335
336
		String proxyHost = null;
337
		String proxyUser = null;
338
		String proxyPassword = null;
339
		boolean proxyReqAuth = false;
340
		int proxyPort = 0;
341
342
		if (proxyNativeIsSet || proxyGnomeIsSet) {
343
			proxyHost = "berlioz";
344
			proxyPort = 3128;
345
			if (proxyAuthIsSet) {
346
				proxyUser = "user";
347
				proxyPassword = "password";
348
				proxyReqAuth = true;
349
			}
350
		}
351
352
		// Test HTTP
353
		pd = pp.select(new URI("http://bbc.com"));
354
		if (proxyNativeIsSet || proxyGnomeIsSet) {
355
			assertEquals(1, pd.length);
356
			assertEquals(proxyHost, pd[0].getHost());
357
			assertEquals(proxyPort, pd[0].getPort());
358
			if (proxyAuthIsSet) {
359
				assertEquals(proxyUser, pd[0].getUserId());
360
				assertEquals(proxyPassword, pd[0].getPassword());
361
				assertEquals(proxyReqAuth, pd[0].isRequiresAuthentication());
362
			}
363
364
		} else {
365
			assertEquals(0, pd.length);
366
		}
367
368
		// Test HTTPS
369
		pd = pp.select(new URI("https://bbc.com"));
370
		if (proxyGnomeIsSet) {
371
			assertEquals(1, pd.length);
372
			assertEquals("https_" + proxyHost, pd[0].getHost());
373
			assertEquals(1 + proxyPort, pd[0].getPort());
374
		} else {
375
			assertEquals(0, pd.length);
376
		}
377
378
		// Test SOCKS
379
		pd = pp.select(new URI("SOCKS://bbc.com"));
380
		if (proxyGnomeIsSet) {
381
			assertEquals(1, pd.length);
382
			assertEquals("socks_" + proxyHost, pd[0].getHost());
383
			assertEquals(2 + proxyPort, pd[0].getPort());
384
		} else {
385
			assertEquals(0, pd.length);
386
		}
387
388
		// Test FTP
389
		pd = pp.select(new URI("FTP://bbc.com"));
390
		if (proxyGnomeIsSet) {
391
			assertEquals(1, pd.length);
392
			assertEquals("ftp_" + proxyHost, pd[0].getHost());
393
			assertEquals(3 + proxyPort, pd[0].getPort());
394
		} else {
395
			assertEquals(0, pd.length);
396
		}
397
398
		// Assume that localhost is a non-proxy host
399
		pd = pp.select(new URI("http://localhost"));
400
		assertEquals(0, pd.length);
401
	}
402
301
}
403
}
(-)fragments/org.eclipse.core.net.linux.x86/build.properties (-1 / +2 lines)
Lines 12-18 Link Here
12
               .,\
12
               .,\
13
               META-INF/,\
13
               META-INF/,\
14
               about.html,\
14
               about.html,\
15
               libproxysupport.so,\
15
               libproxyenv.so,\
16
               libproxygnome.so,\
16
               bin/
17
               bin/
17
src.includes = about.html
18
src.includes = about.html
18
generateSourceBundle=false
19
generateSourceBundle=false
(-)natives/unix/Debug/objects.mk (-7 lines)
Removed Link Here
1
################################################################################
2
# Automatically-generated file. Do not edit!
3
################################################################################
4
5
USER_OBJS :=
6
7
LIBS := -lgconf-2 -lORBit-2 -lgthread-2.0 -lrt -lgobject-2.0 -lglib-2.0
(-)natives/unix/Debug/sources.mk (-17 lines)
Removed Link Here
1
################################################################################
2
# Automatically-generated file. Do not edit!
3
################################################################################
4
5
O_SRCS := 
6
C_SRCS := 
7
S_SRCS := 
8
OBJ_SRCS := 
9
ASM_SRCS := 
10
OBJS := 
11
C_DEPS := 
12
LIBRARIES := 
13
14
# Every subdirectory with source files must be described here
15
SUBDIRS := \
16
. \
17
(-)natives/unix/Debug/subdir.mk (-24 lines)
Removed Link Here
1
################################################################################
2
# Automatically-generated file. Do not edit!
3
################################################################################
4
5
# Add inputs and outputs from these tool invocations to the build variables 
6
C_SRCS += \
7
../getsystemproxy.c 
8
9
OBJS += \
10
./getsystemproxy.o 
11
12
C_DEPS += \
13
./getsystemproxy.d 
14
15
16
# Each subdirectory must supply rules for building sources it contributes
17
%.o: ../%.c
18
	@echo 'Building file: $<'
19
	@echo 'Invoking: GCC C Compiler'
20
	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"$@" "$<"
21
	@echo 'Finished building: $<'
22
	@echo ' '
23
24
(-)natives/unix/Debug/makefile (-43 lines)
Removed Link Here
1
################################################################################
2
# Automatically-generated file. Do not edit!
3
################################################################################
4
5
-include ../makefile.init
6
7
RM := rm -rf
8
9
# All of the sources participating in the build are defined here
10
-include sources.mk
11
-include subdir.mk
12
-include objects.mk
13
14
ifneq ($(MAKECMDGOALS),clean)
15
ifneq ($(strip $(C_DEPS)),)
16
-include $(C_DEPS)
17
endif
18
endif
19
20
-include ../makefile.defs
21
22
# Add inputs and outputs from these tool invocations to the build variables 
23
24
# All Target
25
all: libproxysupport.so
26
27
# Tool invocations
28
libproxysupport.so: $(OBJS) $(USER_OBJS)
29
	@echo 'Building target: $@'
30
	@echo 'Invoking: GCC C Linker'
31
	gcc -m32 -shared -o"libproxysupport.so" $(OBJS) $(USER_OBJS) $(LIBS)
32
	@echo 'Finished building target: $@'
33
	@echo ' '
34
35
# Other Targets
36
clean:
37
	-$(RM) $(OBJS)$(C_DEPS)$(LIBRARIES) libproxysupport.so
38
	-@echo ' '
39
40
.PHONY: all clean dependents
41
.SECONDARY:
42
43
-include ../makefile.targets
(-)natives/unix/Debug/getsystemproxy.d (-226 lines)
Removed Link Here
1
getsystemproxy.d getsystemproxy.o: ../getsystemproxy.c \
2
  /usr/include/glib-2.0/glib.h /usr/include/glib-2.0/glib/galloca.h \
3
  /usr/include/glib-2.0/glib/gtypes.h \
4
  /usr/lib/glib-2.0/include/glibconfig.h \
5
  /usr/include/glib-2.0/glib/gmacros.h \
6
  /usr/include/glib-2.0/glib/garray.h \
7
  /usr/include/glib-2.0/glib/gasyncqueue.h \
8
  /usr/include/glib-2.0/glib/gthread.h \
9
  /usr/include/glib-2.0/glib/gerror.h /usr/include/glib-2.0/glib/gquark.h \
10
  /usr/include/glib-2.0/glib/gutils.h \
11
  /usr/include/glib-2.0/glib/gatomic.h \
12
  /usr/include/glib-2.0/glib/gbacktrace.h \
13
  /usr/include/glib-2.0/glib/gbase64.h \
14
  /usr/include/glib-2.0/glib/gbookmarkfile.h \
15
  /usr/include/glib-2.0/glib/gcache.h /usr/include/glib-2.0/glib/glist.h \
16
  /usr/include/glib-2.0/glib/gmem.h /usr/include/glib-2.0/glib/gslice.h \
17
  /usr/include/glib-2.0/glib/gcompletion.h \
18
  /usr/include/glib-2.0/glib/gconvert.h \
19
  /usr/include/glib-2.0/glib/gdataset.h \
20
  /usr/include/glib-2.0/glib/gdate.h /usr/include/glib-2.0/glib/gdir.h \
21
  /usr/include/glib-2.0/glib/gfileutils.h \
22
  /usr/include/glib-2.0/glib/ghash.h /usr/include/glib-2.0/glib/ghook.h \
23
  /usr/include/glib-2.0/glib/giochannel.h \
24
  /usr/include/glib-2.0/glib/gmain.h /usr/include/glib-2.0/glib/gslist.h \
25
  /usr/include/glib-2.0/glib/gstring.h \
26
  /usr/include/glib-2.0/glib/gunicode.h \
27
  /usr/include/glib-2.0/glib/gkeyfile.h \
28
  /usr/include/glib-2.0/glib/gmappedfile.h \
29
  /usr/include/glib-2.0/glib/gmarkup.h \
30
  /usr/include/glib-2.0/glib/gmessages.h \
31
  /usr/include/glib-2.0/glib/gnode.h /usr/include/glib-2.0/glib/goption.h \
32
  /usr/include/glib-2.0/glib/gpattern.h \
33
  /usr/include/glib-2.0/glib/gprimes.h \
34
  /usr/include/glib-2.0/glib/gqsort.h /usr/include/glib-2.0/glib/gqueue.h \
35
  /usr/include/glib-2.0/glib/grand.h /usr/include/glib-2.0/glib/grel.h \
36
  /usr/include/glib-2.0/glib/gregex.h \
37
  /usr/include/glib-2.0/glib/gscanner.h \
38
  /usr/include/glib-2.0/glib/gsequence.h \
39
  /usr/include/glib-2.0/glib/gshell.h /usr/include/glib-2.0/glib/gspawn.h \
40
  /usr/include/glib-2.0/glib/gstrfuncs.h \
41
  /usr/include/glib-2.0/glib/gthreadpool.h \
42
  /usr/include/glib-2.0/glib/gtimer.h /usr/include/glib-2.0/glib/gtree.h \
43
  /usr/include/gconf/2/gconf/gconf-value.h \
44
  /usr/include/gconf/2/gconf/gconf-error.h \
45
  /usr/include/gconf/2/gconf/gconf-client.h \
46
  /usr/include/glib-2.0/glib-object.h \
47
  /usr/include/glib-2.0/gobject/gboxed.h \
48
  /usr/include/glib-2.0/gobject/gtype.h \
49
  /usr/include/glib-2.0/gobject/genums.h \
50
  /usr/include/glib-2.0/gobject/gobject.h \
51
  /usr/include/glib-2.0/gobject/gvalue.h \
52
  /usr/include/glib-2.0/gobject/gparam.h \
53
  /usr/include/glib-2.0/gobject/gclosure.h \
54
  /usr/include/glib-2.0/gobject/gsignal.h \
55
  /usr/include/glib-2.0/gobject/gmarshal.h \
56
  /usr/include/glib-2.0/gobject/gparamspecs.h \
57
  /usr/include/glib-2.0/gobject/gsourceclosure.h \
58
  /usr/include/glib-2.0/gobject/gtypemodule.h \
59
  /usr/include/glib-2.0/gobject/gtypeplugin.h \
60
  /usr/include/glib-2.0/gobject/gvaluearray.h \
61
  /usr/include/glib-2.0/gobject/gvaluetypes.h \
62
  /usr/include/gconf/2/gconf/gconf.h \
63
  /usr/include/gconf/2/gconf/gconf-schema.h \
64
  /usr/include/gconf/2/gconf/gconf-engine.h \
65
  /usr/include/gconf/2/gconf/gconf-error.h \
66
  /usr/include/gconf/2/gconf/gconf-enum-types.h \
67
  /usr/include/gconf/2/gconf/gconf-listeners.h \
68
  /usr/include/gconf/2/gconf/gconf-changeset.h
69
70
/usr/include/glib-2.0/glib.h:
71
72
/usr/include/glib-2.0/glib/galloca.h:
73
74
/usr/include/glib-2.0/glib/gtypes.h:
75
76
/usr/lib/glib-2.0/include/glibconfig.h:
77
78
/usr/include/glib-2.0/glib/gmacros.h:
79
80
/usr/include/glib-2.0/glib/garray.h:
81
82
/usr/include/glib-2.0/glib/gasyncqueue.h:
83
84
/usr/include/glib-2.0/glib/gthread.h:
85
86
/usr/include/glib-2.0/glib/gerror.h:
87
88
/usr/include/glib-2.0/glib/gquark.h:
89
90
/usr/include/glib-2.0/glib/gutils.h:
91
92
/usr/include/glib-2.0/glib/gatomic.h:
93
94
/usr/include/glib-2.0/glib/gbacktrace.h:
95
96
/usr/include/glib-2.0/glib/gbase64.h:
97
98
/usr/include/glib-2.0/glib/gbookmarkfile.h:
99
100
/usr/include/glib-2.0/glib/gcache.h:
101
102
/usr/include/glib-2.0/glib/glist.h:
103
104
/usr/include/glib-2.0/glib/gmem.h:
105
106
/usr/include/glib-2.0/glib/gslice.h:
107
108
/usr/include/glib-2.0/glib/gcompletion.h:
109
110
/usr/include/glib-2.0/glib/gconvert.h:
111
112
/usr/include/glib-2.0/glib/gdataset.h:
113
114
/usr/include/glib-2.0/glib/gdate.h:
115
116
/usr/include/glib-2.0/glib/gdir.h:
117
118
/usr/include/glib-2.0/glib/gfileutils.h:
119
120
/usr/include/glib-2.0/glib/ghash.h:
121
122
/usr/include/glib-2.0/glib/ghook.h:
123
124
/usr/include/glib-2.0/glib/giochannel.h:
125
126
/usr/include/glib-2.0/glib/gmain.h:
127
128
/usr/include/glib-2.0/glib/gslist.h:
129
130
/usr/include/glib-2.0/glib/gstring.h:
131
132
/usr/include/glib-2.0/glib/gunicode.h:
133
134
/usr/include/glib-2.0/glib/gkeyfile.h:
135
136
/usr/include/glib-2.0/glib/gmappedfile.h:
137
138
/usr/include/glib-2.0/glib/gmarkup.h:
139
140
/usr/include/glib-2.0/glib/gmessages.h:
141
142
/usr/include/glib-2.0/glib/gnode.h:
143
144
/usr/include/glib-2.0/glib/goption.h:
145
146
/usr/include/glib-2.0/glib/gpattern.h:
147
148
/usr/include/glib-2.0/glib/gprimes.h:
149
150
/usr/include/glib-2.0/glib/gqsort.h:
151
152
/usr/include/glib-2.0/glib/gqueue.h:
153
154
/usr/include/glib-2.0/glib/grand.h:
155
156
/usr/include/glib-2.0/glib/grel.h:
157
158
/usr/include/glib-2.0/glib/gregex.h:
159
160
/usr/include/glib-2.0/glib/gscanner.h:
161
162
/usr/include/glib-2.0/glib/gsequence.h:
163
164
/usr/include/glib-2.0/glib/gshell.h:
165
166
/usr/include/glib-2.0/glib/gspawn.h:
167
168
/usr/include/glib-2.0/glib/gstrfuncs.h:
169
170
/usr/include/glib-2.0/glib/gthreadpool.h:
171
172
/usr/include/glib-2.0/glib/gtimer.h:
173
174
/usr/include/glib-2.0/glib/gtree.h:
175
176
/usr/include/gconf/2/gconf/gconf-value.h:
177
178
/usr/include/gconf/2/gconf/gconf-error.h:
179
180
/usr/include/gconf/2/gconf/gconf-client.h:
181
182
/usr/include/glib-2.0/glib-object.h:
183
184
/usr/include/glib-2.0/gobject/gboxed.h:
185
186
/usr/include/glib-2.0/gobject/gtype.h:
187
188
/usr/include/glib-2.0/gobject/genums.h:
189
190
/usr/include/glib-2.0/gobject/gobject.h:
191
192
/usr/include/glib-2.0/gobject/gvalue.h:
193
194
/usr/include/glib-2.0/gobject/gparam.h:
195
196
/usr/include/glib-2.0/gobject/gclosure.h:
197
198
/usr/include/glib-2.0/gobject/gsignal.h:
199
200
/usr/include/glib-2.0/gobject/gmarshal.h:
201
202
/usr/include/glib-2.0/gobject/gparamspecs.h:
203
204
/usr/include/glib-2.0/gobject/gsourceclosure.h:
205
206
/usr/include/glib-2.0/gobject/gtypemodule.h:
207
208
/usr/include/glib-2.0/gobject/gtypeplugin.h:
209
210
/usr/include/glib-2.0/gobject/gvaluearray.h:
211
212
/usr/include/glib-2.0/gobject/gvaluetypes.h:
213
214
/usr/include/gconf/2/gconf/gconf.h:
215
216
/usr/include/gconf/2/gconf/gconf-schema.h:
217
218
/usr/include/gconf/2/gconf/gconf-engine.h:
219
220
/usr/include/gconf/2/gconf/gconf-error.h:
221
222
/usr/include/gconf/2/gconf/gconf-enum-types.h:
223
224
/usr/include/gconf/2/gconf/gconf-listeners.h:
225
226
/usr/include/gconf/2/gconf/gconf-changeset.h:
(-)src/org/eclipse/core/internal/net/Activator.java (+4 lines)
Lines 85-90 Link Here
85
		getInstance().log(new Status(IStatus.INFO, ID, 0, message, exc));
85
		getInstance().log(new Status(IStatus.INFO, ID, 0, message, exc));
86
	}
86
	}
87
87
88
	public static void logWarning(String message, Throwable exc) {
89
		getInstance().log(new Status(IStatus.WARNING, ID, 0, message, exc));
90
	}
91
88
	/*
92
	/*
89
	 * Log the given status to the log file. If the log is not available, log
93
	 * Log the given status to the log file. If the log is not available, log
90
	 * the status to the console.
94
	 * the status to the console.
(-)META-INF/MANIFEST.MF (+1 lines)
Lines 13-18 Link Here
13
 org.eclipse.equinox.registry;bundle-version="3.4.0"
13
 org.eclipse.equinox.registry;bundle-version="3.4.0"
14
Bundle-ActivationPolicy: lazy
14
Bundle-ActivationPolicy: lazy
15
Export-Package: org.eclipse.core.internal.net;x-internal:=true,
15
Export-Package: org.eclipse.core.internal.net;x-internal:=true,
16
 org.eclipse.core.internal.net.proxy.unix;x-internal:=true, 
16
 org.eclipse.core.net.proxy
17
 org.eclipse.core.net.proxy
17
Bundle-RequiredExecutionEnvironment: J2SE-1.4,
18
Bundle-RequiredExecutionEnvironment: J2SE-1.4,
18
 CDC-1.0/Foundation-1.0,
19
 CDC-1.0/Foundation-1.0,
(-)natives/unix/getsystemproxy.c (-237 lines)
Removed Link Here
1
/*
2
 * Copyright 2008 Oakland Software Incorporated and others
3
 * All rights reserved. This program and the accompanying materials 
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 * 
8
 * Contributors:
9
 *     Oakland Software Incorporated - initial API and implementation
10
 */
11
12
#include <jni.h>
13
14
#include <glib.h>
15
#include <glib/gslist.h>
16
#include <gconf/gconf-value.h>
17
#include <gconf/gconf-client.h>
18
19
#ifdef __linux__
20
#include <string.h>
21
#else
22
#include <strings.h>
23
#endif
24
25
static GConfClient *client= NULL;
26
27
static jclass proxyInfoClass;
28
static jclass stringClass;
29
static jmethodID proxyInfoConstructor;
30
static jmethodID toString;
31
32
static jmethodID hostMethod;
33
static jmethodID portMethod;
34
static jmethodID requiresAuthenticationMethod;
35
static jmethodID userMethod;
36
static jmethodID passwordMethod;
37
38
#define CHECK_NULL(X) { if ((X) == NULL) fprintf (stderr,"JNI error at line %d\n", __LINE__); } 
39
40
static void gconfInit(JNIEnv *env) {
41
	client = gconf_client_get_default();
42
	jclass cls= NULL;
43
	CHECK_NULL(cls = (*env)->FindClass(env, "org/eclipse/core/internal/net/ProxyData"));
44
	proxyInfoClass = (*env)->NewGlobalRef(env, cls);
45
46
	CHECK_NULL(cls = (*env)->FindClass(env, "java/lang/String"));
47
	stringClass = (*env)->NewGlobalRef(env, cls);
48
49
	CHECK_NULL(proxyInfoConstructor = (*env)->GetMethodID(env, proxyInfoClass, "<init>", "(Ljava/lang/String;)V"));
50
51
	CHECK_NULL(toString = (*env)->GetMethodID(env, proxyInfoClass, "toString", "()Ljava/lang/String;"));
52
53
	CHECK_NULL(hostMethod = (*env)->GetMethodID(env, proxyInfoClass, "setHost",
54
					"(Ljava/lang/String;)V"));
55
	CHECK_NULL(portMethod = (*env)->GetMethodID(env, proxyInfoClass, "setPort",
56
					"(I)V"));
57
	CHECK_NULL(requiresAuthenticationMethod= (*env)->GetMethodID(env, proxyInfoClass, "setRequiresAuthentication",
58
					"(Z)V"));
59
	CHECK_NULL(userMethod = (*env)->GetMethodID(env, proxyInfoClass, "setUserid",
60
					"(Ljava/lang/String;)V"));
61
	CHECK_NULL(passwordMethod = (*env)->GetMethodID(env, proxyInfoClass, "setPassword",
62
					"(Ljava/lang/String;)V"));
63
}
64
65
/*
66
 * Class:     org_eclipse_core_internal_net_UnixProxyProvider
67
 * Method:    getGConfProxyInfo
68
 * Signature: ([Ljava/lang/String);
69
 */
70
JNIEXPORT jobject JNICALL Java_org_eclipse_core_internal_net_UnixProxyProvider_getGConfProxyInfo(
71
		JNIEnv *env, jclass clazz, jstring protocol) {
72
73
	jboolean isCopy;
74
	const char *cprotocol;
75
76
	jobject proxyInfo= NULL;
77
78
	if (client == NULL) {
79
		gconfInit(env);
80
	}
81
82
	CHECK_NULL(proxyInfo = (*env)->NewObject(env, proxyInfoClass, proxyInfoConstructor, protocol));
83
84
	cprotocol = (*env)->GetStringUTFChars(env, protocol, &isCopy);
85
	if (cprotocol == NULL)
86
		return NULL;
87
88
	//printf("cprotocol: %s\n", cprotocol);
89
90
	if (strcasecmp(cprotocol, "http") == 0) {
91
		gboolean useProxy = gconf_client_get_bool(client,
92
				"/system/http_proxy/use_http_proxy", NULL);
93
		if (!useProxy) {
94
			proxyInfo = NULL;
95
			goto exit;
96
		}
97
98
		gchar *host = gconf_client_get_string(client,
99
				"/system/http_proxy/host", NULL);
100
		jobject jhost = (*env)->NewStringUTF(env, host);
101
		(*env)->CallVoidMethod(env, proxyInfo, hostMethod, jhost);
102
103
		gint port = gconf_client_get_int(client, "/system/http_proxy/port",
104
				NULL);
105
		(*env)->CallVoidMethod(env, proxyInfo, portMethod, port);
106
107
		gboolean reqAuth = gconf_client_get_bool(client,
108
				"/system/http_proxy/use_authentication", NULL);
109
		(*env)->CallVoidMethod(env, proxyInfo,
110
				requiresAuthenticationMethod, reqAuth);
111
		if (reqAuth) {
112
113
			gchar *user = gconf_client_get_string(client,
114
					"/system/http_proxy/authentication_user", NULL);
115
			jobject juser = (*env)->NewStringUTF(env, user);
116
			(*env)->CallVoidMethod(env, proxyInfo, userMethod, juser);
117
118
			gchar *password = gconf_client_get_string(client,
119
					"/system/http_proxy/authentication_password", NULL);
120
			jobject jpassword = (*env)->NewStringUTF(env, password);
121
			(*env)->CallVoidMethod(env, proxyInfo, passwordMethod,
122
					jpassword);
123
		}
124
		goto exit;
125
	}
126
127
	// Everything else applies only if the system proxy mode is manual
128
	gchar *mode = gconf_client_get_string(client, "/system/proxy/mode", NULL);
129
	if (strcasecmp(mode, "manual") != 0) {
130
		proxyInfo = NULL;
131
		goto exit;
132
	}
133
134
	char selector[100];
135
136
	if (strcasecmp(cprotocol, "https") == 0) {
137
		strcpy(selector, "/system/proxy/secure_");
138
	} else if (strcasecmp(cprotocol, "socks") == 0) {
139
		strcpy(selector, "/system/proxy/socks_");
140
	} else if (strcasecmp(cprotocol, "ftp") == 0) {
141
		strcpy(selector, "/system/proxy/ftp_");
142
	} else {
143
		proxyInfo = NULL;
144
		goto exit;
145
	}
146
147
	char useSelector[100];
148
	strcpy(useSelector, selector);
149
150
	gchar *host = gconf_client_get_string(client, strcat(useSelector, "host"),
151
			NULL);
152
	jobject jhost = (*env)->NewStringUTF(env, host);
153
	(*env)->CallVoidMethod(env, proxyInfo, hostMethod, jhost);
154
155
	strcpy(useSelector, selector);
156
	gint port = gconf_client_get_int(client, strcat(useSelector, "port"), NULL);
157
	(*env)->CallVoidMethod(env, proxyInfo, portMethod, port);
158
159
	exit: if (isCopy == JNI_TRUE)
160
		(*env)->ReleaseStringUTFChars(env, protocol, cprotocol);
161
	return proxyInfo;
162
}
163
164
typedef struct {
165
	jobjectArray npHostArray;
166
	JNIEnv *env;
167
	int index;
168
} ListProcContext;
169
170
// user_data is the ListProcContext
171
void listProc(gpointer data, gpointer user_data) {
172
	ListProcContext *lpc = user_data;
173
	jobject jnpHost = (*lpc->env)->NewStringUTF(lpc->env, (char *)data);
174
	(*lpc->env)->SetObjectArrayElement(lpc->env, lpc->npHostArray,
175
			lpc->index++, jnpHost);
176
}
177
178
/*
179
 * Class:     org_eclipse_core_internal_net_UnixProxyProvider
180
 * Method:    getGConfNonProxyHosts
181
 * Signature: ()[Ljava/lang/String;
182
 */
183
JNIEXPORT jobjectArray JNICALL Java_org_eclipse_core_internal_net_UnixProxyProvider_getGConfNonProxyHosts(
184
		JNIEnv *env, jclass clazz) {
185
186
	if (client == NULL) {
187
		gconfInit(env);
188
	}
189
190
	GSList *npHosts;
191
	int size;
192
193
	npHosts = gconf_client_get_list(client, "/system/http_proxy/ignore_hosts",
194
			GCONF_VALUE_STRING, NULL);
195
	size = g_slist_length(npHosts);
196
197
	// TODO - I'm not sure this is really valid, it's from the JVM implementation
198
	// of ProxySelector
199
	if (size == 0) {
200
		npHosts = gconf_client_get_list(client, "/system/proxy/no_proxy_for",
201
				GCONF_VALUE_STRING, NULL);
202
	}
203
	size = g_slist_length(npHosts);
204
205
	jobjectArray ret = (*env)->NewObjectArray(env, size, stringClass, NULL);
206
207
	ListProcContext lpc;
208
	lpc.env = env;
209
	lpc.npHostArray = ret;
210
	lpc.index = 0;
211
212
	g_slist_foreach(npHosts, listProc, &lpc);
213
	return ret;
214
}
215
216
/*
217
 * Class:     org_eclipse_core_internal_net_UnixProxyProvider
218
 * Method:    getKdeProxyInfo
219
 * Signature: ([Ljava/lang/String);
220
 */
221
JNIEXPORT jobject JNICALL Java_org_eclipse_core_internal_net_UnixProxyProvider_getKdeProxyInfo(
222
		JNIEnv *env, jclass clazz, jstring protocol) {
223
	//printf("getKdeProxyInfo - not implemented\n");
224
	return NULL;
225
}
226
227
/*
228
 * Class:     org_eclipse_core_internal_net_UnixProxyProvider
229
 * Method:    getKdeNonProxyHosts
230
 * Signature: ()Ljava/lang/String;
231
 */
232
JNIEXPORT jobject JNICALL Java_org_eclipse_core_internal_net_UnixProxyProvider_getKdeNonProxyHosts(
233
		JNIEnv *env, jclass clazz) {
234
	//printf("getKdeNonProxyHosts - not implemented\n");
235
	return NULL;
236
}
237
(-)src/org/eclipse/core/internal/net/proxy/unix/UnixProxyProvider.java (-22 / +113 lines)
Lines 14-32 Link Here
14
import java.net.URISyntaxException;
14
import java.net.URISyntaxException;
15
15
16
import org.eclipse.core.internal.net.AbstractProxyProvider;
16
import org.eclipse.core.internal.net.AbstractProxyProvider;
17
import org.eclipse.core.internal.net.Activator;
17
import org.eclipse.core.internal.net.ProxyData;
18
import org.eclipse.core.internal.net.ProxyData;
18
import org.eclipse.core.net.proxy.IProxyData;
19
import org.eclipse.core.net.proxy.IProxyData;
19
20
20
public class UnixProxyProvider extends AbstractProxyProvider {
21
public class UnixProxyProvider extends AbstractProxyProvider {
21
22
22
	static {
23
	static {
24
25
		// Load each of the libraries separately so that we get
26
		// whichever ones work
27
		try {
28
			System.loadLibrary("proxyenv"); //$NON-NLS-1$
29
		} catch (UnsatisfiedLinkError ex) {
30
			// This should never happen
31
			Activator.logError("Missing native code for getenv()", ex); //$NON-NLS-1$
32
		}
33
23
		try {
34
		try {
24
			System.loadLibrary("libproxysupport"); //$NON-NLS-1$
35
			System.loadLibrary("proxygnome"); //$NON-NLS-1$
25
		} catch (UnsatisfiedLinkError ex) {
36
		} catch (UnsatisfiedLinkError ex) {
37
			Activator.logInfo("Missing gconf (Gnome) libraries", ex); //$NON-NLS-1$
26
			// This will happen on systems that are missing Gnome libraries
38
			// This will happen on systems that are missing Gnome libraries
27
		}
39
		}
40
41
		// TODO - don't have a library for KDE yet, put it here when we do
28
	}
42
	}
29
43
44
	public static boolean _debug = false;
45
30
	public UnixProxyProvider() {
46
	public UnixProxyProvider() {
31
		// Nothing to initialize
47
		// Nothing to initialize
32
	}
48
	}
Lines 45-56 Link Here
45
		return new IProxyData[0];
61
		return new IProxyData[0];
46
	}
62
	}
47
63
64
	protected String[] debugPrint(String[] strs) {
65
		if (_debug) {
66
			System.out.println("npHosts: "); //$NON-NLS-1$
67
			for (int i = 0; i < strs.length; i++)
68
				System.out.println(i + ": " + strs[i]); //$NON-NLS-1$
69
		}
70
		return strs;
71
	}
72
48
	protected String[] getNonProxiedHosts() {
73
	protected String[] getNonProxiedHosts() {
74
		String[] npHosts;
75
49
		try {
76
		try {
50
			String[] npHosts = getGConfNonProxyHosts();
77
			// First try the environment variable which is a URL
51
			if (npHosts != null && npHosts.length > 0)
78
			String npEnv = null;
52
				return npHosts;
79
			npEnv = getEnv("no_proxy"); //$NON-NLS-1$
53
			return getKdeNonProxyHosts();
80
			if (npEnv != null) {
81
				if (_debug)
82
					System.out.println("got env no_proxy: " + npEnv); //$NON-NLS-1$
83
				npHosts = npEnv.split(","); //$NON-NLS-1$
84
				for (int i = 0; i < npHosts.length; i++)
85
					npHosts[i] = npHosts[i].trim();
86
				return debugPrint(npHosts);
87
			}
88
		} catch (UnsatisfiedLinkError ex) {
89
			// This has already been reported when the native code did not load
90
		}
91
92
		try {
93
			npHosts = getGConfNonProxyHosts();
94
			if (npHosts != null && npHosts.length > 0) {
95
				if (_debug)
96
					System.out.println("got gnome no proxy"); //$NON-NLS-1$
97
				return debugPrint(npHosts);
98
			}
99
		} catch (UnsatisfiedLinkError ex) {
100
			// This has already been reported (the native code did not load)
101
		}
102
103
		try {
104
			npHosts = getKdeNonProxyHosts();
105
			if (npHosts != null && npHosts.length > 0) {
106
				if (_debug)
107
					System.out.println("got kde no proxy"); //$NON-NLS-1$
108
				return debugPrint(npHosts);
109
			}
54
		} catch (UnsatisfiedLinkError ex) {
110
		} catch (UnsatisfiedLinkError ex) {
55
			// This has already been reported (the native code did not load)
111
			// This has already been reported (the native code did not load)
56
		}
112
		}
Lines 61-94 Link Here
61
	protected ProxyData getSystemProxyInfo(String protocol) {
117
	protected ProxyData getSystemProxyInfo(String protocol) {
62
		ProxyData pd = null;
118
		ProxyData pd = null;
63
119
64
		// First try the environment variable which is a URL
120
		try {
65
		// TODO: native calls for system properties, since System#getenx is
121
			// First try the environment variable which is a URL
66
		// deprecated in 1.4
122
			String proxyEnv = null;
67
		String sysHttp = null;
123
			String envName = protocol + "_proxy"; //$NON-NLS-1$
68
		// System.getenv(protocol.toLowerCase() + "_proxy"); //$NON-NLS-1$
124
			proxyEnv = getEnv(envName);
69
		if (sysHttp != null) {
125
			if (_debug)
70
			URI uri = null;
126
				System.out.println("got proxyEnv: " + proxyEnv); //$NON-NLS-1$
71
			try {
127
			if (proxyEnv != null) {
72
				uri = new URI(sysHttp);
128
				URI uri = null;
73
			} catch (URISyntaxException e) {
129
				try {
74
				return null;
130
					uri = new URI(proxyEnv);
75
			}
131
				} catch (URISyntaxException e) {
132
					Activator
133
							.logWarning(
134
									"Error processing URI from: " + envName + " value: " + proxyEnv, e); //$NON-NLS-1$//$NON-NLS-2$
135
					return null;
136
				}
137
138
				pd = new ProxyData(protocol);
139
				pd.setHost(uri.getHost());
140
				pd.setPort(uri.getPort());
141
				String userInfo = uri.getUserInfo();
142
				if (userInfo != null) {
143
					String user = null;
144
					String password = null;
145
					int pwInd = userInfo.indexOf(':');
146
					if (pwInd >= 0) {
147
						user = userInfo.substring(0, pwInd);
148
						password = userInfo.substring(pwInd + 1);
149
					} else {
150
						user = userInfo;
151
					}
152
					pd.setUserid(user);
153
					pd.setPassword(password);
154
				}
76
155
77
			pd = new ProxyData(protocol);
156
				if (_debug)
78
			pd.setHost(uri.getHost());
157
					System.out.println("env proxy data: " + pd); //$NON-NLS-1$
79
			pd.setPort(uri.getPort());
158
				return pd;
80
			return pd;
159
			}
160
		} catch (UnsatisfiedLinkError ex) {
161
			// This has already been reported when the native code did not load
81
		}
162
		}
82
163
83
		try {
164
		try {
84
			// Then ask Gnome
165
			// Then ask Gnome
85
			pd = getGConfProxyInfo(protocol);
166
			pd = getGConfProxyInfo(protocol);
86
167
			if (_debug)
168
				System.out.println("Gnome proxy data: " + pd); //$NON-NLS-1$
87
			if (pd != null)
169
			if (pd != null)
88
				return pd;
170
				return pd;
89
171
172
		} catch (UnsatisfiedLinkError ex) {
173
			// This has already been reported when the native code did not load
174
		}
175
176
		try {
90
			// Then ask KDE
177
			// Then ask KDE
91
			pd = getKdeProxyInfo(protocol);
178
			pd = getKdeProxyInfo(protocol);
179
			if (_debug)
180
				System.out.println("KDE proxy data: " + pd); //$NON-NLS-1$
92
			if (pd != null)
181
			if (pd != null)
93
				return pd;
182
				return pd;
94
		} catch (UnsatisfiedLinkError ex) {
183
		} catch (UnsatisfiedLinkError ex) {
Lines 98-103 Link Here
98
		return null;
187
		return null;
99
	}
188
	}
100
189
190
	protected static native String getEnv(String protocol);
191
101
	protected static native ProxyData getGConfProxyInfo(String protocol);
192
	protected static native ProxyData getGConfProxyInfo(String protocol);
102
193
103
	protected static native String[] getGConfNonProxyHosts();
194
	protected static native String[] getGConfNonProxyHosts();
(-)natives/unix/README.txt (+12 lines)
Added Link Here
1
The source for getting the native proxy info is in the top level unix directory.  If
2
there are more specific compile options, makefiles, etc, then they should be moved
3
to subdirectories, like in org.eclipse.core.filesystem.
4
5
The GetProxy* directories actually have the make files; this is the makefile as generated by the CDT.
6
7
To build this, go into GetProxy* directory and type "make clean", then "make", 
8
the library will be built in that same directory.  Then you will need to copy the library to the correct org.eclipse.core.net.*
9
fragment.
10
11
There is no automatic build process for building the native code, instead the binary
12
shared libraries are checked in for each fragment, just like in org.eclipse.code.filesystem.
(-)natives/unix/getproxyenv.c (+52 lines)
Added Link Here
1
/*
2
 * Copyright 2008 Oakland Software Incorporated and others
3
 * All rights reserved. This program and the accompanying materials 
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 * 
8
 * Contributors:
9
 *     Oakland Software Incorporated - initial API and implementation
10
 */
11
12
#include <jni.h>
13
14
#include <stdlib.h>
15
#ifdef __linux__
16
#include <string.h>
17
#else
18
#include <strings.h>
19
#endif
20
21
static int debug = 0;
22
23
/*
24
 * Class:     org_eclipse_core_internal_net_proxy_unix_UnixProxyProvider
25
 * Method:    getEnvProxyString
26
 * Signature: ([Ljava/lang/String);
27
 */
28
JNIEXPORT jstring JNICALL Java_org_eclipse_core_internal_net_proxy_unix_UnixProxyProvider_getEnv(
29
		JNIEnv *env, jclass clazz, jstring variable) {
30
31
	jboolean isCopy;
32
	const char *cvariable;
33
34
	cvariable = (*env)->GetStringUTFChars(env, variable, &isCopy);
35
	if (cvariable == NULL)
36
		return NULL;
37
38
	if (debug)
39
		printf("envName: %s\n", cvariable);
40
	char *envValue = getenv(cvariable);
41
	if (envValue == NULL)
42
		return NULL;
43
	
44
	if (debug)
45
		printf("envValue: %s\n", envValue);
46
47
	jstring jenvValue = (*env)->NewStringUTF(env, envValue);
48
	return jenvValue;
49
}
50
51
52
(-)natives/unix/GetProxyGnome/makefile (+43 lines)
Added Link Here
1
################################################################################
2
# Automatically-generated file. Do not edit!
3
################################################################################
4
5
-include ../makefile.init
6
7
RM := rm -rf
8
9
# All of the sources participating in the build are defined here
10
-include sources.mk
11
-include subdir.mk
12
-include objects.mk
13
14
ifneq ($(MAKECMDGOALS),clean)
15
ifneq ($(strip $(C_DEPS)),)
16
-include $(C_DEPS)
17
endif
18
endif
19
20
-include ../makefile.defs
21
22
# Add inputs and outputs from these tool invocations to the build variables 
23
24
# All Target
25
all: libproxygnome.so
26
27
# Tool invocations
28
libproxygnome.so: $(OBJS) $(USER_OBJS)
29
	@echo 'Building target: $@'
30
	@echo 'Invoking: GCC C Linker'
31
	gcc -m32 -shared -o"libproxygnome.so" $(OBJS) $(USER_OBJS) $(LIBS)
32
	@echo 'Finished building target: $@'
33
	@echo ' '
34
35
# Other Targets
36
clean:
37
	-$(RM) $(OBJS)$(C_DEPS)$(LIBRARIES) libproxygnome.so
38
	-@echo ' '
39
40
.PHONY: all clean dependents
41
.SECONDARY:
42
43
-include ../makefile.targets
(-)natives/unix/getproxygnome.c (+214 lines)
Added Link Here
1
/*
2
 * Copyright 2008 Oakland Software Incorporated and others
3
 * All rights reserved. This program and the accompanying materials 
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 * 
8
 * Contributors:
9
 *     Oakland Software Incorporated - initial API and implementation
10
 */
11
12
#include <jni.h>
13
14
#include <glib.h>
15
#include <glib/gslist.h>
16
#include <gconf/gconf-value.h>
17
#include <gconf/gconf-client.h>
18
19
#ifdef __linux__
20
#include <string.h>
21
#else
22
#include <strings.h>
23
#endif
24
25
static GConfClient *client= NULL;
26
27
static jclass proxyInfoClass;
28
static jclass stringClass;
29
static jmethodID proxyInfoConstructor;
30
static jmethodID toString;
31
32
static jmethodID hostMethod;
33
static jmethodID portMethod;
34
static jmethodID userMethod;
35
static jmethodID passwordMethod;
36
37
#define CHECK_NULL(X) { if ((X) == NULL) fprintf (stderr,"JNI error at line %d\n", __LINE__); } 
38
39
static void gconfInit(JNIEnv *env) {
40
	client = gconf_client_get_default();
41
	jclass cls= NULL;
42
	CHECK_NULL(cls = (*env)->FindClass(env, "org/eclipse/core/internal/net/ProxyData"));
43
	proxyInfoClass = (*env)->NewGlobalRef(env, cls);
44
45
	CHECK_NULL(cls = (*env)->FindClass(env, "java/lang/String"));
46
	stringClass = (*env)->NewGlobalRef(env, cls);
47
48
	CHECK_NULL(proxyInfoConstructor = (*env)->GetMethodID(env, proxyInfoClass, "<init>", "(Ljava/lang/String;)V"));
49
50
	CHECK_NULL(toString = (*env)->GetMethodID(env, proxyInfoClass, "toString", "()Ljava/lang/String;"));
51
52
	CHECK_NULL(hostMethod = (*env)->GetMethodID(env, proxyInfoClass, "setHost",
53
					"(Ljava/lang/String;)V"));
54
	CHECK_NULL(portMethod = (*env)->GetMethodID(env, proxyInfoClass, "setPort",
55
					"(I)V"));
56
	CHECK_NULL(userMethod = (*env)->GetMethodID(env, proxyInfoClass, "setUserid",
57
					"(Ljava/lang/String;)V"));
58
	CHECK_NULL(passwordMethod = (*env)->GetMethodID(env, proxyInfoClass, "setPassword",
59
					"(Ljava/lang/String;)V"));
60
}
61
62
/*
63
 * Class:     org_eclipse_core_internal_net_UnixProxyProvider
64
 * Method:    getGConfProxyInfo
65
 * Signature: ([Ljava/lang/String);
66
 */
67
JNIEXPORT jobject JNICALL Java_org_eclipse_core_internal_net_proxy_unix_UnixProxyProvider_getGConfProxyInfo(
68
		JNIEnv *env, jclass clazz, jstring protocol) {
69
70
	jboolean isCopy;
71
	const char *cprotocol;
72
73
	jobject proxyInfo= NULL;
74
75
	if (client == NULL) {
76
		gconfInit(env);
77
	}
78
79
	CHECK_NULL(proxyInfo = (*env)->NewObject(env, proxyInfoClass, proxyInfoConstructor, protocol));
80
81
	cprotocol = (*env)->GetStringUTFChars(env, protocol, &isCopy);
82
	if (cprotocol == NULL)
83
		return NULL;
84
85
	//printf("cprotocol: %s\n", cprotocol);
86
87
	// use_same_proxy means we use the http value for everything
88
	gboolean useSame = gconf_client_get_bool(client,
89
			"/system/http_proxy/use_same_proxy", NULL);
90
91
	if (strcasecmp(cprotocol, "http") == 0 || useSame) {
92
		gboolean useProxy = gconf_client_get_bool(client,
93
				"/system/http_proxy/use_http_proxy", NULL);
94
		if (!useProxy) {
95
			proxyInfo = NULL;
96
			goto exit;
97
		}
98
99
		gchar *host = gconf_client_get_string(client,
100
				"/system/http_proxy/host", NULL);
101
		jobject jhost = (*env)->NewStringUTF(env, host);
102
		(*env)->CallVoidMethod(env, proxyInfo, hostMethod, jhost);
103
104
		gint port = gconf_client_get_int(client, "/system/http_proxy/port",
105
				NULL);
106
		(*env)->CallVoidMethod(env, proxyInfo, portMethod, port);
107
108
		gboolean reqAuth = gconf_client_get_bool(client,
109
				"/system/http_proxy/use_authentication", NULL);
110
		if (reqAuth) {
111
112
			gchar *user = gconf_client_get_string(client,
113
					"/system/http_proxy/authentication_user", NULL);
114
			jobject juser = (*env)->NewStringUTF(env, user);
115
			(*env)->CallVoidMethod(env, proxyInfo, userMethod, juser);
116
117
			gchar *password = gconf_client_get_string(client,
118
					"/system/http_proxy/authentication_password", NULL);
119
			jobject jpassword = (*env)->NewStringUTF(env, password);
120
			(*env)->CallVoidMethod(env, proxyInfo, passwordMethod,
121
					jpassword);
122
		}
123
		goto exit;
124
	}
125
126
	// Everything else applies only if the system proxy mode is manual
127
	gchar *mode = gconf_client_get_string(client, "/system/proxy/mode", NULL);
128
	if (strcasecmp(mode, "manual") != 0) {
129
		proxyInfo = NULL;
130
		goto exit;
131
	}
132
133
	char selector[100];
134
135
	if (strcasecmp(cprotocol, "https") == 0) {
136
		strcpy(selector, "/system/proxy/secure_");
137
	} else if (strcasecmp(cprotocol, "socks") == 0) {
138
		strcpy(selector, "/system/proxy/socks_");
139
	} else if (strcasecmp(cprotocol, "ftp") == 0) {
140
		strcpy(selector, "/system/proxy/ftp_");
141
	} else {
142
		proxyInfo = NULL;
143
		goto exit;
144
	}
145
146
	char useSelector[100];
147
	strcpy(useSelector, selector);
148
149
	gchar *host = gconf_client_get_string(client, strcat(useSelector, "host"),
150
			NULL);
151
	jobject jhost = (*env)->NewStringUTF(env, host);
152
	(*env)->CallVoidMethod(env, proxyInfo, hostMethod, jhost);
153
154
	strcpy(useSelector, selector);
155
	gint port = gconf_client_get_int(client, strcat(useSelector, "port"), NULL);
156
	(*env)->CallVoidMethod(env, proxyInfo, portMethod, port);
157
158
	exit: if (isCopy == JNI_TRUE)
159
		(*env)->ReleaseStringUTFChars(env, protocol, cprotocol);
160
	return proxyInfo;
161
}
162
163
typedef struct {
164
	jobjectArray npHostArray;
165
	JNIEnv *env;
166
	int index;
167
} ListProcContext;
168
169
// user_data is the ListProcContext
170
void listProc(gpointer data, gpointer user_data) {
171
	ListProcContext *lpc = user_data;
172
	jobject jnpHost = (*lpc->env)->NewStringUTF(lpc->env, (char *)data);
173
	(*lpc->env)->SetObjectArrayElement(lpc->env, lpc->npHostArray,
174
			lpc->index++, jnpHost);
175
}
176
177
/*
178
 * Class:     org_eclipse_core_internal_net_UnixProxyProvider
179
 * Method:    getGConfNonProxyHosts
180
 * Signature: ()[Ljava/lang/String;
181
 */
182
JNIEXPORT jobjectArray JNICALL Java_org_eclipse_core_internal_net_proxy_unix_UnixProxyProvider_getGConfNonProxyHosts(
183
		JNIEnv *env, jclass clazz) {
184
185
	if (client == NULL) {
186
		gconfInit(env);
187
	}
188
189
	GSList *npHosts;
190
	int size;
191
192
	npHosts = gconf_client_get_list(client, "/system/http_proxy/ignore_hosts",
193
			GCONF_VALUE_STRING, NULL);
194
	size = g_slist_length(npHosts);
195
196
	// TODO - I'm not sure this is really valid, it's from the JVM implementation
197
	// of ProxySelector
198
	if (size == 0) {
199
		npHosts = gconf_client_get_list(client, "/system/proxy/no_proxy_for",
200
				GCONF_VALUE_STRING, NULL);
201
	}
202
	size = g_slist_length(npHosts);
203
204
	jobjectArray ret = (*env)->NewObjectArray(env, size, stringClass, NULL);
205
206
	ListProcContext lpc;
207
	lpc.env = env;
208
	lpc.npHostArray = ret;
209
	lpc.index = 0;
210
211
	g_slist_foreach(npHosts, listProc, &lpc);
212
	return ret;
213
}
214
(-)natives/unix/GetProxyEnv/makefile (+43 lines)
Added Link Here
1
################################################################################
2
# Automatically-generated file. Do not edit!
3
################################################################################
4
5
-include ../makefile.init
6
7
RM := rm -rf
8
9
# All of the sources participating in the build are defined here
10
-include sources.mk
11
-include subdir.mk
12
-include objects.mk
13
14
ifneq ($(MAKECMDGOALS),clean)
15
ifneq ($(strip $(C_DEPS)),)
16
-include $(C_DEPS)
17
endif
18
endif
19
20
-include ../makefile.defs
21
22
# Add inputs and outputs from these tool invocations to the build variables 
23
24
# All Target
25
all: libproxyenv.so
26
27
# Tool invocations
28
libproxyenv.so: $(OBJS) $(USER_OBJS)
29
	@echo 'Building target: $@'
30
	@echo 'Invoking: GCC C Linker'
31
	gcc -m32 -shared -o"libproxyenv.so" $(OBJS) $(USER_OBJS) $(LIBS)
32
	@echo 'Finished building target: $@'
33
	@echo ' '
34
35
# Other Targets
36
clean:
37
	-$(RM) $(OBJS)$(C_DEPS)$(LIBRARIES) libproxyenv.so
38
	-@echo ' '
39
40
.PHONY: all clean dependents
41
.SECONDARY:
42
43
-include ../makefile.targets
(-)natives/unix/GetProxyGnome/objects.mk (+7 lines)
Added Link Here
1
################################################################################
2
# Automatically-generated file. Do not edit!
3
################################################################################
4
5
USER_OBJS :=
6
7
LIBS := -lgconf-2 -lORBit-2 -lgthread-2.0 -lrt -lgobject-2.0 -lglib-2.0
(-)natives/unix/GetProxyGnome/sources.mk (+17 lines)
Added Link Here
1
################################################################################
2
# Automatically-generated file. Do not edit!
3
################################################################################
4
5
O_SRCS := 
6
C_SRCS := 
7
S_SRCS := 
8
OBJ_SRCS := 
9
ASM_SRCS := 
10
OBJS := 
11
C_DEPS := 
12
LIBRARIES := 
13
14
# Every subdirectory with source files must be described here
15
SUBDIRS := \
16
. \
17
(-)natives/unix/GetProxyEnv/getproxyenv.d (+1 lines)
Added Link Here
1
getproxyenv.d getproxyenv.o: ../getproxyenv.c
(-)natives/unix/GetProxyGnome/getproxygnome.d (+226 lines)
Added Link Here
1
getproxygnome.d getproxygnome.o: ../getproxygnome.c \
2
  /usr/include/glib-2.0/glib.h /usr/include/glib-2.0/glib/galloca.h \
3
  /usr/include/glib-2.0/glib/gtypes.h \
4
  /usr/lib/glib-2.0/include/glibconfig.h \
5
  /usr/include/glib-2.0/glib/gmacros.h \
6
  /usr/include/glib-2.0/glib/garray.h \
7
  /usr/include/glib-2.0/glib/gasyncqueue.h \
8
  /usr/include/glib-2.0/glib/gthread.h \
9
  /usr/include/glib-2.0/glib/gerror.h /usr/include/glib-2.0/glib/gquark.h \
10
  /usr/include/glib-2.0/glib/gutils.h \
11
  /usr/include/glib-2.0/glib/gatomic.h \
12
  /usr/include/glib-2.0/glib/gbacktrace.h \
13
  /usr/include/glib-2.0/glib/gbase64.h \
14
  /usr/include/glib-2.0/glib/gbookmarkfile.h \
15
  /usr/include/glib-2.0/glib/gcache.h /usr/include/glib-2.0/glib/glist.h \
16
  /usr/include/glib-2.0/glib/gmem.h /usr/include/glib-2.0/glib/gslice.h \
17
  /usr/include/glib-2.0/glib/gcompletion.h \
18
  /usr/include/glib-2.0/glib/gconvert.h \
19
  /usr/include/glib-2.0/glib/gdataset.h \
20
  /usr/include/glib-2.0/glib/gdate.h /usr/include/glib-2.0/glib/gdir.h \
21
  /usr/include/glib-2.0/glib/gfileutils.h \
22
  /usr/include/glib-2.0/glib/ghash.h /usr/include/glib-2.0/glib/ghook.h \
23
  /usr/include/glib-2.0/glib/giochannel.h \
24
  /usr/include/glib-2.0/glib/gmain.h /usr/include/glib-2.0/glib/gslist.h \
25
  /usr/include/glib-2.0/glib/gstring.h \
26
  /usr/include/glib-2.0/glib/gunicode.h \
27
  /usr/include/glib-2.0/glib/gkeyfile.h \
28
  /usr/include/glib-2.0/glib/gmappedfile.h \
29
  /usr/include/glib-2.0/glib/gmarkup.h \
30
  /usr/include/glib-2.0/glib/gmessages.h \
31
  /usr/include/glib-2.0/glib/gnode.h /usr/include/glib-2.0/glib/goption.h \
32
  /usr/include/glib-2.0/glib/gpattern.h \
33
  /usr/include/glib-2.0/glib/gprimes.h \
34
  /usr/include/glib-2.0/glib/gqsort.h /usr/include/glib-2.0/glib/gqueue.h \
35
  /usr/include/glib-2.0/glib/grand.h /usr/include/glib-2.0/glib/grel.h \
36
  /usr/include/glib-2.0/glib/gregex.h \
37
  /usr/include/glib-2.0/glib/gscanner.h \
38
  /usr/include/glib-2.0/glib/gsequence.h \
39
  /usr/include/glib-2.0/glib/gshell.h /usr/include/glib-2.0/glib/gspawn.h \
40
  /usr/include/glib-2.0/glib/gstrfuncs.h \
41
  /usr/include/glib-2.0/glib/gthreadpool.h \
42
  /usr/include/glib-2.0/glib/gtimer.h /usr/include/glib-2.0/glib/gtree.h \
43
  /usr/include/gconf/2/gconf/gconf-value.h \
44
  /usr/include/gconf/2/gconf/gconf-error.h \
45
  /usr/include/gconf/2/gconf/gconf-client.h \
46
  /usr/include/glib-2.0/glib-object.h \
47
  /usr/include/glib-2.0/gobject/gboxed.h \
48
  /usr/include/glib-2.0/gobject/gtype.h \
49
  /usr/include/glib-2.0/gobject/genums.h \
50
  /usr/include/glib-2.0/gobject/gobject.h \
51
  /usr/include/glib-2.0/gobject/gvalue.h \
52
  /usr/include/glib-2.0/gobject/gparam.h \
53
  /usr/include/glib-2.0/gobject/gclosure.h \
54
  /usr/include/glib-2.0/gobject/gsignal.h \
55
  /usr/include/glib-2.0/gobject/gmarshal.h \
56
  /usr/include/glib-2.0/gobject/gparamspecs.h \
57
  /usr/include/glib-2.0/gobject/gsourceclosure.h \
58
  /usr/include/glib-2.0/gobject/gtypemodule.h \
59
  /usr/include/glib-2.0/gobject/gtypeplugin.h \
60
  /usr/include/glib-2.0/gobject/gvaluearray.h \
61
  /usr/include/glib-2.0/gobject/gvaluetypes.h \
62
  /usr/include/gconf/2/gconf/gconf.h \
63
  /usr/include/gconf/2/gconf/gconf-schema.h \
64
  /usr/include/gconf/2/gconf/gconf-engine.h \
65
  /usr/include/gconf/2/gconf/gconf-error.h \
66
  /usr/include/gconf/2/gconf/gconf-enum-types.h \
67
  /usr/include/gconf/2/gconf/gconf-listeners.h \
68
  /usr/include/gconf/2/gconf/gconf-changeset.h
69
70
/usr/include/glib-2.0/glib.h:
71
72
/usr/include/glib-2.0/glib/galloca.h:
73
74
/usr/include/glib-2.0/glib/gtypes.h:
75
76
/usr/lib/glib-2.0/include/glibconfig.h:
77
78
/usr/include/glib-2.0/glib/gmacros.h:
79
80
/usr/include/glib-2.0/glib/garray.h:
81
82
/usr/include/glib-2.0/glib/gasyncqueue.h:
83
84
/usr/include/glib-2.0/glib/gthread.h:
85
86
/usr/include/glib-2.0/glib/gerror.h:
87
88
/usr/include/glib-2.0/glib/gquark.h:
89
90
/usr/include/glib-2.0/glib/gutils.h:
91
92
/usr/include/glib-2.0/glib/gatomic.h:
93
94
/usr/include/glib-2.0/glib/gbacktrace.h:
95
96
/usr/include/glib-2.0/glib/gbase64.h:
97
98
/usr/include/glib-2.0/glib/gbookmarkfile.h:
99
100
/usr/include/glib-2.0/glib/gcache.h:
101
102
/usr/include/glib-2.0/glib/glist.h:
103
104
/usr/include/glib-2.0/glib/gmem.h:
105
106
/usr/include/glib-2.0/glib/gslice.h:
107
108
/usr/include/glib-2.0/glib/gcompletion.h:
109
110
/usr/include/glib-2.0/glib/gconvert.h:
111
112
/usr/include/glib-2.0/glib/gdataset.h:
113
114
/usr/include/glib-2.0/glib/gdate.h:
115
116
/usr/include/glib-2.0/glib/gdir.h:
117
118
/usr/include/glib-2.0/glib/gfileutils.h:
119
120
/usr/include/glib-2.0/glib/ghash.h:
121
122
/usr/include/glib-2.0/glib/ghook.h:
123
124
/usr/include/glib-2.0/glib/giochannel.h:
125
126
/usr/include/glib-2.0/glib/gmain.h:
127
128
/usr/include/glib-2.0/glib/gslist.h:
129
130
/usr/include/glib-2.0/glib/gstring.h:
131
132
/usr/include/glib-2.0/glib/gunicode.h:
133
134
/usr/include/glib-2.0/glib/gkeyfile.h:
135
136
/usr/include/glib-2.0/glib/gmappedfile.h:
137
138
/usr/include/glib-2.0/glib/gmarkup.h:
139
140
/usr/include/glib-2.0/glib/gmessages.h:
141
142
/usr/include/glib-2.0/glib/gnode.h:
143
144
/usr/include/glib-2.0/glib/goption.h:
145
146
/usr/include/glib-2.0/glib/gpattern.h:
147
148
/usr/include/glib-2.0/glib/gprimes.h:
149
150
/usr/include/glib-2.0/glib/gqsort.h:
151
152
/usr/include/glib-2.0/glib/gqueue.h:
153
154
/usr/include/glib-2.0/glib/grand.h:
155
156
/usr/include/glib-2.0/glib/grel.h:
157
158
/usr/include/glib-2.0/glib/gregex.h:
159
160
/usr/include/glib-2.0/glib/gscanner.h:
161
162
/usr/include/glib-2.0/glib/gsequence.h:
163
164
/usr/include/glib-2.0/glib/gshell.h:
165
166
/usr/include/glib-2.0/glib/gspawn.h:
167
168
/usr/include/glib-2.0/glib/gstrfuncs.h:
169
170
/usr/include/glib-2.0/glib/gthreadpool.h:
171
172
/usr/include/glib-2.0/glib/gtimer.h:
173
174
/usr/include/glib-2.0/glib/gtree.h:
175
176
/usr/include/gconf/2/gconf/gconf-value.h:
177
178
/usr/include/gconf/2/gconf/gconf-error.h:
179
180
/usr/include/gconf/2/gconf/gconf-client.h:
181
182
/usr/include/glib-2.0/glib-object.h:
183
184
/usr/include/glib-2.0/gobject/gboxed.h:
185
186
/usr/include/glib-2.0/gobject/gtype.h:
187
188
/usr/include/glib-2.0/gobject/genums.h:
189
190
/usr/include/glib-2.0/gobject/gobject.h:
191
192
/usr/include/glib-2.0/gobject/gvalue.h:
193
194
/usr/include/glib-2.0/gobject/gparam.h:
195
196
/usr/include/glib-2.0/gobject/gclosure.h:
197
198
/usr/include/glib-2.0/gobject/gsignal.h:
199
200
/usr/include/glib-2.0/gobject/gmarshal.h:
201
202
/usr/include/glib-2.0/gobject/gparamspecs.h:
203
204
/usr/include/glib-2.0/gobject/gsourceclosure.h:
205
206
/usr/include/glib-2.0/gobject/gtypemodule.h:
207
208
/usr/include/glib-2.0/gobject/gtypeplugin.h:
209
210
/usr/include/glib-2.0/gobject/gvaluearray.h:
211
212
/usr/include/glib-2.0/gobject/gvaluetypes.h:
213
214
/usr/include/gconf/2/gconf/gconf.h:
215
216
/usr/include/gconf/2/gconf/gconf-schema.h:
217
218
/usr/include/gconf/2/gconf/gconf-engine.h:
219
220
/usr/include/gconf/2/gconf/gconf-error.h:
221
222
/usr/include/gconf/2/gconf/gconf-enum-types.h:
223
224
/usr/include/gconf/2/gconf/gconf-listeners.h:
225
226
/usr/include/gconf/2/gconf/gconf-changeset.h:
(-)natives/unix/GetProxyGnome/subdir.mk (+24 lines)
Added Link Here
1
################################################################################
2
# Automatically-generated file. Do not edit!
3
################################################################################
4
5
# Add inputs and outputs from these tool invocations to the build variables 
6
C_SRCS += \
7
../getproxygnome.c 
8
9
OBJS += \
10
./getproxygnome.o 
11
12
C_DEPS += \
13
./getproxygnome.d 
14
15
16
# Each subdirectory must supply rules for building sources it contributes
17
%.o: ../%.c
18
	@echo 'Building file: $<'
19
	@echo 'Invoking: GCC C Compiler'
20
	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"$@" "$<"
21
	@echo 'Finished building: $<'
22
	@echo ' '
23
24
(-)natives/unix/GetProxyEnv/objects.mk (+7 lines)
Added Link Here
1
################################################################################
2
# Automatically-generated file. Do not edit!
3
################################################################################
4
5
USER_OBJS :=
6
7
LIBS := -lrt
(-)fragments/org.eclipse.core.net.linux.x86/BUILD_INFO.txt (+10 lines)
Added Link Here
1
Native Build Info:
2
------------------
3
4
platform:         linux.gtk.x86
5
built by:         Francis Upton, francisu@ieee.org
6
build date:       24-Apr-2008
7
OS Name:          Fedora 8
8
OS Version:       Linux 2.6.24.4-64.fc8
9
Compiler version: gcc (GCC) 4.1.2 20070925 (Red Hat 4.1.2-33)
10
Java version:     Standard Edition 1.6.0_04
(-)natives/unix/GetProxyEnv/sources.mk (+17 lines)
Added Link Here
1
################################################################################
2
# Automatically-generated file. Do not edit!
3
################################################################################
4
5
O_SRCS := 
6
C_SRCS := 
7
S_SRCS := 
8
OBJ_SRCS := 
9
ASM_SRCS := 
10
OBJS := 
11
C_DEPS := 
12
LIBRARIES := 
13
14
# Every subdirectory with source files must be described here
15
SUBDIRS := \
16
. \
17
(-)natives/unix/GetProxyEnv/subdir.mk (+24 lines)
Added Link Here
1
################################################################################
2
# Automatically-generated file. Do not edit!
3
################################################################################
4
5
# Add inputs and outputs from these tool invocations to the build variables 
6
C_SRCS += \
7
../getproxyenv.c 
8
9
OBJS += \
10
./getproxyenv.o 
11
12
C_DEPS += \
13
./getproxyenv.d 
14
15
16
# Each subdirectory must supply rules for building sources it contributes
17
%.o: ../%.c
18
	@echo 'Building file: $<'
19
	@echo 'Invoking: GCC C Compiler'
20
	gcc -O0 -fPIC -g3 -Wall -c -fmessage-length=0 -m32 -MMD -MP -MF"$(@:%.o=%.d)" -MT"$(@:%.o=%.d)" -o"$@" "$<"
21
	@echo 'Finished building: $<'
22
	@echo ' '
23
24

Return to bug 226462