phoneengine/phonemodel/src/cpemessagehandler.cpp
branchRCL_3
changeset 61 41a7f70b3818
parent 58 40a3f856b14d
child 62 5266b1f337bd
equal deleted inserted replaced
58:40a3f856b14d 61:41a7f70b3818
    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 ),
       
   166             iServiceHandling( aServiceHandling ),
   165             iServiceHandling( aServiceHandling ),
   167             iDataStore( *aModel.DataStore() )
   166             iDataStore( *aModel.DataStore() )
   168     {
   167     {
   169     }
   168     }
   170 
   169 
   402         }
   401         }
   403     return errorCode;
   402     return errorCode;
   404     }
   403     }
   405 
   404 
   406 // -----------------------------------------------------------------------------
   405 // -----------------------------------------------------------------------------
   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 // -----------------------------------------------------------------------------
       
   420 // CPEMessageHandler::HandleSendDtmf
   406 // CPEMessageHandler::HandleSendDtmf
   421 // Handles send dtmf message from phone application
   407 // Handles send dtmf message from phone application
   422 // Method fetches dtmf string from the CPEEngineInfo class and then
   408 // Method fetches dtmf string from the CPEEngineInfo class and then
   423 // Method parses the DTMF string and then take action properly: 
   409 // Method parses the DTMF string and then take action properly: 
   424 // hard pause: triggers sending MEngineMonitor::EPEMessageStoppedDTMF 
   410 // hard pause: triggers sending MEngineMonitor::EPEMessageStoppedDTMF 
   465             iModel.SendMessage( MEngineMonitor::EPEMessageStoppedDTMF );
   451             iModel.SendMessage( MEngineMonitor::EPEMessageStoppedDTMF );
   466             }
   452             }
   467         
   453         
   468         dtmfString = KNullDesC;
   454         dtmfString = KNullDesC;
   469         }    
   455         }    
   470     else if ( dtmfString[ 0 ] == KPEDtmfPlusChar ) // speed-dial substitution
       
   471         {
       
   472         TEFLOGSTRING( KTAMESINT, "PE CPEMessageHandler::HandleSendDtmf(), Processing +" );
       
   473         HandlePlusSignInDtmf( dtmfString );
       
   474         dtmfString = KNullDesC;
       
   475         }
       
   476     else if ( dtmfString[ 0 ] == KPEDtmfPauseCharLowercase || 
   456     else if ( dtmfString[ 0 ] == KPEDtmfPauseCharLowercase || 
   477               dtmfString[ 0 ] == KPEDtmfPauseCharUppercase ) // soft pause
   457               dtmfString[ 0 ] == KPEDtmfPauseCharUppercase ) // soft pause
   478         {
   458         {
   479         TEFLOGSTRING( KTAMESINT, "PE CPEMessageHandler::HandleSendDtmf(), Processing P" );
   459         TEFLOGSTRING( KTAMESINT, "PE CPEMessageHandler::HandleSendDtmf(), Processing P" );
   480         
   460         
   545     CPEMessageHandler* self = static_cast<CPEMessageHandler*>(aAny);
   525     CPEMessageHandler* self = static_cast<CPEMessageHandler*>(aAny);
   546 
   526 
   547     delete self->iAsyncCallBack;
   527     delete self->iAsyncCallBack;
   548     self->iAsyncCallBack = NULL;
   528     self->iAsyncCallBack = NULL;
   549     return self->HandleSendDtmf();  
   529     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
       
   691     }
   530     }
   692 
   531 
   693 // -----------------------------------------------------------------------------
   532 // -----------------------------------------------------------------------------
   694 // CPEMessageHandler::CheckPrefix
   533 // CPEMessageHandler::CheckPrefix
   695 // Checks the status of phone number prefix change setting
   534 // Checks the status of phone number prefix change setting
  1094         "PE: CPEMessageHandler::RemoveInvalidChars, Parsed string = %S", 
   933         "PE: CPEMessageHandler::RemoveInvalidChars, Parsed string = %S", 
  1095         &aString);
   934         &aString);
  1096     return returnValue;
   935     return returnValue;
  1097     }
   936     }
  1098 
   937 
  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     
       
  1127 // -----------------------------------------------------------------------------
   938 // -----------------------------------------------------------------------------
  1128 // CPEMessageHandler::CallbackSendMessageStoppedDTMF
   939 // CPEMessageHandler::CallbackSendMessageStoppedDTMF
  1129 // -----------------------------------------------------------------------------
   940 // -----------------------------------------------------------------------------
  1130 //
   941 //
  1131 TInt CPEMessageHandler::CallbackSendMessageStoppedDTMF( TAny* aAny )
   942 TInt CPEMessageHandler::CallbackSendMessageStoppedDTMF( TAny* aAny )
  1330     TEFLOGSTRING2( 
  1141     TEFLOGSTRING2( 
  1331         KTAINT, 
  1142         KTAINT, 
  1332         "PE CPEMessageHandler::UpdateClientInfo, allowmatch: %d", 
  1143         "PE CPEMessageHandler::UpdateClientInfo, allowmatch: %d", 
  1333         clientInformation.AllowMatch() );
  1144         clientInformation.AllowMatch() );
  1334     
  1145     
  1335     if ( clientInformation.AllowMatch() && ( aCallId != KPEEmergencyCallId ) )
  1146     if ( EPECallOriginSAT != iDataStore.CallOrigin(aCallId) && 
       
  1147        ( aCallId != KPEEmergencyCallId ) )
  1336         {
  1148         {
  1337         TEFLOGSTRING2( 
  1149         TEFLOGSTRING2( 
  1338             KTAINT, 
  1150             KTAINT, 
  1339             "PE CPEMessageHandler::UpdateClientInfo, match phone number: '%S'", 
  1151             "PE CPEMessageHandler::UpdateClientInfo, match phone number: '%S'", 
  1340             &iDataStore.RemotePhoneNumber( aCallId ) );
  1152             &iDataStore.RemotePhoneNumber( aCallId ) );
  1354         TEFLOGSTRING2( 
  1166         TEFLOGSTRING2( 
  1355             KTAINT, 
  1167             KTAINT, 
  1356             "PE CPEMessageHandler::UpdateClientInfo > MPEContactHandling::FindContactInfoSync( EPEFindWithPhoneNumber ), error code: %d", 
  1168             "PE CPEMessageHandler::UpdateClientInfo > MPEContactHandling::FindContactInfoSync( EPEFindWithPhoneNumber ), error code: %d", 
  1357             errorCode );
  1169             errorCode );
  1358         }
  1170         }
  1359     else if ( clientInformation.Name().Length() )
       
  1360         {
       
  1361         iDataStore.SetRemoteName( clientInformation.Name(), aCallId );
       
  1362         }
       
  1363     
  1171     
  1364     // Calls have to log also without a contact (ECCPErrorNotFound).
  1172     // Calls have to log also without a contact (ECCPErrorNotFound).
  1365     if ( errorCode == ECCPErrorNone || errorCode == ECCPErrorNotFound)
  1173     if ( errorCode == ECCPErrorNone || errorCode == ECCPErrorNotFound)
  1366         {
  1174         {
  1367         // Set name to EngineInfo
  1175         // Set name to EngineInfo
  1388     if ( iCallInfo->iEmergency || aCallId == KPEEmergencyCallId ) 
  1196     if ( iCallInfo->iEmergency || aCallId == KPEEmergencyCallId ) 
  1389         {
  1197         {
  1390         iDataStore.SetRemotePhoneNumberType( EPEEmergencyNumber, aCallId );
  1198         iDataStore.SetRemotePhoneNumberType( EPEEmergencyNumber, aCallId );
  1391         }
  1199         }
  1392     else if( iDataStore.CallDirection( aCallId ) != RMobileCall::EMobileOriginated )
  1200     else if( iDataStore.CallDirection( aCallId ) != RMobileCall::EMobileOriginated )
  1393 		{
  1201         {
  1394 		switch( tempIdentity )
  1202         switch( tempIdentity )
  1395 			{
  1203             {
  1396 			case RMobileCall::ERemoteIdentitySuppressed:
  1204             case RMobileCall::ERemoteIdentitySuppressed:
  1397 				{
  1205                 {
  1398 				// It is neccessary to perform an additional check for available
  1206                 // It is neccessary to perform an additional check for available
  1399 				// remote party phone number to comply with Italian operator
  1207                 // remote party phone number to comply with Italian operator
  1400 				// requirement: "If CLIR is active but network still provides
  1208                 // requirement: "If CLIR is active but network still provides
  1401 				// the device with a phone number, it should not be blocked
  1209                 // the device with a phone number, it should not be blocked
  1402 				// but passed to a client when requested."
  1210                 // but passed to a client when requested."
  1403 				if( iDataStore.RemotePhoneNumber( aCallId ).Length() == 0 )
  1211                 if( iDataStore.RemotePhoneNumber( aCallId ).Length() == 0 )
  1404 					{
  1212                     {
  1405 					HideIdentification( EPEPrivateNumber, aCallId );
  1213                     HideIdentification( EPEPrivateNumber, aCallId );
  1406 					}
  1214                     }
  1407 				else
  1215                 else
  1408 				    {
  1216                     {
  1409 				    // Align remote identity with remote phone number availability.
  1217                     // Align remote identity with remote phone number availability.
  1410 				    iDataStore.SetRemoteIdentity( RMobileCall::ERemoteIdentityAvailable, aCallId );
  1218                     iDataStore.SetRemoteIdentity( RMobileCall::ERemoteIdentityAvailable, aCallId );
  1411 				    }
  1219                     }
  1412 				break;
  1220                 break;
  1413 				}
  1221                 }
  1414 			case RMobileCall::ERemoteIdentityAvailableNoCliRejectedByUser:
  1222             case RMobileCall::ERemoteIdentityAvailableNoCliRejectedByUser:
  1415 				{
  1223                 {
  1416 				HideIdentification( EPEPrivateNumber, aCallId );
  1224                 HideIdentification( EPEPrivateNumber, aCallId );
  1417 				break;
  1225                 break;
  1418 				}
  1226                 }
  1419 			case RMobileCall::ERemoteIdentityUnknown:
  1227             case RMobileCall::ERemoteIdentityUnknown:
  1420 			case RMobileCall::ERemoteIdentityAvailableNoCliInteractionWithOtherService:
  1228             case RMobileCall::ERemoteIdentityAvailableNoCliInteractionWithOtherService:
  1421 			case RMobileCall::ERemoteIdentityUnavailableNoCliInteractionWithOtherService:
  1229             case RMobileCall::ERemoteIdentityUnavailableNoCliInteractionWithOtherService:
  1422 			case RMobileCall::ERemoteIdentityAvailableNoCliCoinOrPayphone:
  1230             case RMobileCall::ERemoteIdentityAvailableNoCliCoinOrPayphone:
  1423 			case RMobileCall::ERemoteIdentityUnavailableNoCliCoinOrPayphone:
  1231             case RMobileCall::ERemoteIdentityUnavailableNoCliCoinOrPayphone:
  1424 			case RMobileCall::ERemoteIdentityAvailableNoCliUnavailable:
  1232             case RMobileCall::ERemoteIdentityAvailableNoCliUnavailable:
  1425 				{
  1233                 {
  1426 				HideIdentification( EPEUnknownNumber, aCallId );
  1234                 HideIdentification( EPEUnknownNumber, aCallId );
  1427 				break;
  1235                 break;
  1428 				}
  1236                 }
  1429 			case RMobileCall::ERemoteIdentityAvailable:
  1237             case RMobileCall::ERemoteIdentityAvailable:
  1430 			default:
  1238             default:
  1431 				{
  1239                 {
  1432 				TEFLOGSTRING( KTAINT,
  1240                 TEFLOGSTRING( KTAINT,
  1433 					"PE CPEMessageHandler::CheckAndHideIdentity, CLI available" );
  1241                     "PE CPEMessageHandler::CheckAndHideIdentity, CLI available" );
  1434 				break;
  1242                 break;
  1435 				}
  1243                 }
  1436 			}
  1244             }
  1437 		}
  1245         }
  1438 	}
  1246     }
  1439     
  1247     
  1440 // -----------------------------------------------------------------------------
  1248 // -----------------------------------------------------------------------------
  1441 // CPEMessageHandler::FindCallInfo
  1249 // CPEMessageHandler::FindCallInfo
  1442 // Return callInfo from Etel/TSY.
  1250 // Return callInfo from Etel/TSY.
  1443 // -----------------------------------------------------------------------------
  1251 // -----------------------------------------------------------------------------
  1735                 }
  1543                 }
  1736              else 
  1544              else 
  1737                 {
  1545                 {
  1738 
  1546 
  1739                 dtmfString = iDataStore.DtmfPostFix( aCallId );
  1547                 dtmfString = iDataStore.DtmfPostFix( aCallId );
  1740 				
  1548                 
  1741                 if ( dtmfString.Length() > 0 )
  1549                 if ( dtmfString.Length() > 0 )
  1742                     {
  1550                     {
  1743                     iDataStore.SetDtmfStringCommand( dtmfString );
  1551                     iDataStore.SetDtmfStringCommand( dtmfString );
  1744                     errorCode = HandleSendDtmf();
  1552                     errorCode = HandleSendDtmf();
  1745                     }
  1553                     }
  1746                 }
  1554                 }
  1747             // Reset unattended transfer callback flag
  1555 
  1748             iDataStore.SetDoCallBackRequest( EFalse, aCallId );
       
  1749             
       
  1750             iDataStore.SetErrorCode( errorCode );
  1556             iDataStore.SetErrorCode( errorCode );
  1751             }  
  1557             }
  1752 		}
  1558         }
  1753     // For Sat call ( normal or emergency )    
  1559     // For Sat call ( normal or emergency )    
  1754     iClientServices->CallRequestMonitor()->SendRespond( ECCPErrorNone );
  1560     iClientServices->CallRequestMonitor()->SendRespond( ECCPErrorNone );
  1755     
       
  1756     
       
  1757     
  1561     
  1758     // 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
  1759     // logging works OK (see CPEMessageHandler::SetPhoneNumberForCallLogging).  
  1563     // logging works OK (see CPEMessageHandler::SetPhoneNumberForCallLogging).  
  1760     iDataStore.SetPhoneNumber( KNullDesC() );
  1564     iDataStore.SetPhoneNumber( KNullDesC() );
  1761     
  1565     
  1867     
  1671     
  1868     if ( aClientCall )
  1672     if ( aClientCall )
  1869         {
  1673         {
  1870         HandleClientCallData();
  1674         HandleClientCallData();
  1871         }
  1675         }
  1872     else
  1676     else 
  1873         {
  1677         {
  1874         ResetClientCallData();
  1678         iDataStore.SetCallOriginCommand(EPECallOriginPhone);
       
  1679 		ResetClientCallData();
  1875         }
  1680         }
  1876         
  1681         
  1877     //Get number of calls
  1682     //Get number of calls
  1878     numberOfCalls = iCallHandling.GetNumberOfCalls();
  1683     numberOfCalls = iCallHandling.GetNumberOfCalls();
  1879 
  1684 
  1880     // Check the phone number for prefix change and change the prefix if needed
  1685     // Check the phone number for prefix change and change the prefix if needed
  1881     CheckPrefix();
  1686     CheckPrefix();
  1882 
  1687 
  1883     if( iSwitchToVidCalReconFlag )
  1688     phoneNumber = iDataStore.PhoneNumber();
  1884         {
  1689   
  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     
       
  1894     __ASSERT_ALWAYS( !( phoneNumber == KNullDesC ), User::Leave( ECCPErrorInvalidPhoneNumber ));
  1690     __ASSERT_ALWAYS( !( phoneNumber == KNullDesC ), User::Leave( ECCPErrorInvalidPhoneNumber ));
  1895     
  1691     
  1896     // Number parser operations
  1692     // Number parser operations
  1897     iOptions->SetOptionStatus( KPhoneOptionSend, ETrue );
  1693     iOptions->SetOptionStatus( KPhoneOptionSend, ETrue );
  1898     iOptions->SetOptionStatus( KPhoneOptionInCall, numberOfCalls > 0 );
  1694     iOptions->SetOptionStatus( KPhoneOptionInCall, numberOfCalls > 0 );
  1995 void CPEMessageHandler::HandleDialingStateL( 
  1791 void CPEMessageHandler::HandleDialingStateL( 
  1996         const TInt aCallId )
  1792         const TInt aCallId )
  1997     {
  1793     {
  1998     TEFLOGSTRING( KTAINT, "PE CPEMessageHandler::HandleDialingStateL <");
  1794     TEFLOGSTRING( KTAINT, "PE CPEMessageHandler::HandleDialingStateL <");
  1999     
  1795     
  2000     if( iCallHandling.GetNumberOfCalls() == 1 )
       
  2001         {
       
  2002         // Check volume levels - zero level needs to be reset to default value
       
  2003         iGsmAudioData.SetDefaultVolume();
       
  2004         }
       
  2005     // Save call direction to engine info.
  1796     // Save call direction to engine info.
  2006     iDataStore.SetCallDirection( RMobileCall::EMobileOriginated, aCallId );
  1797     iDataStore.SetCallDirection( RMobileCall::EMobileOriginated, aCallId );
  2007     
  1798     
  2008     // Log the call information.
  1799     // Log the call information.
  2009     User::LeaveIfError( HandleEngineInfo( aCallId ) );
  1800     User::LeaveIfError( HandleEngineInfo( aCallId ) );
  2054             "PE  CPEMessageHandler::HandleIncomingCallL: Calling iGsmAudioData->PlayInbandTone() for call waiting tone");
  1845             "PE  CPEMessageHandler::HandleIncomingCallL: Calling iGsmAudioData->PlayInbandTone() for call waiting tone");
  2055         iDataStore.SetInbandTone( ECCPCallWaiting );
  1846         iDataStore.SetInbandTone( ECCPCallWaiting );
  2056         iGsmAudioData.PlayInbandTone();
  1847         iGsmAudioData.PlayInbandTone();
  2057         iWaitingCallId = aCallId;
  1848         iWaitingCallId = aCallId;
  2058         }
  1849         }
  2059     else if( numberOfCalls == 1 )
  1850 
  2060         {
       
  2061         // Check volume levels - zero level needs to be reset to default value
       
  2062         iGsmAudioData.SetDefaultVolume();
       
  2063         }
       
  2064     if( AutomaticAnswer( aCallId ) )
  1851     if( AutomaticAnswer( aCallId ) )
  2065         {
  1852         {
  2066         TEFLOGSTRING( KTAINT, 
  1853         TEFLOGSTRING( KTAINT, 
  2067         "PE  CPEMessageHandler::HandleIncomingCallL: iAutomaticAnswerTimer->StartTimer");
  1854         "PE  CPEMessageHandler::HandleIncomingCallL: iAutomaticAnswerTimer->StartTimer");
  2068         iAutomaticAnswerTimer->StartTimer( KPEAutomaticAnswerTimeOut, MEngineMonitor::EPEMessageAnswer, aCallId );
  1855         iAutomaticAnswerTimer->StartTimer( KPEAutomaticAnswerTimeOut, MEngineMonitor::EPEMessageAnswer, aCallId );
  2084     {
  1871     {
  2085     TEFLOGSTRING( KTAINT, "PE CPEMessageHandler::HandleDisconnecting" );
  1872     TEFLOGSTRING( KTAINT, "PE CPEMessageHandler::HandleDisconnecting" );
  2086 
  1873 
  2087     iAutomaticAnswerTimer->Cancel();
  1874     iAutomaticAnswerTimer->Cancel();
  2088 
  1875 
  2089     // Prevent playing inband tone when phone is in silent mode and 
  1876     TEFLOGSTRING( KTAMESOUT, 
  2090     // audio output is not defined (call is  not connected).
       
  2091     if ( ( iDataStore.RingingType() != EProfileRingingTypeSilent ) || 
       
  2092          ( iDataStore.AudioOutput() != EPENotActive ) )
       
  2093         {
       
  2094         TEFLOGSTRING( KTAMESOUT, 
       
  2095         "PE CPEMessageHandler::HandleDisconnecting > iGsmAudioData.PlayInbandTone()");
  1877         "PE CPEMessageHandler::HandleDisconnecting > iGsmAudioData.PlayInbandTone()");
  2096         iGsmAudioData.PlayInbandTone();
  1878     iGsmAudioData.PlayInbandTone();
  2097         }
  1879     
  2098 
       
  2099     return ECCPErrorNone;
  1880     return ECCPErrorNone;
  2100     }
  1881     }
  2101 
  1882 
  2102 // -----------------------------------------------------------------------------
  1883 // -----------------------------------------------------------------------------
  2103 // CPEMessageHandler::HandleDisconnectingWithInband
  1884 // CPEMessageHandler::HandleDisconnectingWithInband
  2223     else
  2004     else
  2224         {
  2005         {
  2225         TEFLOGSTRING2( KTAMESINT, 
  2006         TEFLOGSTRING2( KTAMESINT, 
  2226             "CPEMessageHandler::HandleVoiceCallIdleState: numberOfCalls = %d", 
  2007             "CPEMessageHandler::HandleVoiceCallIdleState: numberOfCalls = %d", 
  2227             numberOfCalls );
  2008             numberOfCalls );
  2228         }
       
  2229     
       
  2230     if ( iDataStore.DoCallBackRequest( aCallId ) )
       
  2231         {
       
  2232         iModel.SendMessage( MEngineMonitor::EPEMessageTransferCallBackRequest, aCallId );
       
  2233         }
  2009         }
  2234     
  2010     
  2235     iDataStore.ResetCallInfo( aCallId );    
  2011     iDataStore.ResetCallInfo( aCallId );    
  2236     
  2012     
  2237     //publish remote party info to Mediator after call info has been cleared.
  2013     //publish remote party info to Mediator after call info has been cleared.
  2626 // -----------------------------------------------------------------------------
  2402 // -----------------------------------------------------------------------------
  2627 // CPEMessageHandler::IsEmergencyAllowed()
  2403 // CPEMessageHandler::IsEmergencyAllowed()
  2628 // Checks if emergency call is allowed. 
  2404 // Checks if emergency call is allowed. 
  2629 // -----------------------------------------------------------------------------
  2405 // -----------------------------------------------------------------------------
  2630 //
  2406 //
  2631 TBool CPEMessageHandler::IsEmergencyAllowed() const
  2407 TBool CPEMessageHandler::IsNetworkConnectionAllowed() const
  2632     {
  2408     {
  2633     TBool networkConnectionAllowed( EFalse );
  2409     TBool networkConnectionAllowed( EFalse );
  2634     //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
  2635     iExternalDataHandler.Get( EPENetworkConnectionAllowedSetting, networkConnectionAllowed );
  2411     iExternalDataHandler.Get( EPENetworkConnectionAllowedSetting, networkConnectionAllowed );
  2636     return networkConnectionAllowed;
  2412     return networkConnectionAllowed;
  2733         if ( iDataStore.CallDirection( aCallId ) == RMobileCall::EMobileOriginated )
  2509         if ( iDataStore.CallDirection( aCallId ) == RMobileCall::EMobileOriginated )
  2734             {
  2510             {
  2735             iDataStore.SetSwitchToNumberCommand( iDataStore.WholeOutgoingPhoneNumber( aCallId ) );  
  2511             iDataStore.SetSwitchToNumberCommand( iDataStore.WholeOutgoingPhoneNumber( aCallId ) );  
  2736             // Clear phonenumber to prevent using the wrong number in MO video call.
  2512             // Clear phonenumber to prevent using the wrong number in MO video call.
  2737             iDataStore.SetPhoneNumber( KNullDesC() );
  2513             iDataStore.SetPhoneNumber( KNullDesC() );
  2738             iSwitchToVidCalReconFlag = ETrue;
       
  2739             }
  2514             }
  2740         else
  2515         else
  2741             {
  2516             {
  2742             iDataStore.SetSwitchToNumberCommand( iDataStore.RemotePhoneNumber( aCallId ) );
  2517             iDataStore.SetSwitchToNumberCommand( iDataStore.RemotePhoneNumber( aCallId ) );
  2743             // Remote phone number must be stored as the phone number in case of low-memory situation where 
  2518             // Remote phone number must be stored as the phone number in case of low-memory situation where 
  2762         "PE CPEMessageHandler::ContinueSwitchToCall, aCallId : %d", aCallId );
  2537         "PE CPEMessageHandler::ContinueSwitchToCall, aCallId : %d", aCallId );
  2763     TInt callId;
  2538     TInt callId;
  2764     TInt errorCode( ECCPErrorNone );
  2539     TInt errorCode( ECCPErrorNone );
  2765   
  2540   
  2766     TPEPhoneNumber phoneNumber = iDataStore.SwitchToNumberCommand();
  2541     TPEPhoneNumber phoneNumber = iDataStore.SwitchToNumberCommand();
  2767     RemovePreAndPostFix( phoneNumber );
       
  2768     
       
  2769     TEFLOGSTRING2( KTAINT, 
  2542     TEFLOGSTRING2( KTAINT, 
  2770         "PE CPEMessageHandler::ContinueSwitchToCall, phoneNumber : %S", 
  2543         "PE CPEMessageHandler::ContinueSwitchToCall, phoneNumber : %S", 
  2771         &phoneNumber );
  2544         &phoneNumber );
  2772 
  2545 
  2773     // Check is current call voice or video
  2546     // Check is current call voice or video
  2898     {
  2671     {
  2899     return iCallHandling.ReplaceActive();
  2672     return iCallHandling.ReplaceActive();
  2900     }
  2673     }
  2901 
  2674 
  2902 // -----------------------------------------------------------------------------
  2675 // -----------------------------------------------------------------------------
       
  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 // -----------------------------------------------------------------------------
  2903 // CPEMessageHandler::IsActiveVideo
  2696 // CPEMessageHandler::IsActiveVideo
  2904 // Checks if there are any connected video calls
  2697 // Checks if there are any connected video calls
  2905 // -----------------------------------------------------------------------------
  2698 // -----------------------------------------------------------------------------
  2906 // 
  2699 // 
  2907 TBool CPEMessageHandler::IsActiveVideo()
  2700 TBool CPEMessageHandler::IsActiveVideo()
  2930 
  2723 
  2931 // -----------------------------------------------------------------------------
  2724 // -----------------------------------------------------------------------------
  2932 // CPEMessageHandler::HandleRemotePartyInfoChanged
  2725 // CPEMessageHandler::HandleRemotePartyInfoChanged
  2933 // -----------------------------------------------------------------------------
  2726 // -----------------------------------------------------------------------------
  2934 //
  2727 //
  2935 void CPEMessageHandler::HandleRemotePartyInfoChanged( const TInt aCallId )
  2728 void CPEMessageHandler::HandleRemotePartyInfoChanged( const TInt /*aCallId*/ )
  2936     {        
  2729     {        
  2937     UpdateRemotePartyInfo(); 
  2730     UpdateRemotePartyInfo(); 
  2938         
  2731         
  2939     }
  2732     }
  2940 
  2733 
  2967     {
  2760     {
  2968     TEFLOGSTRING( KTAINT, "PE CPEMessageHandler::HandleUnattendedTransfer ");
  2761     TEFLOGSTRING( KTAINT, "PE CPEMessageHandler::HandleUnattendedTransfer ");
  2969     TInt errorCode = iCallHandling.DoUnattendedTransfer( 
  2762     TInt errorCode = iCallHandling.DoUnattendedTransfer( 
  2970             iDataStore.TransferTargetCommand() );
  2763             iDataStore.TransferTargetCommand() );
  2971      
  2764      
  2972     iDataStore.SetErrorCode( errorCode );
       
  2973     
       
  2974     return errorCode;
  2765     return errorCode;
  2975     }
  2766     }
  2976 
  2767 
  2977 // -----------------------------------------------------------------------------
  2768 // -----------------------------------------------------------------------------
  2978 // CPEMessageHandler::ForwardCallToAddress
  2769 // CPEMessageHandler::ForwardCallToAddress
  3064                 }
  2855                 }
  3065             }
  2856             }
  3066         }
  2857         }
  3067     return errorCode;
  2858     return errorCode;
  3068     }
  2859     }
  3069 //  End of File  
  2860 
       
  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