示例#1
0
//
// Location Response Message to PSY
//
EXPORT_C TLbsCellLocationResponseMsg::TLbsCellLocationResponseMsg(const TLbsNetSessionIdInt& aSessionId,
                                                                TInt aReason,
                                                                const TPositionInfoBase& aPosInfo): 
         TLbsNetInternalMsgBase(ECellLocationResponse, 
                           sizeof(TLbsCellLocationResponseMsg), 
                           aSessionId)
    {
    // Must make sure that the data to be stored is not bigger than the buffer.
    __ASSERT_COMPILE(sizeof(TLbsCellLocationResponseMsg) <= KMaximumMessageSizeBytes);

    iReason = aReason;
    // Check that the type of aPosInfo is valid
    TUint32 type = aPosInfo.PositionClassType();
    if (((type & EPositionInfoUnknownClass) != EPositionInfoUnknownClass)
        && ((type & EPositionInfoClass) != EPositionInfoClass)
        && ((type & EPositionCourseInfoClass) != EPositionCourseInfoClass)
        && ((type & EPositionSatelliteInfoClass) != EPositionSatelliteInfoClass)
        && ((type & EPositionExtendedSatelliteInfoClass) != EPositionExtendedSatelliteInfoClass))
        {
        User::Panic(_L("LbsNetInternal"), 1);
        }
    
    // The TPositionInfoBase is just the base class, so we need to copy over 
    // the data from the actual concrete class type.
    __ASSERT_DEBUG(aPosInfo.PositionClassSize() <= sizeof(TPositionExtendedSatelliteInfo), User::Invariant());
    Mem::Copy(&iPosInfo, &aPosInfo, aPosInfo.PositionClassSize());
    }
void CX3pChannel::OnX3pCompletion(
	TUint aRequestId, 
	TInt aReason,
	const TPositionInfoBase& aPosInfo)
	{
	INFO_PRINTF1(_L(">>>> X3P Client: Request completed :"));
	INFO_PRINTF2(_L("-> Client Id : %d"), aRequestId);
	INFO_PRINTF2(_L("-> Reason : %d"), aReason);
	
	TX3pReqComplete* reqComp = new TX3pReqComplete;
	if (NULL != reqComp)
		{
		reqComp->iRequestId = aRequestId;
		reqComp->iReason = aReason;
		Mem::Copy(&reqComp->iPosInfo,
				  &aPosInfo,
				  Min(TInt(aPosInfo.PositionClassSize()), 
					  TInt(reqComp->iPosInfo.PositionClassSize())));
		iResponseBuffer.Append(reqComp);
		}

	if (iWait.IsStarted())
		{
		iWait.AsyncStop();
		}	
	}
void CX3pChannel::GetNextResponseAsRequestCompleteL(
		TUint& aRequestId,
		TInt& aReason,
		TPositionInfoBase& aPosInfo)
	{
	if (iResponseBuffer.Count() == 0)
		{
		User::Leave(KErrNotFound);
		}
	
	if (iResponseBuffer[0]->Type() != CX3pChannel::EX3pResponseComplete)
		{
		User::Leave(KErrArgument);
		}

	// Take the response out of the buffer and copy data.
	TX3pReqComplete* reqComplete = static_cast<TX3pReqComplete*>(iResponseBuffer[0]);
	iResponseBuffer.Remove(0);
	aRequestId = reqComplete->iRequestId;
	aReason = reqComplete->iReason;
	Mem::Copy(&aPosInfo,
			  &reqComplete->iPosInfo,
			  Min(TInt(reqComplete->iPosInfo.PositionClassSize()), 
				  TInt(aPosInfo.PositionClassSize())));
	delete reqComplete;	
	}
示例#4
0
EXPORT_C TInt RLbsNetworkPositionUpdates::GetPositionInfo(TLbsNetSessionIdInt& aSessionId,
															TPositionInfoBase& aPosInfo, 
															TTime& aTargetTime, 
															TTime& aActualTime)
	{
	__ASSERT_DEBUG(iNetworkPositionProperty.Handle()!=NULL, User::Invariant());
	
	//Check that aPosInfo is either TPositionInfo, TPositionCourseInfo, TPositionSatelliteInfo or TPositionExtendedSatelliteInfo.
	const TUint32 classType = aPosInfo.PositionClassType();
	const TUint classSize = aPosInfo.PositionClassSize();
	
	if (!IsValidPositionInfoBaseType(classType, classSize))
		{
		return KErrNotSupported;
		}

	TLbsPositionUpdateData data;
	TLbsPositionUpdateDataPckg pckg(data);
	TInt err = iNetworkPositionProperty.Get(pckg);
	if(err!=KErrNone)
		{
		return err;
		}
	// is the data contained valid?
	if(data.iValidData==EFalse)
		{
		return KErrNotReady;
		}
	aTargetTime = data.iTargetTime;
	aActualTime = data.iActualTime;
	aSessionId  = data.iSessionId;
	
	// copy the postion types, this preserves the type and size of the
	// to type, so the copy is offset from the base addresses of the
	// structs. NB this relies on standard C++ class ram layout i.e. address of the
	// parent class property is always lower than the child class.
	TUint8* startCopyToAddress = reinterpret_cast<TUint8*>(&aPosInfo)+sizeof(TPositionClassTypeBase);
	const TUint8* const startCopyFromAddress = reinterpret_cast<TUint8*>(&data.iSatInfo)+sizeof(TPositionClassTypeBase);
	// NB in the future is could be very dodgy, 'cos it always assumes that the
	// strct we copy to has a TSatInfoClass in it and that this is always
	// the biggest possible derative of a TPosInfoBase class 
	const TInt numberOfBytesToCopy = classSize-sizeof(TPositionClassTypeBase);
	TUint8* endAddr = Mem::Copy(startCopyToAddress, startCopyFromAddress, numberOfBytesToCopy);
	// sanity check and return any error code
	if(endAddr != startCopyToAddress + numberOfBytesToCopy)
		{
		return KErrGeneral;
		}
	else
		{	
		return err;	
		}
	}
示例#5
0
EXPORT_C TInt RLbsNetworkPositionUpdates::SetPositionInfo(const TLbsNetSessionIdInt& aSessionId,
														  const TInt& aError, 
															const TPositionInfoBase& aPositionInfo, 
															const TTime& aActualTime)
	{
	__ASSERT_DEBUG(iNetworkPositionProperty.Handle()!=NULL, User::Invariant());

	//Check that aPosInfo is either TPositionInfo, TPositionCourseInfo, or TPositionSatelliteInfo.
	const TUint32 classType = aPositionInfo.PositionClassType();
	const TUint classSize = aPositionInfo.PositionClassSize();
	
	if (!IsValidPositionInfoBaseType(classType, classSize))
		{
		return KErrNotSupported;
		}
	
	TLbsPositionUpdateData data;
	data.iError = aError;
	data.iTargetTime = 0;
	data.iActualTime = aActualTime;
	data.iSessionId = aSessionId;
	// indicate that the property is ok, and now contains no data.
	data.iValidData = ETrue;

	// Copy the full class type, size and data from aPositionInfo into the property.
	// This will set the type of the object in the property to the type being passed in.
	TUint8* startCopyToAddress = reinterpret_cast<TUint8*>(&data.iSatInfo);
	const TUint8* const startCopyFromAddress = reinterpret_cast<const TUint8*>(&aPositionInfo);
	const TInt numberOfBytesToCopy = aPositionInfo.PositionClassSize();
	TUint8* endAddr = Mem::Copy(startCopyToAddress, startCopyFromAddress, numberOfBytesToCopy);
	// sanity check and return any error code
	if(endAddr != (startCopyToAddress + numberOfBytesToCopy))
		{
		return KErrGeneral;
		}
	TLbsPositionUpdateDataPckgC pckg(data);
	TInt err = iNetworkPositionProperty.Set(pckg);
	return err;
	}
void CX3pChannel::OnX3pReferencePositionUpdate(
	TUint aRequestId, 
	const TPositionInfoBase& aRefPosInfo)
	{
	INFO_PRINTF1(_L(">>>> X3P Client: Received reference position :"));
	INFO_PRINTF2(_L("-> Client Id : %d"), aRequestId);
	
	TX3pRefPosUpdate* refPos = new TX3pRefPosUpdate;
	if (NULL != refPos)
		{
		refPos->iRequestId = aRequestId;
		Mem::Copy(&refPos->iRefPosInfo,
				  &aRefPosInfo,
				  Min(TInt(aRefPosInfo.PositionClassSize()), 
					  TInt(refPos->iRefPosInfo.PositionClassSize())));
		iResponseBuffer.Append(refPos);
		}

	if (iWait.IsStarted())
		{
		iWait.AsyncStop();
		}	
	}