supl/locationomasuplprotocolhandler/protocolhandlerver1/src/epos_comasuplsession.cpp
branchRCL_3
changeset 20 2b4ea9893b66
parent 19 02ba3f1733c6
child 21 6b6920c56e2f
equal deleted inserted replaced
19:02ba3f1733c6 20:2b4ea9893b66
   170 		
   170 		
   171 		iSuplVersion.SetSuplVersion(KSuplMajorVersion,KSuplMinorVersion,KSuplRevision);
   171 		iSuplVersion.SetSuplVersion(KSuplMajorVersion,KSuplMinorVersion,KSuplRevision);
   172 		
   172 		
   173 		if( aIMSI.Length() )
   173 		if( aIMSI.Length() )
   174 		    {
   174 		    {
   175 		    iIMSI.Create( aIMSI );    
   175 		    User::LeaveIfError(iIMSI.Create( aIMSI ));    
   176 		    }
   176 		    }
   177 		
   177 		
   178 		if(iPosHandler)
   178 		if(iPosHandler)
   179 			{
   179 			{
   180 				iTrace->Trace(_L("Creating POSSession..."), KTraceFileName, __LINE__); 
   180 				iTrace->Trace(_L("Creating POSSession..."), KTraceFileName, __LINE__); 
   202 
   202 
   203         iDiffTime = 0;
   203         iDiffTime = 0;
   204         iSessionCompletionCode = KErrCompletion;
   204         iSessionCompletionCode = KErrCompletion;
   205         
   205         
   206         iNetworkPrivacy 	= CPosNetworkPrivacy::NewL();
   206         iNetworkPrivacy 	= CPosNetworkPrivacy::NewL();
       
   207         
       
   208         #ifdef PRINT_MESSAGE
       
   209         TInt retval = iLogger.Connect();
       
   210         if(retval == KErrNone)
       
   211 				iLogger.CreateLog(_L("NFT"),_L("NFT.txt"),EFileLoggingModeAppend);
       
   212 				#endif
   207         
   213         
   208 		iTrace->Trace(_L("End of COMASuplSession::ConstructL"), KTraceFileName, __LINE__); 
   214 		iTrace->Trace(_L("End of COMASuplSession::ConstructL"), KTraceFileName, __LINE__); 
   209     }
   215     }
   210     
   216     
   211 //
   217 //
   251 		{
   257 		{
   252 			CancelRunSession();
   258 			CancelRunSession();
   253 			SessionEnd();
   259 			SessionEnd();
   254 			CompleteSession(KErrCancel);
   260 			CompleteSession(KErrCancel);
   255 		}
   261 		}
   256 		iProtocolManager.CancelUiLaunch();
   262 
   257 		delete this;
   263 		delete this;
   258 	}
   264 	}
   259 
   265 
   260 // -----------------------------------------------------------------------------
   266 // -----------------------------------------------------------------------------
   261 // COMASuplSession::PosPlugInUnloaded
   267 // COMASuplSession::PosPlugInUnloaded
   314         delete iIapNotifier;
   320         delete iIapNotifier;
   315     	iIMSI.Close();
   321     	iIMSI.Close();
   316         delete iDialogTimer;
   322         delete iDialogTimer;
   317         
   323         
   318         delete iNetworkPrivacy;
   324         delete iNetworkPrivacy;
   319 
   325         
   320 	if(iStaleLocationId)
   326         #ifdef PRINT_MESSAGE
   321     	  {
   327         iLogger.CloseLog();
   322     	  delete iStaleLocationId;
   328 				iLogger.Close();
   323     	  iStaleLocationId = NULL;
   329 				#endif
   324     	  }  
       
   325     	
   330     	
   326     	if(iTrace)
   331     	if(iTrace)
   327     		iTrace->Trace(_L("End of ~COMASuplSession::COMASuplSession"), KTraceFileName, __LINE__); 
   332     		iTrace->Trace(_L("End of ~COMASuplSession::COMASuplSession"), KTraceFileName, __LINE__); 
   328 		    	
   333 		    	
   329     	delete iTrace;
   334     	delete iTrace;
   430 //
   435 //
   431  void COMASuplSession::RunSuplSessionL(TRequestStatus& aStatus, TBool aFirstReq, const TDesC& aHslpAddress, 
   436  void COMASuplSession::RunSuplSessionL(TRequestStatus& aStatus, TBool aFirstReq, const TDesC& aHslpAddress, 
   432                                        TBool aFallBack, TInt aAllowedCapabilities,
   437                                        TBool aFallBack, TInt aAllowedCapabilities,
   433  									  TInt aSessionIdSeed,TInt aRequestID,TBool aIsStaleCellId,COMASuplLocationId* aLocationId,TBool aPrompt,TBool aWlanOnly)
   438  									  TInt aSessionIdSeed,TInt aRequestID,TBool aIsStaleCellId,COMASuplLocationId* aLocationId,TBool aPrompt,TBool aWlanOnly)
   434     {
   439     {
       
   440     	
       
   441     		iSessionStartTime1.HomeTime();
       
   442     		
       
   443 				
       
   444     	
   435 	    iRunRequestStatus = & aStatus;
   445 	    iRunRequestStatus = & aStatus;
   436 	    *iRunRequestStatus = KRequestPending;
   446 	    *iRunRequestStatus = KRequestPending;
   437 
   447 
   438         iRequestID = aRequestID;
   448         iRequestID = aRequestID;
   439 
   449 
   498                 }
   508                 }
   499             } //OCC
   509             } //OCC
   500 
   510 
   501     	if(aAllowedCapabilities == 0)
   511     	if(aAllowedCapabilities == 0)
   502     		{
   512     		{
   503 				iAllowedCapabilities = KGpsSETBased | KAutonomousGps| KAFLT | KECID | KEOTD | KOTDOA | KCID; 
   513     			iAllowedCapabilities = KGpsSETBased | KAutonomousGps| KAFLT | KECID | KEOTD | KOTDOA | KCID; 
   504     		}
   514     		}
   505     	else
   515     	else
   506     		{
   516     		{
   507     			iAllowedCapabilities = aAllowedCapabilities;
   517     			iAllowedCapabilities = aAllowedCapabilities;
   508     		}
   518     		}
   543 
   553 
   544 	    
   554 	    
   545 		// Clear  Position....
   555 		// Clear  Position....
   546 		delete iPosition;
   556 		delete iPosition;
   547 		iPosition = NULL;
   557 		iPosition = NULL;
   548 
   558 		
   549 	    
   559 	    
   550 		iTrace->Trace(_L("End of COMASuplSession::RunSuplSession"), KTraceFileName, __LINE__); 
   560 		iTrace->Trace(_L("End of COMASuplSession::RunSuplSession"), KTraceFileName, __LINE__); 
   551     }
   561     }
   552 
   562 
   553 // -----------------------------------------------------------------------------
   563 // -----------------------------------------------------------------------------
   562                                         const TDesC& aHslpAddress, TBool aFallBack,
   572                                         const TDesC& aHslpAddress, TBool aFallBack,
   563   										TInt aAllowedCapabilities,TInt aSessionIdSeed,
   573   										TInt aAllowedCapabilities,TInt aSessionIdSeed,
   564   										TSuplTerminalQop& aQop, TInt aRequestID)
   574   										TSuplTerminalQop& aQop, TInt aRequestID)
   565   	{
   575   	{
   566   	
   576   	
   567         iIhaveLaunchedUsagedialog = EFalse;
       
   568   		
   577   		
   569 	  	iClientQop = aQop;
   578 	  	iClientQop = aQop;
   570 	  	
   579 	  	
   571 		TInt delay;
   580 		TInt delay;
   572 		if(iClientQop.GetDelay(delay) != KErrNotFound)
   581 		if(iClientQop.GetDelay(delay) != KErrNotFound)
   718 		    iTrace->Trace(_L("GenerateSuplStartL setting stale location id in supl start"), KTraceFileName, __LINE__);
   727 		    iTrace->Trace(_L("GenerateSuplStartL setting stale location id in supl start"), KTraceFileName, __LINE__);
   719 		    COMASuplStartState* startSuplState =  static_cast <COMASuplPosInitState *>(iSuplState);
   728 		    COMASuplStartState* startSuplState =  static_cast <COMASuplPosInitState *>(iSuplState);
   720 		    startSuplState->SetStaleCellIdToUse(iStaleLocationId->CloneL());
   729 		    startSuplState->SetStaleCellIdToUse(iStaleLocationId->CloneL());
   721 		    }
   730 		    }
   722         iSuplSessionState = ESUPL_GENERATE;
   731         iSuplSessionState = ESUPL_GENERATE;
   723         iSuplMsgType = ESUPL_START;
   732 		iSuplMsgType = ESUPL_START;
       
   733 		SetPOSMsgPluginState(COMASuplPosSessionBase::EOMASuplCreating); 	
   724 		TInt err = iSuplState->GenerateMessageL();
   734 		TInt err = iSuplState->GenerateMessageL();
   725 	
   735 
   726 
       
   727 		SetPOSMsgPluginState(COMASuplPosSessionBase::EOMASuplCreating);	
       
   728 	}  
   736 	}  
   729 	 
   737 	 
   730 
   738 
   731 // -----------------------------------------------------------------------------
   739 // -----------------------------------------------------------------------------
   732 // COMASuplSession::GenerateSuplPosInitL
   740 // COMASuplSession::GenerateSuplPosInitL
   860 //Informs to client about completion of location request, thro' active object
   868 //Informs to client about completion of location request, thro' active object
   861  void COMASuplSession::CompleteSession(TInt aCompletionCode)
   869  void COMASuplSession::CompleteSession(TInt aCompletionCode)
   862     {	
   870     {	
   863     	if(iRunRequestStatus)
   871     	if(iRunRequestStatus)
   864     		{
   872     		{
   865     		
   873     		TTimeIntervalSeconds timeTaken;
   866     		TTime currentTime;
   874     		TTime currentTime;
   867     		currentTime.HomeTime();
   875     		currentTime.HomeTime();
       
   876     		currentTime.SecondsFrom(iSessionStartTime1,timeTaken);
       
   877     		
       
   878     		#ifdef PRINT_MESSAGE
       
   879     		TBuf<30> bufTime1;
       
   880     		_LIT( KFormatDate, "%d%+02d%+02d:%+02d%+02d%+02d.%+06d");
       
   881     		
       
   882     		TDateTime datetime = iSessionStartTime1.DateTime();
       
   883 				bufTime1.Format( KFormatDate, datetime.Year(), 
       
   884 				datetime.Month(), datetime.Day(), 
       
   885 				datetime.Hour(), datetime.Minute(), 
       
   886 				datetime.Second(), datetime.MicroSecond());
       
   887 
       
   888 				iLogger.Write(_L("Session started at time : "));
       
   889     		iLogger.Write(bufTime1);
       
   890 				
       
   891 				TBuf<30> bufTime;
       
   892 				
       
   893 				TDateTime datetime1 = currentTime.DateTime();
       
   894 				bufTime.Format( KFormatDate, datetime1.Year(), 
       
   895 				datetime1.Month(), datetime1.Day(), 
       
   896 				datetime1.Hour(), datetime1.Minute(), 
       
   897 				datetime1.Second(), datetime1.MicroSecond());
       
   898 				
       
   899 				iLogger.Write(_L("Session ended at time : "));
       
   900     		iLogger.Write(bufTime);
       
   901     		iLogger.Write(_L("Time taken : "));
       
   902     		//bufTime.Copy(timeTaken);
       
   903     		iLogger.Write(bufTime);
       
   904     		#endif
       
   905     		
   868     		iSessionCompletionCode = aCompletionCode;
   906     		iSessionCompletionCode = aCompletionCode;
   869     		
   907     		
   870 			TBuf<64> errorCode;
   908 			TBuf<64> errorCode;
   871 			errorCode.Append(_L("Completing Session with error code : "));
   909 			errorCode.Append(_L("Completing Session with error code : "));
   872 			errorCode.AppendNum(aCompletionCode);
   910 			errorCode.AppendNum(aCompletionCode);
  2034 // (other items were commented in a header).
  2072 // (other items were commented in a header).
  2035 // -----------------------------------------------------------------------------
  2073 // -----------------------------------------------------------------------------
  2036 //
  2074 //
  2037 void COMASuplSession::HandleOMASuplMessageL(COMASuplAsnMessageBase* aDecodedAsnMessage,TRequestStatus& aStatus,TInt aSessionIdSeed,TInt aErrorCode)
  2075 void COMASuplSession::HandleOMASuplMessageL(COMASuplAsnMessageBase* aDecodedAsnMessage,TRequestStatus& aStatus,TInt aSessionIdSeed,TInt aErrorCode)
  2038 	{
  2076 	{
  2039 	delete iSuplState;
  2077 		delete iSuplState;
  2040 	iSuplState = NULL;
  2078 		iSuplState = NULL;
  2041 		
  2079 		
  2042 	iSETSessionUniqueId = aSessionIdSeed;
  2080 		iSETSessionUniqueId = aSessionIdSeed;
  2043 	iRunRequestStatus = & aStatus;
  2081 		iRunRequestStatus = & aStatus;
  2044 	*iRunRequestStatus = KRequestPending;
  2082 	    *iRunRequestStatus = KRequestPending;
  2045 	    
  2083 	    
  2046 	TInt networkMode = 1;
  2084 		TInt networkMode = 1;
  2047 	networkMode = GetNetworkModeL();
  2085 		networkMode = GetNetworkModeL();
  2048 		
  2086 		
  2049 	TBuf<64> msg;
  2087 		TBuf<64> msg;
  2050 	if ( networkMode == ECoreAppUIsNetworkConnectionNotAllowed )
  2088 		if ( networkMode == ECoreAppUIsNetworkConnectionNotAllowed )
  2051 		{
  2089 			{
  2052 		msg.Copy(_L("The device is in OFFLINE mode."));
  2090 				msg.Copy(_L("The device is in OFFLINE mode."));
  2053 		iTrace->Trace(msg,KTraceFileName, __LINE__); 
  2091 				iTrace->Trace(msg,KTraceFileName, __LINE__); 
  2054 		iSessionObserver.TerminateSession(this, KErrGeneral);
  2092 				iSessionObserver.TerminateSession(this, KErrGeneral);
  2055 		return;
  2093 				return;
  2056 		}
  2094 			}
  2057 	else
  2095 		else
  2058 		{
  2096 			{
  2059 		msg.Copy(_L("The device is in ON LINE mode."));
  2097 				msg.Copy(_L("The device is in ON LINE mode."));
  2060 		iTrace->Trace(msg,KTraceFileName, __LINE__); 
  2098 				iTrace->Trace(msg,KTraceFileName, __LINE__); 
  2061 		}
  2099 			}
  2062 
  2100 
  2063     CSuplSettings::TSuplSettingsUsage usage = iSuplSettings->SUPLUsage();
  2101         /*CSuplSettings::TSuplSettingsUsage usage = iSuplSettings->SUPLUsage();
  2064 
  2102 
  2065     if (usage == CSuplSettings::ESuplUsageDisabled)
  2103         if (usage == CSuplSettings::ESuplUsageDisabled)
  2066         {                
  2104             {                
  2067 		msg.Copy(_L("SUPL Usage is disabled"));
  2105 			msg.Copy(_L("SUPL Usage is disabled"));
  2068 		iTrace->Trace(msg,KTraceFileName, __LINE__); 
  2106 			iTrace->Trace(msg,KTraceFileName, __LINE__); 
  2069 	    iSessionObserver.TerminateSession(this, KErrGeneral);	
  2107 	        iSessionObserver.TerminateSession(this, KErrGeneral);	
  2070 		return;
  2108 			return;
  2071         }
  2109             }*/
  2072 	    
  2110 	    
  2073 	COMASuplAsnMessageBase::TSuplMessageType messageType = aDecodedAsnMessage->MessageType();
  2111 	    COMASuplAsnMessageBase::TSuplMessageType messageType = aDecodedAsnMessage->MessageType();
  2074 	    
  2112 	    
  2075 	if(messageType == COMASuplAsnMessageBase::ESUPL_INIT && aErrorCode == KErrNone)
  2113 	    if(messageType == COMASuplAsnMessageBase::ESUPL_INIT && aErrorCode == KErrNone)
  2076 		{
       
  2077 	    HandleOMASuplMessageL(aDecodedAsnMessage);
       
  2078 	    }
       
  2079 	else //Other messages than SUPL_INIT.... Send End
       
  2080 	    {
       
  2081 	    CreateCloneMessageL(aDecodedAsnMessage);		
       
  2082 	    UpdateSuplSessionIDL();
       
  2083 
       
  2084 	    if (iRequestType == ESUPL_NETWORK && messageType == COMASuplAsnMessageBase::ESUPL_INIT)
       
  2085 	    	{
  2114 	    	{
  2086 			ServerAddressCheckForSuplInitL();
  2115 	    		HandleOMASuplMessageL(aDecodedAsnMessage);
  2087 	    	}
  2116 	    	}
  2088  
  2117 	    else //Other messages than SUPL_INIT.... Send End
  2089 		iSuplSessionState = ESUPL_INITIALIZED;
  2118 	    	{
  2090 		iSuplMsgType = ESUPL_END;
  2119 	    		CreateCloneMessageL(aDecodedAsnMessage);		
  2091 
  2120 	    		UpdateSuplSessionIDL();
  2092 	    if((aErrorCode == KErrCompletion && messageType == COMASuplAsnMessageBase::ESUPL_INIT) ||
  2121         if (iRequestType == ESUPL_NETWORK && messageType == COMASuplAsnMessageBase::ESUPL_INIT)
  2093 	    	(aErrorCode == KErrOMASuplOutOfRangeParameter && messageType == COMASuplAsnMessageBase::ESUPL_INIT) ||
  2122             {
  2094 	    	(aErrorCode == KErrOMASuplMessageLengthMismatch && messageType == COMASuplAsnMessageBase::ESUPL_INIT) ||
  2123             ServerAddressCheckForSuplInitL();
  2095 			(aErrorCode == KErrOMASuplShortFrame && messageType == COMASuplAsnMessageBase::ESUPL_INIT))	    			
  2124             }
  2096 	   		{
  2125 				iSuplSessionState = ESUPL_INITIALIZED;
  2097 	    	iErrorStatusCode = COMASuplEnd::EUnexpectedDataValue;
  2126 				iSuplMsgType = ESUPL_END;
  2098 	    	if(aErrorCode == KErrOMASuplMessageLengthMismatch)
  2127 
  2099 	    		{
  2128 	    		if((aErrorCode == KErrCompletion && messageType == COMASuplAsnMessageBase::ESUPL_INIT) ||
  2100 	    		iErrorStatusCode = COMASuplEnd::EProtocolError;
  2129 	    			(aErrorCode == KErrOMASuplOutOfRangeParameter && messageType == COMASuplAsnMessageBase::ESUPL_INIT) ||
  2101 	    		}
  2130 	    			(aErrorCode == KErrOMASuplMessageLengthMismatch && messageType == COMASuplAsnMessageBase::ESUPL_INIT) ||
  2102       		if(aErrorCode == KErrOMASuplShortFrame)
  2131 						(aErrorCode == KErrOMASuplShortFrame && messageType == COMASuplAsnMessageBase::ESUPL_INIT))	    			
  2103 	    		{
  2132 	    			{
  2104 	    		iErrorStatusCode = COMASuplEnd::EDataMissing;
  2133 	    				iErrorStatusCode = COMASuplEnd::EUnexpectedDataValue;
  2105 	    		}
  2134 	    				if(aErrorCode == KErrOMASuplMessageLengthMismatch)
  2106 			TInt len = iHSLPAddress.Length();
  2135 	    					{
  2107 			HBufC8 *hslpAdress = NULL;
  2136 	    						iErrorStatusCode = COMASuplEnd::EProtocolError;
  2108 			if(len > 0)
  2137 	    					}
  2109 				{
  2138       				if(aErrorCode == KErrOMASuplShortFrame)
  2110 				hslpAdress = HBufC8::NewL(iHSLPAddress.Length());
  2139 	    					{
  2111 				hslpAdress->Des().Copy(iHSLPAddress);
  2140 	    						iErrorStatusCode = COMASuplEnd::EDataMissing;
  2112 				}						
  2141 	    					}
  2113 			else if(len ==0)
  2142 						TInt len = iHSLPAddress.Length();
  2114 				{
  2143 						HBufC8 *hslpAdress = NULL;
  2115 				CServerParams* serverParams = CServerParams::NewL();
  2144 						if(len > 0)
  2116 				CleanupStack::PushL(serverParams);
  2145 						{
  2117 					
  2146 							hslpAdress = HBufC8::NewL(iHSLPAddress.Length());
  2118 				if (iSuplStorageSettings->GetDefaultServer(serverParams) == KErrNotFound )
  2147 							hslpAdress->Des().Copy(iHSLPAddress);
  2119 					{
  2148 						}
  2120 					iTrace->Trace(_L("HSLP generated frm IMSI"), KTraceFileName, __LINE__);
       
  2121 					hslpAdress = HBufC8::NewL(iSuplSettings->SLPAddressfromImsi().Length());
       
  2122 					hslpAdress->Des().Copy(iSuplSettings->SLPAddressfromImsi());
       
  2123 					}		
       
  2124 				else
       
  2125 					{
       
  2126 					iTrace->Trace(_L("Sending End with ver for Default HSLP"), KTraceFileName, __LINE__);
       
  2127 					TInt64 slpId;
       
  2128             		TBool aServerEnabled, aSimChangeRemove, aUsageInHomeNw, aEditable;
       
  2129 					HBufC* serverAddr = HBufC::NewL(KMaxHSLPAddrLen);
       
  2130 					HBufC* iapName = HBufC::NewL(KMaxIAPLen);
       
  2131 					CleanupStack::PushL(serverAddr);
       
  2132 					CleanupStack::PushL(iapName);
       
  2133 					serverParams->Get(slpId,serverAddr->Des(),iapName->Des(),aServerEnabled, aSimChangeRemove, aUsageInHomeNw, aEditable);
       
  2134 					hslpAdress = HBufC8::NewL(serverAddr->Length());
       
  2135 					hslpAdress->Des().Copy(*serverAddr);
       
  2136 						
  2149 						
  2137 					CleanupStack::PopAndDestroy(iapName);
  2150 						else if(len ==0)
  2138 					CleanupStack::PopAndDestroy(serverAddr);
  2151 						{
  2139 							
  2152                 CServerParams* serverParams = CServerParams::NewL();
  2140 					}
  2153                 CleanupStack::PushL(serverParams);
  2141 				CleanupStack::PopAndDestroy(serverParams);
  2154             
  2142 				}
  2155                 if (iSuplStorageSettings->GetDefaultServer(serverParams) == KErrNotFound )
  2143 			delete iSuplState;
  2156                     {
  2144 			iSuplState = NULL;
  2157                     iTrace->Trace(_L("HSLP generated frm IMSI"), KTraceFileName, __LINE__);
  2145 			CleanupStack::PushL(hslpAdress);
  2158                     hslpAdress = HBufC8::NewL(iSuplSettings->SLPAddressfromImsi().Length());
  2146 			iSuplState = COMASuplEndState::NewL(iErrorStatusCode,iOMASuplAsnHandlerBaseImpl,iEncodedSuplInit,hslpAdress);
  2159                     hslpAdress->Des().Copy(iSuplSettings->SLPAddressfromImsi());	
  2147 			CleanupStack::PopAndDestroy(hslpAdress);
  2160                     }		
  2148 	    	}
  2161                 else
  2149 	    else
  2162                     {
  2150 	    	{
  2163                     iTrace->Trace(_L("Sending End with ver for Default HSLP"), KTraceFileName, __LINE__);
  2151 	    		iErrorStatusCode = COMASuplEnd::EUnexpectedMessage;
  2164                     TInt64 slpId;
  2152 	    		iSuplState = COMASuplEndState::NewL(iErrorStatusCode,iOMASuplAsnHandlerBaseImpl);
  2165                     TBool aServerEnabled, aSimChangeRemove, aUsageInHomeNw, aEditable;
  2153 	    	}	
  2166                     HBufC* serverAddr = HBufC::NewL(KMaxHSLPAddrLen);
       
  2167                     HBufC* iapName = HBufC::NewL(KMaxIAPLen);
       
  2168                     CleanupStack::PushL(serverAddr);
       
  2169                     CleanupStack::PushL(iapName);
       
  2170                     serverParams->Get(slpId,serverAddr->Des(),iapName->Des(),aServerEnabled, aSimChangeRemove, aUsageInHomeNw, aEditable);
       
  2171                     hslpAdress = HBufC8::NewL(serverAddr->Length());
       
  2172                     hslpAdress->Des().Copy(*serverAddr);
       
  2173                 
       
  2174                     CleanupStack::PopAndDestroy(iapName);
       
  2175                     CleanupStack::PopAndDestroy(serverAddr);
       
  2176                     }
       
  2177                 CleanupStack::PopAndDestroy(serverParams);
       
  2178                 }
       
  2179             delete iSuplState;
       
  2180             iSuplState = NULL;
       
  2181 						CleanupStack::PushL(hslpAdress);
       
  2182 						iSuplState = COMASuplEndState::NewL(iErrorStatusCode,iOMASuplAsnHandlerBaseImpl,iEncodedSuplInit,hslpAdress);		
       
  2183 						CleanupStack::PopAndDestroy(hslpAdress);
       
  2184 	    			}
       
  2185 	    		else
       
  2186 	    			{
       
  2187 	    				iErrorStatusCode = COMASuplEnd::EUnexpectedMessage;
       
  2188 	    				iSuplState = COMASuplEndState::NewL(iErrorStatusCode,iOMASuplAsnHandlerBaseImpl);
       
  2189 	    			}	
  2154 	    			
  2190 	    			
  2155 	    SetPOSMsgPluginState(COMASuplPosSessionBase::EOMASuplCreating);	
  2191 	    		SetPOSMsgPluginState(COMASuplPosSessionBase::EOMASuplCreating);	
  2156 		iSuplState->SetMsgStateObserver(this);
  2192 				iSuplState->SetMsgStateObserver(this);
  2157 		//SMP Changes
  2193 				//SMP Changes
  2158 		iSuplState->GenerateMessageL(); //Has to be here because initialisation has to be done for NI case in decode failed scenario.
  2194         iSuplState->GenerateMessageL(); //Has to be here because initialisation has to be done for NI case in decode failed scenario.
  2159 		iSuplSessionState = ESUPL_GENERATE;				 
  2195         iSuplSessionState = ESUPL_GENERATE;
  2160 		}	
  2196         }	
  2161 	}
  2197 	}
  2162 
  2198 
  2163 // -----------------------------------------------------------------------------
  2199 // -----------------------------------------------------------------------------
  2164 // COMASuplSession::HandleOMASuplMessage
  2200 // COMASuplSession::HandleOMASuplMessage
  2165 // Handles OMA Supl messages & starts processing according to state of session.
  2201 // Handles OMA Supl messages & starts processing according to state of session.
  2166 // (other items were commented in a header).
  2202 // (other items were commented in a header).
  2167 // -----------------------------------------------------------------------------
  2203 // -----------------------------------------------------------------------------
  2168 //
  2204 //
  2169 void COMASuplSession::HandleOMASuplMessageL(COMASuplAsnMessageBase* aDecodedAsnMessage)
  2205 void COMASuplSession::HandleOMASuplMessageL(COMASuplAsnMessageBase* aDecodedAsnMessage)
  2170 	{
  2206 	{
  2171     CreateCloneMessageL(aDecodedAsnMessage);
  2207 		CreateCloneMessageL(aDecodedAsnMessage);		
  2172 		if(CheckProtocolVersionL(aDecodedAsnMessage)) //Checks version with supported version
  2208 		if(CheckProtocolVersionL(aDecodedAsnMessage)) //Checks version with supported version
  2173 		{
  2209 		{
  2174 			COMASuplAsnMessageBase::TSuplMessageType messageType = aDecodedAsnMessage->MessageType();
  2210 			COMASuplAsnMessageBase::TSuplMessageType messageType = aDecodedAsnMessage->MessageType();
  2175 
       
  2176 			if(messageType != COMASuplAsnMessageBase::ESUPL_POS)
  2211 			if(messageType != COMASuplAsnMessageBase::ESUPL_POS)
  2177 				{
  2212 				{
  2178 					iCompleteSelfRequestor->CompleteSelf(); //This will result in call of RequestCompleted()
  2213 					iCompleteSelfRequestor->CompleteSelf(); //This will result in call of RequestCompleted()
  2179 				}
  2214 				}
  2180 			else
  2215 			else
  3118 								iTrace->Trace(_L("Failed to Generate First messsage from POS...still continueing.."), KTraceFileName, __LINE__); 		
  3153 								iTrace->Trace(_L("Failed to Generate First messsage from POS...still continueing.."), KTraceFileName, __LINE__); 		
  3119 								iIsFirstPOSMessage = EFalse;
  3154 								iIsFirstPOSMessage = EFalse;
  3120 								return;
  3155 								return;
  3121 							}
  3156 							}
  3122 					}
  3157 					}
       
  3158 				//Comment to ignore coverity missing break error
       
  3159 				//coverity[MISSING_BREAK  :FALSE] 
  3123 				case COMASuplState::ESUPL_POS_INIT:
  3160 				case COMASuplState::ESUPL_POS_INIT:
  3124 				{
  3161 				{
  3125 					cancelSendRequestor = EFalse;
  3162 					cancelSendRequestor = EFalse;
  3126 					iSuplSessionState = ESUPL_GENERATE;
  3163 					iSuplSessionState = ESUPL_GENERATE;
  3127 					iSuplMsgType = ESUPL_END;
  3164 					iSuplMsgType = ESUPL_END;
  3370 			hslpAdress->Des().Copy(iHSLPAddress);
  3407 			hslpAdress->Des().Copy(iHSLPAddress);
  3371 		}
  3408 		}
  3372 		
  3409 		
  3373 			else if(len ==0)
  3410 			else if(len ==0)
  3374 				{
  3411 				{
  3375 					CServerParams* serverParams = CServerParams::NewL();
  3412         CServerParams* serverParams = CServerParams::NewL();
  3376 					CleanupStack::PushL(serverParams);
  3413         CleanupStack::PushL(serverParams);
  3377 					
  3414         
  3378 						if (iSuplStorageSettings->GetDefaultServer(serverParams) == KErrNotFound )
  3415         if (iSuplStorageSettings->GetDefaultServer(serverParams) == KErrNotFound )
  3379 						{
  3416             {
  3380 						iTrace->Trace(_L("HSLP generated frm IMSI"), KTraceFileName, __LINE__);
  3417             iTrace->Trace(_L("HSLP generated frm IMSI"), KTraceFileName, __LINE__);
  3381 						hslpAdress = HBufC8::NewL(iSuplSettings->SLPAddressfromImsi().Length());
  3418             hslpAdress = HBufC8::NewL(iSuplSettings->SLPAddressfromImsi().Length());
  3382 						CleanupStack::PushL(hslpAdress);
  3419             hslpAdress->Des().Copy(iSuplSettings->SLPAddressfromImsi());
  3383 						hslpAdress->Des().Copy(iSuplSettings->SLPAddressfromImsi());
  3420             }
  3384 						CleanupStack::Pop(hslpAdress);	
  3421         else
  3385 						}
  3422             {
  3386 						else
  3423             iTrace->Trace(_L("Default HSLP"), KTraceFileName, __LINE__);
  3387 						{
  3424             TInt64 slpId;
  3388 							iTrace->Trace(_L("Default HSLP"), KTraceFileName, __LINE__);
  3425             TBool aServerEnabled, aSimChangeRemove, aUsageInHomeNw, aEditable;
  3389 							TInt64 slpId;
  3426             HBufC* serverAddr = HBufC::NewL(KMaxHSLPAddrLen);
  3390 							TBool aServerEnabled, aSimChangeRemove, aUsageInHomeNw, aEditable;
  3427             HBufC* iapName = HBufC::NewL(KMaxIAPLen);
  3391 							HBufC* serverAddr = HBufC::NewL(KMaxHSLPAddrLen);
  3428             CleanupStack::PushL(serverAddr);
  3392 							HBufC* iapName = HBufC::NewL(KMaxIAPLen);
  3429             CleanupStack::PushL(iapName);
  3393 							CleanupStack::PushL(serverAddr);
  3430             serverParams->Get(slpId,serverAddr->Des(),iapName->Des(),aServerEnabled, aSimChangeRemove, aUsageInHomeNw, aEditable);
  3394 							CleanupStack::PushL(iapName);
  3431             hslpAdress = HBufC8::NewL(serverAddr->Length());
  3395 							serverParams->Get(slpId,serverAddr->Des(),iapName->Des(),aServerEnabled, aSimChangeRemove, aUsageInHomeNw, aEditable);
  3432             hslpAdress->Des().Copy(*serverAddr);
  3396 							hslpAdress = HBufC8::NewL(serverAddr->Length());
  3433         
  3397 							hslpAdress->Des().Copy(*serverAddr);
  3434             CleanupStack::PopAndDestroy(iapName);
  3398 						
  3435             CleanupStack::PopAndDestroy(serverAddr);
  3399 							CleanupStack::PopAndDestroy(iapName);
  3436             }
  3400 							CleanupStack::PopAndDestroy(serverAddr);
  3437         CleanupStack::PopAndDestroy(serverParams);	
  3401 							
  3438         }
  3402 						}
  3439 
  3403 					CleanupStack::PopAndDestroy(serverParams);	
  3440     delete iSuplState;
  3404 					
  3441     iSuplState = NULL;
  3405 				}
  3442     CleanupStack::PushL(hslpAdress);
  3406             delete iSuplState;
  3443  		if(setStatusCode)
  3407             iSuplState = NULL;
  3444  			{
  3408             CleanupStack::PushL(hslpAdress);
  3445 	 			iSuplState = COMASuplEndState::NewL(iErrorStatusCode,iOMASuplAsnHandlerBaseImpl,iEncodedSuplInit,hslpAdress);		
  3409             if(setStatusCode)
  3446  			}
  3410                 {
  3447  		else
  3411                 iSuplState = COMASuplEndState::NewL(iErrorStatusCode,iOMASuplAsnHandlerBaseImpl,iEncodedSuplInit,hslpAdress);		
  3448  			{
  3412                 }
  3449  				iSuplState = COMASuplEndState::NewL(iOMASuplAsnHandlerBaseImpl,iEncodedSuplInit,hslpAdress );
  3413             else
  3450  			} 		
  3414                 {
       
  3415                 iSuplState = COMASuplEndState::NewL(iOMASuplAsnHandlerBaseImpl,iEncodedSuplInit,hslpAdress );
       
  3416                 } 		
       
  3417  			
  3451  			
  3418  		CleanupStack::PopAndDestroy(hslpAdress);
  3452  		CleanupStack::PopAndDestroy(hslpAdress);
  3419  		
  3453  		
  3420 		iTrace->Trace(_L("COMASuplSession::HandleSuplInitError Send SUPL_END for SUPL_INIT"), KTraceFileName, __LINE__);
  3454 		iTrace->Trace(_L("COMASuplSession::HandleSuplInitError Send SUPL_END for SUPL_INIT"), KTraceFileName, __LINE__);
  3421 		
  3455 		
  3425 		iSuplMsgType = ESUPL_END;
  3459 		iSuplMsgType = ESUPL_END;
  3426 		SetPOSMsgPluginState(COMASuplPosSessionBase::EOMASuplCreating);	
  3460 		SetPOSMsgPluginState(COMASuplPosSessionBase::EOMASuplCreating);	
  3427 		//SMP Changes
  3461 		//SMP Changes
  3428 		
  3462 		
  3429 		iSuplState->GenerateMessageL();
  3463 		iSuplState->GenerateMessageL();
  3430 		iSuplSessionState = ESUPL_GENERATE;//Has to be here because initialisation has to be done for NI case in reject scenario.
  3464 		iSuplSessionState = ESUPL_GENERATE; // HAs to be here because initialisation has to be complete..
  3431 	
  3465 	
  3432 	}
  3466 	}
  3433 
  3467 
  3434 // -----------------------------------------------------------------------------
  3468 // -----------------------------------------------------------------------------
  3435 // COMASuplSession::HandleInvalidParameterErrorL
  3469 // COMASuplSession::HandleInvalidParameterErrorL
  3865 // COMASuplSession::CheckProtocolVersion
  3899 // COMASuplSession::CheckProtocolVersion
  3866 // Returns true if its matching else false
  3900 // Returns true if its matching else false
  3867 // -----------------------------------------------------------------------------
  3901 // -----------------------------------------------------------------------------
  3868 TBool COMASuplSession::CheckProtocolVersionL(COMASuplAsnMessageBase* aDecodedAsn)
  3902 TBool COMASuplSession::CheckProtocolVersionL(COMASuplAsnMessageBase* aDecodedAsn)
  3869 	{
  3903 	{
  3870     TOMASuplVersion version;
  3904 		TOMASuplVersion version;
  3871     COMASuplSessionID* SessionID = NULL;
  3905 		COMASuplSessionID* SessionID = NULL;
  3872     aDecodedAsn->MessageBase(version,SessionID);
  3906 		aDecodedAsn->MessageBase(version,SessionID);
  3873     
  3907 		
  3874     TInt recMajor,recMinor,recServInd;
  3908 		TInt recMajor,recMinor,recServInd;
  3875     version.SuplVersion(recMajor,recMinor,recServInd);		
  3909 		version.SuplVersion(recMajor,recMinor,recServInd);		
  3876     
  3910 		
  3877     if(recMajor == KSuplMajorVersion )
  3911 		if(recMajor == KSuplMajorVersion )
  3878         {
  3912 			{
  3879         return  ETrue;
  3913 				return  ETrue;
  3880         } 
  3914 			} 
  3881     else
  3915 		else
  3882         {
  3916 			{
  3883         COMASuplAsnMessageBase::TSuplMessageType messageType = aDecodedAsn->MessageType();
  3917 			COMASuplAsnMessageBase::TSuplMessageType messageType = aDecodedAsn->MessageType();
  3884         if(messageType == COMASuplAsnMessageBase::ESUPL_END) 
  3918 			if(messageType == COMASuplAsnMessageBase::ESUPL_END) 
  3885             {
  3919 				{
  3886             iTrace->Trace(_L("Received message is SUPL_END...with wrong Version.Terminating session"), KTraceFileName, __LINE__); 
  3920 					iTrace->Trace(_L("Received message is SUPL_END...with wrong Version.Terminating session"), KTraceFileName, __LINE__); 
  3887             iSessionObserver.TerminateSession(this, KErrCompletion);	
  3921 					iSessionObserver.TerminateSession(this, KErrCompletion);	
  3888             }
  3922 				}
  3889         else
  3923 			else
  3890             {
  3924 				{
  3891             iTrace->Trace(_L("Received message with wrong version."), KTraceFileName, __LINE__); 
  3925 					iTrace->Trace(_L("Received message with wrong version."), KTraceFileName, __LINE__); 
  3892 
  3926 					
  3893             delete iSuplState;
  3927 					if (iSuplState)
  3894             iSuplMsgType = ESUPL_END;
  3928 					{
  3895             iErrorStatusCode = COMASuplEnd::EVersionNotSupported;	
  3929 					delete iSuplState;
  3896             SetPOSMsgPluginState(COMASuplPosSessionBase::EOMASuplCreating);	
  3930 					iSuplState = NULL;
  3897 
  3931 					}
  3898             if(iRequestType == ESUPL_NETWORK )
  3932 					iSuplMsgType = ESUPL_END;
  3899                 {
  3933 					iErrorStatusCode = COMASuplEnd::EVersionNotSupported;	
       
  3934 					SetPOSMsgPluginState(COMASuplPosSessionBase::EOMASuplCreating);	
       
  3935 
       
  3936 					if(iRequestType == ESUPL_NETWORK )
       
  3937 					{
  3900                 if (messageType == COMASuplAsnMessageBase::ESUPL_INIT)    
  3938                 if (messageType == COMASuplAsnMessageBase::ESUPL_INIT)    
  3901                     {                                
  3939                     {                                
  3902                     iSuplSessionState = ESUPL_INITIALIZED;
  3940 						
  3903                     TInt len = iHSLPAddress.Length();
  3941 						iSuplSessionState = ESUPL_INITIALIZED;
  3904                     HBufC8 *hslpAdress = NULL;
  3942 					    TInt len = iHSLPAddress.Length();
  3905                     if(len > 0)
  3943 					    HBufC8 *hslpAdress = NULL;
  3906                         {
  3944 					    if(len > 0)
  3907                         hslpAdress = HBufC8::NewL(iHSLPAddress.Length());
  3945 					    {
  3908                         hslpAdress->Des().Copy(iHSLPAddress);
  3946 					        hslpAdress = HBufC8::NewL(iHSLPAddress.Length());
  3909                         }
  3947 					        hslpAdress->Des().Copy(iHSLPAddress);
  3910                     else if(len ==0)
  3948 					    }
  3911                         {
  3949 				   	else if(len ==0)
       
  3950 					{
  3912                         CServerParams* serverParams = CServerParams::NewL();
  3951                         CServerParams* serverParams = CServerParams::NewL();
  3913                         CleanupStack::PushL(serverParams);
  3952                         CleanupStack::PushL(serverParams);
  3914         
  3953         
  3915                         if (iSuplStorageSettings->GetDefaultServer(serverParams) == KErrNotFound )
  3954                         if (iSuplStorageSettings->GetDefaultServer(serverParams) == KErrNotFound )
  3916                             {
  3955                             {
  3917                             iTrace->Trace(_L("Length of HSLP Address is = 0, passing the HSLP generated frm IMSI"), KTraceFileName, __LINE__);
  3956 							iTrace->Trace(_L("Length of HSLP Address is = 0, passing the HSLP generated frm IMSI"), KTraceFileName, __LINE__);
  3918                             hslpAdress = HBufC8::NewL(iSuplSettings->SLPAddressfromImsi().Length());
  3957 							hslpAdress = HBufC8::NewL(iSuplSettings->SLPAddressfromImsi().Length());
  3919                             hslpAdress->Des().Copy(iSuplSettings->SLPAddressfromImsi());	
  3958 							hslpAdress->Des().Copy(iSuplSettings->SLPAddressfromImsi());	
  3920                             }		
  3959                             }		
  3921                         else
  3960                         else
  3922                             {
  3961                             {
  3923                             iTrace->Trace(_L("Sending End with ver for Default HSLP"), KTraceFileName, __LINE__);
  3962                             iTrace->Trace(_L("Sending End with ver for Default HSLP"), KTraceFileName, __LINE__);
  3924                             TInt64 slpId;
  3963                             TInt64 slpId;
  3931                             hslpAdress = HBufC8::NewL(serverAddr->Length());
  3970                             hslpAdress = HBufC8::NewL(serverAddr->Length());
  3932                             hslpAdress->Des().Copy(*serverAddr);
  3971                             hslpAdress->Des().Copy(*serverAddr);
  3933             
  3972             
  3934                             CleanupStack::PopAndDestroy(iapName);
  3973                             CleanupStack::PopAndDestroy(iapName);
  3935                             CleanupStack::PopAndDestroy(serverAddr);
  3974                             CleanupStack::PopAndDestroy(serverAddr);
  3936                             }
  3975 						    }
  3937                         CleanupStack::PopAndDestroy(serverParams);
  3976                         CleanupStack::PopAndDestroy(serverParams);
  3938                         }
  3977                         }
  3939                     if(iSuplState)
  3978                       
  3940                     	{
  3979                       if(iSuplState)
  3941                     delete iSuplState;
  3980                       {
  3942                     iSuplState = NULL;
  3981 	                    delete iSuplState;
  3943                       }
  3982 	                    iSuplState = NULL;
  3944                     CleanupStack::PushL(hslpAdress);
  3983 	                  	}
  3945                     ServerAddressCheckForSuplInitL();
  3984 						
  3946                     iSuplState = COMASuplEndState::NewL(iErrorStatusCode,iOMASuplAsnHandlerBaseImpl,iEncodedSuplInit,hslpAdress);		
  3985 					    CleanupStack::PushL(hslpAdress);
  3947                     CleanupStack::PopAndDestroy(hslpAdress);
  3986 	                    ServerAddressCheckForSuplInitL();
  3948 
  3987 					    iSuplState = COMASuplEndState::NewL(iErrorStatusCode,iOMASuplAsnHandlerBaseImpl,iEncodedSuplInit,hslpAdress);		
  3949                     // Set the SessionId.
  3988 					    CleanupStack::PopAndDestroy(hslpAdress);
  3950                     iTrace->Trace(_L("COMASuplSession::CheckProtocolVersionL Update SLP Session ID"), KTraceFileName, __LINE__);
  3989 
  3951                     UpdateSLPSessionIDL(SessionID);
  3990 			            // Set the SessionId.
  3952 
  3991 				        iTrace->Trace(_L("COMASuplSession::CheckProtocolVersionL Update SLP Session ID"), KTraceFileName, __LINE__);
  3953                     iTrace->Trace(_L("COMASuplSession::CheckProtocolVersionL Update SET Session ID"), KTraceFileName, __LINE__);
  3992 			            UpdateSLPSessionIDL(SessionID);
  3954                     UpdateSETSessionIDL(SessionID);
  3993 
  3955                     iSuplState->SetMsgStateObserver(this);
  3994 				        iTrace->Trace(_L("COMASuplSession::CheckProtocolVersionL Update SET Session ID"), KTraceFileName, __LINE__);
  3956                     iSuplState->GenerateMessageL();
  3995 			            UpdateSETSessionIDL(SessionID);
  3957                     iSuplSessionState = ESUPL_GENERATE;
  3996 						iSuplState->SetMsgStateObserver(this);
       
  3997 						iSuplState->GenerateMessageL();
       
  3998 						iSuplSessionState = ESUPL_GENERATE;
  3958                     }
  3999                     }
  3959                 else
  4000                 else
  3960                     {                                
  4001                     {                                
  3961                     iSuplState = COMASuplEndState::NewL(iErrorStatusCode,iOMASuplAsnHandlerBaseImpl);		
  4002                     iSuplState = COMASuplEndState::NewL(iErrorStatusCode,iOMASuplAsnHandlerBaseImpl);		
  3962                     UpdateSLPSessionIDL(SessionID);
  4003                     UpdateSLPSessionIDL(SessionID);
  3964                     iSuplState->SetMsgStateObserver(this);
  4005                     iSuplState->SetMsgStateObserver(this);
  3965                     iRequestType = ESUPL_INVALID_SESSION;
  4006                     iRequestType = ESUPL_INVALID_SESSION;
  3966                     iSuplSessionState = ESUPL_GENERATE;
  4007                     iSuplSessionState = ESUPL_GENERATE;
  3967                     iSuplState->GenerateMessageL();
  4008                     iSuplState->GenerateMessageL();
  3968                     }
  4009                     }
  3969                 } 
  4010 
  3970             else 							
  4011 					} 
  3971                 {
  4012 					else 							
  3972                 iSuplState = COMASuplEndState::NewL(iErrorStatusCode,iOMASuplAsnHandlerBaseImpl);
  4013 					{
  3973                 iSuplSessionState = ESUPL_ENCODE;
  4014 					    iSuplState = COMASuplEndState::NewL(iErrorStatusCode,iOMASuplAsnHandlerBaseImpl);
  3974                 iSuplState->SetMsgStateObserver(this);
  4015 						iSuplSessionState = ESUPL_ENCODE;
  3975                 iSuplState->GenerateMessageL();
  4016 						iSuplState->SetMsgStateObserver(this);
  3976                 }
  4017 						iSuplState->GenerateMessageL();
  3977             }	
  4018 					}
  3978         return EFalse;
  4019 				}	
  3979         }	
  4020 				
       
  4021 			return EFalse;
       
  4022 			}	
       
  4023 
  3980 	}
  4024 	}
  3981 
  4025 
  3982 // -----------------------------------------------------------------------------
  4026 // -----------------------------------------------------------------------------
  3983 // COMASuplSession::GetRemainingPosPayloadL
  4027 // COMASuplSession::GetRemainingPosPayloadL
  3984 // Returns remaining pos payload
  4028 // Returns remaining pos payload
  4133 
  4177 
  4134 // -----------------------------------------------------------------------------
  4178 // -----------------------------------------------------------------------------
  4135 // COMASuplSession::SettingsUsageUICompletedL
  4179 // COMASuplSession::SettingsUsageUICompletedL
  4136 // 
  4180 // 
  4137 // -----------------------------------------------------------------------------
  4181 // -----------------------------------------------------------------------------
  4138 void COMASuplSession::SettingsUsageUICompletedL(TInt aError)
  4182 /*void COMASuplSession::SettingsUsageUICompletedL(TInt aError)
  4139 	{
  4183 	{
  4140 	iUIFlag = EFalse;
  4184 	iUIFlag = EFalse;
  4141     TBuf<64> msg;	
  4185     TBuf<64> msg;	
  4142     msg.Copy(_L("SUPL Usage UI completed with ... "));
  4186     msg.Copy(_L("SUPL Usage UI completed with ... "));
  4143     msg.AppendNum(aError);
  4187     msg.AppendNum(aError);
  4144     iTrace->Trace(msg,KTraceFileName, __LINE__); 
  4188     iTrace->Trace(msg,KTraceFileName, __LINE__); 
  4145 
  4189 
  4146     iPrevUsageResult = aError;                    
  4190     iPrevUsageResult = aError;                    
  4147     iIhaveLaunchedUsagedialog = EFalse;                 
       
  4148 
  4191 
  4149 
  4192 
  4150     if (aError == KErrNone)
  4193     if (aError == KErrNone)
  4151         {
  4194         {
  4152         iProtocolManager.UpdateAllSubSessnsInSameSession(iIpcSessionId);                
  4195         iProtocolManager.UpdateAllSubSessnsInSameSession(iIpcSessionId);                
  4179 			msg.AppendNum(aError);
  4222 			msg.AppendNum(aError);
  4180 			iTrace->Trace(msg,KTraceFileName, __LINE__); 
  4223 			iTrace->Trace(msg,KTraceFileName, __LINE__); 
  4181 			iSessionObserver.TerminateSession(this, KErrGeneral);	
  4224 			iSessionObserver.TerminateSession(this, KErrGeneral);	
  4182 			return;
  4225 			return;
  4183 		}
  4226 		}
  4184 	}
  4227 	}*/
  4185 
  4228 
  4186 // -----------------------------------------------------------------------------
  4229 // -----------------------------------------------------------------------------
  4187 // COMASuplSession::CheckForSuplUsageL
  4230 // COMASuplSession::CheckForSuplUsageL
  4188 // 
  4231 // 
  4189 // -----------------------------------------------------------------------------
  4232 // -----------------------------------------------------------------------------
  4190 void COMASuplSession::CheckForSuplUsageL()
  4233 void COMASuplSession::CheckForSuplUsageL()
  4191     {
  4234     {
  4192 
  4235 
  4193     if (iSuplUsage >= 1)
  4236     /*if (iSuplUsage >= 1)
  4194         {            
  4237         {            
  4195         CSuplSettings::TSuplSettingsUsage usage = iSuplSettings->SUPLUsage();
  4238         CSuplSettings::TSuplSettingsUsage usage = iSuplSettings->SUPLUsage();
  4196         if (usage == CSuplSettings::ESuplUsageDisabled)
  4239         if (usage == CSuplSettings::ESuplUsageDisabled)
  4197             {            
  4240             {            
  4198 	        iSessionObserver.TerminateSession(this, KErrGeneral);	
  4241 	        iSessionObserver.TerminateSession(this, KErrGeneral);	
  4199             }
  4242             }
  4200         else if (usage == CSuplSettings::ESuplUsageAutomatic)
  4243         else if (usage == CSuplSettings::ESuplUsageAutomatic)
  4201             {            
  4244             { */           
  4202             if (iNwInitError)
  4245             if (iNwInitError)
  4203                 {
  4246                 {
  4204                 iNwInitError = EFalse;                    
  4247                 iNwInitError = EFalse;                    
  4205                 HandleSuplInitErrorL(iNwInitCompletionCode);                             
  4248                 HandleSuplInitErrorL(iNwInitCompletionCode);                             
  4206                 }                
  4249                 }                
  4207             else
  4250             else
  4208 	            InitializeL(iRequestID); 
  4251             	{
  4209             }
  4252             		if (iRoaming)                
       
  4253                     HandleRoamingCheckCompleteL(KErrNone, EFalse);                    
       
  4254                 else
       
  4255                     {                        
       
  4256                     iEtelRoamingCheck = ETrue;
       
  4257                     iProtocolManager.CheckForRoaming();
       
  4258                     }
       
  4259 	            //InitializeL(iRequestID); 
       
  4260 	          	}
       
  4261             /*}
  4210 
  4262 
  4211             else if (usage == CSuplSettings::ESuplUsageHomeAutomatic || usage == CSuplSettings::ESuplUsageAlwaysAsk)
  4263             else if (usage == CSuplSettings::ESuplUsageHomeAutomatic || usage == CSuplSettings::ESuplUsageAlwaysAsk)
  4212             {
  4264             {
  4213                 if (iRoaming)                
  4265                 if (iRoaming)                
  4214                     HandleRoamingCheckCompleteL(KErrNone, EFalse);                    
  4266                     HandleRoamingCheckCompleteL(KErrNone, EFalse);                    
  4218                     iProtocolManager.CheckForRoaming();
  4270                     iProtocolManager.CheckForRoaming();
  4219                     }
  4271                     }
  4220             }            
  4272             }            
  4221         }            
  4273         }            
  4222         else
  4274         else
  4223 	        InitializeL(iRequestID); 
  4275 	        InitializeL(iRequestID); */
  4224 
  4276 
  4225     }        
  4277     }        
  4226 
  4278 
  4227 // -----------------------------------------------------------------------------
  4279 // -----------------------------------------------------------------------------
  4228 // COMASuplSession::CheckForTimerExpiry
  4280 // COMASuplSession::CheckForTimerExpiry
  4301     iEtelRoamingCheck = EFalse;            
  4353     iEtelRoamingCheck = EFalse;            
  4302     if (aErrorCode == KErrNone)            
  4354     if (aErrorCode == KErrNone)            
  4303         {            
  4355         {            
  4304             iUsageHomeNW = aHomeNw;   
  4356             iUsageHomeNW = aHomeNw;   
  4305             iConnRequestor->UpdateSLPListForHomeUsage(iUsageHomeNW);             
  4357             iConnRequestor->UpdateSLPListForHomeUsage(iUsageHomeNW);             
  4306             CSuplSettings::TSuplSettingsUsage usage = iSuplSettings->SUPLUsage();
       
  4307             
       
  4308             if (usage == CSuplSettings::ESuplUsageAlwaysAsk || iStaleLocIdPrompt)
       
  4309                 {
       
  4310                 TInt err;                
       
  4311                 if (!iSuplSettings->IsUIActive() )
       
  4312                     {                        
       
  4313                     if (!aHomeNw)
       
  4314                         {                            
       
  4315                         iTrace->Trace(_L("Invoking LaunchSuplUsageSettingsUI, user is roaming"), KTraceFileName, __LINE__);
       
  4316                         iIhaveLaunchedUsagedialog = ETrue;                 
       
  4317                         err = iProtocolManager.LaunchSuplUsageSettingsUI(this, ETrue);        
       
  4318                         }
       
  4319                     else
       
  4320                         {                            
       
  4321                         iTrace->Trace(_L("Invoking LaunchSuplUsageSettingsUI, user is not roaming"), KTraceFileName, __LINE__);
       
  4322                         iIhaveLaunchedUsagedialog = ETrue;                 
       
  4323                         err = iProtocolManager.LaunchSuplUsageSettingsUI(this, EFalse);        
       
  4324                         }
       
  4325                     }
       
  4326                 else
       
  4327                     err = KErrInUse;                        
       
  4328 
       
  4329                 if(KErrNone != err && KErrInUse == err)
       
  4330                     {
       
  4331                         iTrace->Trace(_L("Dialog in use, setting flag"), KTraceFileName, __LINE__);
       
  4332                         SetSuplUsageFlag();                            
       
  4333                     }
       
  4334                 if( KErrNone == err  && iRequestType == ESUPL_NETWORK )
       
  4335                     {
       
  4336                     iTrace->Trace(_L("Network Session , starting timer"), KTraceFileName, __LINE__);
       
  4337                     COMASuplInit* suplInit = static_cast <COMASuplInit*> (iDecodedAsnMessage);
       
  4338                     TOMASuplQop qop;
       
  4339                     TInt retVal = suplInit->Qop(qop);
       
  4340                     TInt delay;
       
  4341                     qop.Delay(delay);
       
  4342                     //if delay is > 7, it is not valid
       
  4343                     if (delay > 7)
       
  4344                         delay = 0;                                
       
  4345                     if(retVal == KErrNone && delay > 0)
       
  4346                         {
       
  4347                         TReal delayReal;
       
  4348                         Math::Pow(delayReal, 2, (TReal)delay);
       
  4349                         delay = (TInt) delayReal;
       
  4350                         TBuf<128> msg(_L("Delay present in message, value is = "));
       
  4351                         msg.AppendNum(delay);
       
  4352                         iTrace->Trace(msg, KTraceFileName, __LINE__); 
       
  4353                         isTimeoutDialogTimerStarted = ETrue;
       
  4354                         iDialogTimer->StartTimer(delay);
       
  4355                         }  	
       
  4356                     else
       
  4357                         {
       
  4358                         if (iSuplInitTimeOut > 0)
       
  4359                             {                                                        
       
  4360                             TBuf<256> msg(_L("Delay value in CR is"));
       
  4361                             msg.AppendNum(iSuplInitTimeOut);
       
  4362                             iTrace->Trace(msg, KTraceFileName, __LINE__); 
       
  4363                             iDialogTimer->StartTimer(iSuplInitTimeOut * KSecond);
       
  4364                             isTimeoutDialogTimerStarted = ETrue;
       
  4365                             }
       
  4366                         else
       
  4367                             iTrace->Trace(_L("Timeout is <= 0"), KTraceFileName, __LINE__);
       
  4368                         }
       
  4369                     iDlgStartTime.HomeTime();
       
  4370                     }
       
  4371                 else if (KErrNone != err)
       
  4372                     {
       
  4373                     iTrace->Trace(_L("Invoking HandleSuplErrorL"), KTraceFileName, __LINE__);
       
  4374                     HandleSuplErrorL(err);
       
  4375                     }
       
  4376 
       
  4377                 }
       
  4378             else if (usage == CSuplSettings::ESuplUsageHomeAutomatic) 
       
  4379             {                
       
  4380             if (!aHomeNw)
       
  4381                 {                
       
  4382                 TInt err;                
       
  4383                 //if (!iSuplSettings->IsUIActive() )
       
  4384                     {
       
  4385                     iTrace->Trace(_L("Invoking LaunchSuplUsageSettingsUI, user is roaming"), KTraceFileName, __LINE__);
       
  4386                     err = iProtocolManager.LaunchSuplUsageSettingsUI(this, ETrue);        
       
  4387 
  4358 
  4388                     if(iSuplMsgType == ESUPL_INIT)
  4359                     if(iSuplMsgType == ESUPL_INIT)
  4389                         {
  4360                         {
  4390                         iTrace->Trace(_L("Dialog timer started"), KTraceFileName, __LINE__);
  4361                         iTrace->Trace(_L("Dialog timer started"), KTraceFileName, __LINE__);
  4391 				     
       
  4392                         COMASuplInit* suplInit = static_cast <COMASuplInit*> (iDecodedAsnMessage);
  4362                         COMASuplInit* suplInit = static_cast <COMASuplInit*> (iDecodedAsnMessage);
  4393                         TOMASuplQop qop;
  4363                         TOMASuplQop qop;
  4394                         TInt retVal = suplInit->Qop(qop);
  4364                         TInt retVal = suplInit->Qop(qop);
  4395                         TInt delay;
  4365                         TInt delay;
  4396                         qop.Delay(delay);
  4366                         qop.Delay(delay);
  4417                                 }
  4387                                 }
  4418                             else
  4388                             else
  4419                                 iTrace->Trace(_L("Timeout is <= 0"), KTraceFileName, __LINE__);
  4389                                 iTrace->Trace(_L("Timeout is <= 0"), KTraceFileName, __LINE__);
  4420                             }
  4390                             }
  4421                         }
  4391                         }
  4422                     }
  4392                                 
  4423 
       
  4424                 if(!iSuplSettings->IsUIActive() && KErrNone != err)
       
  4425                     {
       
  4426                         SetSuplUsageFlag();                            
       
  4427                     }
       
  4428                 else
       
  4429                     {
       
  4430                     iTrace->Trace(_L("Invoking HandleSuplErrorL"), KTraceFileName, __LINE__);
       
  4431                     HandleSuplErrorL(err);
       
  4432                     }
       
  4433                 }
       
  4434             else            
       
  4435                 {                
       
  4436                 if (iNwInitError)
  4393                 if (iNwInitError)
  4437                     {
  4394                     {
  4438                     iNwInitError = EFalse;                    
  4395                     iNwInitError = EFalse;                    
  4439                     HandleSuplInitErrorL(iNwInitCompletionCode);                             
  4396                     HandleSuplInitErrorL(iNwInitCompletionCode);                             
  4440                     }                
  4397                     }                
  4441                 else
  4398                 else
  4442 	                InitializeL(iRequestID); 
  4399                 {
  4443                 }                
  4400                 	iTrace->Trace(_L("COMASuplSession::InitializeL called after roaming check"), KTraceFileName, __LINE__);
  4444             }                
  4401 	                InitializeL(iRequestID);  
       
  4402 	              }  
  4445         }
  4403         }
  4446         else
  4404    else
  4447             {
  4405         {
  4448 	        iSessionObserver.TerminateSession(this, KErrGeneral);	
  4406       	iSessionObserver.TerminateSession(this, KErrGeneral);	
  4449             }                
  4407         }                
  4450     }            
  4408     }            
  4451 TInt COMASuplSession::SuplIpcSessionID() 
  4409 TInt COMASuplSession::SuplIpcSessionID() 
  4452     {
  4410     {
  4453     return iIpcSessionId;
  4411     return iIpcSessionId;
  4454     }    
  4412     }    
  4509 TBool COMASuplSession::GetSuplUsageFlag()
  4467 TBool COMASuplSession::GetSuplUsageFlag()
  4510     {
  4468     {
  4511     return iUsageDialog;
  4469     return iUsageDialog;
  4512     }        
  4470     }        
  4513 
  4471 
  4514 void COMASuplSession::StartUsageDialogLaunchL()
  4472 /*void COMASuplSession::StartUsageDialogLaunchL()
  4515     {
  4473     {
  4516     iTrace->Trace(_L("COMASuplSession::StartUsageDialogLaunchL"), KTraceFileName, __LINE__);
  4474     iTrace->Trace(_L("COMASuplSession::StartUsageDialogLaunchL"), KTraceFileName, __LINE__);
  4517     ReSetSuplUsageFlag();            
  4475     ReSetSuplUsageFlag();            
  4518     iTrace->Trace(_L("COMASuplSession::StartUsageDialogLaunchL, flag reset done"), KTraceFileName, __LINE__);
  4476     iTrace->Trace(_L("COMASuplSession::StartUsageDialogLaunchL, flag reset done"), KTraceFileName, __LINE__);
  4519 
  4477 
  4675                 }                
  4633                 }                
  4676             else
  4634             else
  4677 	            InitializeL(iRequestID); 
  4635 	            InitializeL(iRequestID); 
  4678             }                
  4636             }                
  4679         }                
  4637         }                
  4680     }
  4638     }*/
  4681 
  4639 
  4682 TBool COMASuplSession::IsEtelNotifySet()
  4640 TBool COMASuplSession::IsEtelNotifySet()
  4683     {
  4641     {
  4684     iTrace->Trace(_L("COMASuplSession::IsEtelNotifySet"), KTraceFileName, __LINE__); 
  4642     iTrace->Trace(_L("COMASuplSession::IsEtelNotifySet"), KTraceFileName, __LINE__); 
  4685     return iEtelNotify;            
  4643     return iEtelNotify;            
  4688 TBool COMASuplSession::IsEtelRoamingSet()
  4646 TBool COMASuplSession::IsEtelRoamingSet()
  4689     {
  4647     {
  4690     iTrace->Trace(_L("COMASuplSession::IsEtelRoamingSet"), KTraceFileName, __LINE__); 
  4648     iTrace->Trace(_L("COMASuplSession::IsEtelRoamingSet"), KTraceFileName, __LINE__); 
  4691     return iEtelRoamingCheck;
  4649     return iEtelRoamingCheck;
  4692     }        
  4650     }        
  4693 	
       
  4694 TBool COMASuplSession::HasMeLaunchedUsageDialog()
       
  4695 {
       
  4696 	return iIhaveLaunchedUsagedialog; 
       
  4697 }
       
  4698 
       
  4699 
  4651 
  4700 // -----------------------------------------------------------------------------
  4652 // -----------------------------------------------------------------------------
  4701 // COMASuplSession::DialogTimerExpiredL
  4653 // COMASuplSession::DialogTimerExpiredL
  4702 // Checks whether UI is displayed or not previously
  4654 // Checks whether UI is displayed or not previously
  4703 // 
  4655 // 
  4704 // -----------------------------------------------------------------------------
  4656 // -----------------------------------------------------------------------------
  4705 void COMASuplSession::DialogTimerExpiredL()
  4657 void COMASuplSession::DialogTimerExpiredL()
  4706 {
  4658 {
  4707    iTrace->Trace(_L("Timer Expired for SUPL Dialog"), KTraceFileName, __LINE__); 
  4659    iTrace->Trace(_L("Timer Expired for SUPL Dialog"), KTraceFileName, __LINE__); 
  4708   
  4660   
  4709     if (!iIapDialogShown)
  4661     //if (!iIapDialogShown)
  4710 	    iProtocolManager.LaunchSuplDialogTimeoutUI(this);
  4662 	   // iProtocolManager.LaunchSuplDialogTimeoutUI(this);
  4711     else
  4663    // else
  4712         iIapDlgTimerExpired = ETrue;            
  4664        // iIapDlgTimerExpired = ETrue;            
  4713 
  4665 
  4714     return;	
  4666     return;	
  4715 }
  4667 }
  4716 
  4668 
  4717 // -----------------------------------------------------------------------------
  4669 // -----------------------------------------------------------------------------
  4718 // COMASuplSession::SettingsTimeOutUICompletedL
  4670 // COMASuplSession::SettingsTimeOutUICompletedL
  4719 // 
  4671 // 
  4720 // -----------------------------------------------------------------------------
  4672 // -----------------------------------------------------------------------------
  4721 void COMASuplSession::SettingsTimeOutUICompletedL(TInt aError)
  4673 void COMASuplSession::SettingsTimeOutUICompletedL(TInt /*aError*/)
  4722 	{
  4674 	{
  4723 	
  4675 	
  4724 	    TBuf<64> msg;	
  4676 	  //  TBuf<64> msg;	
  4725 	    msg.Copy(_L("SUPL Timeout UI completed with ... "));
  4677 	  //  msg.Copy(_L("SUPL Timeout UI completed with ... "));
  4726 	    msg.AppendNum(aError);
  4678 	  //  msg.AppendNum(aError);
  4727 	    iTrace->Trace(msg,KTraceFileName, __LINE__); 
  4679 	  //  iTrace->Trace(msg,KTraceFileName, __LINE__); 
  4728 	    iSessionObserver.TerminateSession(this, KErrGeneral);	
  4680 	  //  iSessionObserver.TerminateSession(this, KErrGeneral);	
  4729 	    return;
  4681 	    return;
  4730 	    
  4682 	    
  4731 	}
  4683 	}
  4732 	
  4684 	
  4733 // -----------------------------------------------------------------------------
  4685 // -----------------------------------------------------------------------------