// --------------------------------------------------------- // CMailToHandler::FieldStart() // --------------------------------------------------------- // TInt CMailToHandler::FieldStart(const TDesC& aHeader) { CLOG_ENTERFN( "CMailToHandler::FieldStart()" ); TPtrC path = iParsedUrl->Des(); TInt retVal = path.Length(); /* find the starting position of the specific filed */ if( IsHeader( aHeader ) ) { retVal = path.FindF( aHeader ) + aHeader.Length(); } CLOG_LEAVEFN( "CMailToHandler::FieldStart()" ); return retVal; }
/** Search for a node by directory path, start from children of aNodeToStart but do not include aNodeToStart. @param aPath the path as the key to search in the tree @param aNodeToStart the node whose children to start with @param aNodeFound in return, the node found @param aDirPos the location of the directory @return KErrNone if a node found KErrNotFound if no node is found */ TInt CLeafDirTree::DoSearch(const TDesC& aPath, CLeafDirTreeNode* aNodeToStart, CLeafDirTreeNode*& aNodeFound, TLeafDirData& aLeafDirData) { RPointerArray<CLeafDirTreeNode> currentLevel = aNodeToStart->Children(); TInt currentPos = currentLevel.Count() - 1; // Current path in search TPtrC currentPath; currentPath.Set(aPath); while (currentLevel.Count() > 0 && currentPos >= 0) { CLeafDirTreeNode* currentNode = currentLevel[currentPos]; TPtrC currentNodePath; currentNodePath.Set(currentNode->Path()); TInt foundPos = currentPath.FindF(currentNodePath); // If current child's path is part of the searching path, // go to next level // E.g.: current child's path = "1\2\3\", searching path = "1\2\3\5\". if (foundPos == 0 && currentNodePath.Length() < currentPath.Length()) { currentPath.Set(currentPath.Mid(currentNodePath.Length())); currentLevel = currentNode->Children(); currentPos = currentLevel.Count() - 1; continue; } // If current child's path matches current searching path, // check the node type. else if (foundPos == 0 && currentNodePath.Length() == currentPath.Length()) { if (currentNode->IsPureIntermediary()) // If found is 'pure intermediary', it is not cached. { return KErrNotFound; } // Otherwise, we have got a cache hit! MakeMostRecentlyUsed(currentNode); aNodeFound = currentNode; aLeafDirData = currentNode->LeafDirData(); return KErrNone; } // else, go through current level currentPos--; } // If there is no child or we have not found any matching node, // return KErrNotFound return KErrNotFound; }
// --------------------------------------------------------- // CMailToHandler::IsHeader() // --------------------------------------------------------- // TBool CMailToHandler::IsHeader(const TDesC& aHeader) { CLOG_ENTERFN( "CMailToHandler::IsHeader()" ); TBool retVal = EFalse; TPtrC path = iParsedUrl->Des(); /* is the field in the mailto sheme */ if( KErrNotFound != path.FindF( aHeader ) ) { retVal = ETrue; } CLOG_LEAVEFN( "CMailToHandler::IsHeader()" ); return retVal; }
TInt CIniData::StepToNextBlock() /** Locates the next available block of data within a section @return ETrue if successful or EFalse */ { if (BlockState != E_UNKNOWN) { // get unscanned portion of the section TPtrC temp = section.Mid(scanStart); // find the start of the next block if (BlockState == E_SET) { blockStart = temp.FindF(TPtrC(BEGIN_SET)); blockEnd = temp.FindF(TPtrC(END_SET)); } else if (BlockState == E_TEMPLATE) { blockStart = temp.FindF(TPtrC(BEGIN_TEMPLATE)); blockEnd = temp.FindF(TPtrC(END_TEMPLATE)); } else if (BlockState == E_ADD) { blockStart = temp.FindF(TPtrC(BEGIN_ADD)); blockEnd = temp.FindF(TPtrC(END_ADD)); } if (blockStart != KErrNotFound && blockEnd != KErrNotFound) { // set the start point for the next block search scanStart += blockEnd; scanStart++; // set the actual block to work with blockEnd -= blockStart; TPtrC tempBlock = temp.Mid(blockStart,blockEnd); block.Set((unsigned short *)tempBlock.Ptr(), tempBlock.Length(), tempBlock.Size()); return ETrue; } } return EFalse; }
/** @SYMTestCaseID PDS-SQL-UT-4224 @SYMTestCaseDesc CSqlServer::GetBackUpListL() functional test @SYMTestPriority High @SYMTestActions Calls CSqlServer::GetBackUpListL() and tests the output, when the drive is read-only, when there is a sub-directory which name is matching the search pattern. @SYMTestExpectedResults Test must not fail */ void GetBackupListFunctionalTest() { CSqlServer* server = NULL; TRAPD(err, server = CreateSqlServerL()); TEST2(err, KErrNone); //Case 1: database with specified uid bellow do exist (on drive C). There will be one subdirectory matching the search pattern. const TDriveNumber KTestDrvNum1 = EDriveC; const TUid KDbUid = {0x98765432}; TDriveUnit testDrive(KTestDrvNum1); TDriveName testDriveName = testDrive.Name(); testDriveName.LowerCase(); //One test directory will be created, which name will be matching the search pattern. //The directory name should not be included in the list with the file names. TFileName testFileName; err = server->Fs().PrivatePath(testFileName); TEST2(err, KErrNone); testFileName.Append(KDbUid.Name()); _LIT(KTestPath, "t_startup\\"); testFileName.Append(KTestPath); testFileName.Append(_L("t_startup.db")); TParse parse; err = parse.Set(testFileName, &testDriveName, 0); TEST2(err, KErrNone); err = server->Fs().MkDirAll(parse.FullName()); TEST(err == KErrNone || err == KErrAlreadyExists); // RArray<HBufC*> files; TRAP(err, server->GetBackUpListL(KDbUid, KTestDrvNum1, files)); TEST2(err, KErrNone); TInt fileCnt = files.Count(); for(TInt i=0;i<fileCnt;++i) { TPtrC fname = files[i]->Des(); TheTest.Printf(_L("Db: %S\r\n"), &fname); TEST(fname.FindF(KTestPath) < 0); //The name should include the full path + the drive err = parse.Set(fname, 0, 0); TEST2(err, KErrNone); TEST(parse.DrivePresent()); TEST(parse.PathPresent()); TDriveName driveName(parse.Drive()); driveName.LowerCase(); delete files[i]; TEST(driveName == testDriveName); } files.Close(); //Case 2: drive Z:. No files should be returned. const TDriveNumber KTestDrvNum2 = EDriveZ; TRAP(err, server->GetBackUpListL(KDbUid, KTestDrvNum2, files)); TEST2(err, KErrNone); fileCnt = files.Count(); TEST2(fileCnt, 0); //Case 3: drive A:. The drive does not exist. No files should be returned. const TDriveNumber KTestDrvNum3 = EDriveA; TRAP(err, server->GetBackUpListL(KDbUid, KTestDrvNum3, files)); TheTest.Printf(_L("Drive %d, err=%d\r\n"), KTestDrvNum3, err); fileCnt = files.Count(); TEST2(fileCnt, 0); // delete server; }
// ----------------------------------------------------------------------------- // CLibxml2Tester::TestUseExternalDataL // test deserialize from file, using external data // (other items were commented in a header). // ----------------------------------------------------------------------------- // TInt CLibxml2Tester::TestUseExternalDataInfosetL(CStifItemParser& aItem) { TInt err; TPtrC pDeserializerType; aItem.GetNextString( pDeserializerType ); TPtrC pInputFile; aItem.GetNextString( pInputFile ); TPtrC pBinary; aItem.GetNextString( pBinary ); TPtrC pFile; aItem.GetNextString(pFile); TPtrC pOutputFile; aItem.GetNextString( pOutputFile ); TPtrC pDirtyReturn; aItem.GetNextString( pDirtyReturn ); TLex inputNum (pDirtyReturn); TInt dirtyReturn; inputNum.Val(dirtyReturn); TInt nContainers = 3; RFile fileHandle; RFs aRFs; aRFs.Connect(); CleanupClosePushL( aRFs ); SetupDocumentL(); HBufC8* binbuf = ReadFileToBufferL(pBinary); CleanupStack::PushL(binbuf); TBufC<100> chunkName(_L("ChunkContainer") ); TInt size = 2000; TInt maxSize = 10000; TInt offset = 0; TInt binarySize = CID_2().Length(); // TBool isReadOnly = EFalse; RChunk chunk; chunk.CreateGlobal(chunkName, size, maxSize); CleanupClosePushL(chunk); RFile fp; User::LeaveIfError( fp.Open(aRFs, pFile, EFileRead) ); CleanupClosePushL(fp); TXmlEngBinaryContainer bincont = iDoc.CreateBinaryContainerL(CID_1(), binbuf->Des()); TXmlEngChunkContainer chunkcont = iDoc.CreateChunkContainerL(CID_2(), chunk, offset, binarySize); TXmlEngFileContainer filecont = iDoc.CreateFileContainerL(CID_3(), fp); iDoc.DocumentElement().AppendChildL(bincont); iDoc.DocumentElement().AppendChildL(chunkcont); iDoc.DocumentElement().AppendChildL(filecont); User::LeaveIfError( fileHandle.Replace( aRFs, pOutputFile, EFileStream | EFileWrite | EFileShareExclusive)); CleanupClosePushL( fileHandle ); CTestHandler* testHandle = CTestHandler::NewLC( fileHandle ); RArray<TXmlEngDataContainer> list; CleanupClosePushL(list); //// iDoc.GetDataContainerList(list); CXmlEngDeserializer* des; if( pDeserializerType.FindF( XOP ) != KErrNotFound ) { des = CXmlEngDeserializer::NewL( *testHandle, EDeserializerXOP ); CleanupStack::PushL( des ); des->SetInputFileL( pInputFile ); des->UseExternalDataL( list ); TRAP(err,des->DeserializeL()); } else if( pDeserializerType.FindF( INFOSET ) != KErrNotFound ) { des = CXmlEngDeserializer::NewL( *testHandle, EDeserializerXOPInfoset ); CleanupStack::PushL( des ); des->SetInputFileL( pInputFile ); des->UseExternalDataL( list ); TRAP(err,des->DeserializeL()); } if(list.Count() != nContainers) User::Leave(KErrGeneral); CleanupStack::PopAndDestroy( 8 ); if ( err == dirtyReturn ) return KErrNone; else return err; }
// ----------------------------------------------------------------------------- // CLibxml2Tester::DeserializeL // deserialize from file, using setter SetInputFileL // (other items were commented in a header). // ----------------------------------------------------------------------------- // TInt CLibxml2Tester::DeserializeInfosetL( CStifItemParser& aItem) { TInt err; TPtrC pDeserializerType; aItem.GetNextString( pDeserializerType ); TPtrC pInputFile; aItem.GetNextString( pInputFile ); TPtrC pOutputFile; aItem.GetNextString( pOutputFile ); TPtrC pDirtyReturn; aItem.GetNextString( pDirtyReturn ); TLex inputNum (pDirtyReturn); TInt dirtyReturn; inputNum.Val(dirtyReturn); iDoc = parser.ParseFileL(pInputFile); TBufC<100> chunkName(_L("ChunkContainer") ); TInt size = 2000; TInt maxSize = 10000; TInt offset = 0; TInt binarySize = CID_1().Length(); // TBool isReadOnly = EFalse; RChunk chunk; chunk.CreateGlobal(chunkName, size, maxSize); CleanupClosePushL(chunk); TBuf8<32> contbuff = _L8("binary container some data..."); RFs aRFs; aRFs.Connect(); CleanupClosePushL( aRFs ); RFile fp; User::LeaveIfError( fp.Open(aRFs, _L("c:\\testing\\data\\xmleng\\efute\\input\\containers\\petit.jpg"), EFileRead) ); CleanupClosePushL(fp); TXmlEngBinaryContainer bincont = iDoc.CreateBinaryContainerL(CID_1(), contbuff); TXmlEngChunkContainer chunkcont = iDoc.CreateChunkContainerL(CID_2(), chunk, offset, binarySize); TXmlEngFileContainer filecont = iDoc.CreateFileContainerL(CID_3(), fp); iDoc.DocumentElement().AppendChildL(bincont); iDoc.DocumentElement().AppendChildL(chunkcont); iDoc.DocumentElement().AppendChildL(filecont); RArray<TXmlEngDataContainer> list; CleanupClosePushL(list); iDoc.GetDataContainerList(list); RFile fileHandle; RFs aRFs_2; aRFs_2.Connect(); CleanupClosePushL( aRFs_2 ); User::LeaveIfError( fileHandle.Replace( aRFs_2, pOutputFile, EFileStream | EFileWrite | EFileShareExclusive)); CleanupClosePushL( fileHandle ); CTestHandler* testHandle = CTestHandler::NewLC( fileHandle ); if( pDeserializerType.FindF( DEFAULT ) != KErrNotFound ) { CXmlEngDeserializer* des = CXmlEngDeserializer::NewL( *testHandle, EDeserializerDefault ); CleanupStack::PushL( des ); des->SetInputFileL( pInputFile ); TRAP(err,des->DeserializeL()); } else if( pDeserializerType.FindF( XOP ) != KErrNotFound ) { CXmlEngDeserializer* des = CXmlEngDeserializer::NewL( *testHandle, EDeserializerXOP ); CleanupStack::PushL( des ); des->SetInputFileL( pInputFile ); TRAP(err,des->DeserializeL()); } else if( pDeserializerType.FindF( INFOSET ) != KErrNotFound ) { CXmlEngDeserializer* des = CXmlEngDeserializer::NewL( *testHandle, EDeserializerXOPInfoset ); CleanupStack::PushL( des ); des->SetInputFileL( pInputFile ); des->UseExternalDataL( list ); TRAP(err,des->DeserializeL()); } else if( pDeserializerType.FindF( GZIP ) != KErrNotFound ) { CXmlEngDeserializer* des = CXmlEngDeserializer::NewL( *testHandle, EDeserializerGZip ); CleanupStack::PushL( des ); des->SetInputFileL( pInputFile ); TRAP(err,des->DeserializeL()); } CleanupStack::PopAndDestroy( 8 ); if ( err == dirtyReturn ) return KErrNone; else return err; }
/** Implementation of the insertion algorithm @param aNodeToStart the node whose children to start with @param aPath the path of the new node to be inserted @param aDirPos the position of the new node to be inserted @param aNodeInserted in return, the node that has been successfully inserted */ void CLeafDirTree::DoInsertL(CLeafDirTreeNode* aNodeToStart, const TDesC& aPath, const TLeafDirData& aLeafDirData, CLeafDirTreeNode*& aNodeInserted) { CLeafDirTreeNode* currentParent = aNodeToStart; TInt foundPos = 0; RPointerArray<CLeafDirTreeNode> currentLevel = aNodeToStart->Children(); TInt currentPos = currentLevel.Count() - 1; TPtrC currentPath; currentPath.Set(aPath); while (currentLevel.Count() > 0 && currentPos >= 0) { CLeafDirTreeNode* currentNode = currentLevel[currentPos]; TPtrC currentNodePath; currentNodePath.Set(currentNode->Path()); // If current node is contained by aPath. // E.g.: current node = "1\2\3\", currentPath = "1\2\3\5\" // In this case, we need to go to next level, // discard logged position (currentPos) in this level as we don't need to come back. foundPos = currentPath.FindF(currentNodePath); if (foundPos == 0 && currentNodePath.Length() < currentPath.Length()) { currentParent = currentNode; currentLevel = currentNode->Children(); currentPos = currentLevel.Count() - 1; currentPath.Set(currentPath.Mid(currentNodePath.Length())); continue; } // If current node's path contains aPath // E.g.: current node = "1\2\3\4\", currentPath = "1\2\3\" // We need to split current node to two nodes and return. foundPos = currentNodePath.FindF(currentPath); if (foundPos == 0 && currentNodePath.Length() > currentPath.Length()) { CLeafDirTreeNode* newNode = CLeafDirTreeNode::NewL(this, currentPath, aLeafDirData, CLeafDirTreeNode::ELeafIntermediary); currentParent->MakeItChildL(newNode); TPtrC restPath; restPath.Set(currentNodePath.Mid(currentPath.Length())); currentNode->SetPathL(restPath); currentParent->RemoveChild(currentNode); newNode->MakeItChildL(currentNode); AddOntoLruL(newNode); aNodeInserted = newNode; return; } // If current node's path equals aPath, // change the node type if it is necessary if (foundPos == 0 && currentNodePath.Length() == currentPath.Length()) { // Check node type, if already cached, update Lru list and return. if (currentNode->IsLeaf() || currentNode->IsLeafIntermediary()) { currentNode->SetLeafDirData(aLeafDirData); aNodeInserted = currentNode; MakeMostRecentlyUsed(currentNode); return; } // If it has not been cached yet, i.e., it is a 'pure intermediary' node, // cache the node and put it onto Lru list else if(currentNode->IsPureIntermediary()) { currentNode->SetLeafDirData(aLeafDirData); currentNode->SetType(CLeafDirTreeNode::ELeafIntermediary); AddOntoLruL(currentNode); aNodeInserted = currentNode; return; } } // If none of above is the case (i.e. haven't found exact match or paths // are not contained by each other), we need to find the first common part // between each child and aPath to share path data. foundPos = FindLongestCommonPath(currentNodePath, currentPath); // If a common part of path is found, we need to create a pure intermediary node to share // the common part of path data, and create a new leaf node for the target path. if (foundPos > 0) { TPtrC commonPath; commonPath.Set(currentNodePath.Left(foundPos + 1)); currentNodePath.Set(currentNodePath.Mid(foundPos + 1)); TPtrC newLeafPath; newLeafPath.Set(currentPath.Mid(foundPos + 1)); // Add new pureintermediary node, set it as child of current parent TLeafDirData dummyPos(0); CLeafDirTreeNode* newPureIntermediaryNode = CLeafDirTreeNode::NewL(this, commonPath, dummyPos, CLeafDirTreeNode::EPureIntermediary); currentParent->MakeItChildL(newPureIntermediaryNode); // Remove current child from aNodeToStart, do not need to change // node type of aNodeToStart currentParent->RemoveChild(currentNode); // Modify current pathData, make it child of new node newPureIntermediaryNode->MakeItChildL(currentNode); currentNode->SetPathL(currentNodePath); // Add new leaf node as a child of the new pure intermediary node CLeafDirTreeNode* newLeafNode = CLeafDirTreeNode::NewL(this, newLeafPath, aLeafDirData, CLeafDirTreeNode::ELeaf); newPureIntermediaryNode->MakeItChildL(newLeafNode); aNodeInserted = newLeafNode; AddOntoLruL(newLeafNode); return; } // Otherwise, move on within this level. currentPos--; } // No match case found, add a new node straight on at current level CLeafDirTreeNode* newNode = CLeafDirTreeNode::NewL(this, currentPath, aLeafDirData, CLeafDirTreeNode::ELeaf); if (currentParent->IsLeaf()) // might be the root node { currentParent->SetType(CLeafDirTreeNode::ELeafIntermediary); } currentParent->MakeItChildL(newNode); aNodeInserted = newNode; AddOntoLruL(newNode); }
TVerdict CForceRemove::doTestStepL() { #ifndef SYMBIAN_UNIVERSAL_INSTALL_FRAMEWORK // Wait up to 30 seconds to ensure both SWIS and the sisregistry server // have shut down _LIT(KSisRegistryServerName, "!SisRegistryServer"); _LIT(KInstallServerName, "!InstallServer"); TInt delaytime = 30; while (delaytime-- > 0) { TFullName serverName; TFindServer find(KInstallServerName); if (KErrNotFound == find.Next(serverName)) { find.Find(KSisRegistryServerName); if (KErrNotFound == find.Next(serverName)) { break; } } User::After(1000000); // wait a second until the next test } #endif // SYMBIAN_UNIVERSAL_INSTALL_FRAMEWORK TPtrC name; RTestUtilSessionSwi testutil; User::LeaveIfError(testutil.Connect()); CleanupClosePushL(testutil); // If file deletion fails we'll try moving the file to a temp directory // for another process to clean up later. TTime currentTime; currentTime.UniversalTime(); _LIT(KTempPathFormat, "\\temp\\%Lu"); TDriveUnit sysDrive (RFs::GetSystemDrive()); TBuf<128> tempPathFormat(sysDrive.Name()); tempPathFormat.Append(KTempPathFormat); TFileName targetPath; targetPath.Format(tempPathFormat, currentTime.Int64()); _LIT(KNumFiles, "numfiles"); #ifdef SYMBIAN_UNIVERSAL_INSTALL_FRAMEWORK RArray<TUint> removeUids; CleanupClosePushL(removeUids); #endif TInt num(0); GetIntFromConfig(ConfigSection(), KNumFiles, num); // Get the file names and use testutil to remove them for (TInt i = 0; i < num; ++i) { _LIT(KFile, "file"); TBuf<32> key(KFile); key.AppendNum(i); if (!GetStringFromConfig(ConfigSection(), key, name)) continue; INFO_PRINTF2(_L("ForceRemove - trying to delete file %S"), &name); TInt err = testutil.Delete(name); if (err != KErrNone && err != KErrNotFound && err != KErrPathNotFound) { INFO_PRINTF3(_L("RTestUtilSessionSwi::Delete(%S) returned %d, attempting move instead."), &name, err); TFileName source(name); TParsePtr parse(source); TFileName dest(targetPath); dest.Append(parse.Path()); if (parse.DrivePresent()) { dest[0] = source[0]; } testutil.MkDirAll(dest); dest.Append(parse.NameAndExt()); err = testutil.Move(source, dest); if (err != KErrNone) { INFO_PRINTF4(_L("Attempt to move from %S to %S returned %d"), &source, &dest, err); } } #ifdef SYMBIAN_UNIVERSAL_INSTALL_FRAMEWORK _LIT(KRegistryPath, "\\sys\\install\\sisregistry\\"); if (name.FindF(KRegistryPath) == KErrNotFound) continue; // Extract the uid and add it to our list TInt slashPos = name.LocateReverse('\\'); TPtrC ptrUid = name.Mid(slashPos + 1); if (ptrUid.Length() != 8) continue; TUint uid = 0; TLex lex(ptrUid); if (lex.Val(uid, EHex) == KErrNone) { removeUids.InsertInOrder(uid); // Will not allow duplicates } #endif } #ifdef SYMBIAN_UNIVERSAL_INSTALL_FRAMEWORK // Use the sisregistry folder uid to remove the package entries from SCR // Note that we remove packages present in ROM too due to two reasons: // This is exactly what ForceRemove used to do (delete entire registry folder containing ALL reg files) // After deleting an entry SWIRegistry re-registers ROM apps (missing ones) TInt count = removeUids.Count(); RSisRegistryAccessSession regWrite; TInt err = regWrite.Connect(); User::LeaveIfError(err); CleanupClosePushL(regWrite); Swi::RSisRegistrySession regRead; User::LeaveIfError(regRead.Connect()); CleanupClosePushL(regRead); for (TInt i = 0; i < count; ++i) { TUid uid = TUid::Uid(removeUids[i]); Swi::RSisRegistryEntry entry; CleanupClosePushL(entry); if (entry.Open(regRead, uid) == KErrNone) { // Get its augmentations RPointerArray<Swi::CSisRegistryPackage> augmentations; CleanupResetAndDestroy<RPointerArray<Swi::CSisRegistryPackage> >::PushL(augmentations); entry.AugmentationsL(augmentations); TInt augCount = augmentations.Count(); for (TInt j = 0; j < augCount; ++j) { // Remove it TInt dummyTime; regWrite.DeleteEntryL(*augmentations[j], dummyTime); } // Finally remove the base package entry Swi::CSisRegistryPackage* package = entry.PackageL(); CleanupStack::PushL(package); TInt dummyTime; regWrite.DeleteEntryL(*package,dummyTime); CleanupStack::PopAndDestroy(2, &augmentations); // package } CleanupStack::PopAndDestroy(&entry); } CleanupStack::PopAndDestroy(3, &removeUids); // regWrite, regRead #endif CleanupStack::PopAndDestroy(&testutil); return EPass; }
void CScriptFile::ParseScriptSectionsL(const TDesC& aScript, TInt aInsertIndex) { iLastSection = NULL; CScriptSection* section = NULL; CScriptSectionItem* currentItem = NULL; TInt currentItemStart = 0; CScriptSection* sectionAll = NULL; RArray<TInt> sectionIndexArray; CleanupClosePushL(sectionIndexArray); TInt indexIncrement = 0; HBufC* scriptContents = ReadFileLC(aScript); TLex input(*scriptContents); while (!input.Eos()) { input.SkipSpaceAndMark(); input.SkipCharacters(); if ( input.TokenLength() == 0 ) // if valid potential token { break; } TPtrC token = input.MarkedToken(); if (token.CompareF(_L("endscript")) == 0) { break; } else if (token.FindF(KScriptSectionStart) == 0 && token.Length() > 2) { ParseAndSetItemValueL(*scriptContents, input, currentItemStart, currentItem); TInt mid = 1; TInt len = token.Length() - 2; if (sectionAll) section = CScriptSection::NewLC(token.Mid(mid, len), *sectionAll); else section = CScriptSection::NewLC(token.Mid(mid, len)); if (!sectionAll && section->SectionName().CompareF(_L("All")) == 0) sectionAll = section; // We have a Scripts section, store its index as we need to track where // it occured so that the scripts can be added in the same location // after the current file has parsed if (section->SectionName().CompareF(KScriptsSection) == 0) { if(aInsertIndex==KErrNotFound) { // Not an embedded script, simple store its index TInt currectSectionsCount = iSections->Count(); sectionIndexArray.Append(currectSectionsCount); } else { // An embedded script, calculate the index it should be inserted at TInt currectSectionsCount = indexIncrement+aInsertIndex; sectionIndexArray.Append(currectSectionsCount); } } // Check if the section needs to be inserted at a particular location if(aInsertIndex==KErrNotFound) iSections->AppendL(section); else iSections->InsertL(aInsertIndex + indexIncrement++, section); CleanupStack::Pop(section); } else if (section) { TPtrC itemEnd(KScriptItemEnd); if (itemEnd.Length() < token.Length() && token.Right(itemEnd.Length()).CompareF(itemEnd) == 0) { FoundNewItemL(*scriptContents, input, currentItemStart, *section, currentItem); } } } ParseAndSetItemValueL(*scriptContents, input, currentItemStart, currentItem); CleanupStack::PopAndDestroy(scriptContents); // We have been tracking where the script sections have been inserted so we // want to load the sections from the embedded script file and insert them // at the same point. This must be done in reverse order so that the index // values of script sections before the current one is maintained. TInt scriptSectionsCount = sectionIndexArray.Count(); for( TInt ii=scriptSectionsCount-1; ii>=0; --ii) { TInt indexOfScriptSection = sectionIndexArray[ii]; ParseEmbeddedScriptsL(*(iSections->At(indexOfScriptSection)), indexOfScriptSection); } CleanupStack::PopAndDestroy(§ionIndexArray); }
// ----------------------------------------------------------------------------- // CLibxml2Tester::SerializeGZIPL // test GZIP Serialize // (other items were commented in a header). // ----------------------------------------------------------------------------- // TInt CLibxml2Tester::SerializeGZIPL(CStifItemParser& aItem) { TInt error(KErrGeneral); //get test controls, input&output paths TPtrC pControl; aItem.GetNextString( pControl ); TPtrC pBinary; aItem.GetNextString( pBinary ); TPtrC pXml; aItem.GetNextString( pXml ); TPtrC pSerialized; aItem.GetNextString( pSerialized ); TPtrC pGzipSerialized; aItem.GetNextString( pGzipSerialized ); TPtrC pOptions; aItem.GetNextString( pOptions ); // saves xml file with binary data added ( default serialize ) RXmlEngDocument iDocument; CleanupClosePushL( iDocument ); if( pControl.FindF( SINGLE ) != KErrNotFound ) { error = SaveXmlWithBinaryDataL( iDocument, pOptions, pBinary, pXml, EMPTY_STRING() ); } else if ( pControl.FindF( MULTI ) != KErrNotFound ) { error = SaveXmlWithBinaryDataL( iDocument, pOptions, pBinary, pXml, EMPTY_STRING(), TRUE ); } else { User::Leave(KErrArgument); } if ( pControl.FindF( ONE_PARA ) != KErrNotFound ) { User::LeaveIfError( TestSerialize1paraToFileL( iDocument, pGzipSerialized, pOptions, ESerializerGZip ) ); } if ( pControl.FindF( THREE_PARA ) != KErrNotFound ) { User::LeaveIfError ( TestSerialize3paraToFileL( iDocument, pGzipSerialized, pOptions, ESerializerGZip ) ); } if ( pControl.FindF( TO_RFS ) != KErrNotFound ) { User::LeaveIfError( TestSerializeRFsL( iDocument, pGzipSerialized, pOptions, ESerializerGZip ) ); } if ( pControl.FindF( BUFFER ) != KErrNotFound ) { User::LeaveIfError( TestSerializeToBufferL( iDocument, pGzipSerialized, pOptions, ESerializerGZip ) ); } CleanupStack::PopAndDestroy( 1 ); return error; }
TInt CLibxml2Tester::TestDOMExternalDataL(CStifItemParser& aItem) { TInt err; TPtrC pDeserializerType; aItem.GetNextString( pDeserializerType ); TPtrC pInputFile; aItem.GetNextString( pInputFile ); TPtrC pBinary; TPtrC pFile; if( (pDeserializerType.FindF( INFOSET ) != KErrNotFound ) || (pDeserializerType.FindF( XOP ) != KErrNotFound ) ) { aItem.GetNextString( pBinary ); aItem.GetNextString(pFile); } TPtrC pOutputFile; aItem.GetNextString( pOutputFile ); TPtrC pDirtyReturn; aItem.GetNextString( pDirtyReturn ); TLex inputNum (pDirtyReturn); TInt dirtyReturn; inputNum.Val(dirtyReturn); TInt nContainers = 3; RFile fileHandle; RFs aRFs; aRFs.Connect(); CleanupClosePushL( aRFs ); RArray<TXmlEngDataContainer> list; if( (pDeserializerType.FindF( INFOSET ) != KErrNotFound ) || (pDeserializerType.FindF( XOP ) != KErrNotFound ) ) { SetupDocumentL(); HBufC8* binbuf = ReadFileToBufferL(pBinary); CleanupStack::PushL(binbuf); TBufC<100> chunkName(_L("ChunkContainer") ); TInt size = 2000; TInt maxSize = 10000; TInt offset = 0; TInt binarySize = CID_2().Length(); // TBool isReadOnly = EFalse; RChunk chunk; chunk.CreateGlobal(chunkName, size, maxSize); CleanupClosePushL(chunk); RFile fp; User::LeaveIfError( fp.Open(aRFs, pFile, EFileRead) ); CleanupClosePushL(fp); TXmlEngBinaryContainer bincont = iDoc.CreateBinaryContainerL(CID_1(), binbuf->Des()); TXmlEngChunkContainer chunkcont = iDoc.CreateChunkContainerL(CID_2(), chunk, offset, binarySize); TXmlEngFileContainer filecont = iDoc.CreateFileContainerL(CID_3(), fp); iDoc.DocumentElement().AppendChildL(bincont); iDoc.DocumentElement().AppendChildL(chunkcont); iDoc.DocumentElement().AppendChildL(filecont); CleanupClosePushL(list); //// iDoc.GetDataContainerList(list); } RXmlEngDocument doc; CXmlEngDeserializerDOM* des = CXmlEngDeserializerDOM::NewL(); CleanupStack::PushL( des ); des->UseDOMImplementationL( DOM_impl); if( pDeserializerType.FindF( XOP ) != KErrNotFound ) { des->UseExternalDataL( list ); des->SetInputFileL( pInputFile,EDeserializerXOP); TRAP(err,doc=des->DeserializeL()); } else if( pDeserializerType.FindF( INFOSET ) != KErrNotFound ) { des->UseExternalDataL( list ); des->SetInputFileL( pInputFile,EDeserializerXOPInfoset ); TRAP(err,doc=des->DeserializeL()); } if(list.Count() != nContainers) User::Leave(KErrGeneral); RArray<TXmlEngDataContainer>* fromDeserializer = des->ExternalData(); if(fromDeserializer->Count() != nContainers) User::Leave(KErrGeneral); for(TInt i = 0; i < nContainers; i++ ) { if (fromDeserializer->operator[](i).NodeType() != list.operator[](i).NodeType() ) User::Leave( KErrGeneral ); if (fromDeserializer->operator[](i).Size() != list.operator[](i).Size() ) User::Leave( KErrGeneral ); } // fromDeserializer->Close(); SaveDocumentL(doc,pOutputFile); CleanupStack::PopAndDestroy( 6 ); if ( err == dirtyReturn ) return KErrNone; else return err; }
TInt CLibxml2Tester::TestDOMSetInputBufferL(CStifItemParser& aItem) { TPtrC pType; aItem.GetNextString(pType); TPtrC pDoc; aItem.GetNextString(pDoc); TPtrC pBinary; TPtrC pFile; if( pType.FindF( INFOSET ) != KErrNotFound ) { aItem.GetNextString( pBinary ); aItem.GetNextString(pFile); } TPtrC pOut; aItem.GetNextString(pOut); HBufC8* buf = ReadFileL(pDoc); CleanupStack::PushL(buf); // TInt nContainers = 3; RFile fileHandle; RFs aRFs; aRFs.Connect(); CleanupClosePushL( aRFs ); RArray<TXmlEngDataContainer> list; if( pType.FindF( INFOSET ) != KErrNotFound ) { SetupDocumentL(); HBufC8* binbuf = ReadFileToBufferL(pBinary); CleanupStack::PushL(binbuf); TBufC<100> chunkName(_L("ChunkContainer") ); TInt size = 2000; TInt maxSize = 10000; TInt offset = 0; TInt binarySize = CID_2().Length(); // TBool isReadOnly = EFalse; RChunk chunk; chunk.CreateGlobal(chunkName, size, maxSize); CleanupClosePushL(chunk); RFile fp; User::LeaveIfError( fp.Open(aRFs, pFile, EFileRead) ); CleanupClosePushL(fp); TXmlEngBinaryContainer bincont = iDoc.CreateBinaryContainerL(CID_1(), binbuf->Des()); TXmlEngChunkContainer chunkcont = iDoc.CreateChunkContainerL(CID_2(), chunk, offset, binarySize); TXmlEngFileContainer filecont = iDoc.CreateFileContainerL(CID_3(), fp); iDoc.DocumentElement().AppendChildL(bincont); iDoc.DocumentElement().AppendChildL(chunkcont); iDoc.DocumentElement().AppendChildL(filecont); CleanupClosePushL(list); //// iDoc.GetDataContainerList(list); } RXmlEngDocument doc; CXmlEngDeserializerDOM* des = CXmlEngDeserializerDOM::NewL(); CleanupStack::PushL( des ); des->UseDOMImplementationL( DOM_impl); if( pType.FindF( INFOSET ) != KErrNotFound ) { des->UseExternalDataL( list ); } des->SetInputBuffer(buf->Des(), RetDeserializerType(pType)); doc=des->DeserializeL(); SaveDocumentL(doc,pOut); if( pType.FindF( INFOSET ) != KErrNotFound ) { CleanupStack::PopAndDestroy( 7 ); } else { CleanupStack::PopAndDestroy( 3 ); } return KErrNone; }
TInt CIpsPlgMsgIterator::SearchL( CMsvEntrySelection* aMessageEntries, const TDesC& aStartWith, TInt& aIndex ) { FUNC_LOG; TInt result( KErrNotFound ); TInt i; TInt findStatus; TInt offset; TFSMailSortField primaryKey = EFSMailDontCare; TPtrC subject; // Check whether the search is supported if ( iSortingCriteria.Count() > 0 ) { primaryKey = iSortingCriteria[0].iField; } if ( !iSortingOn || ( ( primaryKey != EFSMailSortBySender ) && ( primaryKey != EFSMailSortBySubject ) ) ) { result = KErrNotSupported; } // Actual search i = 0; while ( ( result == KErrNotFound ) && ( i < aMessageEntries->Count() ) ) { const TMsvEntry& entry( iFolderEntry->ChildDataL( aMessageEntries->At(i) ) ); findStatus = KErrNotFound; if ( primaryKey == EFSMailSortBySender ) { findStatus = entry.iDetails.FindF( aStartWith ); } if ( primaryKey == EFSMailSortBySubject ) { // Strip the prefixes (Re:, Fwd: etc) from the subject before // matching offset = iMsgSortKey->FindSubjectStart( entry.iDescription ); subject.Set( entry.iDescription.Ptr() + offset, entry.iDescription.Length() - offset ); findStatus = subject.FindF( aStartWith ); } // Checks whether a matching message has been found if ( findStatus == 0 ) { result = KErrNone; aIndex = i; } i++; } return result; }
void CTestEngine::ConstructL() { OstTraceFunctionEntry1( CTESTENGINE_CONSTRUCTL_ENTRY, this ); CActiveScheduler::Add(this); // Display information (construction text and OS build version number gtest.Title(); gtest.Start(_L("Test Engine Initiation")); gtest.Printf(_L(">>\n")); OstTrace0(TRACE_NORMAL, CTESTENGINE_CONSTRUCTL, ">>\n"); gtest.Printf(_L(">> T E S T R U N \n")); OstTrace0(TRACE_NORMAL, CTESTENGINE_CONSTRUCTL_DUP01, ">> T E S T R U N \n"); gtest.Printf(_L(">>\n")); OstTrace0(TRACE_NORMAL, CTESTENGINE_CONSTRUCTL_DUP02, ">>\n"); // Process the command line option for role TInt cmdLineLength(User::CommandLineLength()); HBufC* cmdLine = HBufC::NewMax(cmdLineLength); CleanupStack::PushL(cmdLine); TPtr cmdLinePtr = cmdLine->Des(); User::CommandLine(cmdLinePtr); // be careful, command line length is limited(248 characters) gtest.Printf(_L("***cmdLine = %lS\n"), cmdLine); OstTraceExt1(TRACE_NORMAL, CTESTENGINE_CONSTRUCTL_DUP03, "***cmdLine = %lS\n", *cmdLine); TLex args(*cmdLine); args.SkipSpace(); // Obtain the role of this test module TPtrC roleToken = args.NextToken(); // e.g. -role=host TBool hostFlag(ETrue); TInt pos(roleToken.FindF(KArgRole)); if(pos != KErrNotFound) { pos = roleToken.FindF(_L("=")); TPtrC role = roleToken.Right(roleToken.Length()-pos-1); if(role.Compare(KArgRoleHost) == 0) { hostFlag = ETrue; } else if(role.Compare(KArgRoleClient) == 0) { hostFlag = EFalse; } else { gtest.Printf(_L("Test configuration: could not find option -role\n")); OstTrace0(TRACE_NORMAL, CTESTENGINE_CONSTRUCTL_DUP04, "Test configuration: could not find option -role\n"); gtest(EFalse); } } else { gtest.Printf(_L("Test configuration option not found: %S\n"),&KArgRole); OstTraceExt1(TRACE_NORMAL, CTESTENGINE_CONSTRUCTL_DUP05, "Test configuration option not found: %S\n",KArgRole); gtest(EFalse); } // Obtain the test cases to be run TPtrC casesToken = args.NextToken(); pos = casesToken.FindF(KArgTestCases); if(pos != KErrNotFound) { pos = casesToken.FindF(_L("=")); TPtrC testCases = casesToken.Right(casesToken.Length()-pos-1); // Remaining test cases TPtrC remCases(testCases); while(pos != KErrNotFound) { pos = remCases.FindF(_L(",")); HBufC* tc = HBufC::NewLC(KTestCaseIdLength); TPtr tcPtr = tc->Des(); tcPtr.Append(KTestStringPreamble); if(pos == KErrNotFound) { // This is the last test case identity tcPtr.Append(remCases); } else { tcPtr.Append(remCases.Left(KTestIdSize)); } gtest.Printf(_L("Test case specified: %S\n"),tc); OstTraceExt1(TRACE_NORMAL, CTESTENGINE_CONSTRUCTL_DUP06, "Test case specified: %S\n",*tc); iTestCasesIdentities.Append(tc); CleanupStack::Pop(tc); remCases.Set(testCases.Right(remCases.Length()-pos-1)); } } else { gtest.Printf(_L("Test configuration option not found: %S\n"),&KArgTestCases); OstTraceExt1(TRACE_NORMAL, CTESTENGINE_CONSTRUCTL_DUP07, "Test configuration option not found: %S\n",KArgTestCases()); gtest(EFalse); } // Obtain the role of this test module TPtrC repeatsToken = args.NextToken(); // e.g. -repeats=4 pos = repeatsToken.FindF(KArgTestRepeats); if(pos != KErrNotFound) { pos = repeatsToken.FindF(_L("=")); TPtrC repeats = repeatsToken.Right(repeatsToken.Length()-pos-1); TLex lex(repeats); TInt ret = lex.Val(iNumRepeats, EDecimal); if(ret) { gtest.Printf(_L("Test configuration option not found: %S\n"),&KArgTestRepeats); OstTraceExt1(TRACE_NORMAL, CTESTENGINE_CONSTRUCTL_DUP08, "Test configuration option not found: %S\n",KArgTestRepeats()); gtest.Printf(_L("DEFAULT to number of repeats = %d\n"),KDefaultNumRepeats); OstTrace1(TRACE_NORMAL, CTESTENGINE_CONSTRUCTL_DUP09, "DEFAULT to number of repeats = %d\n",KDefaultNumRepeats); iNumRepeats = KDefaultNumRepeats; } gtest.Printf(_L("Test repeats specified: %d cycles\n"),iNumRepeats); OstTrace1(TRACE_NORMAL, CTESTENGINE_CONSTRUCTL_DUP10, "Test repeats specified: %d cycles\n",iNumRepeats); } else { gtest.Printf(_L("Test configuration option not found: %S\n"),&KArgTestRepeats); OstTraceExt1(TRACE_NORMAL, CTESTENGINE_CONSTRUCTL_DUP11, "Test configuration option not found: %S\n",KArgTestRepeats()); gtest.Printf(_L("DEFAULT to number of repeats = %d\n"),KDefaultNumRepeats); OstTrace1(TRACE_NORMAL, CTESTENGINE_CONSTRUCTL_DUP12, "DEFAULT to number of repeats = %d\n",KDefaultNumRepeats); iNumRepeats = KDefaultNumRepeats; } // Create the test case controller gtest.Printf(_L("Creating the test controller\n")); OstTrace0(TRACE_NORMAL, CTESTENGINE_CONSTRUCTL_DUP13, "Creating the test controller\n"); iTestCaseController = CTestCaseController::NewL(*this,hostFlag); CleanupStack::PopAndDestroy(cmdLine); gtest.Console()->Read(iStatus); SetActive(); OstTraceFunctionExit1( CTESTENGINE_CONSTRUCTL_EXIT, this ); }