/** * 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(); }
/* * Returns the number of bytes available to be read from the connection * without blocking. * * Note: the method gets native connection handle directly from * <code>handle<code> field of <code>BTSPPConnectionImpl</code> object. * * @return the number of available bytes * @throws IOException if any I/O error occurs */ KNIEXPORT KNI_RETURNTYPE_INT KNIDECL(com_sun_jsr082_bluetooth_btspp_BTSPPConnectionImpl_available0) { javacall_handle handle; int count = -1; char* pError; REPORT_INFO(LC_PROTOCOL, "btspp::available"); KNI_StartHandles(1); KNI_DeclareHandle(thisHandle); KNI_GetThisPointer(thisHandle); handle = (javacall_handle)KNI_GetIntField(thisHandle, connHandleID); switch (javacall_bt_rfcomm_get_available(handle, &count)) { case JAVACALL_OK: REPORT_INFO(LC_PROTOCOL, "btspp::available done!"); break; case JAVACALL_FAIL: javacall_bt_rfcomm_get_error(handle, &pError); JAVAME_SNPRINTF(gBtBuffer, BT_BUFFER_SIZE, "IO error during btspp::::available (%s)", pError); REPORT_ERROR(LC_PROTOCOL, gBtBuffer); KNI_ThrowNew(jsropIOException, EXCEPTION_MSG(gBtBuffer)); break; default: /* illegal argument */ REPORT_ERROR(LC_PROTOCOL, "Internal error in btspp::available"); } KNI_EndHandles(); KNI_ReturnInt(count); }
/* 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 the registered MIDlet name for the given inbound connection handle. * <p> * Java declaration: * <pre> * getMIDlet0(J[BI)I * </pre> * * @param handle The handle to inbound connection * @param midletName A byte array to store the MIDlet name * @param midletNameLength The size of <tt>midlet</tt> * * @return <tt>0</tt> if successful, otherwise <tt>-1</tt> */ KNIEXPORT KNI_RETURNTYPE_INT KNIDECL(com_sun_midp_io_j2me_push_ConnectionRegistry_getMIDlet0) { int midletNameLength; char* regentry; int regentryLength; int ret = -1; int handle; midletNameLength = (int)KNI_GetParameterAsInt(3); handle = (int)KNI_GetParameterAsInt(1); KNI_StartHandles(1); KNI_DeclareHandle(midletName); KNI_GetParameterAsObject(2, midletName); regentry = pushfindfd(handle); if (NULL != regentry) { regentryLength = strlen(regentry) + 1; /* Include trailing '\0' */ if (regentryLength < midletNameLength) { memcpy((char*)JavaByteArray(midletName), regentry, regentryLength); ret = 0; } midpFree(regentry); } KNI_EndHandles(); KNI_ReturnInt(ret); }
/** * Gets the total advance width of the given <tt>String</tt> in this * <tt>Font</tt>. * <p> * Java declaration: * <pre> * stringWidth(Ljava/lang/String;)I * </pre> * * @param str the <tt>String</tt> to be measured * * @return the total advance width of the <tt>String</tt> in pixels */ KNIEXPORT KNI_RETURNTYPE_INT KNIDECL(javax_microedition_lcdui_Font_stringWidth) { int strLen; jint result = 0; KNI_StartHandles(2); KNI_DeclareHandle(str); KNI_DeclareHandle(thisObject); KNI_GetParameterAsObject(1, str); KNI_GetParameterAsObject(0, thisObject); if ((strLen = KNI_GetStringLength(str)) == -1) { KNI_ThrowNew(midpNullPointerException, NULL); } else { int face, style, size; _JavaString *jstr; DECLARE_FONT_PARAMS(thisObject); SNI_BEGIN_RAW_POINTERS; jstr = GET_STRING_PTR(str); result = gx_get_charswidth(face, style, size, jstr->value->elements + jstr->offset, strLen); SNI_END_RAW_POINTERS; } KNI_EndHandles(); KNI_ReturnInt(result); }
KNIEXPORT KNI_RETURNTYPE_INT Java_com_sun_cldc_io_j2me_socket_Protocol_writeBuf() { int result; int fd = KNI_GetParameterAsInt(1); int offset = KNI_GetParameterAsInt(3); int length = KNI_GetParameterAsInt(4); KNI_StartHandles(1); KNI_DeclareHandle(buffer_object); KNI_GetParameterAsObject(2, buffer_object); char *buffer = (char *) SNI_GetRawArrayPointer(buffer_object) + offset; result = jvm_send(fd, buffer, length, 0); // We rely on open0() for setting the socket to non-blocking KNI_EndHandles(); if (result < 0) { 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_WRITE; } SNI_BlockThread(); } } KNI_ReturnInt(result); }
/** * 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); }
/** * 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(); }
/* 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); }
/** * 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(); }
/** * 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 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); }
/** * 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(); }
/** * private static native void getLinks0(Link[] linkarray); */ KNIEXPORT KNI_RETURNTYPE_VOID Java_com_sun_midp_links_LinkPortal_getLinks0(void) { int targetIsolate; jsize len; int i; KNI_StartHandles(2); KNI_DeclareHandle(linkArray); KNI_DeclareHandle(linkObj); targetIsolate = JVM_CurrentIsolateID(); KNI_GetParameterAsObject(1, linkArray); len = KNI_GetArrayLength(linkArray); if (portals != NULL) { if (portals[targetIsolate].count > 0) { rendezvous **rpp = portals[targetIsolate].rppa; for (i = 0; i < len; i++) { KNI_GetObjectArrayElement(linkArray, i, linkObj); setNativePointer(linkObj, rpp[i]); rp_incref(rpp[i]); } } portal_free(&portals[targetIsolate]); } KNI_EndHandles(); KNI_ReturnVoid(); }
/** * Retrieves service record from the SDDB. * * @param handle handle of the service record to be retrieved * @param data byte array which will receive the data, * or null for size query * @return size of the data read/required */ KNIEXPORT KNI_RETURNTYPE_INT Java_com_sun_kvem_jsr082_bluetooth_SDDB_readRecord(void) { jint retval; bt_record_t record; KNI_StartHandles(1); KNI_DeclareHandle(dataHandle); KNI_GetParameterAsObject(2, dataHandle); record.id = (bt_sddbid_t)KNI_GetParameterAsInt(1); if (KNI_IsNullHandle(dataHandle)) { record.data = NULL; record.size = 0; } else { record.data = JavaByteArray(dataHandle); record.size = KNI_GetArrayLength(dataHandle); } if (javacall_bt_sddb_read_record(record.id, &record.classes, record.data, &record.size) == JAVACALL_OK) { retval = record.size; } else { retval = 0; } KNI_EndHandles(); KNI_ReturnInt(retval); }
/* JAVADOC COMMENT ELIDED */ KNIEXPORT KNI_RETURNTYPE_VOID KNIDECL(com_sun_j2me_location_LocationPersistentStorage_removeLandmarkStore) { javacall_result res; KNI_StartHandles(1); GET_PARAMETER_AS_UTF16_STRING(1, storeName) /* call provider_open to get provider handler */ res = javacall_landmarkstore_delete(storeName); switch (res) { case JAVACALL_OK: /* LandmarkStore created successfully */ break; case JAVACALL_FAIL: /* operation Failed */ KNI_ThrowNew(jsropIOException, "I/O error"); break; case JAVACALL_INVALID_ARGUMENT: /* operation Failed */ KNI_ThrowNew(jsropIOException, "name is too long"); break; default: /* operation Failed */ KNI_ThrowNew(jsropIOException, "I/O error"); break; } RELEASE_UTF16_STRING_PARAMETER KNI_EndHandles(); KNI_ReturnVoid(); }
/* * Retrieves service record from the service search result. * * @param recHandle native handle of the service record * @param array byte array which will receive the data, * or null for size query * @return size of the data read/required */ KNIEXPORT KNI_RETURNTYPE_INT KNIDECL(com_sun_jsr082_bluetooth_SDPTransaction_getServiceRecord0) { jint retval = 0; javacall_handle id = 0; javacall_uint8 *data = NULL; javacall_uint16 size = 0; KNI_StartHandles(1); KNI_DeclareHandle(dataHandle); KNI_GetParameterAsObject(2, dataHandle); id = (javacall_handle)KNI_GetParameterAsInt(1); if (!KNI_IsNullHandle(dataHandle)) size = KNI_GetArrayLength(dataHandle); data = JAVAME_MALLOC(size); if (data == NULL) { KNI_ThrowNew(jsropOutOfMemoryError, "Out of memory inside SDDB.readRecord()"); } else { if (javacall_bt_sdp_get_service(id, data, &size) == JAVACALL_OK) { retval = size; if (!KNI_IsNullHandle(dataHandle)) { KNI_SetRawArrayRegion(dataHandle, 0, size, data); } } else { retval = 0; } JAVAME_FREE(data); } KNI_EndHandles(); KNI_ReturnInt(retval); }
/* JAVADOC COMMENT ELIDED */ KNIEXPORT KNI_RETURNTYPE_INT KNIDECL(com_sun_j2me_location_LocationPersistentStorage_openCategoryList) { javacall_handle pHandle; jint hndl = 0; javacall_result res; KNI_StartHandles(1); GET_PARAMETER_AS_UTF16_STRING(1, storeName) /* call provider_open to get provider handler */ res = javacall_landmarkstore_categorylist_open(storeName, &pHandle); switch (res) { case JAVACALL_OK: /* Category list open successfully */ hndl = (jint)pHandle; break; default: /* operation Failed */ KNI_ThrowNew(jsropIOException, "I/O error"); break; } RELEASE_UTF16_STRING_PARAMETER KNI_EndHandles(); KNI_ReturnInt(hndl); }
/** * Updates the parameters of the invocation in the native store. * The ID, URL, Type, arguments, and data are stored again in native. * The key into the native store is the TID; * * @param invoc the InvocationImpl to update the native params * @see StoredInvoc * @see #invocQueue */ KNIEXPORT KNI_RETURNTYPE_VOID Java_com_sun_midp_content_InvocationStore_setParams0(void) { StoredLink* link; StoredInvoc* invoc; int tid; KNI_StartHandles(3); KNI_DeclareHandle(invocObj); KNI_DeclareHandle(obj1); KNI_DeclareHandle(obj2); KNI_GetParameterAsObject(1, invocObj); init(invocObj, obj1); /* Find the matching entry in the queue */ tid = KNI_GetIntField(invocObj, tidFid); link = invocFindTid(tid); if (link != NULL) { invoc = link->invoc; if (KNI_TRUE != setParamsFromObj(invoc, invocObj, obj1, obj2)) { KNI_ThrowNew(midpOutOfMemoryError, "invocStore.c: setParam0() allocation failed"); } } else { #if REPORT_LEVEL <= LOG_CRITICAL REPORT_CRIT(LC_NONE, "invocStore.c: setParam0() no entry for tid"); #endif } KNI_EndHandles(); KNI_ReturnVoid(); }
/* JAVADOC COMMENT ELIDED */ KNIEXPORT KNI_RETURNTYPE_VOID KNIDECL(com_sun_j2me_location_LocationPersistentStorage_addCategoryImpl) { javacall_result res; KNI_StartHandles(2); GET_PARAMETER_AS_UTF16_STRING(1, storeName) GET_PARAMETER_AS_UTF16_STRING(2, categoryName) res = javacall_landmarkstore_category_add(storeName, categoryName); switch (res) { case JAVACALL_OK: /* Category added successfully */ break; case JAVACALL_INVALID_ARGUMENT: /* wrong provider name */ KNI_ThrowNew(jsropIllegalArgumentException, "category name already exist"); break; default: /* operation Failed */ KNI_ThrowNew(jsropIOException, "I/O error"); break; } RELEASE_UTF16_STRING_PARAMETER RELEASE_UTF16_STRING_PARAMETER KNI_EndHandles(); KNI_ReturnVoid(); }
/** * 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); }
/* JAVADOC COMMENT ELIDED */ KNIEXPORT KNI_RETURNTYPE_VOID KNIDECL(com_sun_j2me_location_LocationPersistentStorage_deleteLandmarkFromCategoryImpl) { jint landmarkID; javacall_result res; KNI_StartHandles(2); GET_PARAMETER_AS_UTF16_STRING(1, storeName) landmarkID = KNI_GetParameterAsInt(2); GET_PARAMETER_AS_UTF16_STRING(3, categoryName) res = javacall_landmarkstore_landmark_delete_from_category(storeName, (javacall_handle)landmarkID, categoryName); switch (res) { case JAVACALL_OK: /* Category added successfully */ break; default: /* operation Failed */ KNI_ThrowNew(jsropIOException, "I/O error"); break; } RELEASE_UTF16_STRING_PARAMETER RELEASE_UTF16_STRING_PARAMETER KNI_EndHandles(); KNI_ReturnVoid(); }
KNIEXPORT KNI_RETURNTYPE_VOID KNIDECL(javax_microedition_lcdui_TextFieldLFImpl_setNativeEditorContent) { #if 0 int cursorIndex = KNI_GetParameterAsInt(2); _JavaString *jstr; jchar *p; int strLen; if (editBoxShown) { KNI_StartHandles(1); KNI_DeclareHandle(str); KNI_GetParameterAsObject(1, str); jstr = getJavaStringPtr(str); p = jstr->value->elements + jstr->offset; strLen = KNI_GetStringLength(str); /* This is OK: we know that the Java string that gets passed here * is always on the heap. */ jchar saved = p[strLen]; p[strLen] = 0; int oldSize = GetWindowTextLength(hwndTextActive); SendMessage(hwndTextActive, EM_SETSEL, (WPARAM)0, (LPARAM)oldSize); SendMessage(hwndTextActive, EM_REPLACESEL, 0, (LPARAM)((LPSTR)p)); SendMessage(hwndTextActive, EM_SETSEL, cursorIndex, cursorIndex); p[strLen] = saved; /* restore corruption of the heap! */ KNI_EndHandles(); } #endif KNI_ReturnVoid(); }
/* JAVADOC COMMENT ELIDED */ KNIEXPORT KNI_RETURNTYPE_INT KNIDECL(com_sun_j2me_location_LocationPersistentStorage_openLandmarkList) { javacall_handle hndl = 0; javacall_result res; KNI_StartHandles(2); GET_PARAMETER_AS_UTF16_STRING(1, storeName) GET_PARAMETER_AS_UTF16_STRING(2, categoryName) res = javacall_landmarkstore_landmarklist_open(storeName, categoryName, &hndl); switch (res) { case JAVACALL_OK: /* Category list open successfully */ break; case JAVACALL_INVALID_ARGUMENT: /* wrong category name */ break; default: /* operation Failed */ KNI_ThrowNew(jsropIOException, "I/O error"); break; } RELEASE_UTF16_STRING_PARAMETER RELEASE_UTF16_STRING_PARAMETER KNI_EndHandles(); KNI_ReturnInt((jint)hndl); }
/* * Closes client connection. * * Note: the method gets native connection handle directly from * <code>handle<code> field of <code>RFCOMMConnectionImpl</code> object. * * @throws IOException if any I/O error occurs */ KNIEXPORT KNI_RETURNTYPE_VOID KNIDECL(com_sun_jsr082_bluetooth_btspp_BTSPPConnectionImpl_close0) { javacall_handle handle; REPORT_INFO(LC_PROTOCOL, "btspp::close"); KNI_StartHandles(1); KNI_DeclareHandle(thisHandle); KNI_GetThisPointer(thisHandle); handle = (javacall_handle)KNI_GetIntField(thisHandle, connHandleID); if (handle != JAVACALL_BT_INVALID_HANDLE) { if (javacall_bt_rfcomm_close(handle) == JAVACALL_FAIL) { REPORT_ERROR(LC_PROTOCOL, "RFCOMM connection closing failed in btspp::close"); KNI_ThrowNew(jsropIOException, EXCEPTION_MSG("RFCOMM connection closing failed")); } else { // Need revisit: add resource counting /* if (midpDecResourceCount(RSC_TYPE_BT_CLI, 1) == 0) { REPORT_INFO(LC_PROTOCOL, "Resource limit update error"); } */ } KNI_SetIntField(thisHandle, connHandleID, (jint)JAVACALL_BT_INVALID_HANDLE); } REPORT_INFO(LC_PROTOCOL, "btspp::close done!"); KNI_EndHandles(); KNI_ReturnVoid(); }
/** * Native method void finalize of * com.sun.midp.midletsuite.MIDletSuiteImpl. * <p> * * native finalizer * */ KNIEXPORT KNI_RETURNTYPE_VOID KNIDECL(com_sun_midp_midletsuite_MIDletSuiteImpl_finalize) { SuiteIdType suiteId; jboolean locked; KNI_StartHandles(2); KNI_DeclareHandle(object); KNI_DeclareHandle(clazz); KNI_GetThisPointer(object); KNI_GetObjectClass(object, clazz); locked = KNI_GetBooleanField(object, midp_get_field_id(KNIPASSARGS clazz, "locked", "Z")); if (locked) { suiteId = KNI_GetIntField(object, midp_get_field_id(KNIPASSARGS clazz, "id", "I")); unlock_storage(suiteId); } KNI_EndHandles(); KNI_ReturnVoid(); }
/* private native void _putWindowContents( Graphics winGraphics , int pixmapPointer ) ; */ KNIEXPORT KNI_RETURNTYPE_VOID Java_javax_microedition_khronos_egl_EGL10Impl__1putWindowContents() { jint deltaHeight = KNI_GetParameterAsInt(2); jint pixmap = KNI_GetParameterAsInt(3); jint clipX = KNI_GetParameterAsInt(4); jint clipY = KNI_GetParameterAsInt(5); jint clipWidth = KNI_GetParameterAsInt(6); jint clipHeight = KNI_GetParameterAsInt(7); 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, deltaHeight, (JSR239_Pixmap *)pixmap, clipX, clipY, clipWidth, clipHeight, 0); KNI_EndHandles(); KNI_ReturnVoid(); }
/** * Creates or updates service record in the SDDB. * * @param handle handle of the service record to be updated; * if equals to 0, a new record will be created * @param classes device service classes associated with the record * @param data binary data containing attribute-value pairs in the format * identical to the one used in the AttributeList parameter of * the SDP_ServiceAttributeResponse PDU * @return service record handle, or 0 if the operation fails */ KNIEXPORT KNI_RETURNTYPE_INT Java_com_sun_kvem_jsr082_bluetooth_SDDB_updateRecord(void) { bt_sddbid_t retval; bt_record_t record; bt_sddbid_t old_id = (bt_sddbid_t)KNI_GetParameterAsInt(1); KNI_StartHandles(1); KNI_DeclareHandle(dataHandle); record.id = old_id; record.classes = KNI_GetParameterAsInt(2); KNI_GetParameterAsObject(3, dataHandle); record.data = JavaByteArray(dataHandle); record.size = KNI_GetArrayLength(dataHandle); if (javacall_bt_sddb_update_record(&record.id, record.classes, record.data, record.size) == JAVACALL_OK) { retval = record.id; if (old_id != BT_INVALID_SDDB_HANDLE) { bt_push_update_record(old_id, &record); } javacall_bt_stack_set_service_classes(javacall_bt_sddb_get_service_classes(0)); } else { retval = BT_INVALID_SDDB_HANDLE; } KNI_EndHandles(); KNI_ReturnInt(retval); }
/* 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); }
/** * 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(); }