supl/locationomasuplprotocolhandler/protocolhandlerver2/src/epos_comasuplinitstate.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:   Class for handling SUPL_INIT message.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 #include <utf.h>
       
    21 #include "epos_comasuplinitver2.h"
       
    22 #include "epos_comasuplnotification.h"
       
    23 #include "epos_comasuplsessionid.h"
       
    24 #include "lbs/epos_eomasuplposerrors.h"
       
    25 #include "epos_tomasuplposmethod.h"
       
    26 
       
    27 #include "epos_comasuplinitstate.h"
       
    28 #include "epos_comasupltimeouttimer.h"
       
    29 #include "epos_omasuplconstants.h"
       
    30 #include "epos_momasuplprivacyobserver.h"
       
    31 #include "epos_comasupltrace.h"
       
    32 #include <featmgr.h> //APE CENTRIC
       
    33 
       
    34 _LIT(KTraceFileName,"SUPL_OMA_SESSION::EPos_COMASuplInitState.cpp");
       
    35 
       
    36 const TInt KSUPLAPECentricArchSupport = 258;  //APE CENTRIC KFeatureIdFfLocationMwApeCentricArchSupport = 258
       
    37 
       
    38 
       
    39 // ============================ MEMBER FUNCTIONS ===============================
       
    40 
       
    41 // -----------------------------------------------------------------------------
       
    42 // COMASuplInitState::COMASuplInitState
       
    43 // C++ constructor can NOT contain any code, that might leave.
       
    44 // -----------------------------------------------------------------------------
       
    45 //
       
    46 COMASuplInitState::COMASuplInitState(TInt aMsgTimeout,const TDesC8& aHSLPAddress,
       
    47 									MOMASuplPrivacyObserver &aPrivacyObserver,TInt aSupportedMode, CPosNetworkPrivacy*	aNetworkPrivacy):
       
    48 									iHSLPAddress(aHSLPAddress),
       
    49 									iPrivacyObserver(aPrivacyObserver),
       
    50                                     iTriggerSessionFlag(EFalse)
       
    51     {
       
    52 		iMessageTimeOut = aMsgTimeout * KSecond; 
       
    53 		iNoPosition = EFalse;  
       
    54 		iCurrentState =  ESUPL_INIT;
       
    55 		iSupportedMode = aSupportedMode;
       
    56 		iGSMRequestId = KErrNotFound;
       
    57 		iIsNotificationOnly = EFalse; //APE Centric
       
    58 		iNetworkPrivacy = aNetworkPrivacy;
       
    59     }
       
    60 
       
    61 // -----------------------------------------------------------------------------
       
    62 // COMASuplInitState::~COMASuplInitState
       
    63 // -----------------------------------------------------------------------------
       
    64 //
       
    65 COMASuplInitState::~COMASuplInitState()
       
    66     {
       
    67     	//delete iNetworkPrivacy;
       
    68     	iRequestorName.Close();
       
    69       	if(iTrace)
       
    70     		iTrace->Trace(_L("COMASuplInitState::~COMASuplInitState..."), KTraceFileName, __LINE__); 							
       
    71     }
       
    72 
       
    73 // -----------------------------------------------------------------------------
       
    74 // COMASuplInitState::ConstructL
       
    75 // Symbian 2nd phase constructor can leave.
       
    76 // -----------------------------------------------------------------------------
       
    77 //
       
    78 void COMASuplInitState::ConstructL()
       
    79     {
       
    80     	COMASuplState::BaseConstructL();
       
    81     	// Create an instance of Network Privacy that later are
       
    82 		// used to make privacy calls on.
       
    83 		//iNetworkPrivacy 	= CPosNetworkPrivacy::NewL();
       
    84 		//iSuplReqInfo = CPosSUPLPrivacyRequestInfo::NewL();
       
    85 		iRequestorName.CreateL(256);
       
    86 		iRequestorName.Zero();
       
    87 		ReadRequestIDFeatureFlagL();
       
    88 		iPrivacyOverride = EFalse;
       
    89 	 iTrace->Trace(_L("COMASuplInitState::ConstructL..."), KTraceFileName, __LINE__); 							
       
    90     }
       
    91 
       
    92 // -----------------------------------------------------------------------------
       
    93 // COMASuplInitState::NewL
       
    94 // Two-phased constructor.
       
    95 // -----------------------------------------------------------------------------
       
    96 //
       
    97 COMASuplInitState* COMASuplInitState::NewL(TInt aMsgTimeout,const TDesC8& aHSLPAddress,
       
    98 										   MOMASuplPrivacyObserver &aPrivacyObserver,
       
    99 										   TInt aSupportedMode, CPosNetworkPrivacy*	aNetworkPrivacy)
       
   100     {
       
   101 	    COMASuplInitState* self =  new ( ELeave ) COMASuplInitState(aMsgTimeout,aHSLPAddress,
       
   102 	    														   aPrivacyObserver,aSupportedMode,aNetworkPrivacy);
       
   103 	    CleanupStack::PushL( self );
       
   104 	    self->ConstructL();
       
   105 	    CleanupStack::Pop(self);
       
   106 	    return self;
       
   107     }
       
   108 
       
   109 
       
   110 // -----------------------------------------------------------------------------
       
   111 // COMASuplState::ProcessMessage
       
   112 // process message...
       
   113 // (other items were commented in a header).
       
   114 // -----------------------------------------------------------------------------
       
   115 //
       
   116 TInt COMASuplInitState::ProcessMessageL(COMASuplAsnMessageBase* aDecodedMessage)
       
   117 {
       
   118 		TInt error = KErrNone;
       
   119 		iSuplInit = static_cast <COMASuplInitVer2 *>(aDecodedMessage);
       
   120 		iNotification   	= NULL;
       
   121 		
       
   122 		error = CheckForModeSupport();
       
   123 		if(error == KErrOMANonProxyModeNotSupported)
       
   124 			return error;
       
   125 		
       
   126 		// Check for the presence of SET Session ID
       
   127 		error = CheckForSetSessionID();
       
   128 		
       
   129 		if(KErrNone != error)
       
   130 			{
       
   131 				return error;
       
   132 			}
       
   133 		
       
   134 		error = CheckForSLPSessionID();
       
   135 			if(KErrNone != error)
       
   136 			{
       
   137 				return error;
       
   138 			}
       
   139 
       
   140 		
       
   141 		CheckForPositioningMethod();
       
   142 
       
   143 	    CheckForExtensionParameters();	
       
   144 
       
   145         if (iTriggerSessionFlag && iTriggerType != COMASuplTriggeredStart::ETOMASuplPeriodicTrigType)                                   
       
   146 			return KErrSuplServiceNotSupported;
       
   147 
       
   148 		error	= iSuplInit->Notification(iNotification);
       
   149 		if(!error)
       
   150 			{
       
   151 				error = HandlePrivacyL();
       
   152 				return error;		
       
   153 			}
       
   154 		else
       
   155 			{
       
   156 			if(iNoPosition)
       
   157 				{
       
   158 				return KErrOMASuplNoPosition;
       
   159 				}
       
   160 			else
       
   161 				{
       
   162 				iCompletionCode = KErrNone;
       
   163 				iPrivacyObserver.PrivacyCheckCompleteL(iCompletionCode);	
       
   164 				return KErrNone;
       
   165 				}
       
   166 			}		
       
   167 			
       
   168 }
       
   169 // -----------------------------------------------------------------------------
       
   170 // COMASuplInitState::HandlePrivacy
       
   171 // Cancels the generation if SUPL INIT
       
   172 // (other items were commented in a header).
       
   173 // -----------------------------------------------------------------------------
       
   174 //
       
   175 TInt COMASuplInitState::HandlePrivacyL() 
       
   176 	{
       
   177 		iTrace->Trace(_L("COMASuplInitState::HandlePrivacy..."), KTraceFileName, __LINE__); 					
       
   178 		
       
   179 		COMASuplNotification::TOMASuplNotificationType notifyType = iNotification->SuplNotification();
       
   180 		switch(notifyType)
       
   181 			{
       
   182 				case COMASuplNotification::ENoNotificationNoVerification:
       
   183 				case COMASuplNotification::EPrivacyOverride:
       
   184 					{
       
   185 						iPrivacyOverride = ETrue;
       
   186 		       iTrace->Trace(_L("COMASuplInitState::Privacy rule: No notification and no verification"), KTraceFileName, __LINE__); 					
       
   187 					if(iNoPosition)
       
   188 						{
       
   189 							iCompletionCode = KErrOMASuplInformationOnly;
       
   190 						}
       
   191 					else
       
   192 						{
       
   193 							iCompletionCode = KErrNone;		
       
   194 						}	
       
   195 					iPrivacyObserver.PrivacyCheckCompleteL(iCompletionCode);
       
   196 					return KErrNone;
       
   197 					
       
   198 					/*
       
   199 					CPosSUPLPrivacyRequestInfo* suplReqInfo = CPosSUPLPrivacyRequestInfo::NewLC();   
       
   200       		suplReqInfo->SetRequestType(CPosNetworkPrivacyRequestInfo::ERequestPeriodicSlient);
       
   201       		iNetworkPrivacy->VerifyLocationRequestL(*suplReqInfo,aRequestId, *this,CPosNetworkPrivacy::EDecisionAccepted );
       
   202       		CleanupStack::PopAndDestroy(suplReqInfo);
       
   203       		*/  //Vijay.. for Privacy override changes once cambridge team provides api
       
   204 					}
       
   205 				case COMASuplNotification::ENotificationOnly:
       
   206 					{
       
   207 		      iTrace->Trace(_L("COMASuplInitState::Privacy rule: Notification Only"), KTraceFileName, __LINE__); 					
       
   208 					iIsNotificationOnly = ETrue; //APE Centric
       
   209 					MakeGSMNotificationL();
       
   210 					
       
   211 					if(iNoPosition)
       
   212 						{
       
   213 						iCompletionCode = KErrOMASuplInformationOnly;
       
   214 						}
       
   215 					else
       
   216 						{
       
   217 						iCompletionCode = KErrNone;		
       
   218 						}	
       
   219 					iPrivacyObserver.PrivacyCheckCompleteL(iCompletionCode);
       
   220 					return KErrNone;
       
   221 					}
       
   222 				case COMASuplNotification::ENotificationAndVerficationAllowedNA:
       
   223 					{
       
   224 		            iTrace->Trace(_L("COMASuplInitState::Privacy rule: Notification & Verification, Allowed on no answer"), KTraceFileName, __LINE__); 					
       
   225 					return MakeGSMVerificationL(CPosNetworkPrivacy::EDecisionAccepted);	
       
   226 					}
       
   227 				case COMASuplNotification::ENotificationAndVerficationDeniedNA:
       
   228 					{
       
   229 		            iTrace->Trace(_L("COMASuplInitState::Privacy rule: Notification & Verification, Denied on no answer"), KTraceFileName, __LINE__); 					
       
   230 					return MakeGSMVerificationL(CPosNetworkPrivacy::EDecisionRejected);
       
   231 					}
       
   232 				default:
       
   233 					{
       
   234 					 return KErrArgument;
       
   235 					}
       
   236 			}
       
   237 	}
       
   238 // ---------------------------------------------------------
       
   239 // COMASuplInitState::MakeGSMNotificationL
       
   240 //
       
   241 // (other items were commented in a header).
       
   242 // ---------------------------------------------------------
       
   243 //
       
   244 TInt COMASuplInitState::MakeGSMNotificationL()
       
   245 	{
       
   246 	iTrace->Trace(_L("COMASuplInitState::MakeGSMNotification"), KTraceFileName, __LINE__);
       
   247 	// Constructing GSM Privacy Request Information object
       
   248 	CPosSUPLPrivacyRequestInfo* suplReqInfo = CPosSUPLPrivacyRequestInfo::NewLC();
       
   249 	//suplReqInfo->SetRequestType(CPosNetworkPrivacyRequestInfo::ERequestPeriodicSilent);//Make Periodic Slient request...
       
   250 	suplReqInfo->SetRequestType(CPosSUPLPrivacyRequestInfo::ERequestPeriodic);
       
   251 	
       
   252 	TBuf<8> sessionIdBuffer;
       
   253 	_LIT(KTextformat,"%03d");
       
   254 	sessionIdBuffer.Zero();
       
   255 	sessionIdBuffer.AppendNum(iSETSessionUniqueId);
       
   256 	sessionIdBuffer.Format(KTextformat,iSETSessionUniqueId);
       
   257 	
       
   258 	HBufC* requestor = NULL;
       
   259 	TInt reqError = RequestorL(requestor);
       
   260 	if(!reqError)
       
   261 		{
       
   262                 // Set name of Requestor
       
   263                 if(requestor)
       
   264                 {
       
   265                     iRequestorName.Copy(*requestor);
       
   266                     requestor->Des().Append(sessionIdBuffer);
       
   267                     suplReqInfo->SetRequestorL(*requestor,iIdType);
       
   268                 }
       
   269                 else
       
   270 	   						{
       
   271                 requestor = HBufC::NewL(8);
       
   272                 requestor->Des().Append(sessionIdBuffer);
       
   273                 iIdType = CPosSUPLPrivacyRequestInfo::EIdTypeLogicalName;
       
   274                 suplReqInfo->SetRequestorL(*requestor,iIdType);
       
   275 	    					}
       
   276 		}
       
   277 	
       
   278 	
       
   279 	
       
   280 	if (requestor)
       
   281 	{
       
   282 		iTrace->Trace(_L("Requestor Name: "), KTraceFileName, __LINE__);
       
   283 		iTrace->Trace(*requestor, KTraceFileName, __LINE__);
       
   284 		delete requestor;
       
   285 	}
       
   286 	
       
   287 	
       
   288 	HBufC* client = NULL;
       
   289 	TInt clientError = ClientL(client);
       
   290 	if(!clientError)
       
   291 		{
       
   292 			// Set name of Client
       
   293 			if(client)
       
   294 			{
       
   295           client->Des().Append(sessionIdBuffer);
       
   296 					suplReqInfo->SetLCSClientL(*client,iIdType);	
       
   297 			}
       
   298 		  else
       
   299 	    {
       
   300 	    		client = HBufC::NewL(8);
       
   301 	    		client->Des().Append(sessionIdBuffer);
       
   302         	iIdType = CPosSUPLPrivacyRequestInfo::EIdTypeLogicalName;
       
   303         	suplReqInfo->SetLCSClientL(*client,iIdType);
       
   304 	    }
       
   305 		}
       
   306 	
       
   307 	if (client)
       
   308 	delete client;
       
   309 	
       
   310 	iSuplReqInfo = suplReqInfo;
       
   311 	
       
   312 	if(!reqError || !clientError)
       
   313 		{
       
   314 		// Notify Network Privacy of the request information
       
   315 		// Synchronous call 
       
   316 		//iNetworkPrivacy->NotifyLocationRequestL(*suplReqInfo, iNotificationRequestorId); //APE Centric 
       
   317 		 
       
   318 				if(iIsNotificationOnly) //APE Centric 
       
   319 				{
       
   320 					//iGSMRequestId = iNotificationRequestorId; //APE Centric 
       
   321 				}
       
   322 				
       
   323         TBuf<64> msg;
       
   324         msg.Copy(_L("Privacy Fw Generated Notification Request id : "));
       
   325         //msg.AppendNum(iNotificationRequestorId);
       
   326         iTrace->Trace(msg, KTraceFileName, __LINE__);		
       
   327 			  //CleanupStack::PopAndDestroy(suplReqInfo);
       
   328 			  CleanupStack::Pop(suplReqInfo); //Owneship will be with Session2 class.
       
   329 			  
       
   330 		return KErrNone;
       
   331 		}
       
   332 	else
       
   333 		{
       
   334 		CleanupStack::PopAndDestroy(suplReqInfo);
       
   335 		return KErrArgument;
       
   336 		}
       
   337 	}
       
   338 
       
   339 // ---------------------------------------------------------
       
   340 // COMASuplInitState::MakeGSMVerificationL
       
   341 //
       
   342 // (other items were commented in a header).
       
   343 // ---------------------------------------------------------
       
   344 //
       
   345 TInt COMASuplInitState::MakeGSMVerificationL(CPosNetworkPrivacy::TRequestDecision aTimeOutStrategy)
       
   346 	{
       
   347 	// Constructing GSM Privacy Request Information object
       
   348 	CPosSUPLPrivacyRequestInfo* suplReqInfo = CPosSUPLPrivacyRequestInfo::NewLC();
       
   349 	
       
   350 	    
       
   351 	HBufC* requestor = NULL;
       
   352 	TInt reqError = RequestorL(requestor);
       
   353 	suplReqInfo->SetRequestType(CPosSUPLPrivacyRequestInfo::ERequestPeriodic);
       
   354 	if(!reqError)
       
   355 		{
       
   356 			// Set name of Requestor
       
   357 			if(requestor)
       
   358 			    {
       
   359 				suplReqInfo->SetRequestorL(*requestor,iIdType);
       
   360 				iRequestorName.Copy(*requestor);
       
   361 			    }
       
   362 			delete requestor;	
       
   363 		}
       
   364 
       
   365 	HBufC* client = NULL;
       
   366 	TInt clientError = ClientL(client);
       
   367 	if(!clientError)
       
   368 		{
       
   369 		if(client)
       
   370 			{
       
   371 				suplReqInfo->SetLCSClientL(*client,iIdType);	
       
   372 				//iClientName.Copy(*requestor);
       
   373 			}
       
   374 
       
   375 		delete client;
       
   376 		}
       
   377 	//iSuplReqInfo = suplReqInfo;
       
   378 	if(!reqError || !clientError)
       
   379 		{
       
   380 			// Verify the request information using Network Privacy
       
   381 			// asynchronous call with callback function HandleVerifyComplete.
       
   382 			// Argument CPosNetworkPrivacy::EDecisionRejected is to show to the user 
       
   383 			// what decision the GSM Network will make if the user won't answer before 
       
   384 			// a timeout comes in from GSM Network. In this case verification will 
       
   385 			// be rejected.
       
   386 			iNetworkPrivacy->VerifyLocationRequestL(*suplReqInfo, 
       
   387 				iGSMRequestId, *this, aTimeOutStrategy);
       
   388 	        TBuf<64> msg;
       
   389 	        msg.Copy(_L("Privacy Fw Generated Verification Request id : "));
       
   390 	        msg.AppendNum(iGSMRequestId);
       
   391 	        iTrace->Trace(msg, KTraceFileName, __LINE__);       
       
   392 
       
   393 			StartTimer();
       
   394 			CleanupStack::Pop(suplReqInfo);
       
   395 			return KErrNone;
       
   396 		}
       
   397 	else
       
   398 		{
       
   399 		CleanupStack::PopAndDestroy(suplReqInfo);
       
   400 		return KErrArgument;
       
   401 		}
       
   402 	}
       
   403 
       
   404 // ---------------------------------------------------------
       
   405 // COMASuplInitState::ConverttoUniCodeL
       
   406 //
       
   407 // (other items were commented in a header).
       
   408 // ---------------------------------------------------------
       
   409 //
       
   410 TInt COMASuplInitState::ConverttoUniCodeL(HBufC*& aUniCode,HBufC8& aRequstor)
       
   411 	{
       
   412 	COMASuplNotification::TOMASuplEncodingType encodingType;
       
   413 	TInt error = iNotification->EncodingType(encodingType);
       
   414 	if(error)
       
   415 		{
       
   416 		 return KErrArgument;
       
   417 		}	
       
   418 	else
       
   419 		{
       
   420 		
       
   421 		for(TInt i = 0; i < aRequstor.Length(); i++)
       
   422 		{
       
   423 			TBuf<32> printBuffer;
       
   424 			TUint16 FirstChar = aRequstor[i];
       
   425 			printBuffer.AppendNum(FirstChar);
       
   426 			iTrace->Trace(printBuffer,KTraceFileName, __LINE__); 												
       
   427 		}
       
   428 		
       
   429 		switch(encodingType)
       
   430 			{
       
   431 				case COMASuplNotification::EUCS2:
       
   432 					{
       
   433 					iTrace->Trace(_L("Notification Encoding Type : EUCS2"), KTraceFileName, __LINE__); 												
       
   434 					aUniCode =  HBufC::NewL(aRequstor.Length());
       
   435 	    			TPtr16	requestId = aUniCode->Des();
       
   436 					FormUCS2String(aRequstor,requestId);	
       
   437 					break;
       
   438 					}
       
   439 				case COMASuplNotification::EUtf8:
       
   440 					{
       
   441 					iTrace->Trace(_L("Notification Encoding Type : EUtf8"), KTraceFileName, __LINE__); 											
       
   442 					aUniCode =  HBufC::NewL(aRequstor.Length());
       
   443 					TPtr16	requestId = aUniCode->Des();
       
   444 					error = CnvUtfConverter::ConvertToUnicodeFromUtf8(requestId,aRequstor);					
       
   445 					break;
       
   446 					}
       
   447 				case COMASuplNotification::EGsmDefault:
       
   448 					{
       
   449 					iTrace->Trace(_L("Notification Encoding Type : EGsmDefault"), KTraceFileName, __LINE__); 					
       
   450 					aUniCode =  HBufC::NewL(aRequstor.Length() * 2);
       
   451 					TPtr16	requestId = aUniCode->Des();
       
   452 					RBuf8 destString;
       
   453 					destString.CreateL(aRequstor.Length() * 2);	
       
   454 					TBuf<64> temp;
       
   455 					temp.Copy(aRequstor);
       
   456 		            iTrace->Trace(temp, KTraceFileName, __LINE__); 					
       
   457 					GsmDefaultDecode(aRequstor,destString);
       
   458 					requestId.Copy(destString);	
       
   459 					destString.Close();
       
   460 					break;
       
   461 					}
       
   462 				default:
       
   463 					{
       
   464 					error = KErrArgument;
       
   465 					}
       
   466 			}
       
   467 		}
       
   468 	return error;
       
   469 	}
       
   470 // ---------------------------------------------------------
       
   471 // COMASuplInitState::Requestor
       
   472 //
       
   473 // (other items were commented in a header).
       
   474 // ---------------------------------------------------------
       
   475 //
       
   476 TInt COMASuplInitState::RequestorL(HBufC*& aRequestor)
       
   477 	{
       
   478 	
       
   479 	COMASuplNotification::TOMASuplFormatIndicator requestType;
       
   480 	HBufC8* requestor = NULL;
       
   481 	// Eventhough requestor id is empty...we have to show the Privacy verification note
       
   482 	TInt error = iNotification->RequestorId(requestor,requestType);
       
   483 	if(error == KErrNone || error == KErrOMASuplParamNotSet )
       
   484 		{
       
   485 			error = KErrNone; 
       
   486 			if(requestor)
       
   487 			{
       
   488 				error = ConverttoUniCodeL(aRequestor,*requestor);
       
   489 			}
       
   490 			
       
   491 		switch(requestType)
       
   492 				{
       
   493 				case COMASuplNotification::ELogicalName:
       
   494 					{
       
   495 		            iTrace->Trace(_L("COMASuplInitState::RequestorL Requestor type - Logical Name"), KTraceFileName, __LINE__); 					
       
   496 					iIdType = CPosSUPLPrivacyRequestInfo::EIdTypeLogicalName;
       
   497 					break;	
       
   498 					}
       
   499 				case COMASuplNotification::EEMailAddress:
       
   500 					{
       
   501 		            iTrace->Trace(_L("COMASuplInitState::RequestorL Requestor type - EMail Addr"), KTraceFileName, __LINE__); 					
       
   502 					iIdType = CPosSUPLPrivacyRequestInfo::EIdTypeEmailAddress;
       
   503 					break;		
       
   504 					}
       
   505 				case COMASuplNotification::EMsisdn:
       
   506 					{
       
   507 		            iTrace->Trace(_L("COMASuplInitState::RequestorL Requestor type - MSISDN"), KTraceFileName, __LINE__);
       
   508 					iIdType = CPosSUPLPrivacyRequestInfo::EIdTypeMSISDN;
       
   509 					break;	
       
   510 					}
       
   511 				case COMASuplNotification::EUrl:
       
   512 					{
       
   513 		            iTrace->Trace(_L("COMASuplInitState::RequestorL Requestor type - URL"), KTraceFileName, __LINE__);
       
   514 					iIdType = CPosSUPLPrivacyRequestInfo::EIdTypeURL;
       
   515 					break;	
       
   516 					}
       
   517 				case COMASuplNotification::ESipUrl:
       
   518 					{
       
   519 		            iTrace->Trace(_L("COMASuplInitState::RequestorL Requestor type - SIP URL"), KTraceFileName, __LINE__);
       
   520 					iIdType = CPosSUPLPrivacyRequestInfo::EIdTypeSIPURL;
       
   521 					break;
       
   522 					}
       
   523 				case COMASuplNotification::EMin:
       
   524 					{
       
   525 		            iTrace->Trace(_L("COMASuplInitState::RequestorL Requestor type - MIN"), KTraceFileName, __LINE__);
       
   526 					iIdType = CPosSUPLPrivacyRequestInfo::EIdTypeMIN;
       
   527 					break;	
       
   528 					}
       
   529 				case COMASuplNotification::EMdn:
       
   530 					{
       
   531 		            iTrace->Trace(_L("COMASuplInitState::RequestorL Requestor type - MDN"), KTraceFileName, __LINE__);
       
   532 					iIdType = CPosSUPLPrivacyRequestInfo::EIdTypeMDN;
       
   533 					break;	
       
   534 					}
       
   535 				case COMASuplNotification::EIMSPublicIdentity:
       
   536 					{
       
   537 		            iTrace->Trace(_L("COMASuplInitState::RequestorL Requestor type - IMS Public Identity"), KTraceFileName, __LINE__);
       
   538 					iIdType = CPosSUPLPrivacyRequestInfo::EIdTypeIMSPublicIdentity;
       
   539 					break;	
       
   540 					}
       
   541 				default:
       
   542 					{
       
   543 					error = KErrArgument;
       
   544 					break;	
       
   545 					}
       
   546 				}
       
   547 		}
       
   548 
       
   549 	return error;
       
   550 	}
       
   551 // ---------------------------------------------------------
       
   552 // COMASuplInitState::Client
       
   553 //
       
   554 // (other items were commented in a header).
       
   555 // ---------------------------------------------------------
       
   556 //
       
   557 TInt COMASuplInitState::ClientL(HBufC*& aClient)
       
   558 	{
       
   559 	COMASuplNotification::TOMASuplFormatIndicator clientType;
       
   560 	HBufC8* client = NULL;
       
   561 	
       
   562 	TInt error = iNotification->ClientName(client,clientType);
       
   563 	//if(!error)
       
   564 	if(error == KErrNone || error == KErrOMASuplParamNotSet )
       
   565 		{
       
   566 		
       
   567 			error = KErrNone; 
       
   568 			if(client)
       
   569 			{
       
   570 				error = ConverttoUniCodeL(aClient,*client);
       
   571 			}
       
   572 		
       
   573 		switch(clientType)
       
   574 			{
       
   575 			case COMASuplNotification::ELogicalName:
       
   576 				{
       
   577 		        iTrace->Trace(_L("COMASuplInitState::ClientL Client type - Logical Name"), KTraceFileName, __LINE__);
       
   578 				iIdType = CPosSUPLPrivacyRequestInfo::EIdTypeLogicalName;
       
   579 				break;	
       
   580 				}
       
   581 			case COMASuplNotification::EEMailAddress:
       
   582 				{
       
   583 		        iTrace->Trace(_L("COMASuplInitState::ClientL Client type - EMail Addr"), KTraceFileName, __LINE__);
       
   584 				iIdType = CPosSUPLPrivacyRequestInfo::EIdTypeEmailAddress;
       
   585 				break;		
       
   586 				}
       
   587 			case COMASuplNotification::EMsisdn:
       
   588 				{
       
   589 		        iTrace->Trace(_L("COMASuplInitState::ClientL Client type - MSISDN"), KTraceFileName, __LINE__);
       
   590 				iIdType = CPosSUPLPrivacyRequestInfo::EIdTypeMSISDN;
       
   591 				break;	
       
   592 				}
       
   593 			case COMASuplNotification::EUrl:
       
   594 				{
       
   595 		        iTrace->Trace(_L("COMASuplInitState::ClientL Client type - URL"), KTraceFileName, __LINE__);
       
   596 				iIdType = CPosSUPLPrivacyRequestInfo::EIdTypeURL;
       
   597 				break;	
       
   598 				}
       
   599 			case COMASuplNotification::ESipUrl:
       
   600 				{
       
   601 		        iTrace->Trace(_L("COMASuplInitState::ClientL Client type - SIP URL"), KTraceFileName, __LINE__);
       
   602 				iIdType = CPosSUPLPrivacyRequestInfo::EIdTypeSIPURL;
       
   603 				break;
       
   604 				}
       
   605 			case COMASuplNotification::EMin:
       
   606 				{
       
   607 		        iTrace->Trace(_L("COMASuplInitState::ClientL Client type - MIN"), KTraceFileName, __LINE__);
       
   608 				iIdType = CPosSUPLPrivacyRequestInfo::EIdTypeMIN;
       
   609 				break;	
       
   610 				}
       
   611 			case COMASuplNotification::EMdn:
       
   612 				{
       
   613 		        iTrace->Trace(_L("COMASuplInitState::ClientL Client type - MDN"), KTraceFileName, __LINE__);
       
   614 				iIdType = CPosSUPLPrivacyRequestInfo::EIdTypeMDN;
       
   615 				break;	
       
   616 				}
       
   617 			case COMASuplNotification::EIMSPublicIdentity:
       
   618 				{
       
   619 		        iTrace->Trace(_L("COMASuplInitState::ClientL Client type - IMS Public Identity"), KTraceFileName, __LINE__);
       
   620 				iIdType = CPosSUPLPrivacyRequestInfo::EIdTypeIMSPublicIdentity;
       
   621 				break;	
       
   622 				}
       
   623 			default:
       
   624 				{
       
   625 				error = KErrArgument;
       
   626 				break;	
       
   627 				}
       
   628 			}	
       
   629 		}
       
   630 
       
   631 	return error;
       
   632 	}
       
   633 // ---------------------------------------------------------
       
   634 // COMASuplInitState::HandleVerifyComplete
       
   635 //
       
   636 // (other items were commented in a header).
       
   637 // ---------------------------------------------------------
       
   638 //
       
   639 void COMASuplInitState::HandleVerifyComplete(
       
   640 	TInt /*aRequestId*/, TInt aCompletionCode)
       
   641 	{
       
   642 	StopTimer();
       
   643 	iCompletionCode = aCompletionCode;
       
   644 	
       
   645 	if(iNoPosition)
       
   646 		{
       
   647 			if(aCompletionCode)
       
   648 				{
       
   649 				iCompletionCode = KErrOMASuplDenied;
       
   650 				}
       
   651 			else
       
   652 				{
       
   653 				iCompletionCode = KErrOMASuplAccepted;	
       
   654 				}
       
   655 		}	
       
   656 		
       
   657 	if(KErrNone == iCompletionCode || KErrOMASuplAccepted == iCompletionCode)
       
   658 		{
       
   659 				TRAP_IGNORE(MakeGSMNotificationL());		
       
   660 				
       
   661 		}	
       
   662 		
       
   663 	TRAP_IGNORE(iPrivacyObserver.PrivacyCheckCompleteL(iCompletionCode));
       
   664 	
       
   665 	}
       
   666 
       
   667 // -----------------------------------------------------------------------------
       
   668 // COMASuplInitState::TimerExpired
       
   669 // TimerExpired...Gets called when time out occurs .
       
   670 // (other items were commented in a header).
       
   671 // -----------------------------------------------------------------------------
       
   672 //
       
   673 void COMASuplInitState::TimerExpiredL()
       
   674 	{
       
   675 	iTrace->Trace(_L("COMASuplState::TimerExpired..."), KTraceFileName, __LINE__); 							
       
   676 	
       
   677 	COMASuplNotification::TOMASuplNotificationType notifyType = iNotification->SuplNotification();
       
   678 	if(notifyType == COMASuplNotification::ENotificationAndVerficationAllowedNA)
       
   679 	 	{
       
   680 		iCompletionCode = KErrNone;
       
   681 	 	}
       
   682 	else if(notifyType == COMASuplNotification::ENotificationAndVerficationDeniedNA )
       
   683 		{
       
   684 		iCompletionCode	= KErrAccessDenied;
       
   685 		}
       
   686 		
       
   687 	if(iNoPosition)
       
   688 		{
       
   689 		if(iCompletionCode)
       
   690 			{
       
   691 			iCompletionCode = KErrOMASuplDenied;
       
   692 			}
       
   693 		else
       
   694 			{
       
   695 			iCompletionCode = KErrOMASuplAccepted;	
       
   696 			}
       
   697 		}			
       
   698 	// Cancel ongoing verification using Network Privacy
       
   699 	iNetworkPrivacy->CancelVerifyLocationRequest(iGSMRequestId);
       
   700 	if(KErrNone == iCompletionCode || KErrOMASuplAccepted == iCompletionCode)
       
   701 		{
       
   702 			 MakeGSMNotificationL();			
       
   703 		}	
       
   704 	iPrivacyObserver.PrivacyCheckCompleteL(iCompletionCode);
       
   705 	}
       
   706 	
       
   707 // -----------------------------------------------------------------------------
       
   708 //  COMASuplInitState::CheckForVersion
       
   709 // CheckForVersion...Checks version of protocol & received message
       
   710 // (other items were commented in a header).
       
   711 // -----------------------------------------------------------------------------
       
   712 //
       
   713 TInt COMASuplInitState::CheckForVersion()
       
   714 	{
       
   715 		TOMASuplVersion version;
       
   716 		COMASuplSessionID* SessionID = NULL;
       
   717 		iSuplInit->MessageBase(version,SessionID);
       
   718 		
       
   719 		TInt recMajor,recMinor,recServInd;
       
   720 		TInt actMajor,actMinor,actServInd;
       
   721 
       
   722 		version.SuplVersion(recMajor,recMinor,recServInd);		
       
   723 		iOMASuplVersion.SuplVersion(actMajor,actMinor,actServInd);		
       
   724 		if(recMajor == actMajor )
       
   725 			{
       
   726 				return KErrNone;
       
   727 			}
       
   728 		else
       
   729 			{
       
   730 				return KErrOMASuplVersionNotMatching;			
       
   731 			}
       
   732 	}
       
   733 
       
   734 // -----------------------------------------------------------------------------
       
   735 //  COMASuplInitState::CheckForModeSupport
       
   736 // CheckForModeSupport...Checks modes of protocol & received message
       
   737 // (other items were commented in a header).
       
   738 // -----------------------------------------------------------------------------
       
   739 //
       
   740 TInt COMASuplInitState::CheckForModeSupport()
       
   741 	{
       
   742 		COMASuplInit::TOMASuplSLPMode SLPMode;
       
   743 		
       
   744 		iSuplInit->SuplInit(iPosMethod,SLPMode);
       
   745 		
       
   746 		COMASuplInit::TOMASuplSLPMode SupportedMode = (COMASuplInit::TOMASuplSLPMode)iSupportedMode;
       
   747 		
       
   748 		if(SLPMode == SupportedMode )
       
   749 			{
       
   750 				return KErrNone;	
       
   751 			}
       
   752 			else
       
   753 			{
       
   754 				return KErrOMANonProxyModeNotSupported;			
       
   755 			}
       
   756 	}
       
   757 
       
   758 // -----------------------------------------------------------------------------
       
   759 //  COMASuplInitState::CheckForSetSessionID
       
   760 // CheckForModeSupport...Checks if Set session ID is present in the SUPL INT
       
   761 // message received
       
   762 // (other items were commented in a header).
       
   763 // -----------------------------------------------------------------------------
       
   764 //
       
   765 TInt COMASuplInitState::CheckForSetSessionID()
       
   766 	{
       
   767 	  iTrace->Trace(_L("Start COMASuplInitState::CheckForSetSessionID"), KTraceFileName, __LINE__); 							
       
   768 		COMASuplSessionID* retrivedSessionID = NULL;
       
   769 		iSuplInit->SessionId(retrivedSessionID);
       
   770 		if(retrivedSessionID)
       
   771 			{
       
   772 				COMASuplSETSessionID *setSessionId = NULL;
       
   773 				retrivedSessionID->SETSessionID(setSessionId);
       
   774 				if(setSessionId)
       
   775 					{
       
   776 	                    iTrace->Trace(_L("COMASuplInitState::CheckForSetSessionID, SET Session ID present"), KTraceFileName, __LINE__); 
       
   777 						return KErrSuplInvalidSessionID;
       
   778 					}
       
   779 				else
       
   780 					{
       
   781 	                    iTrace->Trace(_L("CheckForSetSessionID, returning KErrNone"), KTraceFileName, __LINE__); 							
       
   782 						return KErrNone;
       
   783 					}
       
   784 			}
       
   785 		else
       
   786 			{
       
   787 				return KErrSuplInvalidSessionID;
       
   788 			}
       
   789 	}
       
   790 		
       
   791 // -----------------------------------------------------------------------------
       
   792 //  COMASuplInitState::CheckForSetSessionID
       
   793 // CheckForModeSupport...Checks if Set session ID is present in the SUPL INT
       
   794 // message received
       
   795 // (other items were commented in a header).
       
   796 // -----------------------------------------------------------------------------
       
   797 //
       
   798 TInt COMASuplInitState::CheckForSLPSessionID()
       
   799 	{
       
   800 	    iTrace->Trace(_L("Start COMASuplInitState::CheckForSLPSessionID"), KTraceFileName, __LINE__); 							
       
   801 		COMASuplSessionID* retrivedSessionID = NULL;
       
   802 		iSuplInit->SessionId(retrivedSessionID);
       
   803 		if(retrivedSessionID)
       
   804 			{
       
   805 				TBuf8<KSLPSessionID> sessionId;
       
   806 				COMASuplSLPAddress* slpIPAddress = NULL;
       
   807 				COMASuplSLPSessionID* retrivedSuplSLPID =NULL;
       
   808 				retrivedSessionID->SLPSessionID(retrivedSuplSLPID);
       
   809 				if(retrivedSuplSLPID)
       
   810 					{
       
   811 	                    iTrace->Trace(_L("CheckForSLPSessionID, SLP ID retrieved"), KTraceFileName, __LINE__); 							
       
   812 						retrivedSuplSLPID->SuplSLPSessionID(sessionId,slpIPAddress);
       
   813 	                    iTrace->Trace(_L("SuplSLPSessionID, returned"), KTraceFileName, __LINE__); 							
       
   814 						if(sessionId.Length() == 0 )
       
   815                             {                                
       
   816 	                        iTrace->Trace(_L("SuplSLPSessionID, returned length zero"), KTraceFileName, __LINE__); 							
       
   817 							return KErrSuplInvalidSessionID;
       
   818                             }
       
   819 						else
       
   820                             {                                
       
   821 	                        iTrace->Trace(_L("CheckForSLPSessionID, returning KErrNone"), KTraceFileName, __LINE__); 							
       
   822 							return KErrNone;	
       
   823                             }
       
   824 					}
       
   825 				else
       
   826 					{
       
   827 	                    iTrace->Trace(_L("CheckForSLPSessionID, returning KErrSuplInvalidSessionID"), KTraceFileName, __LINE__); 							
       
   828 						return KErrSuplInvalidSessionID;
       
   829 					}
       
   830 			}
       
   831 		else
       
   832 			{
       
   833 				return KErrSuplInvalidSessionID;
       
   834 			}
       
   835 	}
       
   836 
       
   837 // -----------------------------------------------------------------------------
       
   838 //  COMASuplInitState::CheckForPositioningMethod
       
   839 // CheckForPositioningMethod...
       
   840 // (other items were commented in a header).
       
   841 // -----------------------------------------------------------------------------
       
   842 //
       
   843 void COMASuplInitState::CheckForPositioningMethod()
       
   844 	{
       
   845 	    iTrace->Trace(_L("Start COMASuplInitState::CheckForPositioningMethod"), KTraceFileName, __LINE__); 							
       
   846 		COMASuplInit::TOMASuplSLPMode SLPMode;
       
   847 		iSuplInit->SuplInit(iPosMethod,SLPMode);
       
   848 		if(EOMANoPosition == iPosMethod)
       
   849 			{
       
   850 				iNoPosition = ETrue;
       
   851 			}
       
   852 	    iTrace->Trace(_L("End COMASuplInitState::CheckForPositioningMethod"), KTraceFileName, __LINE__); 							
       
   853 	}
       
   854 
       
   855 // -----------------------------------------------------------------------------
       
   856 //  COMASuplInitState::CheckForExtensionParameters
       
   857 // CheckForExtensionParameters...
       
   858 // (other items were commented in a header).
       
   859 // -----------------------------------------------------------------------------
       
   860 //
       
   861 void COMASuplInitState::CheckForExtensionParameters()
       
   862 	{
       
   863 	iTrace->Trace(_L("Start COMASuplInitState::CheckForExtensionParameters"), KTraceFileName, __LINE__); 							
       
   864     COMASuplVer2SuplInitExtn* ver2Extn = NULL;            
       
   865 	iTrace->Trace(_L("CheckForExtensionParameters, calling GetVer2SuplInitExtn"), KTraceFileName, __LINE__); 							
       
   866 	TInt err = iSuplInit->GetVer2SuplInitExtn(ver2Extn);
       
   867     if (err == KErrNone)
       
   868         {            
       
   869 	    iTrace->Trace(_L("CheckForExtensionParameters, calling GetNotificationMode"), KTraceFileName, __LINE__); 							
       
   870         ver2Extn->GetNotificationMode(iNotificationMode);
       
   871 	    iTrace->Trace(_L("CheckForExtensionParameters, calling GetTrigType"), KTraceFileName, __LINE__); 							
       
   872         ver2Extn->GetTrigType(iTriggerType);
       
   873 	    iTrace->Trace(_L("CheckForExtensionParameters, calling GetHistoricRep"), KTraceFileName, __LINE__); 							
       
   874         ver2Extn->GetHistoricRep(iHistRepSupported);
       
   875         iTriggerSessionFlag = ETrue;
       
   876        
       
   877         }
       
   878     else
       
   879 	    iTrace->Trace(_L("CheckForExtensionParameters, ext2 absent"), KTraceFileName, __LINE__); 							
       
   880 	iTrace->Trace(_L("End COMASuplInitState::CheckForExtensionParameters"), KTraceFileName, __LINE__); 							
       
   881 	}
       
   882 
       
   883 TInt ConvertHexToGSMDefault(TInt aHex)	
       
   884 	{
       
   885 		TInt GSMDefaultEquivalentHex = aHex;
       
   886 		switch(aHex)
       
   887 			{
       
   888 				case 0x00:GSMDefaultEquivalentHex = 0x40;break;
       
   889 				case 0x01:GSMDefaultEquivalentHex = 0xA3;break;
       
   890 				case 0x02:GSMDefaultEquivalentHex = 0x24;break;
       
   891 				case 0x03:GSMDefaultEquivalentHex = 0xA5;break;
       
   892 				case 0x04:GSMDefaultEquivalentHex = 0xE8;break;
       
   893 				case 0x05:GSMDefaultEquivalentHex = 0xE9;break;
       
   894 				case 0x06:GSMDefaultEquivalentHex = 0xF9;break;
       
   895 				case 0x07:GSMDefaultEquivalentHex = 0xEC;break;
       
   896 				case 0x08:GSMDefaultEquivalentHex = 0xF2;break;
       
   897 				case 0x09:GSMDefaultEquivalentHex = 0xE7;break;
       
   898 				case 0x0a:GSMDefaultEquivalentHex = 0x0A;break;
       
   899 				case 0x0b:GSMDefaultEquivalentHex = 0xD8;break;
       
   900 				case 0x0c:GSMDefaultEquivalentHex = 0xF8;break;
       
   901 				case 0x0d:GSMDefaultEquivalentHex = 0x0D;break;
       
   902 				case 0x0e:GSMDefaultEquivalentHex = 0xC5;break;
       
   903 				case 0x0f:GSMDefaultEquivalentHex = 0xE5;break;
       
   904 				case 0x10:GSMDefaultEquivalentHex = 0x0394;break;
       
   905 				case 0x11:GSMDefaultEquivalentHex = 0x5F;break;
       
   906 				case 0x12:GSMDefaultEquivalentHex = 0x03A6;break;
       
   907 				case 0x13:GSMDefaultEquivalentHex = 0x0393;break;
       
   908 				case 0x14:GSMDefaultEquivalentHex = 0x039B;break;
       
   909 				case 0x15:GSMDefaultEquivalentHex = 0x03A9;break;
       
   910 				case 0x16:GSMDefaultEquivalentHex = 0x03A0;break;
       
   911 				case 0x17:GSMDefaultEquivalentHex = 0x03A8;break;
       
   912 				case 0x18:GSMDefaultEquivalentHex = 0x03A3;break;
       
   913 				case 0x19:GSMDefaultEquivalentHex = 0x0398;break;
       
   914 				case 0x1a:GSMDefaultEquivalentHex = 0x039E;break;
       
   915 				case 0x1c:GSMDefaultEquivalentHex = 0x00C6;break;
       
   916 				case 0x1d:GSMDefaultEquivalentHex = 0x00E6;break;
       
   917 				case 0x1e:GSMDefaultEquivalentHex = 0x00DF;break;
       
   918 				case 0x1f:GSMDefaultEquivalentHex = 0x00C9;break;
       
   919 				case 0x24:GSMDefaultEquivalentHex = 0xA4;break;
       
   920 				
       
   921 				case 0x40:GSMDefaultEquivalentHex = 0xA1;break;
       
   922 				case 0x5b:GSMDefaultEquivalentHex = 0xC4;break;
       
   923 				case 0x5c:GSMDefaultEquivalentHex = 0xD6;break;
       
   924 				case 0x5d:GSMDefaultEquivalentHex = 0xD1;break;
       
   925 				case 0x5e:GSMDefaultEquivalentHex = 0xDC;break;
       
   926 				case 0x5f:GSMDefaultEquivalentHex = 0xA7;break;
       
   927 				case 0x60:GSMDefaultEquivalentHex = 0xBF;break;
       
   928 				
       
   929 				case 0x7b:GSMDefaultEquivalentHex = 0xE4;break;
       
   930 				case 0x7c:GSMDefaultEquivalentHex = 0xF6;break;
       
   931 				case 0x7d:GSMDefaultEquivalentHex = 0xF1;break;
       
   932 				case 0x7e:GSMDefaultEquivalentHex = 0xFC;break;
       
   933 				case 0x7f:GSMDefaultEquivalentHex = 0xE0;break;
       
   934 				default:break;	
       
   935 			}
       
   936 			
       
   937 		return GSMDefaultEquivalentHex;	
       
   938 	}
       
   939 	
       
   940 // -----------------------------------------------------------------------------
       
   941 // COMASuplInitState::GsmDefaultDecode
       
   942 // GsmDefaultDecode...
       
   943 // This function takes packed 7 bit data and pads it out to 8 bit data
       
   944 // Function will actually append data onto end of an existing buffer.
       
   945 // (other items were commented in a header).
       
   946 // -----------------------------------------------------------------------------
       
   947 //
       
   948 void COMASuplInitState::GsmDefaultDecode( const TDesC8& aIn, TDes8& aOut )
       
   949 	{
       
   950 
       
   951 	TInt length = aIn.Length();
       
   952 	TInt count = ( length * 8 ) / 7;
       
   953 
       
   954 	// Get raw pointers and do unpacking
       
   955 	TUint8* outPtr = (TUint8*)aOut.Ptr() + aOut.Length();
       
   956 	const TUint8* inPtr = aIn.Ptr();
       
   957 
       
   958 	TInt startBit = 0;
       
   959 	// Iterate over each 7 bit element
       
   960 	for ( TInt ii = 0; ii < count; ii++ )
       
   961 		{
       
   962 		TInt from = ( *inPtr >> startBit ) & 0x7F;
       
   963 		if ( startBit )
       
   964 			{
       
   965 			inPtr++;
       
   966 			from |= ( *inPtr << ( 8 - startBit ) ) & 0x7F;
       
   967 			}
       
   968 		outPtr[ ii ] = (TUint8)from;
       
   969 		startBit = ( startBit + 7 ) % 8;
       
   970 		}
       
   971 	aOut.SetLength( aOut.Length() + count );
       
   972 	length = aOut.Length();
       
   973 	
       
   974 	for(TInt Index = 0 ; Index < length; Index++ )
       
   975 		{
       
   976 			if( Index == length - 1 && (aOut[Index] == 0x0000 || aOut[Index] == 0x000D))
       
   977 				{
       
   978 					aOut.SetLength( Index );
       
   979 					break;
       
   980 				}
       
   981 
       
   982 			aOut[Index] =  ConvertHexToGSMDefault(aOut[Index]);
       
   983 		}
       
   984 
       
   985 	}
       
   986 
       
   987 // -----------------------------------------------------------------------------
       
   988 // COMASuplInitState::FormUCS2String
       
   989 // FormUCS2String...
       
   990 // This function takes two consecuative characters from input string and combine them to form 
       
   991 // single character of 16-bit.
       
   992 // (other items were commented in a header).
       
   993 // -----------------------------------------------------------------------------
       
   994 //
       
   995 void COMASuplInitState::FormUCS2String( const TDesC8& aIn, TDes& aOut )
       
   996 	{
       
   997 		TUint16 Res; 
       
   998 		TUint16 FirstChar;
       
   999 		TUint16 SecondChar;
       
  1000 		aOut.Zero();
       
  1001 		TInt Len  = aIn.Length() / 2;
       
  1002 		TInt Index = 0;
       
  1003 		TBool IsBigEndian = ETrue;
       
  1004 		TInt Count = 0;
       
  1005 		if(aIn.Length() >= 2  && ((aIn[Index] != 0xFF || aIn[Index + 1] != 0xFE ) && (aIn[Index + 1] != 0xFF || aIn[Index] != 0xFE ))) // Since this is not following algorithm
       
  1006 			{
       
  1007 				aOut.Zero();
       
  1008 				return;
       
  1009 			}
       
  1010 			
       
  1011 		if(aIn.Length() >= 2  && aIn[Index] == 0xFE && aIn[Index + 1] == 0xFF) // Big Endian
       
  1012 			{
       
  1013 				Index = 2;
       
  1014 				Count = 1;
       
  1015 			}
       
  1016 			
       
  1017 		if(aIn.Length() >= 2 && aIn[Index] == 0xFF && aIn[Index + 1] == 0xFE) // Little Endian
       
  1018 			{
       
  1019 				Index = 2;
       
  1020 				IsBigEndian = EFalse;
       
  1021 				Count = 1;
       
  1022 			}
       
  1023 			
       
  1024 		
       
  1025 		for(;Count < Len; Count++)
       
  1026 		{
       
  1027 			if(IsBigEndian)
       
  1028 				{
       
  1029 					FirstChar  = aIn[Index];
       
  1030 					SecondChar = aIn[Index + 1];
       
  1031 				}
       
  1032 			else
       
  1033 				{
       
  1034 					FirstChar  = aIn[Index + 1];
       
  1035 					SecondChar = aIn[Index];
       
  1036 				}	
       
  1037 			FirstChar = FirstChar << 8;	
       
  1038 			Res = FirstChar | SecondChar;
       
  1039 			aOut.Append(Res);
       
  1040 			Index = Index + 2;
       
  1041 		}
       
  1042 
       
  1043 	}
       
  1044 	
       
  1045 TOMASuplPosMethod COMASuplInitState::GetPosMethod()
       
  1046 {
       
  1047 	TBuf<128> msg(_L("SuplInitState::GetPosMethod():"));
       
  1048 	msg.AppendNum(iPosMethod);
       
  1049 	iTrace->Trace(msg, KTraceFileName, __LINE__); 
       
  1050 	return iPosMethod;
       
  1051 }
       
  1052 
       
  1053 TBool COMASuplInitState::IsTriggerSession()
       
  1054 {
       
  1055     
       
  1056     return iTriggerSessionFlag;
       
  1057 }
       
  1058 
       
  1059 COMASuplTriggeredStart::TOMASuplTrigType COMASuplInitState::GetTriggerType()
       
  1060 {
       
  1061 	return iTriggerType;
       
  1062 }
       
  1063 
       
  1064 void COMASuplInitState::GetRequestorIDAndName(TInt& aRequestorId,TDes& aRequestorName) //APE Centric
       
  1065     {
       
  1066         aRequestorName.Copy(iRequestorName);
       
  1067         if ( iRequestIDFeatureFlag )
       
  1068         {
       
  1069         	aRequestorId = iGSMRequestId;
       
  1070         }
       
  1071         else
       
  1072         {
       
  1073         	aRequestorId = 0;
       
  1074         }
       
  1075     }
       
  1076     
       
  1077 void COMASuplInitState::GetPrivacyStatus(TBool& aPrivacyOverride)
       
  1078 	{
       
  1079 	iTrace->Trace(_L("COMASuplInitState::GetPrivacyStatus..."), KTraceFileName, __LINE__);
       
  1080 		aPrivacyOverride = iPrivacyOverride ;
       
  1081 	}
       
  1082 	
       
  1083 void COMASuplInitState::GetSuplPrivacyRequestInfo(CPosSUPLPrivacyRequestInfo*& asuplReqInfo)
       
  1084 {
       
  1085 	
       
  1086 	iTrace->Trace(_L("COMASuplInitState::GetSuplPrivacyRequestInfo..."), KTraceFileName, __LINE__);
       
  1087 	if (iSuplReqInfo)
       
  1088 	{
       
  1089   	asuplReqInfo = iSuplReqInfo;
       
  1090   }
       
  1091   else
       
  1092   {
       
  1093   	asuplReqInfo = NULL;
       
  1094   		iTrace->Trace(_L("iSuplReqInfo is null in state class..."), KTraceFileName, __LINE__);
       
  1095   }
       
  1096 }
       
  1097     
       
  1098 // -----------------------------------------------------------------------------
       
  1099 // COMASuplInitState::ReadRequestIDFeatureFlagL
       
  1100 //   
       
  1101 // 
       
  1102 // -----------------------------------------------------------------------------
       
  1103 
       
  1104 void COMASuplInitState::ReadRequestIDFeatureFlagL() //APE CENTRIC
       
  1105 {
       
  1106 
       
  1107 iRequestIDFeatureFlag = EFalse;
       
  1108 	FeatureManager::InitializeLibL();
       
  1109 
       
  1110  	// Feature flag check provided for Product profile bits specific variation
       
  1111  	
       
  1112  	
       
  1113 	iRequestIDFeatureFlag = FeatureManager::FeatureSupported(KSUPLAPECentricArchSupport);
       
  1114     FeatureManager::UnInitializeLib();
       
  1115     iRequestIDFeatureFlag = EFalse;
       
  1116 	
       
  1117 	if (iRequestIDFeatureFlag)
       
  1118         {
       
  1119 						iTrace->Trace(_L("APE Centric Arch Feature Flag is ON..."), KTraceFileName, __LINE__); 
       
  1120         }   
       
  1121 	else
       
  1122 				{
       
  1123 						iTrace->Trace(_L("APE Centric Arch Feature Flag is OFF..."), KTraceFileName, __LINE__); 
       
  1124 				}
       
  1125 	
       
  1126 }
       
  1127 
       
  1128 void COMASuplInitState::SetSessionId(TInt aSessionId)
       
  1129 {
       
  1130 	iSETSessionUniqueId = aSessionId;
       
  1131 }
       
  1132 
       
  1133 //  End of File