jdk/src/solaris/native/sun/xawt/awt_Desktop.c
author michaelm
Tue, 06 Mar 2012 20:34:38 +0000
changeset 12047 320a714614e9
parent 9035 1255eb81cc2f
child 16471 33bca48c948b
permissions -rw-r--r--
7113349: Initial changeset for Macosx port to jdk Reviewed-by: jjh, alanb, dholmes, anthony, ohrstrom, ksrini, jrose, weijun, smarks Contributed-by: Alan Bateman <alan.bateman@oracle.com>, Alexander Potochkin <alexander.potochkin@oracle.com>, Alexander Zuev <alexander.zuev@oracle.com>, Andrew Brygin <andrew.brygin@oracle.com>, Artem Ananiev <artem.ananiev@oracle.com>, Alex Strange <astrange@apple.com>, Bino George <bino@apple.com>, Christine Lu <christine.lu@oracle.com>, David Katleman <david.katleman@oracle.com>, David Durrence <david_durrence@apple.com>, Dmitry Cherepanov <dmitry.cherepanov@oracle.com>, Greg Lewis <glewis@eyesbeyond.com>, Kevin Miller <kevin_m_miller@apple.com>, Kurt Miller <kurt@intricatesoftware.com>, Landon Fuller <landonf@plausiblelabs.com>, Leonid Romanov <leonid.romanov@oracle.com>, Loefty Walkowiak <loefty@apple.com>, Mark Reinhold <mark.reinhold@oracle.com>, Naoto Sato <naoto.sato@oracle.com>, Philip Race <philip.race@oracle.com>, Roger Hoover <rhoover@apple.com>, Scott Kovatch <scott.kovatch@oracle.com>, Sergey ByloKhov <sergey.bylokhov@oracle.com>, Mike Swingler <swingler@apple.com>, Tomas Hurka <tomas.hurka@oracle.com>
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     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
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>
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents: 9035
diff changeset
    27
#include <jvm_md.h>
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    28
#include <dlfcn.h>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    29
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
typedef int gboolean;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
6825
795e9fe949d3 6989721: awt native code compiler warnings
art
parents: 5506
diff changeset
    32
typedef gboolean (GNOME_URL_SHOW_TYPE)(const char *, void **);
795e9fe949d3 6989721: awt native code compiler warnings
art
parents: 5506
diff changeset
    33
typedef gboolean (GNOME_VFS_INIT_TYPE)(void);
795e9fe949d3 6989721: awt native code compiler warnings
art
parents: 5506
diff changeset
    34
795e9fe949d3 6989721: awt native code compiler warnings
art
parents: 5506
diff changeset
    35
GNOME_URL_SHOW_TYPE *gnome_url_show;
795e9fe949d3 6989721: awt native code compiler warnings
art
parents: 5506
diff changeset
    36
GNOME_VFS_INIT_TYPE *gnome_vfs_init;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
int init(){
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
    void *vfs_handle;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
    void *gnome_handle;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
    const char *errmsg;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    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
90ce3da70b43 Initial load
duke
parents:
diff changeset
    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
90ce3da70b43 Initial load
duke
parents:
diff changeset
    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
90ce3da70b43 Initial load
duke
parents:
diff changeset
    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
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
    dlerror(); /* Clear errors */
6825
795e9fe949d3 6989721: awt native code compiler warnings
art
parents: 5506
diff changeset
    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
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
    if ((errmsg = dlerror()) != NULL) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    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
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
    // call gonme_vfs_init()
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
    (*gnome_vfs_init)();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    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
90ce3da70b43 Initial load
duke
parents:
diff changeset
    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
90ce3da70b43 Initial load
duke
parents:
diff changeset
    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
90ce3da70b43 Initial load
duke
parents:
diff changeset
    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
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
    dlerror(); /* Clear errors */
6825
795e9fe949d3 6989721: awt native code compiler warnings
art
parents: 5506
diff changeset
    81
    gnome_url_show = (GNOME_URL_SHOW_TYPE*)dlsym(gnome_handle, "gnome_url_show");
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
    if ((errmsg = dlerror()) != NULL) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
#ifdef INTERNAL_BUILD
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
        fprintf(stderr, "can not find symble gnome_url_show\n");
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
#endif
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
        return 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
    return 1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
 * Class:     sun_awt_X11_XDesktopPeer
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
 * Method:    init
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
 * Signature: ()Z
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
JNIEXPORT jboolean JNICALL Java_sun_awt_X11_XDesktopPeer_init
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
  (JNIEnv *env, jclass cls)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
    int init_ok = init();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
    return init_ok ? JNI_TRUE : JNI_FALSE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
 * Class:     sun_awt_X11_XDesktopPeer
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
 * Method:    gnome_url_show
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
 * Signature: (Ljava/lang/[B;)Z
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
JNIEXPORT jboolean JNICALL Java_sun_awt_X11_XDesktopPeer_gnome_1url_1show
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
  (JNIEnv *env, jobject obj, jbyteArray url_j)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
    gboolean success;
6825
795e9fe949d3 6989721: awt native code compiler warnings
art
parents: 5506
diff changeset
   113
    const char* url_c;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
6825
795e9fe949d3 6989721: awt native code compiler warnings
art
parents: 5506
diff changeset
   115
    if (gnome_url_show == NULL) {
795e9fe949d3 6989721: awt native code compiler warnings
art
parents: 5506
diff changeset
   116
        return JNI_FALSE;
795e9fe949d3 6989721: awt native code compiler warnings
art
parents: 5506
diff changeset
   117
    }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
6825
795e9fe949d3 6989721: awt native code compiler warnings
art
parents: 5506
diff changeset
   119
    url_c = (char*)(*env)->GetByteArrayElements(env, url_j, NULL);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
    // call gnome_url_show(const char* , GError**)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
    success = (*gnome_url_show)(url_c, NULL);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
    (*env)->ReleaseByteArrayElements(env, url_j, (signed char*)url_c, 0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
    return success ? JNI_TRUE : JNI_FALSE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
}