本文整理汇总了C++中TPckgBuf::Length方法的典型用法代码示例。如果您正苦于以下问题:C++ TPckgBuf::Length方法的具体用法?C++ TPckgBuf::Length怎么用?C++ TPckgBuf::Length使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TPckgBuf
的用法示例。
在下文中一共展示了TPckgBuf::Length方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: HandleRequestForEventL
// -----------------------------------------------------------------------------
// CPosLmDbManEventHandler::HandleRequestForEventL
//
// (other items were commented in a header).
// -----------------------------------------------------------------------------
//
void CPosLmDbManEventHandler::HandleRequestForEventL(
const RMessagePtr2& aMessage)
{
// check that descriptor parameters are OK so that server
// won't panic when trying to write.
TPckgBuf<TPosLmDatabaseEvent> event;
TPckgBuf<TInt> length;
TInt eventMaxLength = aMessage.GetDesMaxLength(KPosLmServerDbManEventArg);
TInt lengthMaxLength = aMessage.GetDesMaxLength(KPosLmServerUriLengthArg);
if (eventMaxLength != event.Length() ||
lengthMaxLength != length.Length())
{
PanicClient(aMessage, EPosUnableToReadOrWriteDataToClient);
return;
}
if (iEventQueue.Count() > 0)
{
// Send the first event in the queue to the client.
WriteEventAndComplete(aMessage);
}
else
{
// No events in queue. Put the message on hold.
if (!iHoldingMessage.IsNull())
{
PanicClient(aMessage,
EPosEventNotifierAlreadyHasOutstandingRequest);
}
else
{
iHoldingMessage = aMessage;
}
}
}
示例2: HandleRequestForEventL
// -----------------------------------------------------------------------------
// CPosLmEventHandler::HandleRequestForEventL
//
// (other items were commented in a header).
// -----------------------------------------------------------------------------
//
void CPosLmEventHandler::HandleRequestForEventL(
const RMessagePtr2& aMessage)
{
TPckgBuf<TPosLmEvent> event;
TInt desMaxLength = aMessage.GetDesMaxLength(KPosLmServerEventArg);
if (desMaxLength != event.Length())
{
PanicClient(aMessage, EPosUnableToReadOrWriteDataToClient);
return;
}
if (iEventQueue.Count() > 0)
{
// Send the first event in the queue to the client.
WriteEventAndComplete(aMessage, iEventQueue[0]);
iEventQueue.Remove(0);
}
else
{
// No events in queue. Put the message on hold.
if (!iHoldingMessage.IsNull())
{
PanicClient(aMessage,
EPosEventNotifierAlreadyHasOutstandingRequest);
}
else
{
iHoldingMessage = aMessage;
}
}
}
示例3: DoOpen
void CProtocolExadump::DoOpen(TInt aSnaplen)
/**
* Try opening the dump file.
*
* Opens the dump file and writes the file header to it.
*
* @param aSnaplen The snap length
*/
{
/** @code */
// Just close the previous, if called with open file.
if (iOpen > 0)
{
iDumpFile.Close();
iFS.Close();
}
// Allocate a working buffer for the packet frames
// (include packet header and snaplen).
delete iBuffer;
iBuffer = HBufC8::NewMax(aSnaplen + sizeof(struct pcap_file_header));
if (iBuffer == NULL)
{
iOpen = KErrNoMemory;
return;
}
_LIT(KDumpFile, "exedump.dat"); // the name of the dump file.
iOpen = iFS.Connect();
if (iOpen != KErrNone)
return;
iOpen = iDumpFile.Replace(iFS, KDumpFile, EFileWrite);
if (iOpen != KErrNone)
{
iFS.Close();
return;
}
// Write the header
TPckgBuf<struct pcap_file_header> hdr;
hdr().magic = TCPDUMP_MAGIC;
hdr().version_major = PCAP_VERSION_MAJOR;
hdr().version_minor = PCAP_VERSION_MINOR;
hdr().thiszone = 0;
hdr().snaplen = aSnaplen;
hdr().sigfigs = 0;
hdr().linktype = DLT_RAW;
iDumpFile.Write(hdr, hdr.Length());
iOpen = 1;
return;
/** @endcode */
}
示例4: RunL
/**
Called when the INIT property is changed and once on the construction of the object. Extracts
the message from the INIT property, notifies both the observer by calling the
MLbsSuplPushRecObserver::OnSuplInit function and the sender by setting the ACK property.
Then it resubscribes for the INIT property to listen for next messages.
@see CSuplPushImpl
@see MLbsSuplPushRecObserver::OnSuplInit
@see CActive::RunL
*/
void CLbsSuplPushRecChannel::RunL()
{
LBSLOG(ELogP1, "CLbsSuplPushRecChannel::RunL() Begin\n");
if(iStatus==KErrNone)
{
iInitProperty.Subscribe(iStatus);
SetActive();
TPckgBuf<TInt> length;
TInt err = RProperty::Get(iPropOwnerSecureId, iInitPropKey, length);
//The INIT propery has been defined but not set yet.
if(err==KErrNone && length.Length()==0)
{
LBSLOG(ELogP1, "CLbsSuplPushRecChannel::RunL() - err==KErrNone && length.Length()==0 End\n");
return;
}
//Can't do anything here, just resubscribe
if(err!=KErrOverflow || length()<=0)
{
//The property must be set in the correct value.
__ASSERT_DEBUG(0, User::Invariant());
LBSLOG(ELogP1, "CLbsSuplPushRecChannel::RunL() - err!=KErrOverflow || length()<=0 End\n");
return;
}
TInt len = length() + 2*sizeof(TInt);
HBufC8* msg = HBufC8::New(len);
//Not enough memory to handle the message, just resubscribe
if(msg==0)
{
LBSLOG(ELogP1, "CLbsSuplPushRecChannel::RunL() - msg==0 End\n");
return;
}
TPtr8 ptr = msg->Des();
err = RProperty::Get(iPropOwnerSecureId, iInitPropKey, ptr);
if(err!=KErrNone || ptr.Length()!=len)
{
delete msg;
//Unexpected environment error or the length of the message is not equal the length declared in
//the header.
__ASSERT_DEBUG(0, User::Invariant());
LBSLOG(ELogP1,
"CLbsSuplPushRecChannel::RunL() RProperty::Get(iPropOwnerSecureId, iInitPropKey, ptr)|| ptr.Length()!=len End\n");
return;
}
TPckgBuf<TInt> reqId;
reqId.Copy(msg->Mid(sizeof(TInt), sizeof(TInt)));
if(reqId()<=0)
{
delete msg;
//Message is corrupted, the reqId must be > 0.
__ASSERT_DEBUG(0, User::Invariant());
LBSLOG(ELogP1, "CLbsSuplPushRecChannel::RunL() - reqId()<=0 End\n");
return;
}
TInt ackId = 0;
err = RProperty::Get(iPropOwnerSecureId, iAckPropKey, ackId);
if(err!=KErrNone || ackId<0)
{
delete msg;
if(ackId<0)
{
RProperty::Set(iPropOwnerSecureId, iAckPropKey, 0);
}
//Unexpected environment error or wrong ackId, it must be > 0.
__ASSERT_DEBUG(0, User::Invariant());
LBSLOG(ELogP1,
"CLbsSuplPushRecChannel::RunL() - RProperty::Get(iPropOwnerSecureId, iAckPropKey, ackId)!=KErrNone || ackId<0 End\n");
return;
}
//We notify the observer only if message was not delivered before
if(ackId!=reqId())
{
TLbsSuplPushRequestId reqIdUnsgn = reqId();
TPtrC8 msgPtr = msg->Right(length());
err = RProperty::Set(iPropOwnerSecureId, iAckPropKey, reqId());
//Unexpected environment error.
__ASSERT_DEBUG(err==KErrNone, User::Invariant());
//.........这里部分代码省略.........