/** * Get the data from the transaction * * Return the minimum of client buffer size and amount left to read */ TInt CDummyWSPCOTrans::GetData(TDes8& aBuffer, RWSPCOTrans::TDataType aDataType, TInt* aSizeLeft) const { __ASSERT_DEBUG(aBuffer.MaxSize()>0, User::Panic(_L("Client buffer not allocated"),0)); //const TDesC8* requestedData=*iDataArray[aDataType]; const TDesC8* requestedData= iDataArray[aDataType]; TInt bufferSize = aBuffer.MaxSize(); TInt reqSize = requestedData->Size(); TInt* offset = iOffsetArray.At(aDataType); TInt retSize = Min(bufferSize, (reqSize - *offset)); aBuffer.Zero(); aBuffer.Append(requestedData->Mid(*offset, retSize)); *offset += retSize; if (*offset==reqSize) { *aSizeLeft = 0; *offset = 0; return KErrNone; } else { *aSizeLeft = reqSize-*offset; return RWAPConn::EMoreData; } }
// --------------------------------------------------------------------------- // CSensorDataCompensatorAxisDataHandler::Compensate // --------------------------------------------------------------------------- // TInt CSensorDataCompensatorAxisDataHandler::Compensate( TDes8& aData ) { FUNC_LOG; TInt err( KErrNone ); TInt x( 0 ); TInt y( 0 ); TInt z( 0 ); TRACE_MATRIX( "Axis data compensation matrix", iMatrix ); if ( KSensrvChannelTypeIdMagnetometerXYZAxisData == iDataType ) { INFO( "Compensating magnetometer data" ); TPckgBuf<TSensrvMagnetometerAxisData> pckg; if ( aData.MaxSize() == pckg.MaxSize() ) { pckg.Copy( aData ); iMatrix.Transform( x, y, z, pckg().iAxisXRaw, pckg().iAxisYRaw, pckg().iAxisZRaw ); INFO_3( "Compensated data Magnetometer raw [X: %d], [Y: %d], [Z: %d]", x, y, z ); pckg().iAxisXRaw = x; pckg().iAxisYRaw = y; pckg().iAxisZRaw = z; iMatrix.Transform( x, y, z, pckg().iAxisXCalibrated, pckg().iAxisYCalibrated, pckg().iAxisZCalibrated ); INFO_3( "Compensated data Magnetometer calib [X: %d], [Y: %d], [Z: %d]", x, y, z ); pckg().iAxisXCalibrated = x; pckg().iAxisYCalibrated = y; pckg().iAxisZCalibrated = z; aData.Copy( pckg ); } else { err = KErrArgument; } } else { INFO( "Compensating accelerometer data" ); TPckgBuf<TSensrvAccelerometerAxisData> pckg; if ( aData.MaxSize() == pckg.MaxSize() ) { pckg.Copy( aData ); iMatrix.Transform( x, y, z, pckg().iAxisX, pckg().iAxisY, pckg().iAxisZ ); INFO_3( "Compensated data accelerometer[X: %d], [Y: %d], [Z: %d]", x, y, z ); pckg().iAxisX = x; pckg().iAxisY = y; pckg().iAxisZ = z; aData.Copy( pckg ); } else { err = KErrArgument; } } ERROR( err, "Axis data compensation error" ); return err; }
/** * Checks that buffer size from client's message is the same * as position data class size specified in the class. * * @param aClass Position data class. * @param aBuffer Buffer containing position data class. * Leaves with KErrArgument if buffer is wrong. */ void Global::ValidatePositionClassBufferL(const TPositionClassTypeBase& aClass, const TDes8& aBuffer) { DEBUG_TRACE("ValidatePositionClassBufferL in", __LINE__); LeaveIfFalseL(aBuffer.MaxSize() >= sizeof(TPositionClassTypeBase), KErrArgument); LeaveIfFalseL(aBuffer.MaxSize() >= aClass.PositionClassSize(), KErrArgument); DEBUG_TRACE("ValidatePositionClassBufferL out", __LINE__); }
EXPORT_C TInt TRuntimeCtxId::Store(TDes8& aDes) const { if (Size() > aDes.MaxSize()) { return KErrOverflow; } aDes.Append((TUint8*)this, Size()); return KErrNone; }
void CABDataOwnerCallbackImplementation::FillBuffer(TDes8& aDes, TBool& aFinished) { TInt bytesToAdd; TChar fillChar(iFillChar); if ((iOffset + aDes.MaxSize()) < iSourceSize) { aFinished = EFalse; bytesToAdd = aDes.MaxSize(); } else { aFinished = ETrue; bytesToAdd = iSourceSize - iOffset; } aDes.Fill(fillChar, bytesToAdd); iOffset += bytesToAdd; }
void CDummyWSPCLConn::UnitWaitPushL(TDes8& aBody,TDes8& aHeaders,TPushID& aID,TRequestStatus& aStatus) { __ASSERT_DEBUG(aBody.MaxSize()>0, User::Panic(_L("Msg Body Buffer Not Allocated"),0)); __ASSERT_DEBUG(aHeaders.MaxSize()>0, User::Panic(_L("Msg Header Buffer Not Allocated"),0)); aStatus=KRequestPending; //point to the Msg Buffers iClientBody=&aBody; iClientHeaders=&aHeaders; iID = &aID; iStatus=(&aStatus); //Initialise Buffers to zero Before Appending iClientBody->Zero(); iClientHeaders->Zero(); *iID =0; //Invoke the dummy Observer UnitWaitPush STATIC_CAST(CDummyWapStack* , Dll::Tls())->Observer().DWSOUnitWaitPushL(*this); }
// --------------------------------------------------------------------------- // Copies descriptor from internal buffer to aData buffer. // Size of the data to be copied is read from the buffer. // Leaves if target descriptor cannot accept descriptor in buffer. // --------------------------------------------------------------------------- // void CPosReadBufStorage::GetL( TDes8& aData ) { TInt size; GetL( size ); if ( size >= 0 && aData.MaxSize() >= size && iPointer + size <= iBoundary ) { aData = TPtrC8( (TUint8*) iPointer, size ); iPointer += size; } else { User::Leave( KErrCorrupt ); } }
// ----------------------------------------------------------------------------- // RPhCltMessenger::Receive // // Receive message. // ----------------------------------------------------------------------------- // void RPhCltMessenger::Receive( TRequestStatus& aStatus, TInt& aMessageSize, TDes8& aMessagePayload ) { __ASSERT_ALWAYS( SubSessionHandle(), User::Panic( KPhClientPanicCategory, EPhCltClientSidePanicNullHandle ) ); // Set message size variables to be byte descriptor. iReceiveMessageSize.Set( ( TUint8* )&aMessageSize, 0, sizeof( TInt ) ) ; iMessengerParameters.iReceiveMessageSizePtr = &iReceiveMessageSize; iMessengerParameters.iReceiveBufferMaxSize = aMessagePayload.MaxSize(); SendReceive( EPhoneServerMessengerSubSessionReceive, TIpcArgs( &iMesParPckg, &aMessagePayload, &iReceiveMessageSize ), aStatus ); }