/** * java call: * private native String getValues0(String callerId, int searchBy); */ KNIEXPORT KNI_RETURNTYPE_OBJECT Java_com_sun_midp_content_RegistryStore_getValues0(void) { jsr211_field searchBy; pcsl_string callerId = PCSL_STRING_NULL_INITIALIZER; JSR211_RESULT_STRARRAY result = _JSR211_RESULT_INITIALIZER_; KNI_StartHandles(1); KNI_DeclareHandle(strObj); // String object do { KNI_GetParameterAsObject(1, strObj); // callerId if (PCSL_STRING_OK != midp_jstring_to_pcsl_string(strObj, &callerId)) { KNI_ThrowNew(midpOutOfMemoryError, "RegistryStore_getValues0 no memory for string arguments"); break; } searchBy = (jsr211_field) KNI_GetParameterAsInt(2); jsr211_get_all(&callerId, searchBy, &result); } while (0); pcsl_string_free(&callerId); result2string((_JSR211_INTERNAL_RESULT_BUFFER_*)&result, strObj); KNI_EndHandlesAndReturnObject(strObj); }
/* private native boolean nCheckFileExist ( String path ) ; */ KNIEXPORT KNI_RETURNTYPE_BOOLEAN KNIDECL(com_sun_mmedia_protocol_FileDS_nCheckFileExist) { #define MAX_FILENAME_SIZE 100 jboolean returnValue = KNI_FALSE; jsize length; jchar uFileName[MAX_FILENAME_SIZE + 1] = {0}; KNI_StartHandles(1); KNI_DeclareHandle(pathHandle); /* KNI_GetParameterAsObject(1, pathHandle); length = KNI_GetStringLength(pathHandle); if (length < MAX_FILENAME_SIZE) { KNI_GetStringRegion(pathHandle, 0, length, uFileName); if (JAVACALL_OK == javacall_file_exist(uFileName, length)) { returnValue = KNI_TRUE; } } */ KNI_EndHandles(); KNI_ReturnBoolean(returnValue); }
/** * Adds a connection to the push registry. * <p> * Java declaration: * <pre> * add0([B)I * </pre> * * @param connection The connection to add to the push registry * * @return <tt>0</tt> upon successfully adding the connection, otherwise * <tt>-1</tt> if connection already exists */ KNIEXPORT KNI_RETURNTYPE_INT KNIDECL(com_sun_midp_io_j2me_push_ConnectionRegistry_add0) { char *szConn = NULL; int connLen; int ret = -1; KNI_StartHandles(1); KNI_DeclareHandle(conn); KNI_GetParameterAsObject(1, conn); connLen = KNI_GetArrayLength(conn); szConn = midpMalloc(connLen); if (szConn != NULL) { KNI_GetRawArrayRegion(conn, 0, connLen, (jbyte*)szConn); ret = pushadd(szConn); midpFree(szConn); } if ((szConn == NULL) || (ret == -2)) { KNI_ThrowNew(midpOutOfMemoryError, NULL); } KNI_EndHandles(); KNI_ReturnInt(ret); }
/* private native int _eglInitialize ( int display , int [ ] major_minor ) ; */ KNIEXPORT KNI_RETURNTYPE_INT Java_javax_microedition_khronos_egl_EGL10Impl__1eglInitialize() { jint display = KNI_GetParameterAsInt(1); EGLint major, minor; jint returnValue; KNI_StartHandles(1); KNI_DeclareHandle(major_minorHandle); KNI_GetParameterAsObject(2, major_minorHandle); returnValue = (jint) eglInitialize((EGLDisplay)display, &major, &minor); #ifdef DEBUG printf("eglInitialize(0x%x, major<-%d, minor<-%d) = %d\n", display, major, minor, returnValue); #endif if ((returnValue == EGL_TRUE) && !KNI_IsNullHandle(major_minorHandle)) { KNI_SetIntArrayElement(major_minorHandle, 0, major); KNI_SetIntArrayElement(major_minorHandle, 1, minor); } KNI_EndHandles(); KNI_ReturnInt(returnValue); }
/** * Native finalizer to reset the native peer event queue when * the Isolate ends. */ KNIEXPORT KNI_RETURNTYPE_VOID Java_com_sun_midp_events_EventQueue_finalize(void) { jint queueId; EventQueue* pEventQueue; KNI_StartHandles(1); KNI_DeclareHandle(thisObject); KNI_GetThisPointer(thisObject); SNI_BEGIN_RAW_POINTERS; queueId = getEventQueuePtr(thisObject)->queueId; SNI_END_RAW_POINTERS; KNI_EndHandles(); if (queueId >= 0) { resetEventQueue(queueId); /* Mark queue as inactive */ GET_EVENT_QUEUE_BY_ID(pEventQueue, queueId); pEventQueue->isActive = KNI_FALSE; } KNI_ReturnVoid(); }
/** * private native void init0(int sender, int receiver); */ KNIEXPORT KNI_RETURNTYPE_VOID Java_com_sun_midp_links_Link_init0(void) { int sender; int receiver; rendezvous *rp; KNI_StartHandles(1); KNI_DeclareHandle(thisObj); sender = KNI_GetParameterAsInt(1); receiver = KNI_GetParameterAsInt(2); KNI_GetThisPointer(thisObj); rp = rp_create(sender, receiver); if (rp == NULL) { KNI_ThrowNew(midpOutOfMemoryError, NULL); } else { setNativePointer(thisObj, rp); rp_incref(rp); } KNI_EndHandles(); KNI_ReturnVoid(); }
/* private native int _eglQueryContext ( int display , int ctx , int attribute , int [ ] value ) ; */ KNIEXPORT KNI_RETURNTYPE_INT Java_javax_microedition_khronos_egl_EGL10Impl__1eglQueryContext() { jint display = KNI_GetParameterAsInt(1); jint ctx = KNI_GetParameterAsInt(2); jint attribute = KNI_GetParameterAsInt(3); EGLint value; jint returnValue = EGL_FALSE; KNI_StartHandles(1); KNI_DeclareHandle(valueHandle); KNI_GetParameterAsObject(4, valueHandle); returnValue = (jint)eglQueryContext((EGLDisplay)display, (EGLContext)ctx, attribute, &value); #ifdef DEBUG printf("eglQueryContext(0x%x, 0x%x, %d, value<-%d) = %d\n", display, ctx, attribute, value, returnValue); #endif if ((returnValue == EGL_TRUE) && !KNI_IsNullHandle(valueHandle)) { KNI_SetIntArrayElement(valueHandle, 0, value); } KNI_EndHandles(); KNI_ReturnInt(returnValue); }
/** * Gets a handle to specific character encoding conversion routine. * <p> * Java declaration: * <pre> * getHandler(Ljava/lang/String;)I * </pre> * * @param encoding character encoding * * @return identifier for requested handler, or <tt>-1</tt> if * the encoding was not supported. */ KNIEXPORT KNI_RETURNTYPE_INT Java_com_sun_cldc_i18n_j2me_Conv_getHandler() { jint result = 0; KNI_StartHandles(1); KNI_DeclareHandle(str); KNI_GetParameterAsObject(1, str); if (!KNI_IsNullHandle(str)) { int strLen = KNI_GetStringLength(str); jchar* strBuf; /* Instead of always multiplying the length by sizeof(jchar), * we shift left by 1. This can be done because jchar has a * size of 2 bytes. */ strBuf = (jchar*)midpMalloc(strLen<<1); if (strBuf != NULL) { KNI_GetStringRegion(str, 0, strLen, strBuf); result = getLcConvMethodsID(strBuf, strLen); midpFree(strBuf); } else { KNI_ThrowNew(midpOutOfMemoryError, NULL); } } KNI_EndHandles(); KNI_ReturnInt(result); }
/** * Gets the length of a specific converted string as an array of * Unicode bytes. * <p> * Java declaration: * <pre> * sizeOfByteInUnicode(I[BII)I * </pre> * * @param handler handle returned from getHandler * @param b buffer of bytes to be converted * @param offset offset into the provided buffer * @param length length of data to be processed * * @return length of the converted string, or zero if the * arguments were not valid */ KNIEXPORT KNI_RETURNTYPE_INT Java_com_sun_cldc_i18n_j2me_Conv_sizeOfByteInUnicode() { int length = KNI_GetParameterAsInt(4); int offset = KNI_GetParameterAsInt(3); int id = KNI_GetParameterAsInt(1); char *buf; jint result = 0; KNI_StartHandles(1); KNI_DeclareHandle(b); KNI_GetParameterAsObject(2, b); buf = (char*)midpMalloc(length); if (buf == NULL) { KNI_ThrowNew(midpOutOfMemoryError, NULL); } else { KNI_GetRawArrayRegion(b, offset, length, (jbyte*)buf); result = lcConv[id] ? lcConv[id]->sizeOfByteInUnicode((const unsigned char *)buf, offset, length) : 0; midpFree(buf); } KNI_EndHandles(); KNI_ReturnInt(result); }
KNIEXPORT KNI_RETURNTYPE_OBJECT KNIDECL(javax_microedition_lcdui_TextFieldLFImpl_mallocToJavaChars) { KNI_StartHandles(1); KNI_DeclareHandle(temp); KNI_ReleaseHandle(temp); KNI_EndHandlesAndReturnObject(temp); }
/* private native int nSetLocator ( int handle , String locator ) ; */ KNIEXPORT KNI_RETURNTYPE_INT Java_com_sun_mmedia_DirectRecord_nSetLocator() { jint handle = KNI_GetParameterAsInt(1); KNIPlayerInfo* pKniInfo = (KNIPlayerInfo*)handle; jint locatorLength; jchar* locator = NULL; jint returnValue = 0; javacall_result ret; KNI_StartHandles(1); KNI_DeclareHandle(locatorHandle); KNI_GetParameterAsObject(2, locatorHandle); locatorLength = KNI_GetStringLength(locatorHandle); locator = MMP_MALLOC(locatorLength * sizeof(jchar)); if (locator) { KNI_GetStringRegion(locatorHandle, 0, locatorLength, locator); if (pKniInfo && pKniInfo->pNativeHandle) { ret = javacall_media_recording_handled_by_native(pKniInfo->pNativeHandle, locator, locatorLength); if (JAVACALL_INVALID_ARGUMENT == ret) { returnValue = -1; REPORT_ERROR1(LC_MMAPI, "[kni_record] Set recording location \ return JAVACALL_INVALID_ARGUMENT handle=%d\n", pKniInfo->pNativeHandle); } else { if (JAVACALL_OK == ret) {
KNIEXPORT KNI_RETURNTYPE_OBJECT KNIDECL(javax_microedition_lcdui_TextFieldLFImpl_getNativeEditorContent) { KNI_StartHandles(1); KNI_DeclareHandle(temp); KNI_ReleaseHandle(temp); KNI_EndHandlesAndReturnObject(temp); }
/** * Sets the requested socket option. * <p> * Java declaration: * <pre> * setSockOpt(II)V * </pre> * * @param option socket option to set * @param value the value to set <tt>option</tt> to */ KNIEXPORT KNI_RETURNTYPE_VOID Java_com_sun_midp_io_j2me_socket_Protocol_setSockOpt0(void) { int option; int value; void *pcslHandle; int status = PCSL_NET_INVALID; value = (int)KNI_GetParameterAsInt(2); option = (int)KNI_GetParameterAsInt(1); KNI_StartHandles(1); KNI_DeclareHandle(thisObject); KNI_GetThisPointer(thisObject); pcslHandle = (void *)(getMidpSocketProtocolPtr(thisObject)->handle); KNI_EndHandles(); if (INVALID_HANDLE == pcslHandle) { KNI_ThrowNew(midpIOException, "invalid handle during socket::getPort"); } else { status = pcsl_network_setsockopt(pcslHandle, option, value); if (status == PCSL_NET_IOERROR) { KNI_ThrowNew(midpIllegalArgumentException, "Unsupported Socket Option"); } else if (PCSL_NET_INVALID == status) { KNI_ThrowNew(midpIllegalArgumentException, "Illegal Socket Option Value"); } } KNI_ReturnVoid(); }
/** * Gets the requested port number. * <p> * Java declaration: * <pre> * getPort(Z)I * </pre> * * @param local <tt>true</tt> to get the local port number, or * <tt>false</tt> to get the remote port number * * @return the port number */ KNIEXPORT KNI_RETURNTYPE_INT Java_com_sun_midp_io_j2me_socket_Protocol_getPort0(void) { int local; void *pcslHandle; int port = 0; int status = PCSL_NET_INVALID; local = (int)KNI_GetParameterAsInt(1); KNI_StartHandles(1); KNI_DeclareHandle(thisObject); KNI_GetThisPointer(thisObject); pcslHandle = (void *)(getMidpSocketProtocolPtr(thisObject)->handle); KNI_EndHandles(); if (INVALID_HANDLE == pcslHandle) { KNI_ThrowNew(midpIOException, "invalid handle during socket::getPort"); } else { if (local == 1) { status = pcsl_network_getlocalport(pcslHandle, &port); } else { status = pcsl_network_getremoteport(pcslHandle, &port); } if (status == PCSL_NET_IOERROR) { KNI_ThrowNew(midpIOException, NULL); } } KNI_ReturnInt((jint)port); }
static jboolean initializeSurfaceFieldIds(jobject objectHandle) { static const FieldDesc surfaceFieldDesc[] = { { "nativePtr", "J" }, { NULL, NULL } }; jboolean retVal; if (fieldIdsInitialized) { return KNI_TRUE; } retVal = KNI_FALSE; KNI_StartHandles(1); KNI_DeclareHandle(classHandle); KNI_GetObjectClass(objectHandle, classHandle); if (initializeFieldIds(fieldIds, classHandle, surfaceFieldDesc)) { retVal = KNI_TRUE; fieldIdsInitialized = KNI_TRUE; } KNI_EndHandles(); return retVal; }
/** * Gets the length of a specific converted string as an array of * Unicode characters. * <p> * Java declaration: * <pre> * sizeOfUnicodeInByte(I[CII)I * </pre> * * @param handler handle returned from getHandler * @param c buffer of characters to be converted * @param offset offset into the provided buffer * @param length length of data to be processed * * @return length of the converted string, or zero if the * arguments were not valid */ KNIEXPORT KNI_RETURNTYPE_INT Java_com_sun_cldc_i18n_j2me_Conv_sizeOfUnicodeInByte() { int length = KNI_GetParameterAsInt(4); int offset = KNI_GetParameterAsInt(3); int id = KNI_GetParameterAsInt(1); jchar *buf; jint result = 0; KNI_StartHandles(1); KNI_DeclareHandle(c); KNI_GetParameterAsObject(2, c); /* Instead of always multiplying the length by sizeof(jchar), * we shift left by 1. This can be done because jchar has a * size of 2 bytes. */ buf = (jchar*)midpMalloc(length<<1); if (buf == NULL) { KNI_ThrowNew(midpOutOfMemoryError, NULL); } else { KNI_GetRawArrayRegion(c, offset<<1, length<<1, (jbyte*)buf); result = lcConv[id] ? lcConv[id]->sizeOfUnicodeInByte((const jchar *)buf, offset, length) : 0; midpFree(buf); } KNI_EndHandles(); KNI_ReturnInt(result); }
/** * public native void close(); */ KNIEXPORT KNI_RETURNTYPE_VOID Java_com_sun_midp_links_Link_close(void) { rendezvous *rp; KNI_StartHandles(1); KNI_DeclareHandle(thisObj); KNI_GetThisPointer(thisObj); rp = getNativePointer(thisObj); /* ignore if closed twice */ if (rp != NULL) { if (rp->sender == JVM_CurrentIsolateID() && rp->msg != INVALID_REFERENCE_ID) { /* we're the sender, make sure to clean out our message */ SNI_DeleteReference(rp->msg); rp->msg = INVALID_REFERENCE_ID; } rp->state = CLOSED; midp_thread_signal(LINK_READY_SIGNAL, (int)rp, 0); setNativePointer(thisObj, NULL); rp_decref(rp); } KNI_EndHandles(); KNI_ReturnVoid(); }
/** * Releases any native resources used by this immutable <tt>ImageData</tt>. * <p> * Java declaration: * <pre> * finalize()V * </pre> */ KNIEXPORT KNI_RETURNTYPE_VOID Java_javax_microedition_lcdui_ImageData_finalize() { java_imagedata * imageDataPtr = NULL; gxpport_image_native_handle h; KNI_StartHandles(1); KNI_DeclareHandle(thisObject); KNI_GetThisPointer(thisObject); imageDataPtr = IMGAPI_GET_IMAGEDATA_PTR(thisObject); /* * Image objects with NULL nativeImageData could exist when loading * romized image but failed. */ h = (gxpport_image_native_handle)imageDataPtr->nativeImageData; if (h != NULL) { if (imageDataPtr->isMutable) { gxpport_destroy_mutable(h); } else { gxpport_destroy_immutable(h); } } KNI_EndHandles(); KNI_ReturnVoid(); }
/** * Initializes the native peer of this <tt>Font</tt>. * <p> * Java declaration: * <pre> * init(III)V * </pre> * * @param face The face of the font to initialize * @param style The style of the font to initialize * @param size The point size of the font to initialize */ KNIEXPORT KNI_RETURNTYPE_VOID KNIDECL(javax_microedition_lcdui_Font_init) { jboolean free_size = KNI_GetParameterAsBoolean(4); int size = (int)KNI_GetParameterAsInt(3); int style = (int)KNI_GetParameterAsInt(2); int face = (int)KNI_GetParameterAsInt(1); int ascent, descent, leading; KNI_StartHandles(1); KNI_DeclareHandle(thisObject); if (free_size == KNI_FALSE) { /* size is one of the SIZE_XXX constants */ size = OEM_FONT_SIZE(size); } KNI_GetParameterAsObject(0, thisObject); gx_get_fontinfo(face, style, size, &ascent, &descent, &leading); SNI_BEGIN_RAW_POINTERS; GET_FONT_PTR(thisObject)->baseline = (jint)ascent; GET_FONT_PTR(thisObject)->height = (jint)(ascent + descent + leading); GET_FONT_PTR(thisObject)->size = (jint)size; GET_FONT_PTR(thisObject)->sizeRounded = (jint) LCDUI_FONT_SIZE(size); SNI_END_RAW_POINTERS; KNI_EndHandles(); KNI_ReturnVoid(); }
KNIEXPORT KNI_RETURNTYPE_BOOLEAN Java_com_sun_midp_jsr82emul_ConnectionEmul_getOutData() { int myHandle = (int)KNI_GetParameterAsInt(1); connection_info_t *info = &emul_data.handled_info[myHandle].conn; jboolean ret = KNI_TRUE; int buflen; LOG1("ConnectionEmul_getOutData(%d)", myHandle); if (info->flags & IN_USE) { KNI_StartHandles(1); KNI_DeclareHandle(buf); KNI_GetParameterAsObject(2, buf); buflen = KNI_GetArrayLength(buf); if (info->out_len < buflen) { LOG1("ConnectionEmul_getOutData(%d) requests too much data", myHandle); ret = KNI_FALSE; } else { memcpy(JavaByteArray(buf), info->out, buflen); info->out_len -= buflen; memmove(info->out, &info->out[buflen], info->out_len); info->out = midpRealloc(info->out, info->out_len); if (info->out_len == 0) { info->out = NULL; } } KNI_EndHandles(); } else { ret = KNI_FALSE; } KNI_ReturnBoolean(ret); }
/* private native int _eglCopyBuffers ( int display , int surface , Graphics target ) ; */ KNIEXPORT KNI_RETURNTYPE_INT Java_javax_microedition_khronos_egl_EGL10Impl__1eglCopyBuffers() { EGLDisplay display = (EGLDisplay) KNI_GetParameterAsInt(1); EGLSurface surface = (EGLSurface) KNI_GetParameterAsInt(2); jint width = KNI_GetParameterAsInt(4); jint height = KNI_GetParameterAsInt(5); jint flip = 0; JSR239_Pixmap *pixmap = (JSR239_Pixmap *) 0; EGLBoolean returnValue = EGL_FALSE; KNI_StartHandles(1); KNI_DeclareHandle(graphicsHandle); KNI_GetParameterAsObject(3, graphicsHandle); returnValue = (jint)eglCopyBuffers((EGLDisplay) display, (EGLSurface) surface, (NativePixmapType) pixmap); #ifdef DEBUG printf("eglCopyBuffers(0x%x, 0x%x, 0x%x) = %d\n", display, surface, pixmap, returnValue); #endif /* Workaround - use glReadPixels if eglCopyBuffers fails. */ if (returnValue == EGL_FALSE) { pixmap = JSR239_getImagePixmap(graphicsHandle, width, height, 4, 8, 8, 8, 8); if (!pixmap) { KNI_ThrowNew("java.lang.OutOfMemoryException", "eglCopyBuffers"); goto exit; } // Enforce RGBA order of glReadPixels pixmap->aOffset = 24; pixmap->bOffset = 16; pixmap->gOffset = 8; pixmap->rOffset = 0; returnValue = eglCopyBuffersWorkaround((EGLDisplay) display, (EGLSurface) surface, pixmap); flip = 1; } if (returnValue == EGL_TRUE) { JSR239_putWindowContents(graphicsHandle, pixmap, flip); } if (pixmap) { JSR239_destroyPixmap(pixmap); } exit: KNI_EndHandles(); KNI_ReturnInt((jint)returnValue); }
/** * Perform a platform-defined procedure for obtaining random bytes and * store the obtained bytes into b, starting from index 0. * (see IETF RFC 1750, Randomness Recommendations for Security, * http://www.ietf.org/rfc/rfc1750.txt) * @param b array that receives random bytes * @param nbytes the number of random bytes to receive, must not be less than size of b * @return the number of actually obtained random bytes, -1 in case of an error */ KNIEXPORT KNI_RETURNTYPE_BOOLEAN KNIDECL(com_sun_midp_crypto_PRand_getRandomBytes) { jint size; jboolean res = KNI_FALSE; unsigned char* buffer; KNI_StartHandles(1); KNI_DeclareHandle(hBytes); KNI_GetParameterAsObject(1, hBytes); size = KNI_GetParameterAsInt(2); buffer = pcsl_mem_malloc(size); if (0 == buffer) { KNI_ThrowNew(midpOutOfMemoryError, NULL); } else { int i; res = get_random_bytes_port(buffer, size); for(i=0; i<size; i++) { KNI_SetByteArrayElement(hBytes,i,(jbyte)buffer[i]); } pcsl_mem_free(buffer); } KNI_EndHandles(); KNI_ReturnBoolean(res); }
/** * Reports a fatal error that cannot be handled in Java. * Must be called from a KNI method * */ void handleFatalError(void) { KNI_StartHandles(1); KNI_DeclareHandle(throwableObj); KNI_GetParameterAsObject(1, throwableObj); /* IMPL NOTE: Figure out what throwable class this is and log the error? */ REPORT_CRIT1(LC_CORE, "handleFatalError: uncaught exception in " "isolate %d event processing thread", getCurrentIsolateId()); KNI_EndHandles(); if (getCurrentIsolateId() == midpGetAmsIsolateId()) { /* AMS isolate or SVM mode, terminate VM */ midp_exitVM(-1); } else { MidpEvent event; /* Application isolate, notify the AMS isolate. */ MIDP_EVENT_INITIALIZE(event); event.type = FATAL_ERROR_NOTIFICATION; event.intParam1 = getCurrentIsolateId(); /* Send the shutdown event. */ StoreMIDPEventInVmThread(event, midpGetAmsIsolateId()); } KNI_ReturnVoid(); }
/** * Sets the content buffer. All paints are done to that buffer. * When paint is processed snapshot of the buffer is flushed to * the native resource content area. * Native implementation of Java function: * private static native int setContentBuffer0 ( int nativeId, Image img ); * @param nativeId native resource is for this CustomItem * @param img mutable image that serves as an offscreen buffer */ KNIEXPORT KNI_RETURNTYPE_VOID Java_javax_microedition_lcdui_CustomItemLFImpl_setContentBuffer0() { MidpError err = KNI_OK; unsigned char* imgPtr = NULL; MidpItem *ciPtr = (MidpItem *)KNI_GetParameterAsInt(1); KNI_StartHandles(1); KNI_DeclareHandle(image); KNI_GetParameterAsObject(2, image); if (KNI_IsNullHandle(image) != KNI_TRUE) { imgPtr = gxp_get_imagedata(image); } KNI_EndHandles(); err = lfpport_customitem_set_content_buffer(ciPtr, imgPtr); if (err != KNI_OK) { KNI_ThrowNew(midpOutOfMemoryError, NULL); } KNI_ReturnVoid(); }
/** * Force Bluetooth stack to listen for incoming client connections. * * Note: the method gets native connection handle directly from * <code>handle<code> field of <code>L2CAPNotifierImpl</code> object. * * @throws IOException if an I/O error occurs */ KNIEXPORT KNI_RETURNTYPE_VOID Java_com_sun_midp_io_j2me_btl2cap_L2CAPNotifierImpl_listen0(void) { javacall_handle handle = BT_INVALID_HANDLE; REPORT_INFO(LC_PROTOCOL, "btl2cap_notif::listen"); KNI_StartHandles(1); KNI_DeclareHandle(thisHandle); KNI_GetThisPointer(thisHandle); if (KNI_GetIntField(thisHandle, pushHandleID) == BT_INVALID_PUSH_HANDLE) { handle = (javacall_handle)KNI_GetIntField(thisHandle, notifHandleID); /* force listening */ if (javacall_bt_l2cap_listen(handle) == JAVACALL_FAIL) { javacall_bt_l2cap_close(handle); REPORT_ERROR(LC_PROTOCOL, "L2CAP notifier listen failed in btl2cap_notif::listen"); KNI_ThrowNew(midpIOException, EXCEPTION_MSG("L2CAP notifier listen failed")); } else { REPORT_INFO(LC_PROTOCOL, "btl2cap_notif::listen done!"); } } KNI_EndHandles(); KNI_ReturnVoid(); }
/** * KNI function that sets new content on the native resource corresponding to * the current StringItem. * * Class: javax.microedition.lcdui.StringLFImpl * Java prototype: * private native int setContent0(int nativeId, Image image, altText, * appearanceMode) * * INTERFACE (operand stack manipulation): * parameters: nativeId pointer to the native resource of the StringItem * text the new string set in the StringItem * appearanceMode the appearance mode of the passed in text * returns: <nothing> */ KNIEXPORT KNI_RETURNTYPE_VOID Java_javax_microedition_lcdui_StringItemLFImpl_setContent0() { MidpError err = KNI_OK; MidpItem *itemPtr = (MidpItem *)KNI_GetParameterAsInt(1); int appearanceMode = KNI_GetParameterAsInt(3); pcsl_string text; pcsl_string_status rc; KNI_StartHandles(1); KNI_DeclareHandle(textJString); KNI_GetParameterAsObject(2, textJString); rc = midp_kjstring_to_pcsl_string(textJString, &text); KNI_EndHandles(); if (PCSL_STRING_OK != rc) { err = KNI_ENOMEM; } else { err = lfpport_stringitem_set_content(itemPtr, &text, appearanceMode); } pcsl_string_free(&text); if (err == KNI_ENOMEM) { KNI_ThrowNew(midpOutOfMemoryError, NULL); } KNI_ReturnVoid(); }
/* JAVADOC COMMENT ELIDED */ KNIEXPORT KNI_RETURNTYPE_OBJECT KNIDECL(com_sun_j2me_location_LocationPersistentStorage_landmarkStoreGetNext) { javacall_handle hndl; javacall_result res; javacall_utf16_string storeName; KNI_StartHandles(1); KNI_DeclareHandle(stringObj); hndl = (javacall_handle)KNI_GetParameterAsInt(1); res = javacall_landmarkstore_list_next(hndl, &storeName); switch (res) { case JAVACALL_OK: /* LandmarkStore name returned successfully */ if (storeName != NULL) { jsrop_jstring_from_utf16_string(KNIPASSARGS storeName, stringObj); } else { /* Category name returned successfully */ KNI_ReleaseHandle(stringObj); } break; default: /* operation Failed */ KNI_ThrowNew(jsropIOException, "I/O error"); break; } KNI_EndHandlesAndReturnObject(stringObj); }
/** * Get index of supported locales for device resources by its name. * <p> * Java declaration: * <pre> * getDevLocaleIndex(Ljava/lang/String)I * </pre> * * @param locale name * @return internal index of locale or -1 if locale is not supported */ KNIEXPORT KNI_RETURNTYPE_INT KNIDECL(com_sun_j2me_global_DevResourceManagerFactory_getDevLocaleIndex) { jint result =-1, index = 0; jsize len = 0; int error = 0; jchar* locale_name; KNI_StartHandles(1); KNI_DeclareHandle(hstr1); KNI_GetParameterAsObject(1, hstr1); if (KNI_IsNullHandle(hstr1)) { locale_name = NULL; } else { len = KNI_GetStringLength(hstr1); locale_name = (jchar *)JAVAME_MALLOC((len + 1) * sizeof(jchar)); if (NULL == locale_name) { KNI_ThrowNew(jsropOutOfMemoryError, "Out of memory"); error = 1; } else { KNI_GetStringRegion(hstr1, 0, len, locale_name); locale_name[len]=0; } } if (!error){ result = jsr238_get_resource_locale_index(locale_name, &index); if (result < 0) index =-1; JAVAME_FREE(locale_name); } KNI_EndHandles(); KNI_ReturnInt(index); }
/** * Adds an entry to the alarm registry. * <p> * Java declaration: * <pre> * addalarm0([BJ)J * </pre> * * @param midlet The entry to add to the alarm registry * @param time The time the alarm will be go off * * @return <tt>0</tt> if this is the first alarm registered with * the given <tt>midlet</tt>, otherwise the time of the * previosly registered alarm. */ KNIEXPORT KNI_RETURNTYPE_LONG KNIDECL(com_sun_midp_io_j2me_push_ConnectionRegistry_addAlarm0) { char *szConn = NULL; int connLen; jlong alarm = 0; jlong lastalarm = 0; int ret = 0; alarm = KNI_GetParameterAsLong(2); KNI_StartHandles(1); KNI_DeclareHandle(conn); KNI_GetParameterAsObject(1, conn); connLen = KNI_GetArrayLength(conn); szConn = midpMalloc(connLen); if (szConn != NULL) { KNI_GetRawArrayRegion(conn, 0, connLen, (jbyte*)szConn); ret = alarmadd(szConn, alarm, &lastalarm); midpFree(szConn); } if ((szConn == NULL) || (ret == -2)) { KNI_ThrowNew(midpOutOfMemoryError, NULL); } KNI_EndHandles(); KNI_ReturnLong(lastalarm); }
/** * java call: * private native boolean unregister(String handlerId); */ KNIEXPORT KNI_RETURNTYPE_BOOLEAN Java_com_sun_midp_content_RegistryStore_unregister0(void) { int ret = KNI_FALSE; pcsl_string id = PCSL_STRING_NULL_INITIALIZER; KNI_StartHandles(1); KNI_DeclareHandle(idStr); // content handler ID KNI_GetParameterAsObject(1, idStr); do { if (PCSL_STRING_OK != midp_jstring_to_pcsl_string(idStr, &id)) { KNI_ThrowNew(midpOutOfMemoryError, "RegistryStore_unregister0 no memory for ID"); break; } if (JSR211_OK != jsr211_unregister_handler(&id)) { break; } ret = KNI_TRUE; } while (0); pcsl_string_free(&id); KNI_EndHandles(); KNI_ReturnBoolean(ret); }