phoneapp/phoneuicontrol/src/cphonestate.cpp
changeset 78 baacf668fe89
parent 76 cfea66083b62
equal deleted inserted replaced
76:cfea66083b62 78:baacf668fe89
    65 #include "tphonecmdparamnote.h"
    65 #include "tphonecmdparamnote.h"
    66 #include "tphonecmdparamkeycapture.h"
    66 #include "tphonecmdparamkeycapture.h"
    67 #include "tphonecmdparamglobalnote.h"
    67 #include "tphonecmdparamglobalnote.h"
    68 #include "tphonecmdparamquery.h"
    68 #include "tphonecmdparamquery.h"
    69 #include "tphonecmdparamstring.h"
    69 #include "tphonecmdparamstring.h"
    70 #include "tphonecmdparamcallstatedata.h"
       
    71 #include "tphonecmdparambitmap.h"
    70 #include "tphonecmdparambitmap.h"
    72 #include "tphonecmdparamappinfo.h"
    71 #include "tphonecmdparamappinfo.h"
    73 #include "tphonecmdparamtranseffect.h"
    72 #include "tphonecmdparamtranseffect.h"
    74 #include "tphonecmdparamringtone.h"
    73 #include "tphonecmdparamringtone.h"
    75 #include "tphonecmdparamcustomdialer.h"
    74 #include "tphonecmdparamcustomdialer.h"
    98 #include "mphonestorage.h"
    97 #include "mphonestorage.h"
    99 #include "phoneconstants.h"
    98 #include "phoneconstants.h"
   100 #include "cphoneclearblacklist.h"
    99 #include "cphoneclearblacklist.h"
   101 #include "phonenoteutil.h"
   100 #include "phonenoteutil.h"
   102 #include "phoneaudioutil.h"
   101 #include "phoneaudioutil.h"
       
   102 #include "phonecallutil.h"
       
   103 
   103 
   104 
   104 // ================= MEMBER FUNCTIONS =======================
   105 // ================= MEMBER FUNCTIONS =======================
   105 
   106 
   106 EXPORT_C CPhoneState::CPhoneState(
   107 EXPORT_C CPhoneState::CPhoneState(
   107     MPhoneStateMachine* aStateMachine,
   108     MPhoneStateMachine* aStateMachine,
   833 // <-------------------------- COMMON STATE FUNCTIONS ------------------------>
   834 // <-------------------------- COMMON STATE FUNCTIONS ------------------------>
   834 // -----------------------------------------------------------
   835 // -----------------------------------------------------------
   835 // CPhoneState::DialMultimediaCallL
   836 // CPhoneState::DialMultimediaCallL
   836 // -----------------------------------------------------------
   837 // -----------------------------------------------------------
   837 //
   838 //
   838 EXPORT_C void CPhoneState::DialMultimediaCallL()
   839 EXPORT_C void CPhoneState::DialMultimediaCall()
   839     {
   840     {
   840     __LOGMETHODSTARTEND(EPhoneControl, "CPhoneState::DialMultimediaCall() ");
   841     __LOGMETHODSTARTEND(EPhoneControl, "CPhoneState::DialMultimediaCall() ");
   841     __ASSERT_DEBUG( iStateMachine->PhoneEngineInfo(),
   842     __ASSERT_DEBUG( iStateMachine->PhoneEngineInfo(),
   842         Panic( EPhoneCtrlInvariant ) );
   843         Panic( EPhoneCtrlInvariant ) );
   843     iStateMachine->PhoneEngineInfo()->SetCallTypeCommand( EPECallTypeVideo );
   844     PhoneCallUtil::DialMultimediaCall();
   844     iStateMachine->SendPhoneEngineMessage( MPEPhoneModel::EPEMessageDial );
       
   845     }
   845     }
   846 
   846 
   847 // -----------------------------------------------------------
   847 // -----------------------------------------------------------
   848 // CPhoneState::DialVoiceCallL
   848 // CPhoneState::DialVoiceCallL
   849 // -----------------------------------------------------------
   849 // -----------------------------------------------------------
   850 //
   850 //
   851 EXPORT_C void CPhoneState::DialVoiceCallL()
   851 EXPORT_C void CPhoneState::DialVoiceCallL()
   852     {
   852     {
   853     __LOGMETHODSTARTEND(EPhoneControl, "CPhoneState::DialVoiceCallL() ");
   853     __LOGMETHODSTARTEND(EPhoneControl, "CPhoneState::DialVoiceCallL() ");
   854     __ASSERT_DEBUG( iStateMachine->PhoneEngineInfo(), Panic( EPhoneCtrlInvariant ) );
   854     __ASSERT_DEBUG( iStateMachine->PhoneEngineInfo(), Panic( EPhoneCtrlInvariant ) );
   855     TPhoneCmdParamBoolean globalNotifierParam;
   855     PhoneCallUtil::DialVoiceCallL();
   856     globalNotifierParam.SetBoolean( ETrue );
       
   857     iViewCommandHandle->ExecuteCommandL( EPhoneViewSetGlobalNotifiersDisabled,
       
   858             &globalNotifierParam );
       
   859     iStateMachine->PhoneEngineInfo()->SetCallTypeCommand( EPECallTypeCSVoice );
       
   860     iStateMachine->SendPhoneEngineMessage( MPEPhoneModel::EPEMessageDial );
       
   861     }
   856     }
   862 
   857 
   863 // -----------------------------------------------------------
   858 // -----------------------------------------------------------
   864 // CPhoneState::DisconnectCallL
   859 // CPhoneState::DisconnectCallL
   865 // -----------------------------------------------------------
   860 // -----------------------------------------------------------
   866 //
   861 //
   867 EXPORT_C TBool CPhoneState::DisconnectCallL()
   862 EXPORT_C TBool CPhoneState::DisconnectCallL()
   868     {
   863     {
   869     __LOGMETHODSTARTEND(EPhoneControl, "CPhoneState::DisconnectCallL( ) ");
   864     __LOGMETHODSTARTEND(EPhoneControl, "CPhoneState::DisconnectCallL( ) ");
   870     TPhoneCmdParamInteger callIdParam;
   865     return PhoneCallUtil::DisconnectCallL();
   871     iViewCommandHandle->ExecuteCommand( 
       
   872             EPhoneViewGetExpandedBubbleCallId, &callIdParam );
       
   873     TBool ret = EFalse;
       
   874     if( callIdParam.Integer() > KErrNotFound )
       
   875         {
       
   876         iStateMachine->SetCallId( callIdParam.Integer() );
       
   877         if( IsVideoCall( callIdParam.Integer() ) )
       
   878             {
       
   879             // Video call can be released only after we get response to VT Shutdown Command
       
   880             CPhoneMediatorFactory::Instance()->Sender()->IssueCommand( 
       
   881                     KMediatorVideoTelephonyDomain,
       
   882                              KCatPhoneToVideotelCommands,
       
   883                              EVtCmdReleaseDataport,
       
   884                    TVersion( KPhoneToVideotelCmdVersionMajor,
       
   885                              KPhoneToVideotelCmdVersionMinor,
       
   886                              KPhoneToVideotelCmdVersionBuild ),
       
   887                    KNullDesC8,
       
   888                    CPhoneReleaseCommand::NewL( *iStateMachine ) );
       
   889             }
       
   890         else
       
   891             {
       
   892             iStateMachine->SendPhoneEngineMessage(
       
   893                 MPEPhoneModel::EPEMessageRelease );
       
   894             }
       
   895         ret = ETrue;
       
   896         }
       
   897     else
       
   898         {
       
   899         __PHONELOG( EOnlyFatal, EPhoneControl,
       
   900             "CPhoneState::DisconnectCallL has negative call id!" );
       
   901         }
       
   902     return ret;
       
   903     }
   866     }
   904 
   867 
   905 // -----------------------------------------------------------
   868 // -----------------------------------------------------------
   906 // CPhoneState::RemoveDialogsAndSendPhoneToBackgroundL()
   869 // CPhoneState::RemoveDialogsAndSendPhoneToBackgroundL()
   907 // -----------------------------------------------------------
   870 // -----------------------------------------------------------
   943     // we must show number entry.
   906     // we must show number entry.
   944     if ( iNumberEntryManager->IsNumberEntryUsedL() && !IsAutoLockOn() )
   907     if ( iNumberEntryManager->IsNumberEntryUsedL() && !IsAutoLockOn() )
   945         {
   908         {
   946         iNumberEntryManager->SetNumberEntryVisibilityL(ETrue);
   909         iNumberEntryManager->SetNumberEntryVisibilityL(ETrue);
   947         }
   910         }
   948     }
       
   949 
       
   950 // -----------------------------------------------------------
       
   951 // CPhoneState::IsWaitingCallL
       
   952 // -----------------------------------------------------------
       
   953 //
       
   954 TBool CPhoneState::IsWaitingCallL( const TInt aCallId  )
       
   955     {
       
   956     __LOGMETHODSTARTEND(EPhoneControl, "CPhoneState::IsWaitingCallL( ) ");
       
   957     TBool waiting( EFalse );
       
   958     if ( aCallId >= 0 && 
       
   959          iStateMachine->PhoneEngineInfo()->CallState( aCallId ) == EPEStateRinging )
       
   960         {
       
   961         TPhoneCmdParamInteger activeCallCount;
       
   962         iViewCommandHandle->ExecuteCommandL(
       
   963             EPhoneViewGetCountOfActiveCalls, &activeCallCount );
       
   964         
       
   965         if( activeCallCount.Integer() > 0 )
       
   966             {
       
   967             waiting = ETrue;
       
   968             }
       
   969         }
       
   970     
       
   971     return waiting;
       
   972     }
   911     }
   973 
   912 
   974 // -----------------------------------------------------------
   913 // -----------------------------------------------------------
   975 // CPhoneState::UpdateCallHeader
   914 // CPhoneState::UpdateCallHeader
   976 // -----------------------------------------------------------
   915 // -----------------------------------------------------------
  1202 // ---------------------------------------------------------
  1141 // ---------------------------------------------------------
  1203 //
  1142 //
  1204 EXPORT_C TBool CPhoneState::IsVideoCall( const TInt aCallId )
  1143 EXPORT_C TBool CPhoneState::IsVideoCall( const TInt aCallId )
  1205     {
  1144     {
  1206     __LOGMETHODSTARTEND(EPhoneControl, "CPhoneState::IsVideoCall( ) ");
  1145     __LOGMETHODSTARTEND(EPhoneControl, "CPhoneState::IsVideoCall( ) ");
  1207     if ( aCallId < 0 )
  1146     return PhoneCallUtil::IsVideoCall( aCallId );
  1208         {
       
  1209         return EFalse;
       
  1210         }
       
  1211 
       
  1212     return EPECallTypeVideo == iStateMachine->PhoneEngineInfo()->CallType( aCallId );
       
  1213     }
  1147     }
  1214 
  1148 
  1215 // ---------------------------------------------------------
  1149 // ---------------------------------------------------------
  1216 // CPhoneState::SimState()
  1150 // CPhoneState::SimState()
  1217 // ---------------------------------------------------------
  1151 // ---------------------------------------------------------
  1722             aData,
  1656             aData,
  1723             CPhoneMainResourceResolver::Instance()->ResolveResourceID( aResource ),
  1657             CPhoneMainResourceResolver::Instance()->ResolveResourceID( aResource ),
  1724             EikonEnv() );
  1658             EikonEnv() );
  1725     }
  1659     }
  1726 
  1660 
  1727 // -----------------------------------------------------------
       
  1728 // CPhoneState::IsAnyConnectedCalls
       
  1729 // -----------------------------------------------------------
       
  1730 //
       
  1731 TBool CPhoneState::IsAnyConnectedCalls()
       
  1732     {
       
  1733     __LOGMETHODSTARTEND( EPhoneControl, "CPhoneState::IsAnyConnectedCalls() ");
       
  1734     TBool connectedCall(EFalse);
       
  1735     if ( iStateMachine->PhoneEngineInfo()->CheckIfCallStateExists( EPEStateConnected ) ||
       
  1736         iStateMachine->PhoneEngineInfo()->CheckIfCallStateExists( EPEStateConnecting ) ||
       
  1737         iStateMachine->PhoneEngineInfo()->CheckIfCallStateExists( EPEStateConnectedConference ) )
       
  1738         {
       
  1739         connectedCall = ETrue;
       
  1740         }
       
  1741     __PHONELOG1( EBasic, EPhoneControl, "CPhoneState::IsAnyConnectedCalls: (%d)", connectedCall );
       
  1742     return connectedCall;
       
  1743     }
       
  1744 
       
  1745 // ---------------------------------------------------------
  1661 // ---------------------------------------------------------
  1746 // CPhoneState::SetToolbarButtonLoudspeakerEnabled
  1662 // CPhoneState::SetToolbarButtonLoudspeakerEnabled
  1747 // ---------------------------------------------------------
  1663 // ---------------------------------------------------------
  1748 //
  1664 //
  1749 EXPORT_C void CPhoneState::SetToolbarButtonLoudspeakerEnabled()
  1665 EXPORT_C void CPhoneState::SetToolbarButtonLoudspeakerEnabled()
  1778 EXPORT_C void CPhoneState::OpenSoftRejectMessageEditorL()
  1694 EXPORT_C void CPhoneState::OpenSoftRejectMessageEditorL()
  1779     {
  1695     {
  1780     __LOGMETHODSTARTEND(EPhoneControl,
  1696     __LOGMETHODSTARTEND(EPhoneControl,
  1781         "CPhoneState::OpenSoftRejectMessageEditorL ()" );
  1697         "CPhoneState::OpenSoftRejectMessageEditorL ()" );
  1782     iUiCommandManager->SetSoftRejectStatus( EFalse );
  1698     iUiCommandManager->SetSoftRejectStatus( EFalse );
  1783     TPhoneCmdParamCallStateData callStateData;
  1699 
  1784     callStateData.SetCallState( EPEStateRinging );
  1700     TInt ringingCallId( PhoneCallUtil::CallIdByState( EPEStateRinging ) );
  1785     iViewCommandHandle->HandleCommandL(
       
  1786         EPhoneViewGetCallIdByState, &callStateData );
       
  1787 
       
  1788     TInt ringingCallId( KErrNotFound );
       
  1789     // Do nothing if negative incoming call id
       
  1790     if( callStateData.CallId() > KErrNotFound  )
       
  1791         {
       
  1792         iViewCommandHandle->ExecuteCommandL( EPhoneViewRemoveQuery );
       
  1793         ringingCallId = callStateData.CallId();
       
  1794         }
       
  1795     
  1701     
  1796     TPhoneCmdParamSfiData sfiDataParam;
  1702     TPhoneCmdParamSfiData sfiDataParam;
  1797     if (KErrNotFound != ringingCallId) 
  1703     if( ringingCallId > KErrNotFound  )
  1798         {
  1704         {
       
  1705         iViewCommandHandle->ExecuteCommandL( EPhoneViewRemoveQuery );
  1799         if ( iStateMachine->PhoneEngineInfo()->
  1706         if ( iStateMachine->PhoneEngineInfo()->
  1800                 RemoteName( ringingCallId ).Length() )
  1707                 RemoteName( ringingCallId ).Length() )
  1801             {
  1708             {
  1802             // store both the name and the number
  1709             // store both the name and the number
  1803             sfiDataParam.SetNumber( 
  1710             sfiDataParam.SetNumber( 
  1825 EXPORT_C void CPhoneState::DisplayCallHeaderL( 
  1732 EXPORT_C void CPhoneState::DisplayCallHeaderL( 
  1826         TInt aCallId,
  1733         TInt aCallId,
  1827         TNumberEntrySetRule aRule )
  1734         TNumberEntrySetRule aRule )
  1828     {
  1735     {
  1829     __LOGMETHODSTARTEND(EPhoneControl, 
  1736     __LOGMETHODSTARTEND(EPhoneControl, 
  1830             "CPhoneState::BringIncomingCallHeaderToForegroundL( ) ");
  1737             "CPhoneState::DisplayCallHeaderL( ) ");
  1831     BeginUiUpdateLC();
  1738     BeginUiUpdateLC();
  1832     switch ( aRule )
  1739     switch ( aRule )
  1833        {
  1740        {
  1834        case ESetNEVisibilityFalse:
  1741        case ESetNEVisibilityFalse:
  1835            iNumberEntryManager->
  1742            iNumberEntryManager->
  1841            break;
  1748            break;
  1842        default: // by default do nothing.
  1749        default: // by default do nothing.
  1843            break;
  1750            break;
  1844        }
  1751        }
  1845     iViewCommandHandle->ExecuteCommandL( EPhoneViewRemovePhoneDialogs );
  1752     iViewCommandHandle->ExecuteCommandL( EPhoneViewRemovePhoneDialogs );
       
  1753     iViewCommandHandle->ExecuteCommandL( EPhoneViewCreateCallHeader, aCallId );
  1846     iViewCommandHandle->ExecuteCommandL( EPhoneViewBringPhoneAppToForeground );
  1754     iViewCommandHandle->ExecuteCommandL( EPhoneViewBringPhoneAppToForeground );
  1847     iViewCommandHandle->ExecuteCommandL( EPhoneViewCreateCallHeader, aCallId );
       
  1848     UpdateUiCommands();
  1755     UpdateUiCommands();
  1849     EndUiUpdate();
  1756     EndUiUpdate();
  1850     }
  1757     }
  1851 
  1758 
  1852 // ---------------------------------------------------------
  1759 // ---------------------------------------------------------