// --------------------------------------------------------------------------- // Data request from CatalogsPCConnectivityPlugin // First ask the size from server, then give correct size CBufFlat // --------------------------------------------------------------------------- // void RCatalogsPCConnectivityClient::GetDataL( TDataType& aMimeType, CBufFlat& aData ) { TPckgBuf<TInt> pckgSize; TPckgBuf<TDataType> pckgMIME; User::LeaveIfError( SendReceive( ECatalogsPCConnectivityGetSize, TIpcArgs( &pckgMIME, &pckgSize ) ) ); TInt size = pckgSize(); aMimeType = pckgMIME(); RBuf8 desData; desData.CreateL( size ); desData.CleanupClosePushL(); User::LeaveIfError( SendReceive( ECatalogsPCConnectivityGetData, TIpcArgs( &desData ) ) ); aData.Reset(); aData.ExpandL( 0, size ); aData.Write( 0, desData, size ); CleanupStack::Pop(); //desData desData.Close(); }
/** Upcall from the Agent */ void CPppAgentNotificationHandler::ConnectCompleteL() { TBool pop = EFalse; CPppProvisionInfo* pppInfo = const_cast<CPppProvisionInfo*>(static_cast<const CPppProvisionInfo*>(GetExtension(STypeId::CreateSTypeId(CPppProvisionInfo::EUid, CPppProvisionInfo::ETypeId)))); if (!pppInfo) // not provisioned yet { pppInfo = new (ELeave) CPppProvisionInfo; CleanupStack::PushL(pppInfo); pop = ETrue; } const TInt KMaxExcessData = 1503 * 2; // from PPP HDLC RBuf8 excessData; CleanupClosePushL(excessData); excessData.CreateL(KMaxExcessData); (void)ReadExcessData(excessData); User::LeaveIfError(pppInfo->SetExcessData(excessData)); CleanupStack::PopAndDestroy(&excessData); pppInfo->SetIsDialIn(QueryIsDialIn()); if (pop) { AppendExtensionL(pppInfo); CleanupStack::Pop(pppInfo); } }
/** Auxilary function should be called only when we need to generate hash values from the screen and returns its hex format. @param aHexString the output MD5 hash hex string obtained from iBitmapDevice */ EXPORT_C void CTHashReferenceImages::GenerateHashAndReturnInHexFormatL(TDes &aHexString) { TInt bufLen = CFbsBitmap::ScanLineLength(iBitmapDevice->SizeInPixels().iWidth, iBitmapDevice->DisplayMode()); RBuf8 buff; buff.CreateL(bufLen); CleanupClosePushL(buff); CMD5 *md = CMD5::NewL(); CleanupStack::PushL(md); for (TPoint pos(0, 0); pos.iY < iBitmapDevice->SizeInPixels().iHeight; pos.iY++) { iBitmapDevice->GetScanLine(buff,pos,iBitmapDevice->SizeInPixels().iWidth,iBitmapDevice->DisplayMode()); md->Update(buff); } TBuf8<KLengthOfHashValue> hashString; //md will be reset after calling CMD5::Final() as Final will call Reset. hashString.Copy(md->Final()); aHexString.Zero(); for(TInt icount=0; icount < hashString.Length(); icount++) { aHexString.AppendNumFixedWidth(hashString[icount], EHex, 4); } CleanupStack::PopAndDestroy(2, &buff); }
/** Inserts the data into the URITbl. @param aUri URI object @param [out] aUriId The URI will be filled upon successful insertion. This ID uniquelly indentifies the URI. @return Returns the number of rows inserted. Normally 1. Otherwise returns with system-wide error code. */ TInt CUriListInterface::InsertIntoUriTblL ( const TUriC8& aUri, TInt& aUriId ) { const TDesC8& id ( iStringPool.String (URILIST::EId,URILIST::Table).DesC() ); aUriId = GetMaxIdValueL ( KUriTblName(), id ) + 1; _LIT8 ( KUriTblInsertStmt, "INSERT INTO %S VALUES (:V1, :V2, :V3, :V4, :V5, :V6, :V7, :V8)" ); RBuf8 sqlStmt; sqlStmt.CreateL ( KMaxDbStmtLen ); CleanupClosePushL ( sqlStmt ); sqlStmt.Format ( KUriTblInsertStmt(), &(KUriTblName()) ); MDBTransaction* dbTrans = iDbAccessor->PrepareTransactionL ( sqlStmt ); CleanupStack::PopAndDestroy (); // sqlStmt CleanupStack::PushL ( TCleanupItem ( CUriListInterface::DestroyTransObj, dbTrans ) ); // We are having 8 parameters for this query. First bind the query with parameter position 0 // and so on dbTrans->BindIntL ( URILIST::EId, aUriId ); dbTrans->BindTextL ( URILIST::EScheme, aUri.IsPresent(EUriScheme) ? aUri.Extract ( EUriScheme ) : KNullDesC8() ); dbTrans->BindTextL ( URILIST::EUserInfo, aUri.IsPresent(EUriUserinfo) ? aUri.Extract ( EUriUserinfo ) : KNullDesC8() ); dbTrans->BindTextL ( URILIST::EHost, aUri.IsPresent(EUriHost) ? aUri.Extract ( EUriHost ) : KNullDesC8() ); dbTrans->BindTextL ( URILIST::EPort, aUri.IsPresent(EUriPort) ? aUri.Extract ( EUriPort ) : KNullDesC8() ); dbTrans->BindTextL ( URILIST::EPath, aUri.IsPresent(EUriPath) ? aUri.Extract ( EUriPath ) : KNullDesC8() ); dbTrans->BindTextL ( URILIST::EQuery, aUri.IsPresent(EUriQuery) ? aUri.Extract ( EUriQuery ) : KNullDesC8() ); dbTrans->BindTextL ( URILIST::EFragments, aUri.IsPresent(EUriFragment) ? aUri.Extract ( EUriFragment ) : KNullDesC8() ); TInt result = dbTrans->ExecuteL (); CleanupStack::PopAndDestroy (); //dbTrans return result; }
TInt InternalizeDesL(RBuf8& aDes, RReadStream& aStream) { TInt length = aStream.ReadInt32L(); aDes.Close(); if (length > 0) { aDes.CreateL(aStream, length); } else { aDes.CreateL(KNullDesC8); } return length; }
/** * @SYMTestCaseID BA-CTSYD-DIS-SIM-NEGATIVE-UN0016 * @SYMComponent telephony_ctsy * @SYMTestCaseDesc Test handing in CTSY dispatch when the SendAPDUReq API is disabled * @SYMTestPriority High * @SYMTestActions Disable API, call API, check correct error returned * @SYMTestExpectedResults Pass * @SYMTestType CT */ void CCTsySimFUNegative::TestSendAPDUReqL() { TConfig config; config.SetSupportedValue(MLtsyDispatchSimSendApduRequest::KLtsyDispatchSimSendApduRequestApiId, EFalse); config.PushL(); OpenEtelServerL(EUseExtendedError); CleanupStack::PushL(TCleanupItem(Cleanup,this)); OpenPhoneL(); RMmCustomAPI customApi; OpenCustomApiLC(customApi); TBuf8<3> info; info.Append(1); info.Append(1); info.Append(1); RBuf8 dataBuf; CleanupClosePushL(dataBuf); _LIT8(KApduDataExp,"APDU DATA EXP "); dataBuf.CreateL(KApduDataExp); RMmCustomAPI::TApdu apdu(info,dataBuf); TRequestStatus status; customApi.SendAPDUReq(status, apdu); User::WaitForRequest(status); ASSERT_EQUALS(status.Int(), KErrNotSupported); AssertMockLtsyStatusL(); config.Reset(); CleanupStack::PopAndDestroy(4, &config); // dataBuf, customApi, this, config }
int main() { __UHEAP_MARK; int retval =ESuccess; char* mycharstring = "Hello Char String"; int char_length= strlen(mycharstring); RBuf8 myRBuf; myRBuf.CreateL(30); myRBuf.CleanupClosePushL(); retval = CharToRbuf8 (mycharstring, myRBuf); int buf_len = myRBuf.Length(); if (retval ==ESuccess &&\ char_length == buf_len &&\ strncmp("Hello Char String",(char*)myRBuf.Ptr() , 17) ==0 ) { printf("CharToRbuf8 content check Passed\n"); } else { assert_failed = true; printf("CharToRbuf8 content check Failed\n"); } CleanupStack::PopAndDestroy(1); __UHEAP_MARKEND; testResultXml("test_chartorbuf8_content_check"); return 0; }
int main() { __UHEAP_MARK; int retval =ESuccess; wchar_t* mywcharstring = NULL; RBuf8 myRBuf; myRBuf.CreateL(10); myRBuf.CleanupClosePushL(); retval = WcharToRbuf8 (mywcharstring, myRBuf); if (retval == EInvalidPointer) { printf("wchartorbuf8 negative1 Passed\n"); } else { assert_failed = true; printf("wchartorbuf8 negative1 Failed\n"); } CleanupStack::PopAndDestroy(1); __UHEAP_MARKEND; testResultXml("test_wchartorbuf8_negative1"); return 0; }
CResourceFile* CSsmCommandListResourceReaderImpl::CInitialiser::OpenResourceFileL(const TDesC& aFileName) { // open the resource file RFile file; CleanupClosePushL(file); User::LeaveIfError(file.Open(iFs, aFileName, EFileRead | EFileShareReadersOnly)); // read entire resource file into a buffer TInt fileSize(0); User::LeaveIfError(file.Size(fileSize)); RBuf8 buf; buf.CreateL(fileSize); CleanupClosePushL(buf); User::LeaveIfError(file.Read(buf)); // create a CResourceFile from the buffer and add it to array (the CResourceFile takes its own copy of the buffer) CResourceFile* const resourceFile = CResourceFile::NewL(buf); CleanupStack::PushL(resourceFile); iResourcePool.AppendL(resourceFile); CleanupStack::Pop(resourceFile); iResourcePool.AppendL(aFileName); CleanupStack::PopAndDestroy(&buf); CleanupStack::PopAndDestroy(&file); return resourceFile; }
void CUptCsvGenerator::WriteApiNameL(const TInt aApiEnum) { // find end of this file, and append the passed data from here. TInt filesize; iCsvFile.Size(filesize); iCsvFile.Seek(ESeekStart, filesize); RBuf8 buf; CleanupClosePushL(buf); //create a buf large enough to contain the passed data and comma separators TInt numbytes = 1024;//2*sizeof(TPtrC8); buf.CreateL(numbytes); //read the APIenum (which is the same as the first element of aPerformanceData) //use this enum value to write the name of the API being tested TApiNames getApiName; buf.Append(getApiName.GetApiIdString(aApiEnum)); buf.Append(KCsvComma); //write the buffer to the given file User::LeaveIfError(iCsvFile.Write(buf)); //close and cleanup the heap objects buf.Close(); CleanupStack::PopAndDestroy(&buf); }
/** This user-side method uses the RFile Session methods to find the end of the file described by iCSVFile. It then appends performance data metrics by element from the passed array, with each element separated by a comma character. @param aPerformanceData is the constant array of performance data stored as TDesC @return KErrNone if command was prepared correctly and a system wide error code otherwise. */ void CUptCsvGenerator::WriteL(const RArray<TPtrC8>& aPerformanceConfig) { // find end of this file, and append the passed data from here. TInt filesize; iCsvFile.Size(filesize); iCsvFile.Seek(ESeekStart, filesize); RBuf8 buf; CleanupClosePushL(buf); //create a buf large enough to contain the passed data and comma separators TInt numbytes = 5*aPerformanceConfig.Count()*sizeof(TPtrC8); buf.CreateL(numbytes); //for the number of elements in the passed array:- append each element, separated by a comma, to the buffer for(TInt i=0; i!=aPerformanceConfig.Count(); i++) //could replace aPerformance.Count() with structure paramter Parameter.Count { buf.Append(aPerformanceConfig[i]); //may reimplement this if(i!=aPerformanceConfig.Count()) buf.Append(KCsvComma); } //write the buffer to the given file User::LeaveIfError(iCsvFile.Write(buf)); //close and cleanup the heap objects buf.Close(); CleanupStack::PopAndDestroy(&buf); }
void CConnection::GetParametersResponseL(TBool aReturnLength) { if (ServiceProvider() == NULL || !iCommsDataObject) { SetReturn(KErrNotReady); return; } if (aReturnLength) { // Client requesting required buffer length for the serialised object iCommsDataObjectLength = iCommsDataObject->Length(); SetReturn(iCommsDataObjectLength); } else { RBuf8 cdoBuffer; cdoBuffer.CreateL(iCommsDataObjectLength); CleanupClosePushL(cdoBuffer); User::LeaveIfError(iCommsDataObject->Store(cdoBuffer)); Message().WriteL(0, cdoBuffer); CleanupStack::PopAndDestroy(); // queryBundleBuffer delete iCommsDataObject; iCommsDataObject = NULL; iCommsDataObjectLength = 0; SetReturn(KErrNone); } }
void CUPnPRControlChannelAO::RunL() { switch ( iState ) { case ERecv: { iTimer->Cancel (); if( iInComingAction.MaxLength() != KErrUnknown ) { if ( iCompleteBuffer.Length() == 0 ) { iCompleteBuffer.CreateL(iInComingAction.MessageDes().Length()); } else { TInt oldLen = iCompleteBuffer.Length(); iCompleteBuffer.ReAlloc ( oldLen + iInComingAction.MessageDes().Length() ); } iCompleteBuffer.Append(iInComingAction.MessageDes()); if( iCompleteBuffer.Length() == iInComingAction.MaxLength() ) { iInComingAction.ClearFlags(); SenddataL(); iState = EStop; } else { iControlChannel.Recv(iInComingAction, iStatus); iState = ERecv; SetActive(); } } else { iExepecteBufLen = iInComingAction.MaxLength(); RBuf8 completeData; completeData.CreateL( iExepecteBufLen ); completeData.Append(iInComingAction.MessageDes()); iControlChannel.Recv(iInComingAction, iStatus); SenddataL(); iState = EStop; } _LIT(KInfoLogFile, "CUPnPRControlChannelAO::RunL().... \n"); iManager->INFO_PRINTF1(KInfoLogFile); } break; case EStop: { CActiveScheduler::Stop(); _LIT(KInfoLogFile1, "CUPnPRControlChannelAO::RunL() Stop.... \n"); iManager->INFO_PRINTF1(KInfoLogFile1); } break; } }
void CTestAppUi::ConstructL() { // Complete the UI framework's construction of the App UI. BaseConstructL(CEikAppUi::ENoAppResourceFile); iPropertyObs = new(ELeave) CPropertyObserver; iPropertyObs->StartL(); //Signal that application is started RSemaphore sem; TInt err = sem.OpenGlobal(KStartShmaTestAppGood); if(err == KErrNone) { sem.Signal(); sem.Close(); } RFs fs; err = fs.Connect(); User::LeaveIfError(err); CleanupClosePushL(fs); RFile file; err = file.Open(fs, KPanicFile, EFileRead); if (err == KErrNotFound) { CleanupStack::PopAndDestroy(&fs); // We are not using the file, so just return return; } else { User::LeaveIfError(err); CleanupClosePushL(file); TBuf8<30> buf; err = file.Read(buf); User::LeaveIfError(err); CleanupStack::PopAndDestroy(&file); err = fs.Delete(KPanicFile); RBuf8 writableArgs; writableArgs.CreateL(buf, 30); CleanupClosePushL(writableArgs); TPtr16 args16 = writableArgs.Expand(); _LIT(KTestGoodProcPanic, "Panic"); if (args16 == KPanicCommandLineOption1) User::Panic(KTestGoodProcPanic, KProcPanic); else if (args16 == KPanicCommandLineOption2) User::Panic(KTestGoodProcPanic, KErrNone); CleanupStack::PopAndDestroy(2, &fs); } }
void CConnection::GetOrSetParametersL() { if (ServiceProvider() == NULL) { SetReturn(KErrNotReady); return; } if (iCommsDataObject) { SetReturn(KErrInUse); return; } TInt cdoLength = Message().GetDesLengthL(0); RBuf8 cdoBuffer; cdoBuffer.CreateL(cdoLength); CleanupClosePushL(cdoBuffer); SafeMessage().ReadL(0, cdoBuffer); TPtrC8 des(cdoBuffer); iCommsDataObject = static_cast<XCommsDataObject*>(SMetaDataECom::LoadL(des)); // Last minute sanity check if ((iCommsDataObject->OperationMode() == XCommsDataObject::EOperationGet && !iCommsDataObject->IsGetSupported()) || (iCommsDataObject->OperationMode() == XCommsDataObject::EOperationSet && !iCommsDataObject->IsSetSupported())) { CleanupStack::PopAndDestroy(); // cdoBuffer delete iCommsDataObject; iCommsDataObject = NULL; SetReturn(KErrCorrupt); return; } // iCommsDataObject passed as *& and will be updated by the TGetOrSetParameters message // upon error RNodeInterface* sp = ServiceProvider(); if (sp == NULL) { delete iCommsDataObject; iCommsDataObject = NULL; SetReturn(KErrNotReady); return; } TGetOrSetParameters msg(SafeMessage(), iCommsDataObject); CMMSockSubSession::ReceivedL(SafeMessage().Function(), msg); DontCompleteCurrentRequest(); //TLegacyControlMessage will complete the message CleanupStack::PopAndDestroy(); // cdoBuffer }
EXPORT_C SMetaDataNetCtor* SMetaDataNetCtorExt::LoadL(TPtrC8& aDes) { TUint8* ptr = const_cast<TUint8*> ( aDes.Ptr() ); TPtr8 ptr2 ( ptr, aDes.Length() ); RBuf8 buf; buf.CreateL(aDes); TPtrC8 ptr3 (buf.Ptr(), buf.Length()); CMetaDataVirtualCtorInPlace* vctr = SockManGlobals::Get()->SelfWorker()->TransportGlobals().VirtualCtor(); SMetaDataNetCtor* meta = vctr->New(ptr3, ptr2); TInt len = buf.Length() - ptr3.Length(); aDes.Set(aDes.Ptr() + len, aDes.Length() - len); buf.Close(); return meta; }
int DRMFilePrivate::read(uchar*& data, int length) { int result = KErrNone; data = NULL; while(true) { if(CAF_data == NULL) { result = KErrBadHandle; break; } RBuf8 buffer; if(!length) TRAP(result, CAF_data->DataSizeL(length)); if(result != KErrNone) break; length++; //to be able use PtrZ() call TRAP (result, buffer.CreateL(length)); if(result != KErrNone) break; if(!intentExecuted) result = CAF_data->ExecuteIntent(ContentAccess::EExecute); if(result != KErrNone) break; intentExecuted = ETrue; result = CAF_data->Read(buffer); if(result != KErrNone) break; result = length; uchar* ptr = const_cast<uchar*>(buffer.PtrZ()); //give up ownership from RBuf8 data = ptr; break; } if(result < KErrNone) RDebug::Print(_L("DRMFilePrivate::read ContentAccess::CData::Read error %d"), result); return result; }
int main() { __UHEAP_MARK; { _LIT(myTlitc,"hellohello"); wchar_t* myWchar = new wchar_t[30]; int size = 30; int retval[10]; retval[0] = Tlitc16ToWchar(myTlitc,myWchar,size); RBuf8 buf; buf.CreateL(60); retval[1] = WcharToRbuf8(myWchar,buf); wstring str; retval[2] = Rbuf8ToWstring(buf,str); TBuf16 <30> tbuf; retval[3]= WstringToTbuf16(str,tbuf); wchar_t* myfinalstring= new wchar_t[15]; int size_new=15; retval[4]= Tbuf16ToWchar(tbuf,myfinalstring,size_new); for(int i=1; i<=4; i++) { if (retval[i]!= 0) printf("Conversion failed for retval\n",retval[i]); } if(!wcscmp(myWchar,myfinalstring)) { printf("\n\n\nintegration_test_scenario27 success"); } else { assert_failed = true; printf("\n\n\nintegration_test_scenario27 failure"); } delete[] myWchar; buf.Close(); delete[] myfinalstring; } __UHEAP_MARKEND; testResultXml("integration_test_scenario27"); return 0; }
void UpnpUuid::GenerateUuidL(RBuf8& aUuid) { // uuid generation TUpnpUuid uuid; TUuidString8 uuidString; UpnpUuid::MakeUuid(uuid); TTime now; now.UniversalTime(); TInt64 randSeed = now.Int64(); TInt randomNum = Math::Rand(randSeed); uuid.iTimeLow = static_cast<TUint32>(randomNum); UpnpUuid::UuidToString(uuid, uuidString); aUuid.CreateL(KUuidString.iTypeLength+KUuidStringLen); aUuid.Copy(KUuidString); aUuid.Append(uuidString); }
RCFParameterFamilyBundleC& SubConnActivities::CSetParameters::GetParameterBundleL() { if ( ! iParameterBundle.IsNull() ) { return iParameterBundle; } //Extract the parameter bundle. TInt length = iMessage.GetDesLengthL(0); RBuf8 buffer; buffer.CreateL(length); CleanupClosePushL(buffer); iMessage.ReadL(0, buffer); iParameterBundle.LoadL(buffer); CleanupStack::PopAndDestroy(&buffer); return iParameterBundle; }
void CHostResolver::ReadAndSetOptionL() { TInt optionName=Message().Int0(); TInt optionLevel=Message().Int2(); RBuf8 setOptionBuf; setOptionBuf.CreateL(Message().GetDesLengthL(1)); //1 - is the option that is passed CleanupClosePushL(setOptionBuf); SafeMessage().ReadL(MSG_PRM(1),setOptionBuf); TPtrC8 setOptionPtr(setOptionBuf); SetReturn(iRSP->SetOption(optionLevel,optionName,setOptionPtr)); CleanupStack::PopAndDestroy(); }
/** Inserts the data into the TLDTbl. @return Returns the number of rows inserted. Normally 1. Otherwise returns with system-wide error code. */ TInt CUriListInterface::InsertIntoTldTblL ( const CTldProperties& aTldProps ) { _LIT8 ( KTldTblInsertStmt, "INSERT INTO %S VALUES ( :V1, :V2, :V3 )" ); RBuf8 sqlStmt; sqlStmt.CreateL ( KMaxDbStmtLen ); CleanupClosePushL ( sqlStmt ); sqlStmt.Format ( KTldTblInsertStmt(), &(KTldTblName()) ); MDBTransaction* dbTrans = iDbAccessor->PrepareTransactionL ( sqlStmt ); CleanupStack::PushL ( TCleanupItem ( CUriListInterface::DestroyTransObj, dbTrans ) ); dbTrans->BindTextL ( TLDLIST::ETLDName, aTldProps.TldName() ); TInt lt = static_cast<TInt> ( aTldProps.ListType() ) ; dbTrans->BindIntL ( TLDLIST::EListType, lt ); dbTrans->BindTextL ( TLDLIST::ECharacterSet, aTldProps.CharacterSet() ); TInt result = dbTrans->ExecuteL (); CleanupStack::PopAndDestroy (2); // sqlStmt, dbTrans return result; }
void CHFPAtCmdHandler::RequestCompletedL(CBtmcActive& aActive, TInt aErr) { TRACE_FUNC_ENTRY TInt err = aErr; switch (aActive.ServiceId()) { case EHandleCommandRequest: { if(err == KErrNone) { if (iRemainingReplyLengthPckg()) { TRACE_INFO((_L8("reply '%S'"), &iReplyBuffer)) iObserver.ATExtHandleReplyReceivedL(err, *iReplyBuffer); do { TRACE_INFO((_L8("iRemainingReplyLength '%d'"), iRemainingReplyLengthPckg())) RBuf8 reply; reply.CreateL(iRemainingReplyLengthPckg()); err = iATExtClient.GetNextPartOfReply(*iRecvBuffer, iRemainingReplyLengthPckg()); if (!err) { reply.Insert(0, *iRecvBuffer); } TRACE_INFO((_L8("reply '%S'"), &reply)) iObserver.ATExtHandleReplyReceivedL(err, reply); reply.Close(); } while (iRemainingReplyLengthPckg()); } else { TRACE_INFO((_L8("reply '%S'"), iReplyBuffer)) iObserver.ATExtHandleReplyReceivedL(err, *iReplyBuffer); } } else { iObserver.ATExtHandleReplyReceivedL(err, iSystemReply); } break; } } TRACE_FUNC_EXIT }
void CIoReadTest::ReadFileL() { RFile file; LeaveIfErr(file.Open(Fs(), iFile, EFileRead | EFileShareExclusive), _L("Cannot open file '%S'"), &iFile); CleanupClosePushL(file); TInt fileSize; User::LeaveIfError(file.Size(fileSize)); RBuf8 contents; contents.CreateL(fileSize); CleanupClosePushL(contents); User::LeaveIfError(file.Read(contents)); // convert data to 16-bit which is how it'll come out of the io server iFileContents.CreateL(fileSize); iFileContents.Copy(contents); // copy & expand CleanupStack::PopAndDestroy(2, &file); // contents, file }
/** Inserts the data into the URIPropertiesTbl. @param aUri URI object @param [out] aUriId The URI will be filled upon successful insertion. This ID uniquelly indentifies the URI. @return Returns the number of rows inserted. Normally 1. Otherwise returns with system-wide error code. */ TInt CUriListInterface::InsertIntoUriPropsTblL ( TInt aUriId, const CInetUriProperties& aUriProps, TInt& aPropId ) { const TInt KMaxLen = 128; const TDesC8& propId ( iStringPool.String (URILIST::EPropId,URILIST::Table).DesC() ); aPropId = GetMaxIdValueL ( KUriPropsTblName(), propId ) + 1; _LIT8 ( KInsertStmt, "INSERT INTO %S VALUES (%d, %d, %d, %d, %d, :V1)"); RBuf8 queryBuf; CleanupClosePushL (queryBuf); queryBuf.CreateL ( KMaxLen ); queryBuf.AppendFormat ( KInsertStmt, &(KUriPropsTblName()), aUriId, aPropId, aUriProps.ServiceType(), aUriProps.ListType(), aUriProps.Permission() ); MDBTransaction* dbTrans = iDbAccessor->PrepareTransactionL ( queryBuf ); CleanupStack::PushL ( TCleanupItem ( CUriListInterface::DestroyTransObj, dbTrans ) ); dbTrans->BindTextL ( 0, aUriProps.FavouriteName () ); // Bind with parameter index 0 TInt result = dbTrans->ExecuteL (); CleanupStack::PopAndDestroy (2); // queryBuf, dbTrans return result; }
/** Checks whether the duplicate entry in the TLDTbl. @return ETrue if already such row exist else retrns EFalse */ TBool CUriListInterface::IsDuplicateEntryL ( const CTldProperties& aTldProps ) { _LIT8 ( KTldTblSearchStmt, "SELECT * FROM %S WHERE %S=:V1 and %S=:V2" ); const TDesC8& KTldName (iStringPool.String (TLDLIST::ETLDName,TLDLIST::Table).DesC()); const TDesC8& KTldListType (iStringPool.String (TLDLIST::EListType,TLDLIST::Table).DesC()); RBuf8 sqlStmt; sqlStmt.CreateL ( KMaxDbStmtLen ); CleanupClosePushL ( sqlStmt ); sqlStmt.Format ( KTldTblSearchStmt(), &(KTldTblName()), &KTldName, &KTldListType ); MDBTransaction* dbTrans = iDbAccessor->PrepareTransactionL ( sqlStmt ); CleanupStack::PushL ( TCleanupItem ( CUriListInterface::DestroyTransObj, dbTrans ) ); dbTrans->BindTextL ( TLDLIST::ETLDName, aTldProps.TldName() ); TInt lt = static_cast<TInt> ( aTldProps.ListType() ) ; dbTrans->BindIntL ( TLDLIST::EListType, lt ); TBool result( dbTrans->Next () ); CleanupStack::PopAndDestroy (2); // sqlStmt, dbTrans return result; }
void CNcdNodePreview::IsPreviewLoadedL( MCatalogsBaseMessage& aMessage ) { RBuf8 buf; buf.CreateL( aMessage.InputLength() ); CleanupClosePushL( buf ); User::LeaveIfError( aMessage.ReadInput( buf ) ); TInt fileIndex = Des8ToInt( buf ); TInt isLoaded = iNodeManager.PreviewManager().PreviewExists( iParentMetaData.Identifier(), *iUris[fileIndex] ); CleanupStack::PopAndDestroy( &buf ); aMessage.CompleteAndReleaseL( isLoaded, KErrNone ); }
// --------------------------------------------------------------------------- // Data package from CatalogsPCConnectivityPlugin // --------------------------------------------------------------------------- // void RCatalogsPCConnectivityClient::PutDataL( const TDataType& aMimeType, const CBufFlat& aData ) { TInt size = aData.Size(); RBuf8 desData; desData.CreateL( size ); desData.CleanupClosePushL(); aData.Read( 0, desData, size ); TPckgBuf<TDataType> pckgMIME( aMimeType ); User::LeaveIfError( SendReceive( ECatalogsPCConnectivityPutData, TIpcArgs( &pckgMIME, &desData, size ) ) ); CleanupStack::Pop(); //desData desData.Close(); }
// ----------------------------------------------------------------------------- // CUpnpContentHandlersController::ParseXmlL // Parses a xml document by passed content handler, // there is a guarantee that aHandlerToUse will be deleted in case of leave // precondition: iStack is empty // postcondition: iStack is empty // ----------------------------------------------------------------------------- // void CUpnpContentHandlersController::ParseXmlL( const TDesC8& aDescription, CUpnpContentHandler* aHandlerToUse ) { ASSERT( iStack->IsEmpty() ); iCurrentContentHandler = aHandlerToUse; iStack->PushL( aHandlerToUse ); CleanupStack::PushL( TCleanupItem( ReleaseHandlersOnStack, iStack ) ); iDocStarted = EFalse; TRAPD( parseError, Xml::ParseL( *iParser, aDescription ) ); if ( EXmlSyntax == parseError || EXmlInvalidToken == parseError ) { while ( iStack->Count() > 1 ) { delete iStack->Pop(); } aHandlerToUse->ResetState(); iCurrentContentHandler = aHandlerToUse; iDocStarted = EFalse; RBuf8 fixedDes; fixedDes.CreateL( aDescription ); CleanupClosePushL( fixedDes ); RemoveForbiddenCharacters( fixedDes ); TRAP( parseError, Xml::ParseL( *iParser, fixedDes ) ); CleanupStack::PopAndDestroy( &fixedDes ); } if ( EXmlJunkAfterDocElement != parseError ) { User::LeaveIfError( parseError ); } else { //EXmlJunkAfterDocElement must not be ignored when root isn't complete if ( !iDocStarted || iStack->Count() != 1 ) { User::Leave( KErrArgument ); //no valid root element were found } } ASSERT( iStack->Count() == 1 ); ASSERT( iStack->Head() == iCurrentContentHandler && iCurrentContentHandler == aHandlerToUse ); iStack->Pop(); CleanupStack::Pop( iStack ); ASSERT( iStack->IsEmpty() ); }
/** Purpose: Read memory from the security server. If the length of the data is greater than the maximum length supported by the security server (as reported debug functionality block tag EMemoryMaxBlockSize), break up the read into reads of this maximum size. @pre Must be connected to the debug security server @pre Must be attached to the process that owns aThreadId @param aThreadId - The id of the thread relative to which the read should take place @param aAddress - The virtual address to read from @param aLength - The number of bytes to read @param aData - The buffer to read into @return Any error which may be returned by Security Server::ReadMemory() */ void CServerCrashDataSource::ReadMemoryL( const TUint64 aThreadId, const TUint32 aAddress, const TUint32 aLength, TDes8 & aData ) { LOG_MSG4("->CServerCrashDataSource::ReadMemoryL(aThreadId=0x%X, aAddress=0x%X, aLength=%d)\n", I64LOW(aThreadId), aAddress, aLength); TInt err; if( aLength <= iMaxMemReadSize ) { err = iSecSess.ReadMemory( aThreadId, aAddress, aLength, aData, EAccess32, EEndLE8); } else { // If aLength is greater than iMaxMemReadSize, then break up the read into // smaller packets and append them to aData RBuf8 readData; readData.CreateL( iMaxMemReadSize ); TInt readLength = iMaxMemReadSize; TInt readSoFar = 0; do { LOG_MSG3( " iSecSess->ReadMemory(addr=0x%X, length=%d)\n", aAddress+readSoFar, readLength ); err = iSecSess.ReadMemory( aThreadId, aAddress+readSoFar, readLength, readData, EAccess32, EEndLE8 ); if(err != KErrNone) break; readSoFar += readLength; aData.Append( readData ); if( (aLength - readSoFar) < iMaxMemReadSize ) { readLength = aLength - readSoFar; } } while( readSoFar < aLength ); readData.Close(); } User::LeaveIfError(err); }