TInt CFloggerTest004_01::DoTestCheckWriteL() { RFile theFile; HBufC8 * hBuffer; TInt listfilesize,returnCode; RFs fileSystem; //For file operation create a file system TBuf8<256> testData; //To hold the test descriptor _LIT(KLogFile,"c:\\logs\\log.txt"); // log file name and path TInt numSuccessful = 0; _LIT(KTestMessage,"TC 4.01 :This is test msg"); //unicode test decriptor User::LeaveIfError(fileSystem.Connect()); //Open the file in the read mode User::LeaveIfError(theFile.Open(fileSystem,KLogFile,EFileRead)); CleanupClosePushL(theFile); User::LeaveIfError(theFile.Size(listfilesize)); //Size of the file hBuffer = HBufC8::New(listfilesize); //Allocate the buffer CleanupStack::PushL(hBuffer); TPtr8 ptrString = hBuffer->Des(); ; //To hold the buffer // Read from position 0: start of file User::LeaveIfError(returnCode = theFile.Read(ptrString)); testData.Copy(KTestMessage); //Copy the test descriptor returnCode = ptrString.Find(testData); //find the test descriptor in the buffer read //from the file if (returnCode != KErrNotFound) { numSuccessful++; } returnCode = ptrString.Find(KErrOOM); if (returnCode > 0) { User::Leave(KErrNoMemory); } CleanupStack::PopAndDestroy(hBuffer); CleanupStack::PopAndDestroy(); //theFile if (numSuccessful == 1) { return KErrNone; } else { return KErrNotFound; } }
TInt CFloggerTest017_04::DoTestCheckWriteL() { User::After(KTimeToLog); RFile theFile; HBufC8 * hBuffer; TInt listfilesize; TInt returnCode; RFs fileSystem; //For file operation create a file system TBuf8<256> testData; //To hold the test descriptor _LIT(KLogFile,"c:\\logs\\log.txt"); // the log file path _LIT(KBodyTxt,"TC 17_4:Test Msg");// Test body descriptor TUint numSuccessful = 0; User::LeaveIfError(fileSystem.Connect()); //Open the file in the read mode User::LeaveIfError(theFile.Open(fileSystem,KLogFile,EFileRead)); CleanupClosePushL(theFile); User::LeaveIfError(returnCode = theFile.Size(listfilesize)); //Size of the file hBuffer = HBufC8::New(listfilesize); //Allocate the buffer CleanupStack::PushL(hBuffer); TPtr8 ptrString = hBuffer->Des(); ; //To hold the buffer // Read from position 0: start of file returnCode = theFile.Read(ptrString); testData.Copy(KBodyTxt); //Copy the test descriptor returnCode=ptrString.Find(testData); //find the test descriptor in the buffer read //from the file if (returnCode > 0) numSuccessful++; returnCode=ptrString.Find(KHexTestHeader); //find the test descriptor in the buffer read if (returnCode == KErrNotFound) numSuccessful++; if (returnCode == KErrNotFound) //Find the error message { returnCode = ptrString.Find(KErrOOM); if (returnCode > 0) User::Leave(KErrNoMemory); } CleanupStack::PopAndDestroy(hBuffer); CleanupStack::PopAndDestroy(); //theFile object if (numSuccessful == 2) return KErrNone; else return KErrGeneral; }
TInt CFloggerTest028_Sync_Binary::DoTestCheckWriteL() { RFile logFile; HBufC8* hBuffer; TInt listfilesize,returnCode; RFs fileSystem; //For file operation create a file system TInt numSuccessful = 0; User::LeaveIfError(fileSystem.Connect()); //Open the file in the read mode User::LeaveIfError(logFile.Open(fileSystem,KFloggerOutputFile,EFileRead)); CleanupClosePushL(logFile); User::LeaveIfError(logFile.Size(listfilesize)); //Size of the file hBuffer = HBufC8::New(listfilesize); //Allocate the buffer CleanupStack::PushL(hBuffer); TPtr8 ptrString = hBuffer->Des(); ; //To access the buffer // Read from position 0: start of file User::LeaveIfError(returnCode = logFile.Read(ptrString)); returnCode = ptrString.Find(KTestMessage8); //find the test descriptor in the buffer read //from the file if (returnCode > 0) { numSuccessful++; } returnCode = ptrString.Find(KStdSubsysTag8); if (returnCode > 0) { numSuccessful++; } returnCode = ptrString.Find(KStdCompTag8); if (returnCode > 0) { numSuccessful++; } CleanupStack::PopAndDestroy(hBuffer); CleanupStack::PopAndDestroy(); //logFile if (numSuccessful ==3) return KErrNone; else return KErrUnknown; }
TInt CFloggerTest017_01::DoTestCheckWriteL() { User::After(KTimeToLog); RFile theFile; HBufC8 * hBuffer; TInt listfilesize; TInt returnCode; RFs fileSystem; //For file operation create a file system _LIT(KLogFile,"c:\\logs\\log.txt"); // the log file path _LIT8(KBodyTxt,"TC 17_1:Test Msg");// First 16 chars of Test body descriptor User::LeaveIfError(fileSystem.Connect()); //Open the file in the read mode User::LeaveIfError(theFile.Open(fileSystem,KLogFile,EFileRead)) ; User::LeaveIfError(returnCode = theFile.Size(listfilesize)); //Size of the file hBuffer = HBufC8::New(listfilesize); //Allocate the buffer CleanupStack::PushL(hBuffer); TPtr8 ptrString = hBuffer->Des(); ; //To hold the buffer // Read from position 0, i.e starting of file returnCode = theFile.Read(ptrString); returnCode = ptrString.Find(KHexTestHeader); //find the test header descriptor in //the buffer read from the file if (returnCode > 0) //The header is present { returnCode = ptrString.Find(KHexTestMargin); //find the test margin descriptor in //the buffer read from the file } if (returnCode > 0) //The margin is present { returnCode = ptrString.Find(KBodyTxt); //find the test descriptor in the //buffer read from the file } theFile.Close(); fileSystem.Close(); //Close the file server CleanupStack::PopAndDestroy(hBuffer); if (returnCode > 0) //The test body descriptor is present return KErrNone; else return KErrNotFound; }
TInt CFloggerTest009_01::DoTestCheckWriteL() { User::After(1000*1000); RFile theFile; HBufC8 * hBuffer; TInt listfilesize; TInt returnCode; RFs fileSystem; //For file operation create a file system TBuf8<256> testData; //To hold the test descriptor _LIT8(KTestMessageOne,"TC 9_01: The value of test integer variable :%d"); testData.Format(KTestMessageOne,100); _LIT8(KOOMError, "#Logs may be lost out of memory!!"); //Error message _LIT(KLogFile,"c:\\logs\\log.txt"); // the log file path User::LeaveIfError(fileSystem.Connect()); //Open the file in the read mode User::LeaveIfError(theFile.Open(fileSystem,KLogFile,EFileRead)); CleanupClosePushL(theFile); User::LeaveIfError(returnCode = theFile.Size(listfilesize)); //Size of the file hBuffer = HBufC8::New(listfilesize); //Allocate the buffer CleanupStack::PushL(hBuffer); TPtr8 ptrString = hBuffer->Des(); ; //To hold the buffer // Read from position 0: start of file returnCode = theFile.Read(ptrString); returnCode = ptrString.Find(testData); //find the test descriptor in the buffer read //from the file if (returnCode == KErrNotFound) //Find the error message { returnCode = ptrString.Find(KOOMError); if (returnCode > 0) User::Leave(KErrNoMemory); } CleanupStack::PopAndDestroy(hBuffer); CleanupStack::PopAndDestroy(); // For theFile object if (returnCode > 0) return KErrNone; else return KErrNotFound; }
TInt CFloggerTest017_05::DoTestCheckWriteL() { User::After(KTimeToLog); RFile theFile; HBufC8 * hBuffer; TInt listfilesize; TInt returnCode; RFs fileSystem; //For file operation create a file system _LIT(KLogFile,"c:\\logs\\log.txt"); // the log file path _LIT8(KExpectedString,"0000 :"); _LIT8(KOOMError, "#Logs may be lost out of memory!!"); //Error message User::LeaveIfError(fileSystem.Connect()); //Open the file in the read mode User::LeaveIfError(theFile.Open(fileSystem,KLogFile,EFileRead)); CleanupClosePushL(theFile); User::LeaveIfError(returnCode = theFile.Size(listfilesize)); //Size of the file hBuffer = HBufC8::New(listfilesize); //Allocate the buffer CleanupStack::PushL(hBuffer); TPtr8 ptrString = hBuffer->Des(); ; //To hold the buffer // Read from position 0: start of file returnCode = theFile.Read(ptrString); //check for no OOM msg returnCode = ptrString.Find(KOOMError); if (returnCode > 0) { User::Leave(KErrNoMemory); } // we expect the output to be pretty blank, so not much to search for // except make sure the standard "0000: " ins't even there returnCode = ptrString.Find(KExpectedString); //find the test descriptor in the buffer read //from the file CleanupStack::PopAndDestroy(hBuffer); CleanupStack::PopAndDestroy(); //theFile object if (returnCode == KErrNotFound) return KErrNone; else return KErrGeneral; }
TInt CFloggerTest025_BuildTestUdeb1::DoTestCheckWriteL() { RFile theFile; HBufC8 * hBuffer; TInt listfilesize; TInt returnCode; RFs fileSystem; //For file operation create a file system User::After(KTimeToLog); User::LeaveIfError(fileSystem.Connect()); //Open the file in the read mode User::LeaveIfError(theFile.Open(fileSystem,KFloggerOutputFile,EFileRead)); CleanupClosePushL(theFile); User::LeaveIfError(returnCode = theFile.Size(listfilesize)); //Size of the file hBuffer = HBufC8::New(listfilesize); //Allocate the buffer CleanupStack::PushL(hBuffer); TPtr8 ptrString = hBuffer->Des(); ; //To hold the buffer // Read from position 0: start of file returnCode = theFile.Read(ptrString); if (returnCode == KErrNone) returnCode = ptrString.Find(KTestMessage8); //find the test descriptor in the buffer read //from the file CleanupStack::PopAndDestroy(hBuffer); CleanupStack::PopAndDestroy(); // For theFile object if (returnCode > 0) return KErrNone; else return KErrGeneral; }
TInt CFloggerTest017_02::DoTestCheckWriteL() { User::After(KTimeToLog); RFile theFile; HBufC8 * hBuffer; TInt listfilesize; TInt returnCode; RFs fileSystem; //For file operation create a file system TBuf8<256> testData; //To hold the test descriptor _LIT(KLogFile,"c:\\logs\\log.txt"); // the log file path _LIT8(KOOMError, "#Logs may be lost out of memory!!"); // Error message User::LeaveIfError(fileSystem.Connect()); //Open the file in the read mode User::LeaveIfError(theFile.Open(fileSystem,KLogFile,EFileRead)); CleanupClosePushL(theFile); User::LeaveIfError(returnCode = theFile.Size(listfilesize)); //Size of the file hBuffer = HBufC8::New(listfilesize); //Allocate the buffer CleanupStack::PushL(hBuffer); TPtr8 ptrString = hBuffer->Des(); ; //To hold the buffer // Read from position 0: start of file returnCode = theFile.Read(ptrString); testData.FillZ(); testData.Copy(KEightSpaces8); //Copy the test descriptor returnCode = ptrString.Find(testData); //find the test descriptor in the buffer read //from the file if (returnCode == KErrNotFound) // Check for the error message in the log { returnCode = ptrString.Find(KOOMError); if (returnCode > 0) User::Leave(KErrNoMemory); } CleanupStack::PopAndDestroy(hBuffer); CleanupStack::PopAndDestroy(); //theFile if (returnCode > 0) return KErrNone; else return KErrGeneral; }
TReal CGpsDataHandler::ParseCoordinateData() { TPtr8 pBuffer = iBuffer->Des(); TReal aAngle; TReal aResult = 0.0; TInt aFindResult; aFindResult = pBuffer.Find(_L8(",")); if(aFindResult != KErrNotFound) { HBufC8* aField = HBufC8::NewL(aFindResult); CleanupStack::PushL(aField); TPtr8 pField = aField->Des(); pField.Copy(pBuffer.Ptr(), aFindResult); pBuffer.Delete(0, aFindResult+1); TLex8 aFieldLex(pField.Ptr()); if(aFieldLex.Val(aAngle, '.') == KErrNone) { TInt32 aDegrees; Math::Int(aDegrees, aAngle / 100.0); TInt32 aMinutes; Math::Int(aMinutes, aAngle - aDegrees * 100); TReal aDecimal; Math::Frac(aDecimal, aAngle); aResult = aDegrees + (aMinutes + aDecimal) / 60.0; if(pBuffer[0] == TUint('S') || pBuffer[0] == TUint('W')) { aResult = -aResult; } aFindResult = pBuffer.Find(_L8(",")); if(aFindResult != KErrNotFound) { pBuffer.Delete(0, aFindResult+1); } } CleanupStack::PopAndDestroy(); } return aResult; }
TInt CFloggerTest007_02::DoTestCheckWriteL() { User::After(KTimeToLog); RFile theFile; HBufC8 * hBuffer; TInt listfilesize,returnCode; RFs fileSystem; //For file operation create a file system TBuf8<256> testData; //To hold the test descriptor _LIT(KLogFile,"c:\\logs\\log.txt"); // log file name and path //The following contains the string of length 200(max) //which is written to the log file //_LIT(KTestLongMessage, "This is the long message This is the long message This is the long message This is the long message This is the long message This is the long message This is the long message This is the long message"); _LIT(KTestLongMessage, "TC 7_02: This is the long message This is the long message This is the long message This is the long message This is the long message This is the long message This is the long message This is the long"); //_LIT8(KOOMError, "#Logs may be lost out of memory!!"); User::LeaveIfError(fileSystem.Connect()); //Open the file in the read mode User::LeaveIfError(theFile.Open(fileSystem,KLogFile,EFileRead)); CleanupClosePushL(theFile); User::LeaveIfError(theFile.Size(listfilesize)); //Size of the file hBuffer = HBufC8::New(listfilesize); //Allocate the buffer CleanupStack::PushL(hBuffer); TPtr8 ptrString = hBuffer->Des(); ; //To hold the buffer // Read from position 0: start of file User::LeaveIfError(returnCode = theFile.Read(ptrString)); testData.Copy(KTestLongMessage); //Copy the test descriptor returnCode = ptrString.Find(testData); //find the test descriptor in the buffer read //from the file CleanupStack::PopAndDestroy(hBuffer); CleanupStack::PopAndDestroy(); //theFile if (returnCode > 0) return KErrNone; else return KErrGeneral; }
TInt CFloggerTest012_02::DoTestCheckWriteL() { User::After(KTimeToLog); RFile theFile; HBufC8 * hBuffer; TInt listfilesize; TInt returnCode; RFs fileSystem; //For file operation create a file system TBuf8<256> testData; //To hold the test descriptor _LIT(KLogFile, "c:\\logs\\log.txt"); // log file name and path _LIT8(KTestMessageTwo,"TEST 12.02: The value of first test integer variable :%d The value of second test integer variable : %d"); testData.Format(KTestMessageTwo,100, 200); User::LeaveIfError(fileSystem.Connect()); //Open the file in the read mode User::LeaveIfError(theFile.Open(fileSystem,KLogFile,EFileRead)); returnCode = theFile.Size(listfilesize); //Size of the file hBuffer = HBufC8::New(listfilesize); //Allocate the buffer CleanupStack::PushL(hBuffer); TPtr8 ptrString = hBuffer->Des(); ; //To hold the buffer // Read from position 0: start of file returnCode = theFile.Read(ptrString); returnCode = ptrString.Find(testData); //find the test descriptor in the buffer read //from the file theFile.Close(); fileSystem.Close(); CleanupStack::PopAndDestroy(hBuffer); if (returnCode > 0) return KErrNone; else return KErrGeneral; }
/** CountLinesOfHtmlL() Counts the number of lines of HTML @param aEntry A reference to an object representing the email @return Number of lines of HTML */ TInt CT_MsgComparePopEmailMsgs::CountLinesOfHtmlL(CMsvEntry& aEntry) { TInt lines = 0; aEntry.SetEntryL(aEntry.EntryId()); CMsvStore* store = aEntry.ReadStoreL(); CleanupStack::PushL(store); MMsvAttachmentManager& attManager = store->AttachmentManagerL(); RFile htmlFile = attManager.GetAttachmentFileL(0); CleanupClosePushL(htmlFile); _LIT8(KFindData, "\r\n"); TInt htmlSize = 0; User::LeaveIfError(htmlFile.Size(htmlSize)); HBufC8* fBuf = HBufC8::NewLC(htmlSize); TPtr8 p = fBuf->Des(); htmlFile.Read(p); TInt pos = 0; for(;;) { pos = p.Find(KFindData); if(pos < 0) { break; } p = p.Mid(pos+2); lines++; } CleanupStack::PopAndDestroy(fBuf); CleanupStack::PopAndDestroy(); // htmlFile CleanupStack::PopAndDestroy(store); return lines; }
TInt CFloggerTest028_Sync_Static_WriteFormatVUni::DoTestCheckWriteL() { RFile logFile; HBufC8* hBuffer; TInt listfilesize,returnCode; RFs fileSystem; //For file operation create a file system TBuf8<KTestMessageSize> testData; //To hold the test descriptor User::LeaveIfError(fileSystem.Connect()); //Open the file in the read mode User::LeaveIfError(logFile.Open(fileSystem,KFloggerOutputFile,EFileRead)); CleanupClosePushL(logFile); User::LeaveIfError(logFile.Size(listfilesize)); //Size of the file hBuffer = HBufC8::New(listfilesize); //Allocate the buffer CleanupStack::PushL(hBuffer); TPtr8 ptrString = hBuffer->Des(); ; //To access the buffer // Read from position 0: start of file User::LeaveIfError(returnCode = logFile.Read(ptrString)); testData.Copy(KTestMessageOneParamExpected); //Copy the test descriptor returnCode = ptrString.Find(testData); //find the test descriptor in the buffer read //from the file CleanupStack::PopAndDestroy(hBuffer); CleanupStack::PopAndDestroy(); //logFile if (returnCode > 0) return KErrNone; else return KErrNotFound; }
TInt CFloggerTest028_Sync_ConMultiple::DoTestCheckWriteL() { RFile logFile; HBufC8* hBuffer; TInt listfilesize,returnCode; RFs fileSystem; //For file operation create a file system TInt numSuccessful = 0; User::LeaveIfError(fileSystem.Connect()); //Open the file in the read mode User::LeaveIfError(logFile.Open(fileSystem,KFloggerOutputFile,EFileRead)); CleanupClosePushL(logFile); User::LeaveIfError(logFile.Size(listfilesize)); //Size of the file hBuffer = HBufC8::New(listfilesize); //Allocate the buffer CleanupStack::PushL(hBuffer); TPtr8 ptrString = hBuffer->Des(); //To access the buffer // Read from position 0: start of file User::LeaveIfError(returnCode = logFile.Read(ptrString)); returnCode = ptrString.Find(KTestMessage8); //find the test descriptor in the buffer read //from the file if (returnCode > 0) { numSuccessful++; } returnCode = ptrString.Find(KTestMessageOneParamExpected); if (returnCode > 0) { numSuccessful++; } TPtrC8 ptrStringOffsetForSearching = ptrString.Right((ptrString.Length()-returnCode)-KTestMessageOneParamExpected().Length()); returnCode = ptrStringOffsetForSearching.Find(KTestMessageOneParamExpected); //find the next occurance if (returnCode > 0) { numSuccessful++; } returnCode = ptrString.Find(KTestTooLongExpectedMessage); if (returnCode > 0) { numSuccessful++; } returnCode = ptrString.Find(KTestTooLongMessageOneParamExpected); if (returnCode > 0) { numSuccessful++; } // we don't check that all the binary data is there - just that the file is nice and long if ( listfilesize > K1KilobyteOfDataSize) { numSuccessful++; } CleanupStack::PopAndDestroy(hBuffer); CleanupStack::PopAndDestroy(); //logFile if ( numSuccessful == 6 ) return KErrNone; else return KErrUnknown; }
// --------------------------------------------------------- // CNSmlDsProvisioningAdapter::StoreAttributesL // --------------------------------------------------------- void CNSmlDsProvisioningAdapter::StoreAttributesL( const TDesC& aType ) { _DBG_FILE("CNSmlDsProvisioningAdapter::StoreAttributesL(): begin"); TInt iDataProvElementCount = iProfiles[iProfiles.Count()-1]->iDataProvElement.Count()-1; // Leave if aType cannot be assigned if( ( aType.Length() > 0 ) && ( iProfiles[iProfiles.Count()-1]->iDataProvElement[iDataProvElementCount]->iRemoteDBUri ) ) { TBool dataProvIdFoundInZ = FALSE; TSmlDataProviderId firstDataProvIdFound = 0; TSmlDataProviderId uidFound = 0; TBool doSearch = ETrue; if ( aType.FindF( KXVcardMimeType ) != KErrNotFound ) { if ( IsOperatorProfile( *iProfiles[iProfiles.Count()-1] ) ) { const CNSmlDsProfileElement& profile = *iProfiles[iProfiles.Count()-1]; StoreOperatorUrlL( *profile.iHostAddress ); // Do not make a search through adapter implementations doSearch = EFalse; uidFound = OperatorAdapterUid(); if ( !uidFound ) { // If OperatorAdapterUid returns 0, do a search doSearch = ETrue; } } } // look through every implementation adapter until one found // which supports MIME type in question // The first one located in ROM is chosen. If none found in ROM then // the first adapter found is chosen. HBufC8 *type = HBufC8::NewLC(aType.Size()); TPtr8 typePtr = type->Des(); CnvUtfConverter::ConvertFromUnicodeToUtf8( typePtr, aType); // get list of dataproviderIds RImplInfoPtrArray implArray; CleanupStack::PushL( PtrArrCleanupItemRArr( CImplementationInformation, &implArray ) ); TUid ifUid = { KNSmlDSInterfaceUid }; REComSession::ListImplementationsL( ifUid, implArray ); if ( doSearch ) { TInt countProviders = implArray.Count(); for( TInt i = 0; i < countProviders; i++ ) { CImplementationInformation* implInfo = implArray[i]; RSyncMLDataProvider dataProvider; dataProvider.OpenL( iSession, implInfo->ImplementationUid().iUid ); CleanupClosePushL( dataProvider ); TInt mimeTypeCount = dataProvider.MimeTypeCount(); for( TInt j = 0; j < mimeTypeCount; j++ ) { HBufC* mimeType = dataProvider.MimeType( j ).AllocLC(); TPtrC8 convMimeType = ConvertTo8LC( *mimeType ); if( typePtr.Find( convMimeType ) == 0) { // MIME type in question was found uidFound = implInfo->ImplementationUid().iUid; if( firstDataProvIdFound == 0 ) { // save the first in case of none found from ROM firstDataProvIdFound = uidFound; } // check whether the provider is located in ROM (drive Z) if( implInfo->Drive() == EDriveZ ) { dataProvIdFoundInZ = TRUE; } } CleanupStack::PopAndDestroy(2); // mimetype, ConvertTo8LC if( uidFound ) { break; } } CleanupStack::PopAndDestroy(); // dataProvider if ( dataProvIdFoundInZ ) { break; } else { uidFound = firstDataProvIdFound; } } } REComSession::FinalClose(); CleanupStack::PopAndDestroy( 2 ); // type, implArray if( uidFound ) { iProfiles[iProfiles.Count()-1]->iDataProvElement[iDataProvElementCount]->iUid = uidFound; } } _DBG_FILE("CNSmlDsProvisioningAdapter::StoreAttributesL(): end"); }
void CIniFileParser::DoParseIniFileL(TDesC& aIniFile) /* * * The force flush state is only updated if it is not already set to something other * than ENoValue. If force flush option is not found in ini file, force flush is set * to off. */ { TInt fileLength; TInt ret = KErrNone; RFile iniFile; // Open file User::LeaveIfError(iniFile.Open(iFs, aIniFile, EFileShareAny)); CleanupClosePushL(iniFile); // as we have been able to open the file, set the media to default. // If the ini file is parsed correctly, this then gets overwritten. // Otherwise the caller should pass thru a mesg to get the default enabled. if (iLoggingMediaString.Length() == 0) { iLoggingMediaString = KDefaultMedia; } User::LeaveIfError(iniFile.Size(fileLength)); HBufC8* iniContents = HBufC8::NewLC(fileLength); TPtr8 hbufPtr = iniContents->Des(); User::LeaveIfError(iniFile.Read(hbufPtr)); TLex8 lex(*iniContents); //OK, file is open and ready for parsing. Make a tempory array and if there is a //problem in the ini file leave settings as they were, leave, and //the error will get picked up. delete iIniSettings; iIniSettings = NULL; CIniLoggingPairs* iniSettings = CIniLoggingPairs::NewL(); CleanupStack::PushL(iniSettings); TNameTag tempTag; TNameTag tempTag2; TChar tempChar; FOREVER { ret = GetNextTokenAndCheck(lex,hbufPtr); if (ret != KErrNone) { break; } if (hbufPtr.Find(KCommentKeyword)!=KErrNotFound) //found a Comment { tempChar = lex.Get(); while (!lex.Eos() && TUint(tempChar) != KCarriageReturn && TUint(tempChar) != KLineFeed) { tempChar = lex.Get(); } } else if (hbufPtr.CompareF(KMediaKeyword)==0) //MediaSetting { User::LeaveIfError(GetNextTokenAndCheck(lex,hbufPtr)); if (hbufPtr.Length()>KMaxMediaStringLength) { User::Leave(KErrGeneral); } iLoggingMediaString = hbufPtr; } else if (hbufPtr.CompareF(KLogKeyword)==0) //LOG { User::LeaveIfError(GetNextTokenAndCheck(lex,hbufPtr)); if (hbufPtr.Length()>KMaxTagLength) { tempTag = hbufPtr.Left(KMaxTagLength); } else { tempTag = hbufPtr; } User::LeaveIfError(GetNextTokenAndCheck(lex,hbufPtr)); if (hbufPtr.Length()>KMaxTagLength) { tempTag2 = hbufPtr.Left(KMaxTagLength); } else { tempTag2 = hbufPtr; } iniSettings->AddSettingL(tempTag, tempTag2); } else if (hbufPtr.CompareF(KForceFlushKeyword)==0) //ForceFlush { if (iForceFlushState == ENoValue) { iForceFlushState = EFlushOn; } } else if (hbufPtr.CompareF(KLogPathKeyword) == 0) //LogPath { User::LeaveIfError(GetNextTokenAndCheck(lex,hbufPtr)); if (hbufPtr.Length()>KMaxName) { User::Leave(KErrOverflow); } iLoggingPathString.Copy(hbufPtr); } else if (hbufPtr.CompareF(KWin32DbgPortKeyword)==0) //Win32DebugPort { iWin32DebugEnabled = ETrue; } else User::Leave(KErrBadName); if (lex.Eos()) { break; } } iIniSettings = iniSettings; CleanupStack::Pop(iniSettings); CleanupStack::PopAndDestroy(); //iniContents CleanupStack::PopAndDestroy(); //iniFile if (iForceFlushState == ENoValue) { iForceFlushState = EFlushOff; } }
void CGpsDataHandler::ProcessData() { TPtr8 pBuffer = iBuffer->Des(); // Check sentence is complete if(pBuffer[0] != TUint('$')) { // Burn invalid data pBuffer.Delete(0, 1); iEngineStatus = EGpsReading; iSocket.Recv(iChar, 0, iStatus); SetActive(); } else if(pBuffer[pBuffer.Length()-1] == TUint('\n')) { // Sentence is complete TInt aStartField; TInt aFindResult; // Ready to parse data if(pBuffer.Find(_L8("$GPGLL")) != KErrNotFound) { aStartField = 1; } else if(pBuffer.Find(_L8("$GPGGA")) != KErrNotFound) { aStartField = 2; } else if(pBuffer.Find(_L8("$GPRMC")) != KErrNotFound) { aStartField = 3; } else { pBuffer.Zero(); iEngineStatus = EGpsReading; iSocket.Recv(iChar, 0, iStatus); SetActive(); return; } // Burn useless data for(TInt i = 0;i < aStartField;i++) { aFindResult = pBuffer.Find(_L8(",")); if(aFindResult != KErrNotFound) { pBuffer.Delete(0, aFindResult+1); } } // Read latitude TReal aLatitude = ParseCoordinateData(); TReal aLongitude = ParseCoordinateData(); pBuffer.Zero(); if(aLatitude != 0.0 || aLongitude != 0.0) { iObserver->GpsData(aLatitude, aLongitude, 10.0); iSocket.Close(); iSocketServ.Close(); iEngineStatus = EGpsDisconnected; } } else { iEngineStatus = EGpsReading; iSocket.Recv(iChar, 0, iStatus); SetActive(); } }
TInt CFloggerTest028_Sync_Static_Multiple2::DoTestCheckWriteL() { RFile logFile; HBufC8* hBuffer; TInt listfilesize,returnCode; RFs fileSystem; //For file operation create a file system TInt numSuccessful = 0; User::LeaveIfError(fileSystem.Connect()); //Open the file in the read mode User::LeaveIfError(logFile.Open(fileSystem,KFloggerOutputFile,EFileRead)); CleanupClosePushL(logFile); User::LeaveIfError(logFile.Size(listfilesize)); //Size of the file hBuffer = HBufC8::New(listfilesize); //Allocate the buffer CleanupStack::PushL(hBuffer); TPtr8 ptrString = hBuffer->Des(); //To access the buffer // Read from position 0: start of file User::LeaveIfError(returnCode = logFile.Read(ptrString)); // the test case writes 5 elements 100 times, but we only check these things: // 1. that the long test message with one parameter is written 100 times // 2. that the test message with one param is written 100 times // 3. that the end of test message has been written TPtrC8 ptrStringOffsetForSearching; returnCode = ptrString.Find(KTestMessageOneParamExpected); if (returnCode > 0) { numSuccessful++; } TInt newLength; // allow length to be watched during debugging TInt loop; ptrStringOffsetForSearching.Set(ptrString.Right((ptrString.Length()-returnCode)-KTestMessageOneParamExpected().Length())); for (loop=0; loop < KMultipleWriteStressTimes; loop++) { returnCode = ptrStringOffsetForSearching.Find(KTestMessageOneParamExpected); //find the next occurance if (returnCode > 0) { numSuccessful++; } newLength = ptrStringOffsetForSearching.Length() - returnCode - KTestMessageOneParamExpected().Length(); if (newLength < 0) { User::Leave(KErrUnknown); } ptrStringOffsetForSearching.Set(ptrStringOffsetForSearching.Right(newLength)); } returnCode = ptrString.Find(KTestTooLongMessageOneParamExpected); if (returnCode > 0) { numSuccessful++; } newLength = ptrString.Length()-returnCode-KTestTooLongMessageOneParamExpected().Length(); ptrStringOffsetForSearching.Set(ptrString.Right(newLength)); for (loop=0; loop < KMultipleWriteStressTimes; loop++) { returnCode = ptrStringOffsetForSearching.Find(KTestTooLongMessageOneParamExpected); //find the next occurance if (returnCode > 0) { numSuccessful++; } if (loop < (KMultipleWriteStressTimes - 1)) { newLength = ptrStringOffsetForSearching.Length() - returnCode - KTestTooLongMessageOneParamExpected().Length(); if (newLength < 0) { User::Leave(KErrUnknown); } ptrStringOffsetForSearching.Set(ptrStringOffsetForSearching.Right(newLength)); } } returnCode = ptrString.Find(KTestEndMessage8); if (returnCode > 0) { numSuccessful++; } CleanupStack::PopAndDestroy(hBuffer); CleanupStack::PopAndDestroy(); //logFile if ( numSuccessful == 201 ) return KErrNone; else return KErrUnknown; }
TInt CFloggerTest028_Sync_ConMultiple2::DoTestCheckWriteL() { RFile logFile; HBufC8* hBuffer; TInt listfilesize,returnCode; RFs fileSystem; //For file operation create a file system TInt numSuccessful = 0; TInt loop = 0; User::LeaveIfError(fileSystem.Connect()); //Open the file in the read mode User::LeaveIfError(logFile.Open(fileSystem,KFloggerOutputFile,EFileRead)); CleanupClosePushL(logFile); User::LeaveIfError(logFile.Size(listfilesize)); //Size of the file hBuffer = HBufC8::New(listfilesize); //Allocate the buffer. This is about 176K in size CleanupStack::PushL(hBuffer); TPtr8 ptrString = hBuffer->Des(); //To access the buffer // Read from position 0: start of file User::LeaveIfError(returnCode = logFile.Read(ptrString)); // the test case writes 6 elements 100 times, but we only check these things: // 1. that the test message with one parameter is written 100 times // 2. that the long message is written 100 times // 3. that the end of test message has been written // 4. that the file is suitably big enough to be expected to contain the // 1K data segment 100 times in it. TPtrC8 ptrStringOffsetForSearching; returnCode = ptrString.Find(KTestMessageOneParamExpected); if (returnCode > 0) { numSuccessful++; } TInt newLength; ptrStringOffsetForSearching.Set(ptrString.Right((ptrString.Length()-returnCode)-KTestMessageOneParamExpected().Length())); for (loop=0; loop < KMultipleWriteStressTimes; loop++) { returnCode = ptrStringOffsetForSearching.Find(KTestMessageOneParamExpected); //find the next occurance if (returnCode > 0) { numSuccessful++; } newLength = ptrStringOffsetForSearching.Length() - returnCode - KTestMessageOneParamExpected().Length(); if (newLength < 0) { User::Leave(KErrUnknown); } ptrStringOffsetForSearching.Set(ptrStringOffsetForSearching.Right(newLength)); } returnCode = ptrString.Find(KTestTooLongExpectedMessage); if (returnCode > 0) { numSuccessful++; } ptrStringOffsetForSearching.Set(ptrString.Right((ptrString.Length()-returnCode)-KTestTooLongExpectedMessage().Length())); for (loop=0; loop < KMultipleWriteStressTimes; loop++) { returnCode = ptrStringOffsetForSearching.Find(KTestTooLongExpectedMessage); //find the next occurance if (returnCode > 0) { numSuccessful++; } newLength = ptrStringOffsetForSearching.Length() - returnCode - KTestTooLongExpectedMessage().Length(); if (newLength <0) { User::Leave(KErrUnknown); } ptrStringOffsetForSearching.Set(ptrStringOffsetForSearching.Right(newLength)); } returnCode = ptrString.Find(KTestEndMessage8); if (returnCode > 0) { numSuccessful++; } // we don't check that all the binary data is there - just that the file is nice and long if ( listfilesize > (K1KilobyteOfDataSize * KMultipleWriteStressTimes)) { numSuccessful++; } CleanupStack::PopAndDestroy(hBuffer); CleanupStack::PopAndDestroy(); //logFile if ( numSuccessful == 202 ) return KErrNone; else return KErrUnknown; }
TInt CFloggerTest028_Sync_Static_Multiple::DoTestCheckWriteL() { RFile logFile; HBufC8* hBuffer; TInt listfilesize,returnCode; RFs fileSystem; //For file operation create a file system TInt numSuccessful = 0; User::LeaveIfError(fileSystem.Connect()); //Open the file in the read mode User::LeaveIfError(logFile.Open(fileSystem,KFloggerOutputFile,EFileRead)); CleanupClosePushL(logFile); User::LeaveIfError(logFile.Size(listfilesize)); //Size of the file hBuffer = HBufC8::New(listfilesize); //Allocate the buffer CleanupStack::PushL(hBuffer); TPtr8 ptrString = hBuffer->Des(); //To access the buffer // Read from position 0: start of file User::LeaveIfError(returnCode = logFile.Read(ptrString)); returnCode = ptrString.Find(KTestMessage8); //find the test descriptor in the buffer read //from the file if (returnCode > 0) { numSuccessful++; } returnCode = ptrString.Find(KTestTooLongMessageOneParamExpected); if (returnCode > 0) { numSuccessful++; } // search for the occurance that the VA_LIST put in // when testing serial, the length will be negative, so skip TInt len; len = (ptrString.Length()-returnCode)-KTestTooLongMessageOneParamExpected().Length(); if (len > 0) { TPtrC8 ptrStringOffsetForSearching = ptrString.Right(len); returnCode = ptrStringOffsetForSearching.Find(KTestTooLongMessageOneParamExpected); //find the next occurance if (returnCode > 0) { numSuccessful++; } } returnCode = ptrString.Find(KTestMessageOneParamExpected); if (returnCode > 0) { numSuccessful++; } returnCode = ptrString.Find(KTestMessageAsHex8); if (returnCode > 0) { numSuccessful++; } CleanupStack::PopAndDestroy(hBuffer); CleanupStack::PopAndDestroy(); //logFile if ( numSuccessful == 5 ) return KErrNone; else return KErrUnknown; }