Mercurial > hg > release > icedtea7-forest-2.0 > jdk
changeset 4533:49d52dd99f97
Support building using system GConf (USE_SYSTEM_GCONF, GCONF_CFLAGS, GOBJECT_FLAGS, GCONF_LIBS, GOBJECT_LIBS)
author | andrew |
---|---|
date | Mon, 15 Aug 2011 15:53:02 +0100 |
parents | ac0f32da8dca |
children | 8317cb1976d6 |
files | make/java/net/FILES_c.gmk make/java/net/Makefile src/solaris/native/sun/net/spi/DefaultProxySelector.c src/solaris/native/sun/net/spi/gconf2/gconf/gconf-client.h src/solaris/native/sun/net/spi/gconf2/gconf_fp.c src/solaris/native/sun/net/spi/gconf2/gconf_fp.h |
diffstat | 6 files changed, 227 insertions(+), 88 deletions(-) [+] |
line wrap: on
line diff
--- a/make/java/net/FILES_c.gmk Fri Aug 12 09:18:57 2011 +0100 +++ b/make/java/net/FILES_c.gmk Mon Aug 15 15:53:02 2011 +0100 @@ -53,3 +53,6 @@ FILES_c += PlainDatagramSocketImpl.c endif +ifndef USE_SYSTEM_GCONF + FILES_c += gconf_fp.c +endif
--- a/make/java/net/Makefile Fri Aug 12 09:18:57 2011 +0100 +++ b/make/java/net/Makefile Mon Aug 15 15:53:02 2011 +0100 @@ -84,6 +84,10 @@ vpath %.c $(PLATFORM_SRC)/native/sun/net/dns $(PLATFORM_SRC)/native/sun/net/www/protocol/http/ntlm \ $(PLATFORM_SRC)/native/sun/net/sdp $(PLATFORM_SRC)/native/sun/net/spi +ifndef USE_SYSTEM_GCONF + vpath %.c $(PLATFORM_SRC)/native/sun/net/spi/gconf2 +endif + # # Include rules # @@ -102,6 +106,13 @@ OTHER_LDLIBS += -lpthread endif +ifdef USE_SYSTEM_GCONF + OTHER_LDLIBS += $(GCONF_LIBS) $(GOBJECT_LIBS) + CPPFLAGS += $(GCONF_CFLAGS) $(GOBJECT_CFLAGS) -DUSE_SYSTEM_GCONF +else + CPPFLAGS += -I$(PLATFORM_SRC)/native/sun/net/spi/gconf2 +endif + CLASSES.export += java.lang.Integer java.io.FileDescriptor java.net.InetAddressImplFactory java.net.Inet4AddressImpl java.net.Inet6AddressImpl #
--- a/src/solaris/native/sun/net/spi/DefaultProxySelector.c Fri Aug 12 09:18:57 2011 +0100 +++ b/src/solaris/native/sun/net/spi/DefaultProxySelector.c Mon Aug 15 15:53:02 2011 +0100 @@ -28,7 +28,6 @@ #include "jvm.h" #include "jlong.h" #include "sun_net_spi_DefaultProxySelector.h" -#include <dlfcn.h> #include <stdio.h> #ifdef __linux__ #include <string.h> @@ -36,11 +35,27 @@ #include <strings.h> #endif +#include <gconf/gconf-client.h> + +#ifndef USE_SYSTEM_GCONF +#include <gconf_fp.h> +#endif + +static jclass proxy_class; +static jclass isaddr_class; +static jclass ptype_class; +static jmethodID isaddr_createUnresolvedID; +static jmethodID proxy_ctrID; +static jfieldID pr_no_proxyID; +static jfieldID ptype_httpID; +static jfieldID ptype_socksID; + +static int gconf_ver = 0; +static void* gconf_client = NULL; + +#define CHECK_NULL(X) { if ((X) == NULL) fprintf (stderr,"JNI errror at line %d\n", __LINE__); } + /** - * These functions are used by the sun.net.spi.DefaultProxySelector class - * to access some platform specific settings. - * This is the Solaris/Linux Gnome 2.x code using the GConf-2 library. - * Everything is loaded dynamically so no hard link with any library exists. * The GConf-2 settings used are: * - /system/http_proxy/use_http_proxy boolean * - /system/http_proxy/use_authentcation boolean @@ -59,33 +74,7 @@ * - /system/proxy/no_proxy_for list * - /system/proxy/gopher_host string * - /system/proxy/gopher_port int - */ -typedef void* gconf_client_get_default_func(); -typedef char* gconf_client_get_string_func(void *, char *, void**); -typedef int gconf_client_get_int_func(void*, char *, void**); -typedef int gconf_client_get_bool_func(void*, char *, void**); -typedef int gconf_init_func(int, char**, void**); -typedef void g_type_init_func (); -gconf_client_get_default_func* my_get_default_func = NULL; -gconf_client_get_string_func* my_get_string_func = NULL; -gconf_client_get_int_func* my_get_int_func = NULL; -gconf_client_get_bool_func* my_get_bool_func = NULL; -gconf_init_func* my_gconf_init_func = NULL; -g_type_init_func* my_g_type_init_func = NULL; - -static jclass proxy_class; -static jclass isaddr_class; -static jclass ptype_class; -static jmethodID isaddr_createUnresolvedID; -static jmethodID proxy_ctrID; -static jfieldID pr_no_proxyID; -static jfieldID ptype_httpID; -static jfieldID ptype_socksID; - -static int gconf_ver = 0; -static void* gconf_client = NULL; - -#define CHECK_NULL(X) { if ((X) == NULL) fprintf (stderr,"JNI errror at line %d\n", __LINE__); } +*/ /* * Class: sun_net_spi_DefaultProxySelector @@ -107,40 +96,13 @@ ptype_socksID = (*env)->GetStaticFieldID(env, ptype_class, "SOCKS", "Ljava/net/Proxy$Type;"); isaddr_createUnresolvedID = (*env)->GetStaticMethodID(env, isaddr_class, "createUnresolved", "(Ljava/lang/String;I)Ljava/net/InetSocketAddress;"); - /** - * Let's try to load le GConf-2 library - */ - if (dlopen("libgconf-2.so", RTLD_GLOBAL | RTLD_LAZY) != NULL || - dlopen("libgconf-2.so.4", RTLD_GLOBAL | RTLD_LAZY) != NULL) { - gconf_ver = 2; - } - if (gconf_ver > 0) { - /* - * Now let's get pointer to the functions we need. - */ - my_g_type_init_func = (g_type_init_func*) dlsym(RTLD_DEFAULT, "g_type_init"); - my_get_default_func = (gconf_client_get_default_func*) dlsym(RTLD_DEFAULT, "gconf_client_get_default"); - if (my_g_type_init_func != NULL && my_get_default_func != NULL) { - /** - * Try to connect to GConf. - */ - (*my_g_type_init_func)(); - gconf_client = (*my_get_default_func)(); - if (gconf_client != NULL) { - my_get_string_func = (gconf_client_get_string_func*) dlsym(RTLD_DEFAULT, "gconf_client_get_string"); - my_get_int_func = (gconf_client_get_int_func*) dlsym(RTLD_DEFAULT, "gconf_client_get_int"); - my_get_bool_func = (gconf_client_get_bool_func*) dlsym(RTLD_DEFAULT, "gconf_client_get_bool"); - if (my_get_int_func != NULL && my_get_string_func != NULL && - my_get_bool_func != NULL) { - /** - * We did get all we need. Let's enable the System Proxy Settings. - */ - return JNI_TRUE; - } - } - } - } - return JNI_FALSE; +#ifdef USE_SYSTEM_GCONF + gconf_ver = 2; + return JNI_TRUE; +#else + return init_gconf (&gconf_ver, &gconf_client); +#endif + } @@ -170,8 +132,8 @@ if (gconf_ver > 0) { if (gconf_client == NULL) { - (*my_g_type_init_func)(); - gconf_client = (*my_get_default_func)(); + g_type_init(); + gconf_client = gconf_client_get_default(); } if (gconf_client != NULL) { cproto = (*env)->GetStringUTFChars(env, proto, &isCopy); @@ -181,12 +143,12 @@ * entries. */ - use_same_proxy = (*my_get_bool_func)(gconf_client, "/system/http_proxy/use_same_proxy", NULL); + use_same_proxy = gconf_client_get_bool (gconf_client, "/system/http_proxy/use_same_proxy", NULL); if (use_same_proxy) { - use_proxy = (*my_get_bool_func)(gconf_client, "/system/http_proxy/use_http_proxy", NULL); + use_proxy = gconf_client_get_bool (gconf_client, "/system/http_proxy/use_http_proxy", NULL); if (use_proxy) { - phost = (*my_get_string_func)(gconf_client, "/system/http_proxy/host", NULL); - pport = (*my_get_int_func)(gconf_client, "/system/http_proxy/port", NULL); + phost = gconf_client_get_string(gconf_client, "/system/http_proxy/host", NULL); + pport = gconf_client_get_int(gconf_client, "/system/http_proxy/port", NULL); } } @@ -197,11 +159,11 @@ * /system/http_proxy/port (integer) */ if (strcasecmp(cproto, "http") == 0) { - use_proxy = (*my_get_bool_func)(gconf_client, "/system/http_proxy/use_http_proxy", NULL); + use_proxy = gconf_client_get_bool (gconf_client, "/system/http_proxy/use_http_proxy", NULL); if (use_proxy) { if (!use_same_proxy) { - phost = (*my_get_string_func)(gconf_client, "/system/http_proxy/host", NULL); - pport = (*my_get_int_func)(gconf_client, "/system/http_proxy/port", NULL); + phost = gconf_client_get_string(gconf_client, "/system/http_proxy/host", NULL); + pport = gconf_client_get_int(gconf_client, "/system/http_proxy/port", NULL); } CHECK_NULL(type_proxy = (*env)->GetStaticObjectField(env, ptype_class, ptype_httpID)); } @@ -214,11 +176,11 @@ * /system/proxy/secure_port (integer) */ if (strcasecmp(cproto, "https") == 0) { - mode = (*my_get_string_func)(gconf_client, "/system/proxy/mode", NULL); + mode = gconf_client_get_string(gconf_client, "/system/proxy/mode", NULL); if (mode != NULL && (strcasecmp(mode,"manual") == 0)) { if (!use_same_proxy) { - phost = (*my_get_string_func)(gconf_client, "/system/proxy/secure_host", NULL); - pport = (*my_get_int_func)(gconf_client, "/system/proxy/secure_port", NULL); + phost = gconf_client_get_string(gconf_client, "/system/proxy/secure_host", NULL); + pport = gconf_client_get_int(gconf_client, "/system/proxy/secure_port", NULL); } use_proxy = (phost != NULL); if (use_proxy) @@ -233,11 +195,11 @@ * /system/proxy/ftp_port (integer) */ if (strcasecmp(cproto, "ftp") == 0) { - mode = (*my_get_string_func)(gconf_client, "/system/proxy/mode", NULL); + mode = gconf_client_get_string(gconf_client, "/system/proxy/mode", NULL); if (mode != NULL && (strcasecmp(mode,"manual") == 0)) { if (!use_same_proxy) { - phost = (*my_get_string_func)(gconf_client, "/system/proxy/ftp_host", NULL); - pport = (*my_get_int_func)(gconf_client, "/system/proxy/ftp_port", NULL); + phost = gconf_client_get_string(gconf_client, "/system/proxy/ftp_host", NULL); + pport = gconf_client_get_int(gconf_client, "/system/proxy/ftp_port", NULL); } use_proxy = (phost != NULL); if (use_proxy) @@ -252,11 +214,11 @@ * /system/proxy/gopher_port (integer) */ if (strcasecmp(cproto, "gopher") == 0) { - mode = (*my_get_string_func)(gconf_client, "/system/proxy/mode", NULL); + mode = gconf_client_get_string(gconf_client, "/system/proxy/mode", NULL); if (mode != NULL && (strcasecmp(mode,"manual") == 0)) { if (!use_same_proxy) { - phost = (*my_get_string_func)(gconf_client, "/system/proxy/gopher_host", NULL); - pport = (*my_get_int_func)(gconf_client, "/system/proxy/gopher_port", NULL); + phost = gconf_client_get_string(gconf_client, "/system/proxy/gopher_host", NULL); + pport = gconf_client_get_int(gconf_client, "/system/proxy/gopher_port", NULL); } use_proxy = (phost != NULL); if (use_proxy) @@ -271,11 +233,11 @@ * /system/proxy/socks_port (integer) */ if (strcasecmp(cproto, "socks") == 0) { - mode = (*my_get_string_func)(gconf_client, "/system/proxy/mode", NULL); + mode = gconf_client_get_string(gconf_client, "/system/proxy/mode", NULL); if (mode != NULL && (strcasecmp(mode,"manual") == 0)) { if (!use_same_proxy) { - phost = (*my_get_string_func)(gconf_client, "/system/proxy/socks_host", NULL); - pport = (*my_get_int_func)(gconf_client, "/system/proxy/socks_port", NULL); + phost = gconf_client_get_string(gconf_client, "/system/proxy/socks_host", NULL); + pport = gconf_client_get_int(gconf_client, "/system/proxy/socks_port", NULL); } use_proxy = (phost != NULL); if (use_proxy) @@ -295,7 +257,7 @@ * check for the exclude list (aka "No Proxy For" list). * It's a list of comma separated suffixes (e.g. domain name). */ - noproxyfor = (*my_get_string_func)(gconf_client, "/system/proxy/no_proxy_for", NULL); + noproxyfor = gconf_client_get_string(gconf_client, "/system/proxy/no_proxy_for", NULL); if (noproxyfor != NULL) { char *tmpbuf[512];
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/solaris/native/sun/net/spi/gconf2/gconf/gconf-client.h Mon Aug 15 15:53:02 2011 +0100 @@ -0,0 +1,42 @@ +/* + * Copyright (c) 2004, 2010, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +#ifndef GCONF_GCONF_H +#define GCONF_GCONF_H + +/** + * These functions are used by the sun.net.spi.DefaultProxySelector class + * to access some platform specific settings. + * This is the Solaris/Linux Gnome 2.x code using the GConf-2 library. + * Everything is loaded dynamically so no hard link with any library exists. + */ +typedef void* fp_client_get_default_func(); +typedef char* fp_client_get_string_func(void *, char *, void**); +typedef int fp_client_get_int_func(void*, char *, void**); +typedef int fp_client_get_bool_func(void*, char *, void**); +typedef int fp_conf_init_func(int, char**, void**); +typedef void fp_type_init_func (); + +#endif
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/solaris/native/sun/net/spi/gconf2/gconf_fp.c Mon Aug 15 15:53:02 2011 +0100 @@ -0,0 +1,72 @@ +/* + * Copyright (c) 2004, 2010, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +#include <gconf_fp.h> +#include <dlfcn.h> + +fp_client_get_default_func* my_get_default_func = NULL; +fp_client_get_string_func* my_get_string_func = NULL; +fp_client_get_int_func* my_get_int_func = NULL; +fp_client_get_bool_func* my_get_bool_func = NULL; +fp_conf_init_func* my_gconf_init_func = NULL; +fp_type_init_func* my_g_type_init_func = NULL; + +jboolean init_gconf(int* gconf_ver, void** gconf_client) +{ + /** + * Let's try to load le GConf-2 library + */ + if (dlopen("libgconf-2.so", RTLD_GLOBAL | RTLD_LAZY) != NULL || + dlopen("libgconf-2.so.4", RTLD_GLOBAL | RTLD_LAZY) != NULL) { + *gconf_ver = 2; + } + if (*gconf_ver > 0) { + /* + * Now let's get pointer to the functions we need. + */ + my_g_type_init_func = (fp_type_init_func*) dlsym(RTLD_DEFAULT, "g_type_init"); + my_get_default_func = (fp_client_get_default_func*) dlsym(RTLD_DEFAULT, "gconf_client_get_default"); + if (my_g_type_init_func != NULL && my_get_default_func != NULL) { + /** + * Try to connect to GConf. + */ + (*my_g_type_init_func)(); + (*gconf_client) = (*my_get_default_func)(); + if ((*gconf_client) != NULL) { + my_get_string_func = (fp_client_get_string_func*) dlsym(RTLD_DEFAULT, "gconf_client_get_string"); + my_get_int_func = (fp_client_get_int_func*) dlsym(RTLD_DEFAULT, "gconf_client_get_int"); + my_get_bool_func = (fp_client_get_bool_func*) dlsym(RTLD_DEFAULT, "gconf_client_get_bool"); + if (my_get_int_func != NULL && my_get_string_func != NULL && + my_get_bool_func != NULL) { + /** + * We did get all we need. Let's enable the System Proxy Settings. + */ + return JNI_TRUE; + } + } + } + } + return JNI_FALSE; +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/solaris/native/sun/net/spi/gconf2/gconf_fp.h Mon Aug 15 15:53:02 2011 +0100 @@ -0,0 +1,49 @@ +/* + * Copyright (c) 2004, 2010, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +#ifndef GCONF_GCONF_FP_H +#define GCONF_GCONF_FP_H + +#include <gconf/gconf-client.h> +#include <jni.h> +#include <stddef.h> + +extern fp_client_get_default_func* my_get_default_func; +extern fp_client_get_string_func* my_get_string_func; +extern fp_client_get_int_func* my_get_int_func; +extern fp_client_get_bool_func* my_get_bool_func; +extern fp_conf_init_func* my_gconf_init_func; +extern fp_type_init_func* my_g_type_init_func; + +#define gconf_client_get_default (*my_get_default_func) +#define gconf_client_get_string (*my_get_string_func) +#define gconf_client_get_int (*my_get_int_func) +#define gconf_client_get_bool (*my_get_bool_func) +#define gconf_init (*my_gconf_init_func) +#define g_type_init (*my_g_type_init_func) + +jboolean init_gconf(int* gconf_ver, void** gconf_client); + +#endif