diff -r 10852b179f64 -r ea98413ce11f supl/locationomasuplprotocolhandler/protocolhandlerver1/src/epos_comasuplsession.cpp --- a/supl/locationomasuplprotocolhandler/protocolhandlerver1/src/epos_comasuplsession.cpp Wed Sep 15 12:40:28 2010 +0300 +++ b/supl/locationomasuplprotocolhandler/protocolhandlerver1/src/epos_comasuplsession.cpp Wed Oct 13 15:01:35 2010 +0300 @@ -128,7 +128,7 @@ iEtelRoamingCheck(EFalse), iIapDialogShown(EFalse), iIapDlgTimerExpired(EFalse), - iOMASuplAsnHandlerBaseImpl(aOMASuplAsnHandlerBase),iWlanOnly(EFalse) + iOMASuplAsnHandlerBaseImpl(aOMASuplAsnHandlerBase) { } @@ -193,6 +193,8 @@ iIapNotifier = COMASuplIapNotifier::NewL(*this); + + iDialogTimer = COMASuplDialogTimer::NewL(*this); iIsQoPPresent = EFalse; iIsFirstPOSMessage = ETrue; @@ -251,6 +253,7 @@ SessionEnd(); CompleteSession(KErrCancel); } + iProtocolManager.CancelUiLaunch(); delete this; } @@ -310,14 +313,9 @@ delete iTimer; delete iIapNotifier; iIMSI.Close(); + delete iDialogTimer; delete iNetworkPrivacy; - - if(iStaleLocationId) - { - delete iStaleLocationId; - iStaleLocationId = NULL; - } if(iTrace) iTrace->Trace(_L("End of ~COMASuplSession::COMASuplSession"), KTraceFileName, __LINE__); @@ -426,7 +424,7 @@ // void COMASuplSession::RunSuplSessionL(TRequestStatus& aStatus, TBool aFirstReq, const TDesC& aHslpAddress, TBool aFallBack, TInt aAllowedCapabilities, - TInt aSessionIdSeed,TInt aRequestID,TBool aIsStaleCellId,COMASuplLocationId* aLocationId,TBool aPrompt,TBool aWlanOnly) + TInt aSessionIdSeed,TInt aRequestID) { iRunRequestStatus = & aStatus; *iRunRequestStatus = KRequestPending; @@ -434,32 +432,7 @@ iRequestID = aRequestID; iTrace->Trace(_L("Start COMASuplSession::RunSuplSession"), KTraceFileName, __LINE__); - - if(aIsStaleCellId) - { - iTrace->Trace(_L("Start COMASuplSession::RunSuplSession for Stale Cell Id"), KTraceFileName, __LINE__); - iIsStaleLocIdPresent = ETrue; - - - if(iStaleLocationId) - { - delete iStaleLocationId; - iStaleLocationId = NULL; - } - - iStaleLocationId = aLocationId; - iStaleLocIdPrompt = aPrompt; - iWlanOnly = aWlanOnly; //OCC - - iTrace->Trace(_L("Deleting pos requestor as session is for Stale Cell Id"), KTraceFileName, __LINE__); - delete iOMASuplPOSRequestor; - iOMASuplPOSRequestor = NULL; - - // Delete the POS Session - delete iPOSSession; - iPOSSession = NULL; - - } + // Log Session Id TBuf<64> id; id.Append(_L("Session Id is ")); @@ -472,27 +445,23 @@ iTrace->Trace(id,KTraceFileName, __LINE__); iSETSessionUniqueId = aSessionIdSeed; - - iIhaveLaunchedUsagedialog = EFalse; + TInt networkMode = 1; networkMode = GetNetworkModeL(); - if(!iWlanOnly) //OCC - { - if ( networkMode == ECoreAppUIsNetworkConnectionNotAllowed ) - { - id.Copy(_L("The device is in OFFLINE mode.")); - iTrace->Trace(id,KTraceFileName, __LINE__); - iSessionObserver.TerminateSession(this, KErrGeneral); - return; - } - else - { - id.Copy(_L("The device is in ON LINE mode.")); - iTrace->Trace(id,KTraceFileName, __LINE__); - } - } //OCC + if ( networkMode == ECoreAppUIsNetworkConnectionNotAllowed ) + { + id.Copy(_L("The device is in OFFLINE mode.")); + iTrace->Trace(id,KTraceFileName, __LINE__); + iSessionObserver.TerminateSession(this, KErrGeneral); + return; + } + else + { + id.Copy(_L("The device is in ON LINE mode.")); + iTrace->Trace(id,KTraceFileName, __LINE__); + } if(aAllowedCapabilities == 0) { @@ -507,41 +476,17 @@ iSuplSessionId->SetSLPSessionID(NULL); iConnRequestor->SetDefaultParametersL(aHslpAddress,aFallBack); - - id.Copy(_L("aFallBack value is ")); - id.AppendNum(aFallBack); - iTrace->Trace(id,KTraceFileName, __LINE__); - - if(!iWlanOnly) //OCC - { - iTrace->Trace(_L("iWLANOnly false COMASuplSession::RunSuplSession"), KTraceFileName, __LINE__); - - id.Copy(_L("aFirstReq value is ")); - id.AppendNum(aFirstReq); - iTrace->Trace(id,KTraceFileName, __LINE__); - - if (aFirstReq) - { - iTrace->Trace(_L("start CheckForSuplUsageL COMASuplSession::RunSuplSession"), KTraceFileName, __LINE__); - CheckForSuplUsageL(); - } - else - { - iTrace->Trace(_L("start CheckForPreviousResultL COMASuplSession::RunSuplSession"), KTraceFileName, __LINE__); - CheckForPreviousResultL(); - } - } - else - { - iTrace->Trace(_L("iWLANOnly true COMASuplSession::RunSuplSession"), KTraceFileName, __LINE__); - InitializeL(iRequestID); - } //OCC + + if (aFirstReq) + CheckForSuplUsageL(); + else + CheckForPreviousResultL(); // Clear Position.... delete iPosition; iPosition = NULL; - + iTrace->Trace(_L("End of COMASuplSession::RunSuplSession"), KTraceFileName, __LINE__); } @@ -560,7 +505,6 @@ TSuplTerminalQop& aQop, TInt aRequestID) { - iIhaveLaunchedUsagedialog = EFalse; iClientQop = aQop; @@ -709,18 +653,11 @@ COMASuplStartState* startSuplState = static_cast (iSuplState); startSuplState->SetQop(iClientQop); } - if(iIsStaleLocIdPresent) - { - iTrace->Trace(_L("GenerateSuplStartL setting stale location id in supl start"), KTraceFileName, __LINE__); - COMASuplStartState* startSuplState = static_cast (iSuplState); - startSuplState->SetStaleCellIdToUse(iStaleLocationId->CloneL()); - } - iSuplSessionState = ESUPL_GENERATE; - iSuplMsgType = ESUPL_START; + //SMP Changes + iSuplMsgType = ESUPL_START; + SetPOSMsgPluginState(COMASuplPosSessionBase::EOMASuplCreating); TInt err = iSuplState->GenerateMessageL(); - - - SetPOSMsgPluginState(COMASuplPosSessionBase::EOMASuplCreating); + } @@ -763,12 +700,6 @@ iTrace->Trace(msg, KTraceFileName, __LINE__); iSuplState = COMASuplPosInitState::NewL(iSETCapabilities, iMobilePhone, iUT2_PosInitTimer, iOMASuplPOSRequestor,iAllowedCapabilities,iRequestType, iPosMethod,iOMASuplAsnHandlerBaseImpl); - if(iIsStaleLocIdPresent) - { - iTrace->Trace(_L("COMASuplSession::GenerateSuplPosInitL() Setting Stale Location Id "), KTraceFileName, __LINE__); - COMASuplPosInitState* posInitSuplState = static_cast (iSuplState); - posInitSuplState->SetStaleCellIdToUse(iStaleLocationId->CloneL()); - } } iSuplState->SetMsgStateObserver(this); @@ -884,7 +815,6 @@ // void COMASuplSession::OperationCompleteL(TInt aErrorCode) { - iTrace->Trace(_L("COMASuplSession::OperationCompleteL"), KTraceFileName, __LINE__); TBuf<256> msg; if(KErrNone != aErrorCode) { @@ -897,10 +827,6 @@ HandleSuplErrorL(aErrorCode); return; } - - msg.Copy(_L("iSuplSessionState : ")); - msg.AppendNum(iSuplSessionState); - iTrace->Trace(msg, KTraceFileName, __LINE__); TInt err = KErrNone; @@ -962,15 +888,7 @@ } else //terminal initiated case { - iTrace->Trace(_L("Connection block."), KTraceFileName, __LINE__); - if(iIsStaleLocIdPresent) - { - TRAP( err, iConnRequestor->CreateConnectionL(iStaleLocIdPrompt,iWlanOnly) ); - } - else - { - TRAP( err, iConnRequestor->CreateConnectionL() ); - } + TRAP( err, iConnRequestor->CreateConnectionL() ); } if(KErrNone != err) { @@ -2056,7 +1974,15 @@ iTrace->Trace(msg,KTraceFileName, __LINE__); } - + CSuplSettings::TSuplSettingsUsage usage = iSuplSettings->SUPLUsage(); + + if (usage == CSuplSettings::ESuplUsageDisabled) + { + msg.Copy(_L("SUPL Usage is disabled")); + iTrace->Trace(msg,KTraceFileName, __LINE__); + iSessionObserver.TerminateSession(this, KErrGeneral); + return; + } COMASuplAsnMessageBase::TSuplMessageType messageType = aDecodedAsnMessage->MessageType(); @@ -3808,6 +3734,16 @@ } +// ----------------------------------------------------------------------------- +// COMASuplSession::SettingsUICompleted +// +// ----------------------------------------------------------------------------- + +void COMASuplSession::SettingsUICompletedL(TInt /*aError*/) + { + + } + // ----------------------------------------------------------------------------- // COMASuplSession::HandleInvalidMessageL @@ -4109,7 +4045,56 @@ OperationCompleteL(KErrTimedOut); } - +// ----------------------------------------------------------------------------- +// COMASuplSession::SettingsUsageUICompletedL +// +// ----------------------------------------------------------------------------- +void COMASuplSession::SettingsUsageUICompletedL(TInt aError) + { + iUIFlag = EFalse; + TBuf<64> msg; + msg.Copy(_L("SUPL Usage UI completed with ... ")); + msg.AppendNum(aError); + iTrace->Trace(msg,KTraceFileName, __LINE__); + + iPrevUsageResult = aError; + + + if (aError == KErrNone) + { + iProtocolManager.UpdateAllSubSessnsInSameSession(iIpcSessionId); + + if (isTimeoutDialogTimerStarted) + { + iTrace->Trace(_L("COMASuplSession::SettingsUsageUICompletedL, stopping timer "), KTraceFileName, __LINE__); + isTimeoutDialogTimerStarted = EFalse; + iDialogTimer->StopTimer(); + + //Compute how log the dialog was on + TTime nowTime; + nowTime.HomeTime(); + nowTime.SecondsFrom(iDlgStartTime, iDiffTime); + } + if (iNwInitError) + { + iNwInitError = EFalse; + HandleSuplInitErrorL(iNwInitCompletionCode); + } + else + InitializeL(iRequestID); + } + else if (aError == KErrCompletion) + CheckForSuplUsageL(); + else + { + TBuf<64> msg; + msg.Copy(_L("Error after SUPL Usage Popup... ")); + msg.AppendNum(aError); + iTrace->Trace(msg,KTraceFileName, __LINE__); + iSessionObserver.TerminateSession(this, KErrGeneral); + return; + } + } // ----------------------------------------------------------------------------- // COMASuplSession::CheckForSuplUsageL @@ -4118,23 +4103,37 @@ void COMASuplSession::CheckForSuplUsageL() { - + if (iSuplUsage >= 1) + { + CSuplSettings::TSuplSettingsUsage usage = iSuplSettings->SUPLUsage(); + if (usage == CSuplSettings::ESuplUsageDisabled) + { + iSessionObserver.TerminateSession(this, KErrGeneral); + } + else if (usage == CSuplSettings::ESuplUsageAutomatic) + { if (iNwInitError) { iNwInitError = EFalse; HandleSuplInitErrorL(iNwInitCompletionCode); } else - { - if (iRoaming) + InitializeL(iRequestID); + } + + else if (usage == CSuplSettings::ESuplUsageHomeAutomatic || usage == CSuplSettings::ESuplUsageAlwaysAsk) + { + if (iRoaming) HandleRoamingCheckCompleteL(KErrNone, EFalse); else { iEtelRoamingCheck = ETrue; iProtocolManager.CheckForRoaming(); } - } - + } + } + else + InitializeL(iRequestID); } @@ -4217,7 +4216,80 @@ { iUsageHomeNW = aHomeNw; iConnRequestor->UpdateSLPListForHomeUsage(iUsageHomeNW); - + CSuplSettings::TSuplSettingsUsage usage = iSuplSettings->SUPLUsage(); + + if (usage == CSuplSettings::ESuplUsageAlwaysAsk) + { + TInt err; + if (!aHomeNw) + { + iTrace->Trace(_L("Invoking LaunchSuplUsageSettingsUI, user is roaming"), KTraceFileName, __LINE__); + err = iProtocolManager.LaunchSuplUsageSettingsUI(this, ETrue); + } + else + { + iTrace->Trace(_L("Invoking LaunchSuplUsageSettingsUI, user is not roaming"), KTraceFileName, __LINE__); + err = iProtocolManager.LaunchSuplUsageSettingsUI(this, EFalse); + } + + if(KErrNone != err && KErrInUse == err) + { + iTrace->Trace(_L("Dialog in use, setting flag"), KTraceFileName, __LINE__); + SetSuplUsageFlag(); + } + if( KErrNone == err && iRequestType == ESUPL_NETWORK ) + { + iTrace->Trace(_L("Network Session , starting timer"), KTraceFileName, __LINE__); + COMASuplInit* suplInit = static_cast (iDecodedAsnMessage); + TOMASuplQop qop; + TInt retVal = suplInit->Qop(qop); + TInt delay; + qop.Delay(delay); + //if delay is > 7, it is not valid + if (delay > 7) + delay = 0; + if(retVal == KErrNone && delay > 0) + { + TReal delayReal; + Math::Pow(delayReal, 2, (TReal)delay); + delay = (TInt) delayReal; + TBuf<128> msg(_L("Delay present in message, value is = ")); + msg.AppendNum(delay); + iTrace->Trace(msg, KTraceFileName, __LINE__); + isTimeoutDialogTimerStarted = ETrue; + iDialogTimer->StartTimer(delay); + } + else + { + if (iSuplInitTimeOut > 0) + { + TBuf<256> msg(_L("Delay value in CR is")); + msg.AppendNum(iSuplInitTimeOut); + iTrace->Trace(msg, KTraceFileName, __LINE__); + iDialogTimer->StartTimer(iSuplInitTimeOut * KSecond); + isTimeoutDialogTimerStarted = ETrue; + } + else + iTrace->Trace(_L("Timeout is <= 0"), KTraceFileName, __LINE__); + } + iDlgStartTime.HomeTime(); + } + else if (KErrNone != err) + { + iTrace->Trace(_L("Invoking HandleSuplErrorL"), KTraceFileName, __LINE__); + HandleSuplErrorL(err); + } + + } + else if (usage == CSuplSettings::ESuplUsageHomeAutomatic) + { + if (!aHomeNw) + { + TInt err; + //if (!iSuplSettings->IsUIActive() ) + { + iTrace->Trace(_L("Invoking LaunchSuplUsageSettingsUI, user is roaming"), KTraceFileName, __LINE__); + err = iProtocolManager.LaunchSuplUsageSettingsUI(this, ETrue); if(iSuplMsgType == ESUPL_INIT) { @@ -4240,35 +4312,47 @@ msg.AppendNum(delay); iTrace->Trace(msg, KTraceFileName, __LINE__); isTimeoutDialogTimerStarted = ETrue; - + iDialogTimer->StartTimer(delay); } else { if (iSuplInitTimeOut > 0) { isTimeoutDialogTimerStarted = ETrue; - + iDialogTimer->StartTimer(iSuplInitTimeOut * KSecond); } else iTrace->Trace(_L("Timeout is <= 0"), KTraceFileName, __LINE__); } } - + } + + if(!iSuplSettings->IsUIActive() && KErrNone != err) + { + SetSuplUsageFlag(); + } + else + { + iTrace->Trace(_L("Invoking HandleSuplErrorL"), KTraceFileName, __LINE__); + HandleSuplErrorL(err); + } + } + else + { if (iNwInitError) { iNwInitError = EFalse; HandleSuplInitErrorL(iNwInitCompletionCode); } else - { - iTrace->Trace(_L("COMASuplSession::InitializeL called after roaming check"), KTraceFileName, __LINE__); - InitializeL(iRequestID); - } + InitializeL(iRequestID); + } + } } - else - { - iSessionObserver.TerminateSession(this, KErrGeneral); - } + else + { + iSessionObserver.TerminateSession(this, KErrGeneral); + } } TInt COMASuplSession::SuplIpcSessionID() { @@ -4333,7 +4417,173 @@ return iUsageDialog; } - +void COMASuplSession::StartUsageDialogLaunchL() + { + iTrace->Trace(_L("COMASuplSession::StartUsageDialogLaunchL"), KTraceFileName, __LINE__); + ReSetSuplUsageFlag(); + iTrace->Trace(_L("COMASuplSession::StartUsageDialogLaunchL, flag reset done"), KTraceFileName, __LINE__); + + CSuplSettings::TSuplSettingsUsage usage = iSuplSettings->SUPLUsage(); + if (usage == CSuplSettings::ESuplUsageAlwaysAsk) + { + TInt err; + if (!iUsageHomeNW) + { + iTrace->Trace(_L("Invoking LaunchSuplUsageSettingsUI, user is roaming"), KTraceFileName, __LINE__); + err = iProtocolManager.LaunchSuplUsageSettingsUI(this, ETrue); + + if(iRequestType == ESUPL_NETWORK && err == KErrNone) + { + iTrace->Trace(_L("starting Dialog timer "), KTraceFileName, __LINE__); + + COMASuplInit* suplInit = static_cast (iDecodedAsnMessage); + TOMASuplQop qop; + TInt retVal = suplInit->Qop(qop); + TInt delay; + qop.Delay(delay); + //if delay is > 7, it is not valid + if (delay > 7) + delay = 0; + if(retVal == KErrNone && delay > 0) + { + TReal delayReal; + Math::Pow(delayReal, 2, (TReal)delay); + delay = (TInt) delayReal; + TBuf<128> msg(_L("Delay present in message, value is = ")); + msg.AppendNum(delay); + iTrace->Trace(msg, KTraceFileName, __LINE__); + isTimeoutDialogTimerStarted = ETrue; + iDialogTimer->StartTimer(delay); + } + else + { + if (iSuplInitTimeOut > 0) + { + iTrace->Trace(_L("Delay not present in message"), KTraceFileName, __LINE__); + TBuf<256> msg(_L("Delay value in CR is ")); + msg.AppendNum(iSuplInitTimeOut); + iDialogTimer->StartTimer(iSuplInitTimeOut * KSecond); + isTimeoutDialogTimerStarted = ETrue; + } + else + iTrace->Trace(_L("Timeout is <= 0"), KTraceFileName, __LINE__); + } + } + } + else + { + iTrace->Trace(_L("Invoking LaunchSuplUsageSettingsUI, user is not roaming"), KTraceFileName, __LINE__); + err = iProtocolManager.LaunchSuplUsageSettingsUI(this, EFalse); + + if( iRequestType == ESUPL_NETWORK && err == KErrNone) + { + iTrace->Trace(_L("starting Dialog timer "), KTraceFileName, __LINE__); + + COMASuplInit* suplInit = static_cast (iDecodedAsnMessage); + TOMASuplQop qop; + TInt retVal = suplInit->Qop(qop); + TInt delay; + qop.Delay(delay); + //if delay is > 7, it is not valid + if (delay > 7) + delay = 0; + if(retVal == KErrNone && delay > 0) + { + TReal delayReal; + Math::Pow(delayReal, 2, (TReal)delay); + delay = (TInt) delayReal; + TBuf<128> msg(_L("Delay present in message, value is = ")); + msg.AppendNum(delay); + iTrace->Trace(msg, KTraceFileName, __LINE__); + isTimeoutDialogTimerStarted = ETrue; + iDialogTimer->StartTimer(delay); + } + else + { + if (iSuplInitTimeOut > 0) + { + iTrace->Trace(_L("Delay not present in message"), KTraceFileName, __LINE__); + TBuf<256> msg(_L("Delay value in CR is")); + msg.AppendNum(iSuplInitTimeOut); + iDialogTimer->StartTimer(iSuplInitTimeOut * KSecond); + isTimeoutDialogTimerStarted = ETrue; + } + else + iTrace->Trace(_L("Timeout is <= 0"), KTraceFileName, __LINE__); + } + } + } + + if(KErrNone != err) + { + iTrace->Trace(_L("Invoking HandleSuplErrorL"), KTraceFileName, __LINE__); + HandleSuplErrorL(err); + } + } + else if (usage == CSuplSettings::ESuplUsageHomeAutomatic) + { + if (!iUsageHomeNW) + { + TInt err; + iTrace->Trace(_L("Invoking LaunchSuplUsageSettingsUI, user is roaming"), KTraceFileName, __LINE__); + err = iProtocolManager.LaunchSuplUsageSettingsUI(this, ETrue); + + if(KErrNone != err) + { + iTrace->Trace(_L("Invoking HandleSuplErrorL"), KTraceFileName, __LINE__); + HandleSuplErrorL(err); + } + + if(iRequestType == ESUPL_NETWORK && err == KErrNone) + { + iTrace->Trace(_L("starting Dialog timer "), KTraceFileName, __LINE__); + + COMASuplInit* suplInit = static_cast (iDecodedAsnMessage); + TOMASuplQop qop; + TInt retVal = suplInit->Qop(qop); + TInt delay; + qop.Delay(delay); + //if delay is > 7, it is not valid + if (delay > 7) + delay = 0; + if(retVal == KErrNone && delay > 0) + { + TReal delayReal; + Math::Pow(delayReal, 2, (TReal)delay); + delay = (TInt) delayReal; + TBuf<128> msg(_L("Delay present in message, value is = ")); + msg.AppendNum(delay); + iTrace->Trace(msg, KTraceFileName, __LINE__); + isTimeoutDialogTimerStarted = ETrue; + iDialogTimer->StartTimer(delay); + } + else + { + if (iSuplInitTimeOut > 0) + { + iTrace->Trace(_L("Delay not present in message"), KTraceFileName, __LINE__); + TBuf<256> msg(_L("Delay value in CR is")); + msg.AppendNum(iSuplInitTimeOut); + iDialogTimer->StartTimer(iSuplInitTimeOut * KSecond); + isTimeoutDialogTimerStarted = ETrue; + } + else + iTrace->Trace(_L("Timeout is <= 0"), KTraceFileName, __LINE__); + } + } + } + else + { + if (iNwInitError) + { + iNwInitError = EFalse; + HandleSuplInitErrorL(iNwInitCompletionCode); + } + else + InitializeL(iRequestID); + } + } + } TBool COMASuplSession::IsEtelNotifySet() { @@ -4346,13 +4596,39 @@ iTrace->Trace(_L("COMASuplSession::IsEtelRoamingSet"), KTraceFileName, __LINE__); return iEtelRoamingCheck; } - -TBool COMASuplSession::HasMeLaunchedUsageDialog() + +// ----------------------------------------------------------------------------- +// COMASuplSession::DialogTimerExpiredL +// Checks whether UI is displayed or not previously +// +// ----------------------------------------------------------------------------- +void COMASuplSession::DialogTimerExpiredL() { - return iIhaveLaunchedUsagedialog; + iTrace->Trace(_L("Timer Expired for SUPL Dialog"), KTraceFileName, __LINE__); + + if (!iIapDialogShown) + iProtocolManager.LaunchSuplDialogTimeoutUI(this); + else + iIapDlgTimerExpired = ETrue; + + return; } - +// ----------------------------------------------------------------------------- +// COMASuplSession::SettingsTimeOutUICompletedL +// +// ----------------------------------------------------------------------------- +void COMASuplSession::SettingsTimeOutUICompletedL(TInt aError) + { + + TBuf<64> msg; + msg.Copy(_L("SUPL Timeout UI completed with ... ")); + msg.AppendNum(aError); + iTrace->Trace(msg,KTraceFileName, __LINE__); + iSessionObserver.TerminateSession(this, KErrGeneral); + return; + + } // ----------------------------------------------------------------------------- // COMASuplSession::StoreCurrentCellIDL