supl/locationomasuplprotocolhandler/asnconverterpluginapi/src/epos_comasuplposinit.cpp
changeset 0 667063e416a2
equal deleted inserted replaced
-1:000000000000 0:667063e416a2
       
     1 /*
       
     2 * Copyright (c) 2002-2005 Nokia Corporation and/or its subsidiary(-ies). 
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:  Header file for supl Pos init message
       
    15 *
       
    16 */
       
    17 
       
    18 // INCLUDE FILES
       
    19 
       
    20 #include <e32def.h>
       
    21 
       
    22 #include "epos_comasuplposinit.h"
       
    23 #include "lbs/epos_comasuplreqasstdata.h"
       
    24 #include "lbs/epos_comasuplposition.h"
       
    25 #include "lbs/epos_comasuplvelocity.h"
       
    26 #include "lbs/epos_comasuplsetcapabilities.h"
       
    27 #include "lbs/epos_comasuplpospayload.h"
       
    28 #include "epos_comasuplpos.h"
       
    29 #include "epos_comasuplsessionid.h"
       
    30 #include "epos_comasupllocationid.h"
       
    31 #include "lbs/epos_eomasuplposerrors.h"
       
    32 
       
    33 // ============================ MEMBER FUNCTIONS of COMASuplPosInit===============================
       
    34 // -----------------------------------------------------------------------------
       
    35 // COMASuplPosInit::NewL() 
       
    36 // (other items were commented in a header).
       
    37 // -----------------------------------------------------------------------------
       
    38 //
       
    39 EXPORT_C COMASuplPosInit* COMASuplPosInit::NewL()
       
    40     {
       
    41     COMASuplPosInit* self = new( ELeave ) COMASuplPosInit;
       
    42     CleanupStack::PushL( self );
       
    43     self->ConstructL();
       
    44     CleanupStack::Pop(self);
       
    45     return self;
       
    46     }
       
    47     
       
    48 // -----------------------------------------------------------------------------
       
    49 // COMASuplPosInit::~COMASuplPosInit() 
       
    50 // (other items were commented in a header).
       
    51 // -----------------------------------------------------------------------------
       
    52 //    
       
    53 EXPORT_C COMASuplPosInit::~COMASuplPosInit()
       
    54     {
       
    55 	if(iReqAsstData)
       
    56 		{
       
    57 		delete iReqAsstData;
       
    58 		iReqAsstData = NULL;
       
    59 		}
       
    60 	if(iPosPayload)
       
    61 		{
       
    62 		delete iPosPayload;
       
    63 		iPosPayload = NULL;
       
    64 		}
       
    65 	if(iVelocity)
       
    66 		{
       
    67 		delete iVelocity;
       
    68 		iVelocity = NULL;
       
    69 		}
       
    70 	if(iPosition)
       
    71 		{
       
    72 		delete iPosition;
       
    73 		iPosition = NULL;
       
    74 		}
       
    75 	}
       
    76 
       
    77 // -----------------------------------------------------------------------------
       
    78 // COMASuplPosInit::SetSuplPosInit() 
       
    79 // (other items were commented in a header).
       
    80 // -----------------------------------------------------------------------------
       
    81 //   			
       
    82 EXPORT_C void COMASuplPosInit::SetSuplPosInit(COMASuplSETCapabilities* aSuplSETCaps,
       
    83 						  			         COMASuplLocationId* aSuplLocationId,
       
    84 						  			         TBool aeCID)
       
    85 {	
       
    86 	delete iLocationId;
       
    87 	iLocationId = NULL;
       
    88 	iSETCapabilities = aSuplSETCaps;
       
    89 	iLocationId = aSuplLocationId;
       
    90 	ieCID  = aeCID;
       
    91 }	
       
    92 
       
    93 // -----------------------------------------------------------------------------
       
    94 // COMASuplPosInit::RequestAssistanceData() 
       
    95 // (other items were commented in a header).
       
    96 // -----------------------------------------------------------------------------
       
    97 //   			
       
    98 EXPORT_C TInt COMASuplPosInit::RequestAssistanceData(COMASuplReqAsstData*& aReqAsstData)const
       
    99 {
       
   100 	if(iOptionalMask & (1<<(0)))
       
   101 		{
       
   102 		aReqAsstData = iReqAsstData;		
       
   103 		return KErrNone;
       
   104 		}
       
   105 	else
       
   106 		{
       
   107 		return KErrOMASuplParamNotSet;
       
   108 		}
       
   109 }						  			   
       
   110 
       
   111 // -----------------------------------------------------------------------------
       
   112 // COMASuplPosInit::SetRequestAssistanceData() 
       
   113 // (other items were commented in a header).
       
   114 // -----------------------------------------------------------------------------
       
   115 //   			
       
   116 EXPORT_C void COMASuplPosInit::SetRequestAssistanceData(COMASuplReqAsstData* aReqAsstData)
       
   117 {	
       
   118 	delete iReqAsstData;
       
   119 	iReqAsstData = NULL;
       
   120 	
       
   121 	iReqAsstData = aReqAsstData;
       
   122 	if(iReqAsstData)
       
   123 		iOptionalMask |= LEFTSHIFT(0);
       
   124 }	
       
   125 
       
   126 
       
   127 // -----------------------------------------------------------------------------
       
   128 // COMASuplPosInit::Position()
       
   129 // (other items were commented in a header).
       
   130 // -----------------------------------------------------------------------------
       
   131 //   			
       
   132 EXPORT_C TInt COMASuplPosInit::Position(COMASuplPosition*& aPosition)const
       
   133 {
       
   134 	if(iOptionalMask & (1<<(1)))
       
   135 		{
       
   136 		aPosition = iPosition;		
       
   137 		return KErrNone;
       
   138 		}
       
   139 	else
       
   140 		{
       
   141 		return KErrOMASuplParamNotSet;
       
   142 		}
       
   143 }						  			   
       
   144 
       
   145 // -----------------------------------------------------------------------------
       
   146 // COMASuplPosInit::SetPosition() 
       
   147 // (other items were commented in a header).
       
   148 // -----------------------------------------------------------------------------
       
   149 //   			
       
   150 EXPORT_C void COMASuplPosInit::SetPosition(COMASuplPosition* aPosition)
       
   151 {	
       
   152 	delete iPosition;
       
   153 	iPosition = NULL;
       
   154 	iPosition = aPosition;
       
   155 	if(iPosition)
       
   156 		iOptionalMask |= LEFTSHIFT(1);
       
   157 }	
       
   158 
       
   159 
       
   160 // -----------------------------------------------------------------------------
       
   161 // COMASuplPosInit::Ver()
       
   162 // (other items were commented in a header).
       
   163 // -----------------------------------------------------------------------------
       
   164 //   			
       
   165 EXPORT_C TInt COMASuplPosInit::Ver(TDes8& aVer)const
       
   166 {
       
   167 	if(iOptionalMask & (1<<(2)))
       
   168 		{
       
   169 		aVer.Copy(iVer);		
       
   170 		return KErrNone;
       
   171 		}
       
   172 	else
       
   173 		{
       
   174 		return KErrOMASuplParamNotSet;
       
   175 		}
       
   176 }						  			   
       
   177 
       
   178 // -----------------------------------------------------------------------------
       
   179 // COMASuplPosInit::SetVer() 
       
   180 // (other items were commented in a header).
       
   181 // -----------------------------------------------------------------------------
       
   182 //   			
       
   183 EXPORT_C void COMASuplPosInit::SetVer(TDesC8& aVer)
       
   184 {
       
   185 	iVer.Copy(aVer);
       
   186 	iOptionalMask |= LEFTSHIFT(2);
       
   187 }  
       
   188 
       
   189 // -----------------------------------------------------------------------------
       
   190 // COMASuplPosInit::SuplPosPayload()
       
   191 // (other items were commented in a header).
       
   192 // -----------------------------------------------------------------------------
       
   193 //   
       
   194 	
       
   195 EXPORT_C TInt COMASuplPosInit::SuplPosPayload(COMASuplPosPayload*& aPosPayload)const
       
   196 {
       
   197 	if(iOptionalMask & (1<<(3)))
       
   198 		{
       
   199 		aPosPayload = iPosPayload;		
       
   200 		return KErrNone;
       
   201 		}
       
   202 	else
       
   203 		{
       
   204 		return KErrOMASuplParamNotSet;
       
   205 		}
       
   206 }						  			   
       
   207 
       
   208 // -----------------------------------------------------------------------------
       
   209 // COMASuplPosInit::SetSuplPosPayload() 
       
   210 // (other items were commented in a header).
       
   211 // -----------------------------------------------------------------------------
       
   212 //   	
       
   213 EXPORT_C void COMASuplPosInit::SetSuplPosPayload(COMASuplPosPayload* aPosPayload)
       
   214 {	
       
   215 	delete iPosPayload;
       
   216 	iPosPayload = NULL;
       
   217 	iPosPayload = aPosPayload;
       
   218 	if(iPosPayload)
       
   219 		{
       
   220 		iOptionalMask |= LEFTSHIFT(3);	
       
   221 		}		
       
   222 }	  
       
   223 
       
   224 // -----------------------------------------------------------------------------
       
   225 // COMASuplPosInit::SuplPosPayload()
       
   226 // (other items were commented in a header).
       
   227 // -----------------------------------------------------------------------------
       
   228 //   
       
   229 	
       
   230 EXPORT_C TInt COMASuplPosInit::Velocity(COMASuplVelocity*& aVelocity)const
       
   231 {
       
   232 	if(iOptionalMask & (1<<(4)))
       
   233 		{
       
   234 		aVelocity = iVelocity;		
       
   235 		return KErrNone;
       
   236 		}
       
   237 	else
       
   238 		{
       
   239 		return KErrOMASuplParamNotSet;
       
   240 		}
       
   241 }						  			   
       
   242 
       
   243 // -----------------------------------------------------------------------------
       
   244 // COMASuplPosInit::SetSuplPosPayload() 
       
   245 // (other items were commented in a header).
       
   246 // -----------------------------------------------------------------------------
       
   247 //   	
       
   248 EXPORT_C void COMASuplPosInit::SetVelocity(COMASuplVelocity* aVelocity)
       
   249 {	
       
   250 	delete iVelocity;
       
   251 	iVelocity = NULL;
       
   252 	iVelocity = aVelocity;
       
   253 	if(iVelocity)
       
   254 		{
       
   255 		iOptionalMask |= LEFTSHIFT(4);	
       
   256 		}		
       
   257 }	  
       
   258 
       
   259 // -----------------------------------------------------------------------------
       
   260 // COMASuplPosInit::COMASuplPosInit() 
       
   261 // (other items were commented in a header).
       
   262 // -----------------------------------------------------------------------------
       
   263 //
       
   264 EXPORT_C COMASuplPosInit::COMASuplPosInit()
       
   265 	{
       
   266 	ieCID = EFalse;	
       
   267 	}
       
   268 // -----------------------------------------------------------------------------
       
   269 // COMASuplPosInit::ConstructL() 
       
   270 // (other items were commented in a header).
       
   271 // -----------------------------------------------------------------------------
       
   272 //
       
   273 EXPORT_C void COMASuplPosInit::ConstructL()
       
   274     {
       
   275     iOptionalMask = 0;
       
   276     SetMessageType(COMASuplAsnMessageBase::ESUPL_POSINIT);
       
   277     }
       
   278 
       
   279 // -----------------------------------------------------------------------------
       
   280 // COMASuplPosInit::IntializeECellId() 
       
   281 // (other items were commented in a header).
       
   282 // -----------------------------------------------------------------------------
       
   283 //   			
       
   284 EXPORT_C void COMASuplPosInit::SetECellId(TOMASuplECellInfo& aECId)
       
   285 	{
       
   286 		iMmCellInfo = aECId;
       
   287 		ieCID = ETrue ;
       
   288 	}
       
   289 
       
   290 // -----------------------------------------------------------------------------
       
   291 // COMASuplPosInit::CloneL() 
       
   292 // (other items were commented in a header).
       
   293 // -----------------------------------------------------------------------------
       
   294 //   			
       
   295 EXPORT_C void COMASuplPosInit::Clone(const COMASuplAsnMessageBase* aPosInit,TInt& aErrorCode)
       
   296     {
       
   297     TRAP(aErrorCode, CloneBaseL(aPosInit,aErrorCode));
       
   298     COMASuplPosInit* posInit = (COMASuplPosInit*)aPosInit;
       
   299     if(posInit->iSETCapabilities && posInit->iLocationId)
       
   300         TRAP(aErrorCode,SetSuplPosInit(static_cast<COMASuplSETCapabilities*>(posInit->iSETCapabilities->CloneL()),posInit->iLocationId->CloneL(),posInit->ieCID));
       
   301     if(posInit->iPosition)
       
   302         TRAP(aErrorCode,SetPosition(static_cast<COMASuplPosition*>(posInit->iPosition->CloneL())));
       
   303     if(posInit->iReqAsstData)
       
   304         TRAP(aErrorCode,SetRequestAssistanceData(static_cast<COMASuplReqAsstData*>(posInit->iReqAsstData->CloneL())));
       
   305     
       
   306     TBuf8<KVer> ver;
       
   307     ver.Append(posInit->iVer);
       
   308     SetVer(ver);
       
   309     if(posInit->iPosPayload)
       
   310         TRAP(aErrorCode,SetSuplPosPayload(static_cast<COMASuplPosPayload*>(posInit->iPosPayload->CloneL())));
       
   311     if(posInit->iVelocity)
       
   312         TRAP(aErrorCode,SetVelocity(static_cast<COMASuplVelocity*>(posInit->iVelocity->CloneL())));
       
   313     if(posInit->ieCID)
       
   314         SetECellId(posInit->iMmCellInfo);
       
   315     }		
       
   316