phoneengine/phonemodel/src/cpemessagehandler.cpp
branchRCL_3
changeset 62 5266b1f337bd
parent 61 41a7f70b3818
child 66 b0a26d6936b2
child 81 c26cc2a7c548
equal deleted inserted replaced
61:41a7f70b3818 62:5266b1f337bd
    48 #include <bldvariant.hrh>
    48 #include <bldvariant.hrh>
    49 #include <ccpdefs.h>
    49 #include <ccpdefs.h>
    50 #include <coreapplicationuisdomainpskeys.h>
    50 #include <coreapplicationuisdomainpskeys.h>
    51 #include <cpeclientinformation.h>
    51 #include <cpeclientinformation.h>
    52 #include <cpegsmaudiodata.h>
    52 #include <cpegsmaudiodata.h>
    53 #include <cphonegsmhandlercontainer.h>
    53 #include <CPhoneGsmHandlerContainer.h>
    54 #include <cphonegsmoptioncontainerbase.h>
    54 #include <CPhoneGsmOptionContainerBase.h>
    55 #include <cphonegsmparserbase.h>
    55 #include <CPhoneGsmParserBase.h>
    56 #include <cphonegsmparserresult.h>
    56 #include <CPhoneGsmParserResult.h>
    57 #include <featmgr.h>
    57 #include <featmgr.h>
    58 #include <mccecall.h>
    58 #include <mccecall.h>
    59 #include <mpeaudiodata.h>
    59 #include <mpeaudiodata.h>
    60 #include <mpecallhandling.h>
    60 #include <mpecallhandling.h>
    61 #include <mpecontacthandling.h>
    61 #include <mpecontacthandling.h>
    62 #include <mpedatastore.h>
    62 #include <mpedatastore.h>
    63 #include <mpeloghandling.h>
    63 #include <mpeloghandling.h>
    64 #include <pathinfo.h>
    64 #include <pathinfo.h>
    65 #include <pepanic.pan>
    65 #include <pepanic.pan>
    66 #include <phclttypes.h>
    66 #include <PhCltTypes.h>
    67 #include <phonegsmparser.h>
    67 #include <PhoneGsmParser.h>
    68 #include <ProfileEngineDomainConstants.h>
    68 #include <ProfileEngineDomainConstants.h>
    69 #include <talogger.h>
    69 #include <talogger.h>
    70 #include <w32std.h>
    70 #include <w32std.h>
    71 
    71 
    72 // EXTERNAL DATA STRUCTURES
    72 // EXTERNAL DATA STRUCTURES
    74 
    74 
    75 // EXTERNAL FUNCTION PROTOTYPES  
    75 // EXTERNAL FUNCTION PROTOTYPES  
    76 // None.
    76 // None.
    77 
    77 
    78 // CONSTANTS
    78 // CONSTANTS
    79 // Prefix change off. See SettingsInternalCRKeys.h
    79 // Prefix change off. See settingsinternalcrkeys.h
    80 const TInt KPEPrefixChangeOff = 0;
    80 const TInt KPEPrefixChangeOff = 0;
    81 // Prefix change on. See SettingsInternalCRKeys.h
    81 // Prefix change on. See settingsinternalcrkeys.h
    82 const TInt KPEPrefixChangeOn = 1;
    82 const TInt KPEPrefixChangeOn = 1;
    83 // International prefix
    83 // International prefix
    84 _LIT( KPEIntPrefix, "+" );
    84 _LIT( KPEIntPrefix, "+" );
    85 // Japan prefix
    85 // Japan prefix
    86 _LIT( KPEJapanPrefix, "+81" );
    86 _LIT( KPEJapanPrefix, "+81" );
   160             iLogHandling( aLogHandling ),
   160             iLogHandling( aLogHandling ),
   161             iContactHandling( aContactHandling ),
   161             iContactHandling( aContactHandling ),
   162             iExternalDataHandler( aExternalDataHandler ),
   162             iExternalDataHandler( aExternalDataHandler ),
   163             iSimStateMonitor( aSimStateMonitor ),
   163             iSimStateMonitor( aSimStateMonitor ),
   164             iFsSession( aFsSession ),
   164             iFsSession( aFsSession ),
       
   165 			iSwitchToVidCalReconFlag( EFalse ),
   165             iServiceHandling( aServiceHandling ),
   166             iServiceHandling( aServiceHandling ),
   166             iDataStore( *aModel.DataStore() )
   167             iDataStore( *aModel.DataStore() )
   167     {
   168     {
   168     }
   169     }
   169 
   170 
   401         }
   402         }
   402     return errorCode;
   403     return errorCode;
   403     }
   404     }
   404 
   405 
   405 // -----------------------------------------------------------------------------
   406 // -----------------------------------------------------------------------------
       
   407 // CPEMessageHandler::HandleReleaseConference
       
   408 // Handles release message from phone application
       
   409 // Method calls HangUp method from the CallHandling subsystem.
       
   410 // -----------------------------------------------------------------------------
       
   411 //
       
   412 TInt CPEMessageHandler::HandleReleaseConference()
       
   413     {
       
   414     
       
   415     return iCallHandling.ReleaseConference(); 
       
   416  
       
   417     }
       
   418 
       
   419 // -----------------------------------------------------------------------------
   406 // CPEMessageHandler::HandleSendDtmf
   420 // CPEMessageHandler::HandleSendDtmf
   407 // Handles send dtmf message from phone application
   421 // Handles send dtmf message from phone application
   408 // Method fetches dtmf string from the CPEEngineInfo class and then
   422 // Method fetches dtmf string from the CPEEngineInfo class and then
   409 // Method parses the DTMF string and then take action properly: 
   423 // Method parses the DTMF string and then take action properly: 
   410 // hard pause: triggers sending MEngineMonitor::EPEMessageStoppedDTMF 
   424 // hard pause: triggers sending MEngineMonitor::EPEMessageStoppedDTMF 
   451             iModel.SendMessage( MEngineMonitor::EPEMessageStoppedDTMF );
   465             iModel.SendMessage( MEngineMonitor::EPEMessageStoppedDTMF );
   452             }
   466             }
   453         
   467         
   454         dtmfString = KNullDesC;
   468         dtmfString = KNullDesC;
   455         }    
   469         }    
       
   470     else if ( dtmfString[ 0 ] == KPEDtmfPlusChar ) // speed-dial substitution
       
   471         {
       
   472         TEFLOGSTRING( KTAMESINT, "PE CPEMessageHandler::HandleSendDtmf(), Processing +" );
       
   473         HandlePlusSignInDtmf( dtmfString );
       
   474         dtmfString = KNullDesC;
       
   475         }
   456     else if ( dtmfString[ 0 ] == KPEDtmfPauseCharLowercase || 
   476     else if ( dtmfString[ 0 ] == KPEDtmfPauseCharLowercase || 
   457               dtmfString[ 0 ] == KPEDtmfPauseCharUppercase ) // soft pause
   477               dtmfString[ 0 ] == KPEDtmfPauseCharUppercase ) // soft pause
   458         {
   478         {
   459         TEFLOGSTRING( KTAMESINT, "PE CPEMessageHandler::HandleSendDtmf(), Processing P" );
   479         TEFLOGSTRING( KTAMESINT, "PE CPEMessageHandler::HandleSendDtmf(), Processing P" );
   460         
   480         
   525     CPEMessageHandler* self = static_cast<CPEMessageHandler*>(aAny);
   545     CPEMessageHandler* self = static_cast<CPEMessageHandler*>(aAny);
   526 
   546 
   527     delete self->iAsyncCallBack;
   547     delete self->iAsyncCallBack;
   528     self->iAsyncCallBack = NULL;
   548     self->iAsyncCallBack = NULL;
   529     return self->HandleSendDtmf();  
   549     return self->HandleSendDtmf();  
       
   550     }
       
   551 
       
   552 // -----------------------------------------------------------------------------
       
   553 // CPEMessageHandler::HandlePlusSignInDtmf
       
   554 // Handles plus (+) sign in a DTMF string.
       
   555 // -----------------------------------------------------------------------------
       
   556 //
       
   557 void CPEMessageHandler::HandlePlusSignInDtmf(const TPEDtmfString& aDtmfString )
       
   558     {
       
   559     TEFLOGSTRING2( KTAMESINT, "PE CPEMessageHandler::HandlePlusSignInDtmf(), aDtmfString: %S", &aDtmfString ); 
       
   560           
       
   561     // Find the SD index after the plus sign
       
   562     TPtrC validManualDTMFChars( KPEValidSpeedDialChars );
       
   563     TInt index = ECCPErrorNotFound;
       
   564     for ( index = 1 ; index < aDtmfString.Length() ; index++ )
       
   565         {
       
   566         if ( validManualDTMFChars.Locate( aDtmfString[index] ) == ECCPErrorNotFound )
       
   567             {
       
   568             TEFLOGSTRING( KTAMESINT, "PE CPEMessageHandler::HandlePlusSignInDtmf(), Not Found" ); 
       
   569             break; 
       
   570             }
       
   571         }
       
   572     TPESpeedDialSubstituionStatus sdStatus = EPEDtmfSpeedDialOk;
       
   573     
       
   574     // Empty string after the plus sign
       
   575     if ( index == 1 )
       
   576         {
       
   577         if ( aDtmfString.Length() > 1 )
       
   578             {
       
   579             // pw+ after the plus sign.
       
   580             sdStatus = EPEDtmfSpeedDialInvalidSpeedDial;
       
   581             }
       
   582         else
       
   583             {
       
   584             // string ended with the plus sign.
       
   585             sdStatus = EPEDtmfSpeedDialPromptUser;
       
   586             }
       
   587         // Clear DTMF string.
       
   588         iDataStore.SetDtmfString( KNullDesC() );
       
   589         }
       
   590     // Else if the SD location ends the DTMF string, move the index to the
       
   591     // last character instead of one over.
       
   592     else if ( index == aDtmfString.Length() )
       
   593         {
       
   594         index--;
       
   595         }
       
   596     
       
   597     // Check that the index is valid
       
   598     TInt sdIndex = ECCPErrorNotFound; 
       
   599     if ( sdStatus == EPEDtmfSpeedDialOk )
       
   600         {
       
   601         TLex lexer( aDtmfString.Mid( 1, index ) );
       
   602         // convert it to a number
       
   603         if ( lexer.Val(sdIndex) == ECCPErrorNone )
       
   604             {
       
   605             // Is it out of range
       
   606             if ( sdIndex < KPESpeedDialIndexMin  ||
       
   607                 sdIndex > KPESpeedDialIndexMax )
       
   608                 {
       
   609                 sdStatus = EPEDtmfSpeedDialInvalidSpeedDial;
       
   610                 }
       
   611             }
       
   612         else
       
   613             {
       
   614             sdStatus = EPEDtmfSpeedDialInvalidSpeedDial;
       
   615             }
       
   616         }
       
   617     
       
   618     // Fetch the SD location
       
   619     TPEPhoneNumber speedDialLocationString;
       
   620     if ( sdStatus == EPEDtmfSpeedDialOk )
       
   621         {
       
   622         TEFLOGSTRING2( KTAMESINT, "PE CPEMessageHandler::HandlePlusSignInDtmf(), SD location %i", sdIndex ); 
       
   623         if ( iContactHandling.GetSpeedDialLocation( 
       
   624             sdIndex, speedDialLocationString ) == ECCPErrorNone )
       
   625             {
       
   626             // Is content found
       
   627             if ( speedDialLocationString.Length() == 0)
       
   628                 {
       
   629                 sdStatus = EPEDtmfSpeedDialNotAssigned;
       
   630                 }
       
   631             else if ( speedDialLocationString[0] == KPEDtmfPlusChar)  
       
   632                 {
       
   633                 // plus char must be removed from dtmf string before sending
       
   634                 RemovePlusPrefix( speedDialLocationString );
       
   635                 }
       
   636             }
       
   637         else
       
   638             {
       
   639             sdStatus = EPEDtmfSpeedDialInvalidSpeedDial;
       
   640             }
       
   641         }
       
   642     
       
   643     // Now interpret the sdStatus to the next action
       
   644     switch ( sdStatus )
       
   645         {
       
   646         case EPEDtmfSpeedDialOk:
       
   647             {
       
   648             TEFLOGSTRING2( KTAMESINT, "PE CPEMessageHandler::HandlePlusSignInDtmf(), SD result: %S", &speedDialLocationString ); 
       
   649             // Take the SD location string and use that as new DTMF string
       
   650             iDataStore.SetDtmfStringCommand( speedDialLocationString );
       
   651             
       
   652             // Do recursion asyncronously                        
       
   653             TCallBack callBack( CallBackHandleSendDtmf, this );
       
   654             delete iAsyncCallBack;
       
   655             iAsyncCallBack = NULL;
       
   656             // Function does not allow to leave.
       
   657             iAsyncCallBack = new CAsyncCallBack( callBack, CActive::EPriorityStandard );
       
   658             if ( iAsyncCallBack )
       
   659                 {
       
   660                 iAsyncCallBack->CallBack();
       
   661                 }
       
   662             else
       
   663                 {
       
   664                 iModel.SendMessage( MEngineMonitor::EPEMessageDTMFSendingAborted );
       
   665                 }
       
   666             }
       
   667             break;
       
   668         case EPEDtmfSpeedDialPromptUser:
       
   669             // Speed dial location not given.
       
   670             iDataStore.SetDtmfString( KNullDesC() );
       
   671             iModel.SendMessage( MEngineMonitor::EPEMessagePromptSpeedDial );
       
   672             break;
       
   673         case EPEDtmfSpeedDialNotAssigned:
       
   674             // Speed dial location valid but not assigned
       
   675             iDataStore.SetDtmfString( KNullDesC() );
       
   676             iDataStore.SetDtmfStringCommand( KNullDesC() );
       
   677             iModel.SendMessage( MEngineMonitor::EPEMessageDTMFSendingAborted);
       
   678             iModel.SendMessage( MEngineMonitor::EPEMessageSpeedDialNotAssigned );
       
   679             break;
       
   680         case EPEDtmfSpeedDialInvalidSpeedDial:
       
   681             // Speed dial location invalid
       
   682             iDataStore.SetDtmfString( KNullDesC() );
       
   683             iDataStore.SetDtmfStringCommand( KNullDesC() );
       
   684             iModel.SendMessage( MEngineMonitor::EPEMessageDTMFSendingAborted);
       
   685             iModel.SendMessage( MEngineMonitor::EPEMessageInvalidSpeedDial );
       
   686             break;
       
   687         default:
       
   688             Panic( EPEPanicInvalidState );
       
   689             break;
       
   690         } // end switch
   530     }
   691     }
   531 
   692 
   532 // -----------------------------------------------------------------------------
   693 // -----------------------------------------------------------------------------
   533 // CPEMessageHandler::CheckPrefix
   694 // CPEMessageHandler::CheckPrefix
   534 // Checks the status of phone number prefix change setting
   695 // Checks the status of phone number prefix change setting
   933         "PE: CPEMessageHandler::RemoveInvalidChars, Parsed string = %S", 
  1094         "PE: CPEMessageHandler::RemoveInvalidChars, Parsed string = %S", 
   934         &aString);
  1095         &aString);
   935     return returnValue;
  1096     return returnValue;
   936     }
  1097     }
   937 
  1098 
       
  1099 
       
  1100 // -----------------------------------------------------------------------------
       
  1101 // CPEMessageHandler::HandleGetLifeTimerData
       
  1102 // Reads lifetimerdata from custom api and stores it to engine info
       
  1103 // -----------------------------------------------------------------------------
       
  1104 //
       
  1105 TInt CPEMessageHandler::HandleGetLifeTimerData() const
       
  1106     {
       
  1107     TCCPLifeTimeData lifeTimeData; 
       
  1108     TCCPLifeTimeDataPckg pckg( lifeTimeData );
       
  1109 
       
  1110     if ( iCallHandling.GetLifeTime( pckg ) )
       
  1111         {
       
  1112         TEFLOGSTRING2( 
       
  1113             KTAGENERAL, 
       
  1114             "PE: CPEMessageHandler::HandleGetLifeTimerData, iHours = %d", 
       
  1115             lifeTimeData.iHours);
       
  1116         TEFLOGSTRING2( 
       
  1117             KTAGENERAL, 
       
  1118             "PE: CPEMessageHandler::HandleGetLifeTimerData, iMinutes = %d", 
       
  1119             lifeTimeData.iMinutes);
       
  1120             
       
  1121         iDataStore.SetLifeTimerData( pckg );
       
  1122         }
       
  1123     
       
  1124     return ECCPErrorNone;
       
  1125     }
       
  1126     
   938 // -----------------------------------------------------------------------------
  1127 // -----------------------------------------------------------------------------
   939 // CPEMessageHandler::CallbackSendMessageStoppedDTMF
  1128 // CPEMessageHandler::CallbackSendMessageStoppedDTMF
   940 // -----------------------------------------------------------------------------
  1129 // -----------------------------------------------------------------------------
   941 //
  1130 //
   942 TInt CPEMessageHandler::CallbackSendMessageStoppedDTMF( TAny* aAny )
  1131 TInt CPEMessageHandler::CallbackSendMessageStoppedDTMF( TAny* aAny )
  1141     TEFLOGSTRING2( 
  1330     TEFLOGSTRING2( 
  1142         KTAINT, 
  1331         KTAINT, 
  1143         "PE CPEMessageHandler::UpdateClientInfo, allowmatch: %d", 
  1332         "PE CPEMessageHandler::UpdateClientInfo, allowmatch: %d", 
  1144         clientInformation.AllowMatch() );
  1333         clientInformation.AllowMatch() );
  1145     
  1334     
  1146     if ( EPECallOriginSAT != iDataStore.CallOrigin(aCallId) && 
  1335     if ( clientInformation.AllowMatch() && ( aCallId != KPEEmergencyCallId ) )
  1147        ( aCallId != KPEEmergencyCallId ) )
       
  1148         {
  1336         {
  1149         TEFLOGSTRING2( 
  1337         TEFLOGSTRING2( 
  1150             KTAINT, 
  1338             KTAINT, 
  1151             "PE CPEMessageHandler::UpdateClientInfo, match phone number: '%S'", 
  1339             "PE CPEMessageHandler::UpdateClientInfo, match phone number: '%S'", 
  1152             &iDataStore.RemotePhoneNumber( aCallId ) );
  1340             &iDataStore.RemotePhoneNumber( aCallId ) );
  1166         TEFLOGSTRING2( 
  1354         TEFLOGSTRING2( 
  1167             KTAINT, 
  1355             KTAINT, 
  1168             "PE CPEMessageHandler::UpdateClientInfo > MPEContactHandling::FindContactInfoSync( EPEFindWithPhoneNumber ), error code: %d", 
  1356             "PE CPEMessageHandler::UpdateClientInfo > MPEContactHandling::FindContactInfoSync( EPEFindWithPhoneNumber ), error code: %d", 
  1169             errorCode );
  1357             errorCode );
  1170         }
  1358         }
       
  1359     else if ( clientInformation.Name().Length() )
       
  1360         {
       
  1361         iDataStore.SetRemoteName( clientInformation.Name(), aCallId );
       
  1362         }
  1171     
  1363     
  1172     // Calls have to log also without a contact (ECCPErrorNotFound).
  1364     // Calls have to log also without a contact (ECCPErrorNotFound).
  1173     if ( errorCode == ECCPErrorNone || errorCode == ECCPErrorNotFound)
  1365     if ( errorCode == ECCPErrorNone || errorCode == ECCPErrorNotFound)
  1174         {
  1366         {
  1175         // Set name to EngineInfo
  1367         // Set name to EngineInfo
  1196     if ( iCallInfo->iEmergency || aCallId == KPEEmergencyCallId ) 
  1388     if ( iCallInfo->iEmergency || aCallId == KPEEmergencyCallId ) 
  1197         {
  1389         {
  1198         iDataStore.SetRemotePhoneNumberType( EPEEmergencyNumber, aCallId );
  1390         iDataStore.SetRemotePhoneNumberType( EPEEmergencyNumber, aCallId );
  1199         }
  1391         }
  1200     else if( iDataStore.CallDirection( aCallId ) != RMobileCall::EMobileOriginated )
  1392     else if( iDataStore.CallDirection( aCallId ) != RMobileCall::EMobileOriginated )
  1201         {
  1393 		{
  1202         switch( tempIdentity )
  1394 		switch( tempIdentity )
  1203             {
  1395 			{
  1204             case RMobileCall::ERemoteIdentitySuppressed:
  1396 			case RMobileCall::ERemoteIdentitySuppressed:
  1205                 {
  1397 				{
  1206                 // It is neccessary to perform an additional check for available
  1398 				// It is neccessary to perform an additional check for available
  1207                 // remote party phone number to comply with Italian operator
  1399 				// remote party phone number to comply with Italian operator
  1208                 // requirement: "If CLIR is active but network still provides
  1400 				// requirement: "If CLIR is active but network still provides
  1209                 // the device with a phone number, it should not be blocked
  1401 				// the device with a phone number, it should not be blocked
  1210                 // but passed to a client when requested."
  1402 				// but passed to a client when requested."
  1211                 if( iDataStore.RemotePhoneNumber( aCallId ).Length() == 0 )
  1403 				if( iDataStore.RemotePhoneNumber( aCallId ).Length() == 0 )
  1212                     {
  1404 					{
  1213                     HideIdentification( EPEPrivateNumber, aCallId );
  1405 					HideIdentification( EPEPrivateNumber, aCallId );
  1214                     }
  1406 					}
  1215                 else
  1407 				else
  1216                     {
  1408 				    {
  1217                     // Align remote identity with remote phone number availability.
  1409 				    // Align remote identity with remote phone number availability.
  1218                     iDataStore.SetRemoteIdentity( RMobileCall::ERemoteIdentityAvailable, aCallId );
  1410 				    iDataStore.SetRemoteIdentity( RMobileCall::ERemoteIdentityAvailable, aCallId );
  1219                     }
  1411 				    }
  1220                 break;
  1412 				break;
  1221                 }
  1413 				}
  1222             case RMobileCall::ERemoteIdentityAvailableNoCliRejectedByUser:
  1414 			case RMobileCall::ERemoteIdentityAvailableNoCliRejectedByUser:
  1223                 {
  1415 				{
  1224                 HideIdentification( EPEPrivateNumber, aCallId );
  1416 				HideIdentification( EPEPrivateNumber, aCallId );
  1225                 break;
  1417 				break;
  1226                 }
  1418 				}
  1227             case RMobileCall::ERemoteIdentityUnknown:
  1419 			case RMobileCall::ERemoteIdentityUnknown:
  1228             case RMobileCall::ERemoteIdentityAvailableNoCliInteractionWithOtherService:
  1420 			case RMobileCall::ERemoteIdentityAvailableNoCliInteractionWithOtherService:
  1229             case RMobileCall::ERemoteIdentityUnavailableNoCliInteractionWithOtherService:
  1421 			case RMobileCall::ERemoteIdentityUnavailableNoCliInteractionWithOtherService:
  1230             case RMobileCall::ERemoteIdentityAvailableNoCliCoinOrPayphone:
  1422 			case RMobileCall::ERemoteIdentityAvailableNoCliCoinOrPayphone:
  1231             case RMobileCall::ERemoteIdentityUnavailableNoCliCoinOrPayphone:
  1423 			case RMobileCall::ERemoteIdentityUnavailableNoCliCoinOrPayphone:
  1232             case RMobileCall::ERemoteIdentityAvailableNoCliUnavailable:
  1424 			case RMobileCall::ERemoteIdentityAvailableNoCliUnavailable:
  1233                 {
  1425 				{
  1234                 HideIdentification( EPEUnknownNumber, aCallId );
  1426 				HideIdentification( EPEUnknownNumber, aCallId );
  1235                 break;
  1427 				break;
  1236                 }
  1428 				}
  1237             case RMobileCall::ERemoteIdentityAvailable:
  1429 			case RMobileCall::ERemoteIdentityAvailable:
  1238             default:
  1430 			default:
  1239                 {
  1431 				{
  1240                 TEFLOGSTRING( KTAINT,
  1432 				TEFLOGSTRING( KTAINT,
  1241                     "PE CPEMessageHandler::CheckAndHideIdentity, CLI available" );
  1433 					"PE CPEMessageHandler::CheckAndHideIdentity, CLI available" );
  1242                 break;
  1434 				break;
  1243                 }
  1435 				}
  1244             }
  1436 			}
  1245         }
  1437 		}
  1246     }
  1438 	}
  1247     
  1439     
  1248 // -----------------------------------------------------------------------------
  1440 // -----------------------------------------------------------------------------
  1249 // CPEMessageHandler::FindCallInfo
  1441 // CPEMessageHandler::FindCallInfo
  1250 // Return callInfo from Etel/TSY.
  1442 // Return callInfo from Etel/TSY.
  1251 // -----------------------------------------------------------------------------
  1443 // -----------------------------------------------------------------------------
  1543                 }
  1735                 }
  1544              else 
  1736              else 
  1545                 {
  1737                 {
  1546 
  1738 
  1547                 dtmfString = iDataStore.DtmfPostFix( aCallId );
  1739                 dtmfString = iDataStore.DtmfPostFix( aCallId );
  1548                 
  1740 				
  1549                 if ( dtmfString.Length() > 0 )
  1741                 if ( dtmfString.Length() > 0 )
  1550                     {
  1742                     {
  1551                     iDataStore.SetDtmfStringCommand( dtmfString );
  1743                     iDataStore.SetDtmfStringCommand( dtmfString );
  1552                     errorCode = HandleSendDtmf();
  1744                     errorCode = HandleSendDtmf();
  1553                     }
  1745                     }
  1554                 }
  1746                 }
  1555 
  1747             // Reset unattended transfer callback flag
       
  1748             iDataStore.SetDoCallBackRequest( EFalse, aCallId );
       
  1749             
  1556             iDataStore.SetErrorCode( errorCode );
  1750             iDataStore.SetErrorCode( errorCode );
  1557             }
  1751             }  
  1558         }
  1752 		}
  1559     // For Sat call ( normal or emergency )    
  1753     // For Sat call ( normal or emergency )    
  1560     iClientServices->CallRequestMonitor()->SendRespond( ECCPErrorNone );
  1754     iClientServices->CallRequestMonitor()->SendRespond( ECCPErrorNone );
       
  1755     
       
  1756     
  1561     
  1757     
  1562     // Reset Phonenumber from engine info, this is necessary so that call number
  1758     // Reset Phonenumber from engine info, this is necessary so that call number
  1563     // logging works OK (see CPEMessageHandler::SetPhoneNumberForCallLogging).  
  1759     // logging works OK (see CPEMessageHandler::SetPhoneNumberForCallLogging).  
  1564     iDataStore.SetPhoneNumber( KNullDesC() );
  1760     iDataStore.SetPhoneNumber( KNullDesC() );
  1565     
  1761     
  1671     
  1867     
  1672     if ( aClientCall )
  1868     if ( aClientCall )
  1673         {
  1869         {
  1674         HandleClientCallData();
  1870         HandleClientCallData();
  1675         }
  1871         }
  1676     else 
  1872     else
  1677         {
  1873         {
  1678         iDataStore.SetCallOriginCommand(EPECallOriginPhone);
  1874         ResetClientCallData();
  1679 		ResetClientCallData();
       
  1680         }
  1875         }
  1681         
  1876         
  1682     //Get number of calls
  1877     //Get number of calls
  1683     numberOfCalls = iCallHandling.GetNumberOfCalls();
  1878     numberOfCalls = iCallHandling.GetNumberOfCalls();
  1684 
  1879 
  1685     // Check the phone number for prefix change and change the prefix if needed
  1880     // Check the phone number for prefix change and change the prefix if needed
  1686     CheckPrefix();
  1881     CheckPrefix();
  1687 
  1882 
  1688     phoneNumber = iDataStore.PhoneNumber();
  1883     if( iSwitchToVidCalReconFlag )
  1689   
  1884         {
       
  1885         phoneNumber = iDataStore.SwitchToNumberCommand();
       
  1886 		// Clear flag to match the previous set operation in HandleSwitchToVideoOrVoice() function.
       
  1887         iSwitchToVidCalReconFlag = EFalse;
       
  1888         }
       
  1889     else
       
  1890         {
       
  1891         phoneNumber = iDataStore.PhoneNumber();
       
  1892         }
       
  1893     
  1690     __ASSERT_ALWAYS( !( phoneNumber == KNullDesC ), User::Leave( ECCPErrorInvalidPhoneNumber ));
  1894     __ASSERT_ALWAYS( !( phoneNumber == KNullDesC ), User::Leave( ECCPErrorInvalidPhoneNumber ));
  1691     
  1895     
  1692     // Number parser operations
  1896     // Number parser operations
  1693     iOptions->SetOptionStatus( KPhoneOptionSend, ETrue );
  1897     iOptions->SetOptionStatus( KPhoneOptionSend, ETrue );
  1694     iOptions->SetOptionStatus( KPhoneOptionInCall, numberOfCalls > 0 );
  1898     iOptions->SetOptionStatus( KPhoneOptionInCall, numberOfCalls > 0 );
  1791 void CPEMessageHandler::HandleDialingStateL( 
  1995 void CPEMessageHandler::HandleDialingStateL( 
  1792         const TInt aCallId )
  1996         const TInt aCallId )
  1793     {
  1997     {
  1794     TEFLOGSTRING( KTAINT, "PE CPEMessageHandler::HandleDialingStateL <");
  1998     TEFLOGSTRING( KTAINT, "PE CPEMessageHandler::HandleDialingStateL <");
  1795     
  1999     
       
  2000     if( iCallHandling.GetNumberOfCalls() == 1 )
       
  2001         {
       
  2002         // Check volume levels - zero level needs to be reset to default value
       
  2003         iGsmAudioData.SetDefaultVolume();
       
  2004         }
  1796     // Save call direction to engine info.
  2005     // Save call direction to engine info.
  1797     iDataStore.SetCallDirection( RMobileCall::EMobileOriginated, aCallId );
  2006     iDataStore.SetCallDirection( RMobileCall::EMobileOriginated, aCallId );
  1798     
  2007     
  1799     // Log the call information.
  2008     // Log the call information.
  1800     User::LeaveIfError( HandleEngineInfo( aCallId ) );
  2009     User::LeaveIfError( HandleEngineInfo( aCallId ) );
  1845             "PE  CPEMessageHandler::HandleIncomingCallL: Calling iGsmAudioData->PlayInbandTone() for call waiting tone");
  2054             "PE  CPEMessageHandler::HandleIncomingCallL: Calling iGsmAudioData->PlayInbandTone() for call waiting tone");
  1846         iDataStore.SetInbandTone( ECCPCallWaiting );
  2055         iDataStore.SetInbandTone( ECCPCallWaiting );
  1847         iGsmAudioData.PlayInbandTone();
  2056         iGsmAudioData.PlayInbandTone();
  1848         iWaitingCallId = aCallId;
  2057         iWaitingCallId = aCallId;
  1849         }
  2058         }
  1850 
  2059     else if( numberOfCalls == 1 )
       
  2060         {
       
  2061         // Check volume levels - zero level needs to be reset to default value
       
  2062         iGsmAudioData.SetDefaultVolume();
       
  2063         }
  1851     if( AutomaticAnswer( aCallId ) )
  2064     if( AutomaticAnswer( aCallId ) )
  1852         {
  2065         {
  1853         TEFLOGSTRING( KTAINT, 
  2066         TEFLOGSTRING( KTAINT, 
  1854         "PE  CPEMessageHandler::HandleIncomingCallL: iAutomaticAnswerTimer->StartTimer");
  2067         "PE  CPEMessageHandler::HandleIncomingCallL: iAutomaticAnswerTimer->StartTimer");
  1855         iAutomaticAnswerTimer->StartTimer( KPEAutomaticAnswerTimeOut, MEngineMonitor::EPEMessageAnswer, aCallId );
  2068         iAutomaticAnswerTimer->StartTimer( KPEAutomaticAnswerTimeOut, MEngineMonitor::EPEMessageAnswer, aCallId );
  1871     {
  2084     {
  1872     TEFLOGSTRING( KTAINT, "PE CPEMessageHandler::HandleDisconnecting" );
  2085     TEFLOGSTRING( KTAINT, "PE CPEMessageHandler::HandleDisconnecting" );
  1873 
  2086 
  1874     iAutomaticAnswerTimer->Cancel();
  2087     iAutomaticAnswerTimer->Cancel();
  1875 
  2088 
  1876     TEFLOGSTRING( KTAMESOUT, 
  2089     // Prevent playing inband tone when phone is in silent mode and 
       
  2090     // audio output is not defined (call is  not connected).
       
  2091     if ( ( iDataStore.RingingType() != EProfileRingingTypeSilent ) || 
       
  2092          ( iDataStore.AudioOutput() != EPENotActive ) )
       
  2093         {
       
  2094         TEFLOGSTRING( KTAMESOUT, 
  1877         "PE CPEMessageHandler::HandleDisconnecting > iGsmAudioData.PlayInbandTone()");
  2095         "PE CPEMessageHandler::HandleDisconnecting > iGsmAudioData.PlayInbandTone()");
  1878     iGsmAudioData.PlayInbandTone();
  2096         iGsmAudioData.PlayInbandTone();
  1879     
  2097         }
       
  2098 
  1880     return ECCPErrorNone;
  2099     return ECCPErrorNone;
  1881     }
  2100     }
  1882 
  2101 
  1883 // -----------------------------------------------------------------------------
  2102 // -----------------------------------------------------------------------------
  1884 // CPEMessageHandler::HandleDisconnectingWithInband
  2103 // CPEMessageHandler::HandleDisconnectingWithInband
  2004     else
  2223     else
  2005         {
  2224         {
  2006         TEFLOGSTRING2( KTAMESINT, 
  2225         TEFLOGSTRING2( KTAMESINT, 
  2007             "CPEMessageHandler::HandleVoiceCallIdleState: numberOfCalls = %d", 
  2226             "CPEMessageHandler::HandleVoiceCallIdleState: numberOfCalls = %d", 
  2008             numberOfCalls );
  2227             numberOfCalls );
       
  2228         }
       
  2229     
       
  2230     if ( iDataStore.DoCallBackRequest( aCallId ) )
       
  2231         {
       
  2232         iModel.SendMessage( MEngineMonitor::EPEMessageTransferCallBackRequest, aCallId );
  2009         }
  2233         }
  2010     
  2234     
  2011     iDataStore.ResetCallInfo( aCallId );    
  2235     iDataStore.ResetCallInfo( aCallId );    
  2012     
  2236     
  2013     //publish remote party info to Mediator after call info has been cleared.
  2237     //publish remote party info to Mediator after call info has been cleared.
  2402 // -----------------------------------------------------------------------------
  2626 // -----------------------------------------------------------------------------
  2403 // CPEMessageHandler::IsEmergencyAllowed()
  2627 // CPEMessageHandler::IsEmergencyAllowed()
  2404 // Checks if emergency call is allowed. 
  2628 // Checks if emergency call is allowed. 
  2405 // -----------------------------------------------------------------------------
  2629 // -----------------------------------------------------------------------------
  2406 //
  2630 //
  2407 TBool CPEMessageHandler::IsNetworkConnectionAllowed() const
  2631 TBool CPEMessageHandler::IsEmergencyAllowed() const
  2408     {
  2632     {
  2409     TBool networkConnectionAllowed( EFalse );
  2633     TBool networkConnectionAllowed( EFalse );
  2410     //It is safe to ignore error code here: a default value of EFalse is used if the get fails
  2634     //It is safe to ignore error code here: a default value of EFalse is used if the get fails
  2411     iExternalDataHandler.Get( EPENetworkConnectionAllowedSetting, networkConnectionAllowed );
  2635     iExternalDataHandler.Get( EPENetworkConnectionAllowedSetting, networkConnectionAllowed );
  2412     return networkConnectionAllowed;
  2636     return networkConnectionAllowed;
  2509         if ( iDataStore.CallDirection( aCallId ) == RMobileCall::EMobileOriginated )
  2733         if ( iDataStore.CallDirection( aCallId ) == RMobileCall::EMobileOriginated )
  2510             {
  2734             {
  2511             iDataStore.SetSwitchToNumberCommand( iDataStore.WholeOutgoingPhoneNumber( aCallId ) );  
  2735             iDataStore.SetSwitchToNumberCommand( iDataStore.WholeOutgoingPhoneNumber( aCallId ) );  
  2512             // Clear phonenumber to prevent using the wrong number in MO video call.
  2736             // Clear phonenumber to prevent using the wrong number in MO video call.
  2513             iDataStore.SetPhoneNumber( KNullDesC() );
  2737             iDataStore.SetPhoneNumber( KNullDesC() );
       
  2738             iSwitchToVidCalReconFlag = ETrue;
  2514             }
  2739             }
  2515         else
  2740         else
  2516             {
  2741             {
  2517             iDataStore.SetSwitchToNumberCommand( iDataStore.RemotePhoneNumber( aCallId ) );
  2742             iDataStore.SetSwitchToNumberCommand( iDataStore.RemotePhoneNumber( aCallId ) );
  2518             // Remote phone number must be stored as the phone number in case of low-memory situation where 
  2743             // Remote phone number must be stored as the phone number in case of low-memory situation where 
  2537         "PE CPEMessageHandler::ContinueSwitchToCall, aCallId : %d", aCallId );
  2762         "PE CPEMessageHandler::ContinueSwitchToCall, aCallId : %d", aCallId );
  2538     TInt callId;
  2763     TInt callId;
  2539     TInt errorCode( ECCPErrorNone );
  2764     TInt errorCode( ECCPErrorNone );
  2540   
  2765   
  2541     TPEPhoneNumber phoneNumber = iDataStore.SwitchToNumberCommand();
  2766     TPEPhoneNumber phoneNumber = iDataStore.SwitchToNumberCommand();
       
  2767     RemovePreAndPostFix( phoneNumber );
       
  2768     
  2542     TEFLOGSTRING2( KTAINT, 
  2769     TEFLOGSTRING2( KTAINT, 
  2543         "PE CPEMessageHandler::ContinueSwitchToCall, phoneNumber : %S", 
  2770         "PE CPEMessageHandler::ContinueSwitchToCall, phoneNumber : %S", 
  2544         &phoneNumber );
  2771         &phoneNumber );
  2545 
  2772 
  2546     // Check is current call voice or video
  2773     // Check is current call voice or video
  2671     {
  2898     {
  2672     return iCallHandling.ReplaceActive();
  2899     return iCallHandling.ReplaceActive();
  2673     }
  2900     }
  2674 
  2901 
  2675 // -----------------------------------------------------------------------------
  2902 // -----------------------------------------------------------------------------
  2676 // CPEMessageHandler::CheckIfPhoneIsLockedL
       
  2677 // -----------------------------------------------------------------------------
       
  2678 //
       
  2679 void CPEMessageHandler::CheckIfPhoneIsLockedL()
       
  2680     {
       
  2681     // Check if phone is locked
       
  2682     TInt  keyLockStatus( EAutolockStatusUninitialized );
       
  2683     TInt err = RProperty::Get( KPSUidCoreApplicationUIs, KCoreAppUIsAutolockStatus, keyLockStatus );
       
  2684     const TBool phoneIsLocked = ( keyLockStatus > EAutolockOff );
       
  2685 
       
  2686     if ( phoneIsLocked && err == KErrNone )
       
  2687         {
       
  2688         // New call is not possible if device lock is on 
       
  2689         TEFLOGSTRING2( KTAERROR,
       
  2690             "PE CPEMessageHandler::CheckIfPhoneIsLockedL, keyLockStatus : %d", keyLockStatus );
       
  2691         User::Leave( ECCPErrorAuthenticationFailed );
       
  2692         }
       
  2693     }
       
  2694 
       
  2695 // -----------------------------------------------------------------------------
       
  2696 // CPEMessageHandler::IsActiveVideo
  2903 // CPEMessageHandler::IsActiveVideo
  2697 // Checks if there are any connected video calls
  2904 // Checks if there are any connected video calls
  2698 // -----------------------------------------------------------------------------
  2905 // -----------------------------------------------------------------------------
  2699 // 
  2906 // 
  2700 TBool CPEMessageHandler::IsActiveVideo()
  2907 TBool CPEMessageHandler::IsActiveVideo()
  2723 
  2930 
  2724 // -----------------------------------------------------------------------------
  2931 // -----------------------------------------------------------------------------
  2725 // CPEMessageHandler::HandleRemotePartyInfoChanged
  2932 // CPEMessageHandler::HandleRemotePartyInfoChanged
  2726 // -----------------------------------------------------------------------------
  2933 // -----------------------------------------------------------------------------
  2727 //
  2934 //
  2728 void CPEMessageHandler::HandleRemotePartyInfoChanged( const TInt /*aCallId*/ )
  2935 void CPEMessageHandler::HandleRemotePartyInfoChanged( const TInt aCallId )
  2729     {        
  2936     {        
  2730     UpdateRemotePartyInfo(); 
  2937     UpdateRemotePartyInfo(); 
  2731         
  2938         
  2732     }
  2939     }
  2733 
  2940 
  2760     {
  2967     {
  2761     TEFLOGSTRING( KTAINT, "PE CPEMessageHandler::HandleUnattendedTransfer ");
  2968     TEFLOGSTRING( KTAINT, "PE CPEMessageHandler::HandleUnattendedTransfer ");
  2762     TInt errorCode = iCallHandling.DoUnattendedTransfer( 
  2969     TInt errorCode = iCallHandling.DoUnattendedTransfer( 
  2763             iDataStore.TransferTargetCommand() );
  2970             iDataStore.TransferTargetCommand() );
  2764      
  2971      
       
  2972     iDataStore.SetErrorCode( errorCode );
       
  2973     
  2765     return errorCode;
  2974     return errorCode;
  2766     }
  2975     }
  2767 
  2976 
  2768 // -----------------------------------------------------------------------------
  2977 // -----------------------------------------------------------------------------
  2769 // CPEMessageHandler::ForwardCallToAddress
  2978 // CPEMessageHandler::ForwardCallToAddress
  2855                 }
  3064                 }
  2856             }
  3065             }
  2857         }
  3066         }
  2858     return errorCode;
  3067     return errorCode;
  2859     }
  3068     }
  2860 
  3069 //  End of File  
  2861 // -----------------------------------------------------------------------------
       
  2862 // CPEMessageHandler::HandleDialCall
       
  2863 // Handles dial message from dial service
       
  2864 // 
       
  2865 // -----------------------------------------------------------------------------
       
  2866 // 
       
  2867 TInt CPEMessageHandler::HandleDialServiceCall(
       
  2868     const TBool /*aClientCall*/ )
       
  2869     {
       
  2870     TEFLOGSTRING( KTAINT, "PE CPEMessageHandler::HandleDialCall" );
       
  2871     TInt errorCode( ECCPErrorNone );
       
  2872     //TODO 
       
  2873     iModel.HandleInternalMessage( MPEPhoneModel::EPEMessageDialServiceCall );
       
  2874     return errorCode;
       
  2875     }
       
  2876 
       
  2877 //  End of File