/** Test MSdpElementBuilder::BuildUnknownL() */ void CT_DataSdpElementBuilder::DoCmdBuildUnknownL(MSdpElementBuilder& aElementBuilder, const TDesC& aSection) { TInt theValue; if( iDataWrapper.GetIntFromConfig(aSection, KType(), theValue) ) { TUint8 type = theValue; if( iDataWrapper.GetIntFromConfig(aSection, KSizeDesc(), theValue) ) { TUint8 sizeDesc = theValue; TPtrC theString; if( iDataWrapper.GetStringFromConfig(aSection, KData(), theString) ) { HBufC8* theString8 = HBufC8::NewLC(theString.Length()); theString8->Des().Copy(theString); TPtrC8 stringPtr=theString8->Des(); TRAPD(err, aElementBuilder.BuildUnknownL(type, sizeDesc, stringPtr)); if(err != KErrNone) { iDataWrapper.ERR_PRINTF2(_L("MSdpElementBuilder BuildUnknownL failed with error %d"), err); iDataWrapper.SetError(err); } CleanupStack::PopAndDestroy(theString8); } else { iDataWrapper.ERR_PRINTF2(_L("Missing parameter %S"), &KData()); iDataWrapper.SetBlockResult(EFail); } } else { iDataWrapper.ERR_PRINTF2(_L("Missing parameter %S"), &KData()); iDataWrapper.SetBlockResult(EFail); } } else { iDataWrapper.ERR_PRINTF2(_L("Missing parameter %S"), &KData()); iDataWrapper.SetBlockResult(EFail); } }
HBufC8 *CemailTest::GetNextStringLC ( CStifItemParser& aItem, const TDesC &aName ) { TPtrC nodename; nodename.Set( KNullDesC ); TInt i( aItem.GetNextString ( nodename ) ); if ( i != KErrNone ) { iLog->Log( _L( "ERROR Reading '%S' argument: 0x%X" ), &aName, i ); } else { iLog->Log( _L("%S: %S"), &aName, &nodename); } HBufC8 *buf = HBufC8::NewLC( nodename.Length() ) ; buf->Des().Copy( nodename ); return buf; }
//Util function void CTestIfioctls::ReadStringParam(char* aString) { _LIT( KSl, "Param%d" ); TBuf<8> pNameBuf; TPtrC string; pNameBuf.Format(KSl,++iParamCount); TBool res = GetStringFromConfig(ConfigSection(), pNameBuf, string); if(!res) { _LIT(Kerr , "Unable to retrieve string parameter") ; INFO_PRINTF1(Kerr); } TBuf8<256> bufstring; bufstring.Copy(string); TInt paramLength=string.Length(); char* text=(char *)(bufstring.Ptr()); *(text+paramLength)='\0'; strcpy(aString,text); return; }
void CPreviewPopUpContent::SetTextL(const TDesC& aFirstText, const TDesC& aSecondText, const TDesC& aThirdText) { TBuf<256> wrappedText; AknTextUtils::WrapToStringL(aSecondText, *iStringLengths, *iLabelContainer[1].iLabel->Font(), wrappedText); iLabelContainer[0].iLabel->SetTextL(aFirstText); iLabelContainer[0].iLabel->CropText(); _LIT(KNewLine, "\n"); TInt pos = wrappedText.Find(KNewLine); if (pos != KErrNotFound) { TPtrC leftText = wrappedText.Left(pos); iLabelContainer[1].iLabel->SetTextL(leftText); TPtrC rightText = wrappedText.Mid(pos + 1); if (rightText.Length() < 1) { // WrapToStringL always seems to add a newline so we need to // check for length as well. iLabelContainer[2].iLabel->SetTextL(aThirdText); iLabelContainer[2].iLabel->CropText(); iLabelContainer[3].iLabel->SetTextL(KDefaultText); } else { iLabelContainer[2].iLabel->SetTextL(rightText); iLabelContainer[2].iLabel->CropText(); iLabelContainer[3].iLabel->SetTextL(aThirdText); iLabelContainer[3].iLabel->CropText(); } } else { // WrapToStringL didnt add a newline (we dont need to wrap) but it // seems WrapToStringL always adds newline (see above comment). iLabelContainer[1].iLabel->SetTextL(aSecondText); iLabelContainer[2].iLabel->SetTextL(aThirdText); iLabelContainer[2].iLabel->CropText(); iLabelContainer[3].iLabel->SetTextL(KDefaultText); } //iLabel->SetRect(iLabelRect); //iLabel->DrawDeferred(); }
/** Return the end of the paragraph - after the paragraph separator if any. */ EXPORT_C TInt MTmSource::ParagraphEnd(TInt aPos) const { TInt doc_end = DocumentLength(); TPtrC text; TTmCharFormat format; while (aPos < doc_end) { GetText(aPos,text,format); const TText *p = text.Ptr(); const TText *q = p + text.Length(); while (p < q) if (*p == CEditableText::EParagraphDelimiter) return aPos + 1; else { p++; aPos++; } } return doc_end + 1; }
/** Copies the content of a text column, identified by aColumnIndex, to the place refered by aDest parameter. If the destination buffer is not big enough, the function will copy as much data as possible and will return KErrOverflow. @param aColumnIndex Column index @param aDest Refers to the place where the column data will be copied. @return KErrNone, if the function completes successfully, otherwise one of the other system-wide error codes. @panic SqlDb 5 Column index out of bounds. @panic SqlDb 11 Statement cursor not positioned on a row */ TInt CSqlStatementImpl::ColumnText(TInt aColumnIndex, TDes& aDest) { __ASSERT_ALWAYS((TUint)aColumnIndex < (TUint)iColumnCnt, __SQLPANIC(ESqlPanicBadColumnIndex)); __ASSERT_ALWAYS(iState == CSqlStatementImpl::EAtRow, __SQLPANIC(ESqlPanicInvalidRow)); iColumnValBufIt.MoveTo(aColumnIndex); TInt err = KErrNone; //The text column value has not been transferred to the client side if its length is >= KSqlMaxDesLen characters. //In this case an additional call to the server is made to get the column value. if(!iColumnValBufIt.IsPresent()) { if(iColumnValBufIt.Type() != ESqlText) { aDest.Zero(); return err; } TPtr8 ptr(reinterpret_cast <TUint8*> (const_cast <TUint16*> (aDest.Ptr())), aDest.MaxLength() * sizeof(TUint16)); err = iSqlStmtSession.ReadColumnValue(aColumnIndex, ptr); switch(err) { case KErrNone: case KErrOverflow: aDest.SetLength(ptr.Length() / sizeof(TUint16)); break; default: break; } } else { TPtrC src = iColumnValBufIt.Text(); TInt len = src.Length(); if(len > aDest.MaxLength()) { len = aDest.MaxLength(); err = KErrOverflow; } aDest.Copy(src.Ptr(), len); } return err; }
// --------------------------------------------------------- // CMailToHandler::FieldEnd() // --------------------------------------------------------- // TInt CMailToHandler::FieldEnd(const TDesC& aHeader) { CLOG_ENTERFN( "CMailToHandler::FieldEnd()" ); TPtrC path = iParsedUrl->Des(); TInt length = path.Length(); // length of the scheme TInt retVal = length; TInt startPos = FieldStart( aHeader ); if( IsHeader( aHeader ) ) { TInt temp = GetNextField( startPos ); /* we need to subtract 1 if the result is not equal to length because of the & or ? */ retVal = ( temp == length ) ? length : ( temp - 1); } CLOG_LEAVEFN( "CMailToHandler::FieldEnd()" ); return retVal; }
TInt CCmdExit::ProcessL(const TDesC &aCommand) { // Complete the test machine - will then get the next cmd Machine()->CompleteRequest(); TPtrC param; TRAPD(error, param.Set(ParamsL(aCommand))); if (error != KErrNone ) return Error(error, TFR_KFmtErrBadCmd, &Keyphrase()); TLex parse( param ); if (!parse.Eos() && !parse.Peek().IsSpace()) return Error( error, TFR_KFmtErrBadCmd, &Keyphrase()); // Print out param if any and stop. param.Set( TfrLex::Peel(param)); if (param.Length() > 0) Print(param); Machine()->StopEngine(); return error; }
/** Compare the various character sets @test */ void CTestHtmlToCrtConverterBufferStep::ComparisonForVariousCharsetsL() { // Get different character sets from the ini file TPtrC sourceData; GetStringFromConfig(ConfigSection(), KSourceText, sourceData); HBufC8* tempSource = HBufC8::NewLC(sourceData.Length()); tempSource->Des().Copy(sourceData); TPtr8 source(tempSource->Des()); // Compare the source text with the text converted by the characterset converter if ( DoComparisonL(source) == 0 ) { INFO_PRINTF1(KInfoComparisionSuccessful); } else { ERR_PRINTF1(KErrInComparison); SetTestStepResult(EFail); } CleanupStack::PopAndDestroy(tempSource); }
// ----------------------------------------------------------------------------- // CLandmarksModel::FormatListItemLC // Formats a list item to the following format "X\tlandmarkName\t" // where X = icon index // (other items were commented in a header). // ----------------------------------------------------------------------------- // HBufC* CLandmarksModel::FormatListItemLC(CPosLandmark& aLandmark) { // Extract name TPtrC name; aLandmark.GetLandmarkName(name); // 10 extra chars for icon index and column separator const TInt KExtraChars = 10; HBufC* formattedNameBuf = HBufC::NewLC(name.Length() + KExtraChars); TPtr formattedNamePtr = formattedNameBuf->Des(); // Extract icon info TPtrC mbmIconFile; TInt iconIndex, maskIndex; TInt res = aLandmark.GetIcon(mbmIconFile, iconIndex, maskIndex); // Format list item if (res == KErrNone) { // Create icon and append it to icon array. TRAPD(err, AppendIconL(mbmIconFile, iconIndex, maskIndex)); if (err == KErrNone) { // Append the array index where the icon is appended formattedNamePtr.AppendNum(iIconList->Count() - 1); } else { formattedNamePtr.AppendNum(KDefaultIconIndex); } } else // res == KErrNotFound { formattedNamePtr.AppendNum(KDefaultIconIndex); } formattedNamePtr.Append(KTab); formattedNamePtr.Append(name); return formattedNameBuf; }
// --------------------------------------------------------- // CWtaiHandler::GetParameterCountL() // --------------------------------------------------------- // TInt CWtaiHandler::GetParameterCountL() { CLOG_ENTERFN( "CWtaiHandler::GetParameterCount()" ); // wtai://<library>/<function> (; <parameter>)* TInt retVal = 0; TPtrC path = RemoveSchemeFromUrlL( KWtai ); TInt length = path.Length(); /* Count for the amount of parameter */ for( TInt i = 0; i < length; i++ ) { if( path[i] == KSemiColon ) { retVal++; } } CLOG_LEAVEFN( "CWtaiHandler::GetParameterCount()" ); return retVal; }
int main() { int retval =ESuccess; wchar_t* mywcharstring = L"Hello Widechar String"; int wchar_length= wcslen(mywcharstring); TPtrC myTptrc; retval = WcharpToTptrc16(mywcharstring, myTptrc); int buf_len = myTptrc.Length(); if (retval ==ESuccess &&\ wchar_length == buf_len ) { printf("wcharptotptrc16 boundary1 Passed\n"); } else { assert_failed = true; printf("wcharptotptrc16 boundary1 Failed\n"); } testResultXml("test_wcharptotptrc16_boundary1"); return 0; }
// --------------------------------------------------------------------------- // If aDevExt contains a valid friendly name, the friendly name will be displayed; // Otherwise, if the given name from the parameter of a notifier request is valid, // the given name will be displayed; // Otherwise, If aDevExt contains a valid device name, the name will be displayed; // Otherwise, the a name will be created by this function. // --------------------------------------------------------------------------- // void TBTNotifUtil::GetDeviceUiNameL( TDes& aNameBuf, const CBtDevExtension* aDevExt, const TDesC& aNameInParam, const TBTDevAddr& aAddr) { CBtDevExtension* tempDev( NULL ); TPtrC namePtr; if ( aDevExt && aDevExt->Device().IsValidFriendlyName() && aDevExt->Device().FriendlyName().Length() != 0 ) { // We always use the friendly name regardless of // the device-name of the device is available or not. namePtr.Set( aDevExt->Device().FriendlyName() ); } else { // this will take care of name formating. Either the // name from iNameInParam or the address will be // the alias: tempDev = CBtDevExtension::NewLC( aAddr, aNameInParam ); namePtr.Set( tempDev->Alias() ); } // Make sure no overflow: if ( aNameBuf.MaxLength() < namePtr.Length() ) { aNameBuf.Copy( namePtr.Left( aNameBuf.MaxLength() ) ); } else { aNameBuf.Copy( namePtr ); } if ( tempDev ) { CleanupStack::PopAndDestroy( tempDev ); } }
// Set grid items from a resource void CSendGrid::SetItemsL(TInt aResourceId) { // Clear previous items if we already have an item array, otherwise create // it if ( iItemArray ) { iGrid->SetCurrentItemIndex(0); iItemArray->Reset(); iGrid->HandleItemRemovalL(); } else { iItemArray = new (ELeave) CDesCArrayFlat(12); iGrid->Model()->SetItemTextArray(iItemArray); } // Read items from the resource file TResourceReader reader; CCoeEnv::Static()->CreateResourceReaderLC(reader, aResourceId); TInt count = reader.ReadInt16(); __ASSERT_ALWAYS(count == KSendGridNumItems, User::Panic(KPanic, KPanicBadResource)); for ( TInt i = 0; i < count; i++ ) { iCommands[i] = reader.ReadInt32(); iSubGrids[i] = reader.ReadInt32(); TBuf<32> buf; buf.Append('\t'); buf.Append(KGridItemLabels[i]); buf.Append('\t'); TPtrC ptr = reader.ReadTPtrC(); __ASSERT_ALWAYS(ptr.Length() <= 30, User::Panic(KPanic, KPanicBadResource)); buf.Append(ptr); iItemArray->AppendL(buf); } CleanupStack::PopAndDestroy(); // reader iGrid->HandleItemAdditionL(); iGrid->SetCurrentItemIndex(0); iCurrentGrid = aResourceId; }
/** * See JNI method __1close. * This is an internal wrapper method for handling Leaves. */ jint CloseL(JNIEnv *aEnv, jclass aClass, jint aHandle, jobject aOutputFilename) { // Convert handle to pointer. CImportFile *file = reinterpret_cast<CImportFile*>(aHandle<<2); // Complete writing and get output filename from the agent. TInt err = file->WriteDataComplete(); // Initialize output filename to aOutputFilename parameter. if (KErrNone == err) { // Get class handle to StringBuffer aClass = aEnv->GetObjectClass(aOutputFilename); // Get method ID to StringBuffer StringBuffer.append(String) jmethodID methodID = aEnv->GetMethodID( aClass, "append", "(Ljava/lang/String;)Ljava/lang/StringBuffer;"); if (0 == methodID) { ELOG(EJavaInstaller, "FileWriter__1close: StringBuffer.append not found"); err = KErrGeneral; } else { CSupplierOutputFile &output = file->OutputFileL(0); TPtrC outputFilename = output.FileName(); // Create new Java String. jstring jOutputFilename = aEnv->NewString(outputFilename.Ptr(), outputFilename.Length()); aEnv->CallObjectMethod(aOutputFilename, methodID, jOutputFilename); } } // Delete the CImportFile instance which is no longer used. delete file; return err; }
// --------------------------------------------------------- // 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; }
/** Test MSdpElementBuilder::BuildURLL() */ void CT_DataSdpElementBuilder::DoCmdBuildURLL(MSdpElementBuilder& aElementBuilder, const TDesC& aSection) { iDataWrapper.INFO_PRINTF1(_L("MSdpElementBuilder BuildURLL Call")); TPtrC theString; if( iDataWrapper.GetStringFromConfig(aSection, KUrl(), theString) ) { HBufC8* theString8=HBufC8::NewLC(theString.Length()); theString8->Des().Copy(theString); TPtrC8 stringPtr = theString8->Des(); TRAPD(err, aElementBuilder.BuildURLL(stringPtr)); if(err != KErrNone) { iDataWrapper.ERR_PRINTF2(_L("MSdpElementBuilder BuildURLL failed with error %d"), err); iDataWrapper.SetError(err); } CleanupStack::PopAndDestroy(theString8); } else { iDataWrapper.ERR_PRINTF2(_L("Missing parameter %S"), &KUrl()); iDataWrapper.SetBlockResult(EFail); } }
// -------------------------------------------------------------------------- // CImageCapture::GetNextFileNameLC // Get the file name // -------------------------------------------------------------------------- HBufC* CImageCapture::GetNextFileNameLC(const TDesC& aName) const { const TInt KNumberLength = 4; // this is to indicate the file numbering, // e.g. 0001, 0002, etc. const TInt KMaxIndex = 10000; const TInt KTimeRecordSize = 512; TPtrC filePathPtr; _LIT(KExtensionpng, ".png"); _LIT(KSlash,"\\"); // Gets the file extension. TPtrC fileExtension; fileExtension.Set(KExtensionpng); filePathPtr.Set(iSettings.iLogPath); TInt result = filePathPtr.LocateReverse('\\'); TPtrC string; if(result!=KErrNotFound) string.Set(filePathPtr.Left(result+1)); TBuf8<KTimeRecordSize> fileName; fileName.Copy(string); if(iXmlFileName.Length()>0) { TInt pos=iXmlFileName.LocateReverse('.'); TPtrC8 ptr; if(pos!=KErrNotFound) { ptr.Set(iXmlFileName.Left(pos)); fileName.Append(ptr); } fileName.Append(KSlash); } fileName.Append(aName); HBufC* newFileName = HBufC::NewLC(fileName.Length()+ KNumberLength + fileExtension.Length() + 1); TPtr newFileNamePtr(newFileName->Des()); newFileNamePtr.Copy(fileName); // Checks whether aNamexxxx.png already exists on the phone or not. // This is to prevent over-riding of any existing images with the same name TBool IsFileExist = ETrue; TInt index = 1; HBufC* buffer = HBufC::NewL(newFileNamePtr.MaxLength()); TPtr bufferPtr(buffer->Des()); while ((index < KMaxIndex) && (IsFileExist)) { bufferPtr.Copy(newFileNamePtr); bufferPtr.AppendNumFixedWidth(index, EDecimal, KNumberLength); bufferPtr.Append(fileExtension); if (BaflUtils::FileExists(CCoeEnv::Static()->FsSession(), *buffer)) { index++; } else { IsFileExist = EFalse; } } delete buffer; // If the index exceeds KMaxIndex, then we don't need to format the file name. if (index >= KMaxIndex) { newFileNamePtr.AppendNum(index); } else { newFileNamePtr.AppendNumFixedWidth(index, EDecimal, KNumberLength); } newFileNamePtr.Append(fileExtension); // If the index greated then KMaxIndex, then rollback to 1 if (index >= KMaxIndex) { index = 1; } return newFileName; }
TBool CIniFile::FindVar(const TDesC &aSection, const TDesC &aVarName, TPtrC &aResult) // // Find a variable's value given a section name and a var name // { __ASSERT_DEBUG(aSection.Length()<=(TInt)KTokenSize,Panic(ESectionNameTooBig)); __ASSERT_DEBUG(aVarName.Length()<=(TInt)KTokenSize,Panic(EVarNameTooBig)); TPtr sectionToken = iToken->Des(); _LIT(KSectionTokenString,"[%S]"); sectionToken.Format(KSectionTokenString,&aSection); TInt sectionStart = iPtr.Find(sectionToken); TInt ret = ETrue; if (sectionStart == KErrNotFound) { ret = EFalse; } else { TPtrC section = iPtr.Mid(sectionStart); TInt endBracket = section.Find(TPtrC(_S("]"))); if (endBracket == KErrNotFound) { ret = EFalse; } else { sectionStart += endBracket + 1; section.Set(iPtr.Mid(sectionStart)); TInt sectionEnd = section.Find(TPtrC(_S("["))); if (sectionEnd == KErrNotFound) { sectionEnd = iPtr.Length() - sectionStart; } else { sectionEnd--; } section.Set(iPtr.Mid(sectionStart,sectionEnd)); TPtr varToken = iToken->Des(); _LIT(KVarTokenString,"%S="); varToken.Format(KVarTokenString,&aVarName); TInt pos = section.Find(varToken); if (pos == KErrNotFound) { ret = EFalse; } else { // 'lex' points at the start of the data TPtrC lex(section.Mid(pos)); TInt startpos = lex.Locate(TChar('=')); startpos++; // startpos points immediately after the =. while ( TChar(lex[startpos]).IsSpace() ) { startpos++; // skip to start of data } TInt endpos = lex.Locate(TChar('\n')); // assumes \n is after =. if ( endpos == KErrNotFound ) // may not be \n on last line { endpos = section.Length()-1; } aResult.Set(lex.Mid(startpos).Ptr(),endpos-startpos-1); } } } return ret; }
void CBcaController::RunL() /** * AO async callback method. Called after request is completed. * */ { OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CBCACONTROLLER_RUNL_1, "CBcaControl::RunL() called"); switch (iState) { //in this state, Ioctl is called to set IAP ID, check the result of // Ioctl, then either set the BCA stack with another Ioctl call, // open the BCA (if there's no BCA stack to set), or stop the NIF. case EIdling: { if(iStatus == KErrNone || iStatus == KErrNotSupported) { if(iStatus == KErrNotSupported) { OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CBCACONTROLLER_RUNL_2, "This BCA does not support IAPID set"); } else { OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CBCACONTROLLER_RUNL_3, "This BCA supports IAPID set"); } TPtrC bcaStack = iBCAProvisionConfig->GetBCAStack(); if(bcaStack.Length()) { TBuf8<KMaxName> remainingBcaStack8; remainingBcaStack8.Copy(bcaStack); iMBca->Control(iStatus, KBcaOptLevelGeneric,KBCASetBcaStack,remainingBcaStack8); } else { TRequestStatus* statusPtr=&iStatus; User::RequestComplete(statusPtr,KErrNone); } iState = EIAPSet; SetActive(); } else { OstTraceDef1(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CBCACONTROLLER_RUNL_4, "ERROR in BCA IAPID set = %d", iStatus.Int()); Stop(iStatus.Int()); } break; } //in this case, we receive the result of Ioctl call to set Bca Stack. // Check the result of Ioctl, then Open and start the Bca or stop the NIF case EIAPSet: { if(iStatus == KErrNotSupported || iStatus == KErrNone) { if(iStatus == KErrNotSupported) { OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CBCACONTROLLER_RUNL_5, "This BCA does not support BCA stacking"); } else { OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CBCACONTROLLER_RUNL_6, "This BCA supports BCA stacking"); } iBcaParams = new(ELeave) MBca2::TBcaParams(const_cast<CBCAProvision*>(iBCAProvisionConfig)->GetCommsPond(), iBCAProvisionConfig->GetPortName()); TInt aErr = iMBca->Open(*iUpperControl,*iUpperDataReceiver,*iBcaParams); if ( aErr != KErrNone) { OstTraceDef1(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CBCACONTROLLER_RUNL_7, "ERROR in BCA Open = %d", aErr); Stop(iStatus.Int()); iState = EIdling; } else { iMBca->Start(); } } else { OstTraceDef1(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CBCACONTROLLER_RUNL_8, "ERROR in BCA stack set = %d", iStatus.Int()); Stop(iStatus.Int()); } break; } // Wrong state. default: { OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CBCACONTROLLER_RUNL_9, "ERROR CBcaControl::RunL(): Unknown state"); OstTraceDefExt2(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CBCACONTROLLER_RUNL_10, "PANIC: %S %d", KNifName, KBcaUnkownState); User::Panic(KNifName, KBcaUnkownState); break; } } }
TInt COpenMAXALTestModule::al_SetDataLocator( CStifItemParser& aItem ) { TInt status(KErrNone); TInt type; status = aItem.GetNextInt(type); switch(type) { case XA_DATALOCATOR_URI: { TPtrC uri; if(m_URIName) { delete m_URIName; m_URIName = NULL; } //status = aItem.SetParsingType(CStifItemParser::EQuoteStyleParsing); status = aItem.GetNextString(uri); if(!status) { m_URIName = HBufC8::NewL(uri.Length()+1); TPtr8 desc = m_URIName->Des(); desc.Copy(uri); m_Uri.locatorType = XA_DATALOCATOR_URI; m_Uri.URI = (XAchar*) desc.PtrZ(); } else { status = KErrGeneral; } } break; case XA_DATALOCATOR_IODEVICE: { TInt devicetype; TUint deviceId; status = aItem.GetNextInt(devicetype); if(!status) { status = aItem.GetNextInt(deviceId); if(!status) { TInt srcsinktype(0); status = aItem.GetNextInt(srcsinktype); if(!status) { if(srcsinktype == 1) { m_SrcIODevice.deviceID = deviceId; m_SrcIODevice.deviceType = devicetype; m_SrcIODevice.locatorType = XA_DATALOCATOR_IODEVICE; } else { m_SinkIODevice.deviceID = deviceId; m_SinkIODevice.deviceType = devicetype; m_SinkIODevice.locatorType = XA_DATALOCATOR_IODEVICE; } } else { status = KErrGeneral; } } else { status = KErrGeneral; } } else { status = KErrGeneral; } } break; case XA_DATALOCATOR_OUTPUTMIX: case XA_DATALOCATOR_NATIVEDISPLAY: case XA_DATALOCATOR_ADDRESS: break; default: status = KErrGeneral; break; } return status; }
TInt CParsedFieldCollection::GetFieldValueAndLength(const TDesC& aFieldName, TPtrC& aValue) const { aValue.Set(GetFieldValue(aFieldName)); return aValue.Length(); }
TBool CTe_LbsIniFileReader::FindNextSection() { _LIT(KSectionHeaderStart, "["); _LIT(KSectionHeaderEnd, "]"); // Clear the previous section information. iSection.Set(KNullDesC); // Early check to see if we have already searched // to the end of the file. if (iSectionEnd == iPtr.Length()) { return (EFalse); } // Begin searching from the end of the last section. TPtrC ptrSection = iPtr.Mid(iSectionEnd); // Search for the section header '[<text>]'. TInt sectionHeaderEnd(KErrNotFound); TInt sectionHeaderStart = ptrSection.Find(KSectionHeaderStart); if (sectionHeaderStart == KErrNotFound) { // No match, so no more sections in the file. iSectionEnd = iPtr.Length(); return (EFalse); } else { sectionHeaderEnd = ptrSection.Find(KSectionHeaderEnd); if ((sectionHeaderEnd == KErrNotFound) || (sectionHeaderEnd < sectionHeaderStart)) { // Parsing error - the section header was not closed properly iSectionEnd = iPtr.Length(); return (EFalse); } else if (sectionHeaderEnd == ptrSection.Length()) { // Parsing error - the section header ends at the end // of the file, so the section is empty! iSectionEnd = iPtr.Length(); return (EFalse); } } iSection.Set(ptrSection.Mid(sectionHeaderEnd + 1)); // Search for the start of the next section // - take this to be the end of the current section. TInt sectionEnd = iSection.Find(KSectionHeaderStart); if (sectionEnd != KErrNotFound) { iSection.Set(iSection.Left(sectionEnd)); iSectionEnd += (sectionHeaderStart + sectionEnd + 1); } else { // No more sections after this one, so set the index to the end. iSectionEnd = iPtr.Length(); } return (ETrue); }
// --------------------------------------------------------- // CPosTp148::PrintLandmarkFieldsWithDescriptionL // // (other items were commented in a header). // --------------------------------------------------------- // void CPosTp148::PrintLandmarkFieldsWithDescriptionL(const CPosLandmark& aLandmark, TBool aTraceFlag) { iLog->Log(_L("Parsing Description ... \n")); TPositionFieldId sourceFieldId = aLandmark.FirstPositionFieldId(); TLocality loc; TInt err; TPtrC landmarkName; TPtrC landmarkDescription; err = aLandmark.GetLandmarkName( landmarkName ); if ( err == KErrNone ) { HBufC* buffer = HBufC::NewLC( landmarkName.Length() + 256 ); TPtr buf = buffer->Des(); buf.Append( _L(" \tLandmark Name: ")); buf.Append( landmarkName ); iLog->Log( buf ); if( aTraceFlag ) { TraceL( buf ); } CleanupStack::PopAndDestroy( buffer ); buffer = NULL; } err = aLandmark.GetPosition(loc); if (err == KErrNone) { HBufC* buffer = HBufC::NewLC( 1024 ); TPtr buf = buffer->Des(); TRealFormat format( 12, KRealFormatFixed ); format.iPoint = TChar('.'); format.iTriLen = KDoNotUseTriads; format.iPlaces = 6; TBuf<20> sLon, sLat, sVacc, sHacc, sAlt, sRad; sLon.Num( loc.Longitude(), format ); sLat.Num( loc.Latitude(), format ); sAlt.Num( loc.Altitude(), format ); sVacc.Num( loc.VerticalAccuracy(), format ); sHacc.Num( loc.HorizontalAccuracy(), format ); buf.Format( _L("\tLM: Long %S Lat %S vertAcc %S horAcc %S alt %S "), &sLon, &sLat, &sVacc, &sHacc, &sAlt); TReal32 sourceR; err = aLandmark.GetCoverageRadius(sourceR); if (err == KErrNone ) { sRad.Num( sourceR, format ); buf.AppendFormat(_L(" srcRadius %S" ), &sRad); } iLog->Log(buf); if (aTraceFlag) TraceL(buf); CleanupStack::PopAndDestroy( buffer ); buffer = NULL; } //Get landmark description err = aLandmark.GetLandmarkDescription(landmarkDescription); if (err == KErrNone) { HBufC* buffer = HBufC::NewLC( landmarkDescription.Length() + 256 ); TPtr buf = buffer->Des(); buf.Format(_L("\tLandmark Description: ")); buf.Append(landmarkDescription); iLog->Log(buf); if ( aTraceFlag ) { TraceL( buf ); } CleanupStack::PopAndDestroy( buffer ); buffer = NULL; } while (sourceFieldId != EPositionFieldNone) { TPtrC sourceValue; aLandmark.GetPositionField(sourceFieldId, sourceValue); HBufC* buffer = HBufC::NewLC( sourceValue.Length() + 256 ); TPtr buf = buffer->Des(); buf.Format( _L( "\tIdField Id: %d Value:" ), sourceFieldId ); buf.Append( sourceValue ); iLog->Log( buf ); if ( aTraceFlag ) { TraceL( buf ); } sourceFieldId = aLandmark.NextPositionFieldId( sourceFieldId ); CleanupStack::PopAndDestroy( buffer ); } }
// --------------------------------------------------------- // CPosTp148::PrintParsedDataFromEncoderL // // (other items were commented in a header). // --------------------------------------------------------- // void CPosTp148::PrintParsedDataFromEncoderL( const TDesC& aFile, const TDesC8& aBuffer, TInt aExpectedStatusCode, const TDesC8& aMimeType) { iLog->Log(_L("===== PrintParsedDataFromEncoderL =======")); iLandmarkParser = CPosLandmarkParser::NewL(aMimeType); if (aFile != KNullDesC) { TFileName file( aFile ); iLog->Log(_L("FILE (%S)"), &file ); TraceL(_L("----->Using FILE<-------")); TraceL(file); iLandmarkParser->SetInputFileL(file); } else { iLog->Log(_L("BUFFER (size %d)"), aBuffer.Size() ); TraceL(_L("----->Using BUFFER<-------")); iLandmarkParser->SetInputBuffer(aBuffer); } iOperation = iLandmarkParser->ParseContentL(); TRequestStatus status = KPosLmOperationNotComplete; TReal32 progress; TInt number = 0; RArray<TPosLmItemId> array; CleanupClosePushL(array); while (status == KPosLmOperationNotComplete) { iLog->Log(_L("--- Parsing ---------------------------")); TraceL(_L("------------------------------")); iOperation->NextStep(status, progress); // Wait for NextStep to complete User::WaitForRequest(status); if (status != KPosLmOperationNotComplete && status != KErrNone) { iLog->Log(_L("Parsing Complete")); HBufC* buffer = HBufC::NewLC( 128); TPtr buf = buffer->Des(); buf.Format(_L("\tStatus %d"), status.Int()); iLog->Log(buf); TraceL(buf); CleanupStack::PopAndDestroy( buffer ); buffer = NULL; } else { iLog->Log(_L("Parsing element")); if ( iLandmarkParser->NumOfParsedLandmarks() ) { // Get last parsed landmark CPosLandmark* lm = iLandmarkParser->LandmarkLC(); TPtrC lmName; TPtrC catName; lm->GetLandmarkName(lmName); lm->GetCategoriesL(array); //iLog->Log(lmName); for (TInt i=0;i<array.Count();i++) { CPosLandmarkCategory* category = iLandmarkParser->LandmarkCategoryLC( array[i] ); category->GetCategoryName( catName ); HBufC* buffer = HBufC::NewLC( 128 + catName.Length()); TPtr buf = buffer->Des(); if ( category->GlobalCategory()) { buf.Append(_L("\tGlobal category: ")); } else { buf.Append(_L("\tLocal category: ")); } buf.Append( catName ); iLog->Log( buf ); TraceL( buf ); CleanupStack::PopAndDestroy( buffer ); buffer = NULL; CleanupStack::PopAndDestroy(category); } PrintLandmarkFieldsWithDescriptionL(*lm, ETrue); number++; CleanupStack::PopAndDestroy(lm); } } } iLog->Log(_L("--- Parsing end ---------------------------")); TraceL(_L("------------------------------")); CleanupStack::PopAndDestroy(&array); if (status.Int() != aExpectedStatusCode) { HBufC* buffer = HBufC::NewLC( 128 ); TPtr buf = buffer->Des(); buf.Format(_L("\tERROR: Wrong status returned, was %d, should be %d"), status.Int(), aExpectedStatusCode); iLog->Log( buf ); iErrorsFound++; CleanupStack::PopAndDestroy( buffer ); buffer = NULL; } TUint32 nr = iLandmarkParser->NumOfParsedLandmarks(); HBufC* buffer = HBufC::NewLC( 256 ); TPtr buf = buffer->Des(); buf.Format(_L("\tNr of Parsed landmarks %d, should be %d"), nr, number); iLog->Log(buf); TraceL(buf); CleanupStack::PopAndDestroy( buffer ); buffer = NULL; if (nr != (TUint32)number) { iLog->Log(_L("\tERROR: Wrong number of landmarks parsed returned!")); iErrorsFound++; } TPosLmCollectionDataId lmId = iLandmarkParser->FirstCollectionDataId(); iLog->Log(_L("--- CollectionData ---")); TraceL(_L("--- CollectionData ---")); if (lmId != EPosLmCollDataNone) { TPtrC first = iLandmarkParser->CollectionData(lmId); HBufC* buffer = HBufC::NewLC( first.Length() + 256 ); TPtr buf = buffer->Des(); buf.Zero(); buf.Format(_L("\t(1)Collection Id: %d CollectionData: "), lmId); buf.Append(first); iLog->Log(buf); TraceL(buf); CleanupStack::PopAndDestroy( buffer ); buffer = NULL; } else { iLog->Log(_L("\tNo collection data found 1")); } while (lmId != EPosLmCollDataNone) { lmId = iLandmarkParser->NextCollectionDataId(lmId); if (lmId != EPosLmCollDataNone) { TPtrC first = iLandmarkParser->CollectionData(lmId); HBufC* buffer = HBufC::NewLC( first.Length() + 256 ); TPtr buf = buffer->Des(); buf.Zero(); buf.Format(_L("\t(2)Collection Id: %d CollectionData: "), lmId); buf.Append(first); iLog->Log(buf); TraceL(buf); CleanupStack::PopAndDestroy( buffer ); buffer = NULL; } else { iLog->Log(_L("\tNo collection data found 2")); } } iLog->Log(_L("--- CollectionData ---")); TraceL(_L("--- CollectionData ---")); delete iOperation; iOperation = NULL; delete iLandmarkParser; iLandmarkParser = NULL; iLog->Log(_L("====== PrintParsedDataFromEncoderL Done ========\n")); }
EXPORT_C void CMMFFormatSelectionParameters::SetMatchToFileNameL(const TDesC& aFileName) { delete iMatchReqData; iMatchReqData = NULL; iMatchDataType = EMatchAny; // Extract the extension from the data passed in // Parse the path and extract the extension _LIT( KDot, "." ) ; _LIT8( KDot8, "." ); // If there is no dot "." in aFileName then assume that we have been passed the extension only (if KMaxExtLen or less) if ( (aFileName.Length() <= KMaxExtLen) && (aFileName.Find( KDot ) == KErrNotFound) ) { RBuf8 temp; CleanupClosePushL(temp); temp.CreateL(aFileName.Length()+1); User::LeaveIfError(CnvUtfConverter::ConvertFromUnicodeToUtf8(temp, aFileName)); temp.Insert(0,KDot8); iMatchReqData = CMatchData::CreateL(); iMatchReqData->SetMatchDataL(temp); CleanupStack::PopAndDestroy(&temp); } else if ( aFileName.Find( KDot ) == 0 ) // the first character is dot so assume extension only { RBuf8 temp; CleanupClosePushL(temp); temp.CreateL(aFileName.Length()); User::LeaveIfError(CnvUtfConverter::ConvertFromUnicodeToUtf8(temp, aFileName)); iMatchReqData = CMatchData::CreateL(); iMatchReqData->SetMatchDataL(temp); CleanupStack::PopAndDestroy(&temp); } else // We have been given the whole filename. Use TParse to extract the extension. { TParse parser ; parser.Set( aFileName, NULL, NULL ) ; if ( !( parser.NamePresent() ) ) User::Leave( KErrBadName ) ; if ( !( parser.PathPresent() ) ) { RFs fsSession ; User::LeaveIfError(fsSession.Connect()); TInt error = fsSession.Parse(aFileName, parser); fsSession.Close(); User::LeaveIfError(error); } // Parser should now have the full filename and path TPtrC extension = parser.Ext(); RBuf8 temp; CleanupClosePushL(temp); temp.CreateL(extension.Length()); User::LeaveIfError(CnvUtfConverter::ConvertFromUnicodeToUtf8(temp, extension)); iMatchReqData = CMatchData::CreateL(); iMatchReqData->SetMatchDataL(temp); CleanupStack::PopAndDestroy(&temp); } // If we're here, we must now have the file extension iMatchDataType = EMatchFileExtension; }
/** Function : doTestStepL Description : Fetches the srvice ID using the IMAP account name and sets the full download limit fields of the setting object corresponding to it. @return : TVerdict - Test step result @leave : KMsvNullIndexEntryId If valid IMAP account name is not specified or If valid remote folder name is not specified */ TVerdict CT_MsgSetImap4FullDownloadLimits::doTestStepL() { INFO_PRINTF1(KInfoTestStepName); TPtrC imapAccountName; /* Reads IMAP Account Name from ini file */ if(!GetStringFromConfig(ConfigSection(), KImapAccountName, imapAccountName)) { ERR_PRINTF1(KAcntNameNtSpecified); SetTestStepResult(EFail); } else { TPtrC destFolderName; /* Reads the destination Folder Name */ if(!GetStringFromConfig(ConfigSection(), KFolderName, destFolderName)) { ERR_PRINTF1(KDestFolderNtSpecified); SetTestStepResult(EFail); } else { TInt maxEmailSize = KMaxTInt; /* Reads the size of the Email to be set,where default is KMaxTInt */ GetIntFromConfig(ConfigSection(), KMaxEmailSize, maxEmailSize); TPtrC mailOption; /* Reads the mail option to be set from the ini file */ if(!GetStringFromConfig(ConfigSection(), KImapMailOption, mailOption)) { ERR_PRINTF1(KGetMailOptNtSpecified); SetTestStepResult(EFail); } else { TMsvId destFolderId = -1; /* Retrieves the IMAP service Id based on the IMAP account name*/ TMsvId imapServiceId = CT_MsgUtilsCentralRepository::GetImapServiceIdL((TDes&) imapAccountName); if(imapServiceId == KMsvNullIndexEntryId) { ERR_PRINTF2(KAcntNtExist, &imapAccountName); SetTestStepResult(EFail); } else { /* * Retrieves the mail options and the remote destination folder Id * based on the IMAP account name and the remote folder name given */ TImap4GetMailOptions imapMailOption = CT_MsgUtilsEnumConverter::ConvertDesToTImap4GetMailOptions(mailOption); destFolderId = CT_MsgUtils::GetRemoteFolderIdByNameL(iSharedDataIMAP.iSession, imapAccountName,destFolderName); if(destFolderId == KMsvNullIndexEntryId) { ERR_PRINTF1(_L("Invalid remote folder name specified")); SetTestStepResult(EFail); } else { INFO_PRINTF2(KFolderId,destFolderId); /* Stores the fulll donwload limit values */ TImImap4GetMailInfo imap4GetMailInfo; imap4GetMailInfo.iMaxEmailSize = maxEmailSize; imap4GetMailInfo.iGetMailBodyParts = imapMailOption; imap4GetMailInfo.iDestinationFolder = destFolderId; /* Loads the Imap account settings and save the download limits */ CEmailAccounts* emailAccounts = CEmailAccounts::NewLC(); CImImap4Settings* imapSettings = new(ELeave) CImImap4Settings(); CleanupStack::PushL(imapSettings); TImapAccount imapAccount; emailAccounts->GetImapAccountL(imapServiceId, imapAccount); emailAccounts->LoadImapSettingsL(imapAccount, *imapSettings); TBool deleteFlag; if(GetBoolFromConfig(ConfigSection(),KDeleteFlag,deleteFlag)) { imapSettings->SetDeleteEmailsWhenDisconnecting(deleteFlag); } TBool updateFlag; if(GetBoolFromConfig(ConfigSection(),KUpdateFlag,updateFlag)) { imapSettings->SetUpdatingSeenFlags(updateFlag); } TInt fetchSizeLimit = 20480; if(GetIntFromConfig(ConfigSection(),KFetchSizeLimit,fetchSizeLimit)) { imapSettings->SetFetchSizeL(fetchSizeLimit); } TInt inboxSyncLimit; if(GetIntFromConfig(ConfigSection(),KInboxSyncLimit,inboxSyncLimit)) { imapSettings->SetInboxSynchronisationLimit(inboxSyncLimit); } TInt mailboxSyncLimit; if(GetIntFromConfig(ConfigSection(),KMailboxSyncLimit,mailboxSyncLimit)) { imapSettings->SetMailboxSynchronisationLimit(mailboxSyncLimit); } TPtrC searchString; if(GetStringFromConfig(ConfigSection(),KSearchString,searchString)) { HBufC8* string = HBufC8::NewLC(searchString.Length()); string->Des().Copy(searchString); imapSettings->SetSearchStringL(string->Des()); CleanupStack::PopAndDestroy(string); } TPtrC folderSubTypeName; if(GetStringFromConfig(ConfigSection(),KFolderSubType,folderSubTypeName)) { TFolderSubscribeType folderSubType = CT_MsgUtilsEnumConverter::ConvertDesToTFolderSubscribeType ((TDesC&)folderSubTypeName); imapSettings->SetSubscribe(folderSubType); } TPtrC folderSyncTypeName; if(GetStringFromConfig(ConfigSection(),KFolderSyncType,folderSyncTypeName)) { TFolderSyncType folderSyncType = CT_MsgUtilsEnumConverter::ConvertDesToTFolderSyncType ((TDesC&)folderSyncTypeName); imapSettings->SetSynchronise(folderSyncType); } /* Sets the download limts in the settings object created */ imapSettings->SetMaxEmailSize( imap4GetMailInfo.iMaxEmailSize ); imapSettings->SetGetMailOptions( imap4GetMailInfo.iGetMailBodyParts ); /* Saves the settings */ emailAccounts->SaveImapSettingsL(imapAccount, *imapSettings); CleanupStack::PopAndDestroy(2,emailAccounts);/* imapSettings, emailAccounts */ INFO_PRINTF2(KInfoCompletionStatus, &KSetImap4FullDownloadLimits); } } } } } return TestStepResult(); }
/** * Finds the java attribute specified by * aAttributeName from aJad and returns the value of that attribute * in HBufC. * @param[in] aJad contents of Jad file * @param[in] aAttributeName the name of a java attribute * @return the value of the attribute. Caller gets the ownership of the * returned HBufC. * If the attribute is not found, returns NULL */ HBufC *CSilentMIDletInstall::ParseAttribute(const HBufC *aJad, const TDesC& aAttributeName) { JELOG2(EJavaPreinstaller); TInt nInd(0); TBool fullNameFound(EFalse); TUint32 ch; // Start parsing from the beginning of the Jad file TPtrC parsePtr = aJad->Mid(nInd); do { // Find attribute name nInd = parsePtr.Find(aAttributeName); if (nInd < 0) { // Returns NULL if the attribute cannot be found return NULL; } // Check that the attribute name was preceded by line break or // it was at the beginning of the Jad file if (nInd == 0) { fullNameFound = ETrue; } else { ch = parsePtr[nInd-1]; if ((ch == CR) || (ch == LF)) { fullNameFound = ETrue; } else { // Name was just a part of longer string (not 'word match') fullNameFound = EFalse; // Skip to the last character of the found match. // We can skip because we are insterested only in 'word' matches // so the next cannot start inside the area we are skipping now. parsePtr.Set(parsePtr.Mid(nInd + aAttributeName.Length() - 1)); continue; } } // Check whether Jad file ends after attribute name if (nInd + aAttributeName.Length() >= parsePtr.Length()) { // Jad file ends immediately after the found // attribute name instance. No attribute value return NULL; } // Check that there is a white space character or colon after // attribute name ch = parsePtr[nInd + aAttributeName.Length()]; if ((ch == COLON) || (ch == SP) || (ch == HT)) { fullNameFound = ETrue; } else { // Name was just a part of longer string (not 'word match') fullNameFound = EFalse; // Skip to the next character after the found match parsePtr.Set(parsePtr.Mid(nInd + aAttributeName.Length())); continue; } } while (!fullNameFound); // Skip to the end of the attribute name and find ':' after the name. // The skipped characters must be white space chacraters, otherwise // the attribute name is illegal and Java Installer will not accept // the Jad file. parsePtr.Set(parsePtr.Mid(nInd + aAttributeName.Length() - 1)); nInd = parsePtr.Locate(COLON); if (nInd < 0) { return NULL; } nInd++; // Parse attribute value (CR or LF ends) TInt nEndInd = parsePtr.Locate(CR); TInt nTmpInd = parsePtr.Locate(LF); if (KErrNotFound == nEndInd) { nEndInd = parsePtr.Length() - 1; } if (KErrNotFound == nTmpInd) { nTmpInd = parsePtr.Length() - 1; } if (nTmpInd < nEndInd) { nEndInd = nTmpInd; } if (nEndInd < nInd) { return NULL; } TPtrC attributeValue = parsePtr.Mid(nInd, (nEndInd - nInd)); // Remove possible white space from the beginning and end of the value HBufC *bufValue = attributeValue.Alloc(); if (NULL == bufValue) { return NULL; } TPtr value = bufValue->Des(); value.Trim(); return bufValue; } // parseAttribute
HBufC* MicroEditionPlatformL() { // First try to get the actual device name // If the device name is not found the default value is used: Series60/ HBufC *productName= NULL; TBuf<KBufferSize> hardwareType(0); int retCode = getHardwareVersionL(hardwareType); if (retCode == KErrNone && hardwareType.Length() > 0) { TInt slashAfterManufacturer = hardwareType.Locate('/'); TInt spaceAfterManufacturer = hardwareType.Locate(' '); TPtrC productNameShort = hardwareType; if ((slashAfterManufacturer != KErrNotFound) || (spaceAfterManufacturer != KErrNotFound)) { if (slashAfterManufacturer == KErrNotFound) { productNameShort.Set(hardwareType.Left( spaceAfterManufacturer)); } else if (spaceAfterManufacturer == KErrNotFound) { productNameShort.Set(hardwareType.Left( slashAfterManufacturer)); } else { productNameShort.Set(hardwareType.Left( slashAfterManufacturer < spaceAfterManufacturer ? slashAfterManufacturer : spaceAfterManufacturer)); } } productName = HBufC::NewL(productNameShort.Length()); productName->Des().Copy(productNameShort); } if (!productName) { productName = KMicroeditionPlatformValueDefaultPrefix().AllocLC(); } else { CleanupStack::PushL(productName); } HBufC* platformName = NULL; TBuf<KSysUtilVersionTextLength> swVersion; if (SysUtil::GetSWVersion(swVersion) == KErrNone && swVersion.Length()>0) { // Assume syntax xx.xx\ndd-mm-yy\nNHL-vvv\n(c)Vendor TInt NLloc = swVersion.Locate('\n'); if (KErrNotFound == NLloc) { NLloc = swVersion.Length(); // no '\n' -> use whole string } TPtrC verPtr = swVersion.Left(NLloc); // Get platform minor and major version numbers HBufC* platformVersionValue = GetPlatformVersionL(); CleanupStack::PushL(platformVersionValue); // Get platform properties and values HBufC* platformNameProperty = KMicroeditionPlatformName().AllocLC(); HBufC* platformNameValue = KMicroeditionPlatform().AllocLC(); HBufC* platformVersionProperty = KMicroeditionPlatformVersion().AllocLC(); HBufC* platformJavaVersionProperty = KMicroeditionPlatformJavaVersion().AllocLC(); // Get Java version number TVersion versionInfo = Java::JavaEnvInfo::Version(); TVersionName versionName; versionName.AppendNum(versionInfo.iMajor); versionName.Append('.'); versionName.AppendNum(versionInfo.iMinor); versionName.Append('.'); versionName.AppendNum(versionInfo.iBuild); HBufC* platformJavaVersionValue = versionName.AllocL(); CleanupStack::PushL(platformJavaVersionValue); // Calculate length of property string TUint propertyLength = productName->Length() + 1 + verPtr.Length() + 1; propertyLength += platformNameProperty->Length(); propertyLength += platformNameValue->Length() + 1; propertyLength += platformVersionProperty->Length(); propertyLength += platformVersionValue->Length() + 1; propertyLength += platformJavaVersionProperty->Length(); propertyLength += platformJavaVersionValue->Length(); // Concatenate properties platformName = HBufC::NewL(propertyLength); platformName->Des().Append(*productName); platformName->Des().Append('/'); platformName->Des().Append(verPtr); platformName->Des().Append('/'); platformName->Des().Append(*platformNameProperty); platformName->Des().Append(*platformNameValue); platformName->Des().Append(';'); platformName->Des().Append(*platformVersionProperty); platformName->Des().Append(*platformVersionValue); platformName->Des().Append(';'); platformName->Des().Append(*platformJavaVersionProperty); platformName->Des().Append(*platformJavaVersionValue); CleanupStack::PopAndDestroy(platformJavaVersionValue); CleanupStack::PopAndDestroy(platformJavaVersionProperty); CleanupStack::PopAndDestroy(platformVersionProperty); CleanupStack::PopAndDestroy(platformNameValue); CleanupStack::PopAndDestroy(platformNameProperty); CleanupStack::PopAndDestroy(platformVersionValue); } CleanupStack::PopAndDestroy(productName); return platformName; }
TVerdict CWriteStringStep::doTestStepL() /** * @return - TVerdict code * Override of base class pure virtual * Our implementation only gets called if the base class doTestStepPreambleL() did * not leave. That being the case, the current test result value will be EPass. */ { INFO_PRINTF1(_L("This step tests WriteStringToConfig function.")); SetTestStepResult(EFail); TPtrC originalValue; TBool ret = EFalse; if(!GetStringFromConfig(ConfigSection(),KTe_RegStepTestSuiteString, originalValue)) { // Leave if there's any error. User::Leave(KErrNotFound); } INFO_PRINTF2(_L("The Original String is %S"), &originalValue); // Block end RBuf buf; buf.Create(originalValue.Length()); buf.Copy(originalValue); _LIT(KText,"GoodBye Jason"); TBufC<16> buf1(KText); TPtrC TheString1(buf1); if (WriteStringToConfig(ConfigSection(), KTe_RegStepTestSuiteString, TheString1)) { if (GetStringFromConfig(ConfigSection(), KTe_RegStepTestSuiteString, TheString1) && 0==TheString1.Compare(KText())) { INFO_PRINTF2(_L("Changed String To %S"),&TheString1); ret = ETrue; } } _LIT(KText2,"Hello Jason"); TBufC<16> buf2(KText2); TPtrC TheString2(buf2); if (WriteStringToConfig(ConfigSection(), KTe_RegStepTestSuiteString, TheString2)) { if (GetStringFromConfig(ConfigSection(), KTe_RegStepTestSuiteString, TheString2) && 0==TheString2.Compare(KText2())) { INFO_PRINTF2(_L("Changed String To %S"), &TheString2); } } else { ret = EFalse; } if (!WriteStringToConfig(ConfigSection(), KTe_RegStepTestSuiteString, buf)) { ret = EFalse; } buf.Close(); if (ret) { SetTestStepResult(EPass); } return TestStepResult(); }