author | michaelm |
Tue, 06 Mar 2012 20:34:38 +0000 | |
changeset 12047 | 320a714614e9 |
parent 9035 | 1255eb81cc2f |
child 16471 | 33bca48c948b |
permissions | -rw-r--r-- |
2 | 1 |
/* |
9035
1255eb81cc2f
7033660: Update copyright year to 2011 on any files changed in 2011
ohair
parents:
8369
diff
changeset
|
2 |
* Copyright (c) 2005, 2011, Oracle and/or its affiliates. All rights reserved. |
2 | 3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 |
* |
|
5 |
* This code is free software; you can redistribute it and/or modify it |
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
|
5506 | 7 |
* published by the Free Software Foundation. Oracle designates this |
2 | 8 |
* particular file as subject to the "Classpath" exception as provided |
5506 | 9 |
* by Oracle in the LICENSE file that accompanied this code. |
2 | 10 |
* |
11 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
|
12 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
13 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
14 |
* version 2 for more details (a copy is included in the LICENSE file that |
|
15 |
* accompanied this code). |
|
16 |
* |
|
17 |
* You should have received a copy of the GNU General Public License version |
|
18 |
* 2 along with this work; if not, write to the Free Software Foundation, |
|
19 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
|
20 |
* |
|
5506 | 21 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
22 |
* or visit www.oracle.com if you need additional information or have any |
|
23 |
* questions. |
|
2 | 24 |
*/ |
25 |
||
26 |
#include <jni.h> |
|
12047
320a714614e9
7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
9035
diff
changeset
|
27 |
#include <jvm_md.h> |
2 | 28 |
#include <dlfcn.h> |
29 |
||
30 |
typedef int gboolean; |
|
31 |
||
6825 | 32 |
typedef gboolean (GNOME_URL_SHOW_TYPE)(const char *, void **); |
33 |
typedef gboolean (GNOME_VFS_INIT_TYPE)(void); |
|
34 |
||
35 |
GNOME_URL_SHOW_TYPE *gnome_url_show; |
|
36 |
GNOME_VFS_INIT_TYPE *gnome_vfs_init; |
|
2 | 37 |
|
38 |
int init(){ |
|
39 |
void *vfs_handle; |
|
40 |
void *gnome_handle; |
|
41 |
const char *errmsg; |
|
42 |
||
12047
320a714614e9
7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
9035
diff
changeset
|
43 |
vfs_handle = dlopen(VERSIONED_JNI_LIB_NAME("gnomevfs-2", "0"), RTLD_LAZY); |
2 | 44 |
if (vfs_handle == NULL) { |
12047
320a714614e9
7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
9035
diff
changeset
|
45 |
vfs_handle = dlopen(JNI_LIB_NAME("gnomevfs-2"), RTLD_LAZY); |
320a714614e9
7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
9035
diff
changeset
|
46 |
if (vfs_handle == NULL) { |
2 | 47 |
#ifdef INTERNAL_BUILD |
12047
320a714614e9
7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
9035
diff
changeset
|
48 |
fprintf(stderr, "can not load libgnomevfs-2.so\n"); |
2 | 49 |
#endif |
12047
320a714614e9
7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
9035
diff
changeset
|
50 |
return 0; |
320a714614e9
7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
9035
diff
changeset
|
51 |
} |
2 | 52 |
} |
53 |
dlerror(); /* Clear errors */ |
|
6825 | 54 |
gnome_vfs_init = (GNOME_VFS_INIT_TYPE*)dlsym(vfs_handle, "gnome_vfs_init"); |
8369
d835f77a7f86
6994933: java.awt.Desktop feature is "intermittently" supported on Solaris. Really unexpected behavior.
dav
parents:
7668
diff
changeset
|
55 |
if (gnome_vfs_init == NULL){ |
d835f77a7f86
6994933: java.awt.Desktop feature is "intermittently" supported on Solaris. Really unexpected behavior.
dav
parents:
7668
diff
changeset
|
56 |
#ifdef INTERNAL_BUILD |
d835f77a7f86
6994933: java.awt.Desktop feature is "intermittently" supported on Solaris. Really unexpected behavior.
dav
parents:
7668
diff
changeset
|
57 |
fprintf(stderr, "dlsym( gnome_vfs_init) returned NULL\n"); |
d835f77a7f86
6994933: java.awt.Desktop feature is "intermittently" supported on Solaris. Really unexpected behavior.
dav
parents:
7668
diff
changeset
|
58 |
#endif |
d835f77a7f86
6994933: java.awt.Desktop feature is "intermittently" supported on Solaris. Really unexpected behavior.
dav
parents:
7668
diff
changeset
|
59 |
return 0; |
d835f77a7f86
6994933: java.awt.Desktop feature is "intermittently" supported on Solaris. Really unexpected behavior.
dav
parents:
7668
diff
changeset
|
60 |
} |
2 | 61 |
if ((errmsg = dlerror()) != NULL) { |
62 |
#ifdef INTERNAL_BUILD |
|
8369
d835f77a7f86
6994933: java.awt.Desktop feature is "intermittently" supported on Solaris. Really unexpected behavior.
dav
parents:
7668
diff
changeset
|
63 |
fprintf(stderr, "can not find symbol gnome_vfs_init %s \n", errmsg); |
2 | 64 |
#endif |
65 |
return 0; |
|
66 |
} |
|
67 |
// call gonme_vfs_init() |
|
68 |
(*gnome_vfs_init)(); |
|
69 |
||
12047
320a714614e9
7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
9035
diff
changeset
|
70 |
gnome_handle = dlopen(VERSIONED_JNI_LIB_NAME("gnome-2", "0"), RTLD_LAZY); |
2 | 71 |
if (gnome_handle == NULL) { |
12047
320a714614e9
7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
9035
diff
changeset
|
72 |
gnome_handle = dlopen(JNI_LIB_NAME("gnome-2"), RTLD_LAZY); |
320a714614e9
7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
9035
diff
changeset
|
73 |
if (gnome_handle == NULL) { |
2 | 74 |
#ifdef INTERNAL_BUILD |
12047
320a714614e9
7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
9035
diff
changeset
|
75 |
fprintf(stderr, "can not load libgnome-2.so\n"); |
2 | 76 |
#endif |
12047
320a714614e9
7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
9035
diff
changeset
|
77 |
return 0; |
320a714614e9
7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
9035
diff
changeset
|
78 |
} |
2 | 79 |
} |
80 |
dlerror(); /* Clear errors */ |
|
6825 | 81 |
gnome_url_show = (GNOME_URL_SHOW_TYPE*)dlsym(gnome_handle, "gnome_url_show"); |
2 | 82 |
if ((errmsg = dlerror()) != NULL) { |
83 |
#ifdef INTERNAL_BUILD |
|
84 |
fprintf(stderr, "can not find symble gnome_url_show\n"); |
|
85 |
#endif |
|
86 |
return 0; |
|
87 |
} |
|
88 |
||
89 |
return 1; |
|
90 |
} |
|
91 |
||
92 |
/* |
|
93 |
* Class: sun_awt_X11_XDesktopPeer |
|
94 |
* Method: init |
|
95 |
* Signature: ()Z |
|
96 |
*/ |
|
97 |
JNIEXPORT jboolean JNICALL Java_sun_awt_X11_XDesktopPeer_init |
|
98 |
(JNIEnv *env, jclass cls) |
|
99 |
{ |
|
100 |
int init_ok = init(); |
|
101 |
return init_ok ? JNI_TRUE : JNI_FALSE; |
|
102 |
} |
|
103 |
||
104 |
/* |
|
105 |
* Class: sun_awt_X11_XDesktopPeer |
|
106 |
* Method: gnome_url_show |
|
107 |
* Signature: (Ljava/lang/[B;)Z |
|
108 |
*/ |
|
109 |
JNIEXPORT jboolean JNICALL Java_sun_awt_X11_XDesktopPeer_gnome_1url_1show |
|
110 |
(JNIEnv *env, jobject obj, jbyteArray url_j) |
|
111 |
{ |
|
112 |
gboolean success; |
|
6825 | 113 |
const char* url_c; |
2 | 114 |
|
6825 | 115 |
if (gnome_url_show == NULL) { |
116 |
return JNI_FALSE; |
|
117 |
} |
|
2 | 118 |
|
6825 | 119 |
url_c = (char*)(*env)->GetByteArrayElements(env, url_j, NULL); |
2 | 120 |
// call gnome_url_show(const char* , GError**) |
121 |
success = (*gnome_url_show)(url_c, NULL); |
|
122 |
(*env)->ReleaseByteArrayElements(env, url_j, (signed char*)url_c, 0); |
|
123 |
||
124 |
return success ? JNI_TRUE : JNI_FALSE; |
|
125 |
} |