javacall_ams_suitestore.c
来自「This is a resource based on j2me embedde」· C语言 代码 · 共 1,908 行 · 第 1/5 页
C
1,908 行
return JAVACALL_OK;}/** * Installer invokes this function to get the install information * of a MIDlet suite. * * Note that memory for the strings inside the returned * javacall_ams_suite_install_info structure is allocated by the callee, * and the caller is responsible for freeing it using * javacall_free_install_info(). * * @param suiteId [in] unique ID of the suite * @param pInstallInfo [in/out] pointer to a place where the installation * information will be saved. * * @return <tt>JAVACALL_OK</tt> on success, an error code otherwise */javacall_resultjavanotify_ams_suite_get_install_info(javacall_suite_id suiteId, javacall_ams_suite_install_info* pInstallInfo) { MidpInstallInfo midpInstallInfo; MIDPError status; if (pInstallInfo == NULL) { return JAVACALL_FAIL; } do { midpInstallInfo = midp_get_suite_install_info((SuiteIdType)suiteId); status = midpInstallInfo.status; if (status != ALL_OK) { break; } status = midp_pcsl_str2javacall_str(&midpInstallInfo.jadUrl_s, &pInstallInfo->jadUrl); if (status != ALL_OK) { break; } status = midp_pcsl_str2javacall_str(&midpInstallInfo.jarUrl_s, &pInstallInfo->jarUrl); if (status != ALL_OK) { javacall_free(pInstallInfo->jadUrl); break; } status = midp_pcsl_str2javacall_str(&midpInstallInfo.domain_s, &pInstallInfo->domain); if (status != ALL_OK) { javacall_free(pInstallInfo->jadUrl); javacall_free(pInstallInfo->jarUrl); break; } /** true if suite is trusted, false if not */ pInstallInfo->isTrusted = (midpInstallInfo.trusted == KNI_TRUE) ? JAVACALL_TRUE : JAVACALL_FALSE; /* convert the authorization path */ pInstallInfo->authPathLen = (javacall_int32)midpInstallInfo.authPathLen; if (midpInstallInfo.authPathLen > 0) { status = pcsl_string_array2javacall_impl( midpInstallInfo.authPath_as, midpInstallInfo.authPathLen, &pInstallInfo->pAuthPath, &pInstallInfo->authPathLen); if (status != ALL_OK) { break; } } else { pInstallInfo->pAuthPath = NULL; } pInstallInfo->verifyHashLen = midpInstallInfo.verifyHashLen; if (midpInstallInfo.verifyHashLen > 0) { pInstallInfo->pVerifyHash = (javacall_uint8*) javacall_malloc(midpInstallInfo.verifyHashLen); if (pInstallInfo->pVerifyHash == NULL) { javacall_free(pInstallInfo->jadUrl); javacall_free(pInstallInfo->jarUrl); javacall_free(pInstallInfo->domain); status = OUT_OF_MEMORY; break; } memcpy((unsigned char*)pInstallInfo->pVerifyHash, (unsigned char*)midpInstallInfo.pVerifyHash, midpInstallInfo.verifyHashLen); } else { pInstallInfo->pVerifyHash = NULL; } /* converting the properties from JAD */ if (pInstallInfo->jadUrl != NULL) { pInstallInfo->jadProps.numberOfProperties = (javacall_int32)midpInstallInfo.jadProps.numberOfProperties; if (midpInstallInfo.jadProps.numberOfProperties > 0) { status = pcsl_string_array2javacall_impl( midpInstallInfo.jadProps.pStringArr, midpInstallInfo.jadProps.numberOfProperties, &pInstallInfo->jadProps.pStringArr, &pInstallInfo->jadProps.numberOfProperties); if (status != ALL_OK) { break; } } else { pInstallInfo->jadProps.pStringArr = NULL; } } else { pInstallInfo->jadProps.numberOfProperties = 0; pInstallInfo->jadProps.pStringArr = NULL; } /* converting the properties from JAR */ pInstallInfo->jarProps.numberOfProperties = (javacall_int32)midpInstallInfo.jarProps.numberOfProperties; if (midpInstallInfo.jarProps.numberOfProperties > 0) { status = pcsl_string_array2javacall_impl( midpInstallInfo.jarProps.pStringArr, midpInstallInfo.jarProps.numberOfProperties, &pInstallInfo->jarProps.pStringArr, &pInstallInfo->jarProps.numberOfProperties); if (status != ALL_OK) { break; } } else { pInstallInfo->jarProps.pStringArr = NULL; } } while (0); midp_free_install_info(&midpInstallInfo); return midp_error2javacall(status);}/** * Installer invokes this function to frees an * javacall_ams_suite_install_info struct. * Does nothing if passed NULL. * * @param pInstallInfo installation information returned from * javanotify_ams_suite_get_install_info */void javanotify_ams_suite_free_install_info( javacall_ams_suite_install_info* pInstallInfo) { if (pInstallInfo != NULL) { int i; if (pInstallInfo->jadUrl != NULL) { javacall_free(pInstallInfo->jadUrl); } if (pInstallInfo->jarUrl != NULL) { javacall_free(pInstallInfo->jarUrl); } if (pInstallInfo->domain != NULL) { javacall_free(pInstallInfo->domain); } if (pInstallInfo->verifyHashLen > 0 && pInstallInfo->pVerifyHash != NULL) { javacall_free(pInstallInfo->pVerifyHash); } /* free the auth. path */ if (pInstallInfo->pAuthPath != NULL) { for (i = 0; i < pInstallInfo->authPathLen; i++) { javacall_free(&pInstallInfo->pAuthPath[i]); } javacall_free(pInstallInfo->pAuthPath); } /* free the properties from JAD */ if (pInstallInfo->jadProps.pStringArr != NULL) { for (i = 0; i < pInstallInfo->jadProps.numberOfProperties; i++) { if (pInstallInfo->jadProps.pStringArr[i] != NULL) { javacall_free(pInstallInfo->jadProps.pStringArr[i]); } } javacall_free(pInstallInfo->jadProps.pStringArr); } /* free the properties from JAR */ if (pInstallInfo->jarProps.pStringArr != NULL) { for (i = 0; i < pInstallInfo->jarProps.numberOfProperties; i++) { if (pInstallInfo->jarProps.pStringArr[i] != NULL) { javacall_free(pInstallInfo->jarProps.pStringArr[i]); } } javacall_free(pInstallInfo->jarProps.pStringArr); } javacall_free(pInstallInfo); }}/** * Installer calls this function to store or update a midlet suite. * * @param pInstallInfo structure containing the following information:<br> * <pre> * id - unique ID of the suite; * jadUrl - where the JAD came from, can be null; * jarUrl - where the JAR came from; * jarFilename - name of the downloaded MIDlet suite jar file; * suiteName - name of the suite; * suiteVendor - vendor of the suite; * authPath - authPath if signed, the authorization path starting * with the most trusted authority; * domain - security domain of the suite; * isTrusted - true if suite is trusted; * verifyHash - may contain hash value of the suite with * preverified classes or may be NULL; * jadProps - properties given in the JAD as an array of strings in * key/value pair order, can be null if jadUrl is null * jarProps - properties of the manifest as an array of strings * in key/value pair order * </pre> * * @param pSuiteSettings structure containing the following information:<br> * <pre> * permissions - permissions for the suite; * pushInterruptSetting - defines if this MIDlet suite interrupt * other suites; * pushOptions - user options for push interrupts; * suiteId - unique ID of the suite, must be equal to the one given * in installInfo; * boolean enabled - if true, MIDlet from this suite can be run; * </pre> * * @param pSuiteInfo structure containing the following information:<br> * <pre> * suiteId - unique ID of the suite, must be equal to the value given * in installInfo and suiteSettings parameters; * storageId - ID of the storage where the MIDlet should be installed; * numberOfMidlets - number of midlets in the suite; * displayName - the suite's name to display to the user; * midletToRunClassName - the midlet's class name if the suite contains * only one midlet, ignored otherwise; * iconName - name of the icon for this suite. * </pre> * * @return <tt>JAVACALL_OK</tt> on success, an error code otherwise */javacall_resultjavanotify_ams_suite_store_suite( const javacall_ams_suite_install_info* pInstallInfo, const javacall_ams_suite_settings* pSuiteSettings, const javacall_ams_suite_info* pSuiteInfo) { /* * IMPL_NOTE: to be implemented! Currently it's not critical to have this * function implemented, it is required only for the case when * the installer is located on the Platform's side, but the suite * strorage - on our side. */ return JAVACALL_NOT_IMPLEMENTED;}/*------------- Suite Storage: interface to Application Manager -------------*//** * App Manager invokes this function to get the number of MIDlet suites * currently installed. * * @param pNumbefOfSuites [out] pointer to location where the number * of the installed suites will be saved * * @return <tt>JAVACALL_OK</tt> on success, * <tt>JAVACALL_FAIL</tt> otherwise */javacall_resultjavanotify_ams_suite_get_suites_number(int* pNumberOfSuites) { return midp_error2javacall(midp_get_number_of_suites(pNumberOfSuites));}/** * AppManager invokes this function to get the list of IDs * of the installed MIDlet suites. * * Note that memory for the suite IDs is allocated by the callee, * and the caller is responsible for freeing it using * javanotify_ams_suite_free_ids(). * * @param ppSuiteIds [out] on exit will hold an address of the array * containing suite IDs * @param pNumberOfSuites [out] pointer to variable to accept the number * of suites in the returned array * * @return <tt>JAVACALL_OK</tt> on success, * <tt>JAVACALL_OUT_OF_MEMORY</tt> if out of memory, * <tt>JAVACALL_IO_ERROR</tt> if an IO error */javacall_resultjavanotify_ams_suite_get_suite_ids(javacall_suite_id** ppSuiteIds, int* pNumberOfSuites) { int numberOfSuites; SuiteIdType* pSuites; MIDPError status; int i; if (pNumberOfSuites == NULL) { return JAVACALL_FAIL; } status = midp_get_suite_ids(&pSuites, &numberOfSuites); if (status != ALL_OK) { return midp_error2javacall(status); } if (numberOfSuites == 0) { *pNumberOfSuites = 0; return JAVACALL_OK; } *ppSuiteIds = (javacall_suite_id*) javacall_malloc(numberOfSuites * sizeof(javacall_suite_id)); if (*ppSuiteIds == NULL) { midp_free_suite_ids(pSuites, numberOfSuites); return JAVACALL_OUT_OF_MEMORY; } for (i = 0; i < numberOfSuites; i++) { (*ppSuiteIds)[i] = (javacall_suite_id) pSuites[i]; } *pNumberOfSuites = numberOfSuites; midp_free_suite_ids(pSuites, numberOfSuites); return JAVACALL_OK;}/** * App Manager invokes this function to free a list of suite IDs allocated * during the previous call of javanotify_ams_suite_get_suite_ids(). * * @param pSuiteIds points to an array of suite IDs * @param numberOfSuites number of elements in pSuites */voidjavanotify_ams_suite_free_suite_ids(javacall_suite_id* pSuiteIds, int numberOfSuites) { if (pSuiteIds != NULL && numberOfSuites > 0) { javacall_free(pSuiteIds); }}/** * App Manager invokes this function to get a information about the midlets * contained in the given suite. * * @param suiteId [in] unique ID of the MIDlet suite * @param ppMidletsInfo [out] on exit will hold an address of the array * containing the midlets info * @param pNumberOfEntries [out] number of entries in the returned array * * @return <tt>JAVACALL_OK</tt> on success, an error code otherwise */javacall_resultjavanotify_ams_suite_get_midlets_info(javacall_suite_id suiteId, javacall_ams_midlet_info** ppMidletsInfo, int* pNumberOfEntries) { javacall_ams_midlet_info* pTmpMidletInfo; MidletSuiteData* pMidpSuiteData; MIDPError status; jint n; PCSL_DEFINE_ASCII_STRING_LITERAL_START(midletStr) {'M', 'I', 'D', 'l', 'e', 't', '-', '\0'} PCSL_DEFINE_ASCII_STRING_LITERAL_END(midletStr); if (ppMidletsInfo == NULL || pNumberOfEntries == NULL) { return JAVACALL_FAIL; }
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?