jdk/src/solaris/native/sun/xawt/awt_Desktop.c
author art
Thu, 14 Oct 2010 14:07:50 +0400
changeset 6825 795e9fe949d3
parent 5506 202f599c92aa
child 7668 d4a77089c587
permissions -rw-r--r--
6989721: awt native code compiler warnings Reviewed-by: yan, uta
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
     2
 * Copyright (c) 2005, Oracle and/or its affiliates. All rights reserved.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
90ce3da70b43 Initial load
duke
parents:
diff changeset
     4
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
90ce3da70b43 Initial load
duke
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
     7
 * published by the Free Software Foundation.  Oracle designates this
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
     9
 * by Oracle in the LICENSE file that accompanied this code.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    10
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    11
 * This code is distributed in the hope that it will be useful, but WITHOUT
90ce3da70b43 Initial load
duke
parents:
diff changeset
    12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
90ce3da70b43 Initial load
duke
parents:
diff changeset
    13
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
90ce3da70b43 Initial load
duke
parents:
diff changeset
    14
 * version 2 for more details (a copy is included in the LICENSE file that
90ce3da70b43 Initial load
duke
parents:
diff changeset
    15
 * accompanied this code).
90ce3da70b43 Initial load
duke
parents:
diff changeset
    16
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    17
 * You should have received a copy of the GNU General Public License version
90ce3da70b43 Initial load
duke
parents:
diff changeset
    18
 * 2 along with this work; if not, write to the Free Software Foundation,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    19
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    20
 *
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    23
 * questions.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    24
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    25
90ce3da70b43 Initial load
duke
parents:
diff changeset
    26
#include <jni.h>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    27
#include <dlfcn.h>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    28
90ce3da70b43 Initial load
duke
parents:
diff changeset
    29
typedef int gboolean;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
6825
795e9fe949d3 6989721: awt native code compiler warnings
art
parents: 5506
diff changeset
    31
typedef gboolean (GNOME_URL_SHOW_TYPE)(const char *, void **);
795e9fe949d3 6989721: awt native code compiler warnings
art
parents: 5506
diff changeset
    32
typedef gboolean (GNOME_VFS_INIT_TYPE)(void);
795e9fe949d3 6989721: awt native code compiler warnings
art
parents: 5506
diff changeset
    33
795e9fe949d3 6989721: awt native code compiler warnings
art
parents: 5506
diff changeset
    34
GNOME_URL_SHOW_TYPE *gnome_url_show;
795e9fe949d3 6989721: awt native code compiler warnings
art
parents: 5506
diff changeset
    35
GNOME_VFS_INIT_TYPE *gnome_vfs_init;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
int init(){
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
    void *vfs_handle;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
    void *gnome_handle;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
    const char *errmsg;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
    vfs_handle = dlopen("libgnomevfs-2.so.0", RTLD_LAZY);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
    if (vfs_handle == NULL) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
#ifdef INTERNAL_BUILD
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
        fprintf(stderr, "can not load libgnomevfs-2.so\n");
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
#endif
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
        return 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
    dlerror(); /* Clear errors */
6825
795e9fe949d3 6989721: awt native code compiler warnings
art
parents: 5506
diff changeset
    50
    gnome_vfs_init = (GNOME_VFS_INIT_TYPE*)dlsym(vfs_handle, "gnome_vfs_init");
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
    if ((errmsg = dlerror()) != NULL) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
#ifdef INTERNAL_BUILD
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
        fprintf(stderr, "can not find symble gnome_vfs_init\n");
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
#endif
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
        return 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
    // call gonme_vfs_init()
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
    (*gnome_vfs_init)();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
    gnome_handle = dlopen("libgnome-2.so.0", RTLD_LAZY);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
    if (gnome_handle == NULL) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
#ifdef INTERNAL_BUILD
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
        fprintf(stderr, "can not load libgnome-2.so\n");
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
#endif
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
        return 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
    dlerror(); /* Clear errors */
6825
795e9fe949d3 6989721: awt native code compiler warnings
art
parents: 5506
diff changeset
    68
    gnome_url_show = (GNOME_URL_SHOW_TYPE*)dlsym(gnome_handle, "gnome_url_show");
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
    if ((errmsg = dlerror()) != NULL) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
#ifdef INTERNAL_BUILD
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
        fprintf(stderr, "can not find symble gnome_url_show\n");
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
#endif
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
        return 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
    return 1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
 * Class:     sun_awt_X11_XDesktopPeer
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
 * Method:    init
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
 * Signature: ()Z
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
JNIEXPORT jboolean JNICALL Java_sun_awt_X11_XDesktopPeer_init
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
  (JNIEnv *env, jclass cls)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
    int init_ok = init();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
    return init_ok ? JNI_TRUE : JNI_FALSE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
 * Class:     sun_awt_X11_XDesktopPeer
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
 * Method:    gnome_url_show
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
 * Signature: (Ljava/lang/[B;)Z
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
JNIEXPORT jboolean JNICALL Java_sun_awt_X11_XDesktopPeer_gnome_1url_1show
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
  (JNIEnv *env, jobject obj, jbyteArray url_j)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
    gboolean success;
6825
795e9fe949d3 6989721: awt native code compiler warnings
art
parents: 5506
diff changeset
   100
    const char* url_c;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
6825
795e9fe949d3 6989721: awt native code compiler warnings
art
parents: 5506
diff changeset
   102
    if (gnome_url_show == NULL) {
795e9fe949d3 6989721: awt native code compiler warnings
art
parents: 5506
diff changeset
   103
        return JNI_FALSE;
795e9fe949d3 6989721: awt native code compiler warnings
art
parents: 5506
diff changeset
   104
    }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
6825
795e9fe949d3 6989721: awt native code compiler warnings
art
parents: 5506
diff changeset
   106
    url_c = (char*)(*env)->GetByteArrayElements(env, url_j, NULL);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
    // call gnome_url_show(const char* , GError**)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
    success = (*gnome_url_show)(url_c, NULL);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
    (*env)->ReleaseByteArrayElements(env, url_j, (signed char*)url_c, 0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
    return success ? JNI_TRUE : JNI_FALSE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
}