/* * Reads information about the installed midlet suite's component * from the storage. * * @param componentId unique ID of the component * @param ci ComponentInfo object to fill with the information about * the midlet suite's component having the given ID * * @exception IOException if an the information cannot be read * @exception IllegalArgumentException if suiteId is invalid or ci is null */ KNIEXPORT KNI_RETURNTYPE_VOID KNIDECL( com_sun_midp_midletsuite_DynamicComponentStorage_getComponentInfo) { ComponentIdType componentId = KNI_GetParameterAsInt(1); MIDPError status = ALL_OK; KNI_StartHandles(3); KNI_DeclareHandle(componentInfoObject); KNI_DeclareHandle(componentInfoClass); KNI_DeclareHandle(tmpHandle); KNI_GetParameterAsObject(2, componentInfoObject); KNI_GetObjectClass(componentInfoObject, componentInfoClass); do { char *pszError = NULL; MidletSuiteData *pData = NULL; /* Ensure that suite data are read */ status = read_suites_data(&pszError); storageFreeError(pszError); if (status != ALL_OK) { break; } pData = get_component_data(componentId); if (!pData) { status = NOT_FOUND; break; } KNI_RESTORE_INT_FIELD(componentInfoObject, componentInfoClass, "componentId", componentId); KNI_RESTORE_INT_FIELD(componentInfoObject, componentInfoClass, "suiteId", pData->suiteId); KNI_RESTORE_PCSL_STRING_FIELD(componentInfoObject, componentInfoClass, "displayName", &(pData->varSuiteData.displayName), tmpHandle); KNI_RESTORE_PCSL_STRING_FIELD(componentInfoObject, componentInfoClass, "version", &(pData->varSuiteData.suiteVersion), tmpHandle); KNI_RESTORE_BOOLEAN_FIELD(componentInfoObject, componentInfoClass, "trusted", pData->isTrusted); } while (0); if (status != ALL_OK) { if (status == NOT_FOUND) { KNI_ThrowNew(midpIllegalArgumentException, "bad component ID"); } else { KNI_ThrowNew(midpIOException, NULL); } } KNI_EndHandles(); KNI_ReturnVoid(); }
/** * Restore the state of the MIDlet suite loader. * <p> * Java declaration: * <pre> * restoreCommandState(Lcom/sun/midp/CommandState;)V * </pre> */ KNIEXPORT KNI_RETURNTYPE_VOID KNIDECL(com_sun_midp_main_CommandState_restoreCommandState) { KNI_StartHandles(5); KNI_DeclareHandle(runtimeInfo); KNI_DeclareHandle(commandState); KNI_DeclareHandle(clazz); KNI_DeclareHandle(rtiClazz); KNI_DeclareHandle(string); KNI_GetParameterAsObject(1, commandState); KNI_GetObjectClass(commandState, clazz); KNI_GetObjectField(commandState, midp_get_field_id(KNIPASSARGS clazz, "runtimeInfo", "Lcom/sun/midp/main/RuntimeInfo;"), runtimeInfo); KNI_GetObjectClass(runtimeInfo, rtiClazz); KNI_RESTORE_INT_FIELD(commandState, clazz, "status", MidpCommandState.status); KNI_RESTORE_BOOLEAN_FIELD(commandState, clazz, "logoDisplayed", MidpCommandState.logoDisplayed); KNI_RESTORE_PCSL_STRING_FIELD(commandState, clazz, "midletClassName", &MidpCommandState.midletClassName, string); KNI_RESTORE_INT_FIELD(commandState, clazz, "suiteId", MidpCommandState.suiteId); KNI_RESTORE_INT_FIELD(commandState, clazz, "lastSuiteId", MidpCommandState.lastSuiteId); KNI_RESTORE_INT_FIELD(commandState, clazz, "debugMode", MidpCommandState.debugMode); KNI_RESTORE_INT_FIELD(runtimeInfo, rtiClazz, "memoryReserved", MidpCommandState.runtimeInfo.memoryReserved); KNI_RESTORE_INT_FIELD(runtimeInfo, rtiClazz, "memoryTotal", MidpCommandState.runtimeInfo.memoryTotal); KNI_RESTORE_INT_FIELD(runtimeInfo, rtiClazz, "priority", MidpCommandState.runtimeInfo.priority); KNI_RESTORE_PCSL_STRING_FIELD(commandState, clazz, "lastMidletClassName", &MidpCommandState.lastMidletClassName, string); KNI_RESTORE_PCSL_STRING_FIELD(commandState, clazz, "lastArg0", &MidpCommandState.lastArg0, string); KNI_RESTORE_PCSL_STRING_FIELD(commandState, clazz, "lastArg1", &MidpCommandState.lastArg1, string); KNI_RESTORE_PCSL_STRING_FIELD(commandState, clazz, "arg0", &MidpCommandState.arg0, string); KNI_RESTORE_PCSL_STRING_FIELD(commandState, clazz, "arg1", &MidpCommandState.arg1, string); KNI_RESTORE_PCSL_STRING_FIELD(commandState, clazz, "arg2", &MidpCommandState.arg2, string); KNI_RESTORE_PCSL_STRING_FIELD(runtimeInfo, rtiClazz, "profileName", &MidpCommandState.profileName, string); KNI_EndHandles(); KNI_ReturnVoid(); }
/** * Reads information about the installed midlet suite's components * from the storage. * * @param suiteId unique ID of the suite * @param ci array of ComponentInfo objects to fill with the information * about the installed midlet suite's components * * @exception IOException if an the information cannot be read * @exception IllegalArgumentException if suiteId is invalid or ci is null */ KNIEXPORT KNI_RETURNTYPE_VOID KNIDECL(com_sun_midp_midletsuite_DynamicComponentStorage_getSuiteComponentsList) { SuiteIdType suiteId; int numberOfComponents = 0, arraySize; MidletSuiteData *pData = g_pSuitesData; KNI_StartHandles(4); KNI_DeclareHandle(components); KNI_DeclareHandle(componentObj); KNI_DeclareHandle(componentObjClass); KNI_DeclareHandle(tmpHandle); suiteId = KNI_GetParameterAsInt(1); KNI_GetParameterAsObject(2, components); arraySize = (int)KNI_GetArrayLength(components); do { if (arraySize <= 0) { break; } while (pData) { if (pData->suiteId == suiteId && pData->type == COMPONENT_DYNAMIC) { KNI_GetObjectArrayElement(components, (jint)numberOfComponents, componentObj); KNI_GetObjectClass(componentObj, componentObjClass); KNI_RESTORE_INT_FIELD(componentObj, componentObjClass, "componentId", (jint)pData->componentId); KNI_RESTORE_INT_FIELD(componentObj, componentObjClass, "suiteId", (jint)suiteId); KNI_RESTORE_BOOLEAN_FIELD(componentObj, componentObjClass, "trusted", pData->isTrusted); KNI_RESTORE_PCSL_STRING_FIELD(componentObj, componentObjClass, "displayName", &(pData->varSuiteData.displayName), tmpHandle); KNI_RESTORE_PCSL_STRING_FIELD(componentObj, componentObjClass, "version", &(pData->varSuiteData.suiteVersion), tmpHandle); numberOfComponents++; if (numberOfComponents == arraySize) { /* IMPL_NOTE: log an error! */ break; } } pData = pData->nextEntry; } } while (0); KNI_EndHandles(); KNI_ReturnVoid(); }