void RepositoryProfile::setProfileName ( const QString & newProfileName, bool renameDirectory ) { if ( curProfileName == newProfileName ) // nothing to do return; // should therminate thread because it is using the current database connection // and restart it after changing the repository name bool restartLister = false; if ( lister->isRunning() ) { lister->terminate(); lister->wait(); restartLister = true; } // remove existing db conenction RDDatabaseHandler::removeDbConnection ( curProfileName ); if ( renameDirectory ) { renameDatabaseFile ( databaseFile(), rpmDownloaderSettings().cacheDir().absolutePath() + "/" + curProfileName + "/" + newProfileName + ".db" ); renameRepoCacheDir ( rpmDownloaderSettings().cacheDir().absolutePath(), curProfileName, newProfileName ); } curProfileName = newProfileName; }
SearchQueryParserTest() : m_database(QSqlDatabase::addDatabase("QSQLITE")), m_parser(m_database) { QTemporaryFile databaseFile("mixxxdb.sqlite"); Q_ASSERT(databaseFile.open()); m_database.setHostName("localhost"); m_database.setUserName("mixxx"); m_database.setPassword("mixxx"); qDebug() << "Temp file is" << databaseFile.fileName(); m_database.setDatabaseName(databaseFile.fileName()); Q_ASSERT(m_database.open()); }
QMap<QString, QVariant> keyboardConfiguration(DeviceInfo *deviceInfo) { QJson::Parser parser; foreach(QString database, databaseFiles) { QFile databaseFile(database); if(!databaseFile.exists()) continue; QVariant config = parser.parse(&databaseFile); if(config.toMap().contains(deviceInfo->configurationIdentifier())) { QMap<QString, QVariant> thisKeyboardDatabase = config.toMap().value(deviceInfo->configurationIdentifier()).toMap(); return thisKeyboardDatabase; } }
void RepositoryProfile::refreshStatus() { if ( lister->isRunning() ) // thread is running do nothing return; lister->setArchitectures ( PackageMetaData::archStringList ( architecures() ) ); lister->setDatabasePath ( databaseFile() ); lister->setRepoName ( profileName() ); lister->setDownloadPath ( downloadDir() ); lister->start(); }
FileNameVector_t CompilationDatabase::GetCompileCommandsFiles() const { wxFileName databaseFile(GetFileName()); wxFileName fn(databaseFile); // Usually it will be under the top folder fn.RemoveLastDir(); // Since we can have multiple "compile_commands.json" files, we take the most updated file // Prepare a list of files to check FileNameVector_t files; std::queue<std::pair<wxString, int> > dirs; // we start with the current path dirs.push(std::make_pair(fn.GetPath(), 0)); const int MAX_DEPTH = 2; // If no files were found, scan 2 levels only while(!dirs.empty()) { std::pair<wxString, int> curdir = dirs.front(); dirs.pop(); if(files.empty() && (curdir.second > MAX_DEPTH)) { CL_DEBUG("Could not find compile_commands.json files while reaching depth 2, aborting"); break; } wxFileName fn(curdir.first, "compile_commands.json"); if(fn.Exists()) { CL_DEBUGS("CompilationDatabase: found file: " + fn.GetFullPath()); files.push_back(fn); } // Check to see if there are more directories to recurse wxDir dir; if(dir.Open(curdir.first)) { wxString dirname; bool cont = dir.GetFirst(&dirname, "", wxDIR_DIRS); while(cont) { wxString new_dir; new_dir << curdir.first << wxFileName::GetPathSeparator() << dirname; dirs.push(std::make_pair(new_dir, curdir.second + 1)); dirname.Clear(); cont = dir.GetNext(&dirname); } } } return files; }
FileNameVector_t CompilationDatabase::GetCompileCommandsFiles() const { wxFileName databaseFile(GetFileName()); wxFileName fn(databaseFile); // Usually it will be under the top folder fn.RemoveLastDir(); // Since we can have multiple "compile_commands.json" files, we take the most updated file // Prepare a list of files to check FileNameVector_t files; std::queue<wxString> dirs; // we start with the current path dirs.push(fn.GetPath()); while(!dirs.empty()) { wxString curdir = dirs.front(); dirs.pop(); wxFileName fn(curdir, "compile_commands.json"); if(fn.Exists() /*&& // file exists (fn.GetModificationTime().GetTicks() > databaseFile.GetModificationTime().GetTicks())*/) // and its newer than the database file { CL_DEBUGS("CompilationDatabase: found file: " + fn.GetFullPath()); files.push_back(fn); } // Check to see if there are more directories to recurse wxDir dir; if(dir.Open(curdir)) { wxString dirname; bool cont = dir.GetFirst(&dirname, "", wxDIR_DIRS); while(cont) { wxString new_dir; new_dir << curdir << wxFileName::GetPathSeparator() << dirname; dirs.push(new_dir); dirname.Clear(); cont = dir.GetNext(&dirname); } } } return files; }
/** * @brief Tests import of ImportNewData. */ void TestCreateAsset::testImport() { QDate startDate = QDate::fromString("2014-01-01", "yyyy-MM-dd"); QDate endDate = QDate::fromString("2014-02-01", "yyyy-MM-dd"); Asset b = Asset("Gogolea", "../Examples/Gogolea_test.csv", "Yahoo", startDate, endDate); CreateAsset algo = CreateAsset(); algo.import(b, "../../Examples/table.csv"); SessionSaver::getInstance()->saveAsset(b); QString data; QFile importedCSV(b.getAbsolutePathToFile()); QStringList dataRows; QStringList dataRow; if (importedCSV.open(QFile::ReadOnly)) { data = importedCSV.readAll(); dataRows = data.split("\n"); importedCSV.close(); } QCOMPARE(dataRows.size(), 23); // Checks first date: dataRow = dataRows.at(1).split(","); QVERIFY(endDate >= QDate::fromString(dataRow[0], "yyyy-MM-dd")); // Checks last date: dataRow = dataRows.at(dataRows.size()-2).split(","); QVERIFY(startDate <= QDate::fromString(dataRow[0], "yyyy-MM-dd")); Asset *a = SessionBuilder::getInstance()->buildAsset("Gogolea"); QVERIFY(a->getFile() == "../Examples/Gogolea_test.csv"); QVERIFY(a->getStartDate() == startDate); QVERIFY(a->getEndDate() == endDate); QVERIFY(a->getName() == "Gogolea"); QVERIFY(a->getOrigin() == "Yahoo"); QVERIFY(AssetsFactory::getInstance()->retrieveAsset("Gogolea") != NULL); //Verify the day of week int size = dataRows.size(); for (int x =1; x < size; x++) { dataRow = dataRows.at(x).split(","); QVERIFY((QDate::fromString(dataRow[0], "yyyy-MM-dd").dayOfWeek() <= 5)); } // Deletes the database file: QFile databaseFile(SessionSaver::getInstance()->getDatabaseFile()); databaseFile.remove(); }
void CTestContactOperations::DeleteContactsL() { // existing database TPtrC databaseFile(_L("C:contactDB.cdb")); TContactItemId itemId = KErrNotFound; CContactDatabase* dBase = NULL; CContactIdArray* idArray = NULL; dBase = CContactDatabase::OpenL(databaseFile); CleanupStack::PushL(dBase); // Set the filter to select all the contact items in the database CCntFilter* exportFilter = CCntFilter::NewL(); CleanupStack::PushL(exportFilter); exportFilter->SetContactFilterTypeCard(ETrue); dBase->FilterDatabaseL(*exportFilter); idArray = exportFilter->iIds; CleanupStack::PushL(idArray); TInt numberOfContacts; GetIntFromConfig(ConfigSection(), KNumberOfCont, numberOfContacts); INFO_PRINTF1(_L("Deleting Contacts.....")); // Delete the contacts one at a time for(TInt i=(idArray->Count()-1);i>=0;i--) { dBase->DeleteContactL((*idArray)[i]); } _LIT(KCount, "The number of contacts in the database is %d \n"); INFO_PRINTF2(KCount, dBase->CountL()); // Close the contacts dBase->CloseContactL(itemId); // Cleanup CleanupStack::Pop(idArray); CleanupStack::PopAndDestroy(exportFilter); CleanupStack::PopAndDestroy(dBase); }
int ctkDICOMDatabaseTest2( int argc, char * argv [] ) { QCoreApplication app(argc, argv); if (argc < 2) { std::cerr << "ctkDICOMDatabaseTest2: missing dicom filePath argument"; std::cerr << std::endl; return EXIT_FAILURE; } QString dicomFilePath(argv[1]); ctkDICOMDatabase database; QDir databaseDirectory = QDir::temp(); databaseDirectory.remove("ctkDICOMDatabase.sql"); databaseDirectory.remove("ctkDICOMTagCache.sql"); QFileInfo databaseFile(databaseDirectory, QString("database.test")); database.openDatabase(databaseFile.absoluteFilePath()); if (!database.lastError().isEmpty()) { std::cerr << "ctkDICOMDatabase::openDatabase() failed: " << qPrintable(database.lastError()) << std::endl; return EXIT_FAILURE; } if (!database.database().isValid()) { std::cerr << "ctkDICOMDatabase::openDatabase() failed: " << "invalid sql database" << std::endl; return EXIT_FAILURE; } if (database.isInMemory()) { std::cerr << "ctkDICOMDatabase::openDatabase() failed: " << "database should not be in memory" << std::endl; return EXIT_FAILURE; } bool res = database.initializeDatabase(); if (!res) { std::cerr << "ctkDICOMDatabase::initializeDatabase() failed." << std::endl; return EXIT_FAILURE; } // // Test that the tag interface works to parse ascii // QString tag("0008,103e"); unsigned short group, element; if ( !database.tagToGroupElement(tag, group, element) ) { std::cerr << "ctkDICOMDatabase: could not parse tag" << std::endl; return EXIT_FAILURE; } if ( group != 0x8 || element != 0x103e ) { std::cerr << "ctkDICOMDatabase: expected: " << "0008,103e" << std::endl; std::cerr << "ctkDICOMDatabase: got: " << group << " " << element << std::endl; std::cerr << "ctkDICOMDatabase: parsed tag does not match group/element" << std::endl; return EXIT_FAILURE; } if ( database.groupElementToTag(group, element) != tag ) { std::cerr << "ctkDICOMDatabase: could not convert a uints to tag string" << std::endl; return EXIT_FAILURE; } // // Basic test: // - insert the file specified on the command line // - ask for tag values and compare to known results // database.insert(dicomFilePath, false, false); QString instanceUID("1.2.840.113619.2.135.3596.6358736.4843.1115808177.83"); QString foundFile = database.fileForInstance(instanceUID); if (foundFile != dicomFilePath) { std::cerr << "ctkDICOMDatabase: didn't get back the original file path" << std::endl; return EXIT_FAILURE; } QString foundInstance = database.instanceForFile(dicomFilePath); if (foundInstance != instanceUID) { std::cerr << "ctkDICOMDatabase: didn't get back the original instance uid" << std::endl; return EXIT_FAILURE; } // // Test the tag cache // if (database.tagCacheExists()) { std::cerr << "ctkDICOMDatabase: tag cache should not exist in fresh database" << std::endl; return EXIT_FAILURE; } if (!database.initializeTagCache()) { std::cerr << "ctkDICOMDatabase: could not initialize tag cache" << std::endl; return EXIT_FAILURE; } if (!database.tagCacheExists()) { std::cerr << "ctkDICOMDatabase: tag cache should exist but is not detected" << std::endl; return EXIT_FAILURE; } if (database.cachedTag(instanceUID, tag) != QString("")) { std::cerr << "ctkDICOMDatabase: tag cache should return empty string for unknown instance tag" << std::endl; return EXIT_FAILURE; } QString knownSeriesDescription("3D Cor T1 FAST IR-prepped GRE"); if (!database.cacheTag(instanceUID, tag, knownSeriesDescription)) { std::cerr << "ctkDICOMDatabase: could not insert instance tag" << std::endl; return EXIT_FAILURE; } if (database.cachedTag(instanceUID, tag) != knownSeriesDescription) { std::cerr << "ctkDICOMDatabase: could not retrieve cached tag" << std::endl; return EXIT_FAILURE; } QString foundSeriesDescription = database.instanceValue(instanceUID, tag); if (foundSeriesDescription != knownSeriesDescription) { std::cerr << "ctkDICOMDatabase: invalid element value returned" << std::endl; return EXIT_FAILURE; } // now update the database database.updateSchema(); // and repeat the above checks foundFile = database.fileForInstance(instanceUID); if (foundFile != dicomFilePath) { std::cerr << "ctkDICOMDatabase: didn't get back the original file path" << std::endl; return EXIT_FAILURE; } foundSeriesDescription = database.instanceValue(instanceUID, tag); if (foundSeriesDescription != knownSeriesDescription) { std::cerr << "ctkDICOMDatabase: invalid element value returned" << std::endl; return EXIT_FAILURE; } database.closeDatabase(); database.initializeDatabase(); return EXIT_SUCCESS; }
int ctkDICOMDatabaseTest6( int argc, char * argv [] ) { QCoreApplication app(argc, argv); if (argc < 2) { std::cerr << "ctkDICOMDatabaseTest6: missing dicom filePath argument"; std::cerr << std::endl; return EXIT_FAILURE; } QString dicomFilePath(argv[1]); ctkDICOMDatabase database; QDir databaseDirectory = QDir::temp(); databaseDirectory.remove("ctkDICOMDatabase.sql"); databaseDirectory.remove("ctkDICOMTagCache.sql"); QFileInfo databaseFile(databaseDirectory, QString("database.test")); database.openDatabase(databaseFile.absoluteFilePath()); bool res = database.initializeDatabase(); if (!res) { std::cerr << "ctkDICOMDatabase::initializeDatabase() failed." << std::endl; return EXIT_FAILURE; } // // Basic test: // - insert the file specified on the command line // - ask for name and descriptions and compare to known results // QString instanceUID("1.2.840.113619.2.135.3596.6358736.4843.1115808177.83"); // // Test the pre load values feature of the database // QString preInsertDescription = database.descriptionForSeries(instanceUID); if (!preInsertDescription.isEmpty()) { std::cerr << "ctkDICOMDatabase: db should return empty string for unknown " << " instance series description, instead got: " << preInsertDescription.toStdString() << std::endl; return EXIT_FAILURE; } database.insert(dicomFilePath, false, false); QString filePath = database.fileForInstance(instanceUID); std::cerr << "Instance file " << filePath.toStdString() << std::endl; // check for descriptions QHash<QString,QString> descriptions (database.descriptionsForFile(filePath)); std::cout << "\tPatient Name: " << descriptions["PatientsName"].toStdString() << "\n\tStudy Desciption: " << descriptions["StudyDescription"].toStdString() << "\n\tSeries Desciption: " << descriptions["SeriesDescription"].toStdString() << std::endl; // check for known series description QString knownSeriesDescription("3D Cor T1 FAST IR-prepped GRE"); QString seriesUID = database.seriesForFile(filePath); QString seriesDescription = database.descriptionForSeries(seriesUID); if (seriesDescription != knownSeriesDescription) { std::cerr << "ctkDICOMDatabase: database should return series description of '" << knownSeriesDescription.toStdString() << "', instead returned '" << seriesDescription.toStdString() << "'\n\tinstanceUID = " << instanceUID.toStdString() << "\n\tseriesUID = " << seriesUID.toStdString() << std::endl; return EXIT_FAILURE; } // get the study and patient uids QString patientUID, studyUID; studyUID = database.studyForSeries(seriesUID); patientUID = database.patientForStudy(studyUID); // check for empty study description QString studyDescription = database.descriptionForStudy(studyUID); if (!studyDescription.isEmpty()) { std::cerr << "ctkDICOMDatabase: database should return empty study" << " description for studyUID of " << studyUID.toStdString() << ", instead returned '" << studyDescription.toStdString() << "'" << std::endl; return EXIT_FAILURE; } // check for known patient name QString knownPatientName("Facial Expression"); QString patientName = database.nameForPatient(patientUID); if (patientName != knownPatientName) { std::cerr << "ctkDICOMDatabase: database should return known patient name '" << knownPatientName.toStdString() << "' for patient UID of " << patientUID.toStdString() << ", instead returned '" << patientName.toStdString() << "'" << std::endl; return EXIT_FAILURE; } database.closeDatabase(); std::cerr << "Database is in " << databaseDirectory.path().toStdString() << std::endl; return EXIT_SUCCESS; }
void IpLocationStore::Load() { _ipLocationStore.clear(); TC_LOG_INFO("server.loading", "Loading IP Location Database..."); std::string databaseFilePath = sConfigMgr->GetStringDefault("IPLocationFile", ""); if (databaseFilePath.empty()) return; // Check if file exists std::ifstream databaseFile(databaseFilePath); if (!databaseFile) { TC_LOG_ERROR("server.loading", "IPLocation: No ip database file exists (%s).", databaseFilePath.c_str()); return; } if (!databaseFile.is_open()) { TC_LOG_ERROR("server.loading", "IPLocation: Ip database file (%s) can not be opened.", databaseFilePath.c_str()); return; } std::string ipFrom; std::string ipTo; std::string countryCode; std::string countryName; while (databaseFile.good()) { // Read lines if (!std::getline(databaseFile, ipFrom, ',')) break; if (!std::getline(databaseFile, ipTo, ',')) break; if (!std::getline(databaseFile, countryCode, ',')) break; if (!std::getline(databaseFile, countryName, '\n')) break; // Remove new lines and return countryName.erase(std::remove(countryName.begin(), countryName.end(), '\r'), countryName.end()); countryName.erase(std::remove(countryName.begin(), countryName.end(), '\n'), countryName.end()); // Remove quotation marks ipFrom.erase(std::remove(ipFrom.begin(), ipFrom.end(), '"'), ipFrom.end()); ipTo.erase(std::remove(ipTo.begin(), ipTo.end(), '"'), ipTo.end()); countryCode.erase(std::remove(countryCode.begin(), countryCode.end(), '"'), countryCode.end()); countryName.erase(std::remove(countryName.begin(), countryName.end(), '"'), countryName.end()); // Convert country code to lowercase std::transform(countryCode.begin(), countryCode.end(), countryCode.begin(), ::tolower); _ipLocationStore.emplace_back(uint32(atoul(ipFrom.c_str())), uint32(atoul(ipTo.c_str())), std::move(countryCode), std::move(countryName)); } std::sort(_ipLocationStore.begin(), _ipLocationStore.end(), [](IpLocationRecord const& a, IpLocationRecord const& b) { return a.IpFrom < b.IpFrom; }); ASSERT(std::is_sorted(_ipLocationStore.begin(), _ipLocationStore.end(), [](IpLocationRecord const& a, IpLocationRecord const& b) { return a.IpFrom < b.IpTo; }), "Overlapping IP ranges detected in database file"); databaseFile.close(); TC_LOG_INFO("server.loading", ">> Loaded " SZFMTD " ip location entries.", _ipLocationStore.size()); }
int ctkDICOMDatabaseTest5( int argc, char * argv [] ) { QCoreApplication app(argc, argv); if (argc < 2) { std::cerr << "ctkDICOMDatabaseTest2: missing dicom filePath argument"; std::cerr << std::endl; return EXIT_FAILURE; } QString dicomFilePath(argv[1]); ctkDICOMDatabase database; QDir databaseDirectory = QDir::temp(); databaseDirectory.remove("ctkDICOMDatabase.sql"); databaseDirectory.remove("ctkDICOMTagCache.sql"); QFileInfo databaseFile(databaseDirectory, QString("database.test")); database.openDatabase(databaseFile.absoluteFilePath()); bool res = database.initializeDatabase(); if (!res) { std::cerr << "ctkDICOMDatabase::initializeDatabase() failed." << std::endl; return EXIT_FAILURE; } std::cerr << "Database is in " << databaseDirectory.path().toStdString() << std::endl; // // First, copy the passed file to two temp directories // databaseDirectory.rmdir("firstInsert"); databaseDirectory.rmdir("secondInsert"); databaseDirectory.mkdir("firstInsert"); databaseDirectory.mkdir("secondInsert"); QString firstDestination = QDir::cleanPath(databaseDirectory.absolutePath() + QDir::separator() + "firstInsert" + QDir::separator() + "file.dcm"); QString secondDestination = QDir::cleanPath(databaseDirectory.absolutePath() + QDir::separator() + "secondInsert" + QDir::separator() + "file.dcm"); QFile::copy(dicomFilePath, firstDestination); std::cerr << "copied to: " << firstDestination.toStdString() << std::endl; QFile::copy(dicomFilePath, secondDestination); std::cerr << "copied to: " << secondDestination.toStdString() << std::endl; // // Insert the first instance // database.insert(firstDestination, false, false); // // Now delete the first instance and try inserting the second // QFile::remove(firstDestination); database.insert(secondDestination, false, false); // // At this point, the file associated with the instance UID should be // the secondDestination - it's an error if not. // QString instanceUID("1.2.840.113619.2.135.3596.6358736.4843.1115808177.83"); QString filePathInDatabase = database.fileForInstance(instanceUID); if (filePathInDatabase != secondDestination) { std::cerr << "ctkDICOMDatabase thinks instance is in " << filePathInDatabase.toStdString() << std::endl; std::cerr << "But we just inserted it from " << secondDestination.toStdString() << std::endl; return EXIT_FAILURE; } // // Close and clean up // database.closeDatabase(); return EXIT_SUCCESS; }
int ctkDICOMDatabaseTest1( int argc, char * argv [] ) { QCoreApplication app(argc, argv); ctkDICOMDatabase database; QDir databaseDirectory = QDir::temp(); QFileInfo databaseFile(databaseDirectory, QString("database.test")); database.openDatabase(databaseFile.absoluteFilePath()); if (!database.lastError().isEmpty()) { std::cerr << "ctkDICOMDatabase::openDatabase() failed: " << qPrintable(database.lastError()) << std::endl; return EXIT_FAILURE; } if (!database.database().isValid()) { std::cerr << "ctkDICOMDatabase::openDatabase() failed: " << "invalid sql database" << std::endl; return EXIT_FAILURE; } if (database.isInMemory()) { std::cerr << "ctkDICOMDatabase::openDatabase() failed: " << "database should not be in memory" << std::endl; return EXIT_FAILURE; } if (database.databaseFilename() != databaseFile.absoluteFilePath()) { std::cerr << "ctkDICOMDatabase::databaseFilename() failed: " << qPrintable( database.databaseFilename()) << std::endl; return EXIT_FAILURE; } if (QDir(database.databaseDirectory()) != databaseDirectory) { std::cerr << "ctkDICOMDatabase::databaseDirectory() failed" << qPrintable(database.databaseDirectory()) << std::endl; return EXIT_FAILURE; } bool res = database.initializeDatabase(); if (!res) { std::cerr << "ctkDICOMDatabase::initializeDatabase() failed." << std::endl; return EXIT_FAILURE; } // check if it doesn't crash database.pathForDataset(0); database.insert(0, true, true); database.insert(0, true, false); database.insert(0, false, false); database.insert(0, false, true); database.closeDatabase(); database.initializeDatabase(); return EXIT_SUCCESS; }
void CTestContactsPBAPExport::ExportContactsL() { TInt err = KErrNone; // Retrieve the file name to which contact item is to be exported RFs fsSession; RFileWriteStream writeStream; // connect to file system User::LeaveIfError(fsSession.Connect()); CleanupClosePushL(fsSession); GetInputFromIni(); // Makes one or more directories. fsSession.MkDirAll(iExportTo); // Replaces a single file with another User::LeaveIfError(writeStream.Replace(fsSession, iExportTo, EFileWrite)); INFO_PRINTF1(_L("Exporting Contact.....")); // Existing database TPtrC databaseFile(_L("C:contactDb.cdb")); CContactDatabase* dBase = NULL; CContactIdArray* idArray = NULL; // Open the existing database dBase = CContactDatabase::OpenL(databaseFile); CleanupStack::PushL(dBase); // Create Utility class object, to export the contact from database CTestStep* self = static_cast<CTestStep*>(this); iExportObj = new(ELeave) CContactsPBAPExportUtilityClass(self); SetFilterL(); CCntFilter* exportFilter = CCntFilter::NewL(); CleanupStack::PushL(exportFilter); // Get all the contacts from the database to export exportFilter->SetContactFilterTypeCard(ETrue); dBase->FilterDatabaseL(*exportFilter); idArray = exportFilter->iIds; CleanupStack::PushL(idArray); if(iDamageDb) { #ifdef _DEBUG #ifndef __SYMBIAN_CNTMODEL_USE_SQLITE__ TRAPD(err1,dBase->DamageDatabaseL(0x666)); if(err1 == KErrNone) { TRAPD(err,iExportObj->ExportvCardL(dBase, iStandard, idArray, writeStream, iContactFilter)); INFO_PRINTF2(_L("Err:%d"),err); if(err == KErrNotReady) { SetTestStepResult(EPass); } else { SetTestStepResult(EFail); } if(dBase->IsDamaged()) { dBase->RecoverL(); } } else { INFO_PRINTF2(_L("Could not damage database Err:"),err1); } #else SetTestStepResult(EPass); #endif #endif } else { if(iInvalidFileSystem) { #ifdef _DEBUG fsSession.SetErrorCondition(KErrNotReady); TRAPD(err,iExportObj->ExportvCardL(dBase, iStandard, idArray, writeStream, iContactFilter)); if(err == KErrNotReady) { SetTestStepResult(EPass); } else { SetTestStepResult(EFail); } fsSession.SetErrorCondition(KErrNone); #endif } else { if(!iSetOOM) { if(idArray->Count() > 0) { for(TInt i=0; i<idArray->Count() ; i++) { TInt dCount = dBase->CountL(); if(i>=dCount) { break; } // temporary array used to export one contact at a time CContactIdArray* tempIdArray = CContactIdArray::NewL(); CleanupStack::PushL(tempIdArray); tempIdArray->AddL((*idArray)[i]); TRAPD(err,iExportObj->ExportvCardL(dBase, iStandard, tempIdArray, writeStream, iContactFilter)); if(err != KErrNone ) { if(err != KErrNotFound) { SetTestStepError(err); } } CleanupStack::PopAndDestroy(tempIdArray); } } else { if(idArray->Count()==0) { TRAPD(err,iExportObj->ExportvCardL(dBase, iStandard, idArray, writeStream, iContactFilter)); if(err != KErrNone) { SetTestStepError(err); } } } } else { TInt tryCount = 1; for ( ;; ) { __UHEAP_SETFAIL(RHeap::EDeterministic, tryCount); TRAP(err, iExportObj->ExportvCardL(dBase, iStandard, idArray, writeStream, iContactFilter)); if ( err == KErrNone ) { __UHEAP_RESET; INFO_PRINTF1(_L("OOM testing of CContactDatabase::ExportSelectedContactsL Api is done")); break; } if ( err != KErrNoMemory ) { INFO_PRINTF2(_L("The unexpected error code is:%d"),err); SetTestStepResult(EFail); break; } __UHEAP_SETFAIL(RHeap::ENone, 0); tryCount++; } } } } CleanupStack::Pop(idArray); CleanupStack::PopAndDestroy(exportFilter); INFO_PRINTF1(_L("Exported Contact")); writeStream.CommitL(); writeStream.Close(); INFO_PRINTF2(_L("Total number of contacts in database %d "), dBase->CountL()); // Cleanup CleanupStack::PopAndDestroy(dBase); CleanupStack::PopAndDestroy(&fsSession); }