/** * Unlocks the device. * <p>Java declaration: * <pre> * private native boolean unlock0(); * </pre> * @return KNI_TRUE in case of success, else KNI_FALSE */ KNIEXPORT KNI_RETURNTYPE_INT KNIDECL(com_sun_cardreader_PlatformCardDevice_unlock0) { jboolean retcode = KNI_FALSE; if (javacall_carddevice_unlock() == JAVACALL_OK) { midp_thread_signal(CARD_READER_DATA_SIGNAL, SIGNAL_LOCK, 0); javacall_carddevice_clear_error(); retcode = KNI_TRUE; } KNI_ReturnInt(retcode); }
/** * Performs platform lock of the device. * <p>Java declaration: * <pre> * private native boolean lock0(); * </pre> * @return KNI_TRUE in case of success, else KNI_FALSE */ KNIEXPORT KNI_RETURNTYPE_INT KNIDECL(com_sun_cardreader_PlatformCardDevice_lock0) { javacall_result lock_retcode = JAVACALL_OK; jboolean retcode = KNI_FALSE; if ((lock_retcode=javacall_carddevice_lock()) == JAVACALL_OK) { javacall_carddevice_clear_error(); retcode = KNI_TRUE; } else { if (lock_retcode == JAVACALL_WOULD_BLOCK) { midp_thread_wait(CARD_READER_DATA_SIGNAL, SIGNAL_LOCK, NULL); } } KNI_ReturnInt(retcode); }
/** * Clears error state. */ void jsr177_clear_error() { javacall_carddevice_clear_error(); }
/** * Initializes the device. * <p>Java declaration: * <pre> * private native boolean init0(); * </pre> * @return KNI_TRUE in case of success, else KNI_FALSE * @throws CardDeviceException If configuration failed. */ KNIEXPORT KNI_RETURNTYPE_INT KNIDECL (com_sun_cardreader_PlatformCardDevice_init0) { jboolean retcode = KNI_FALSE; javacall_result status; char *err_msg; char *buffer; const char *prop_value; prop_value = getInternalProperty(hostsandports); if (prop_value != NULL) { status = javacall_carddevice_set_property(hostsandports, prop_value); if (status != JAVACALL_OK) { goto err; } prop_value = getInternalProperty(satselectapdu); status = javacall_carddevice_set_property(satselectapdu, prop_value); if (status != JAVACALL_OK) { goto err; } } if ((status = javacall_carddevice_init()) == JAVACALL_OK) { javacall_carddevice_clear_error(); retcode = KNI_TRUE; } else if (status == JAVACALL_NOT_IMPLEMENTED) { /* We throw special exception to tell i3tests to skip real testing*/ KNI_ThrowNew(cardDeviceException, "stub"); retcode = KNI_TRUE; } goto end; err: #define BUFFER_SIZE 128 buffer = malloc(BUFFER_SIZE); if (buffer == NULL) { err_msg = "init0()"; KNI_ThrowNew(jsropOutOfMemoryError, err_msg); goto end; } switch (status) { case JAVACALL_NOT_IMPLEMENTED: if (javacall_carddevice_get_error(buffer, BUFFER_SIZE)) { err_msg = buffer; } else { err_msg = "Required property not supported"; } KNI_ThrowNew(cardDeviceException, err_msg); break; case JAVACALL_OUT_OF_MEMORY: if (javacall_carddevice_get_error(buffer, BUFFER_SIZE)) { err_msg = buffer; } else { err_msg = "init0()"; } KNI_ThrowNew(jsropOutOfMemoryError, err_msg); break; default: if (javacall_carddevice_get_error(buffer, BUFFER_SIZE)) { err_msg = buffer; } else { err_msg = "Invalid internal property"; } KNI_ThrowNew(cardDeviceException, err_msg); break; } free(buffer); end: KNI_ReturnInt(retcode); }