本文整理汇总了C++中CBufBase::InsertL方法的典型用法代码示例。如果您正苦于以下问题:C++ CBufBase::InsertL方法的具体用法?C++ CBufBase::InsertL怎么用?C++ CBufBase::InsertL使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CBufBase
的用法示例。
在下文中一共展示了CBufBase::InsertL方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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;
}
示例2: AddObjectToBufferL
// -----------------------------------------------------------------------------
// CNSmlDmDevDetailAdapter::AddObjectToBufferL()
// -----------------------------------------------------------------------------
void CNSmlDmDevDetailAdapter::AddObjectToBufferL( CBufBase& aCrcBuf,
const TDesC8& aURI )
{
CBufBase* buf = CBufFlat::NewL( 1 );
CleanupStack::PushL( buf );
FetchLeafObjectL( aURI, *buf );
aCrcBuf.InsertL( aCrcBuf.Size(), buf->Ptr(0) );
_LIT8( KNSmlDmSeparator, ";" );
aCrcBuf.InsertL( aCrcBuf.Size(), KNSmlDmSeparator );
CleanupStack::PopAndDestroy(); //buf
}
示例3: 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;
}
示例4: GetTTimeBufferL
HBufC8* CAgentAddressbook::GetTTimeBufferL(const TTime aTime)
{
TInt64 timestamp = aTime.Int64();
CBufBase* buffer = CBufFlat::NewL(50);
CleanupStack::PushL(buffer);
TUint32 len = sizeof(len) + sizeof(timestamp);
buffer->InsertL(buffer->Size(), &len, sizeof(len));
buffer->InsertL(buffer->Size(), ×tamp, sizeof(timestamp));
HBufC8* result = buffer->Ptr(0).AllocL();
CleanupStack::PopAndDestroy(buffer);
return result;
}
示例5: ToTextLC
// -----------------------------------------------------------------------------
// CSIPMessage::ToTextLC
// -----------------------------------------------------------------------------
//
EXPORT_C CBufBase* CSIPMessage::ToTextLC ()
{
CBufBase* encodedMessage = ToTextHeaderPartLC();
TInt length = encodedMessage->Ptr(0).Length();
encodedMessage->InsertL (length,*iContent);
return encodedMessage;
}
示例6: FetchLeafObjectSizeL
// -----------------------------------------------------------------------------
// 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: GetCellIdBufferL
HBufC8* CAgentPosition::GetCellIdBufferL()
{
TUint cellId=0;
TUint lac=0;
TInt32 signalStrength = 0;
TBuf<CTelephony::KNetworkIdentitySize> network;
TBuf<CTelephony::KNetworkCountryCodeSize> cc;
TBuf<CTelephony::KNetworkLongNameSize> oper;
iPhone->GetCellIDSync(cellId, lac, network, cc, oper);
iPhone->GetSignalStrengthSync(signalStrength); // signalStrength is set to 0 if not available
cellId = cellId & 0xFFFF; // jo, maybe redundant
CBufBase* buffer = CBufFlat::NewL(50);
CleanupStack::PushL(buffer);
TCellInfo cellInfo;
TTime now;
now.UniversalTime();
//TInt64 filetime = GetFiletime(now);
TInt64 filetime = TimeUtils::GetFiletime(now);
cellInfo.filetime.dwHighDateTime = (filetime >> 32);
cellInfo.filetime.dwLowDateTime = (filetime & 0xFFFFFFFF);
// Converts CountryCode from string to number
TLex lex(cc);
lex.Val(cellInfo.cell.dwMobileCountryCode, EDecimal);
// Converts NetworkCode from string to number
lex.Assign(network);
lex.Val(cellInfo.cell.dwMobileNetworkCode, EDecimal);
cellInfo.cell.dwLocationAreaCode = lac;
cellInfo.cell.dwCellID = cellId;
cellInfo.cell.dwTimingAdvance = 0; // there are no public APIs for this
cellInfo.cell.dwRxLevel = signalStrength;
cellInfo.cell.dwRxQuality = 0;
TUint32 type = TYPE_CELL;
buffer->InsertL(0, &type, sizeof(TUint32));
buffer->InsertL(buffer->Size(), &cellInfo, sizeof(TCellInfo));
HBufC8* result = buffer->Ptr(0).AllocL();
CleanupStack::PopAndDestroy(buffer);
return result;
}
示例8: DDFVersionL
// --------------------------------------------------------------------------
// CNSmlDmAOAdapter::DDFVersionL
// Returns ddf version nr
// --------------------------------------------------------------------------
void CNSmlDmAOAdapter::DDFVersionL( CBufBase& aDDFVersion )
{
LOGSTRING( "CNSmlDmAOAdapter::DDFVersionL: Start" );
aDDFVersion.InsertL( 0, KNSmlDmAOAdapterDDFVersion );
LOGSTRING( "CNSmlDmAOAdapter::DDFVersionL:End" );
}
示例9: 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;
}
示例10: EncodeL
// -----------------------------------------------------------------------------
// CNATFWUNSAFAttribute::EncodeL
// -----------------------------------------------------------------------------
//
HBufC8* CNATFWUNSAFAttribute::EncodeL() const
{
HBufC8* value = EncodeValueL();
CleanupStack::PushL(value);
TInt attrValLength = value->Length();
//Pad non-DWORD-boundary aligned attributes with spaces if needed. Spaces
//used instead of \0 in order to not mess up buggy C implementations.
const TInt KGranularity = 4;
TInt bytesInLastBlock = attrValLength % KGranularity;
TInt bytesToAppend = KGranularity - bytesInLastBlock;
if (0 < bytesInLastBlock && !IsWordBoundaryAligned(Type()))
{
CBufBase* valueBuf = CBufFlat::NewL(attrValLength + bytesToAppend);
CleanupStack::PushL(valueBuf);
valueBuf->InsertL(0, *value, attrValLength);
const TChar KSpace(' ');
for (TInt i = 0; i < bytesToAppend; ++i)
{
valueBuf->InsertL(valueBuf->Size(), &KSpace, 1);
}
// Store value pointer for proper cleanupstack handling
HBufC8* oldValue = value;
value = valueBuf->Ptr(0).AllocL();
CleanupStack::PopAndDestroy(valueBuf);
CleanupStack::PopAndDestroy( oldValue );
CleanupStack::PushL( value );
}
HBufC8* attribute = HBufC8::NewLC(value->Length() + EValueOffset);
TPtr8 ptr = attribute->Des();
ptr.FillZ(EValueOffset);
NATFWUNSAFUtils::WriteNetworkOrder16L(ptr, ETypeOffset, Type());
NATFWUNSAFUtils::WriteNetworkOrder16L(ptr,
ELengthOffset,
static_cast<TUint16>(attrValLength));
ptr.Append(*value);
CleanupStack::Pop(attribute);
CleanupStack::PopAndDestroy(value);
return attribute;
}
示例11: FetchLeafObjectSizeL
// --------------------------------------------------------------------------
// 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: ChildURIListL
// ------------------------------------------------------------------------
// CNSmlDmAOAdapter::ChildURIListL
// Fetches child nodes of a node. these may be either all VENDORCONFIG
// nodes or leaf nodes under a VENDORCONFIG node.
// ------------------------------------------------------------------------
void CNSmlDmAOAdapter::ChildURIListL( const TDesC8& aURI,
const TDesC8& aLUID,
const CArrayFix<TSmlDmMappingInfo>&
/*aPreviousURISegmentList*/,
TInt aResultsRef,
TInt aStatusRef )
{
LOGSTRING( "CNSmlDmAOAdapter::ChildURIListL: Start" );
LOGSTRING3( "\tChildURIListL URI: %S, LUID: %S ",
&aURI, &aLUID );
CBufBase* resultList = CBufFlat::NewL( KSmlMaxURISegLen );
CleanupStack::PushL( resultList );
// get all leaf nodes below VENDORCONFIG node
if ( !aURI.Compare( KNSmlDmAOAdapterAO ) )
{
CSmlDmAOCommandElement* cmd =
CSmlDmAOCommandElement::NewLC( EFalse,
aStatusRef,
aResultsRef,
CNSmlDmAOAdapter::EGetCmd,
KNullDesC8,
KNullDesC8 );
TInt luid( KDefaultLuid );
if ( aLUID.Length() > 0 )
{
luid = DesToIntL( aLUID );
}
iSettingStore->ExecuteCmdL( *cmd, luid );
LOGSTRING2( "\tCmd executed with status: %d ",
cmd->Status() );
Callback().SetStatusL( aStatusRef, cmd->Status() );
if( cmd->Status() == CSmlDmAdapter::EOk )
{
resultList->InsertL( 0, *cmd->Data() );
Callback().SetResultsL( aResultsRef,
*resultList,
KNullDesC8 );
}
CleanupStack::PopAndDestroy( cmd );
}
CleanupStack::PopAndDestroy( resultList );
LOGSTRING( "CNSmlDmAOAdapter::ChildURIListL: End" );
}
示例13: DumpFileL
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: 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");
}
示例15: EncodeL
// -----------------------------------------------------------------------------
// CNATFWUNSAFMessage::EncodeL
// 1. Encode the UNSAF message normally.
// 2. Create a MESSAGE-INTEGRITY attribute. This updates also the header's
// length field to include the MESSAGE-INTEGRITY before computing the hash.
// 3. Encode it to the last attribute of the UNSAF message.
// 4. Create a FINGERPRINT attribute. This updates also the header's
// length field to include the FINGERPRINT before computing the hash.
// 5. Encode it to the last attribute of the UNSAF message.
// -----------------------------------------------------------------------------
//
EXPORT_C CBufBase* CNATFWUNSAFMessage::EncodeL(
const TDesC8& aSharedSecret,
TBool aUseFingerprint) const
{
CBufBase* msg = EncodeL();
CleanupStack::PushL(msg);
if ( aSharedSecret.Length() )
{
//Long term credentials need be used if there's a REALM attribute
CNATFWUNSAFMessageIntegrityAttribute* msgIntegrity =
CNATFWUNSAFMessageIntegrityAttribute::NewLC(aSharedSecret, *msg,
HasAttribute( CNATFWUNSAFAttribute::ERealm ));
HBufC8* encodedMsgIntegrity = msgIntegrity->EncodeL();
CleanupStack::PushL(encodedMsgIntegrity);
msg->InsertL(msg->Size(), *encodedMsgIntegrity);
CleanupStack::PopAndDestroy(encodedMsgIntegrity);
CleanupStack::PopAndDestroy(msgIntegrity);
}
if ( aUseFingerprint )
{
CNATFWUNSAFFingerprintAttribute* fingerprint =
CNATFWUNSAFFingerprintAttribute::NewLC(*msg);
HBufC8* encodedFingerprint = fingerprint->EncodeL();
CleanupStack::PushL(encodedFingerprint);
msg->InsertL(msg->Size(), *encodedFingerprint);
CleanupStack::PopAndDestroy(encodedFingerprint);
CleanupStack::PopAndDestroy(fingerprint);
}
CleanupStack::Pop(msg);
msg->Compress();
return msg;
}