// --------------------------------------------------------- // CPosTp1::VerifyLockedDatabaseL // // (other items were commented in a header). // --------------------------------------------------------- // void CPosTp1::VerifyLockedDatabaseL() { _LIT(KTestPath, "c:\\system\\test\\testdata\\"); // copy the test db to the private path CFileMan* fileMan = CFileMan::NewL(iFileSession); CleanupStack::PushL(fileMan); TBuf<150> srcPath; srcPath.Append(KTestPath); srcPath.Append(KTp1TestDb); TInt err = fileMan->Copy(srcPath, KLmTp1DefaultDbPath, CFileMan::EOverWrite); if (err != KErrNone) iLog->Log(_L("Error when copying file")); CleanupStack::PopAndDestroy(fileMan); CPosLmDatabaseManager* manager = CPosLmDatabaseManager::NewL(); CleanupStack::PushL(manager); // This db must exist manager->SetDefaultDatabaseUriL(KTp1TestDb); CleanupStack::PopAndDestroy(manager); CPosLandmarkDatabase* db1 = CPosLandmarkDatabase::OpenL(KTp1TestDb); CleanupStack::PushL(db1); if (db1->IsInitializingNeeded()) { TRAPD( err, ExecuteAndDeleteLD( db1->InitializeL() ) ); AssertTrueSecL(err == KErrNone, _L("Init db failed")); } // Take read lock RArray<TPosLmItemId> ids; CleanupClosePushL(ids); User::LeaveIfError(ids.Append(1)); User::LeaveIfError(ids.Append(3)); User::LeaveIfError(ids.Append(4)); User::LeaveIfError(ids.Append(6)); User::LeaveIfError(ids.Append(7)); User::LeaveIfError(ids.Append(9)); User::LeaveIfError(ids.Append(24)); User::LeaveIfError(ids.Append(14)); User::LeaveIfError(ids.Append(66)); User::LeaveIfError(ids.Append(61)); User::LeaveIfError(ids.Append(14)); CPosLmOperation* operation = db1->PreparePartialLandmarksL(ids); CleanupStack::PushL(operation); TReal32 progress(0); TRequestStatus status; while (progress < 0.4) { operation->NextStep(status, progress); User::WaitForRequest(status); } // Try to instantiate a new db handle operation->NextStep(status, progress); CPosLandmarkDatabase* db2 = CPosLandmarkDatabase::OpenL(); iLog->Log(_L("CPosLandmarkDatabase::OpenL done")); delete db2; User::WaitForRequest(status); // Release read lock CleanupStack::PopAndDestroy(operation); // Take write lock operation = db1->RemoveAllLandmarksL(); CleanupStack::PushL(operation); progress = 0; while (progress < 0.4) { operation->NextStep(status, progress); User::WaitForRequest(status); } // Try to instantiate a new db handle - should result in KErrLocked operation->NextStep(status, progress); db2 = NULL; TRAPD(err1, db2 = CPosLandmarkDatabase::OpenL()); delete db2; User::WaitForRequest(status); AssertTrueSecL(err1 == KErrLocked, _L("OpenL() didn't result in KErrLocked but in %d"), err1); CleanupStack::PopAndDestroy(3, db1); }
void IntegrityDeleteFileL(const TDesC& aPath, CIntegrityTreeLeaf* aLeaf, RFs& aFs, RLoader& aLoader, CFileMan& aFileMan) { _LIT(KSysBin, "\\sys\\bin"); RBuf name; name.CreateL(aPath, KMaxFileName); CleanupClosePushL(name); name.Append(aLeaf->Name()); TEntry entry; TInt err = aFs.Entry(name, entry); if (err == KErrNone) { aFs.SetAtt(name, 0, KEntryAttReadOnly); if(entry.IsDir()) { // Make sure to append slash before calling RmDir - otherwise it deletes the parent directory if (name[name.Length()-1] != KPathDelimiter) { name.Append(KPathDelimiter); } User::LeaveIfError(aFileMan.RmDir(name)); } else { if ( aLeaf->Type() == EBackupFile ) // Implies a commit operation is in progress { if ( IsBinary(entry) ) { // Forming the file name so the renamed file can be under sys/bin // for special delete mechanism using RLoader::Delete RBuf tmpName; TParsePtrC fileName(name); tmpName.CreateL(name.Length() + KSysBin.iTypeLength); CleanupClosePushL(tmpName); tmpName.Append(fileName.Drive()); tmpName.Append(KSysBin); tmpName.Append(fileName.Path()); tmpName.Append(fileName.NameAndExt()); DEBUG_PRINTF3(_L("Integrity Services - Renaming %S to %S"), &name, &tmpName); aFileMan.Rename(name,tmpName,CFileMan::EOverWrite); User::LeaveIfError(aLoader.Delete(tmpName)); // Using RLoader delete for paged binaries DEBUG_PRINTF2(_L("Integrity Services - Deleted renamed file %S"), &tmpName); // prune the directory tree if possible RemoveDirectoryTreeL(aFs, tmpName); CleanupStack::PopAndDestroy(&tmpName); } else { User::LeaveIfError(aFileMan.Delete(name)); } } else { // Need to use RLoader Delete which can be used during deletion of Added files during Rollback User::LeaveIfError(aLoader.Delete(name)); } } // prune the directory tree if possible RemoveDirectoryTreeL(aFs, name); } else if(err != KErrNotFound && err != KErrPathNotFound) { DEBUG_PRINTF3(_L("Integrity Services - error %d removing %S"), err, &name); User::Leave(err); } else { DEBUG_PRINTF3(_L("Integrity Services - error %d removing %S"), err, &name); // Check for any renamed files to move it to sys/bin for special delete mechanism RBuf tmpName; TParsePtrC fileName(name); tmpName.CreateL(name.Length() + KSysBin.iTypeLength); CleanupClosePushL(tmpName); tmpName.Append(fileName.Drive()); tmpName.Append(KSysBin); tmpName.Append(fileName.Path()); tmpName.Append(fileName.NameAndExt()); DEBUG_PRINTF2(_L("Integrity Services - Removing %S renamed binary files if any"), &tmpName); aLoader.Delete(tmpName); // prune the directory tree if possible RemoveDirectoryTreeL(aFs, tmpName); CleanupStack::PopAndDestroy(&tmpName); } CleanupStack::PopAndDestroy(&name); }
LOCAL_C void TestCreateContactWithoutImagesFoldeL() { test.Next(_L("TestCreateContactWithoutImagesFoldeL")); SETUP; // Delete the images folder and all contents TInt drive; #ifdef __WINS__ TInt err = DriveInfo::GetDefaultDrive(DriveInfo::EDefaultPhoneMemory, drive); #else TInt err = DriveInfo::GetDefaultDrive(DriveInfo::EDefaultMassStorage, drive); #endif // Do not leave with this error. The phone does not have to have this support if (err == KErrNone) { // Get the root path in this drive to create // to create the images directory TPath dir; User::LeaveIfError(PathInfo::GetRootPath(dir, drive)); dir.Append(KImagesFolder); CFileMan* fileMan = CFileMan::NewL(fs); err = fileMan->RmDir(dir); // err not used delete fileMan; } else { test.Printf(_L("Could not remove the images folder\n")); return; } // Create an image and store an image without the images dir available CContactItem *contact = CContactItem::NewLC(KUidContactCard); CContactItemField *newField = CContactItemField::NewLC(KStorageTypeText, KUidContactFieldCodImage); newField->SetMapping(KUidContactFieldVCardMapUnknown); newField->TextStorage()->SetTextL(KSrcImage()); contact->AddFieldL(*newField); // Takes ownership CleanupStack::Pop(newField); TContactItemId id = cntClient.CreateContactL(*contact); CleanupStack::PopAndDestroy(contact); // View definition to read image field CContactItemViewDef *imageViewDef = CContactItemViewDef::NewLC(CContactItemViewDef::EIncludeFields, CContactItemViewDef::EMaskHiddenFields); imageViewDef->AddL(KUidContactFieldCodImage); contact = cntClient.ReadContactL(imageViewDef ,id); CleanupStack::PopAndDestroy(imageViewDef); // imageViewDef TInt index = contact->CardFields().Find(KUidContactFieldCodImage, KUidContactFieldVCardMapUnknown); // Test image field found test(index != KErrNotFound); CContactItemField& field = contact->CardFields()[index]; TPtrC imagePtr = field.TextStorage()->Text(); // Image path should not change test(imagePtr.Compare(KSrcImage()) == 0); cntClient.CloseContact(id); delete contact; TEAR_DOWN; }
// --------------------------------------------------------- // CPosTp666::SetupTestPartL // // (other items were commented in a header). // --------------------------------------------------------- // void CPosTp666::SetupTestPartL(TInt aIndex) { iLog->Put(_L("StartL(TInt aIndex)")); /* #ifdef __WINS__ _LIT(KNotOnWins, "!!!!This test is NOT supported on WINS!!!!"); LogErrorAndLeave(KNotOnWins); #endif */ TBuf<20> capability; switch (aIndex) { case 0: iLog->Put(_L("Part1")); capability.Zero(); // Set to all cap but readuserdata and writeuserdata capability.Append(_L("27FFF")); break; case 1: iLog->Put(_L("Part2")); // Set to Set to all cap but writeuserdata capability.Append(_L("2FFFF")); break; case 2: iLog->Put(_L("Part3")); // Set to Set to all cap but readuserdata capability.Append(_L("37FFF")); break; case 3: iLog->Put(_L("Part4")); // Set to only readuserdata and writeuserdata capability.Append(_L("18000")); break; default: iLog->Put(_L("Default")); LogErrorAndLeave(_L("We should never come here")); break; } // Only for target, on winscw use bat-script RProcess execlient; RFile file; RFs fileSession; User::LeaveIfError(fileSession.Connect()); CleanupClosePushL(fileSession); CleanupClosePushL(file); CFileMan* fileMan = CFileMan::NewL(fileSession); CleanupStack::PushL(fileMan); TBuf<100> buf; buf.Append(_L("CapabilityTests.exe ")); buf.Append(capability); buf.Append(_L(" CapabilityTests_tmp.exe")); // Make call to SetCap TInt result = execlient.Create(KSetCapPath, //_L("CapabilityTests.exe 3FFFF CapabilityTests_All.exe"), buf, TUidType(KNullUid, KNullUid, KNullUid)); User::LeaveIfError(result); execlient.Resume(); //make the execlient visible User::After(800000); //Wait 0.8 s execlient.Close(); //Close handle to exe-client // now move file CapabilityTests_tmp.exe to CapabilityTests.exe TInt err = fileMan->Move(_L("c:\\sys\\bin\\CapabilityTests_tmp.exe"), _L("c:\\sys\\bin\\CapabilityTests.exe"), CFileMan::EOverWrite); if (err != KErrNone) { iLog->Put(_L("Move problem")); LogErrorAndLeave(_L("Move problem"), err); } CleanupStack::PopAndDestroy(fileMan); //fileMan CleanupStack::PopAndDestroy(&file); //file CleanupStack::PopAndDestroy(&fileSession); //fileSession // Prepare test conditions SetupTestEnvironmentL(); buf.Zero(); buf.Format(_L("SetCap done, Now Execute CapabilityTest TP107, part %d"), aIndex+1); TUtfwUserAnswer answer = iUserInfo->ShowDialog(buf, EUtfwDialogTypeOk, EFalse); //if(answer == EUtfwUserAnswerNo) }
void CImPop3TransferMessage::StartL(TMsvId aSourceMessage, TMsvId aDestFolder, TImPop3TransferMethod aTransferMethod, TRequestStatus& aStatus) { iSourceMessage = aSourceMessage; iDestFolder = aDestFolder; iTransferMethod = aTransferMethod; iReportStatus = &aStatus; User::LeaveIfError(iEntry.SetEntry(aSourceMessage)); TMsvEntry entry = iEntry.Entry(); HBufC* details = HBufC::NewLC(entry.iDetails.Size()); (*details) = entry.iDetails; HBufC* description = HBufC::NewLC(entry.iDescription.Size()); (*description) = entry.iDescription; TFileName mailDirectory; mailDirectory.Append('a' + MessageServer::CurrentDriveL(iEntry.FileSession())); mailDirectory.Append(KPop3DriveSeparator); mailDirectory.Append(KMsvDefaultFolder2); // Get the store filename from the source message TFileName sourceStoreFilename = mailDirectory; User::LeaveIfError(iEntry.SetEntry(aSourceMessage)); TBool storeFound = iEntry.HasStoreL(); if (storeFound) { MsvUtils::ConstructEntryName(iEntry.Entry().iServiceId, iEntry.Entry().Id(), sourceStoreFilename, MsvUtils::EStore); } // Create a message entry in the destination folder iEntry.SetEntry(aDestFolder); TMsvEmailEntry emailEntry(entry); emailEntry.SetVisible(ETrue); emailEntry.iDetails.Set(details->Des()); emailEntry.iDescription.Set(description->Des()); emailEntry.SetDisconnectedOperation(ENoDisconnectedOperations); User::LeaveIfError(iEntry.CreateEntry(emailEntry)); iCopiedMessageId = emailEntry.Id(); User::LeaveIfError(iEntry.SetEntry(emailEntry.Id())); TMsvId newEntry = emailEntry.Id(); // Get the serviceId of the service the destination ID is located in. TMsvId destinationServiceId = iEntry.OwningService(); if (storeFound) { // Get the name that the destination file should be copied to TFileName destinationStoreFilename = mailDirectory; MsvUtils::ConstructEntryName(destinationServiceId, iEntry.Entry().Id(), destinationStoreFilename, MsvUtils::EStore); CFileMan* fileMan = CFileMan::NewL(iEntry.FileSession()); CleanupStack::PushL(fileMan); User::LeaveIfError(fileMan->Copy(sourceStoreFilename, destinationStoreFilename, CFileMan::ERecurse|CFileMan::EOverWrite)); CleanupStack::PopAndDestroy(); // fileMan // This change entry isn't actually changing anything. // However the store contains a hidden stream created by the Message Server. // This is used to rebuild the index if it's corrupted // Calling ChangeEntry will make sure the stream is updated correctly iEntry.ChangeEntry(iEntry.Entry()); } // Move all child entries from under the remote entry to the new entry User::LeaveIfError(iEntry.SetEntry(aSourceMessage)); CMsvEntrySelection* childEntries = new (ELeave) CMsvEntrySelection; CleanupStack::PushL(childEntries); User::LeaveIfError(iEntry.GetChildren(*childEntries)); if (childEntries->Count() > 0) { if (iTransferMethod == EImPop3CopyTransfer) // If we are in disconnected mode then we really want to copy the // entries, however if we are not then we want to move them. // This is because the only reason there are entries under the // service is because the remote server does not support the TOP // command. { iStatus = KRequestPending; iEntry.CopyEntriesL(*childEntries, newEntry, iStatus); SetActive(); } else { iStatus = KRequestPending; iEntry.MoveEntriesL(*childEntries, newEntry, iStatus); SetActive(); } } else { iStatus = KRequestPending; SetActive(); TRequestStatus* status = &iStatus; User::RequestComplete(status, KErrNone); } CleanupStack::PopAndDestroy(); // childEntries CleanupStack::PopAndDestroy(2); // description, details }
EXPORT_C void CMsvTestUtils::CleanMessageFolderL() { //Kill the message server if its running _LIT(KMsvServerPattern, "!MsvServer*"); TFindProcess findprocess(KMsvServerPattern); TFullName name; if(findprocess.Next(name)==KErrNone) { RProcess process; User::LeaveIfError(process.Open(findprocess)); process.Kill(KErrCancel) ; process.Close() ; } // Wait for the server to close before trying to remove // the message folder TInt loopCount = 0; FOREVER { TFindServer find(KMsvServerPattern); if (find.Next(name) != KErrNone) break; User::After(1000000); ++loopCount; if(loopCount > 5) { User::Invariant(); } } // remove the drive from the system ini CDictionaryFileStore* store = CDictionaryFileStore::SystemLC(iFs); if (store->IsPresentL(KUidMsvMessageDriveStream)) { store->RemoveL(KUidMsvMessageDriveStream); store->CommitL(); } CleanupStack::PopAndDestroy(); // store CFileMan* fileMan = CFileMan::NewL(iFs); CleanupStack::PushL(fileMan); TParse parse; TInt error; TFileName fileName(KMsvDefaultFolder2); TChar driveChar=FileSession().GetSystemDriveChar(); TBuf<2> systemDrive = iDriveName; parse.Set(fileName, &systemDrive, NULL); error = fileMan->RmDir(parse.DriveAndPath()); error = iFs.RmDir(parse.DriveAndPath()); if (!(error==KErrNotFound||error==KErrNone || error == KErrPathNotFound)) { TPtrC driveAndPath = parse.DriveAndPath(); Printf(_L("Directory %S cannot be removed. "), &driveAndPath); Printf(_L("Please ensure directory is not in use.\n")); User::Leave(KErrAccessDenied); } //delete DBs in C:, D: and E:. TPath pathNameTemp(iDriveName); pathNameTemp.Append(KDbFileName); RSqlDatabase::Delete(pathNameTemp); pathNameTemp = _L("D:"); pathNameTemp.Append(KDbFileName); RSqlDatabase::Delete(pathNameTemp); pathNameTemp = _L("E:"); pathNameTemp.Append(KDbFileName); RSqlDatabase::Delete(pathNameTemp); // delete "StoreInit.tmp" TPath pathName(iDriveName); pathName.Append(KStoreInitFileName); iFs.Delete(pathName); CleanupStack::PopAndDestroy(fileMan); }
// --------------------------------------------------------------------------- // 2nd phase constructor // --------------------------------------------------------------------------- // void CCatalogsHttpDownloadManager::ConstructL( TBool aCleanup ) { DLTRACEIN(("")); User::LeaveIfError( iFs.Connect() ); // shared so that RFiles can be given to Download manager User::LeaveIfError( iFs.ShareProtected() ); QString DmgrUid(QString::number(KNCDEngineAppID)); iDmgr = new DownloadManager(DmgrUid); iDmgr->initialize(); iQTmgr = new CCatalogsHttpQTDownloadManager(this,iDmgr); TUid sessionId( TUid::Uid( iSessionId ) ); if ( aCleanup ) { DLTRACE(("Cleaning download manager before connecting")); TUidName client( CleanUidName( sessionId ) ); TPath path; path.Format( KCatalogsDownloadMgrPath, &client ); CFileMan* fileman = CFileMan::NewL( iFs ); CleanupStack::PushL( fileman ); DLINFO(( _L("Clearing directory: %S"), &path )); // Ignoring errors fileman->Delete( path ); CleanupStack::PopAndDestroy( fileman ); } // Connect with the download manager // If the 3rd parameter == ETrue, this session inherits downloads // from other sessions that have the same UID. TInt err = KErrNone; TInt retries = KCatalogsDlMgrConnectRetryAttempts; do { if ( err != KErrNone ) { DLERROR(("DL manager connection failed with err: %d, retry attempts left", err, retries )); // This halts the whole thread which is not nice but shouldn't // be a problem since this should occur only when the download // manager is being shutdown when we try to connect to it User::After( KCatalogsDlMgrConnectRetryInterval ); } } while ( err != KErrNone && retries-- ); if( err != KErrNone ) { DLINFO(("Leaving.. DL manager connection failed with: %d", err )); User::Leave( err ); } DLTRACE(("ConnectL ok")); iDefaultConfig = CCatalogsHttpConfig::NewL(); iNetworkManager = &CCatalogsHttpSessionManager::NetworkManagerL(); iNetworkManager->AddObserverL( *this ); // Restore downloads from previous sessions // RestoreDownloadsL(); DLTRACEOUT(("")); }
static void DoL() { RFile policyConfigFile; RFile certsFile; RFs fsSession; User::LeaveIfError(fsSession.Connect()); TInt err = policyConfigFile.Open(fsSession,_L("c:\\private\\102033E6\\security\\tmp\\old_policy.txt"), EFileStreamText | EFileRead); TBuf8<256> oldPolicy; TBuf8<256> newPolicy; TBuf8<256> oldWarningsMode; TBuf8<256> newWarningsMode; bool updateCerts = false; bool removeCerts = false; if (err == KErrNone) { policyConfigFile.Read(oldPolicy); policyConfigFile.Close(); } else { err = policyConfigFile.Open(fsSession,_L("c:\\private\\102033E6\\security\\tmp\\new_policy.txt"), EFileStreamText | EFileRead); if (err == KErrNone) { policyConfigFile.Read(newPolicy); policyConfigFile.Close(); } } err = policyConfigFile.Open(fsSession,_L("c:\\private\\102033E6\\security\\tmp\\old_warnings_mode.txt"), EFileStreamText | EFileRead); if (err == KErrNone) { policyConfigFile.Read(oldWarningsMode); policyConfigFile.Close(); } else { err = policyConfigFile.Open(fsSession,_L("c:\\private\\102033E6\\security\\tmp\\new_warnings_mode.txt"), EFileStreamText | EFileRead); if (err == KErrNone) { policyConfigFile.Read(newWarningsMode); policyConfigFile.Close(); } } err = certsFile.Open(fsSession,_L("c:\\private\\102033E6\\security\\tmp\\update_certs"), EFileStreamText | EFileRead); if (err == KErrNone) { updateCerts = true; certsFile.Close(); } err = certsFile.Open(fsSession,_L("c:\\private\\102033E6\\security\\tmp\\remove_certs"), EFileStreamText | EFileRead); if (err == KErrNone) { removeCerts = true; certsFile.Close(); } if (oldPolicy.Length() > 0) { // restore the old policy CRepository* repository = CRepository::NewLC(KCRUidJavaSecurity); HBufC* tmp = HBufC::NewLC(oldPolicy.Length()); TPtr tmpPtr(tmp->Des()); tmpPtr.Copy(oldPolicy); repository->Set(KPolicy, tmpPtr); CleanupStack::PopAndDestroy(tmp); CleanupStack::PopAndDestroy(repository); // remove the directory CFileMan* fileMan = CFileMan::NewL(fsSession); fileMan->RmDir(_L("c:\\private\\102033E6\\security\\tmp")); delete fileMan; } else if (newPolicy.Length() > 0) { // save the old policy into old_policy.txt CRepository* repository = CRepository::NewLC(KCRUidJavaSecurity); HBufC* buf = HBufC::NewLC(NCentralRepositoryConstants::KMaxUnicodeStringLength); TPtr policy(buf->Des()); repository->Get(KPolicy, policy); TInt err = policyConfigFile.Replace(fsSession,_L("c:\\private\\102033E6\\security\\tmp\\old_policy.txt"), EFileStreamText | EFileWrite); if (err == KErrNone) { HBufC8* tmp8 = HBufC8::NewLC(policy.Length()); TPtr8 tmpPtr8(tmp8->Des()); tmpPtr8.Copy(policy); policyConfigFile.Write(tmpPtr8); CleanupStack::PopAndDestroy(tmp8); policyConfigFile.Close(); // write the new policy HBufC* tmp = HBufC::NewLC(newPolicy.Length()); TPtr tmpPtr(tmp->Des()); tmpPtr.Copy(newPolicy); repository->Set(KPolicy, tmpPtr); CleanupStack::PopAndDestroy(tmp); } CleanupStack::PopAndDestroy(buf); CleanupStack::PopAndDestroy(repository); } if (oldWarningsMode.Length() > 0) { // restore the old value CRepository* repository = CRepository::NewLC(KCRUidJavaSecurity); if (oldWarningsMode == _L8("1")) { repository->Set(KWarningsMode, 1); } else { repository->Set(KWarningsMode, 2); } CleanupStack::PopAndDestroy(repository); // remove the directory CFileMan* fileMan = CFileMan::NewL(fsSession); fileMan->RmDir(_L("c:\\private\\102033E6\\security\\tmp")); delete fileMan; } else if (newWarningsMode.Length() > 0) { // save the old value CRepository* repository = CRepository::NewLC(KCRUidJavaSecurity); TInt tmp; repository->Get(KWarningsMode, tmp); TInt err = policyConfigFile.Replace(fsSession,_L("c:\\private\\102033E6\\security\\tmp\\old_warnings_mode.txt"), EFileStreamText | EFileWrite); if (err == KErrNone) { if (tmp == 1) { policyConfigFile.Write(_L8("1")); } else { policyConfigFile.Write(_L8("2")); } policyConfigFile.Close(); // write the new value if (newWarningsMode == _L8("1")) { repository->Set(KWarningsMode, 1); } else { repository->Set(KWarningsMode, 2); } } CleanupStack::PopAndDestroy(repository); } if (updateCerts || removeCerts) { if (removeCerts) { CFileMan* fileMan = CFileMan::NewL(fsSession); fileMan->RmDir(_L("c:\\private\\102033E6\\security\\tmp")); delete fileMan; } else { TInt err = certsFile.Replace(fsSession,_L("c:\\private\\102033E6\\security\\tmp\\remove_certs"), EFileStreamText | EFileWrite); certsFile.Close(); } // send the COMMS message to JavaCertStore to do the refresh CommsClientEndpoint cli_conn; if (cli_conn.connect(IPC_ADDRESS_JAVA_CAPTAIN_C) == 0) { CommsMessage s_msg; CommsMessage r_msg; s_msg.setModuleId(PLUGIN_ID_JAVA_CERT_STORE_EXTENSION_C); s_msg.setMessageId(JAVA_CERT_STORE_MSG_ID_REQUEST); s_msg << JAVA_CERT_STORE_OPERATION_REFRESH_CERTS; cli_conn.send(s_msg); } } fsSession.Close(); }
TUid CDeploymentComponentData::SetDataL(const TFileName &aData, const TDesC8& aMimeType) { RDEBUG_2("CDeploymentComponentData::SetDataL() TFileName: (%S)", &aData); _LIT(KNewPath, "c:\\private\\200267FB\\"); TUid ret(TUid::Null()); iMimeType = aMimeType.Left(KMaxMimeLength) ; RFs fs; User::LeaveIfError(fs.Connect() ); CleanupClosePushL(fs); CFileMan *fm = CFileMan::NewL(fs); CleanupStack::PushL(fm); TFileName fn; fn.Copy(iDataFileName); RDEBUG("App Mgmt before copy start"); TInt maxLength = iDataFileName.Length(); TChar charvaldot = '.'; TChar charvalslash = '\\'; TInt pos = iDataFileName.LocateReverse(charvaldot); TInt lengthDeleted = maxLength-pos; iDataFileName.Delete(pos, lengthDeleted); TInt srcpos = aData.LocateReverse(charvaldot); TBuf<15> extn(aData.Mid(srcpos)); iDataFileName.Append(extn); TFileName newfilepath; newfilepath.Copy(iDataFileName); User::LeaveIfError(fm->Move(aData,KNewPath())); TFileName oldfilepath(KNewPath()); oldfilepath.Append(aData.Mid(aData.LocateReverse(charvalslash))); User::LeaveIfError(fm->Rename(oldfilepath, newfilepath)); //User::LeaveIfError(fm->Copy(aData, fn) ); RDEBUG("App Mgmt before copy End"); if (IsSISInstallFile(aMimeType) ) { ret = ResolveUidL(fs); } CleanupStack::PopAndDestroy(fm); CleanupStack::PopAndDestroy( &fs); RDEBUG_2("CDeploymentComponentData::SetDataL() (%d)", ret.iUid); return ret; }
TUid CDeploymentComponentData::SetDataL(const TDesC8& aMimeType) { RDEBUG8_2("CDeploymentComponentData::SetDataL() aMimeType: (%S)", &aMimeType); TUid ret(TUid::Null()); iMimeType = aMimeType.Left(KMaxMimeLength); if (aMimeType.Length()!=NULL) { TUid ret(TUid::Null()); RFs fs; User::LeaveIfError(fs.Connect()); CleanupClosePushL(fs); CFileMan *fm = CFileMan::NewL(fs); CleanupStack::PushL(fm); TFileName oldfilepath; oldfilepath.Copy(iDataFileName); RDEBUG("App Mgmt before copy start"); TInt maxLength = iDataFileName.Length(); TChar charvaldot = '.'; TChar charvalslash = '\\'; //TFileName oldfilepath; TInt pos = iDataFileName.LocateReverse(charvaldot); TInt lengthDeleted = maxLength - pos; iDataFileName.Delete(pos, lengthDeleted); if (iMimeType == KSisxMimeType) { _LIT16(KExt,".sisx"); iExtn.Append(KExt); } if(iMimeType==KSisMimeType) { _LIT16(KExt,".sis"); iExtn.Append(KExt); } if(iMimeType==KPipMimeType) { _LIT16(KExt,".pip"); iExtn.Append(KExt); } if(iMimeType==KJadMIMEType) { _LIT16(KExt,".jad"); iExtn.Append(KExt); } if(iMimeType==KJarMIMEType) { _LIT16(KExt,".jar"); iExtn.Append(KExt); } if(iMimeType==KJavaMIMEType) { _LIT16(KExt,".jar"); iExtn.Append(KExt); } iDataFileName.Append(iExtn);//file name with sisx extension TFileName newfilepath; newfilepath.Copy(iDataFileName); User::LeaveIfError(fm->Rename(oldfilepath, newfilepath)); CleanupStack::PopAndDestroy(fm); CleanupStack::PopAndDestroy( &fs); //RDEBUG_2(" filename: %S", iDataFileName ); } if (IsSISInstallFile(aMimeType) ) { RFs fs; User::LeaveIfError(fs.Connect() ); CleanupClosePushL(fs); ret = ResolveUidL(fs); CleanupStack::PopAndDestroy( &fs); } RDEBUG8_2("CDeploymentComponentData::SetDataL() UID: (0x%x)", ret.iUid); return ret; }
/** * UpdateDriveStatusL() * @param TUint: The index of the said drive in preferred * drive list. */ void CMsvIndexContext::UpdateDriveStatusL(TUint aDriveIndex, TDriveState& aStoreStatus) { aStoreStatus = EMsvInvalidDriveStatus; TBool deleteStore = EFalse; TMsvPreferredDrive driveEntry; CMsvPreferredDriveList::GetDriveList()->DriveInfoL(aDriveIndex, driveEntry); // Check if the media is available in the drive. TVolumeInfo volume; if (iServer.FileSession().Volume(volume, driveEntry.driveNum) != KErrNone) { CMsvPreferredDriveList::GetDriveList()->UpdateDriveStatusL(aDriveIndex, EMsvDriveDiskNotAvailableStatus); aStoreStatus = EMsvDriveDiskNotAvailableStatus; return; } // Validate the database. The function opens the database // and check its version and returns appropriate error. TRAPD(err, CMsvDBAdapter::ValidateDatabaseL(driveEntry.driveNum)); // If no error, database is available. if(KErrNone == err) { CMsvPreferredDriveList::GetDriveList()->UpdateDriveStatusL(aDriveIndex, EMsvMessageStoreAvailableStatus); return; } // If the database is not found in the drive. if(KErrNotFound == err) { // Check if index file exists. RFile file; TParse parse; TPtrC drive(TDriveUnit(driveEntry.driveNum).Name()); parse.Set(KMsvDefaultIndexFile2, &drive, NULL); TFileName indexFileName = parse.FullName(); err = file.Open(iServer.FileSession(), indexFileName, EFileShareAny|EFileWrite); //file.Close(); // If index file exists, set drive status to NOT SUPPORTED. if(KErrNone == err) { CPermanentFileStore* fileStoreIndex = NULL; TRAPD(permError, fileStoreIndex = CPermanentFileStore::FromL(file)); if(KErrNone == permError) { // Check if the store is corrupt. If so then delete it. if (fileStoreIndex->Type() != TUidType(KPermanentFileStoreLayoutUid, KUidMsvIndexFile)) { deleteStore = ETrue; } } // There was an error in getting a permanent filestore object. // Mark the message store for deletion. else { deleteStore = ETrue; } delete fileStoreIndex; //If message store is corrupted, wipe it. if(deleteStore) { TFileName mail2Folder = parse.DriveAndPath(); CFileMan* fileMan = CFileMan::NewL(iServer.FileSession()); // Remove the readonly attribute.. (void)fileMan->Attribs(mail2Folder, 0, KEntryAttReadOnly, TTime(0), CFileMan::ERecurse); CleanupStack::PushL(fileMan); //Check if the mailfolder exists.. TBool mail2FolderExists = BaflUtils::FileExists(iServer.FileSession(), mail2Folder); if(mail2FolderExists) { // Remove old message store if exists.. User::LeaveIfError(fileMan->RmDir(mail2Folder)); } CleanupStack::PopAndDestroy(fileMan); CMsvPreferredDriveList::GetDriveList()->UpdateDriveStatusL(aDriveIndex, EMsvMessageStoreUnavailableStatus); aStoreStatus = EMsvMessageStoreCorruptStatus; // Create store delete file in the respective drive. CreateStoreDeleteFile(driveEntry.driveNum); } //Else only set status as EMsvMessageStoreNotSupportedStatus. else { CMsvPreferredDriveList::GetDriveList()->UpdateDriveStatusL(aDriveIndex, EMsvMessageStoreNotSupportedStatus); aStoreStatus = EMsvMessageStoreNotSupportedStatus; } file.Close(); return; } // If index file does not exists, set drive status to STORE UNAVAILABLE. if((KErrNotFound == err) || (KErrPathNotFound == err)) { CMsvPreferredDriveList::GetDriveList()->UpdateDriveStatusL(aDriveIndex, EMsvMessageStoreUnavailableStatus); aStoreStatus = EMsvMessageStoreUnavailableStatus; return; } User::Leave(err); } //If a database exists, but is corrupt. if( (KSqlErrCorrupt == err) || (KSqlErrNotDb == err) ) { // If the database is corrupt, delete // the database and old message store. // Delete the database. TParse parse; TPtrC drive(TDriveUnit(driveEntry.driveNum).Name()); parse.Set(KDBFileName, &drive, NULL); TFileName dBFile = parse.FullName(); RSqlDatabase::Delete(dBFile); // Delete the message store. //ISSUE Can we use ResetAndCreateNewMailStore()? parse.Set(KMsvDefaultIndexFile2, &drive, NULL); TFileName mail2Folder = parse.DriveAndPath(); CFileMan* fileMan = CFileMan::NewL(iServer.FileSession()); // Remove the readonly attribute.. (void)fileMan->Attribs(mail2Folder, 0, KEntryAttReadOnly, TTime(0), CFileMan::ERecurse); CleanupStack::PushL(fileMan); //Check if the mailfolder exists.. TBool mail2FolderExists = BaflUtils::FileExists(iServer.FileSession(), mail2Folder); if( mail2FolderExists) { // Remove old message store if exists.. User::LeaveIfError(fileMan->RmDir(mail2Folder)); } CleanupStack::PopAndDestroy(fileMan); // Update the drive status. CMsvPreferredDriveList::GetDriveList()->UpdateDriveStatusL(aDriveIndex, EMsvMessageStoreUnavailableStatus); aStoreStatus = EMsvMessageStoreCorruptStatus; // Create store delete file in the respective drive. CreateStoreDeleteFile(driveEntry.driveNum); return; } //If the database version is not supported. if(KErrNotSupported == err) { // If the drive as old version of database. CMsvPreferredDriveList::GetDriveList()->UpdateDriveStatusL(aDriveIndex, EMsvMessageStoreNotSupportedStatus); aStoreStatus = EMsvMessageStoreNotSupportedStatus; return; } // Do not return DB error. if(err <= KSqlErrGeneral) { // If DB Error, return KErrGeneral. User::LeaveIfError(KErrGeneral); } else { User::LeaveIfError(err); } }
/** @SYMTestCaseID SYSLIB-SQL-UT-4060 @SYMTestCaseDesc Private database and compaction configuration test. The test verifies that a private database can be created using auto, background or manual compaction mode and that the compaction mode does not chage after reopening the database. The test also verifies that if the database is legacy, read-only, then the compaction mode is auto. The test also verifies that if the database is legacy, r/w, then the compaction mode will be changed from auto to background. @SYMTestPriority Medium @SYMTestActions Private database and compaction configuration test. @SYMTestExpectedResults Test must not fail @SYMREQ REQ10273 REQ10274 REQ10400 REQ10402 */ void CompactConfigTest5L() { //Create a private test database with "auto" compaction mode _LIT8(KConfigStr1, "encoding=utf-8;compaction=auto"); TInt err = TheDb.Create(KTestPrivDbName, &KConfigStr1); TEST2(err, KErrNone); //Check the vacuum mode. The SQLite vacuum mode should be "auto" TSqlScalarFullSelectQuery scalarQuery(TheDb); TInt compact = scalarQuery.SelectIntL(_L("PRAGMA auto_vacuum")); TEST2(compact, KAutoVacuum); TheDb.Close(); //Close and open the database again. The SQLite vacuum mode should be "auto". err = TheDb.Open(KTestPrivDbName); TEST2(err, KErrNone); scalarQuery.SetDatabase(TheDb); compact = scalarQuery.SelectIntL(_L("PRAGMA auto_vacuum")); TEST2(compact, KAutoVacuum); TheDb.Close(); //Close and open the database again with a config string with "background" compaction mode. //The SQLite vacuum mode should stay unchanged. _LIT8(KConfigStr2, "compaction=background"); err = TheDb.Open(KTestPrivDbName, &KConfigStr2); TEST2(err, KErrNone); scalarQuery.SetDatabase(TheDb); compact = scalarQuery.SelectIntL(_L("PRAGMA auto_vacuum")); TEST2(compact, KAutoVacuum); TheDb.Close(); //Delete database err = RSqlDatabase::Delete(KTestPrivDbName); TEST2(err, KErrNone); //Create a private test database - no config string err = TheDb.Create(KTestPrivDbName); TEST2(err, KErrNone); //Check the vacuum mode. The SQLite vacuum mode should be KSqlDefaultVacuum scalarQuery.SetDatabase(TheDb); compact = scalarQuery.SelectIntL(_L("PRAGMA auto_vacuum")); TEST2(compact, KSqlDefaultVacuum); TheDb.Close(); //Close and open the database again. The SQLite vacuum mode should be KSqlDefaultVacuum. err = TheDb.Open(KTestPrivDbName); TEST2(err, KErrNone); scalarQuery.SetDatabase(TheDb); compact = scalarQuery.SelectIntL(_L("PRAGMA auto_vacuum")); TEST2(compact, KSqlDefaultVacuum); TheDb.Close(); //Close and open the database again with a config string with "auto" compaction mode. //The SQLite vacuum mode should stay unchanged. err = TheDb.Open(KTestPrivDbName, &KConfigStr1); TEST2(err, KErrNone); scalarQuery.SetDatabase(TheDb); compact = scalarQuery.SelectIntL(_L("PRAGMA auto_vacuum")); TEST2(compact, KSqlDefaultVacuum); TheDb.Close(); //Delete database err = RSqlDatabase::Delete(KTestPrivDbName); TEST2(err, KErrNone); //Open an existing private database that is read-only (on drive Z:) err = TheDb.Open(KTestPrivDbNameZ, &KConfigStr1); TEST2(err, KErrNone); //Check the vacuum mode. The SQLite compact mode should be "auto" (this is an old database (pre-"background compact" era)) scalarQuery.SetDatabase(TheDb); compact = scalarQuery.SelectIntL(_L("PRAGMA auto_vacuum")); TEST2(compact, KAutoVacuum); TheDb.Close(); //Open the same database after copying it to drive C: (r/w private database). The compaction mode should change from auto to background. RFs fs; err = fs.Connect(); TEST2(err, KErrNone); CFileMan* fm = CFileMan::NewL(fs); TEST(fm != NULL); err = fm->Copy(KTestPrivDbNameZ, KTestPrivDbNameC); TEST2(err, KErrNone); //"Copy" operation executed without errors. Now it is a time to turn off the read-only //flag of the target file (which may be on if the source file is on a read-only drive) err = fs.SetAtt(KTestPrivDbNameC, 0, KEntryAttReadOnly); TEST2(err, KErrNone); delete fm; fs.Close(); err = TheDb.Open(KTestPrivDbNameC); TEST2(err, KErrNone); scalarQuery.SetDatabase(TheDb); compact = scalarQuery.SelectIntL(_L("PRAGMA auto_vacuum")); TEST2(compact, KSqlDefaultVacuum); TheDb.Close(); (void)RSqlDatabase::Delete(KTestPrivDbNameC); }
LOCAL_C void DoOOMTestsL() { TheTest.Next (_L (" @SYMTestCaseID:SYSLIB-CENTRALREPOSITORY-LEGACY-T_OOMCENREP-0001 Starting CENREPSRV OOM Test ")); RFs fs; User::LeaveIfError(fs.Connect()); CleanupClosePushL(fs); CFileMan* fm = CFileMan::NewL(fs); CleanupStack::PushL(fm); //Clear any files in the persist directory CleanupCDriveL(); //First Testuid=KTestRepositoryUid KCurrentTestUid=KTestRepositoryUid; DoOOMTestL(&CenrepSrvOOMTest::GetL,_L("Get Basic Test"),EFalse); DoOOMTestL(&CenrepSrvOOMTest::FindL,_L("FindL Basic Test"),EFalse); DoOOMTestL(&CenrepSrvOOMTest::NotifyL,_L("NotifyL Basic Test"),EFalse); DoOOMTestL(&CenrepSrvOOMTest::ResetL,_L("ResetL Basic Test"),EFalse); // Save file without timestamp User::LeaveIfError(fm->Copy(KPersistsFile, KPersistsFileNoUpgrade)); DoOOMTestL(&CenrepSrvOOMTest::SetL,_L("SetL Basic Test"),EFalse); DoOOMTestL(&CenrepSrvOOMTest::CreateL,_L("CreateL Basic Test"),EFalse); DoOOMTestL(&CenrepSrvOOMTest::DeleteL,_L("DeleteL Basic Test"),EFalse); DoOOMTestL(&CenrepSrvOOMTest::MoveL,_L("MoveL Basic Test"),EFalse); //Clear any files in the persist directory CleanupCDriveL(); // Simulate response to SWI rom-upgrade and downgrade events DoOOMSwiTestL(&CenrepSwiOOMTest::UpgradeROMRev1L,_L("SwiUpgradeROMRev1L Basic Test"),EFalse); // Save file with timestamp User::LeaveIfError(fm->Copy(KPersistsFile, KPersistsFileUpgraded)); DoOOMSwiTestL(&CenrepSwiOOMTest::UpgradeROMRev2L,_L("SwiUpgradeROMRev2L Basic Test"),EFalse); DoOOMSwiTestL(&CenrepSwiOOMTest::UninstallROMUpgradeL,_L("SwiUninstallROMUpgradeL Basic Test"),EFalse); // Simulate response to SWI new rep install/uninstall event events DoOOMSwiTestL(&CenrepSwiOOMTest::InstallL,_L("SwiInstallL Basic Test"),EFalse); DoOOMSwiTestL(&CenrepSwiOOMTest::UpgradeInstallL,_L("SwiUpgradeInstallL Basic Test"),EFalse); DoOOMSwiTestL(&CenrepSwiOOMTest::UninstallL,_L("SwiUninstallL Basic Test"),EFalse); // Simulate SWI events before server startup DoOOMNoServReposL(&StartupUpgradeL, _L("Startup Upgrade Basic Test"), EFalse); DoOOMNoServReposL(&StartupDowngradeL, _L("Startup Downgrade Basic Test"), EFalse); DoOOMNoServReposL(&StartupUninstallL,_L("Startup Uninstall Basic Test"), EFalse); //OOM Test aOOMMode=ETrue DoOOMNoServReposL(&CreateDeleteL, _L("Create Delete OOM Test"),ETrue); DoOOMNoServReposL(&CreateDeleteCorruptL, _L("Create Delete Corrupt OOM Test"),ETrue); DoOOMTestL(&CenrepSrvOOMTest::GetL,_L("Get OOM Test"),ETrue); DoOOMTestL(&CenrepSrvOOMTest::FindL,_L("FindL OOM Test"),ETrue); DoOOMTestL(&CenrepSrvOOMTest::NotifyL,_L("NotifyL OOM Test"),ETrue); DoOOMTestL(&CenrepSrvOOMTest::ResetL,_L("ResetL OOM Test"),ETrue); DoOOMTestL(&CenrepSrvOOMTest::SetL,_L("SetL OOM Test"),ETrue); DoOOMTestL(&CenrepSrvOOMTest::CreateL,_L("CreateL OOM Test"),ETrue); DoOOMTestL(&CenrepSrvOOMTest::DeleteL,_L("DeleteL OOM Test"),ETrue); DoOOMTestL(&CenrepSrvOOMTest::MoveL,_L("MoveL OOM Test"),ETrue); //Clear any files in the persist directory CleanupCDriveL(); DoOOMSwiTestL(&CenrepSwiOOMTest::UpgradeROMRev1L,_L("SwiUpgradeROMRev1L OOM Test"),ETrue); DoOOMSwiTestL(&CenrepSwiOOMTest::UpgradeROMRev2L,_L("SwiUpgradeROMRev2L OOM Test"),ETrue); DoOOMSwiTestL(&CenrepSwiOOMTest::UninstallROMUpgradeL,_L("SwiUninstallROMUpgradeL OOM Test"),ETrue); DoOOMSwiTestL(&CenrepSwiOOMTest::InstallL,_L("SwiInstallL OOM Test"),ETrue); DoOOMSwiTestL(&CenrepSwiOOMTest::UpgradeInstallL,_L("SwiUpgradeInstallL OOM Test"),ETrue); DoOOMSwiTestL(&CenrepSwiOOMTest::UninstallL,_L("SwiUninstallL OOM Test"),ETrue); DoOOMNoServReposL(&StartupUpgradeL, _L("Startup Upgrade OOM Test"), ETrue); DoOOMNoServReposL(&StartupDowngradeL, _L("Startup Downgrade OOM Test"), ETrue); DoOOMNoServReposL(&StartupUninstallL, _L("Startup Uninstall OOM Test"), ETrue); #ifdef SYMBIAN_CENTREP_SUPPORT_MULTIROFS DoPersistedVersionCheckingL(); DoOOMMultiRofsTestL(); #endif // Delete files from bur dir User::LeaveIfError(fm->Attribs(KPersistsFileNoUpgrade,0,KEntryAttReadOnly,TTime(0))); TInt err=fs.Delete(KPersistsFileNoUpgrade); if((err!=KErrNone)&&(err!=KErrNotFound)) User::Leave(err); User::LeaveIfError(fm->Attribs(KPersistsFileUpgraded,0,KEntryAttReadOnly,TTime(0))); err=fs.Delete(KPersistsFileUpgraded); if((err!=KErrNone)&&(err!=KErrNotFound)) User::Leave(err); //Clear any files in the persist directory CleanupCDriveL(); CleanupStack::PopAndDestroy (2); // fs and fm }