本文整理汇总了C++中CBufBase类的典型用法代码示例。如果您正苦于以下问题:C++ CBufBase类的具体用法?C++ CBufBase怎么用?C++ CBufBase使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了CBufBase类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: DLTRACEIN
void CNcdNodeLink::InternalizeRequestL( MCatalogsBaseMessage& aMessage ) const
{
DLTRACEIN((""));
CBufBase* buf = CBufFlat::NewL( KBufExpandSize );
CleanupStack::PushL( buf );
RBufWriteStream stream( *buf );
CleanupClosePushL( stream );
// Include all the necessary node data to the stream
ExternalizeDataForRequestL( stream );
// Commits data to the stream when closing.
CleanupStack::PopAndDestroy( &stream );
if ( buf->Size() > 0 )
{
DLTRACE(( "Completing the message, buf len: %d", buf->Ptr(0).Length() ));
}
// If this leaves, ReceiveMessage function will complete the message.
aMessage.CompleteAndReleaseL( buf->Ptr( 0 ), KErrNone );
DLTRACE(("Deleting the buf"));
CleanupStack::PopAndDestroy( buf );
DLTRACEOUT((""));
}
示例2: DLTRACEIN
void CNcdNodePreview::InternalizeRequestL( MCatalogsBaseMessage& aMessage )
{
DLTRACEIN((""));
CBufBase* buf = CBufFlat::NewL( KBufExpandSize );
CleanupStack::PushL( buf );
RBufWriteStream stream( *buf );
CleanupClosePushL( stream );
// Include all the necessary node data to the stream
ExternalizeDataForRequestL( stream );
// Commits data to the stream when closing.
CleanupStack::PopAndDestroy( &stream );
// If this leaves, ReceiveMessage will complete the message.
// NOTE: that here we expect that the buffer contains at least
// some data. So, make sure that ExternalizeDataForRequestL inserts
// something to the buffer.
aMessage.CompleteAndReleaseL( buf->Ptr( 0 ), KErrNone );
DLINFO(("Deleting the buf"));
CleanupStack::PopAndDestroy( buf );
DLTRACEOUT((""));
}
示例3: FTRACE
// -----------------------------------------------------------------------------
// CCommonTestClass::ExternalizeMPXCollectionTypeL()
// Returns: Symbian OS errors.
// -----------------------------------------------------------------------------
TInt CCommonTestClass::ExternalizeMPXCollectionTypeL()
{
FTRACE(FPrint(_L("CCommonTestClass::ExternalizeMPXCollectionTypeL testing CMPXCollectionType::ExternalizeMPXCollectionTypeL begin")));
iLog->Log(_L("CCommonTestClass::ExternalizeMPXCollectionTypeL testing CMPXCollectionType::ExternalizeMPXCollectionTypeL begin"));
TInt err = KErrNone;
if ( iType != NULL )
{
FTRACE(FPrint(_L("CCommonTestClass::ExternalizeMPXCollectionTypeL started Externalize")));
iLog->Log(_L("CCommonTestClass::ExternalizeMPXCollectionTypeL started Externalize"));
CBufBase* buffer = CBufFlat::NewL( 50 );
CleanupStack::PushL( buffer );
RBufWriteStream writeStream( *buffer );
CleanupClosePushL( writeStream );
iType->ExternalizeL( writeStream );
writeStream.CommitL();
buffer->Compress();
CleanupStack::PopAndDestroy( &writeStream );
CleanupStack::PopAndDestroy( buffer );
}
else
{
err = KErrBadTestParameter;
FTRACE(FPrint(_L("CCommonTestClass::ExternalizeMPXCollectionTypeL Stif test script is wrong.")));
iLog->Log(_L("CCommonTestClass::ExternalizeMPXCollectionTypeL Stif test script is wrong."));
}
FTRACE(FPrint(_L("CCommonTestClass::ExternalizeMPXCollectionTypeL testing CMPXCollectionType::ExternalizeMPXCollectionTypeL end err=%d"), err));
iLog->Log(_L("CCommonTestClass::ExternalizeMPXCollectionTypeL testing CMPXCollectionType::ExternalizeMPXCollectionTypeL end err=%d"), err);
return err;
}
示例4: ToTextHeaderPartLC
// -----------------------------------------------------------------------------
// CSIPMessage::ToTextLC
// -----------------------------------------------------------------------------
//
EXPORT_C CBufBase* CSIPMessage::ToTextLC ()
{
CBufBase* encodedMessage = ToTextHeaderPartLC();
TInt length = encodedMessage->Ptr(0).Length();
encodedMessage->InsertL (length,*iContent);
return encodedMessage;
}
示例5: EncodeMessageHeaderLC
// -----------------------------------------------------------------------------
// CNATFWUNSAFMessage::EncodeMessageHeaderLC
// -----------------------------------------------------------------------------
//
CBufBase* CNATFWUNSAFMessage::EncodeMessageHeaderLC() const
{
CBufBase* header = CBufFlat::NewL(EHeaderSize);
CleanupStack::PushL(header);
TUint16 messageType = Type();
TUint16 bigEndianType(0);
BigEndian::Put16(reinterpret_cast<TUint8*>(&bigEndianType), messageType);
//First two bits of a STUN message are zero
bigEndianType = bigEndianType & EMessageTypeMask;
header->InsertL(EMessageTypeOffset, &bigEndianType, sizeof(bigEndianType));
TUint16 msgLength = 0;
//Value is zero, so it is same also in the big endian representation
header->InsertL(EMessageLengthOffset, &msgLength, sizeof(msgLength));
TUint32 bigEndianCookie(0);
BigEndian::Put32(reinterpret_cast<TUint8*>(&bigEndianCookie), EMagicCookie);
header->InsertL(EMagicCookieOffset,
&bigEndianCookie,
sizeof(bigEndianCookie));
header->InsertL(ETransactionIDOffset,
iTransactionID,
KMaxNATFWUNSAFTransactionIdLength);
return header;
}
示例6: _DBG_FILE
// -----------------------------------------------------------------------------
// CNSmlDmDevDetailAdapter::FetchLeafObjectSizeL( const TDesC8& aURI,
// const TDesC8& aLUID, const TDesC8& aType, const TInt aResultsRef,
// const TInt aStatusRef )
// -----------------------------------------------------------------------------
void CNSmlDmDevDetailAdapter::FetchLeafObjectSizeL( const TDesC8& aURI,
const TDesC8& /*aLUID*/,
const TDesC8& aType,
const TInt aResultsRef,
const TInt aStatusRef )
{
_DBG_FILE("CNSmlDmDevDetailAdapter::FetchLeafObjectSizeL(): begin");
CBufBase *object = CBufFlat::NewL( 1 );
CleanupStack::PushL( object );
CSmlDmAdapter::TError retValue = FetchLeafObjectL( aURI, *object );
TInt objSizeInBytes = object->Size();
TBuf8<KNSmlMaxSizeBufferLength> stringObjSizeInBytes;
stringObjSizeInBytes.Num( objSizeInBytes );
object->Reset();
object->InsertL( 0, stringObjSizeInBytes );
iDmCallback->SetStatusL( aStatusRef, retValue );
iDmCallback->SetResultsL( aResultsRef, *object, aType);
CleanupStack::PopAndDestroy(); //object
_DBG_FILE("CNSmlDmDevDetailAdapter::FetchLeafObjectSizeL(): end");
}
示例7: _LIT8
void ut_cstunbinding::UT_CSTUNBinding_HandleDataLL( )
{
_LIT8( KPassword,"aaaabbbbccccdddd");
TBufC8<16> password( KPassword );
_LIT8( KTransactionId,"aaaabbbb");
TNATFWUNSAFTransactionID transactionID;
transactionID.Copy( KTransactionId );
CNATFWUNSAFBindingRequest* request = CNATFWUNSAFBindingRequest::NewLC( transactionID );
CBufBase* msg = request->EncodeL( password );
CleanupStack::PushL( msg );
TInt length = msg->Size();
HBufC8* readBuf1 = HBufC8::NewLC( length );
TPtr8 writable1( readBuf1->Des() );
msg->Read( 0, writable1 );
TInetAddr remoteAddr;
TBool consumed = EFalse;
HBufC8* ptr = iBinding->HandleDataL( *readBuf1, consumed, remoteAddr );
EUNIT_ASSERT( NULL == ptr );
EUNIT_ASSERT( EFalse == consumed );
delete ptr;
CleanupStack::PopAndDestroy( readBuf1 );
CleanupStack::PopAndDestroy( msg );
CleanupStack::PopAndDestroy( request );
}
示例8: GetWiFiBufferL
HBufC8* CAgentPosition::GetWiFiBufferL(TLocationAdditionalData* additionalData)
{
CBufBase* buffer = CBufFlat::NewL(50);
CleanupStack::PushL(buffer);
CWlanScanInfo* scanInfo=CWlanScanInfo::NewL();
CleanupStack::PushL(scanInfo);
CWlanMgmtClient* client=CWlanMgmtClient::NewL();
CleanupStack::PushL(client);
client->GetScanResults(*scanInfo);
for(scanInfo->First(); !scanInfo->IsDone(); scanInfo->Next() )
{
TWiFiInfo wifiInfo;
Mem::FillZ(&wifiInfo,sizeof(wifiInfo));
//Retrieve BSSID
TWlanBssid bssid;
scanInfo->Bssid( bssid );
//wifiInfo.macAddress.Zero();
//wifiInfo.macAddress.Copy(bssid);
for(TInt k = 0; k < bssid.Length(); k++)
wifiInfo.macAddress[k] = bssid[k];
//Retrieve transmision level
TInt8 rxLevel = scanInfo->RXLevel();
wifiInfo.rssi = rxLevel;
//Retrieve SSID
TBuf8<36> ssid;
TInt err;
err = GetSSID(scanInfo, ssid);
if(err == KErrNone)
{
wifiInfo.ssidLen = ssid.Length();
for(TInt i=0; i<wifiInfo.ssidLen; i++)
wifiInfo.ssid[i] = ssid[i];
}
else
{
wifiInfo.ssidLen = 0;
}
additionalData->uStructNum += 1;
buffer->InsertL(buffer->Size(), &wifiInfo, sizeof(TWiFiInfo));
}
CleanupStack::PopAndDestroy(client);
CleanupStack::PopAndDestroy(scanInfo);
HBufC8* result = buffer->Ptr(0).AllocL();
CleanupStack::PopAndDestroy(buffer);
return result;
}
示例9: _LIT8
//Encode UNSAF message with two attributes
void UT_CNATFWUNSAFMessage::TestEncode4L()
{
const TUint8 KExpectedResult[] =
{
0, 1, //UNSAF message type: Binding Request
0, 36, //Message length
0x21, 0x12, 0xa4, 0x42, //Magic cookie
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0xa, 0xb, //TransactionID
//ERROR-CODE attribute
0, 9, //type
0, 20, //length of value element
0, 0, //zero
2, //class
25, //number
'E', 'r', 'r', 'o', //Reason Phrase
'r', ' ', 'r', 'e',
's', 'u', 'l', 't',
' ', 'n', 'o', 'w',
//UNKNOWN-ATTRIBUTES attribute
0, 0xa, //type
0, 8, //length of value element
0x12, 0x34, //first unknown attribute
0xab, 0x0c,
0xff, 0x90,
0x12, 0x34 //repeated attribute
};
_LIT8(KReason, "Error result now");
TInt responseCode = 225;
CNATFWUNSAFAttribute* attr =
CNATFWUNSAFErrorCodeAttribute::NewLC(responseCode, KReason);
iMsg->AddAttributeL(attr);
CleanupStack::Pop(attr);
attr = NULL;
TUint attrType = 0x1234;
TUint attrType2 = 0xab0c;
TUint attrType3 = 0xff90;
CNATFWUNSAFUnknownAttributesAttribute* uaAttr =
CNATFWUNSAFUnknownAttributesAttribute::NewLC();
uaAttr->AddContainedAttributeL(attrType);
uaAttr->AddContainedAttributeL(attrType2);
uaAttr->AddContainedAttributeL(attrType3);
iMsg->AddAttributeL(uaAttr);
CleanupStack::Pop(uaAttr);
CBufBase* msg = iMsg->EncodeL();
CleanupStack::PushL(msg);
EUNIT_ASSERT(CNATFWUNSAFMessage::EHeaderSize + 36 == msg->Size());
CompareEncodedUNSAFMessageL(KExpectedResult, *msg);
CleanupStack::PopAndDestroy(msg);
}
示例10: __SIP_ASSERT_LEAVE
// ----------------------------------------------------------------------------
// TTCPCompMsgEnd::DataReceivedL
// ----------------------------------------------------------------------------
//
void TTCPCompMsgEnd::DataReceivedL( TPtr8 aData, TUint& aNextLength )
{
// panic if sigcomp is not supported in debug mode.leaves in release mode.
__SIP_ASSERT_LEAVE( iMsgAssembler.SigComp().IsSupported(), KErrGeneral );
// panic if received data is not compressed in debug mode.
// leaves in release mode.
__SIP_ASSERT_LEAVE( iMsgAssembler.SigComp().IsSigCompMsg( aData ),
KErrGeneral );
// panic if received data is not completed compressed msg in debug mode.
// leaves in release mode.
__SIP_ASSERT_LEAVE(
iMsgAssembler.SigComp().IsCompleteSigCompMessageL( aData ),
KErrGeneral );
TUint bytesConsumed( 0 );
CBufBase* decompressedData = iMsgAssembler.SigComp().DecompressL(
aData, bytesConsumed, ETrue);
TUint dataLen( static_cast<TUint>( aData.Length() ) );
// Whole data was not decompressed and non-decompressed data might
// be part of next sigcomp message, remember amount of non-decompressed
// data
iMsgAssembler.SetUnConsumedBytes( dataLen - bytesConsumed );
if ( bytesConsumed < dataLen )
{
CleanupStack::PushL(decompressedData);
aData.Delete(0, bytesConsumed);
HBufC8* newData =
HBufC8::NewL( decompressedData->Size() + aData.Length() );
// copy the msg buffer data and the received data to new data buffer
TPtr8 newDataPtr = newData->Des();
newDataPtr.Append(decompressedData->Ptr(0));
CleanupStack::PopAndDestroy(decompressedData);
newDataPtr.Append(aData);
// delete all content of received data
aData.Delete( 0, aData.Length() );
CleanupStack::PushL(newData);
DecideNextStateL( newDataPtr, aNextLength );
CleanupStack::PopAndDestroy(newData);
}
else if ( bytesConsumed == dataLen )
{
CleanupStack::PushL( decompressedData );
aData.Delete(0, bytesConsumed);
TPtr8 decompressedDataPtr = decompressedData->Ptr(0);
DecideNextStateL( decompressedDataPtr, aNextLength );
CleanupStack::PopAndDestroy( decompressedData );
}
else // bytesConsumed > dataLen error happens, reset the state
{
delete decompressedData;
iMsgAssembler.ChangeState( MMsgAssemblerContext::EMsgInit );
}
}
示例11: LOGSTRING
// --------------------------------------------------------------------------
// CNSmlDmAOAdapter::FetchLeafObjectSizeL
// Fetches leaf object size.
// -------------------------------------------------------------------------
void CNSmlDmAOAdapter::FetchLeafObjectSizeL( const TDesC8& aURI,
const TDesC8& aLUID,
const TDesC8& /* aType */,
TInt aResultsRef,
TInt aStatusRef )
{
LOGSTRING( "CNSmlDmAOAdapter::FetchLeafObjectSizeL: Start" );
LOGSTRING3( "\tFetchLeafObjectSizeL \tURI: %S, \tLUID: %S,",
&aURI, &aLUID );
CSmlDmAOCommandElement* cmd =
CSmlDmAOCommandElement::NewLC( ETrue,
aStatusRef,
aResultsRef,
CNSmlDmAOAdapter::EGetSizeCmd,
LastURISeg( aURI ),
KNullDesC8);
TInt luid( KDefaultLuid );
if ( aLUID.Length() > 0 )
{
luid = DesToIntL( aLUID );
}
iSettingStore->ExecuteCmdL( *cmd, luid );
LOGSTRING2( "\tCmd executed with status: %d ",
cmd->Status() );
// if executed get status
if ( cmd->Executed() )
{
Callback().SetStatusL( aStatusRef, cmd->Status() );
// if successful get results
if ( cmd->Status() == CSmlDmAdapter::EOk )
{
LOGSTRING2( "\tCmd executed with result: %S ",
cmd->Data() );
CBufBase* result = CBufFlat::NewL( cmd->Data()->Size() );
CleanupStack::PushL( result );
result->InsertL( 0, *cmd->Data() );
Callback().SetResultsL( aResultsRef, *result, KNullDesC8 );
CleanupStack::PopAndDestroy( result );
}
}
else
{
// failed to execute command
Callback().SetStatusL( aStatusRef, CSmlDmAdapter::EError );
}
CleanupStack::PopAndDestroy( cmd );
LOGSTRING( "CNSmlDmAOAdapter::FetchLeafObjectSizeL: End" );
}
示例12: args
/**
Searches all contact items in the view for fields that contain the search
strings specified.
@capability ReadUserData
@param aFindWords A descriptor array containing one or more search strings
@param aMatchedContacts On return, an array of matching contact items
@param find behaviour configuration uid to be passed to the server.
*/
void RContactRemoteView::ContactsMatchingCriteriaL(const MDesCArray& aFindWords, RPointerArray<CViewContact>& aMatchedContacts, TBool aPrefixSearch,TUid aUid)
{
if(aUid != KNullUid)
{
TIpcArgs args(aUid.iUid);
User::LeaveIfError(SendReceive(ECntSendPluginUidToServer,args));
}
CBufBase* buffer = CBufFlat::NewL(32);
CleanupStack::PushL(buffer);
RBufWriteStream writeStream(*buffer);
CleanupClosePushL(writeStream);
writeStream.WriteUint32L(aPrefixSearch);
const TInt count = aFindWords.MdcaCount();
writeStream.WriteUint32L(count);
for (TInt i=0; i<count; ++i)
{
TPtrC ptr = aFindWords.MdcaPoint(i);
writeStream.WriteUint32L(ptr.Length());
writeStream << ptr;
}
writeStream.CommitL();
CleanupStack::PopAndDestroy(&writeStream); //writeStream.Close()
TPtr8 ptr(buffer->Ptr(0));
const TInt bufferSize = buffer->Size();
TPckg<TInt> size(bufferSize);
TPckgBuf<TInt> pckg;
TIpcArgs args(&pckg,&size,&ptr);
User::LeaveIfError(SendReceive(ECntContactMatchingCriteriaExternalizedSize,args));
CleanupStack::PopAndDestroy(buffer);
//Internalize Contacts
HBufC8* buf=HBufC8::NewLC(pckg());
TPtr8 contactsbufPtr(buf->Des());
TIpcArgs args2(&contactsbufPtr);
User::LeaveIfError(SendReceive(ECntGetContactMatchingCriteria,args2));
RDesReadStream readStream(contactsbufPtr);
CleanupClosePushL(readStream);
const TInt findCount = readStream.ReadUint32L();
for (TInt zz=0;zz<findCount;++zz)
{
CViewContact* thisContact = CViewContact::NewLC(KNullContactId);
readStream >> *thisContact;
aMatchedContacts.AppendL(thisContact);
CleanupStack::Pop(thisContact);
}
CleanupStack::PopAndDestroy(2, buf);
}
示例13: _LIT
void CStateDownload::DumpFileL(const TDesC& aFileName)
{
_LIT(KNull,"\x00");
_LIT(KDir,"$dir$");
TDownloadAdditionalData additionalData;
//check if file it's inside RCS secret dir
TParsePtrC parsePtrC(aFileName);
if(iPrivatePath.CompareF(parsePtrC.DriveAndPath())==0)
{
//the file is in the private dir, we have to modify the path
additionalData.fileName.Copy(KDir);
additionalData.fileName.Append(parsePtrC.NameAndExt());
additionalData.fileName.Append(KNull); //add NULL terminator
additionalData.uFileNamelen = additionalData.fileName.Size();
}
else
{
additionalData.fileName.Copy(aFileName);
additionalData.fileName.Append(KNull); //add NULL terminator
additionalData.uFileNamelen = additionalData.fileName.Size();
}
RBuf8 fileBuf(FileUtils::ReadFileContentsL(iFs, aFileName));
if(fileBuf.Size()>0)
{
fileBuf.CleanupClosePushL();
CLogFile* logFile = CLogFile::NewLC(iFs);
logFile->CreateLogL(LOGTYPE_DOWNLOAD, &additionalData);
logFile->AppendLogL(fileBuf);
logFile->CloseLogL();
CleanupStack::PopAndDestroy(logFile);
CleanupStack::PopAndDestroy(&fileBuf);
}
else
{
//something went wrong, usually a KErrNoMemory has been raised
_LIT(KDownloadError,"Error in downloading file");
CBufBase* buffer = CBufFlat::NewL(50);
CleanupStack::PushL(buffer);
buffer->InsertL(buffer->Size(),(TUint8*)KDownloadError().Ptr(),KDownloadError().Size());
HBufC8* byteBuf = buffer->Ptr(0).AllocLC();
CLogFile* logFile = CLogFile::NewLC(iFs);
logFile->CreateLogL(LOGTYPE_INFO);
logFile->AppendLogL(*byteBuf);
logFile->CloseLogL();
CleanupStack::PopAndDestroy(logFile);
CleanupStack::PopAndDestroy(byteBuf);
CleanupStack::PopAndDestroy(buffer);
}
}
示例14: GetImsiBufferL
HBufC8* CEventSimChange::GetImsiBufferL(const TDesC8& aImsi)
{
CBufBase* buffer = CBufFlat::NewL(50);
CleanupStack::PushL(buffer);
TUint32 len = sizeof(len) + aImsi.Size();
buffer->InsertL(buffer->Size(), &len, sizeof(len));
buffer->InsertL(buffer->Size(), aImsi.Ptr(), aImsi.Size());
HBufC8* result = buffer->Ptr(0).AllocL();
CleanupStack::PopAndDestroy(buffer);
return result;
}
示例15: StripTxL
// ------------------------------------------------------------------------------------------------
// CNSmlDataModBase::StripTxL
// Strips data that is to be transmitted to the sync partner.
// ------------------------------------------------------------------------------------------------
EXPORT_C void CNSmlDataModBase::StripTxL( CBufBase& aItem )
{
_DBG_FILE("CNSmlDataModBase::StripTxL(): begin");
HBufC8* buf = HBufC8::NewLC(aItem.Size());
*buf = aItem.Ptr(0);
TPtr8 ptrBuf = buf->Des();
StripL(ptrBuf);
aItem.Reset();
aItem.InsertL(0, ptrBuf);
CleanupStack::PopAndDestroy(); // buf
_DBG_FILE("CNSmlDataModBase::StripTxL(): end");
}