/** * Tells if a given suite is in a list of the installed suites. * * @param suiteId unique ID of the midlet suite * * @return ALL_OK if the suite is in the list of the installed suites, * NOT_FOUND if not, * IO_ERROR if an i/o error occured when reading the information * about the installed suites, * OUT_OF_MEMORY if out of memory or IO error, * SUITE_CORRUPTED_ERROR is suite is found in the list, but it's * corrupted. */ static MIDPError suite_in_list(SuiteIdType suiteId) { MIDPError status; char* pszError; MidletSuiteData* pData; /* load _suites.dat */ status = read_suites_data(&pszError); storageFreeError(pszError); if (status != ALL_OK) { return status; } pData = get_suite_data(suiteId); if (pData != NULL) { /* * Make sure that suite is not corrupted. Return * SUITE_CORRUPTED_ERROR if the suite is corrupted. * Remove the suite before returning the status. */ status = check_for_corrupted_suite(suiteId); } else { status = NOT_FOUND; } return status; }
/** * Checks the integrity of the suite storage database and of the * installed suites. * * @param fullCheck 0 to check just an integrity of the database, * other value for full check * @param delCorruptedSuites != 0 to delete the corrupted suites, * 0 - to keep them (for re-installation). * * @return ALL_OK if no errors, * SUITE_CORRUPTED_ERROR if the suite database was corrupted * but has been successfully repaired, * another error code if the database is corrupted and * could not be repaired */ MIDPError midp_check_suites_integrity(int fullCheck, int delCorruptedSuites) { MIDPError status; char *pszError = NULL; int dbWasCorrupted = 0; /* Check if there is a previously started transaction exists. */ if (unfinished_transaction_exists()) { (void)rollback_transaction(); } /* Check if the suite database is corrupted and repair it if needed. */ status = read_suites_data(&pszError); if (status == SUITE_CORRUPTED_ERROR) { dbWasCorrupted = 1; status = repair_suite_db(); } if (status != ALL_OK) { /* give up, user interaction is needed */ return status; } /* if fullCheck is true, check all installed suites */ if (fullCheck) { int i, numOfSuites; SuiteIdType suiteId, *pSuiteIds = NULL; status = midp_get_suite_ids(&pSuiteIds, &numOfSuites); if (status == ALL_OK) { for (i = 0; i < numOfSuites; i++) { suiteId = pSuiteIds[i]; if (check_for_corrupted_suite(suiteId) == SUITE_CORRUPTED_ERROR) { dbWasCorrupted = 1; if (delCorruptedSuites) { midp_remove_suite(suiteId); } } } if (pSuiteIds != NULL) { midp_free_suite_ids(pSuiteIds, numOfSuites); } } } return dbWasCorrupted ? SUITE_CORRUPTED_ERROR : ALL_OK; }
/** * Tells if a given suite is in a list of the installed suites. * * @param suiteId unique ID of the midlet suite * * @return ALL_OK if the suite is in the list of the installed suites, * NOT_FOUND if not, * IO_ERROR if an i/o error occured when reading the information * about the installed suites, * OUT_OF_MEMORY if out of memory or IO error, * SUITE_CORRUPTED_ERROR is suite is found in the list, but it's * corrupted. */ static MIDPError suite_in_list(ComponentType type, SuiteIdType suiteId, ComponentIdType componentId) { MIDPError status; char* pszError; MidletSuiteData* pData; #if !ENABLE_DYNAMIC_COMPONENTS /** to supress compilation warnings */ (void)type; (void)componentId; #endif /* load _suites.dat */ status = read_suites_data(&pszError); storageFreeError(pszError); if (status != ALL_OK) { return status; } #if ENABLE_DYNAMIC_COMPONENTS if (type == COMPONENT_DYNAMIC) { pData = get_component_data(componentId); if (pData == NULL) { status = NOT_FOUND; } } else { #endif /* ENABLE_DYNAMIC_COMPONENTS */ pData = get_suite_data(suiteId); if (pData != NULL) { /* * Make sure that suite is not corrupted. Return * SUITE_CORRUPTED_ERROR if the suite is corrupted. * Remove the suite before returning the status. */ status = check_for_corrupted_suite(suiteId); } else { status = NOT_FOUND; } #if ENABLE_DYNAMIC_COMPONENTS } #endif return status; }