supl/locationsuplfw/gateway/src/epos_csuplnetinitiatedsession.cpp
changeset 22 4c4ed41530db
parent 0 667063e416a2
--- a/supl/locationsuplfw/gateway/src/epos_csuplnetinitiatedsession.cpp	Mon May 03 12:54:42 2010 +0300
+++ b/supl/locationsuplfw/gateway/src/epos_csuplnetinitiatedsession.cpp	Fri May 14 16:17:02 2010 +0300
@@ -61,15 +61,34 @@
     TInt majorVersion = KErrNotFound;
     TInt err = aSessnMgr.GetSUPLMessageVersionL(majorVersion,aClientBuf->Des());
     
-    if(majorVersion == 1)
+    if(majorVersion == 2)
+	{
+		if(!CheckSuplTriggerServiceStatus())
+    	{
+    			User::Leave(KErrNotSupported);
+    	}
+		suplService = RSuplTerminalSubSession::ESUPL_2_0;
+	}
+    else 
     	suplService = RSuplTerminalSubSession::ESUPL_1_0;
-    else 
-    	suplService = RSuplTerminalSubSession::ESUPL_2_0;
     
     iSuplSession = aSessnMgr.CreateNewSessionL(aReqType, 0, suplService );
+    if (iSuplSession)
+    {	
     iSuplSession->SetSUPLVersion(majorVersion);
     iSuplSessnReq = CSuplSessionRequest::NewL(aSessnMgr, iSuplSession, aServer);
-  
+    }  
+    else
+    	if (!iSuplSession && suplService == RSuplTerminalSubSession::ESUPL_2_0)
+    		{
+    			 suplService = RSuplTerminalSubSession::ESUPL_1_0;
+    			 iSuplSession = aSessnMgr.CreateNewSessionL(aReqType, 0, suplService );
+    					if (iSuplSession)
+   						 {	
+   						 iSuplSession->SetSUPLVersion(majorVersion);
+    					 iSuplSessnReq = CSuplSessionRequest::NewL(aSessnMgr, iSuplSession, aServer);
+    					 }
+    		}
 
     }
 
@@ -171,5 +190,41 @@
 	aSessionMgr->DestroySession(iSuplSession);
 }
 
+// ---------------------------------------------------------
+// CSuplNetInitiatedSession::CheckSuplTriggerServiceStatus
+//
+// (other items were commented in a header).
+// ---------------------------------------------------------
+//
+TBool CSuplNetInitiatedSession::CheckSuplTriggerServiceStatus()
+{
+	
+	CSuplSettings* 	suplStorageSettings = NULL;
+	
+	CSuplSettings::TSuplTriggerStatus suplTriggerStatus;
+
+	// create local object iSuplStorageSettings
+	TRAPD(err,suplStorageSettings = CSuplSettings::NewL());
+	if(err == KErrNone)
+	{
+			suplStorageSettings->GetSuplTriggeredServiceStatus(suplTriggerStatus);
+			delete suplStorageSettings;
+			suplStorageSettings = NULL;
+
+			if(suplTriggerStatus == CSuplSettings::ESuplTriggerOn)
+			{
+					return ETrue;						
+			}
+			else
+			{
+					return EFalse;	
+			}
+	}		
+	else
+	{
+			return ETrue;
+	}
+}
+
 // End of File