phoneengine/phonemodel/src/cpemessagehandler.cpp
branchGCC_SURGE
changeset 51 f39ed5e045e0
parent 30 ebdbd102c78a
parent 46 bc5a64e5bc3c
equal deleted inserted replaced
40:bab96b7ed1a4 51:f39ed5e045e0
   451             iModel.SendMessage( MEngineMonitor::EPEMessageStoppedDTMF );
   451             iModel.SendMessage( MEngineMonitor::EPEMessageStoppedDTMF );
   452             }
   452             }
   453         
   453         
   454         dtmfString = KNullDesC;
   454         dtmfString = KNullDesC;
   455         }    
   455         }    
   456     else if ( dtmfString[ 0 ] == KPEDtmfPlusChar ) // speed-dial substitution
       
   457         {
       
   458         TEFLOGSTRING( KTAMESINT, "PE CPEMessageHandler::HandleSendDtmf(), Processing +" );
       
   459         HandlePlusSignInDtmf( dtmfString );
       
   460         dtmfString = KNullDesC;
       
   461         }
       
   462     else if ( dtmfString[ 0 ] == KPEDtmfPauseCharLowercase || 
   456     else if ( dtmfString[ 0 ] == KPEDtmfPauseCharLowercase || 
   463               dtmfString[ 0 ] == KPEDtmfPauseCharUppercase ) // soft pause
   457               dtmfString[ 0 ] == KPEDtmfPauseCharUppercase ) // soft pause
   464         {
   458         {
   465         TEFLOGSTRING( KTAMESINT, "PE CPEMessageHandler::HandleSendDtmf(), Processing P" );
   459         TEFLOGSTRING( KTAMESINT, "PE CPEMessageHandler::HandleSendDtmf(), Processing P" );
   466         
   460         
   531     CPEMessageHandler* self = static_cast<CPEMessageHandler*>(aAny);
   525     CPEMessageHandler* self = static_cast<CPEMessageHandler*>(aAny);
   532 
   526 
   533     delete self->iAsyncCallBack;
   527     delete self->iAsyncCallBack;
   534     self->iAsyncCallBack = NULL;
   528     self->iAsyncCallBack = NULL;
   535     return self->HandleSendDtmf();  
   529     return self->HandleSendDtmf();  
   536     }
       
   537 
       
   538 // -----------------------------------------------------------------------------
       
   539 // CPEMessageHandler::HandlePlusSignInDtmf
       
   540 // Handles plus (+) sign in a DTMF string.
       
   541 // -----------------------------------------------------------------------------
       
   542 //
       
   543 void CPEMessageHandler::HandlePlusSignInDtmf(const TPEDtmfString& aDtmfString )
       
   544     {
       
   545     TEFLOGSTRING2( KTAMESINT, "PE CPEMessageHandler::HandlePlusSignInDtmf(), aDtmfString: %S", &aDtmfString ); 
       
   546           
       
   547     // Find the SD index after the plus sign
       
   548     TPtrC validManualDTMFChars( KPEValidSpeedDialChars );
       
   549     TInt index = ECCPErrorNotFound;
       
   550     for ( index = 1 ; index < aDtmfString.Length() ; index++ )
       
   551         {
       
   552         if ( validManualDTMFChars.Locate( aDtmfString[index] ) == ECCPErrorNotFound )
       
   553             {
       
   554             TEFLOGSTRING( KTAMESINT, "PE CPEMessageHandler::HandlePlusSignInDtmf(), Not Found" ); 
       
   555             break; 
       
   556             }
       
   557         }
       
   558     TPESpeedDialSubstituionStatus sdStatus = EPEDtmfSpeedDialOk;
       
   559     
       
   560     // Empty string after the plus sign
       
   561     if ( index == 1 )
       
   562         {
       
   563         if ( aDtmfString.Length() > 1 )
       
   564             {
       
   565             // pw+ after the plus sign.
       
   566             sdStatus = EPEDtmfSpeedDialInvalidSpeedDial;
       
   567             }
       
   568         else
       
   569             {
       
   570             // string ended with the plus sign.
       
   571             sdStatus = EPEDtmfSpeedDialPromptUser;
       
   572             }
       
   573         // Clear DTMF string.
       
   574         iDataStore.SetDtmfString( KNullDesC() );
       
   575         }
       
   576     // Else if the SD location ends the DTMF string, move the index to the
       
   577     // last character instead of one over.
       
   578     else if ( index == aDtmfString.Length() )
       
   579         {
       
   580         index--;
       
   581         }
       
   582     
       
   583     // Check that the index is valid
       
   584     TInt sdIndex = ECCPErrorNotFound; 
       
   585     if ( sdStatus == EPEDtmfSpeedDialOk )
       
   586         {
       
   587         TLex lexer( aDtmfString.Mid( 1, index ) );
       
   588         // convert it to a number
       
   589         if ( lexer.Val(sdIndex) == ECCPErrorNone )
       
   590             {
       
   591             // Is it out of range
       
   592             if ( sdIndex < KPESpeedDialIndexMin  ||
       
   593                 sdIndex > KPESpeedDialIndexMax )
       
   594                 {
       
   595                 sdStatus = EPEDtmfSpeedDialInvalidSpeedDial;
       
   596                 }
       
   597             }
       
   598         else
       
   599             {
       
   600             sdStatus = EPEDtmfSpeedDialInvalidSpeedDial;
       
   601             }
       
   602         }
       
   603     
       
   604     // Fetch the SD location
       
   605     TPEPhoneNumber speedDialLocationString;
       
   606     if ( sdStatus == EPEDtmfSpeedDialOk )
       
   607         {
       
   608         TEFLOGSTRING2( KTAMESINT, "PE CPEMessageHandler::HandlePlusSignInDtmf(), SD location %i", sdIndex ); 
       
   609         if ( iContactHandling.GetSpeedDialLocation( 
       
   610             sdIndex, speedDialLocationString ) == ECCPErrorNone )
       
   611             {
       
   612             // Is content found
       
   613             if ( speedDialLocationString.Length() == 0)
       
   614                 {
       
   615                 sdStatus = EPEDtmfSpeedDialNotAssigned;
       
   616                 }
       
   617             else if ( speedDialLocationString[0] == KPEDtmfPlusChar)  
       
   618                 {
       
   619                 // plus char must be removed from dtmf string before sending
       
   620                 RemovePlusPrefix( speedDialLocationString );
       
   621                 }
       
   622             }
       
   623         else
       
   624             {
       
   625             sdStatus = EPEDtmfSpeedDialInvalidSpeedDial;
       
   626             }
       
   627         }
       
   628     
       
   629     // Now interpret the sdStatus to the next action
       
   630     switch ( sdStatus )
       
   631         {
       
   632         case EPEDtmfSpeedDialOk:
       
   633             {
       
   634             TEFLOGSTRING2( KTAMESINT, "PE CPEMessageHandler::HandlePlusSignInDtmf(), SD result: %S", &speedDialLocationString ); 
       
   635             // Take the SD location string and use that as new DTMF string
       
   636             iDataStore.SetDtmfStringCommand( speedDialLocationString );
       
   637             
       
   638             // Do recursion asyncronously                        
       
   639             TCallBack callBack( CallBackHandleSendDtmf, this );
       
   640             delete iAsyncCallBack;
       
   641             iAsyncCallBack = NULL;
       
   642             // Function does not allow to leave.
       
   643             iAsyncCallBack = new CAsyncCallBack( callBack, CActive::EPriorityStandard );
       
   644             if ( iAsyncCallBack )
       
   645                 {
       
   646                 iAsyncCallBack->CallBack();
       
   647                 }
       
   648             else
       
   649                 {
       
   650                 iModel.SendMessage( MEngineMonitor::EPEMessageDTMFSendingAborted );
       
   651                 }
       
   652             }
       
   653             break;
       
   654         case EPEDtmfSpeedDialPromptUser:
       
   655             // Speed dial location not given.
       
   656             iDataStore.SetDtmfString( KNullDesC() );
       
   657             iModel.SendMessage( MEngineMonitor::EPEMessagePromptSpeedDial );
       
   658             break;
       
   659         case EPEDtmfSpeedDialNotAssigned:
       
   660             // Speed dial location valid but not assigned
       
   661             iDataStore.SetDtmfString( KNullDesC() );
       
   662             iDataStore.SetDtmfStringCommand( KNullDesC() );
       
   663             iModel.SendMessage( MEngineMonitor::EPEMessageDTMFSendingAborted);
       
   664             iModel.SendMessage( MEngineMonitor::EPEMessageSpeedDialNotAssigned );
       
   665             break;
       
   666         case EPEDtmfSpeedDialInvalidSpeedDial:
       
   667             // Speed dial location invalid
       
   668             iDataStore.SetDtmfString( KNullDesC() );
       
   669             iDataStore.SetDtmfStringCommand( KNullDesC() );
       
   670             iModel.SendMessage( MEngineMonitor::EPEMessageDTMFSendingAborted);
       
   671             iModel.SendMessage( MEngineMonitor::EPEMessageInvalidSpeedDial );
       
   672             break;
       
   673         default:
       
   674             Panic( EPEPanicInvalidState );
       
   675             break;
       
   676         } // end switch
       
   677     }
   530     }
   678 
   531 
   679 // -----------------------------------------------------------------------------
   532 // -----------------------------------------------------------------------------
   680 // CPEMessageHandler::CheckPrefix
   533 // CPEMessageHandler::CheckPrefix
   681 // Checks the status of phone number prefix change setting
   534 // Checks the status of phone number prefix change setting
  1080         "PE: CPEMessageHandler::RemoveInvalidChars, Parsed string = %S", 
   933         "PE: CPEMessageHandler::RemoveInvalidChars, Parsed string = %S", 
  1081         &aString);
   934         &aString);
  1082     return returnValue;
   935     return returnValue;
  1083     }
   936     }
  1084 
   937 
  1085 
       
  1086 // -----------------------------------------------------------------------------
       
  1087 // CPEMessageHandler::HandleGetLifeTimerData
       
  1088 // Reads lifetimerdata from custom api and stores it to engine info
       
  1089 // -----------------------------------------------------------------------------
       
  1090 //
       
  1091 TInt CPEMessageHandler::HandleGetLifeTimerData() const
       
  1092     {
       
  1093     TCCPLifeTimeData lifeTimeData; 
       
  1094     TCCPLifeTimeDataPckg pckg( lifeTimeData );
       
  1095 
       
  1096     if ( iCallHandling.GetLifeTime( pckg ) )
       
  1097         {
       
  1098         TEFLOGSTRING2( 
       
  1099             KTAGENERAL, 
       
  1100             "PE: CPEMessageHandler::HandleGetLifeTimerData, iHours = %d", 
       
  1101             lifeTimeData.iHours);
       
  1102         TEFLOGSTRING2( 
       
  1103             KTAGENERAL, 
       
  1104             "PE: CPEMessageHandler::HandleGetLifeTimerData, iMinutes = %d", 
       
  1105             lifeTimeData.iMinutes);
       
  1106             
       
  1107         iDataStore.SetLifeTimerData( pckg );
       
  1108         }
       
  1109     
       
  1110     return ECCPErrorNone;
       
  1111     }
       
  1112     
       
  1113 // -----------------------------------------------------------------------------
   938 // -----------------------------------------------------------------------------
  1114 // CPEMessageHandler::CallbackSendMessageStoppedDTMF
   939 // CPEMessageHandler::CallbackSendMessageStoppedDTMF
  1115 // -----------------------------------------------------------------------------
   940 // -----------------------------------------------------------------------------
  1116 //
   941 //
  1117 TInt CPEMessageHandler::CallbackSendMessageStoppedDTMF( TAny* aAny )
   942 TInt CPEMessageHandler::CallbackSendMessageStoppedDTMF( TAny* aAny )
  1510                 &number, aCallId );
  1335                 &number, aCallId );
  1511                                          
  1336                                          
  1512             RemovePreAndPostFix( number );
  1337             RemovePreAndPostFix( number );
  1513   
  1338   
  1514             iDataStore.SetRemotePhoneNumber( number, aCallId );
  1339             iDataStore.SetRemotePhoneNumber( number, aCallId );
  1515             }
  1340             }            
  1516         
       
  1517         // The Colp number is stored to remoteparty in connected state.
       
  1518         TPEPhoneNumber colpNumber = iCallInfo->iRemoteParty.iRemoteNumber.iTelNumber;
       
  1519         RemovePreAndPostFix( colpNumber );
       
  1520         iDataStore.SetRemoteColpNumber( colpNumber, aCallId ); 
       
  1521         TEFLOGSTRING3( 
       
  1522             KTAMESINT, 
       
  1523             "PE CPEMessageHandler::SetPhoneNumberForCallLogging, colp number: '%S', call id: %d", 
       
  1524             &colpNumber, aCallId );
       
  1525         }
  1341         }
  1526     else if ( iDataStore.CallDirection( aCallId ) == RMobileCall::EMobileTerminated )
  1342     else if ( iDataStore.CallDirection( aCallId ) == RMobileCall::EMobileTerminated )
  1527         {
  1343         {
  1528         iDataStore.SetRemotePhoneNumber( iCallInfo->iRemoteParty.iRemoteNumber.iTelNumber, aCallId );
  1344         iDataStore.SetRemotePhoneNumber( iCallInfo->iRemoteParty.iRemoteNumber.iTelNumber, aCallId );
  1529         TEFLOGSTRING2( 
  1345         TEFLOGSTRING2( 
  1745     
  1561     
  1746     // Reset Phonenumber from engine info, this is necessary so that call number
  1562     // Reset Phonenumber from engine info, this is necessary so that call number
  1747     // logging works OK (see CPEMessageHandler::SetPhoneNumberForCallLogging).  
  1563     // logging works OK (see CPEMessageHandler::SetPhoneNumberForCallLogging).  
  1748     iDataStore.SetPhoneNumber( KNullDesC() );
  1564     iDataStore.SetPhoneNumber( KNullDesC() );
  1749     
  1565     
  1750     // COLP number is updated in connected state 
       
  1751     UpdateRemotePartyInfo();
       
  1752    
       
  1753     return ECCPErrorNone;
  1566     return ECCPErrorNone;
  1754     }
  1567     }
  1755 
  1568 
  1756 // -----------------------------------------------------------------------------
  1569 // -----------------------------------------------------------------------------
  1757 // CPEMessageHandler::HandleDialCall
  1570 // CPEMessageHandler::HandleDialCall
  1861         HandleClientCallData();
  1674         HandleClientCallData();
  1862         }
  1675         }
  1863     else 
  1676     else 
  1864         {
  1677         {
  1865         iDataStore.SetCallOriginCommand(EPECallOriginPhone);
  1678         iDataStore.SetCallOriginCommand(EPECallOriginPhone);
       
  1679 		ResetClientCallData();
  1866         }
  1680         }
  1867         
  1681         
  1868     //Get number of calls
  1682     //Get number of calls
  1869     numberOfCalls = iCallHandling.GetNumberOfCalls();
  1683     numberOfCalls = iCallHandling.GetNumberOfCalls();
  1870 
  1684 
  1914         }
  1728         }
  1915 
  1729 
  1916     TEFLOGSTRING2( KTAINT, "PE CPEMessageHandler::HandleDialCallL: errorCode = %d", errorCode );
  1730     TEFLOGSTRING2( KTAINT, "PE CPEMessageHandler::HandleDialCallL: errorCode = %d", errorCode );
  1917         
  1731         
  1918     return errorCode;
  1732     return errorCode;
       
  1733     }
       
  1734 
       
  1735 // -----------------------------------------------------------------------------
       
  1736 // CPEMessageHandler::ResetClientCallData
       
  1737 // Reset CCCECallParameters to prevent of use a previous callīs parameters
       
  1738 // -----------------------------------------------------------------------------
       
  1739 //
       
  1740 void CPEMessageHandler::ResetClientCallData()
       
  1741     {
       
  1742     TEFLOGSTRING( KTAINT, "PE CPEMessageHandler::ResetClientCallData()" );
       
  1743 
       
  1744     CCCECallParameters& params = iDataStore.CallParameters();
       
  1745     params.SetLineType( CCCECallParameters::ECCELineTypePrimary );
       
  1746     params.SetUUSId( KNullDesC() );
       
  1747     params.SetBearer( KNullDesC8() );
       
  1748     params.SetSubAddress( KNullDesC() );
       
  1749     params.SetOrigin( CCCECallParameters::ECCECallOriginPhone );
  1919     }
  1750     }
  1920 
  1751 
  1921 // -----------------------------------------------------------------------------
  1752 // -----------------------------------------------------------------------------
  1922 // CPEMessageHandler::HandleSatCallRequestCompleted
  1753 // CPEMessageHandler::HandleSatCallRequestCompleted
  1923 // Sends respond to SAT after dial request completion
  1754 // Sends respond to SAT after dial request completion
  2571 // -----------------------------------------------------------------------------
  2402 // -----------------------------------------------------------------------------
  2572 // CPEMessageHandler::IsEmergencyAllowed()
  2403 // CPEMessageHandler::IsEmergencyAllowed()
  2573 // Checks if emergency call is allowed. 
  2404 // Checks if emergency call is allowed. 
  2574 // -----------------------------------------------------------------------------
  2405 // -----------------------------------------------------------------------------
  2575 //
  2406 //
  2576 TBool CPEMessageHandler::IsEmergencyAllowed() const
  2407 TBool CPEMessageHandler::IsNetworkConnectionAllowed() const
  2577     {
  2408     {
  2578     TBool networkConnectionAllowed( EFalse );
  2409     TBool networkConnectionAllowed( EFalse );
  2579     //It is safe to ignore error code here: a default value of EFalse is used if the get fails
  2410     //It is safe to ignore error code here: a default value of EFalse is used if the get fails
  2580     iExternalDataHandler.Get( EPENetworkConnectionAllowedSetting, networkConnectionAllowed );
  2411     iExternalDataHandler.Get( EPENetworkConnectionAllowedSetting, networkConnectionAllowed );
  2581     return networkConnectionAllowed;
  2412     return networkConnectionAllowed;
  2892 
  2723 
  2893 // -----------------------------------------------------------------------------
  2724 // -----------------------------------------------------------------------------
  2894 // CPEMessageHandler::HandleRemotePartyInfoChanged
  2725 // CPEMessageHandler::HandleRemotePartyInfoChanged
  2895 // -----------------------------------------------------------------------------
  2726 // -----------------------------------------------------------------------------
  2896 //
  2727 //
  2897 void CPEMessageHandler::HandleRemotePartyInfoChanged()
  2728 void CPEMessageHandler::HandleRemotePartyInfoChanged( const TInt /*aCallId*/ )
  2898     {
  2729     {        
  2899     UpdateRemotePartyInfo();      
  2730     UpdateRemotePartyInfo(); 
       
  2731         
  2900     }
  2732     }
  2901 
  2733 
  2902 
  2734 
  2903 // -----------------------------------------------------------------------------
  2735 // -----------------------------------------------------------------------------
  2904 // CPEMessageHandler::HandleUnattendedTransferRequestResponse
  2736 // CPEMessageHandler::HandleUnattendedTransferRequestResponse
  2987         mediatorUpdater->UpdateRemotePartyInfo();
  2819         mediatorUpdater->UpdateRemotePartyInfo();
  2988         }
  2820         }
  2989     }
  2821     }
  2990 
  2822 
  2991 // -----------------------------------------------------------------------------
  2823 // -----------------------------------------------------------------------------
       
  2824 // CPEMessageHandler::AddSIMRejectedMoCsCallToLog
       
  2825 // -----------------------------------------------------------------------------
       
  2826 //	
       
  2827 TInt CPEMessageHandler::AddSIMRejectedMoCsCallToLog( const TInt aCallId )
       
  2828     {
       
  2829     TInt errorCode( ECCPErrorGeneral );
       
  2830     
       
  2831     errorCode = iCallHandling.GetCallInfo( *iCallInfo, aCallId );
       
  2832     
       
  2833     if ( errorCode == ECCPErrorNone )
       
  2834         {
       
  2835         TPEState callState;
       
  2836         callState = iCallHandling.GetCallState( aCallId );
       
  2837         TPECallType callType;
       
  2838 		callType = iDataStore.CallType( aCallId );
       
  2839 
       
  2840 	    errorCode = ECCPErrorNotFound;
       
  2841 	            
       
  2842         if ( EPEStateIdle == callState 
       
  2843              && EPECallTypeCSVoice == callType )
       
  2844             {
       
  2845             SetPhoneNumberForCallLogging( aCallId );
       
  2846             
       
  2847             errorCode = UpdateClientInfo( aCallId );       
       
  2848             
       
  2849             // Calls have to log also without a contact (ECCPErrorNotFound).
       
  2850             if ( errorCode == ECCPErrorNone || errorCode == ECCPErrorNotFound )
       
  2851                 {
       
  2852                 // Save the rest of information to EngineInfo.
       
  2853                 SetLoggingInfo( aCallId, callState );
       
  2854                 errorCode = iLogHandling.SaveCallEntry( aCallId );
       
  2855                 }
       
  2856             }
       
  2857         }
       
  2858     return errorCode;
       
  2859     }
       
  2860 
       
  2861 // -----------------------------------------------------------------------------
  2992 // CPEMessageHandler::HandleDialCall
  2862 // CPEMessageHandler::HandleDialCall
  2993 // Handles dial message from dial service
  2863 // Handles dial message from dial service
  2994 // 
  2864 // 
  2995 // -----------------------------------------------------------------------------
  2865 // -----------------------------------------------------------------------------
  2996 // 
  2866 // 
  3002     //TODO 
  2872     //TODO 
  3003     iModel.HandleInternalMessage( MPEPhoneModel::EPEMessageDialServiceCall );
  2873     iModel.HandleInternalMessage( MPEPhoneModel::EPEMessageDialServiceCall );
  3004     return errorCode;
  2874     return errorCode;
  3005     }
  2875     }
  3006 
  2876 
  3007 
       
  3008 // -----------------------------------------------------------------------------
       
  3009 // CPEMessageHandler::ExecuteKeySequenceL
       
  3010 // Only sequences which are not issued with send-key are handled here. SS 
       
  3011 // commands etc. are processed in HandleDialCallL().
       
  3012 // -----------------------------------------------------------------------------
       
  3013 //
       
  3014 TBool CPEMessageHandler::ExecuteKeySequenceL( const TDesC16 &aSequence )
       
  3015 {
       
  3016     TBool keySequenceProcessed( EFalse );
       
  3017     
       
  3018     iOptions->SetOptionStatus( KPhoneOptionInCall, 
       
  3019         ( iCallHandling.GetNumberOfCalls() > 0 ) );
       
  3020     iOptions->SetOptionStatus( KPhoneOptionSend, EFalse );
       
  3021     iOptions->SetOptionStatus( KPhoneOptionVoipCall, EFalse );
       
  3022     
       
  3023     if ( iParser->ParseL( aSequence, *iResult, *iOptions ) )
       
  3024         {
       
  3025         keySequenceProcessed = ETrue;
       
  3026         iGsmParserErrorCode = ECCPErrorNone;
       
  3027         iParserHandlerContainer->ProcessL( *iResult );
       
  3028         }
       
  3029     
       
  3030     return keySequenceProcessed;
       
  3031 }
       
  3032 
       
  3033 //  End of File
  2877 //  End of File