networkprotocolmodules/common/suplrrlpasn1/src/suplposinit.cpp
branchGCC_SURGE
changeset 49 5f20f71a57a3
parent 41 ec40843d536a
parent 45 15a2125aa2f3
equal deleted inserted replaced
41:ec40843d536a 49:5f20f71a57a3
     1 // Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
       
     2 // All rights reserved.
       
     3 // This component and the accompanying materials are made available
       
     4 // under the terms of "Eclipse Public License v1.0"
       
     5 // which accompanies this distribution, and is available
       
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     7 //
       
     8 // Initial Contributors:
       
     9 // Nokia Corporation - initial contribution.
       
    10 //
       
    11 // Contributors:
       
    12 //
       
    13 // Description:
       
    14 //
       
    15 
       
    16 /**
       
    17  @file
       
    18  @internalTechnology
       
    19  
       
    20 */
       
    21 
       
    22 #include "ULP.h"
       
    23 #include "suplposinit.h"
       
    24 #include "supldevloggermacros.h" 
       
    25 
       
    26 /**
       
    27 Static factory constructor
       
    28 */
       
    29 EXPORT_C CSuplPosInit* CSuplPosInit::NewL()
       
    30 	{
       
    31 	SUPLLOG(ELogP1, "CSuplPosInit::NewL() Begin\n");
       
    32 	CSuplPosInit* self = new (ELeave) CSuplPosInit();
       
    33 	CleanupStack::PushL(self);
       
    34 	self->ConstructL();
       
    35 	SUPLLOG(ELogP1, "CSuplPosInit::NewL() End\n");
       
    36 	CleanupStack::Pop(self);
       
    37 	return self;
       
    38 	}
       
    39 	
       
    40 	
       
    41 /** 
       
    42 Constructor 
       
    43 */
       
    44 CSuplPosInit::CSuplPosInit()
       
    45  : CSuplMessageBase::CSuplMessageBase(ESuplPosInit, ETrue)
       
    46 	{
       
    47 	}
       
    48 
       
    49 
       
    50 /** 
       
    51 Second stage constructor 
       
    52 */
       
    53 void CSuplPosInit::ConstructL()
       
    54 	{
       
    55 	// call the base class ConstructL() to create data structures
       
    56 	CSuplMessageBase::ConstructL();
       
    57 
       
    58 	// local reference to context object
       
    59 	OSCTXT* pctxt = iControl->getCtxtPtr();
       
    60 
       
    61 	iData->message.t =  T_UlpMessage_msSUPLPOSINIT;
       
    62 	iData->message.u.msSUPLPOSINIT = (ASN1T_SUPLPOSINIT*)rtxMemAllocZ(pctxt, sizeof(ASN1T_SUPLPOSINIT));
       
    63    	LeaveIfAllocErrorL();
       
    64 	}
       
    65 	
       
    66 
       
    67 /** 
       
    68 Destructor
       
    69 */
       
    70 CSuplPosInit::~CSuplPosInit()
       
    71 	{
       
    72 	SUPLLOG(ELogP1, "CSuplPosInit::~CSuplPosInit() Begin\n");
       
    73 	SUPLLOG(ELogP1, "CSuplPosInit::~CSuplPosInit() End\n");
       
    74 	}
       
    75 	
       
    76 
       
    77 /** 
       
    78 SetCapabilities()
       
    79 
       
    80 Sets the capabilities parameter of the outgoing message
       
    81 
       
    82 @param  aCapabilities, LBS capabilities
       
    83 @return error indication, KErrNone otherwise
       
    84 */
       
    85 EXPORT_C TInt CSuplPosInit::SetCapabilities(const TLbsNetPosCapabilities& aCapabilities)
       
    86 	{
       
    87 	__ASSERT_DEBUG(iData->message.u.msSUPLPOSINIT != NULL, User::Invariant());
       
    88 	SUPLLOG(ELogP1, "CSuplPosInit::SetCapabilities() Begin\n");
       
    89 	
       
    90 	TInt err = PopulateSetCapabilities(aCapabilities, iData->message.u.msSUPLPOSINIT->sETCapabilities);
       
    91 
       
    92 	SUPLLOG(ELogP1, "CSuplPosInit::SetCapabilities() End\n");
       
    93 	return err;
       
    94 	}
       
    95 
       
    96 
       
    97 /** 
       
    98 SetRequestedAssistanceData()
       
    99 
       
   100 Sets the requested assistance data parameter 
       
   101 
       
   102 @param  aDataReqMask, bitmask indicating requested assistance data components.
       
   103 @return error indication, KErrNone otherwise
       
   104 */
       
   105 EXPORT_C TInt CSuplPosInit::SetRequestedAssistanceData(const TLbsAsistanceDataGroup& aDataReqMask)
       
   106 	{
       
   107 	__ASSERT_DEBUG(iData->message.u.msSUPLPOSINIT != NULL, User::Invariant());
       
   108 	SUPLLOG(ELogP1, "CSuplPosInit::SetRequestedAssistanceData() Begin\n");
       
   109 	SUPLLOG2(ELogP1, "    - TLbsAsistanceDataGroup aDataReqMask  = 0x%08X\n", aDataReqMask);	\
       
   110 	
       
   111 	// pointer to message body
       
   112 	ASN1T_SUPLPOSINIT* msgBody = iData->message.u.msSUPLPOSINIT;
       
   113 	
       
   114 	if (aDataReqMask == EAssistanceDataNone)
       
   115 		{
       
   116 		// no assistance data requested
       
   117 		return KErrNone;
       
   118 		}
       
   119 	
       
   120 	// indicate parameter is set
       
   121 	msgBody->m.requestedAssistDataPresent = 1;
       
   122 	
       
   123 	if (aDataReqMask & EAssistanceDataAquisitionAssistance)
       
   124 		{
       
   125 		msgBody->requestedAssistData.acquisitionAssistanceRequested = ETrue;
       
   126 		}
       
   127 
       
   128 	if (aDataReqMask & EAssistanceDataBadSatList)
       
   129 		{
       
   130 		msgBody->requestedAssistData.realTimeIntegrityRequested = ETrue;
       
   131 		}
       
   132 
       
   133 	if (aDataReqMask & EAssistanceDataNavigationModel)
       
   134 		{
       
   135 		msgBody->requestedAssistData.navigationModelRequested = ETrue;
       
   136 
       
   137 		// Navigation Model Data
       
   138 		// Note that setting nSAT (number of satellites for which the SET has
       
   139 		// ephemeris data available) to zero means that the SLP should ignore
       
   140 		// values for gpsWeek and gpsToe. The TOE-Limit also becomes redundant.
       
   141 		// Also means there is no need to include any additional satellite 
       
   142 		// information. See OMA-TS-V1_0-20070615A p22-23 for further detail.
       
   143 		msgBody->requestedAssistData.m.navigationModelDataPresent = 1;
       
   144 		msgBody->requestedAssistData.navigationModelData.gpsWeek = 0;
       
   145 		msgBody->requestedAssistData.navigationModelData.gpsToe = 0;
       
   146 		msgBody->requestedAssistData.navigationModelData.nSAT = 0;
       
   147 		msgBody->requestedAssistData.navigationModelData.toeLimit = 0;
       
   148 		msgBody->requestedAssistData.navigationModelData.m.satInfoPresent = 0;
       
   149 		}
       
   150 
       
   151 	if (aDataReqMask & EAssistanceDataReferenceTime)
       
   152 		{
       
   153 		msgBody->requestedAssistData.referenceTimeRequested = ETrue;
       
   154    		}
       
   155    		
       
   156 	if (aDataReqMask & EAssistanceDataIonosphericModel)
       
   157 		{
       
   158 		msgBody->requestedAssistData.ionosphericModelRequested = ETrue;
       
   159 		}
       
   160    
       
   161 	if (aDataReqMask & EAssistanceDataDgpsCorrections)
       
   162 		{
       
   163 		msgBody->requestedAssistData.dgpsCorrectionsRequested = ETrue;
       
   164 		}
       
   165    
       
   166 	if (aDataReqMask & EAssistanceDataReferenceLocation)
       
   167 		{
       
   168 		msgBody->requestedAssistData.referenceLocationRequested = ETrue;
       
   169 		}
       
   170    
       
   171 	if (aDataReqMask & EAssistanceDataAlmanac)
       
   172 		{
       
   173 	   msgBody->requestedAssistData.almanacRequested = ETrue;
       
   174 		}
       
   175 
       
   176 	if (aDataReqMask & EAssistanceDataPositioningGpsUtcModel)
       
   177 		{
       
   178 		msgBody->requestedAssistData.utcModelRequested = ETrue;
       
   179 		}
       
   180 	
       
   181 	SUPLLOG(ELogP1, "CSuplPosInit::SetRequestedAssistanceData() End\n");
       
   182 	return KErrNone;
       
   183 	}
       
   184 
       
   185 
       
   186 /**	
       
   187 SetLocationId()
       
   188 
       
   189 Set the location ID parameter 
       
   190 
       
   191 Location ID - Describes the globally unique cell identification of the most current serving cell.
       
   192 	Cell Info (m) The following cell IDs are supported:
       
   193 		- GSM Cell Info
       
   194 		- WCDMA Cell Info
       
   195 		- CDMA Cell Info
       
   196 	Status (m) Describes whether or not the cell info is:
       
   197 		- Not Current, last known cell info
       
   198 		- Current, the present cell info
       
   199 		- Unknown (ie not known whether the cell id is current or not current)
       
   200 
       
   201 Note: The Status parameter does NOT apply to WCDMA optional parameters 
       
   202 (Frequency Info, Primary Scrambling Code and Measured Results List). Frequency
       
   203 Info, Primary Scrambling Code and Measured Results List, if present, are always
       
   204 considered to be correct for the current cell.
       
   205 
       
   206 @param  aLocationId, describes the current location
       
   207 @return error indication, KErrNone otherwise
       
   208 */
       
   209 EXPORT_C TInt CSuplPosInit::SetLocationId(const CSuplLocationId& aLocationId)
       
   210 	{
       
   211 	SUPLLOG(ELogP1, "CSuplPosInit::SetLocationId() Begin\n");
       
   212 	__ASSERT_DEBUG(iData->message.u.msSUPLPOSINIT != NULL, User::Invariant());
       
   213 	
       
   214 	TInt retval = PopulateLocationId(aLocationId, iData->message.u.msSUPLPOSINIT->locationId);
       
   215 	SUPLLOG2(ELogP1, "CSuplPosInit::SetLocationId() End, retval = %d\n", retval);
       
   216 	return retval;
       
   217 	}
       
   218 
       
   219 
       
   220 /**	
       
   221 SetPosition()
       
   222 
       
   223 Sets the Position parameter of the outgoing message (optional)
       
   224 
       
   225 @param  aPosInfo, position as supplied by LBS subsystem
       
   226 @return error indication, KErrNone otherwise
       
   227 */
       
   228 EXPORT_C TInt CSuplPosInit::SetPosition(const TPositionInfoBase& aPosInfo)
       
   229 	{
       
   230 	SUPLLOG(ELogP1, "CSuplPosInit::SetPosition() Begin\n");
       
   231 	__ASSERT_DEBUG(iData->message.u.msSUPLPOSINIT != NULL, User::Invariant());
       
   232 	
       
   233 	// flag that the optional position parameter is present
       
   234 	iData->message.u.msSUPLPOSINIT->m.positionPresent = 1;
       
   235 
       
   236 	TInt retval = PopulatePosition(aPosInfo, iData->message.u.msSUPLPOSINIT->position);
       
   237 	SUPLLOG2(ELogP1, "CSuplPosInit::SetPosition() End, retval = %d\n", retval);
       
   238 	return retval;
       
   239 	}
       
   240 
       
   241 
       
   242 /** 
       
   243 SetVer()
       
   244 
       
   245 Sets the Ver parameter, a hash of the received SUPL INIT message of the
       
   246 outgoing message
       
   247 
       
   248 @param aVer, pointer to buffer containing the hash of the SUPL INIT message
       
   249 @return error indication, KErrNone otherwise
       
   250 */
       
   251 EXPORT_C TInt CSuplPosInit::SetVer(const TDesC8& aVer)
       
   252 	{
       
   253 	SUPLLOG(ELogP1, "CSuplPosInit::SetVer() Begin\n");
       
   254 	__ASSERT_DEBUG(iData->message.u.msSUPLPOSINIT != NULL, User::Invariant());
       
   255 	
       
   256 	ASN1T_SUPLPOSINIT& posInit = *iData->message.u.msSUPLPOSINIT;
       
   257 	posInit.m.verPresent = 1;
       
   258 	posInit.ver.numbits = 64;
       
   259 	TPtr8 target(posInit.ver.data, 8);
       
   260 	target.Copy(aVer);
       
   261 
       
   262 	SUPLLOG(ELogP1, "CSuplPosInit::SetVer() End\n");
       
   263 	return KErrNone;
       
   264 	}
       
   265