phoneapp/phoneuivoipextension/src/cphonestateidlevoip.cpp
changeset 0 5f000ab63145
child 9 8871b09be73b
child 21 92ab7f8d0eab
equal deleted inserted replaced
-1:000000000000 0:5f000ab63145
       
     1 /*
       
     2 * Copyright (c) 2007 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: Implementation of CPhoneStateIdleVoIP class.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 // INCLUDES
       
    20 #include <mpeengineinfo.h>       
       
    21 #include "pevirtualengine.h"
       
    22 #include <featmgr.h>
       
    23                                   
       
    24 #include "cphonestateidlevoip.h"
       
    25 #include "phoneappvoipcommands.hrh"
       
    26 #include "phonerssvoip.h"
       
    27 #include "tphonecmdparaminteger.h"
       
    28 #include "cphonemainresourceresolver.h"
       
    29 #include "mphonestatemachine.h"
       
    30 #include "cphonelogger.h"
       
    31 #include "phoneui.pan"
       
    32 #include "cphonecustomizationvoip.h"
       
    33 #include "tphonecmdparamspeeddial.h"
       
    34 #include "cphonecenrepproxy.h"
       
    35 #include "cphonestateutilsvoip.h"
       
    36 #include "cphonestatemachinevoip.h"
       
    37 
       
    38 // CONSTANTS
       
    39 
       
    40 // ================= MEMBER FUNCTIONS =======================
       
    41 
       
    42 // C++ default constructor can NOT contain any code, that
       
    43 // might leave.
       
    44 //
       
    45 CPhoneStateIdleVoIP::CPhoneStateIdleVoIP( 
       
    46     MPhoneStateMachine& aStateMachine, 
       
    47     MPhoneViewCommandHandle& aViewCommandHandle,
       
    48     MPhoneCustomization& aCustomization ) : 
       
    49     CPhoneIdle( &aStateMachine, &aViewCommandHandle, &aCustomization )
       
    50     {
       
    51     }
       
    52 
       
    53 
       
    54 // -----------------------------------------------------------
       
    55 // CPhoneStateIdleVoIP::~CPhoneStateIdleVoIP()
       
    56 // Destructor
       
    57 // (other items were commented in a header).
       
    58 // -----------------------------------------------------------
       
    59 //
       
    60 CPhoneStateIdleVoIP::~CPhoneStateIdleVoIP()
       
    61     {
       
    62     }
       
    63 
       
    64 
       
    65 // -----------------------------------------------------------
       
    66 // CPhoneStateIdleVoIP::ConstructL()
       
    67 // Constructor
       
    68 // (other items were commented in a header).
       
    69 // -----------------------------------------------------------
       
    70 //
       
    71 void CPhoneStateIdleVoIP::ConstructL()
       
    72     {
       
    73     CPhoneIdle::ConstructL();
       
    74     }
       
    75 
       
    76 
       
    77 // -----------------------------------------------------------
       
    78 // CPhoneStateIdleVoIP::NewL()
       
    79 // Constructor
       
    80 // (other items were commented in a header).
       
    81 // -----------------------------------------------------------
       
    82 //
       
    83 CPhoneStateIdleVoIP* CPhoneStateIdleVoIP::NewL( 
       
    84     MPhoneStateMachine& aStateMachine, 
       
    85     MPhoneViewCommandHandle& aViewCommandHandle,
       
    86     MPhoneCustomization& aCustomization )
       
    87     {
       
    88     CPhoneStateIdleVoIP* self = new (ELeave) CPhoneStateIdleVoIP( 
       
    89         aStateMachine, aViewCommandHandle, aCustomization );
       
    90     
       
    91     CleanupStack::PushL( self );
       
    92     self->ConstructL();
       
    93     CleanupStack::Pop( self );
       
    94     
       
    95     return self;
       
    96     }
       
    97 
       
    98 
       
    99 // -----------------------------------------------------------
       
   100 // CPhoneStateIdleVoIP::HandlePhoneEngineMessageL
       
   101 // -----------------------------------------------------------
       
   102 //
       
   103 void CPhoneStateIdleVoIP::HandlePhoneEngineMessageL( 
       
   104     const TInt aMessage,
       
   105     TInt aCallId )
       
   106     {
       
   107     switch ( aMessage )
       
   108         {           
       
   109         default:
       
   110             CPhoneIdle::HandlePhoneEngineMessageL( aMessage, aCallId );
       
   111             break;
       
   112         }
       
   113     }
       
   114 
       
   115 
       
   116 // -----------------------------------------------------------
       
   117 // CPhoneStateIdleVoIP::HandleCommandL
       
   118 // -----------------------------------------------------------
       
   119 //
       
   120 TBool CPhoneStateIdleVoIP::HandleCommandL( TInt aCommand )
       
   121     {
       
   122     __LOGMETHODSTARTEND( PhoneUIVoIPExtension, "CPhoneStateIdleVoIP::HandleCommandL() ");
       
   123 
       
   124     TBool commandStatus( ETrue );
       
   125 
       
   126     switch( aCommand )
       
   127         {     	
       
   128         case EPhoneNumberAcqCmdInternetCall:
       
   129             {
       
   130             StateUtils().SelectServiceAndDialL();
       
   131             }
       
   132         	break;
       
   133 
       
   134         default:
       
   135             commandStatus = CPhoneIdle::HandleCommandL( aCommand );
       
   136             break;
       
   137         }
       
   138 
       
   139     return commandStatus;
       
   140     }
       
   141 
       
   142 
       
   143 // -----------------------------------------------------------
       
   144 // CPhoneStateIdleVoIP::HandleSendCommandL
       
   145 // -----------------------------------------------------------
       
   146 //
       
   147 void CPhoneStateIdleVoIP::HandleSendCommandL()
       
   148     {
       
   149     __LOGMETHODSTARTEND( 
       
   150         PhoneUIVoIPExtension, "CPhoneStateIdleVoIP::HandleSendCommandL()" );
       
   151     
       
   152     HBufC* phoneNumber = PhoneNumberFromEntryLC();
       
   153      
       
   154     if ( !IsSimOk() || IsEmergencyNumber( *phoneNumber ) )
       
   155         {
       
   156         CPhoneIdle::HandleSendCommandL();         
       
   157         }  
       
   158     else if ( IsSpeedDialNumber( *phoneNumber ) )
       
   159         {
       
   160         SpeedDialL( (*phoneNumber)[0], EDialMethodSendCommand );
       
   161         }
       
   162     else
       
   163         {
       
   164         TUint serviceId( 0 );
       
   165         CPhoneStateUtilsVoip& utils = StateUtils();
       
   166         if ( utils.IsVoipPreferredCall( serviceId ) &&
       
   167              !iStateMachine->PhoneEngineInfo()->PhoneNumberIsServiceCode() )
       
   168             {
       
   169             utils.SelectServiceAndDialL( KNullDesC, serviceId );
       
   170             }
       
   171         else
       
   172             {
       
   173             if ( utils.IsVoipNumber() )
       
   174                 {
       
   175                 utils.SelectServiceAndDialL();
       
   176                 }
       
   177             else
       
   178                 {
       
   179                 CPhoneIdle::HandleSendCommandL();
       
   180                 }
       
   181             }        
       
   182         }
       
   183     
       
   184     CleanupStack::PopAndDestroy( phoneNumber );
       
   185     }
       
   186 
       
   187 
       
   188 // -----------------------------------------------------------
       
   189 // CPhoneStateIdleVoIP::HandleDialingL
       
   190 // -----------------------------------------------------------
       
   191 //
       
   192 void CPhoneStateIdleVoIP::HandleDialingL( TInt aCallId )
       
   193 	{
       
   194     __LOGMETHODSTARTEND( PhoneUIVoIPExtension, "CPhoneStateIdleVoIP::HandleDialingL( ) ");
       
   195 
       
   196 	if( iStateMachine->PhoneEngineInfo()->CallType( aCallId ) == EPECallTypeVoIP )
       
   197 		{
       
   198 		SetCallHeaderType( CBubbleManager::EVoIPCall );			
       
   199 		}
       
   200 
       
   201 	CPhoneIdle::HandleDialingL( aCallId );
       
   202 	}
       
   203 
       
   204 
       
   205 // -----------------------------------------------------------
       
   206 // CPhoneStateIdleVoIP::DialL
       
   207 // -----------------------------------------------------------
       
   208 //   
       
   209 void CPhoneStateIdleVoIP::DialL( 
       
   210         const TDesC& aNumber, 
       
   211         TPhoneNumberType aNumberType,
       
   212         TDialInitiationMethod aDialMethod )
       
   213     {
       
   214     __LOGMETHODSTARTEND( PhoneUIVoIPExtension, 
       
   215                          "CPhoneStateIdleVoIP::DialL( ) ");
       
   216     if ( FeatureManager::FeatureSupported( KFeatureIdCommonVoip ) )
       
   217         {
       
   218         CPhoneStateUtilsVoip& utils = StateUtils();
       
   219 
       
   220         // When speed dialling to voice mailbox, service id comes from vmbx
       
   221         TUint serviceId = iStateMachine->PhoneEngineInfo()->ServiceIdCommand();
       
   222         
       
   223         if ( serviceId != KUnknownService && EPhoneNumberTypeNotFound != aNumberType )
       
   224             {
       
   225             if ( EPhoneNumberTypeVoip == aNumberType )
       
   226                 {
       
   227                 utils.DialVoIPL( aNumber, serviceId );
       
   228                 }
       
   229             else
       
   230                 {
       
   231                 CPhoneIdle::DialL( aNumber, aNumberType, aDialMethod );
       
   232                 }
       
   233             }
       
   234         else if( utils.IsVoipPreferredCall( serviceId ) )
       
   235             {
       
   236             // Because IsVoipPreferredCall assumes that Send key is pressed,
       
   237             // we only use serviceId given by it when dial method is SendCommand
       
   238             if ( EDialMethodSendCommand == aDialMethod ) 
       
   239                 {
       
   240                 utils.SelectServiceAndDialL( aNumber, serviceId );
       
   241                 }
       
   242             else
       
   243                 {
       
   244                 // One key dialing is done based on number type even
       
   245                 // if VoIP is preferred call.
       
   246                 CPhoneIdle::DialL( aNumber, aNumberType, aDialMethod );
       
   247                 }
       
   248             }
       
   249         else
       
   250             {
       
   251             if ( EPhoneNumberTypeVoip == aNumberType )
       
   252                 {
       
   253                 utils.SelectServiceAndDialL( aNumber );
       
   254                 }
       
   255             else
       
   256                 {
       
   257                 CPhoneIdle::DialL( aNumber, aNumberType, aDialMethod );
       
   258                 }
       
   259             }
       
   260         }
       
   261     else
       
   262         {
       
   263         CPhoneIdle::DialL( aNumber, aNumberType, aDialMethod );
       
   264         }
       
   265     }
       
   266 
       
   267 
       
   268 // -----------------------------------------------------------
       
   269 // CPhoneStateIdleVoip::IsEmergencyNumber()
       
   270 // -----------------------------------------------------------
       
   271 //
       
   272 TBool CPhoneStateIdleVoIP::IsEmergencyNumber( const TDesC& aNumber )
       
   273     {
       
   274     __LOGMETHODSTARTEND( PhoneUIVoIPExtension, 
       
   275         "CPhoneStateIdleVoIP::IsEmergencyNumber" );
       
   276     
       
   277     return StateUtils().IsEmergencyNumber( aNumber );
       
   278     }
       
   279 
       
   280 
       
   281 // -----------------------------------------------------------
       
   282 // CPhoneStateIdleVoIP::StateUtils
       
   283 // -----------------------------------------------------------
       
   284 //
       
   285 CPhoneStateUtilsVoip& CPhoneStateIdleVoIP::StateUtils()
       
   286     {
       
   287     return static_cast<CPhoneStateMachineVoIP&>( 
       
   288         *iStateMachine ).StateUtils();
       
   289     }
       
   290 
       
   291 // End of File