supl/locationomasuplprotocolhandler/protocolhandlerver1/src/epos_comasuplsession.cpp
branchRCL_3
changeset 16 6fcbaa43369c
parent 12 f3bd2a0973b9
child 24 9c303455e256
equal deleted inserted replaced
13:19bff11d6c18 16:6fcbaa43369c
    81 #include "epos_comasupldialogtimer.h"
    81 #include "epos_comasupldialogtimer.h"
    82 #include "epos_tomasuplposmethod.h"
    82 #include "epos_tomasuplposmethod.h"
    83 #include "epos_omasuplconfigurationkeys.h"
    83 #include "epos_omasuplconfigurationkeys.h"
    84 #include "epos_csuplsettingparams.h"
    84 #include "epos_csuplsettingparams.h"
    85 #include "epos_comasuplasnbase.h"
    85 #include "epos_comasuplasnbase.h"
       
    86 #include "epos_csuplsettingsconstants.h"
    86 
    87 
    87 
    88 
    88 _LIT(KTraceFileName,"SUPL_OMA_SESSION::EPos_COMASuplSession.cpp");
    89 _LIT(KTraceFileName,"SUPL_OMA_SESSION::EPos_COMASuplSession.cpp");
    89 
    90 
    90 //Multiplying factor for conversion of ellipsoid to circle
    91 //Multiplying factor for conversion of ellipsoid to circle
  1510 			
  1511 			
  1511 			TPosition posInfo;
  1512 			TPosition posInfo;
  1512 			TOMASuplUtcTime UtcTime;
  1513 			TOMASuplUtcTime UtcTime;
  1513 			TOMASuplPositionEstimate PosEstimate;
  1514 			TOMASuplPositionEstimate PosEstimate;
  1514 			TDateTime TimeStamp;
  1515 			TDateTime TimeStamp;
  1515 			TInt ZoneCode,Zone,altitude,AltitudeUncertainty, HorizontalAccuracy;
  1516 			TInt ZoneCode,Zone,altitude, HorizontalAccuracy;
       
  1517 			TInt AltitudeUncertainty = 0;
  1516 			TOMASuplAltitudeInfo AltitudeInfo;
  1518 			TOMASuplAltitudeInfo AltitudeInfo;
  1517 			TInt latitude,longitude;
  1519 			TInt latitude,longitude;
  1518 			TOMASuplPositionEstimate::TOMASuplLatitudeSign LatSign;
  1520 			TOMASuplPositionEstimate::TOMASuplLatitudeSign LatSign;
  1519 			TOMASuplAltitudeInfo::TOMASuplAltitudeDirection altitudeDirection;
  1521 			TOMASuplAltitudeInfo::TOMASuplAltitudeDirection altitudeDirection;
  1520             TOMASuplUncertainty Uncertainty;
  1522             TOMASuplUncertainty Uncertainty;
  1694 						
  1696 						
  1695 			TPosition posInfo;
  1697 			TPosition posInfo;
  1696 			TOMASuplUtcTime UtcTime;
  1698 			TOMASuplUtcTime UtcTime;
  1697 			TOMASuplPositionEstimate PosEstimate;
  1699 			TOMASuplPositionEstimate PosEstimate;
  1698 			TDateTime TimeStamp;
  1700 			TDateTime TimeStamp;
  1699 			TInt ZoneCode,Zone,altitude,AltitudeUncertainty, HorizontalAccuracy;
  1701 			TInt ZoneCode,Zone,altitude, HorizontalAccuracy;
       
  1702 			TInt AltitudeUncertainty = 0;
  1700 			TOMASuplAltitudeInfo AltitudeInfo;
  1703 			TOMASuplAltitudeInfo AltitudeInfo;
  1701 			TInt latitude,longitude;
  1704 			TInt latitude,longitude;
  1702 			TOMASuplPositionEstimate::TOMASuplLatitudeSign LatSign;
  1705 			TOMASuplPositionEstimate::TOMASuplLatitudeSign LatSign;
  1703 			TOMASuplAltitudeInfo::TOMASuplAltitudeDirection AltitudeDirection;
  1706 			TOMASuplAltitudeInfo::TOMASuplAltitudeDirection AltitudeDirection;
  1704             TOMASuplUncertainty Uncertainty;
  1707             TOMASuplUncertainty Uncertainty;
  1945 // (other items were commented in a header).
  1948 // (other items were commented in a header).
  1946 // -----------------------------------------------------------------------------
  1949 // -----------------------------------------------------------------------------
  1947 //
  1950 //
  1948 void COMASuplSession::HandleOMASuplMessageL(COMASuplAsnMessageBase* aDecodedAsnMessage,TRequestStatus& aStatus,TInt aSessionIdSeed,TInt aErrorCode)
  1951 void COMASuplSession::HandleOMASuplMessageL(COMASuplAsnMessageBase* aDecodedAsnMessage,TRequestStatus& aStatus,TInt aSessionIdSeed,TInt aErrorCode)
  1949 	{
  1952 	{
  1950 		delete iSuplState;
  1953 	delete iSuplState;
  1951 		iSuplState = NULL;
  1954 	iSuplState = NULL;
  1952 		
  1955 		
  1953 		iSETSessionUniqueId = aSessionIdSeed;
  1956 	iSETSessionUniqueId = aSessionIdSeed;
  1954 		iRunRequestStatus = & aStatus;
  1957 	iRunRequestStatus = & aStatus;
  1955 	    *iRunRequestStatus = KRequestPending;
  1958 	*iRunRequestStatus = KRequestPending;
  1956 	    
  1959 	    
  1957 		TInt networkMode = 1;
  1960 	TInt networkMode = 1;
  1958 		networkMode = GetNetworkModeL();
  1961 	networkMode = GetNetworkModeL();
  1959 		
  1962 		
  1960 		TBuf<64> msg;
  1963 	TBuf<64> msg;
  1961 		if ( networkMode == ECoreAppUIsNetworkConnectionNotAllowed )
  1964 	if ( networkMode == ECoreAppUIsNetworkConnectionNotAllowed )
  1962 			{
  1965 		{
  1963 				msg.Copy(_L("The device is in OFFLINE mode."));
  1966 		msg.Copy(_L("The device is in OFFLINE mode."));
  1964 				iTrace->Trace(msg,KTraceFileName, __LINE__); 
  1967 		iTrace->Trace(msg,KTraceFileName, __LINE__); 
  1965 				iSessionObserver.TerminateSession(this, KErrGeneral);
  1968 		iSessionObserver.TerminateSession(this, KErrGeneral);
  1966 				return;
  1969 		return;
  1967 			}
  1970 		}
  1968 		else
  1971 	else
  1969 			{
  1972 		{
  1970 				msg.Copy(_L("The device is in ON LINE mode."));
  1973 		msg.Copy(_L("The device is in ON LINE mode."));
  1971 				iTrace->Trace(msg,KTraceFileName, __LINE__); 
  1974 		iTrace->Trace(msg,KTraceFileName, __LINE__); 
  1972 			}
  1975 		}
  1973 
  1976 
  1974         CSuplSettings::TSuplSettingsUsage usage = iSuplSettings->SUPLUsage();
  1977     CSuplSettings::TSuplSettingsUsage usage = iSuplSettings->SUPLUsage();
  1975 
  1978 
  1976         if (usage == CSuplSettings::ESuplUsageDisabled)
  1979     if (usage == CSuplSettings::ESuplUsageDisabled)
  1977             {                
  1980         {                
  1978 			msg.Copy(_L("SUPL Usage is disabled"));
  1981 		msg.Copy(_L("SUPL Usage is disabled"));
  1979 			iTrace->Trace(msg,KTraceFileName, __LINE__); 
  1982 		iTrace->Trace(msg,KTraceFileName, __LINE__); 
  1980 	        iSessionObserver.TerminateSession(this, KErrGeneral);	
  1983 	    iSessionObserver.TerminateSession(this, KErrGeneral);	
  1981 			return;
  1984 		return;
  1982             }
  1985         }
  1983 	    
  1986 	    
  1984 	    COMASuplAsnMessageBase::TSuplMessageType messageType = aDecodedAsnMessage->MessageType();
  1987 	COMASuplAsnMessageBase::TSuplMessageType messageType = aDecodedAsnMessage->MessageType();
  1985 	    
  1988 	    
  1986 	    if(messageType == COMASuplAsnMessageBase::ESUPL_INIT && aErrorCode == KErrNone)
  1989 	if(messageType == COMASuplAsnMessageBase::ESUPL_INIT && aErrorCode == KErrNone)
       
  1990 		{
       
  1991 	    HandleOMASuplMessageL(aDecodedAsnMessage);
       
  1992 	    }
       
  1993 	else //Other messages than SUPL_INIT.... Send End
       
  1994 	    {
       
  1995 	    CreateCloneMessageL(aDecodedAsnMessage);		
       
  1996 	    UpdateSuplSessionIDL();
       
  1997 
       
  1998 	    if (iRequestType == ESUPL_NETWORK && messageType == COMASuplAsnMessageBase::ESUPL_INIT)
  1987 	    	{
  1999 	    	{
  1988 	    		HandleOMASuplMessageL(aDecodedAsnMessage);
  2000 			ServerAddressCheckForSuplInitL();
  1989 	    	}
  2001 	    	}
  1990 	    else //Other messages than SUPL_INIT.... Send End
  2002  
       
  2003 		iSuplSessionState = ESUPL_INITIALIZED;
       
  2004 		iSuplMsgType = ESUPL_END;
       
  2005 
       
  2006 	    if((aErrorCode == KErrCompletion && messageType == COMASuplAsnMessageBase::ESUPL_INIT) ||
       
  2007 	    	(aErrorCode == KErrOMASuplOutOfRangeParameter && messageType == COMASuplAsnMessageBase::ESUPL_INIT) ||
       
  2008 	    	(aErrorCode == KErrOMASuplMessageLengthMismatch && messageType == COMASuplAsnMessageBase::ESUPL_INIT) ||
       
  2009 			(aErrorCode == KErrOMASuplShortFrame && messageType == COMASuplAsnMessageBase::ESUPL_INIT))	    			
       
  2010 	   		{
       
  2011 	    	iErrorStatusCode = COMASuplEnd::EUnexpectedDataValue;
       
  2012 	    	if(aErrorCode == KErrOMASuplMessageLengthMismatch)
       
  2013 	    		{
       
  2014 	    		iErrorStatusCode = COMASuplEnd::EProtocolError;
       
  2015 	    		}
       
  2016       		if(aErrorCode == KErrOMASuplShortFrame)
       
  2017 	    		{
       
  2018 	    		iErrorStatusCode = COMASuplEnd::EDataMissing;
       
  2019 	    		}
       
  2020 			TInt len = iHSLPAddress.Length();
       
  2021 			HBufC8 *hslpAdress = NULL;
       
  2022 			if(len > 0)
       
  2023 				{
       
  2024 				hslpAdress = HBufC8::NewL(iHSLPAddress.Length());
       
  2025 				hslpAdress->Des().Copy(iHSLPAddress);
       
  2026 				}						
       
  2027 			else if(len ==0)
       
  2028 				{
       
  2029 				CServerParams* serverParams = CServerParams::NewL();
       
  2030 				CleanupStack::PushL(serverParams);
       
  2031 					
       
  2032 				if (iSuplStorageSettings->GetDefaultServer(serverParams) == KErrNotFound )
       
  2033 					{
       
  2034 					iTrace->Trace(_L("HSLP generated frm IMSI"), KTraceFileName, __LINE__);
       
  2035 					hslpAdress = HBufC8::NewL(iSuplSettings->SLPAddressfromImsi().Length());
       
  2036 					hslpAdress->Des().Copy(iSuplSettings->SLPAddressfromImsi());
       
  2037 					}		
       
  2038 				else
       
  2039 					{
       
  2040 					iTrace->Trace(_L("Sending End with ver for Default HSLP"), KTraceFileName, __LINE__);
       
  2041 					TInt64 slpId;
       
  2042             		TBool aServerEnabled, aSimChangeRemove, aUsageInHomeNw, aEditable;
       
  2043 					HBufC* serverAddr = HBufC::NewL(KMaxHSLPAddrLen);
       
  2044 					HBufC* iapName = HBufC::NewL(KMaxIAPLen);
       
  2045 					CleanupStack::PushL(serverAddr);
       
  2046 					CleanupStack::PushL(iapName);
       
  2047 					serverParams->Get(slpId,serverAddr->Des(),iapName->Des(),aServerEnabled, aSimChangeRemove, aUsageInHomeNw, aEditable);
       
  2048 					hslpAdress = HBufC8::NewL(serverAddr->Length());
       
  2049 					hslpAdress->Des().Copy(*serverAddr);
       
  2050 						
       
  2051 					CleanupStack::PopAndDestroy(iapName);
       
  2052 					CleanupStack::PopAndDestroy(serverAddr);
       
  2053 							
       
  2054 					}
       
  2055 				CleanupStack::PopAndDestroy(serverParams);
       
  2056 				}
       
  2057 			delete iSuplState;
       
  2058 			iSuplState = NULL;
       
  2059 			CleanupStack::PushL(hslpAdress);
       
  2060 			iSuplState = COMASuplEndState::NewL(iErrorStatusCode,iOMASuplAsnHandlerBaseImpl,iEncodedSuplInit,hslpAdress);
       
  2061 			CleanupStack::PopAndDestroy(hslpAdress);
       
  2062 	    	}
       
  2063 	    else
  1991 	    	{
  2064 	    	{
  1992 	    		CreateCloneMessageL(aDecodedAsnMessage);		
  2065 	    		iErrorStatusCode = COMASuplEnd::EUnexpectedMessage;
  1993 	    		UpdateSuplSessionIDL();
  2066 	    		iSuplState = COMASuplEndState::NewL(iErrorStatusCode,iOMASuplAsnHandlerBaseImpl);
  1994  
  2067 	    	}	
  1995 				iSuplSessionState = ESUPL_INITIALIZED;
       
  1996 				iSuplMsgType = ESUPL_END;
       
  1997 
       
  1998 	    		if((aErrorCode == KErrCompletion && messageType == COMASuplAsnMessageBase::ESUPL_INIT) ||
       
  1999 	    			(aErrorCode == KErrOMASuplOutOfRangeParameter && messageType == COMASuplAsnMessageBase::ESUPL_INIT) ||
       
  2000 	    			(aErrorCode == KErrOMASuplMessageLengthMismatch && messageType == COMASuplAsnMessageBase::ESUPL_INIT) ||
       
  2001 						(aErrorCode == KErrOMASuplShortFrame && messageType == COMASuplAsnMessageBase::ESUPL_INIT))	    			
       
  2002 	    			{
       
  2003 	    				iErrorStatusCode = COMASuplEnd::EUnexpectedDataValue;
       
  2004 	    				if(aErrorCode == KErrOMASuplMessageLengthMismatch)
       
  2005 	    					{
       
  2006 	    						iErrorStatusCode = COMASuplEnd::EProtocolError;
       
  2007 	    					}
       
  2008       				if(aErrorCode == KErrOMASuplShortFrame)
       
  2009 	    					{
       
  2010 	    						iErrorStatusCode = COMASuplEnd::EDataMissing;
       
  2011 	    					}
       
  2012 						TInt len = iHSLPAddress.Length();
       
  2013 						HBufC8 *hslpAdress = NULL;
       
  2014 						if(len > 0)
       
  2015 						{
       
  2016 							hslpAdress = HBufC8::NewL(iHSLPAddress.Length());
       
  2017 							hslpAdress->Des().Copy(iHSLPAddress);
       
  2018 						}
       
  2019 						
       
  2020 						else if(len ==0)
       
  2021 						{
       
  2022 						iTrace->Trace(_L("Length of HSLP Address is = 0, passing the HSLP generated frm IMSI"), KTraceFileName, __LINE__);
       
  2023 						hslpAdress = HBufC8::NewL(iSuplSettings->SLPAddressfromImsi().Length());
       
  2024 						CleanupStack::PushL(hslpAdress);
       
  2025 						hslpAdress->Des().Copy(iSuplSettings->SLPAddressfromImsi());	
       
  2026 						CleanupStack::Pop(hslpAdress);						
       
  2027 						}
       
  2028 						CleanupStack::PushL(hslpAdress);
       
  2029 						iSuplState = COMASuplEndState::NewL(iErrorStatusCode,iOMASuplAsnHandlerBaseImpl,iEncodedSuplInit,hslpAdress);		
       
  2030 						CleanupStack::PopAndDestroy(hslpAdress);
       
  2031 	    			}
       
  2032 	    		else
       
  2033 	    			{
       
  2034 	    				iErrorStatusCode = COMASuplEnd::EUnexpectedMessage;
       
  2035 	    				iSuplState = COMASuplEndState::NewL(iErrorStatusCode,iOMASuplAsnHandlerBaseImpl);
       
  2036 	    			}	
       
  2037 	    			
  2068 	    			
  2038 	    		SetPOSMsgPluginState(COMASuplPosSessionBase::EOMASuplCreating);	
  2069 	    SetPOSMsgPluginState(COMASuplPosSessionBase::EOMASuplCreating);	
  2039 				iSuplState->SetMsgStateObserver(this);
  2070 		iSuplState->SetMsgStateObserver(this);
  2040 				//SMP Changes
  2071 		//SMP Changes
  2041 				iSuplSessionState = ESUPL_GENERATE;
  2072 		iSuplState->GenerateMessageL(); //Has to be here because initialisation has to be done for NI case in decode failed scenario.
  2042 				iSuplState->GenerateMessageL();
  2073 		iSuplSessionState = ESUPL_GENERATE;				 
  2043 				 
  2074 		}	
  2044 	    	}	
       
  2045 	}
  2075 	}
  2046 
  2076 
  2047 // -----------------------------------------------------------------------------
  2077 // -----------------------------------------------------------------------------
  2048 // COMASuplSession::HandleOMASuplMessage
  2078 // COMASuplSession::HandleOMASuplMessage
  2049 // Handles OMA Supl messages & starts processing according to state of session.
  2079 // Handles OMA Supl messages & starts processing according to state of session.
  2050 // (other items were commented in a header).
  2080 // (other items were commented in a header).
  2051 // -----------------------------------------------------------------------------
  2081 // -----------------------------------------------------------------------------
  2052 //
  2082 //
  2053 void COMASuplSession::HandleOMASuplMessageL(COMASuplAsnMessageBase* aDecodedAsnMessage)
  2083 void COMASuplSession::HandleOMASuplMessageL(COMASuplAsnMessageBase* aDecodedAsnMessage)
  2054 	{
  2084 	{
       
  2085     CreateCloneMessageL(aDecodedAsnMessage);
  2055 		if(CheckProtocolVersionL(aDecodedAsnMessage)) //Checks version with supported version
  2086 		if(CheckProtocolVersionL(aDecodedAsnMessage)) //Checks version with supported version
  2056 		{
  2087 		{
  2057 			COMASuplAsnMessageBase::TSuplMessageType messageType = aDecodedAsnMessage->MessageType();
  2088 			COMASuplAsnMessageBase::TSuplMessageType messageType = aDecodedAsnMessage->MessageType();
  2058 			CreateCloneMessageL(aDecodedAsnMessage);		
  2089 
  2059 			if(messageType != COMASuplAsnMessageBase::ESUPL_POS)
  2090 			if(messageType != COMASuplAsnMessageBase::ESUPL_POS)
  2060 				{
  2091 				{
  2061 					iCompleteSelfRequestor->CompleteSelf(); //This will result in call of RequestCompleted()
  2092 					iCompleteSelfRequestor->CompleteSelf(); //This will result in call of RequestCompleted()
  2062 				}
  2093 				}
  2063 			else
  2094 			else
  3253 			hslpAdress->Des().Copy(iHSLPAddress);
  3284 			hslpAdress->Des().Copy(iHSLPAddress);
  3254 		}
  3285 		}
  3255 		
  3286 		
  3256 			else if(len ==0)
  3287 			else if(len ==0)
  3257 				{
  3288 				{
  3258 					iTrace->Trace(_L("HSLP generated frm IMSI"), KTraceFileName, __LINE__);
  3289 					CServerParams* serverParams = CServerParams::NewL();
  3259 					hslpAdress = HBufC8::NewL(iSuplSettings->SLPAddressfromImsi().Length());
  3290 					CleanupStack::PushL(serverParams);
  3260 					CleanupStack::PushL(hslpAdress);
  3291 					
  3261 					hslpAdress->Des().Copy(iSuplSettings->SLPAddressfromImsi());
  3292 						if (iSuplStorageSettings->GetDefaultServer(serverParams) == KErrNotFound )
  3262 					CleanupStack::Pop(hslpAdress);	
  3293 						{
       
  3294 						iTrace->Trace(_L("HSLP generated frm IMSI"), KTraceFileName, __LINE__);
       
  3295 						hslpAdress = HBufC8::NewL(iSuplSettings->SLPAddressfromImsi().Length());
       
  3296 						CleanupStack::PushL(hslpAdress);
       
  3297 						hslpAdress->Des().Copy(iSuplSettings->SLPAddressfromImsi());
       
  3298 						CleanupStack::Pop(hslpAdress);	
       
  3299 						}
       
  3300 						else
       
  3301 						{
       
  3302 							iTrace->Trace(_L("Default HSLP"), KTraceFileName, __LINE__);
       
  3303 							TInt64 slpId;
       
  3304 							TBool aServerEnabled, aSimChangeRemove, aUsageInHomeNw, aEditable;
       
  3305 							HBufC* serverAddr = HBufC::NewL(KMaxHSLPAddrLen);
       
  3306 							HBufC* iapName = HBufC::NewL(KMaxIAPLen);
       
  3307 							CleanupStack::PushL(serverAddr);
       
  3308 							CleanupStack::PushL(iapName);
       
  3309 							serverParams->Get(slpId,serverAddr->Des(),iapName->Des(),aServerEnabled, aSimChangeRemove, aUsageInHomeNw, aEditable);
       
  3310 							hslpAdress = HBufC8::NewL(serverAddr->Length());
       
  3311 							hslpAdress->Des().Copy(*serverAddr);
       
  3312 						
       
  3313 							CleanupStack::PopAndDestroy(iapName);
       
  3314 							CleanupStack::PopAndDestroy(serverAddr);
       
  3315 							
       
  3316 						}
       
  3317 					CleanupStack::PopAndDestroy(serverParams);	
  3263 					
  3318 					
  3264 				}
  3319 				}
  3265 		CleanupStack::PushL(hslpAdress);
  3320             delete iSuplState;
  3266 		
  3321             iSuplState = NULL;
  3267 		delete iSuplState;
  3322             CleanupStack::PushL(hslpAdress);
  3268 		iSuplState = NULL;
  3323             if(setStatusCode)
  3269 		
  3324                 {
  3270  		if(setStatusCode)
  3325                 iSuplState = COMASuplEndState::NewL(iErrorStatusCode,iOMASuplAsnHandlerBaseImpl,iEncodedSuplInit,hslpAdress);		
  3271  			{
  3326                 }
  3272 	 			iSuplState = COMASuplEndState::NewL(iErrorStatusCode,iOMASuplAsnHandlerBaseImpl,iEncodedSuplInit,hslpAdress);		
  3327             else
  3273  			}
  3328                 {
  3274  		else
  3329                 iSuplState = COMASuplEndState::NewL(iOMASuplAsnHandlerBaseImpl,iEncodedSuplInit,hslpAdress );
  3275  			{
  3330                 } 		
  3276  				iSuplState = COMASuplEndState::NewL(iOMASuplAsnHandlerBaseImpl,iEncodedSuplInit,hslpAdress );
       
  3277  			} 		
       
  3278  			
  3331  			
  3279  		CleanupStack::PopAndDestroy(hslpAdress);
  3332  		CleanupStack::PopAndDestroy(hslpAdress);
  3280  		
  3333  		
  3281 		iTrace->Trace(_L("COMASuplSession::HandleSuplInitError Send SUPL_END for SUPL_INIT"), KTraceFileName, __LINE__);
  3334 		iTrace->Trace(_L("COMASuplSession::HandleSuplInitError Send SUPL_END for SUPL_INIT"), KTraceFileName, __LINE__);
  3282 		
  3335 		
  3726 // COMASuplSession::CheckProtocolVersion
  3779 // COMASuplSession::CheckProtocolVersion
  3727 // Returns true if its matching else false
  3780 // Returns true if its matching else false
  3728 // -----------------------------------------------------------------------------
  3781 // -----------------------------------------------------------------------------
  3729 TBool COMASuplSession::CheckProtocolVersionL(COMASuplAsnMessageBase* aDecodedAsn)
  3782 TBool COMASuplSession::CheckProtocolVersionL(COMASuplAsnMessageBase* aDecodedAsn)
  3730 	{
  3783 	{
  3731 		TOMASuplVersion version;
  3784     TOMASuplVersion version;
  3732 		COMASuplSessionID* SessionID = NULL;
  3785     COMASuplSessionID* SessionID = NULL;
  3733 		aDecodedAsn->MessageBase(version,SessionID);
  3786     aDecodedAsn->MessageBase(version,SessionID);
  3734 		
  3787     
  3735 		TInt recMajor,recMinor,recServInd;
  3788     TInt recMajor,recMinor,recServInd;
  3736 		version.SuplVersion(recMajor,recMinor,recServInd);		
  3789     version.SuplVersion(recMajor,recMinor,recServInd);		
  3737 		
  3790     
  3738 		if(recMajor == KSuplMajorVersion )
  3791     if(recMajor == KSuplMajorVersion )
  3739 			{
  3792         {
  3740 				return  ETrue;
  3793         return  ETrue;
  3741 			} 
  3794         } 
  3742 		else
  3795     else
  3743 			{
  3796         {
  3744 			COMASuplAsnMessageBase::TSuplMessageType messageType = aDecodedAsn->MessageType();
  3797         COMASuplAsnMessageBase::TSuplMessageType messageType = aDecodedAsn->MessageType();
  3745 			if(messageType == COMASuplAsnMessageBase::ESUPL_END) 
  3798         if(messageType == COMASuplAsnMessageBase::ESUPL_END) 
  3746 				{
  3799             {
  3747 					iTrace->Trace(_L("Received message is SUPL_END...with wrong Version.Terminating session"), KTraceFileName, __LINE__); 
  3800             iTrace->Trace(_L("Received message is SUPL_END...with wrong Version.Terminating session"), KTraceFileName, __LINE__); 
  3748 					iSessionObserver.TerminateSession(this, KErrCompletion);	
  3801             iSessionObserver.TerminateSession(this, KErrCompletion);	
  3749 				}
  3802             }
  3750 			else
  3803         else
  3751 				{
  3804             {
  3752 					iTrace->Trace(_L("Received message with wrong version."), KTraceFileName, __LINE__); 
  3805             iTrace->Trace(_L("Received message with wrong version."), KTraceFileName, __LINE__); 
  3753 
  3806 
  3754 					delete iSuplState;
  3807             delete iSuplState;
  3755 					iSuplMsgType = ESUPL_END;
  3808             iSuplMsgType = ESUPL_END;
  3756 					iErrorStatusCode = COMASuplEnd::EVersionNotSupported;	
  3809             iErrorStatusCode = COMASuplEnd::EVersionNotSupported;	
  3757 					SetPOSMsgPluginState(COMASuplPosSessionBase::EOMASuplCreating);	
  3810             SetPOSMsgPluginState(COMASuplPosSessionBase::EOMASuplCreating);	
  3758 
  3811 
  3759 					if(iRequestType == ESUPL_NETWORK )
  3812             if(iRequestType == ESUPL_NETWORK )
  3760 					{
  3813                 {
  3761 						
  3814                 if (messageType == COMASuplAsnMessageBase::ESUPL_INIT)    
  3762 						iSuplSessionState = ESUPL_INITIALIZED;
  3815                     {                                
  3763 					    TInt len = iHSLPAddress.Length();
  3816                     iSuplSessionState = ESUPL_INITIALIZED;
  3764 					    HBufC8 *hslpAdress = NULL;
  3817                     TInt len = iHSLPAddress.Length();
  3765 					    if(len > 0)
  3818                     HBufC8 *hslpAdress = NULL;
  3766 					    {
  3819                     if(len > 0)
  3767 					        hslpAdress = HBufC8::NewL(iHSLPAddress.Length());
  3820                         {
  3768 					        hslpAdress->Des().Copy(iHSLPAddress);
  3821                         hslpAdress = HBufC8::NewL(iHSLPAddress.Length());
  3769 					    }
  3822                         hslpAdress->Des().Copy(iHSLPAddress);
  3770 				   	else if(len ==0)
  3823                         }
  3771 					{
  3824                     else if(len ==0)
  3772 					iTrace->Trace(_L("Length of HSLP Address is = 0, passing the HSLP generated frm IMSI"), KTraceFileName, __LINE__);
  3825                         {
  3773 					hslpAdress = HBufC8::NewL(iSuplSettings->SLPAddressfromImsi().Length());
  3826                         CServerParams* serverParams = CServerParams::NewL();
  3774 					CleanupStack::PushL(hslpAdress);
  3827                         CleanupStack::PushL(serverParams);
  3775 					hslpAdress->Des().Copy(iSuplSettings->SLPAddressfromImsi());	
  3828         
  3776 					CleanupStack::Pop(hslpAdress);
  3829                         if (iSuplStorageSettings->GetDefaultServer(serverParams) == KErrNotFound )
  3777 					    }
  3830                             {
  3778 						
  3831                             iTrace->Trace(_L("Length of HSLP Address is = 0, passing the HSLP generated frm IMSI"), KTraceFileName, __LINE__);
  3779 					    CleanupStack::PushL(hslpAdress);
  3832                             hslpAdress = HBufC8::NewL(iSuplSettings->SLPAddressfromImsi().Length());
  3780 					    iSuplState = COMASuplEndState::NewL(iErrorStatusCode,iOMASuplAsnHandlerBaseImpl,iEncodedSuplInit,hslpAdress);		
  3833                             hslpAdress->Des().Copy(iSuplSettings->SLPAddressfromImsi());	
  3781 					    CleanupStack::PopAndDestroy(hslpAdress);
  3834                             }		
  3782 
  3835                         else
  3783 			            // Set the SessionId.
  3836                             {
  3784 				        iTrace->Trace(_L("COMASuplSession::CheckProtocolVersionL Update SLP Session ID"), KTraceFileName, __LINE__);
  3837                             iTrace->Trace(_L("Sending End with ver for Default HSLP"), KTraceFileName, __LINE__);
  3785 			            UpdateSLPSessionIDL(SessionID);
  3838                             TInt64 slpId;
  3786 
  3839                             TBool aServerEnabled, aSimChangeRemove, aUsageInHomeNw, aEditable;
  3787 				        iTrace->Trace(_L("COMASuplSession::CheckProtocolVersionL Update SET Session ID"), KTraceFileName, __LINE__);
  3840                             HBufC* serverAddr = HBufC::NewL(KMaxHSLPAddrLen);
  3788 			            UpdateSETSessionIDL(SessionID);
  3841                             HBufC* iapName = HBufC::NewL(KMaxIAPLen);
  3789 						iSuplState->SetMsgStateObserver(this);
  3842                             CleanupStack::PushL(serverAddr);
  3790 						iSuplState->GenerateMessageL();
  3843                             CleanupStack::PushL(iapName);
  3791 						iSuplSessionState = ESUPL_GENERATE;
  3844                             serverParams->Get(slpId,serverAddr->Des(),iapName->Des(),aServerEnabled, aSimChangeRemove, aUsageInHomeNw, aEditable);
  3792 
  3845                             hslpAdress = HBufC8::NewL(serverAddr->Length());
  3793 					} 
  3846                             hslpAdress->Des().Copy(*serverAddr);
  3794 					else 							
  3847             
  3795 					{
  3848                             CleanupStack::PopAndDestroy(iapName);
  3796 					    iSuplState = COMASuplEndState::NewL(iErrorStatusCode,iOMASuplAsnHandlerBaseImpl);
  3849                             CleanupStack::PopAndDestroy(serverAddr);
  3797 						iSuplSessionState = ESUPL_ENCODE;
  3850                             }
  3798 						iSuplState->SetMsgStateObserver(this);
  3851                         CleanupStack::PopAndDestroy(serverParams);
  3799 						iSuplState->GenerateMessageL();
  3852                         }
  3800 					}
  3853                     
  3801 				}	
  3854                     delete iSuplState;
  3802 				
  3855                     iSuplState = NULL;
  3803 			return EFalse;
  3856                     CleanupStack::PushL(hslpAdress);
  3804 			}	
  3857                     ServerAddressCheckForSuplInitL();
  3805 
  3858                     iSuplState = COMASuplEndState::NewL(iErrorStatusCode,iOMASuplAsnHandlerBaseImpl,iEncodedSuplInit,hslpAdress);		
       
  3859                     CleanupStack::PopAndDestroy(hslpAdress);
       
  3860 
       
  3861                     // Set the SessionId.
       
  3862                     iTrace->Trace(_L("COMASuplSession::CheckProtocolVersionL Update SLP Session ID"), KTraceFileName, __LINE__);
       
  3863                     UpdateSLPSessionIDL(SessionID);
       
  3864 
       
  3865                     iTrace->Trace(_L("COMASuplSession::CheckProtocolVersionL Update SET Session ID"), KTraceFileName, __LINE__);
       
  3866                     UpdateSETSessionIDL(SessionID);
       
  3867                     iSuplState->SetMsgStateObserver(this);
       
  3868                     iSuplState->GenerateMessageL();
       
  3869                     iSuplSessionState = ESUPL_GENERATE;
       
  3870                     }
       
  3871                 else
       
  3872                     {                                
       
  3873                     iSuplState = COMASuplEndState::NewL(iErrorStatusCode,iOMASuplAsnHandlerBaseImpl);		
       
  3874                     UpdateSLPSessionIDL(SessionID);
       
  3875                     UpdateSETSessionIDL(SessionID);
       
  3876                     iSuplState->SetMsgStateObserver(this);
       
  3877                     iRequestType = ESUPL_INVALID_SESSION;
       
  3878                     iSuplSessionState = ESUPL_GENERATE;
       
  3879                     iSuplState->GenerateMessageL();
       
  3880                     }
       
  3881                 } 
       
  3882             else 							
       
  3883                 {
       
  3884                 iSuplState = COMASuplEndState::NewL(iErrorStatusCode,iOMASuplAsnHandlerBaseImpl);
       
  3885                 iSuplSessionState = ESUPL_ENCODE;
       
  3886                 iSuplState->SetMsgStateObserver(this);
       
  3887                 iSuplState->GenerateMessageL();
       
  3888                 }
       
  3889             }	
       
  3890         return EFalse;
       
  3891         }	
  3806 	}
  3892 	}
  3807 
  3893 
  3808 // -----------------------------------------------------------------------------
  3894 // -----------------------------------------------------------------------------
  3809 // COMASuplSession::GetRemainingPosPayloadL
  3895 // COMASuplSession::GetRemainingPosPayloadL
  3810 // Returns remaining pos payload
  3896 // Returns remaining pos payload