/* JAVADOC COMMENT ELIDED */
KNIEXPORT KNI_RETURNTYPE_INT
    Java_com_sun_j2me_location_PlatformLocationProvider_getLastLocationImpl() {

    jint provider;
    jboolean ret;

    KNI_StartHandles(2);
    KNI_DeclareHandle(string_obj);
    KNI_DeclareHandle(locationInfo);

    provider = KNI_GetParameterAsInt(1);
    KNI_GetParameterAsObject(2, locationInfo);

    ret = getLocation(locationInfo, string_obj, getProviderInfo(provider));    

    KNI_EndHandles();
    KNI_ReturnBoolean(ret);
}
Beispiel #2
0
/* private native void _putWindowContents( Graphics winGraphics , int pixmapPointer ) ; */
KNIEXPORT KNI_RETURNTYPE_VOID
Java_javax_microedition_khronos_egl_EGL10Impl__1putWindowContents() {
    
    jint pixmap = KNI_GetParameterAsInt(2);

    KNI_StartHandles(1);
    KNI_DeclareHandle(graphicsHandle);
    KNI_GetParameterAsObject(1, graphicsHandle);

#ifdef DEBUG
    printf("JSR239_putWindowContents(0x%x, 0x%x)\n",
	   graphicsHandle, pixmap);
#endif
    JSR239_putWindowContents(graphicsHandle, (JSR239_Pixmap *)pixmap, 0);

    KNI_EndHandles();
    KNI_ReturnVoid();
}
Beispiel #3
0
/**
 * 
 * The datetime parameter coming from java is in milliseconds since the
 * epoch 00:00 1/1/1970. It is needed to translate this value to the native
 * date/time representation. (for example, QT uses the same epoch, but in
 * resolution of seconds rather than milliseconds).
 *
 * private native void setDate0 ( int nativeId , long date ) ; 
 * @param date in milliseconds since 00:00 1/1/1970
 */
KNIEXPORT KNI_RETURNTYPE_VOID
Java_javax_microedition_lcdui_DateFieldLFImpl_setDate0() {
    MidpItem *dfPtr = NULL;
    MidpError err;

    jint nativeId = KNI_GetParameterAsInt(1);
    jlong date = KNI_GetParameterAsLong(2); /* Long occupies two parameters */

    dfPtr = (MidpItem *)nativeId;

    err = lfpport_datefield_set_date(dfPtr,(long)(date/1000));

    if (err != KNI_OK) {
      KNI_ThrowNew(midpOutOfMemoryError, NULL);
    }

    KNI_ReturnVoid();
}
/**
 * Native connection registry method to check in connections that are in
 * launch pending state for a specific MIDlet.
 *
 * @param suiteId Suite ID of the MIDlet as zero terminated ASCII byte array
 * @param className Class name of the MIDlet as zero terminated ASCII byte
 *                  array
 */
KNIEXPORT void
KNIDECL(com_sun_midp_io_j2me_push_ConnectionRegistry_checkInByMidlet0) {
    SuiteIdType suiteId;

    KNI_StartHandles(1);
    KNI_DeclareHandle(classNameObj);

    suiteId = KNI_GetParameterAsInt(1);
    KNI_GetParameterAsObject(2, classNameObj);

    SNI_BEGIN_RAW_POINTERS;
    pushcheckinbymidlet(/*(char*)JavaByteArray(suiteIdObj)*/ suiteId,
                        (char*)JavaByteArray(classNameObj));
    SNI_END_RAW_POINTERS;

    KNI_EndHandles();
    KNI_ReturnVoid();
}
/* JAVADOC COMMENT ELIDED */
KNIEXPORT KNI_RETURNTYPE_VOID
    KNIDECL(com_sun_j2me_location_LocationPersistentStorage_updateLandmarkImpl) {
    
    jint landmarkID;
    javacall_result res;
    javacall_landmarkstore_landmark *landmark;
    jint numAddressFields;
    
    KNI_StartHandles(3);
    KNI_DeclareHandle(landmarkObj);
    KNI_DeclareHandle(stringObj);
    GET_PARAMETER_AS_UTF16_STRING(1, storeName)
    landmarkID = KNI_GetParameterAsInt(2);
    KNI_GetParameterAsObject(3, landmarkObj);
    numAddressFields = KNI_GetIntField(landmarkObj, 
            landmarkImplFieldID.numAddressInfoFields);
    landmark = JAVAME_MALLOC(SIZE_OF_LANDMARK_INFO(numAddressFields));

    if (landmark != NULL) {
        if (fill_landmark(landmarkObj, landmark, stringObj) == KNI_TRUE) {
            res = javacall_landmarkstore_landmark_update(storeName, 
                                    (javacall_handle)landmarkID, landmark);
            switch (res) {
                case JAVACALL_OK:
                    /* Landmark updated successfully */
                    break;
                case JAVACALL_INVALID_ARGUMENT:
                    /* wrong landmark ID */
                    KNI_ThrowNew(jsropIllegalArgumentException, 
                                "Landmark does not belong to this store");
                    break;
                default:
                    /* operation Failed */
                    KNI_ThrowNew(jsropIOException, "I/O error");
                    break;
            }
        }
        JAVAME_FREE(landmark);
    }

    RELEASE_UTF16_STRING_PARAMETER
    KNI_EndHandles();
    KNI_ReturnVoid();
}
/* JAVADOC COMMENT ELIDED */
KNIEXPORT KNI_RETURNTYPE_INT
    Java_com_sun_j2me_location_PlatformLocationProvider_getStateImpl() {

    jsr179_state state = JSR179_OUT_OF_SERVICE;
    jint provider = KNI_GetParameterAsInt(1);
    jint ret=0; /* out of service */
    
    if (stateValue.filled == KNI_FALSE) {

        KNI_StartHandles(1);
        KNI_DeclareHandle(clazz);
    
        KNI_FindClass("javax/microedition/location/LocationProvider", clazz);
        if(!KNI_IsNullHandle(clazz)) {
            stateValue.available = KNI_GetStaticIntField(clazz, 
                KNI_GetStaticFieldID(clazz, "AVAILABLE", "I"));
            stateValue.temporarilyUnavailable = KNI_GetStaticIntField(clazz, 
                KNI_GetStaticFieldID(clazz, "TEMPORARILY_UNAVAILABLE", "I"));
            stateValue.outOfService = KNI_GetStaticIntField(clazz, 
                KNI_GetStaticFieldID(clazz, "OUT_OF_SERVICE", "I"));
            stateValue.filled = KNI_TRUE;
        }
        KNI_EndHandles();

    }        

    if (stateValue.filled == KNI_TRUE) {
        jsr179_provider_state((jsr179_handle)provider, &state);
        switch(state) {
            case JSR179_AVAILABLE:
                ret = stateValue.available;
                break;
            case JSR179_TEMPORARILY_UNAVAILABLE:
                ret = stateValue.temporarilyUnavailable;
                break;
            case JSR179_OUT_OF_SERVICE:
            default:
                ret = stateValue.outOfService;
                break;
        }
    }

    KNI_ReturnInt(ret);
}
/**
 * Gets the MIDlet name for the given registered push connection.
 * <p>
 * Java declaration:
 * <pre>
 *     getEntry0([B[BI)I
 * </pre>
 *
 * @param connection The connection to add to the push registry
 * @param midlet A byte array to store the MIDlet name
 * @param midletsize The size of <tt>midlet</tt>
 *
 * @return <tt>0</tt> if successful, otherwise <tt>-1</tt>
 *
 * @throw IOException if the registry entry is too long.
 */
KNIEXPORT KNI_RETURNTYPE_INT
KNIDECL(com_sun_midp_io_j2me_push_ConnectionRegistry_getEntry0) {
    int midletsize;
    char *regentry;
    int regsize ;
    int ret = -1;
    int connLen;
    char *szConn = NULL;

    midletsize = KNI_GetParameterAsInt(3);

    KNI_StartHandles(2);
    KNI_DeclareHandle(conn);
    KNI_DeclareHandle(regObject);

    KNI_GetParameterAsObject(1, conn);
    connLen = KNI_GetArrayLength(conn);
    ret = -1;
    if ((szConn = midpMalloc(connLen)) != NULL) {
        KNI_GetRawArrayRegion(conn, 0, connLen, (jbyte*)szConn);

        KNI_GetParameterAsObject(2, regObject);

        regentry = pushfindconn(szConn);
        if (NULL != regentry) {
            regsize = strlen(regentry) + 1;
            if (regsize < midletsize) {
                KNI_SetRawArrayRegion(regObject, 0, regsize,
                                      (jbyte*)regentry);
                ret = 0;
            }
            else {
                KNI_ThrowNew(midpIOException, "registration too long");
            }
        }
        midpFree(szConn);
    }
    else {
        KNI_ThrowNew(midpOutOfMemoryError, NULL);
    }
    KNI_EndHandles();

    KNI_ReturnInt(ret);
}
KNIEXPORT KNI_RETURNTYPE_VOID
KNIDECL(com_sun_midp_midletsuite_MIDletSuiteImpl_lockMIDletSuite) {
    jboolean isUpdate;
    SuiteIdType suiteId;
    int status;

    suiteId  = KNI_GetParameterAsInt(1);
    isUpdate = KNI_GetParameterAsBoolean(2);
    /* Throw an exception here if we have an error */
    status = lock_storage(suiteId, isUpdate);
    if (status < 0) {
        if (status == OUT_OF_MEM_LEN) {
            KNI_ThrowNew(midpOutOfMemoryError, NULL);
        } else if (status == SUITE_LOCKED) {
            KNI_ThrowNew(midletsuiteLocked, NULL);
        }
    }
    KNI_ReturnVoid();
}
/*
 * Checks out (takes ownership of) an active server connection maintained
 * by push subsystem.
 *
 * @param url URL used during registration of the push entry
 * @param suiteId suite id
 * @return true if the operation succeeds, false otherwise
 */
KNIEXPORT KNI_RETURNTYPE_BOOLEAN
Java_com_sun_jsr082_bluetooth_btspp_BTSPPNotifierImpl_pushCheckout(void)
{
    jboolean retval = KNI_FALSE;
    MidpString wsUrl;
    SuiteIdType suiteId;
    char *szUrl;
    bt_port_t port;
    jfieldID notifHandleID = NULL;
    jfieldID pushHandleID  = NULL;

    KNI_StartHandles(3);
    KNI_DeclareHandle(thisHandle);
    KNI_DeclareHandle(urlHandle);
    KNI_DeclareHandle(classHandle);
    KNI_GetClassPointer(classHandle);

    GET_FIELDID(classHandle, "handle", "I", notifHandleID)
    GET_FIELDID(classHandle, "pushHandle", "I", pushHandleID)

    KNI_GetThisPointer(thisHandle);
    KNI_GetParameterAsObject(1, urlHandle);
    suiteId = KNI_GetParameterAsInt(2);
    wsUrl = midpNewString(urlHandle);
    szUrl = midpJcharsToChars(wsUrl);
    if (bt_push_parse_url(szUrl, &port, NULL) == JAVACALL_OK) {
        if (pushcheckout(szUrl, 0, (char*)midp_suiteid2chars(suiteId)) == -2) {
            KNI_ThrowNew(midpIOException, "Port already in use.");
        } else {
            javacall_handle handle;
            bt_pushid_t pushid = bt_push_checkout_server(&port, &handle, NULL);
            if (pushid != BT_INVALID_PUSH_HANDLE) {
                KNI_SetIntField(thisHandle, pushHandleID, (jint)pushid);
                KNI_SetIntField(thisHandle, notifHandleID, (jint)handle);
                retval = KNI_TRUE;
            }
        }
    }
    midpFree(szUrl);
    MIDP_FREE_STRING(wsUrl);
    KNI_EndHandles();
    KNI_ReturnBoolean(retval);
}
Beispiel #10
0
KNIEXPORT KNI_RETURNTYPE_INT
Java_com_sun_midp_jsr82emul_DeviceEmul_initDevice() {
    LOG("DeviceEmul_initDevice()");
    
    KNI_StartHandles(1);
    KNI_DeclareHandle(buf);
    KNI_GetParameterAsObject(1, buf);
    memcpy(emul_data.local_addr, JavaByteArray(buf), BT_ADDRESS_SIZE);
    KNI_EndHandles();
    
    emul_data.device_class_base = DEFAULT_COD;
    emul_data.device_class = loadCod();
    emul_data.access_code = KNI_GetParameterAsInt(2);

    state |= DEVICE_INITED;
    midp_thread_signal(JSR82_SIGNAL, BTE_SIGNAL_HANDLE, 0);

    KNI_ReturnInt((jint)emul_data.device_class);
}
/**
 * Gets an ARGB integer array from this <tt>ImmutableImage</tt>. The
 * array consists of values in the form of 0xAARRGGBB.
 * <p>
 * Java declaration:
 * <pre>
 *     getRGB([IIIIIII)V
 * </pre>
 *
 * @param rgbData The target integer array for the ARGB data
 * @param offset Zero-based index of first ARGB pixel to be saved
 * @param scanlen Number of intervening pixels between pixels in
 *                the same column but in adjacent rows
 * @param x The x coordinate of the upper left corner of the
 *          selected region
 * @param y The y coordinate of the upper left corner of the
 *          selected region
 * @param width The width of the selected region
 * @param height The height of the selected region
 */
KNIEXPORT KNI_RETURNTYPE_VOID
KNIDECL(javax_microedition_lcdui_ImageData_getRGB) {
    int height = KNI_GetParameterAsInt(7);
    int width = KNI_GetParameterAsInt(6);
    int y = KNI_GetParameterAsInt(5);
    int x = KNI_GetParameterAsInt(4);
    int scanlength = KNI_GetParameterAsInt(3);
    int offset = KNI_GetParameterAsInt(2);
    int *rgbBuffer;
    java_imagedata *srcImageDataPtr;
    gxpport_mutableimage_native_handle srcImageNativeData;
    img_native_error_codes error = IMG_NATIVE_IMAGE_NO_ERROR;

    KNI_StartHandles(2);
    KNI_DeclareHandle(rgbData);
    KNI_DeclareHandle(thisObject);

    KNI_GetParameterAsObject(1, rgbData);
    KNI_GetThisPointer(thisObject);


    SNI_BEGIN_RAW_POINTERS;
    
    rgbBuffer = JavaIntArray(rgbData);

    srcImageDataPtr = IMGAPI_GET_IMAGEDATA_PTR(thisObject);
    srcImageNativeData =
      (gxpport_mutableimage_native_handle)srcImageDataPtr->nativeImageData;    

    if (srcImageDataPtr->isMutable) {
        gxpport_get_mutable_argb(srcImageNativeData,
                                 rgbBuffer, offset, scanlength,
                                 x, y, width, height, 
                                 &error);
    } else {
        gxpport_get_immutable_argb(srcImageNativeData,
                                   rgbBuffer, offset, scanlength,
                                   x, y, width, height, 
                                   &error);
    }

    SNI_END_RAW_POINTERS;
    
    if (error != IMG_NATIVE_IMAGE_NO_ERROR) {
      KNI_ThrowNew(midpOutOfMemoryError, NULL);
    }

    KNI_EndHandles();
    KNI_ReturnVoid();
}
/**
 * Gets all registered push connections associated with the given MIDlet
 * suite.
 * <p>
 * Java declaration:
 * <pre>
 *     list0([BZ[BI)I
 * </pre>
 *
 * @param midlet The MIDlet suite to get push registry entries
 * @param available Which connections to return. If <tt>true</tt>,
 *                  only return the connections with available input.
 *                  Otherwise, return all connection.
 * @param connectionlist A comma separated string of connections stored
 *                       as a byte array.
 * @param listsz The maximum length of the byte array that will be
 *               accepted for <tt>connectionlist</tt>
 *
 * @return <tt>0</tt> if successful, otherwise <tt>-1</tt>
 *
 * @throw IllegalArgumentException If the length <tt>midlet</tt> is
 *                                 too long.
 */
KNIEXPORT KNI_RETURNTYPE_INT
KNIDECL(com_sun_midp_io_j2me_push_ConnectionRegistry_list0) {
    char *midletName = NULL;
    int available;
    int connsize;
    int nameLength;
    char *conn;
    int ret = -1;

    available = KNI_GetParameterAsBoolean(2);
    connsize = KNI_GetParameterAsInt(4);

    KNI_StartHandles(2);

    KNI_DeclareHandle(name);
    KNI_DeclareHandle(connections);
    KNI_GetParameterAsObject(1, name);
    KNI_GetParameterAsObject(3, connections);

    nameLength = KNI_GetArrayLength(name);
    midletName = (char*)midpMalloc(nameLength);
    if (midletName == NULL) {
        KNI_ThrowNew(midpOutOfMemoryError, NULL);
    }
    else {
        KNI_GetRawArrayRegion(name, 0, nameLength, (jbyte*)midletName);

        conn = pushfindsuite(midletName, available);

        if (conn != NULL) {
            KNI_SetRawArrayRegion(connections, 0, strlen(conn), (jbyte*)conn);
            midpFree(conn);
            ret = 0;
        }

        midpFree(midletName);
    }

    KNI_EndHandles();

    KNI_ReturnInt(ret);
}
Beispiel #13
0
/*  protected native int nGetVolume ( int mediaType ) ; */
KNIEXPORT KNI_RETURNTYPE_INT
KNIDECL(com_sun_mmedia_DirectVolume_nGetVolume) {
    jint handle = KNI_GetParameterAsInt(1);
    javacall_result ret = JAVACALL_FAIL;
    long volume;
    KNIPlayerInfo* pKniInfo = (KNIPlayerInfo*)handle;

    MMP_DEBUG_STR("[kni_volume] +nGetVolume\n");

    if (pKniInfo && pKniInfo->pNativeHandle) {
        ret = javacall_media_get_volume(pKniInfo->pNativeHandle, &volume);
    } else {
        MMP_DEBUG_STR("[nGetVolume] Invalid native handle");
    }
    if (ret != JAVACALL_OK) {
        volume = -1;
    }

    KNI_ReturnInt((int)volume);
}
/**
 * Native method void removeComponent(int componentId) of
 * com.sun.midp.midletsuite.DynamicComponentStorage.
 * <p>
 * Removes a dynamic component given its ID.
 * <p>
 * If the component is in use it must continue to be available
 * to the other components that are using it.
 *
 * @param componentId ID of the component ot remove
 *
 * @throws IllegalArgumentException if the component cannot be found
 * @throws MIDletSuiteLockedException is thrown, if the component is
 *                                    locked
 */
KNIEXPORT KNI_RETURNTYPE_VOID
KNIDECL(com_sun_midp_midletsuite_DynamicComponentStorage_removeComponent) {
    MIDPError status;
    MidletSuiteData* pData;
    ComponentIdType componentId = KNI_GetParameterAsInt(1);

    do {
        /* check that the component exists */
        pData = get_component_data(componentId);
        if (pData == NULL) {
            status = NOT_FOUND;
            break;
        }

        status = begin_transaction(TRANSACTION_REMOVE_COMPONENT,
                                   componentId, NULL);
        if (status != ALL_OK) {
            break;
        }

        status = delete_components_files(pData->suiteId, componentId);
        if (status != ALL_OK) {
            break;
        }

        (void)remove_from_component_list_and_save(pData->suiteId, componentId);
    } while(0);

    (void)finish_transaction();

    if (status == SUITE_LOCKED) {
        KNI_ThrowNew(midletsuiteLocked, NULL);
    } else if (status == BAD_PARAMS || status == NOT_FOUND) {
        KNI_ThrowNew(midpIllegalArgumentException, "bad component ID");
    } else if (status != ALL_OK) {
        KNI_ThrowNew(midpRuntimeException,
            (status == OUT_OF_MEMORY) ? "Out of memory!" : "Remove failed");
    }

    KNI_ReturnVoid();
}
Beispiel #15
0
/**
 * The datetime parameter returned to java must be in milliseconds since the
 * epoch 00:00 1/1/1970. 
 * It is needed to translate the native value to the java date/time
 * representation. (for example, QT uses the same epoch, but in
 * resolution of seconds rather than milliseconds, so it is needed to multiply
 * the value by 1000 to pass to java).
 *
 * private native long getDate0 ( int nativeId ) ; 
 * @return date in milliseconds since 00:00 1/1/1970
 */
KNIEXPORT KNI_RETURNTYPE_LONG
Java_javax_microedition_lcdui_DateFieldLFImpl_getDate0() {
    MidpItem *dfPtr = NULL;
    MidpError err;

    jint nativeId = KNI_GetParameterAsInt(1);

    jlong returnValue = 0L ;
    
    dfPtr = (MidpItem *)nativeId;

    err = lfpport_datefield_get_date((long*)(void*)&returnValue, dfPtr);

    if (err != KNI_OK) {
      KNI_ThrowNew(midpOutOfMemoryError, NULL);
    }

    returnValue *= 1000;

    KNI_ReturnLong(returnValue);
}
/**
 * Delete all messages registered against specified suite ID.
 *
 * @param msid The MIDlet suite ID.
 *
 */
KNIEXPORT KNI_RETURNTYPE_VOID
KNIDECL(com_sun_midp_wma_WMACleanupMonitor_deleteMessages0) { 

    /** The MIDP String version of the Midlet suite ID. */
    int msid = UNUSED_APP_ID;

    /* Pick up the Midlet Suite ID string. */
    msid = KNI_GetParameterAsInt(1);

    /*
     * Invoke a native function that will delete all messages
     * registered against msid.
     */
    jsr120_sms_cleanup_midlet_suite(msid);
    jsr120_cbs_delete_midlet_suite_msg(msid);
#if ENABLE_JSR_205
    jsr205_mms_delete_midlet_suite_msg(msid);
#endif

    KNI_ReturnVoid();
}
Beispiel #17
0
/*  protected native boolean nIsMuted ( int mediaType ) ; */
KNIEXPORT KNI_RETURNTYPE_BOOLEAN
KNIDECL(com_sun_mmedia_DirectVolume_nIsMuted) {

    jint handle = KNI_GetParameterAsInt(1);
    javacall_result ret = JAVACALL_FAIL;
    jboolean returnValue = KNI_FALSE;
    javacall_bool isMuted;
    KNIPlayerInfo* pKniInfo = (KNIPlayerInfo*)handle;

    MMP_DEBUG_STR("[kni_volume] +nIsMuted\n");

    if (pKniInfo && pKniInfo->pNativeHandle) {
        ret= javacall_media_is_mute(pKniInfo->pNativeHandle, &isMuted);
    } else {
        MMP_DEBUG_STR("[nIsMuted] Invalid native handle");
    }
    if (ret == JAVACALL_OK) {
        returnValue = (isMuted == JAVACALL_TRUE) ? KNI_TRUE : KNI_FALSE;
    }

    KNI_ReturnBoolean(returnValue);
}
Beispiel #18
0
KNIEXPORT KNI_RETURNTYPE_VOID
Java_com_sun_pisces_AbstractSurface_drawRGBImpl() {
    KNI_StartHandles(2);
    KNI_DeclareHandle(objectHandle);
    KNI_DeclareHandle(arrayHandle);

    jint offset = KNI_GetParameterAsInt(2);
    jint scanLength = KNI_GetParameterAsInt(3);
    jint x = KNI_GetParameterAsInt(4);
    jint y = KNI_GetParameterAsInt(5);
    jint width = KNI_GetParameterAsInt(6);
    jint height = KNI_GetParameterAsInt(7);
    jfloat opacity = KNI_GetParameterAsFloat(8);

    jint srcX = 0;
    jint srcY = 0;

    Surface* surface;

    KNI_GetParameterAsObject(1, arrayHandle);

    KNI_GetThisPointer(objectHandle);
    surface = (Surface*)JLongToPointer(
                  KNI_GetLongField(objectHandle, fieldIds[SURFACE_NATIVE_PTR]));

    CORRECT_DIMS(surface, x, y, width, height, srcX, srcY);

    if ((width > 0) && (height > 0)) {
        jint* tempArray;
        offset += srcY * scanLength + srcX;

        SNI_BEGIN_RAW_POINTERS;

        tempArray = &JavaIntArray(arrayHandle)[offset];

        ACQUIRE_SURFACE(surface, objectHandle);
        surface_drawRGB(surface, x, y, width, height, tempArray, scanLength,
                        opacity);
        RELEASE_SURFACE(surface, objectHandle);

        SNI_END_RAW_POINTERS;
    }

    KNI_EndHandles();
    KNI_ReturnVoid();
}
Beispiel #19
0
/**
 * Stores the romized byte array in corresponding Java array
 * @param the required resource (initialFont or defaultFont)
 *
 */
KNIEXPORT KNI_RETURNTYPE_VOID
Java_com_sun_perseus_platform_ResourceHandler_getRomizedResource() {

	jbyte *font_data;
    int font_type = -1;
    int buflen = -1;
	int size = -1;
    KNI_StartHandles(2);
    KNI_DeclareHandle(clazz);
    KNI_DeclareHandle(bufHandle);
    KNI_GetClassPointer(clazz);
    
    font_type = KNI_GetParameterAsInt(1);
    if (font_type == DEFAULT_FONT) {
        KNI_GetStaticObjectField(clazz, KNI_GetStaticFieldID(clazz, "defaultFont", "[B"), bufHandle);
		size = sizeof(defaultFont);
		font_data = defaultFont;
    } else {
        KNI_GetStaticObjectField(clazz, KNI_GetStaticFieldID(clazz, "initialFont", "[B"), bufHandle);
		size = sizeof(initialFont);
		font_data = initialFont;
    }
    
    if (KNI_IsNullHandle(bufHandle)) {
        KNI_ThrowNew(midpNullPointerException, 0);
    } else {
        buflen = KNI_GetArrayLength(bufHandle);
        if (buflen < size) {
			//REPORT_ERROR(LC_HIGHUI, "java array too small");
            KNI_ThrowNew(midpArrayIndexOutOfBoundsException, 0);
        } else {
			KNI_SetRawArrayRegion(bufHandle, 0, size, (jbyte*)font_data);
        }
    }

    KNI_EndHandles();
    KNI_ReturnVoid();
}
KNIEXPORT KNI_RETURNTYPE_VOID
KNIDECL(com_sun_amms_DirectSoundSource3D_nAddPlayer)
{
    javacall_audio3d_soundsource3d_t *src = getNativePtr(KNIPASSARGS 0);
    KNIPlayerInfo* pKniInfo = (KNIPlayerInfo*)KNI_GetParameterAsInt( 1 );
    javacall_handle player = ( javacall_handle )( pKniInfo->pNativeHandle );
    javacall_result result = JAVACALL_FAIL;

    result = javacall_audio3d_soundsource3d_add_player( src, player );

    if( result == JAVACALL_INVALID_ARGUMENT )
    {
        KNI_ThrowNew( "java/lang/IllegalArgumentException",
"\nInvalid arguments were passed to the native part of \
SoundSource3D.addPlayer\n"
                );
        KNI_ReturnVoid();
    }

    if( result == JAVACALL_NOT_IMPLEMENTED )
    {
        KNI_ThrowNew( "javax/microedition/media/MediaException",
                "\nAdding the Player to SoundSource3D is not supported\n"
            );
        KNI_ReturnVoid();
    }

    if( result != JAVACALL_OK )
    {
        KNI_ThrowNew( "java/lang/RuntimeException",
"\nNative error occurred while adding the Player to SoundSource3D\n"
            );
        KNI_ReturnVoid();
    }


    KNI_ReturnVoid();
}
Beispiel #21
0
/**
 * Get a hostname for the given raw IPv4 address.
 * <p>
 * Java declaration:
 * <pre>
 *     static addrToString(I)Ljava/lang/String;
 * </pre>
 *
 * @param ipn raw IPv4 address
 * @return The hostname or <tt>ipn</tt> as a dotted-quad if
 *         no hostname was found
 */
KNIEXPORT KNI_RETURNTYPE_OBJECT
Java_com_sun_midp_io_j2me_datagram_Protocol_addrToString(void) {
    jint ipn;
    jchar* result;
    int resultLen;
    int status;

    ipn = KNI_GetParameterAsInt(1);

    status = pcsl_network_addrToString((unsigned char*)&ipn, &result,
                                       &resultLen);
    KNI_StartHandles(1);
    KNI_DeclareHandle(resultObj);

    if (PCSL_NET_SUCCESS == status) {
        KNI_NewString(result, (jsize)resultLen, resultObj);
        pcsl_mem_free(result);
    } else {
        KNI_ThrowNew(midpOutOfMemoryError, NULL);
    }

    KNI_EndHandlesAndReturnObject(resultObj);
}
Beispiel #22
0
/* void stop(int exit_code, int exit_reason); */
void Java_com_sun_cldc_isolate_Isolate_stop(JVM_SINGLE_ARG_TRAPS) {
  UsingFastOops fast_oops;
  IsolateObj::Fast isolate_obj = GET_PARAMETER_AS_OOP(0);
  Task::Fast task = isolate_obj().task();
  const int exit_code = KNI_GetParameterAsInt(1);
  const int exit_reason = KNI_GetParameterAsBoolean(2);

  switch (isolate_obj().status()) {
  case Task::TASK_NEW:
    isolate_obj().terminate(exit_code JVM_NO_CHECK_AT_BOTTOM);
    // Isolate was never started, so no threads to kill.
    break;

  case Task::TASK_STARTED:
    GUARANTEE(task.not_null(), "Task must exist for running Isolate");
    task().stop(exit_code, exit_reason JVM_NO_CHECK_AT_BOTTOM);
    break;

  default:
    // OK to call stop() multiple times. Just ignore it.
    break;
  }
}
/**
 * Get the class path for the specified dynamic component.
 *
 * @param componentId unique ID of the component
 *
 * @return class path or null if the component does not exist
 */
KNIEXPORT KNI_RETURNTYPE_OBJECT
KNIDECL(com_sun_midp_midletsuite_DynamicComponentStorage_getComponentJarPath) {
    ComponentIdType componentId;
    MIDPError status;
    pcsl_string classPath = PCSL_STRING_NULL;

    KNI_StartHandles(1);
    KNI_DeclareHandle(resultHandle);

    componentId = KNI_GetParameterAsInt(1);

    status = get_jar_path(COMPONENT_DYNAMIC, (jint)componentId,
                          &classPath);
    if (status != ALL_OK) {
        KNI_ThrowNew(midpRuntimeException, NULL);
        KNI_ReleaseHandle(resultHandle);
    } else {
        midp_jstring_from_pcsl_string(KNIPASSARGS &classPath, resultHandle);
        pcsl_string_free(&classPath);
    }

    KNI_EndHandlesAndReturnObject(resultHandle);
}
Beispiel #24
0
/**
 * java call:
 *     private native String loadFieldValues0(String handlerId, int fieldId);
 */
KNIEXPORT KNI_RETURNTYPE_OBJECT
Java_com_sun_midp_content_RegistryStore_loadFieldValues0(void) {
    int fieldId;
    pcsl_string id = PCSL_STRING_NULL_INITIALIZER;
    JSR211_RESULT_STRARRAY result = _JSR211_RESULT_INITIALIZER_;

    KNI_StartHandles(1);
    KNI_DeclareHandle(strObj);       /* string object */

    KNI_GetParameterAsObject(1, strObj); /* handlerId */
    if (PCSL_STRING_OK == midp_jstring_to_pcsl_string(strObj, &id)) {
        fieldId = KNI_GetParameterAsInt(2);
        jsr211_get_handler_field(&id, fieldId, &result);
        pcsl_string_free(&id);
        result2string((_JSR211_INTERNAL_RESULT_BUFFER_*)&result, strObj);
    } else {
        KNI_ThrowNew(midpOutOfMemoryError, 
                   "RegistryStore_loadFieldValues0 no memory for handler ID");
        KNI_ReleaseHandle(strObj);
    }

    KNI_EndHandlesAndReturnObject(strObj);
}
KNIEXPORT KNI_RETURNTYPE_OBJECT
KNIDECL(com_sun_midp_chameleon_skins_resources_LoadedSkinData_readByteArray) {
    int arrayLength = KNI_GetParameterAsInt(1);

    KNI_StartHandles(1);
    KNI_DeclareHandle(returnArray);

    do {
        ENSURE_SKIN_DATA_AVAILABILITY(arrayLength);

        SNI_NewArray(SNI_BYTE_ARRAY, arrayLength, returnArray);
        if (KNI_IsNullHandle(returnArray)) {
            KNI_ThrowNew(midpOutOfMemoryError, NULL);
            break;
        }

        KNI_SetRawArrayRegion(returnArray, 0, arrayLength, (jbyte*)gsSkinFileDataPos);
        gsSkinFileDataPos += arrayLength;

    } while (0);

    KNI_EndHandlesAndReturnObject(returnArray);
}
Beispiel #26
0
/**
 * Checks out (takes ownership of) an active server connection maintained
 * by push subsystem.
 *
 * @param url URL used during registration of the push entry
 * @param suiteId suite id
 * @return true if the operation succeeds, false otherwise
 */
KNIEXPORT KNI_RETURNTYPE_BOOLEAN
Java_com_sun_midp_io_j2me_btspp_BTSPPNotifierImpl_pushCheckout(void) {
    jboolean retval = KNI_FALSE;
    SuiteIdType suiteId;
    MidpString wsUrl;
    char *szUrl;
    bt_port_t port;

    KNI_StartHandles(2);
    KNI_DeclareHandle(thisHandle);
    KNI_DeclareHandle(urlHandle);
    KNI_GetThisPointer(thisHandle);
    KNI_GetParameterAsObject(1, urlHandle);
    suiteId = KNI_GetParameterAsInt(2);

    wsUrl = midpNewString(urlHandle);
    szUrl = midpJcharsToChars(wsUrl);

    if (bt_push_parse_url(szUrl, &port, NULL) == BT_RESULT_SUCCESS) {
        if (pushcheckout(szUrl, 0, (char*)midp_suiteid2chars(suiteId)) == -2) {
            KNI_ThrowNew(midpIOException, "Port already in use.");
        } else {
            bt_handle_t handle;
            bt_pushid_t pushid = bt_push_checkout_server(&port, &handle, NULL);
            if (pushid != BT_INVALID_PUSH_HANDLE) {
                KNI_SetIntField(thisHandle, pushHandleID, (jint)pushid);
                KNI_SetIntField(thisHandle, notifHandleID, (jint)handle);
                retval = KNI_TRUE;
            }
        }
    }

    midpFree(szUrl);
    MIDP_FREE_STRING(wsUrl);
    KNI_EndHandles();
    KNI_ReturnBoolean(retval);
}
Beispiel #27
0
KNIEXPORT KNI_RETURNTYPE_INT
Java_com_sun_cldc_io_j2me_socket_Protocol_readByte() {
  jint result = -1;
  unsigned char byte;

  int fd = KNI_GetParameterAsInt(1);
  int n = jvm_recv(fd, (char*)&byte, 1, 0);

  if (n == 1) {
    result = byte; // do not sign-extend
    GUARANTEE(0 <= result && result <= 255, "no sign extension");
  }
  else if (n == 0) {
    // If remote side has shut down the connection gracefully, and all
    // data has been received, recv() will complete immediately with
    // zero bytes received.
    //
    // This is true for Win32/CE and Linux
    result = -1;
  }
  else {
    int err_code = GET_LAST_ERROR();
    if (err_code == EWOULDBLOCK) {
      if (SNI_GetReentryData(NULL) == NULL) {
        BlockingSocket *socket =
            (BlockingSocket *)SNI_AllocateReentryData(sizeof(*socket));
        socket->fd = fd;
        socket->check_flags = CHECK_READ;
      }
      SNI_BlockThread();
    } else {
      result = -1;
    }
  }

  KNI_ReturnInt(result);
}
/**
 * Loads a native image data from image cache into ImageData..
 * <p>
 * Java declaration:
 * <pre>
 *     boolean loadCachedImage0(ImageData imageData,
 *                              String suiteId, String resName);
 * </pre>
 *
 * @param imageData The ImageData to be populated
 * @param suiteId   The suite Id
 * @param resName   The name of the image resource
 * @return true if a cached image was loaded, false otherwise
 */
KNIEXPORT KNI_RETURNTYPE_BOOLEAN
KNIDECL(javax_microedition_lcdui_ImageDataFactory_loadCachedImage0) {
#if ENABLE_IMAGE_CACHE
    int len;
    SuiteIdType suiteId;
    jboolean status = KNI_FALSE;
    unsigned char *rawBuffer = NULL;

    KNI_StartHandles(3);

    /* A handle for which KNI_IsNullHandle() check is true */
    KNI_DeclareHandle(nullHandle);

    GET_PARAMETER_AS_PCSL_STRING(3, resName)

    KNI_DeclareHandle(imageData);
    KNI_GetParameterAsObject(1, imageData);

    suiteId = KNI_GetParameterAsInt(2);

    len = loadImageFromCache(suiteId, &resName, &rawBuffer);
    if (len != -1 && rawBuffer != NULL) {
        /* image is found in cache */
        status = gx_load_imagedata_from_raw_buffer(KNIPASSARGS
            imageData, rawBuffer, nullHandle, 0, len);
    }

    midpFree(rawBuffer);

    RELEASE_PCSL_STRING_PARAMETER

    KNI_EndHandles();
    KNI_ReturnBoolean(status);
#else
    KNI_ReturnBoolean(KNI_FALSE);
#endif
}
Beispiel #29
0
/**
 * Checks if this slot is SAT slot. 
 * <p>Java declaration:
 * <pre>
 * private native int isSatSlot0(int slotNumber);
 * </pre>
 * @param slotNumber Slot number
 * @return <code> 1</code> if the slot is dedicated for SAT,
 *         <code> 0</code> if not,
 *         <code>-1</code> if any error occured
 */
KNIEXPORT KNI_RETURNTYPE_INT 
KNIDECL(com_sun_cardreader_PlatformCardDevice_isSatSlot0) {
    jint retcode;
    javacall_bool result;
    MidpReentryData* info;
    javacall_result status_code;
    void *context = NULL;

    int slotIndex = KNI_GetParameterAsInt(1);
    info = (MidpReentryData*)SNI_GetReentryData(NULL);

    if (info == NULL) {
        status_code = javacall_carddevice_is_sat_start(slotIndex, &result, &context);
    } else {
        context = info->pResult;
        status_code = javacall_carddevice_is_sat_finish(slotIndex, &result, context);
    }

    if (status_code == JAVACALL_WOULD_BLOCK) {
        midp_thread_wait(CARD_READER_DATA_SIGNAL, SIGNAL_XFER, context);
        goto end;
    }

    if (status_code != JAVACALL_OK) {
        retcode = -1;
    } else {
        if (result == JAVACALL_FALSE) {
            retcode = 0;
        } else {
            retcode = 1;
        }
    }

end:
    KNI_ReturnInt(retcode);
}
Beispiel #30
0
KNIEXPORT KNI_RETURNTYPE_VOID
Java_com_sun_pisces_AbstractSurface_drawSurfaceImpl() {
    KNI_StartHandles(2);
    KNI_DeclareHandle(objectHandle);
    KNI_DeclareHandle(surfaceHandle);

    jint srcX = KNI_GetParameterAsInt(2);
    jint srcY = KNI_GetParameterAsInt(3);
    jint dstX = KNI_GetParameterAsInt(4);
    jint dstY = KNI_GetParameterAsInt(5);
    jint width = KNI_GetParameterAsInt(6);
    jint height = KNI_GetParameterAsInt(7);
    jfloat opacity = KNI_GetParameterAsFloat(8);

    Surface* dstSurface;
    Surface* srcSurface;

    KNI_GetThisPointer(objectHandle);
    dstSurface = (Surface*)JLongToPointer(
                     KNI_GetLongField(objectHandle, 
                     fieldIds[SURFACE_NATIVE_PTR]));
    KNI_GetParameterAsObject(1, surfaceHandle);
    srcSurface = (Surface*)JLongToPointer(
                     KNI_GetLongField(surfaceHandle, 
                     fieldIds[SURFACE_NATIVE_PTR]));

    CORRECT_DIMS(dstSurface, dstX, dstY, width, height, srcX, srcY);
    CORRECT_DIMS(srcSurface, srcX, srcY, width, height, dstX, dstY);

    if ((width > 0) && (height > 0) && (opacity > 0)) {
        ACQUIRE_SURFACE(dstSurface, objectHandle);
        ACQUIRE_SURFACE(srcSurface, surfaceHandle);
        surface_drawSurface(dstSurface, dstX, dstY, width, height,
                            srcSurface, srcX, srcY, opacity);
        RELEASE_SURFACE(srcSurface, surfaceHandle);
        RELEASE_SURFACE(dstSurface, objectHandle);
    }

    KNI_EndHandles();
    KNI_ReturnVoid();
}