// ----------------------------------------------------------------------------- // 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; } } }
static void DeleteSingleton( const TUid& aSingletonKey ) /** * Deletes a singleton object that was created on WServ's main heap. * * @pre The ws plugins have not been unloaded. * @param aSingletonKey The UID of the singleton which correponds to an * RProperty within WServ's category. */ { if ( gReleaseSingletonsOnExit ) { RThread t; TPckgBuf<TCallBack> cb; RProperty prop; TInt err = prop.Get(TUid::Uid(t.SecureId().iId), aSingletonKey.iUid, cb); if (err == KErrNone && cb.Length() == sizeof(TCallBack) && cb().iFunction && cb().iPtr == &User::Heap()) { // Callback is only invoked if the heap for the singleton was the // WServ heap because the WServ memory leak tests only check this // heap. cb().CallBack(); } // Errors are ignored because the purpose of this function is to free // singletons in order top make memory leak checks pass. prop.Close(); t.Close(); } }
// ----------------------------------------------------------------------------- // 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; } } }
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 */ }
/** 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()); iObserver.OnSuplInit(iChannel, reqIdUnsgn , msgPtr); LBSLOG(ELogP9, "<-S MLbsSuplPushRecObserver::OnSuplInit() SuplPush\n"); LBSLOG2(ELogP9, " > TLbsSuplPushChannel aChannel = %d\n", iChannel); LBSLOG2(ELogP9, " > TLbsSuplPushRequestId aReqId = %d\n", reqIdUnsgn); } delete msg; } else { iInitProperty.Subscribe(iStatus); SetActive(); } LBSLOG(ELogP1, "CLbsSuplPushRecChannel::RunL() End\n"); }