// --------------------------------------------------------- // CDownloadDataClient::MarshalDataL() // --------------------------------------------------------- // HBufC8* CDownloadDataClient::MarshalDataL() const { TInt bufLen = Bytes(); // Size of class including iMediaArray elements. // Note that this includes actual bytes occupied by // contents of descriptors and pointers. bufLen += sizeof(TInt); // We include the count of elements in iMediaArray // while externalizing. bufLen += sizeof(TInt) * iMediaArray.Count(); // iMediaArray has an array iTypes. We are including // count of elements in iTypes array while externalizing // each element of iMediaArray. // Dynamic data buffer CBufFlat* buf = CBufFlat::NewL(bufLen); CleanupStack::PushL(buf); // Stream over the buffer RBufWriteStream stream(*buf); CleanupClosePushL(stream); ExternalizeL(stream); CleanupStack::PopAndDestroy(); //stream // Create a heap descriptor from the buffer HBufC8* des = HBufC8::NewL(buf->Size()); TPtr8 ptr(des->Des()); buf->Read(0, ptr, buf->Size()); CleanupStack::PopAndDestroy(); //buf return des; }
// Creates and returns a heap descriptor which holds contents of ’this’ EXPORT_C HBufC8* CRTSecMgrRegisterScriptMsg::PackMsgL() const { // Dynamic data buffer CBufFlat* buf = CBufFlat::NewL(KMaxMsgLength); CleanupStack::PushL(buf); RBufWriteStream stream(*buf); // Stream over the buffer CleanupClosePushL(stream); ExternalizeL(stream); CleanupStack::PopAndDestroy(&stream); // Create a heap descriptor from the buffer HBufC8* des = HBufC8::NewL(buf->Size()); TPtr8 ptr(des->Des()); buf->Read(0, ptr, buf->Size()); CleanupStack::PopAndDestroy(buf); // Finished with the buffer return (des); }
// --------------------------------------------------------------------------- // 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(); }
// -------------------------------------------------------------------------- // CUpnpAVDevice::ToDes8L // See upnpavdevice.h // -------------------------------------------------------------------------- EXPORT_C HBufC8* CUpnpAVDevice::ToDes8L() const { // serialize object CBufFlat* tempFlatBuf = CBufFlat::NewL( KBufferGranularity ); CleanupStack::PushL( tempFlatBuf ); RBufWriteStream stream( *tempFlatBuf ); CleanupClosePushL( stream ); stream << *this; // create heap descriptor HBufC8* tempBuf = HBufC8::NewLC( tempFlatBuf->Size() ); TPtr8 ptr( tempBuf->Des() ); tempFlatBuf->Read( 0, ptr, tempFlatBuf->Size() ); // clean up CleanupStack::Pop( tempBuf ); CleanupStack::PopAndDestroy( &stream ); CleanupStack::PopAndDestroy( tempFlatBuf ); return tempBuf; }
/** Returns the commandlist to the client from swppolicy. @return A pointer to commandlist. */ void CSsmSwpPolicyServer::CallCommandListL(const RMessage2& aMessage, TInt aSessionIndex) { DEBUGPRINT1(_L("CSsmSwpPolicyServer: CallCommandListL")); __ASSERT_DEBUG(IN_RANGE(aSessionIndex, iSessionInfoArray.Count()), PanicNow(KSsmSwpPolicyBadIdx, KSsmSwpPolicySrvArrayIndexInvalid)); __ASSERT_DEBUG(iSessionInfoArray[aSessionIndex].iSsmSwpPolicyStepCompletion != NULL, PanicNow(KSsmSwpPolicyServer, ESsmSwpPolicyServerError4)); // CommandList should be called only after preparing the command list, so the active object state should be EPrepareCommandList. __ASSERT_DEBUG(iSessionInfoArray[aSessionIndex].iSsmSwpPolicyStepCompletion->CurrentStep() == CSsmSwpPolicyServer::CSsmSwpPolicyStepCompletion::EPrepareCommandList, PanicNow(KSsmSwpPolicyServer, ESsmSwpPolicySrvStepError3)); // CSsmSwpPolicyFrame checks whether initialize is called before CallCommandList is called, so no need to check // for valid iSsmSwpPolicyStepCompletion pointer. // Sets the current step to CallCommandList iSessionInfoArray[aSessionIndex].iSsmSwpPolicyStepCompletion->SetCurrentStep(CSsmSwpPolicyServer::CSsmSwpPolicyStepCompletion::ECallCommandList); CSsmCommandList* ssmCmdList = (iSessionInfoArray[aSessionIndex].iSwpPolicy)->CommandList(); CleanupStack::PushL(ssmCmdList); CBufFlat* buf = CBufFlat::NewL(KSsmSwpPolicyStreamBufMaxSize); CleanupStack::PushL(buf); RBufWriteStream writeStream(*buf); CleanupClosePushL(writeStream); DEBUGPRINT1(_L("CSsmSwpPolicyServer: Externalizes the commandlist")); ssmCmdList->ExternalizeL(writeStream); // Ensure any memory that might already have been allocated is disposed of. // Transfer the streamed cmd list from the CBuf. RBuf8 cmdListBuf; cmdListBuf.CreateL(buf->Size()); CleanupClosePushL(cmdListBuf); buf->Read(0, cmdListBuf); aMessage.WriteL(0, cmdListBuf); aMessage.Complete(KErrNone); CleanupStack::PopAndDestroy(4, ssmCmdList); // buf, writeStream and cmdListBuf }
/**--------------------------------------------------------- * * ServiceL(const RMessage& aMessage) * *----------------------------------------------------------*/ void CPKISession::ServiceL(const RMessage2& aMessage) { TInt Status = KErrNone; TInt count = 0; LOG_1("CPKISession::ServiceL: function = %d", aMessage.Function()); switch(aMessage.Function()) { case PkiService::ECancelPendingOperation: iWrapper->CancelPendingOperation(); aMessage.Complete(KErrNone); break; case PkiService::EGetRequiredBufferSize: if (iRequiredBufferSize == KBufferSizeNotDefined) { Status = iWrapper->GetRequiredBufferSizeL(aMessage); } else { TPckg<TInt> pckgSize(iRequiredBufferSize); aMessage.WriteL(0, pckgSize); aMessage.Complete(KErrNone); } break; case PkiService::ECertCount: count = iMapper.CertCount(iWrapper->Informational()); aMessage.Complete(count); break; case PkiService::EApplicableCertCount: { TInt aC = 0; TPckg<TInt> pckgApplCount(aC); aMessage.ReadL(0, pckgApplCount); // Read applications // Allocate list for applications CBufFlat* list = CBufFlat::NewL(sizeof(TUid)); CleanupStack::PushL(list); list->ResizeL(aC * sizeof(TUid)); TPtr8 ptrList = list->Ptr(0); aMessage.ReadL(1, ptrList); iUidArray.Close(); if(aC > 0) { TUid tempUid; for (TInt i = 0; i < aC; i++) { list->Read(i * sizeof(TUid), (TAny*)&tempUid, sizeof(TUid)); iUidArray.Append(tempUid); } } CleanupStack::PopAndDestroy(1); // list TInt matchCount = iMapper.ApplicableCertCount(iUidArray); aMessage.Complete(matchCount); } break; case PkiService::EGetCertDetails: { TPckgBuf<TSecurityObjectDescriptor> secDescPtr; aMessage.ReadL(1, secDescPtr); TCertificateListEntry* resultCertInfo = new (ELeave) TCertificateListEntry; CleanupStack::PushL(resultCertInfo); Status = iMapper.GetCertDetailsL(secDescPtr(), iWrapper->CertStoreType(), iWrapper->Informational(), *resultCertInfo); if (Status == KErrNone) { TPckg<TCertificateListEntry> certDetailsPtr(*resultCertInfo); aMessage.WriteL(0, certDetailsPtr); } aMessage.Complete(Status); CleanupStack::PopAndDestroy(resultCertInfo); } break; case PkiService::EGetCertList: iMapper.GetCertListL(aMessage, iWrapper->Informational()); aMessage.Complete(KErrNone); break; case PkiService::EGetApplicableCertList: iMapper.GetApplicableCertListL(aMessage, iUidArray); aMessage.Complete(KErrNone); break; case PkiService::EGetKeyList: { PKISERVICE_ASSERT(iKeyList != NULL); CBufFlat* list = CBufFlat::NewL(sizeof(TKeyListEntry)); CleanupStack::PushL(list); list->ResizeL(iKeyList->Count() * sizeof(TKeyListEntry)); for(TInt i = 0; i < iKeyList->Count(); i++) { const TKeyListEntry& keyInfo = (*iKeyList)[i]; list->Write(i * sizeof(TKeyListEntry), (TAny*)&keyInfo, sizeof(TKeyListEntry)); } TPtr8 ptrList = list->Ptr(0); aMessage.WriteL(0, ptrList); CleanupStack::PopAndDestroy(list); // list delete iKeyList; iKeyList = NULL; aMessage.Complete(KErrNone); } break; case PkiService::ECertReqCount: count = iServer.CertificateRequestStore().CertReqCountL(); aMessage.Complete(count); break; case PkiService::EGetCertReqList: { CArrayFixFlat<TCertificateRequestListEntry>* certReqList = iServer.CertificateRequestStore().GetCertReqListLC(); TUint bufferGranularity = sizeof(TCertificateRequestListEntry); if (certReqList->Count() > 0) { bufferGranularity = bufferGranularity * certReqList->Count(); } CBufFlat* list = CBufFlat::NewL(bufferGranularity); CleanupStack::PushL(list); if (certReqList->Count() > 0) { list->ResizeL(sizeof(TCertificateRequestListEntry) * certReqList->Count()); } for (TInt i = 0; i < certReqList->Count(); ++i) { const TCertificateRequestListEntry &certReqInfo = (*certReqList)[i]; list->Write(i * sizeof(TCertificateRequestListEntry), &certReqInfo, sizeof(TCertificateRequestListEntry)); } TPtr8 ptrList = list->Ptr(0); aMessage.WriteL(0, ptrList); CleanupStack::PopAndDestroy(list); CleanupStack::PopAndDestroy(certReqList); aMessage.Complete(KErrNone); } break; case PkiService::ESaveCertificateRequest: { TInt requestSize = aMessage.GetDesLength(0); HBufC8* request = HBufC8::NewLC(requestSize); TPtr8 requestPtr = request->Des(); TKeyIdentifier keyId; aMessage.ReadL(0, requestPtr); aMessage.ReadL(2, keyId); //keyId is ignored. HBufC* certRequestRef = iServer.CertificateRequestStore().SaveCertRequestLC(*request); aMessage.WriteL(1, *certRequestRef); CleanupStack::PopAndDestroy(certRequestRef); CleanupStack::PopAndDestroy(request); aMessage.Complete(KErrNone); } break; case PkiService::EReadCertificateRequest: { TInt certRequestRefSize = aMessage.GetDesLength(0); HBufC *certRequestRef = HBufC::NewLC(certRequestRefSize); TPtr certRequestRefPtr = certRequestRef->Des(); aMessage.ReadL(0, certRequestRefPtr); if (certRequestRef->Length() == 0) { User::Leave(KErrNotFound); } HBufC8* certificateRequest = iServer.CertificateRequestStore().ReadCertRequestLC(*certRequestRef); if (aMessage.GetDesMaxLength(1) >= certificateRequest->Length()) { aMessage.WriteL(1, *certificateRequest); aMessage.Complete(KErrNone); } else { iRequiredBufferSize = certificateRequest->Length(); aMessage.Complete(KPKIErrBufferTooShort); } CleanupStack::PopAndDestroy(certificateRequest); CleanupStack::PopAndDestroy(certRequestRef); } break; case PkiService::EDeleteCertificateRequest: { TInt certRequestRefSize = aMessage.GetDesLength(0); HBufC *certRequestRef = HBufC::NewLC(certRequestRefSize); TPtr certRequestRefPtr = certRequestRef->Des(); aMessage.ReadL(0, certRequestRefPtr); iServer.CertificateRequestStore().DeleteCertRequestL(*certRequestRef); CleanupStack::PopAndDestroy(certRequestRef); aMessage.Complete(KErrNone); } break; case PkiService::ESetCertStoreType: iWrapper->SetCertStoreType(static_cast<TPkiServiceStoreType>(aMessage.Int0())); aMessage.Complete(KErrNone); break; case PkiService::ESetKeyStoreType: SetKeyStoreL(static_cast<TPkiServiceStoreType>(aMessage.Int0())); aMessage.Complete(KErrNone); break; case PkiService::ESetStoreType: iWrapper->SetCertStoreType(static_cast<TPkiServiceStoreType>(aMessage.Int0())); SetKeyStoreL(static_cast<TPkiServiceStoreType>(aMessage.Int1())); aMessage.Complete(KErrNone); break; case PkiService::EGetCertStoreType: { Status = iWrapper->CertStoreType(); aMessage.Complete(Status); break; } case PkiService::EGetKeyStoreType: { Status = KeyStore(); aMessage.Complete(Status); break; } case PkiService::ESetInformational: { iWrapper->SetInformational(aMessage.Int0()); aMessage.Complete(KErrNone); } break; case PkiService::EInitialize://falls through case PkiService::EKeyCount: //falls through case PkiService::EGetKeyDetails: //falls through case PkiService::EDecrypt: //falls through case PkiService::ESignWithKeyId: //falls through case PkiService::ESignWithCert: //falls through case PkiService::EReadPublicKey: //falls through case PkiService::ELogon: //falls through case PkiService::ELogoff: //falls through case PkiService::EChangePassword: //falls through case PkiService::ERemoveKeypair: //falls through case PkiService::EGenerateKeypair: //falls through case PkiService::EStoreKeypair: //falls through iKeyOperationQueue.AddOperationL(*this, aMessage, iUsedKeyStore, iWrapper->CertStoreType()); break; default: iRequiredBufferSize = KBufferSizeNotDefined; iWrapper->InitOperation(aMessage); break; } }