TPtrC TLineBuffer::ReadLine() { // Class nvariant: iRemainder == iTail.Length() ASSERT(iRemainder == iTail.Length()); TInt end = iTail.Locate('\n'); if (end < 0) { // Buffer ends without ending '\n', treat as line end = iTail.Length(); iRemainder = 0; } else { // 0 <= end < iTail.Length() => iTail.Length() > iRemainder >= 0 // (remainder is always decreased at least by 1, skipping '\n', // and will never become negative, because end < remainder) iRemainder -= end + 1; // Ignore CR before LF, if present if (end > 0 && iTail[end-1] == '\r') --end; } const TPtrC line(iTail.Left(end)); iTail.Set(iTail.Right(iRemainder)); return line; }
void CDbCreator::ParseCommandLineLC( CCommandLineArguments* aArgs, TFileName& aFileName, TBool& aExt, TBool& aDump ) { TPtrC arg; if ( aArgs->Count() > 1 ) { for ( TInt i = 1; i < aArgs->Count(); i++ ) { arg.Set( aArgs->Arg( i ) ); if( arg.Size() > 0 ) { switch( arg[0] ) { case 'd': case 'D'://fall-through // D means "dump" needed aDump = ETrue; break; case 'f': case 'F'://fall-through { _LIT( KHeader, "f:" ); if ( 0 == arg.FindF( KHeader ) ) { //f: must be in the head position of file location aFileName.Copy( arg.Right( arg.Length() - KFParamLength ) ); } else { User::Leave( KErrInvalidParameter ); } break; } // Only the CommsDat will be extended case 'E': case 'e'://fall-through { aExt = ETrue; break; } default: { User::Leave( KErrInvalidParameter ); } }//swich }//if }//for }//if }
EXPORT_C TBool CEikListBoxTextEditor::UpdateModelL() // virtual - needs to be rewritten if editing other than single column text list { _AKNTRACE_FUNC_ENTER; if (!Editor()) { _AKNTRACE_FUNC_EXIT; return EFalse; // quit if editing is not currently on } const MDesCArray* matchableTextArray=ListBoxModel()->MatchableTextArray(); CDesCArray* textArray=(CDesCArray*)matchableTextArray; TPtrC itemtext = ItemText(); if ( iItemPos ) // partly editable item? { HBufC* itemBuffer= HBufC::New(itemtext.Length()); CleanupStack::PushL( itemBuffer ); TPtr itemPointer = itemBuffer->Des(); itemPointer.Append( itemtext.Left( iItemPos ) ); HBufC* ptr=iEditor->GetTextInHBufL(); TPtrC newText; if (ptr) { newText.Set(ptr->Des()); } TInt addSpaces = iItemLen - newText.Length(); for (TInt index=0; ((addSpaces>0) && (index<addSpaces)); index++) itemPointer.Append(_L(" ")); itemPointer.Append( newText ); itemPointer.Append( itemtext.Right( itemtext.Length()-iItemPos-iItemLen ) ); delete ptr; textArray->InsertL( ItemIndex(), *itemBuffer ); CleanupStack::PopAndDestroy(); // itemBuffer textArray->Delete( ItemIndex()+1 ); } else // replace the whole list item { HBufC* newText = iEditor->GetTextInHBufL(); if (!newText) return ETrue; // if user tries to insert an empty text... CleanupStack::PushL(newText); textArray->InsertL(ItemIndex(),*newText); CleanupStack::PopAndDestroy(); // newText textArray->Delete( ItemIndex() + 1 ); } _AKNTRACE_FUNC_EXIT; return ETrue; }
EXPORT_C void TInuLogger::WriteComment(const TDesC& aComment) // // Writes aComment to test log file, logging file and test harness { TPtrC line; line.Set(aComment); while (line.Length() > KMaxLogLineLength) { iLogger.Write(line.Left(KMaxLogLineLength)); line.Set(line.Right(line.Length() - KMaxLogLineLength)); } iLogger.Write(line.Left(line.Length())); }
/** CheckIfFooterMessageExistsL() Checks the email for the presence of the footer string @param aRecvBodyText Reference to a descriptor holding the body text @param aFooterSize The expected number of KB remaining on the server which has been inserted into the footer string @return ETrue if footer string found otherwise EFalse */ TBool CT_MsgComparePopEmailMsgs::CheckIfFooterMessageExistsL(TPtrC& aRecvBodyText , TInt& aFooterSize) { RResourceFile resFile; CT_MsgUtils ::OpenResourceFileL(resFile, iFs, KImEngineResourceFile); // NB leaves if file not found TCleanupItem close(CT_MsgUtils ::CloseResourceFile, &resFile); CleanupStack::PushL(close); HBufC8* buf = NULL; buf = resFile.AllocReadLC(PARTIAL_DOWNLOAD_FOOTER_MESSAGE); TResourceReader reader; reader.SetBuffer(buf); HBufC* resourceBuf = (reader.ReadTPtrC()).AllocL(); CleanupStack::PushL(resourceBuf); TInt len = resourceBuf->Find(_L("%d")); const TInt KBufLen = 256; TBuf<KBufLen> findBuf; if(len == KErrNotFound) { len = resourceBuf->Length(); } if(len > KBufLen) { len = KBufLen; } findBuf.Copy(resourceBuf->Ptr(), len); len = aRecvBodyText.Find(findBuf); if(len>=0) { TPtrC rest=aRecvBodyText.Right(aRecvBodyText.Length()-len-findBuf.Length()); TLex lex(rest.Left(rest.Locate(TChar(' ')))); lex.Val(aFooterSize); } else { aFooterSize=0; } CT_MsgUtils ::CloseResourceFile(&resFile); CleanupStack::PopAndDestroy(3); // buf, resourceBuf, close return (len != KErrNotFound); }
/** Parses URL from a token. Is used by SearchUrlL method and if a URL was found it's appended to item array. Note that parsing for generic URIs is done with SearchGenericUriL -method. @param aType a Type of URL to seach, i.e. www. wap. IP e.g.127.0.0.1 @param aTokenPtr Pointer to token that will be parsed @param aTextOffset Offset of the token (start position in the whole text) @leave KErrNone, if successful; otherwise one of the other system-wide error codes. @return ETrue if the parameter for phone number is valid, else returns EFalse */ TBool CTulAddressStringTokenizer::ParseUrlL(const TDesC& aType, const TPtrC& aTokenPtr, TInt aTextOffset) { TBool wasValidUrl = EFalse; TLex url; TInt position = aTokenPtr.FindF( aType ); if ( position != KErrNotFound ) { // address start found url = aTokenPtr.Right( aTokenPtr.Length() - position ); url.Inc( aType.Length() ); while( IsValidUrlChar( url.Peek() ) && !(url.Eos()) ) { if( url.Peek() == ':' ) { url.Inc(); if ( !url.Peek().IsDigit() ) { url.UnGet(); break; } } else url.Inc(); } // If a period or question mark was followed by a whitespace remove it if ( url.Eos() ) // Can't be followed by white space if it's { // the last character at token url.UnGet(); if ( url.Peek() != '.' && url.Peek() != '?' && url.Peek() != ',' ) // If it wasn't a period or question mark url.Inc(); } url.Mark(); wasValidUrl = ETrue; } if ( wasValidUrl && ( url.MarkedOffset() > aType.Length() ) ) { AddItemL( aTextOffset - aTokenPtr.Length() + position, url.MarkedOffset(), EFindItemSearchURLBin ); return ETrue; } return EFalse; }
/** Function to write a comment string to test log file, logging file and test harness. @param aComment The descriptor containing the comment string */ EXPORT_C void THttpLogger::WriteComment(const TDesC& aComment) // // Writes aComment to test log file, logging file and test harness { if(iLogger) { // If connection to flogger was made if(iLogger->Handle() != 0) { TPtrC line; line.Set(aComment); while (line.Length() > KMaxLogLineLength) { iLogger->Write(line.Left(KMaxLogLineLength)); line.Set(line.Right(line.Length() - KMaxLogLineLength)); } iLogger->Write(line.Left(line.Length())); } } }
// --------------------------------------------------------- // CMailToHandler::GetNextField() // --------------------------------------------------------- // TInt CMailToHandler::GetNextField( TInt aStart ) { TPtrC path = iParsedUrl->Des(); TInt retVal = path.Length(); TPtrC scheme; //KSubject KBody KCc if( aStart < retVal ) { scheme.Set( path.Right( retVal - aStart ) ); } else { return retVal; } TInt subjPos = scheme.FindF( KSubject ); subjPos = ( subjPos == KErrNotFound ) ? retVal : subjPos; TInt bodyPos = scheme.FindF( KBody ); bodyPos = ( bodyPos == KErrNotFound ) ? retVal : bodyPos; TInt toPos = scheme.FindF( KTo ); toPos = ( toPos == KErrNotFound ) ? retVal : toPos; TInt ccPos = scheme.FindF( KCc ); ccPos = ( ccPos == KErrNotFound ) ? retVal : ccPos; TInt bccPos = scheme.FindF( KBcc ); bccPos = ( bccPos == KErrNotFound ) ? retVal : bccPos; TInt temp = Minimum( subjPos, bodyPos, toPos, ccPos, bccPos ); retVal = ( temp < retVal) ? temp + aStart : retVal; return retVal; }
/** CountLinesOfBodyTextL() Counts the lines of body text in the email aEntry @param aEntry A reference to an object representing the email @param aFooterExists Reference to a boolean variable - set to ETrue if the footer string is found in the body text @param aFooterSize Expected KB left on server inserted into footer string if present @return Number of lines in the body text */ TInt CT_MsgComparePopEmailMsgs::CountLinesOfBodyTextL(CMsvEntry& aEntry, TBool& aFooterExists, TInt& aFooterSize) { TInt lines = 0; TInt count =0; aFooterExists=EFalse; aFooterSize=0; aEntry.SetEntryL(aEntry.EntryId()); if(aEntry.HasStoreL()) { CMsvStore* msvStore1= aEntry.ReadStoreL(); CleanupStack::PushL(msvStore1); CParaFormatLayer* paraFormatLayer1 = CParaFormatLayer::NewL(); CleanupStack::PushL(paraFormatLayer1); CCharFormatLayer* charFormatLayer1 = CCharFormatLayer::NewL(); CleanupStack::PushL(charFormatLayer1); CRichText* bodyText1=CRichText::NewL(paraFormatLayer1, charFormatLayer1, CEditableText::EFlatStorage, 256); CleanupStack::PushL(bodyText1); bodyText1->Reset(); if (msvStore1->HasBodyTextL()) { msvStore1->RestoreBodyTextL(*bodyText1); TUint16 val = CEditableText::ELineBreak; TUint16 val1 = CEditableText::EParagraphDelimiter; TUint16 val2 = KUnicodeValue; TInt n = 0; TInt pos = 0; for(;;) { TPtrC bodyText = bodyText1->Read(pos); n = bodyText.Find(&val, 1); // if iStore8BitData flag is set, the line is terminated by "CEditableText::EParagraphDelimiter" if(msvStore1->IsPresentL(KMsvPlainBodyText8)) { if ( 0 == count ) { TPtrC buffer = bodyText.Mid(0,n+2); // eg for 8bit the body look as : This is a simple email message.\x2028\x2029\x2029 // eg for 16bit the body look as: This is a simple email message.\x2028\x2028\x2029 if((bodyText.Right(2).Compare(KParagraphDelimiter)==KErrNone) && \ buffer.Find(&val2,1) != 75) { lines++; count++; } // Increment the line if EParagraphDelimiter or 0x0046 is found sequence as eg:1. \x2028\x2029 // 2. \x2028\x2029\x2028\x2029\x0046 3. \x2028\x2029\x2028\x2029\x2028\x2029 else if ( (buffer.Find(&val1,1)==0 && n==-1) || (buffer.Find(&val2,1)==1) \ || (buffer.Find(&val1,1)>0) ) { lines++; } } } if(n < 0) break; lines++; pos += n+1; //This Check is needed to delete the extra line introduced by communigate Pro Server TInt fpos = CheckIfServerMessageExists(bodyText); if (fpos != KErrNotFound) { lines--; } } TPtrC pBt = bodyText1->Read(0); aFooterExists = CheckIfFooterMessageExistsL(pBt , aFooterSize); } CleanupStack::PopAndDestroy(4, msvStore1); //bodyText1,charFormatLayer1,paraFormatLayer1,msvStore1. } return lines; }
// ----------------------------------------------------------------------------- // CPosLmLocalDatabaseManager::ListDatabasesLC // // (other items were commented in a header). // ----------------------------------------------------------------------------- // CDesCArray* CPosLmLocalDatabaseManager::ListDatabasesLC() { CDesCArray* dbArray = new (ELeave) CDesCArrayFlat(KPosDbListGranularity); CleanupStack::PushL(dbArray); RFs fs; CleanupClosePushL(fs); User::LeaveIfError(fs.Connect()); TDriveList driveList; User::LeaveIfError(fs.DriveList(driveList)); RDbs dbSession; CleanupClosePushL(dbSession); User::LeaveIfError(dbSession.Connect()); for (TInt drive = EDriveA; drive <= EDriveZ; drive++) { if ( driveList[drive] && !( driveList[drive] & KDriveAttRemote ) ) // avoid remote drives { TDriveInfo drvInfo; TInt err = fs.Drive( drvInfo, drive ); if ( !err && drvInfo.iType != EMediaNotPresent ) { CDbDatabaseNames* dbNames = NULL; TRAPD(err, dbNames = dbSession.DatabaseNamesL( static_cast<TDriveNumber>(drive), KPosLmDbSecureUid)); // Ignore all errors except KErrNoMemory (and KErrNone) if (err == KErrNone) { CleanupStack::PushL(dbNames); for (TInt i = 0; i < dbNames->Count(); i++) { TPtrC ptr = (*dbNames)[i]; if (ptr.Right(KFileExtension().Length()). CompareF(KFileExtension) == 0) { HBufC* fullName = HBufC::NewLC( KFileProtocol().Length() + KProtocolDelimiter().Length() + KDriveAndDelimiterLength + (*dbNames)[i].Length()); TChar chr; fs.DriveToChar(drive, chr); TPtr ptr2 = fullName->Des(); ptr2.Append(KFileProtocol); ptr2.Append(KProtocolDelimiter); ptr2.Append(chr); ptr2.Append(KDriveDelimiter); ptr2.Append((*dbNames)[i]); dbArray->AppendL(*fullName); CleanupStack::PopAndDestroy(fullName); } } CleanupStack::PopAndDestroy(dbNames); } else if (err == KErrNoMemory) { User::Leave(err); } } } } CleanupStack::PopAndDestroy(2, &fs); //dbSession return dbArray; }
TVerdict CTestMmfAclntOpenFile7905::DoTestStepL() { INFO_PRINTF1( _L("TestRecorder : Record File")); TVerdict ret = EFail; iError = KErrTimedOut; RFs fs; RFile file; User::LeaveIfError(fs.Connect()); CleanupClosePushL(fs); User::LeaveIfError(fs.ShareProtected()); TPtrC filename; if(!GetStringFromConfig(iSectName, iKeyName, filename)) { return EInconclusive; } CMdaAudioRecorderUtility* recUtil = CMdaAudioRecorderUtility::NewL(*this); CleanupStack::PushL(recUtil); TUid invalidAudioController; invalidAudioController.iUid = KInvalidAudioController; User::LeaveIfError(file.Replace(fs,filename,EFileWrite)); CleanupClosePushL(file); recUtil->OpenFileL(file, invalidAudioController, KNullUid, KNullUid, KFourCCNULL); INFO_PRINTF1( _L("Initialise CMdaAudioRecorderUtility")); CActiveScheduler::Start(); if( iError == KErrNotFound ) { ret = EPass; } if(iError == KErrNone) { iError = KErrTimedOut; recUtil->RecordL(); INFO_PRINTF1( _L("Record CMdaAudioRecorderUtility")); CActiveScheduler::Start(); // open -> record User::After(KFiveSeconds); recUtil->Stop(); } CleanupStack::PopAndDestroy(2, recUtil); recUtil = NULL; // Playback the file if (iError == KErrNone) { if (filename.Right(4).Compare(_L(".wav"))==0) { // Wav file playback CMdaAudioPlayerUtility* playUtil = CMdaAudioPlayerUtility::NewL(*this); CleanupStack::PushL(playUtil); TRAPD(err, playUtil->OpenFileL(filename)); if (err != KErrNone) { INFO_PRINTF2(_L("Error opening file for playback err = %d"), err); ret = EFail; } CActiveScheduler::Start(); if (iError != KErrNone) { INFO_PRINTF2(_L("Error opening file for playback iError = %d"), iError); ret = EFail; } playUtil->Play(); CActiveScheduler::Start(); CleanupStack::PopAndDestroy(playUtil); if (iError != KErrNone) { INFO_PRINTF2(_L("Error during playback of recorded file iError=%d"), iError); ret = EFail; } } } if( iError == KErrNone ) { RFile file; TInt size = 0; User::LeaveIfError(file.Open(fs,filename,EFileRead)); CleanupClosePushL(file); User::LeaveIfError(file.Size(size)); if(size > 0) { ret = EPass; } CleanupStack::PopAndDestroy(); //file } CleanupStack::PopAndDestroy(); // fs ERR_PRINTF2( _L("CMdaAudioRecorderUtility completed with error %d"),iError ); User::After(KOneSecond); return ret; }
/** * Wraps the text and sets it into the labels. */ void CAknTextControl::ParseTextL(const CFont* aFont, CArrayFixFlat<TInt>* aLineWidths,const TWrapMethod& aWrapMethod) { if ( aWrapMethod == ENoAllocation && iWrappedArray ) { // We preallocate text required in construction of alert win, so we just replace the texts in labels. TPtrC remainder = Text(); TChar endlchar('\n'); TInt linebreak = remainder.LocateReverse(endlchar); TBuf<17 + KAknBidiExtraSpacePerLine> temp; //KEikAlertMaxMsgLength not declared in this scope if ( linebreak == KErrNotFound ) { AknBidiTextUtils::ConvertToVisualAndClip(remainder, temp, *aFont, KMaxTInt, KMaxTInt ); Line(0)->SetTextL(temp); // won't leave as there is enough space in buffer iLines[0]->iModified = ETrue; Line(1)->SetTextL(KNullDesC); iLines[1]->iModified = ETrue; } else { AknBidiTextUtils::ConvertToVisualAndClip( remainder.Left(linebreak), temp, *aFont, KMaxTInt, KMaxTInt ); Line(0)->SetTextL(temp); iLines[0]->iModified = ETrue; if ( remainder.Length()-1 == linebreak) // Line break is the last character { Line(1)->SetTextL(KNullDesC); } else { AknBidiTextUtils::ConvertToVisualAndClip( remainder.Right(remainder.Length()-linebreak-1), temp, *aFont, KMaxTInt, KMaxTInt ); Line(1)->SetTextL(temp); // we don't want new line to label, thus -1 } iLines[1]->iModified = ETrue; } return; } if (iTextIsAlreadyInLabel || !iWrappedArray) return; TInt maxLines = aLineWidths->Count(); // user handles all text processing if ( aWrapMethod == ENoProcessing ) { iWrappedArray->Reset(); TPtrC remainder = Text(); while ( remainder.Length() && iWrappedArray->Count() < maxLines ) { const TText* textArray = remainder.Ptr(); TInt textLength = remainder.Length(); TInt i = 0; for ( ; i < textLength ; i++ ) { TText t = textArray[i]; if ( t == KLineFeed || t == KLineSeparator || t == KParagraphSeparator || t == KCarriageReturn ) { break; } } iWrappedArray->AppendL( remainder.Left( i ) ); // After a CR, skip also possible matching LF if ( i < textLength - 1 && textArray[i] == KCarriageReturn && textArray[i + 1] == KLineFeed ) { i++; } i++; if ( i >= textLength ) { break; } remainder.Set( remainder.Right( textLength - i ) ); } } else { TPtr text = Text(); HBufC* visualBuffer = HBufC::NewLC( text.Length() + maxLines * KAknBidiExtraSpacePerLine ); *visualBuffer = text; TPtr ptr = visualBuffer->Des(); AknTextUtils::DisplayTextLanguageSpecificNumberConversion( ptr); if (aWrapMethod == EWord) { AknBidiTextUtils::ConvertToVisualAndWrapToArrayL( ptr, *aLineWidths, *aFont, *iWrappedArray, ETrue ); } else if (aWrapMethod == ELine) { AknBidiTextUtils::ConvertToVisualAndChopToArrayL( ptr, *aLineWidths, *aFont, *iWrappedArray ); } else { __ASSERT_DEBUG(0,Panic(EAknPanicNotSupported)); } } TInt numLines = iWrappedArray->Count(); UpdateLabelsL(numLines,aFont,aLineWidths); SetWrappedTextIntoLabelsL(*iWrappedArray, numLines, aFont); if ( aWrapMethod != ENoProcessing ) { CleanupStack::PopAndDestroy(); // visualBuffer } }
TBool CDataWrapperBase::GetCommandStringParameterL(const TDesC& aSectName, const TDesC& aKeyName, TPtrC& aResult) { TBool ret=EFalse; if ( aSectName.Length()!=0 ) { ret=CDataWrapper::GetStringFromConfig(aSectName, aKeyName, aResult); for ( TInt index=iInclude.Count(); (index>0) && (!ret); ) { ret=iInclude[--index]->FindVar(aSectName, aKeyName, aResult); } } if ( ret ) { if ( aResult.Match(KMatch)!=KErrNotFound ) { // We have an entry of the format // entry =*{section,entry}* // where * is one or more characters // We need to construct this from other data in the ini file replacing {*,*} // with the data from // [section] // entry =some_value HBufC* buffer=HBufC::NewLC(aResult.Length()); buffer->Des().Copy(aResult); TInt startLength=KStart().Length(); TInt sparatorLength=KSeparator().Length(); TInt endLength=KEnd().Length(); TInt bufferLength; TInt start; TInt sparator; TInt end; TPtrC remaining; TLex lex; do { bufferLength=buffer->Length(); start=buffer->Find(KStart); remaining.Set(buffer->Des().Right(bufferLength-start-startLength)); sparator=remaining.Find(KSeparator); remaining.Set(remaining.Right(remaining.Length()-sparator-sparatorLength)); sparator += (start + startLength); end=remaining.Find(KEnd) + sparator + sparatorLength; TPtrC sectionName(buffer->Ptr()+start+startLength, sparator-start-startLength); TPtrC keyName(buffer->Ptr()+sparator+sparatorLength, end-sparator-sparatorLength); sectionName.Set(TLex(sectionName).NextToken()); keyName.Set(TLex(keyName).NextToken()); TInt entrySize=0; TPtrC entryData; TBool found=CDataWrapper::GetStringFromConfig(sectionName, keyName, entryData); for ( TInt index=iInclude.Count(); (index>0) && (!found); ) { found=iInclude[--index]->FindVar(sectionName, keyName, entryData); } if ( found ) { entrySize=entryData.Length(); } TInt newLength=start + bufferLength - end - endLength + entrySize; HBufC* bufferNew=HBufC::NewLC(newLength); bufferNew->Des().Copy(buffer->Ptr(), start); if ( entrySize>0 ) { bufferNew->Des().Append(entryData); } bufferNew->Des().Append(buffer->Ptr() + end + endLength, bufferLength - end - endLength); CleanupStack::Pop(bufferNew); CleanupStack::PopAndDestroy(buffer); buffer=bufferNew; CleanupStack::PushL(buffer); } while ( buffer->Match(KMatch)!=KErrNotFound ); iBuffer.Append(buffer); CleanupStack::Pop(buffer); aResult.Set(*buffer); INFO_PRINTF4(KDataRead, &aSectName, &aKeyName , &aResult); } } return ret; }
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); }
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 ); }