phoneapp/phoneuicontrol/src/phonecallutil.cpp
changeset 78 baacf668fe89
equal deleted inserted replaced
76:cfea66083b62 78:baacf668fe89
       
     1 /*
       
     2 * Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). 
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:  Acessory and Bluetooth handler.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 // INCLUDE FILES
       
    20 #include    "phonecallutil.h"
       
    21 #include    "mphonestatemachine.h"
       
    22 #include    "mphoneviewcommandhandle.h"
       
    23 #include    "cphonestatehandle.h"
       
    24 #include    "tphonecmdparamboolean.h"
       
    25 #include    "tphonecmdparaminteger.h"
       
    26 #include    "cphonemediatorfactory.h"
       
    27 #include    "cphonemediatorsender.h"
       
    28 #include    "cphonereleasecommand.h"
       
    29 #include    "tphonecmdparamcallstatedata.h" 
       
    30 
       
    31 #include    <videotelcontrolmediatorapi.h>
       
    32 #include    <MediatorDomainUIDs.h>
       
    33 #include    <pevirtualengine.h>
       
    34 #include    <mpeengineinfo.h>
       
    35 
       
    36 // CONSTANTS
       
    37 
       
    38 // ============================ MEMBER FUNCTIONS ===============================
       
    39 
       
    40 // ---------------------------------------------------------
       
    41 // PhoneCallUtil::DialMultimediaCall
       
    42 // ---------------------------------------------------------
       
    43 //
       
    44 EXPORT_C void PhoneCallUtil::DialMultimediaCall()
       
    45     {    
       
    46     MPhoneStateMachine* stateMachine = StateMachine();
       
    47     stateMachine->PhoneEngineInfo()->SetCallTypeCommand( EPECallTypeVideo );
       
    48     stateMachine->SendPhoneEngineMessage( MPEPhoneModel::EPEMessageDial );
       
    49     }
       
    50 
       
    51 // ---------------------------------------------------------
       
    52 // PhoneCallUtil::DialVoiceCallL
       
    53 // ---------------------------------------------------------
       
    54 //
       
    55 EXPORT_C void PhoneCallUtil::DialVoiceCallL()
       
    56     {
       
    57     MPhoneStateMachine* stateMachine = StateMachine();
       
    58     
       
    59     TPhoneCmdParamBoolean globalNotifierParam;
       
    60     globalNotifierParam.SetBoolean( ETrue );
       
    61     ViewCommandHandle()->ExecuteCommandL( EPhoneViewSetGlobalNotifiersDisabled,
       
    62             &globalNotifierParam );
       
    63     stateMachine->PhoneEngineInfo()->SetCallTypeCommand( EPECallTypeCSVoice );
       
    64     stateMachine->SendPhoneEngineMessage( MPEPhoneModel::EPEMessageDial );
       
    65     }
       
    66 
       
    67 // -----------------------------------------------------------
       
    68 // PhoneCallUtil::DisconnectCallL
       
    69 // -----------------------------------------------------------
       
    70 //
       
    71 EXPORT_C TBool PhoneCallUtil::DisconnectCallL()
       
    72     {
       
    73     MPhoneStateMachine* stateMachine = StateMachine();
       
    74     TPhoneCmdParamInteger callIdParam;
       
    75     
       
    76     ViewCommandHandle()->ExecuteCommand( 
       
    77             EPhoneViewGetExpandedBubbleCallId, &callIdParam );
       
    78     TBool ret = EFalse;
       
    79     if( callIdParam.Integer() > KErrNotFound )
       
    80         {
       
    81         stateMachine->SetCallId( callIdParam.Integer() );
       
    82         if( IsVideoCall( callIdParam.Integer() ) )
       
    83             {
       
    84             // Video call can be released only after we get response to VT Shutdown Command
       
    85             CPhoneMediatorFactory::Instance()->Sender()->IssueCommand( 
       
    86                     KMediatorVideoTelephonyDomain,
       
    87                              KCatPhoneToVideotelCommands,
       
    88                              EVtCmdReleaseDataport,
       
    89                    TVersion( KPhoneToVideotelCmdVersionMajor,
       
    90                              KPhoneToVideotelCmdVersionMinor,
       
    91                              KPhoneToVideotelCmdVersionBuild ),
       
    92                    KNullDesC8,
       
    93                    CPhoneReleaseCommand::NewL( *stateMachine ) );
       
    94             }
       
    95         else
       
    96             {
       
    97             stateMachine->SendPhoneEngineMessage(
       
    98                 MPEPhoneModel::EPEMessageRelease );
       
    99             }
       
   100         
       
   101         ret = ETrue;
       
   102         }
       
   103 
       
   104     return ret;
       
   105     }
       
   106 
       
   107 
       
   108 // ---------------------------------------------------------
       
   109 // PhoneCallUtil::IsVideoCall
       
   110 // ---------------------------------------------------------
       
   111 //
       
   112 EXPORT_C TBool PhoneCallUtil::IsVideoCall( const TInt aCallId )
       
   113     {
       
   114     if ( aCallId < 0 )
       
   115         {
       
   116         return EFalse;
       
   117         }
       
   118 
       
   119     return EPECallTypeVideo == StateMachine()->PhoneEngineInfo()->
       
   120                 CallType( aCallId );
       
   121     }
       
   122 
       
   123 // ---------------------------------------------------------
       
   124 // PhoneCallUtil::CallIdByState
       
   125 // ---------------------------------------------------------
       
   126 //
       
   127 EXPORT_C TInt PhoneCallUtil::CallIdByState( const TPEState aCallState )
       
   128     {
       
   129     TPhoneCmdParamCallStateData callStateData;
       
   130     callStateData.SetCallState( aCallState );
       
   131 
       
   132     ViewCommandHandle()->ExecuteCommand(
       
   133         EPhoneViewGetCallIdByState, &callStateData );
       
   134 
       
   135     return callStateData.CallId();
       
   136     }
       
   137 
       
   138 // ---------------------------------------------------------
       
   139 // PhoneCallUtil::CheckIfCallExists
       
   140 // ---------------------------------------------------------
       
   141 //
       
   142 EXPORT_C TBool PhoneCallUtil::CheckIfCallExists( 
       
   143         const TPEState aCallState, const TPECallType aCallType )
       
   144     {
       
   145     TBool retVal = EFalse;
       
   146     TInt callId = CallIdByState( aCallState );
       
   147 
       
   148     if ( callId > 0 && 
       
   149          aCallType == StateMachine()->PhoneEngineInfo()->
       
   150             CallType( callId ) )
       
   151         {
       
   152         retVal = ETrue;
       
   153         }
       
   154     
       
   155     return retVal;
       
   156     }
       
   157 
       
   158 // -----------------------------------------------------------
       
   159 // PhoneCallUtil::IsAnyConnectedCalls
       
   160 // -----------------------------------------------------------
       
   161 //
       
   162 EXPORT_C TBool PhoneCallUtil::IsAnyConnectedCalls()
       
   163     {
       
   164     TBool connectedCall(EFalse);
       
   165     MPhoneStateMachine* stateMachine = StateMachine();
       
   166     
       
   167     if ( stateMachine->PhoneEngineInfo()->CheckIfCallStateExists( 
       
   168             EPEStateConnected ) ||
       
   169          stateMachine->PhoneEngineInfo()->CheckIfCallStateExists( 
       
   170             EPEStateConnecting ) ||
       
   171          stateMachine->PhoneEngineInfo()->CheckIfCallStateExists( 
       
   172             EPEStateConnectedConference ) )
       
   173         {
       
   174         connectedCall = ETrue;
       
   175         }
       
   176 
       
   177     return connectedCall;
       
   178     }
       
   179 
       
   180 // ---------------------------------------------------------
       
   181 //  PhoneCallUtil::ViewCommandHandle
       
   182 // ---------------------------------------------------------
       
   183 //
       
   184 MPhoneViewCommandHandle* PhoneCallUtil::ViewCommandHandle()
       
   185     {   
       
   186     return CPhoneStateHandle::Instance()->ViewCommandHandle();
       
   187     }
       
   188 
       
   189 // ---------------------------------------------------------
       
   190 //  PhoneCallUtil::StateMachine
       
   191 // ---------------------------------------------------------
       
   192 //
       
   193 MPhoneStateMachine* PhoneCallUtil::StateMachine()
       
   194     {   
       
   195     return CPhoneStateHandle::Instance()->StateMachine();
       
   196     }
       
   197 
       
   198 //  End of File