install_peer_midlet_kni.c
来自「This is a resource based on j2me embedde」· C语言 代码 · 共 509 行 · 第 1/2 页
C
509 行
jcInstallState.suiteName = NULL; } /* get the suite properties from the Java object */ KNI_GetObjectField(javaInstallState, midp_get_field_id(KNIPASSARGS clazz, "suiteProperties", "[Ljava/lang/String;"), javaProperties); /* get the authorization path from the java object */ KNI_GetObjectField(javaInstallState, midp_get_field_id(KNIPASSARGS clazz, "authPath", "[Ljava/lang/String;"), javaAuthPath); /* convert the suite properties to javacall format */ if (!KNI_IsNullHandle(javaProperties)) { jcRes = java_str_array2javacall_impl(javaProperties, tmpHandle, &propertiesLen, &jcInstallState.suiteProperties.pStringArr); } else { jcRes = JAVACALL_OK; propertiesLen = 0; jcInstallState.suiteProperties.pStringArr = NULL; } /* 2 strings (key/value) for each property */ jcInstallState.suiteProperties.numberOfProperties = propertiesLen >> 1; if (jcRes != JAVACALL_OK) { break; } /* convert the authorization path to javacall format */ if (!KNI_IsNullHandle(javaAuthPath)) { jcRes = java_str_array2javacall_impl(javaAuthPath, tmpHandle, &jcInstallState.authPathLen, &jcInstallState.pAuthPath); } else { jcRes = JAVACALL_OK; jcInstallState.authPathLen = 0; jcInstallState.pAuthPath = NULL; } /* jcRes contains the result code */ } while (0); pcsl_string_free(&pcslJarUrl); pcsl_string_free(&pcslSuiteName); if (jcRes != JAVACALL_OK) { int j; /* free suite properties */ if (jcInstallState.suiteProperties.pStringArr != NULL) { /* free each string */ for (j = 0; j < jcInstallState.suiteProperties.numberOfProperties << 1; j++) { javacall_free(jcInstallState.suiteProperties.pStringArr[j]); } /* free the array of pointers to the strings */ javacall_free(jcInstallState.suiteProperties.pStringArr); } /* free authorization path */ if (jcInstallState.pAuthPath != NULL) { /* free each string */ for (j = 0; j < jcInstallState.authPathLen; j++) { javacall_free(jcInstallState.pAuthPath[j]); } /* free the array of pointers to the strings */ javacall_free(jcInstallState.pAuthPath); } } /* * now general parameters are read and converted, get * request-specific parameters (if any) and send the request */ if (jcRes == JAVACALL_OK) { if ((int)requestCode == RQ_UPDATE_STATUS) { /* reporting the current installation progress */ int totalDone = (int)((int)jcRequestData.installStatus * 100 / (int) JAVACALL_INSTALL_STATUS_COMPLETED); int currStepDone = totalDone; /* IMPL_NOTE: should be changed */ javacall_ams_install_report_progress(&jcInstallState, jcRequestData.installStatus, currStepDone, totalDone); } else { /* get request type-dependent parameters */ if (requestCode == JAVACALL_INSTALL_REQUEST_CONFIRM_REDIRECTION) { pcsl_string_status pcslRes; jsize strSize, convertedLength; GET_PARAMETER_AS_PCSL_STRING(4, newLocation) strSize = pcsl_string_utf16_length(&newLocation); jcRequestData.newLocation = javacall_malloc((strSize + 1) << 1); pcslRes = pcsl_string_convert_to_utf16(&newLocation, (jchar*)jcRequestData.newLocation, strSize, &convertedLength); RELEASE_PCSL_STRING_PARAMETER if (pcslRes != PCSL_STRING_OK) { jcRes = JAVACALL_FAIL; } } if (jcRes == JAVACALL_OK) { /* sending the request */ g_installerIsolateId = -1; jcRes = javacall_ams_install_ask(requestCode, &jcInstallState, &jcRequestData); if (jcRes != JAVACALL_OK) { /* If something is wrong, apply "No" answer */ g_fAnswer = JAVACALL_FALSE; g_fAnswerReady = JAVACALL_TRUE; } } } /* if RQ_UPDATE_REQUEST */ } /* if (jcRes == JAVACALL_OK) */ KNI_EndHandles(); KNI_ReturnInt(jcRes == JAVACALL_OK ? 0 : jcRes);}/** * Returns yes/no answer from the native callback. * * @return yes/no answer from the native callback */KNIEXPORT KNI_RETURNTYPE_BOOLEANKNIDECL(com_sun_midp_installer_InstallerPeerMIDlet_getAnswer0) { if (g_fAnswerReady == JAVACALL_TRUE) { /* all done, the answer is ready, just return */ g_fAnswerReady = JAVACALL_FALSE; g_installerIsolateId = -1; } else { g_installerIsolateId = getCurrentIsolateId(); /* block the thread until the answer is ready */ midp_thread_wait(INSTALLER_UI_SIGNAL, g_installerIsolateId, NULL); } KNI_ReturnBoolean(g_fAnswer == JAVACALL_TRUE ? KNI_TRUE : KNI_FALSE);}/** * Reports to the party using this installer that * the operation has been completed. * * @param appId this application ID * @param suiteId ID of the newly installed midlet suite, or * MIDletSuite.UNUSED_SUITE_ID if the installation * failed * @param resultCode result of the installation (0 if succeeded or -1 in * case of unknown error, or one of the values defined * in InvalidJadException) * @param errMsg error message if the installation failed, null otherwise */KNIEXPORT KNI_RETURNTYPE_VOIDKNIDECL(com_sun_midp_installer_InstallerPeerMIDlet_reportFinished0) { pcsl_string errMsgParam = PCSL_STRING_NULL_INITIALIZER; jint appId = KNI_GetParameterAsInt(1); SuiteIdType suiteId = (SuiteIdType) KNI_GetParameterAsInt(2); jint instResult = KNI_GetParameterAsInt(3); javacall_ams_install_data jcInstallData; KNI_StartHandles(2); KNI_DeclareHandle(errMsg); if (instResult == 0) { jcInstallData.installResultCode = JAVACALL_INSTALL_EXC_ALL_OK; } else if (instResult == -1) { jcInstallData.installResultCode = JAVACALL_INSTALL_EXC_GENERAL_ERROR; } else { jcInstallData.installResultCode = (javacall_ams_install_exception_code)instResult; } /* get request type-dependent parameters */ if (suiteId == UNUSED_SUITE_ID) { GET_PARAMETER_AS_PCSL_STRING(4, errMsgParam) if (!pcsl_string_is_null(&errMsgParam)) { /* IMPL_NOTE: pass the error message to the listener */ } RELEASE_PCSL_STRING_PARAMETER } jcInstallData.installStatus = JAVACALL_INSTALL_STATUS_COMPLETED; jcInstallData.suiteId = (javacall_suite_id)suiteId; javacall_ams_operation_completed(JAVACALL_OPCODE_INSTALL_SUITE, (javacall_app_id)appId, &jcInstallData); KNI_EndHandles(); KNI_ReturnVoid();}/** * Reports to the party using this installer that the requested * operation has been completed and the result (if any) is available. * * @param appId this application ID * @param requestCode code of the request that was handled * @param resultCode completion code (0 if succeeded or -1 in case * of error) * @param result operation-dependent result (for OCSP operations it contains * the current state (enabled/disabled) of OCSP checks) */KNIEXPORT KNI_RETURNTYPE_VOIDKNIDECL(com_sun_midp_installer_InstallerPeerMIDlet_notifyRequestHandled0) { jint appId = KNI_GetParameterAsInt(1); jint requestCode = KNI_GetParameterAsInt(2); jint resultCode = KNI_GetParameterAsInt(3); jboolean result = KNI_GetParameterAsBoolean(4); javacall_bool jcResult = (result == KNI_TRUE ? JAVACALL_TRUE : JAVACALL_FALSE); javacall_opcode operationCode = JAVACALL_OPCODE_INVALID; /* IMPL_NOTE: currently unused because the supported operations can't fail */ (void)resultCode; if (requestCode == NATIVE_ENABLE_OCSP_REQUEST) { operationCode = JAVACALL_OPCODE_ENABLE_OCSP; } else if (requestCode == NATIVE_CHECK_OCSP_ENABLED_REQUEST) { operationCode = JAVACALL_OPCODE_IS_OCSP_ENABLED; } javacall_ams_operation_completed(operationCode, (javacall_app_id)appId, &jcResult); KNI_ReturnVoid();}/** * Unblocks the installer thread. */KNIEXPORT KNI_RETURNTYPE_VOIDKNIDECL(com_sun_midp_installer_InstallerPeerMIDlet_unblockInstaller0) { midp_thread_signal(INSTALLER_UI_SIGNAL, getCurrentIsolateId(), 0); KNI_ReturnVoid();}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?