supl/locationomasuplprotocolhandler/asnconverterpluginapi/src/epos_comasuplinit.cpp
changeset 0 667063e416a2
child 22 4c4ed41530db
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 init message
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 // INCLUDE FILES
       
    20 
       
    21 #include <e32def.h>
       
    22 
       
    23 #include "epos_comasuplinit.h"
       
    24 #include "epos_comasuplnotification.h"
       
    25 #include "epos_comasuplsessionid.h"
       
    26 #include "epos_suplconstants.h"
       
    27 #include  "lbs/epos_eomasuplposerrors.h"
       
    28 
       
    29 // ============================ MEMBER FUNCTIONS of COMASuplInit===============================
       
    30 
       
    31 // -----------------------------------------------------------------------------
       
    32 // COMASuplInit::NewL() 
       
    33 // (other items were commented in a header).
       
    34 // -----------------------------------------------------------------------------
       
    35 //
       
    36 EXPORT_C COMASuplInit* COMASuplInit::NewL()
       
    37     {
       
    38     COMASuplInit* self = new( ELeave ) COMASuplInit;
       
    39     CleanupStack::PushL( self );
       
    40     self->ConstructL();
       
    41     CleanupStack::Pop(self);
       
    42     return self;
       
    43     }
       
    44     
       
    45 // -----------------------------------------------------------------------------
       
    46 // COMASuplInit::~COMASuplInit() 
       
    47 // (other items were commented in a header).
       
    48 // -----------------------------------------------------------------------------
       
    49 //    
       
    50 EXPORT_C COMASuplInit::~COMASuplInit()
       
    51     {
       
    52     if(iSessionId)
       
    53 	    {
       
    54 	    delete iSessionId;
       
    55 	    iSessionId = NULL;	
       
    56 	    }
       
    57 	if(iNotification)
       
    58 		{
       
    59 		delete iNotification;
       
    60 		iNotification = NULL;
       
    61 		}
       
    62 	if(iSLPAddress)
       
    63 		{
       
    64 		delete iSLPAddress;
       
    65 		iSLPAddress = NULL;
       
    66 		}
       
    67     }
       
    68     
       
    69 // -----------------------------------------------------------------------------
       
    70 // COMASuplInit::SuplInit() 
       
    71 // (other items were commented in a header).
       
    72 // -----------------------------------------------------------------------------
       
    73 //   			
       
    74 EXPORT_C void COMASuplInit::SuplInit(TOMASuplPosMethod& aPosMethod,TOMASuplSLPMode& aSLPMode)const
       
    75 {
       
    76 	aPosMethod = iPosMethod;
       
    77 	aSLPMode = iSLPMode;
       
    78 }						  			   
       
    79 
       
    80 // -----------------------------------------------------------------------------
       
    81 // COMASuplInit::SetSuplInit() 
       
    82 // (other items were commented in a header).
       
    83 // -----------------------------------------------------------------------------
       
    84 //   			
       
    85 EXPORT_C void COMASuplInit::SetSuplInit(TOMASuplPosMethod aPosMethod,TOMASuplSLPMode aSLPMode)
       
    86 {
       
    87 	iPosMethod = aPosMethod;
       
    88 	iSLPMode = aSLPMode;
       
    89 }						  			   
       
    90 
       
    91 // -----------------------------------------------------------------------------
       
    92 // COMASuplInit::SLPAddress() 
       
    93 // (other items were commented in a header).
       
    94 // -----------------------------------------------------------------------------
       
    95 //   			
       
    96 EXPORT_C TInt COMASuplInit::SLPAddress(COMASuplSLPAddress*& aAddress)const
       
    97 {
       
    98 	if(iOptionalMask & (1<<(2)))
       
    99 		{
       
   100 		aAddress = iSLPAddress;
       
   101 		return KErrNone;
       
   102 		}
       
   103 	else
       
   104 		{
       
   105 		return KErrOMASuplParamNotSet;
       
   106 		}
       
   107 }						  			   
       
   108 
       
   109 // -----------------------------------------------------------------------------
       
   110 // COMASuplInit::SetSLPAddress() 
       
   111 // (other items were commented in a header).
       
   112 // -----------------------------------------------------------------------------
       
   113 //   			
       
   114 EXPORT_C void COMASuplInit::SetSLPAddress(COMASuplSLPAddress* aAddress)
       
   115 {	
       
   116 	delete iSLPAddress;
       
   117 	iSLPAddress = NULL;
       
   118 	iSLPAddress = aAddress;
       
   119 	if(iSLPAddress)
       
   120 		{
       
   121 		iOptionalMask |= LEFTSHIFT(2);		
       
   122 		}	
       
   123 }						  			   
       
   124 // -----------------------------------------------------------------------------
       
   125 // COMASuplInit::Qop() 
       
   126 // (other items were commented in a header).
       
   127 // -----------------------------------------------------------------------------
       
   128 //   			
       
   129 EXPORT_C TInt COMASuplInit::Qop(TOMASuplQop& aSuplQop)const
       
   130 {
       
   131 	if(iOptionalMask & (1<<(0)))
       
   132 		{
       
   133 		aSuplQop    = iSuplQop;	
       
   134 		return KErrNone;
       
   135 		}
       
   136 	else
       
   137 		{
       
   138 		return KErrOMASuplParamNotSet;
       
   139 		}
       
   140 }	
       
   141 
       
   142 // -----------------------------------------------------------------------------
       
   143 // COMASuplInit::SetQop() 
       
   144 // (other items were commented in a header).
       
   145 // -----------------------------------------------------------------------------
       
   146 //   			
       
   147 EXPORT_C void COMASuplInit::SetQop(TOMASuplQop& aSuplQop)
       
   148 {
       
   149 	iSuplQop = aSuplQop;
       
   150 	iOptionalMask |= LEFTSHIFT(0);
       
   151 }	
       
   152 				  			   
       
   153 // -----------------------------------------------------------------------------
       
   154 // COMASuplInit::Notification() 
       
   155 // (other items were commented in a header).
       
   156 // -----------------------------------------------------------------------------
       
   157 //   			
       
   158 EXPORT_C TInt COMASuplInit::Notification(COMASuplNotification*& aNotification)const
       
   159 {
       
   160 	if(iOptionalMask & (1<<(1)))
       
   161 		{
       
   162 		aNotification = iNotification;		
       
   163 		return KErrNone;
       
   164 		}
       
   165 	else
       
   166 		{
       
   167 		return KErrOMASuplParamNotSet;
       
   168 		}
       
   169 }						  			   
       
   170 
       
   171 // -----------------------------------------------------------------------------
       
   172 // COMASuplInit::SetNotification() 
       
   173 // (other items were commented in a header).
       
   174 // -----------------------------------------------------------------------------
       
   175 //   			
       
   176 EXPORT_C void COMASuplInit::SetNotification(COMASuplNotification* aNotification)
       
   177 {
       
   178 	delete iNotification;
       
   179 	iNotification = NULL;
       
   180 	iNotification = aNotification;
       
   181 	if(iNotification)
       
   182 	   iOptionalMask |= LEFTSHIFT(1);
       
   183 }						  			   
       
   184 
       
   185 
       
   186 
       
   187 // -----------------------------------------------------------------------------
       
   188 // COMASuplResponse::CloneL() 
       
   189 // (other items were commented in a header).
       
   190 // -----------------------------------------------------------------------------
       
   191 //   			
       
   192 EXPORT_C void COMASuplInit::Clone(const COMASuplAsnMessageBase* aInit,TInt& aErrorCode)
       
   193 {
       
   194 	TRAP(aErrorCode, CloneBaseL(aInit,aErrorCode));
       
   195 	if(aErrorCode)
       
   196 	 	return;
       
   197 	COMASuplInit* suplInit = (COMASuplInit*)aInit;
       
   198 	
       
   199 	iPosMethod = suplInit->iPosMethod;
       
   200 	iSLPMode = suplInit->iSLPMode;
       
   201 	iOptionalMask = suplInit->iOptionalMask;
       
   202 	
       
   203 	if(iOptionalMask & (1<<(0)))
       
   204 		{
       
   205 		iSuplQop = suplInit->iSuplQop;
       
   206 		}
       
   207 	if(iOptionalMask & (1<<(1)))
       
   208 		{
       
   209 		TRAP(aErrorCode,CloneNotificationL(suplInit));
       
   210 		if(aErrorCode)
       
   211 			{
       
   212 			return;
       
   213 			}
       
   214 		}
       
   215 	if(iOptionalMask & (1<<(2)))
       
   216 		{
       
   217 		TRAP(aErrorCode,CloneSLPAddressL(suplInit));
       
   218 		}
       
   219 }	
       
   220 // -----------------------------------------------------------------------------
       
   221 // COMASuplInit::COMASuplInit() 
       
   222 // (other items were commented in a header).
       
   223 // -----------------------------------------------------------------------------
       
   224 //
       
   225 EXPORT_C COMASuplInit::COMASuplInit()
       
   226 	{
       
   227 		
       
   228 	}
       
   229 // -----------------------------------------------------------------------------
       
   230 // COMASuplInit::ConstructL() 
       
   231 // (other items were commented in a header).
       
   232 // -----------------------------------------------------------------------------
       
   233 //
       
   234 EXPORT_C void COMASuplInit::ConstructL()
       
   235     {
       
   236     iOptionalMask = 0;
       
   237     SetMessageType(COMASuplAsnMessageBase::ESUPL_INIT);
       
   238     }
       
   239     
       
   240 // -----------------------------------------------------------------------------
       
   241 // COMASuplInit::CloneNotification() 
       
   242 // (other items were commented in a header).
       
   243 // -----------------------------------------------------------------------------
       
   244 // 	
       
   245 void COMASuplInit::CloneNotificationL(const COMASuplInit* aSuplInit)
       
   246 	{
       
   247 	TInt error = KErrNone;
       
   248 	
       
   249 	delete iNotification;
       
   250 	iNotification = NULL;
       
   251 	iNotification = COMASuplNotification::NewL();
       
   252 	
       
   253 	COMASuplNotification::TOMASuplEncodingType encodeType;
       
   254 	
       
   255 	COMASuplNotification* cloneNotification = NULL;
       
   256 	aSuplInit->Notification(cloneNotification);
       
   257 	
       
   258 	
       
   259 	COMASuplNotification::TOMASuplNotificationType notifyType = cloneNotification->SuplNotification();
       
   260 	iNotification->SetSuplNotification(notifyType);
       
   261 	
       
   262 	error = cloneNotification->EncodingType(encodeType);
       
   263 	if(!error)
       
   264 		{
       
   265 		iNotification->SetEncodingType(encodeType);		
       
   266 		}
       
   267 	
       
   268 	COMASuplNotification::TOMASuplFormatIndicator formatIndicator;
       
   269 	HBufC8* cloneName = NULL;
       
   270 	error = cloneNotification->ClientName(cloneName,formatIndicator);
       
   271 	if(!error)
       
   272 		{
       
   273 		HBufC8* name = HBufC8::NewL(cloneName->Length());
       
   274 		*name = *cloneName;
       
   275 		iNotification->SetClientName(name,formatIndicator);
       
   276 		}
       
   277 		
       
   278 	HBufC8* cloneRequestor = NULL;
       
   279 	error = cloneNotification->RequestorId(cloneRequestor,formatIndicator);
       
   280 	if(!error)
       
   281 		{
       
   282 		HBufC8* requestor = HBufC8::NewL(cloneRequestor->Length());
       
   283 		*requestor = *cloneRequestor;
       
   284 		iNotification->SetRequestorId(requestor,formatIndicator);
       
   285 		}
       
   286 	}
       
   287 
       
   288 // -----------------------------------------------------------------------------
       
   289 // COMASuplInit::CloneSLPAddress() 
       
   290 // (other items were commented in a header).
       
   291 // -----------------------------------------------------------------------------
       
   292 // 	
       
   293 void COMASuplInit::CloneSLPAddressL(const COMASuplInit* aSuplInit)
       
   294 	{
       
   295 	TBuf8<KIPv6Address>  lIPvAddress;
       
   296 	
       
   297 	COMASuplSLPAddress* cloneSLPAddress =  NULL;
       
   298 	
       
   299 	delete iSLPAddress;
       
   300 	iSLPAddress = NULL;
       
   301 	iSLPAddress = COMASuplSLPAddress::NewL();
       
   302 	
       
   303 	aSuplInit->SLPAddress(cloneSLPAddress);
       
   304 	COMASuplSLPAddress::TSuplSLPAddressType lChoice = cloneSLPAddress->SLPAddressType();
       
   305 
       
   306 	switch(lChoice)
       
   307 	{
       
   308 		case COMASuplSLPAddress::EIPv4Address: 
       
   309 				{
       
   310 				cloneSLPAddress->IPvAddress(lIPvAddress);
       
   311 				iSLPAddress->SetIPv4Address(lIPvAddress);
       
   312 				break;				
       
   313 				}
       
   314 		case COMASuplSLPAddress::EIPv6Address: 
       
   315 				{
       
   316 				cloneSLPAddress->IPvAddress(lIPvAddress);
       
   317 									
       
   318 				iSLPAddress->SetIPv6Address(lIPvAddress);
       
   319 				break;	
       
   320 				}
       
   321 		case COMASuplSLPAddress::EFqdn: 	
       
   322 				{
       
   323 				HBufC8* cloneFqdn = NULL;
       
   324 				cloneSLPAddress->Fqdn(cloneFqdn);
       
   325 				
       
   326 				HBufC8* fqdn = HBufC8::NewL(cloneFqdn->Length());
       
   327 								
       
   328 				*fqdn = *cloneFqdn;
       
   329 				iSLPAddress->SetFqdn(fqdn);
       
   330 								
       
   331 				break;	
       
   332 				}
       
   333 		}
       
   334 	}
       
   335 
       
   336