phoneapp/phoneuivoipextension/src/cphonecustomizationvoip.cpp
changeset 37 ba76fc04e6c2
child 50 377c906a8701
child 51 f39ed5e045e0
equal deleted inserted replaced
36:2eacb6118286 37:ba76fc04e6c2
       
     1 /*
       
     2 * Copyright (c) 2008-2009 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 CPhoneCustomizationVoip class.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 // INCLUDES
       
    20 #include <eikmenup.h>
       
    21 #include <spsettings.h>
       
    22 #include <spentry.h>
       
    23 #include <spproperty.h>
       
    24 #include <mpeengineinfo.h>
       
    25 #include "phoneresourceids.h"
       
    26 #include <avkon.rsg>
       
    27 #include <StringLoader.h>
       
    28 #include <featmgr.h>
       
    29 
       
    30 #include "cphonecustomizationvoip.h"
       
    31 #include "tphonecmdparaminteger.h"
       
    32 #include "tphonecmdparamboolean.h"
       
    33 #include "tphonecmdparamstring.h"
       
    34 #include "cphonemainresourceresolver.h"
       
    35 #include "mphonestatemachine.h"
       
    36 #include "cphonelogger.h"
       
    37 #include "cphonecenrepproxy.h"
       
    38 #include "phoneui.pan"
       
    39 #include "mphoneviewcommandhandle.h"
       
    40 #include "tphonecmdparamdynmenu.h"
       
    41 #include "phoneappvoipcommands.hrh"
       
    42 #include "phonerssvoip.h"
       
    43 #include "tphonecmdparamcallstatedata.h"
       
    44 #include "tphonecmdparamquery.h"
       
    45 #include "tphonecmdparamcallheaderdata.h"
       
    46 #include "cphoneextensionhandler.h"
       
    47 #include "cphonestate.h"
       
    48 #include "tphonecmdparamglobalnote.h"
       
    49 #include "cphonestatemachinevoip.h"
       
    50 #include "cphonevoiperrormessageshandler.h"
       
    51 #include "cphoneviewcustomizationvoip.h"
       
    52 #include "cphonestateutilsvoip.h"
       
    53 #include "cphoneunattendedtransfercmdhandler.h"
       
    54 #include "tphonecmdparampointer.h"
       
    55 #include "cphonenewcallcmdhandler.h"
       
    56 #include "cphonecallforwardqueryhandler.h"
       
    57 #include "cphonekeys.h"
       
    58 
       
    59 // CONSTANTS
       
    60 const TInt KMaxLengthForSIPURIFirstLine = 15;
       
    61 const TInt KMaxLengthForSIPURITwoLines = 30;
       
    62 const TInt KMaxLengthForSIPURI = 256;
       
    63 
       
    64 _LIT( KVoipAt, "@" );
       
    65 
       
    66 // ================= MEMBER FUNCTIONS =======================
       
    67 
       
    68 // C++ default constructor can NOT contain any code, that
       
    69 // might leave.
       
    70 //
       
    71 CPhoneCustomizationVoip::CPhoneCustomizationVoip( 
       
    72     MPhoneStateMachine& aStateMachine,
       
    73     MPhoneViewCommandHandle& aViewCommandHandle ) : 
       
    74     iCoeEnv( *CCoeEnv::Static() ),
       
    75     iStateMachine( aStateMachine ),
       
    76     iViewCommandHandle( aViewCommandHandle )
       
    77     {
       
    78     }
       
    79 
       
    80 
       
    81 // -----------------------------------------------------------
       
    82 // CPhoneCustomizationVoip::~CPhoneCustomizationVoip()
       
    83 // Destructor
       
    84 // -----------------------------------------------------------
       
    85 //
       
    86 CPhoneCustomizationVoip::~CPhoneCustomizationVoip()
       
    87     {
       
    88     delete iCallForwardHandler;
       
    89     delete iExtensionHandler;
       
    90     delete iPhoneViewCustomization;
       
    91     delete iTransferCmdHandler;
       
    92     delete iNewCallCmdHandler;
       
    93     }
       
    94 
       
    95 
       
    96 // -----------------------------------------------------------
       
    97 // CPhoneCustomizationVoip::ConstructL()
       
    98 // Constructor
       
    99 // -----------------------------------------------------------
       
   100 //
       
   101 void CPhoneCustomizationVoip::ConstructL()
       
   102     {
       
   103     // Set view customization
       
   104     iPhoneViewCustomization = CPhoneViewCustomizationVoip::NewL( *this );
       
   105     TPhoneCmdParamPointer pointerParam;
       
   106     pointerParam.SetPointer( 
       
   107         static_cast<MPhoneViewCustomization*>( iPhoneViewCustomization ) );
       
   108     iViewCommandHandle.ExecuteCommand( EPhoneViewSetViewCustomization, 
       
   109         &pointerParam );
       
   110     // Set touch button customization
       
   111     pointerParam.SetPointer( 
       
   112         static_cast<MPhoneButtonCustomization*>( this ) );
       
   113     iViewCommandHandle.ExecuteCommand( EPhoneViewSetButtonCustomization, 
       
   114         &pointerParam );
       
   115     
       
   116     // Set phone customization
       
   117     pointerParam.SetPointer( static_cast<MPhoneCustomization*>( this ) );
       
   118     iViewCommandHandle.ExecuteCommand( EPhoneViewSetPhoneCustomization, 
       
   119         &pointerParam );
       
   120     
       
   121     iExtensionHandler = CPhoneExtensionHandler::NewL();
       
   122     iTransferCmdHandler = CPhoneUnattendedTransferCmdHandler::NewL( 
       
   123         iStateMachine, iViewCommandHandle );
       
   124         
       
   125     iNewCallCmdHandler = CPhoneNewCallCmdHandler::NewL( 
       
   126         iStateMachine, iViewCommandHandle );
       
   127         
       
   128     iCallForwardHandler = CPhoneCallForwardQueryHandler::NewL( 
       
   129         iStateMachine, iViewCommandHandle );
       
   130     }
       
   131 
       
   132 
       
   133 // -----------------------------------------------------------
       
   134 // CPhoneCustomizationVoip::NewL()
       
   135 // Constructor
       
   136 // -----------------------------------------------------------
       
   137 //
       
   138 CPhoneCustomizationVoip* CPhoneCustomizationVoip::NewL( 
       
   139     MPhoneStateMachine& aStateMachine,
       
   140     MPhoneViewCommandHandle& aViewCommandHandle )
       
   141     {
       
   142     CPhoneCustomizationVoip* self = new (ELeave) CPhoneCustomizationVoip( 
       
   143         aStateMachine,
       
   144         aViewCommandHandle );
       
   145     
       
   146     CleanupStack::PushL( self );
       
   147     self->ConstructL();
       
   148     CleanupStack::Pop( self );
       
   149     
       
   150     return self;
       
   151     }
       
   152 
       
   153 
       
   154 // -----------------------------------------------------------
       
   155 // From class MPhoneCustomization.
       
   156 // CPhoneCustomizationVoip::CustomizeMenuBarL
       
   157 // -----------------------------------------------------------
       
   158 // 
       
   159 void CPhoneCustomizationVoip::CustomizeMenuBarL(
       
   160         TInt aResourceId, CEikMenuBar* aMenuBar )
       
   161     {
       
   162     __LOGMETHODSTARTEND( PhoneUIVoIPExtension, 
       
   163         "CPhoneCustomizationVoip::CustomizeMenuBarL" );
       
   164     
       
   165     if ( 0 == aResourceId || !aMenuBar )
       
   166         {
       
   167         __ASSERT_DEBUG( EFalse, Panic( EPhoneCtrlParameterNotInitialized ) );
       
   168         }
       
   169     }
       
   170 
       
   171 
       
   172 // -----------------------------------------------------------
       
   173 // From class MPhoneCustomization.
       
   174 // CPhoneCustomizationVoip::CustomizeMenuPaneL
       
   175 // -----------------------------------------------------------
       
   176 //
       
   177 void CPhoneCustomizationVoip::CustomizeMenuPaneL(
       
   178     TInt aResourceId, CEikMenuPane* aMenuPane)
       
   179     {
       
   180     __LOGMETHODSTARTEND( PhoneUIVoIPExtension, 
       
   181           "CPhoneCustomizationVoip::CustomizeMenuPaneL" );
       
   182     
       
   183     CEikMenuPane* menuPane = aMenuPane;
       
   184     RArray<TInt> menuItemArray;
       
   185     CleanupClosePushL( menuItemArray );
       
   186 
       
   187     // Menu items to array
       
   188     TInt menuItemCount = menuPane->NumberOfItemsInPane();
       
   189     for ( TInt i( 0 ); i < menuItemCount; i++ )
       
   190         {
       
   191         menuItemArray.Append( menuPane->MenuItemCommandId( i ) );
       
   192         }
       
   193 
       
   194     // Menu items to be deleted 
       
   195     for ( TInt i( 0 ); i < menuItemArray.Count(); i++ )
       
   196         {
       
   197         switch( menuItemArray[ i ] )
       
   198             {
       
   199             case EPhoneDialerCmdTouchInput:
       
   200                 {
       
   201                 if ( !AllowAlphaNumericMode() )
       
   202                     {
       
   203                     menuPane->DeleteMenuItem( menuItemArray[ i ] ); 
       
   204                     }
       
   205                 break;
       
   206                 }
       
   207             case EPhoneInCallCmdTransfer:
       
   208                 {
       
   209                 if ( ! IsFeatureSupported( EFeatureTransfer ) )
       
   210                     {
       
   211                     menuPane->DeleteMenuItem( menuItemArray[ i ] ); 
       
   212                     }
       
   213                 break;
       
   214                 }
       
   215             case EPhoneInCallCmdCreateConference:
       
   216                 {
       
   217                 if ( ! IsFeatureSupported( EFeatureConference ) )
       
   218                     {
       
   219                     menuPane->DeleteMenuItem( menuItemArray[ i ] ); 
       
   220                     }
       
   221                 break;
       
   222                 }
       
   223             case EPhoneInCallCmdNewCall:
       
   224                 {
       
   225                 if ( !FeatureManager::FeatureSupported( KFeatureIdOnScreenDialer ) &&
       
   226                      AllowAlphaNumericMode() &&
       
   227                      R_PHONEUI_NEW_CALL_MENU_VOIP != aResourceId )
       
   228                     {
       
   229                         
       
   230                     menuPane->DeleteMenuItem( menuItemArray[ i ] ); 
       
   231                     
       
   232                     HBufC* string = StringLoader::LoadLC( 
       
   233                           CPhoneMainResourceResolver::Instance()->
       
   234                           ResolveResourceID( EPhoneVoIPNewCallMenuOption ) );
       
   235                           
       
   236                     CEikMenuPaneItem::SData data;
       
   237                     data.iCascadeId=R_PHONEUI_NEW_CALL_MENU_VOIP; //r_phoneui_new_call_menu_voip
       
   238                     data.iText = *string;
       
   239                     data.iFlags=0;
       
   240                     data.iCommandId = 0;             
       
   241                     
       
   242                     menuPane->InsertMenuItemL( data, i );
       
   243                     
       
   244                     CleanupStack::PopAndDestroy( string ); 
       
   245                     }
       
   246                 break;
       
   247                 }
       
   248             default: 
       
   249                 break;
       
   250             }
       
   251         }
       
   252 
       
   253     CleanupStack::PopAndDestroy( &menuItemArray );    
       
   254 
       
   255     // Added HO menu items if needed
       
   256     AddHandoverMenuItemIfNeededL( aResourceId, *aMenuPane );
       
   257     
       
   258     if ( iViewCommandHandle.HandleCommandL( 
       
   259             EPhoneViewGetNumberEntryIsVisibleStatus ) != 
       
   260             EPhoneViewResponseSuccess )
       
   261         {
       
   262         // Handle call menu without dialer/number entry
       
   263         TRAP_IGNORE( ModifyInCallMenuL( aResourceId, *aMenuPane ) );
       
   264         }
       
   265     else
       
   266         {
       
   267         // Handle dialer/number entry options menu modification
       
   268         ModifyNumberAcquisitionMenuL( aResourceId, *aMenuPane );
       
   269         }
       
   270     }
       
   271 
       
   272 
       
   273 // -----------------------------------------------------------
       
   274 // From class MPhoneCustomization.
       
   275 // CPhoneCustomizationVoip::ModifyCallHeaderTexts
       
   276 // Formats and fits VoIP address and possible display name into two lines to 
       
   277 // be shown on a call bubble. These two lines are placed on CLI and CNAP 
       
   278 // fields of the TPhoneCmdParamCallHeaderData. In a call bubble CLI-field is 
       
   279 // placed as a first line and CNAP-field is placed as a second line. 
       
   280 // -----------------------------------------------------------
       
   281 //
       
   282 void CPhoneCustomizationVoip::ModifyCallHeaderTexts( TInt aCallId, 
       
   283         TPhoneCmdParamCallHeaderData* aCommandParam,
       
   284         const TDesC& aInCallNumberText ) 
       
   285     {
       
   286     __LOGMETHODSTARTEND( PhoneUIVoIPExtension, 
       
   287         "CPhoneCustomizationVoip::ModifyCallHeaderTexts" );
       
   288     
       
   289     MPEEngineInfo& engineInfo = *iStateMachine.PhoneEngineInfo();
       
   290     
       
   291     if ( EPECallTypeVoIP == engineInfo.CallType( aCallId ) ) 
       
   292         {
       
   293         const TBool contactInfoAvailable = 
       
   294             engineInfo.RemoteName( aCallId ).Length() ||
       
   295             engineInfo.RemoteCompanyName( aCallId ).Length();
       
   296         
       
   297         if ( !contactInfoAvailable )
       
   298             {
       
   299             if ( EPEStateRinging == aCommandParam->CallState() )
       
   300                 {
       
   301                 if ( KNullDesC() != engineInfo.RemotePartyName( aCallId ) )
       
   302                     {
       
   303                     // Telephone UI specification, 4.2.1 Call identification:
       
   304                     // display name is used as the CLI if available.
       
   305                     aCommandParam->SetCLIText( 
       
   306                         engineInfo.RemotePartyName( aCallId ), 
       
   307                         TPhoneCmdParamCallHeaderData::ERight );
       
   308                     // use line reserved for CNAP to show SIP URI
       
   309                     aCommandParam->SetCNAPText( 
       
   310                         engineInfo.RemotePhoneNumber( aCallId ), 
       
   311                         TPhoneCmdParamCallHeaderData::ERight
       
   312                        );
       
   313                     }
       
   314                 else
       
   315                     {
       
   316                     TBuf<KMaxLengthForSIPURI> sipURI;
       
   317                     TBuf<KMaxLengthForSIPURI> sipURIDomainPart;
       
   318                     HandleURIFittingToCallBubble( 
       
   319                         aCommandParam->CLIText(),
       
   320                         sipURI,
       
   321                         sipURIDomainPart );
       
   322                     
       
   323                     aCommandParam->SetCLIText( sipURI, TPhoneCmdParamCallHeaderData::ERight );
       
   324                     aCommandParam->SetCNAPText( sipURIDomainPart,
       
   325                         TPhoneCmdParamCallHeaderData::ERight );
       
   326                     }
       
   327                 }
       
   328             else
       
   329                 {
       
   330                 if ( KNullDesC() == engineInfo.RemotePartyName( aCallId ) )
       
   331                     {
       
   332                     // Display name not available, set incall number text as a
       
   333                     // CLI text. Text could be 'Call 1', 'Call 2', ...
       
   334                     aCommandParam->SetCLIText( aInCallNumberText,
       
   335                         TPhoneCmdParamCallHeaderData::ERight );
       
   336                     aCommandParam->SetCNAPText( 
       
   337                         aCommandParam->CNAPText(),
       
   338                         TPhoneCmdParamCallHeaderData::ERight );
       
   339                     }
       
   340                 }
       
   341             }
       
   342         }
       
   343     }
       
   344 
       
   345 
       
   346 // -----------------------------------------------------------
       
   347 // From class MPhoneCustomization.
       
   348 // CPhoneCustomizationVoip::HandleCommandL
       
   349 // -----------------------------------------------------------
       
   350 //
       
   351 TBool CPhoneCustomizationVoip::HandleCommandL( TInt aCommand )
       
   352     {
       
   353     __LOGMETHODSTARTEND( PhoneUIVoIPExtension, 
       
   354          "CPhoneCustomizationVoip::HandleCommandL" );
       
   355     
       
   356     TBool handled( EFalse );
       
   357     switch( aCommand )
       
   358         {
       
   359         case EPhoneNumberAcqCmdInternetCall:
       
   360             {
       
   361             StateUtils().SelectServiceAndDialL();
       
   362             handled = ETrue;
       
   363             }
       
   364             break;
       
   365         case EPhoneInCallCmdNewInternetCall:
       
   366         case EPhoneCmdNewInternetCallOk:
       
   367         case EPhoneCmdNewInternetCallSearch:
       
   368         case EPhoneCmdNewInternetCallContactFetch: 
       
   369             {
       
   370             iNewCallCmdHandler->HandleCommandL( aCommand );
       
   371             handled = ETrue;
       
   372             }
       
   373             break;
       
   374         case EPhoneInCallCmdUnattendedTransfer:
       
   375         case EPhoneCmdTransferDialerOk:
       
   376         case EPhoneCmdTransferDialerExit:
       
   377         case EPhoneCmdTransferDialerSearch:
       
   378         case EPhoneCmdTransferDialerContactFetch:
       
   379             // intended fall-through
       
   380             iTransferCmdHandler->HandleCommandL( aCommand );
       
   381             handled = ETrue;
       
   382             break;
       
   383         case EPhoneCmdCancelServiceEnabling:
       
   384             {
       
   385             iStateMachine.SendPhoneEngineMessage( 
       
   386                 MPEPhoneModel::EPEMessageDisableService );
       
   387             handled = ETrue;
       
   388             }
       
   389             break;
       
   390         case EPhoneCmdServiceEnablingTimedOut:
       
   391             {
       
   392             iStateMachine.SendPhoneEngineMessage( 
       
   393                 MPEPhoneModel::EPEMessageDisableService ); 
       
   394   
       
   395             TUint32 serviceId = 
       
   396                 iStateMachine.PhoneEngineInfo()->ServiceIdCommand();
       
   397             static_cast<CPhoneStateMachineVoIP&>( iStateMachine ).
       
   398                 VoipErrorMessageHandler().ShowErrorNoteWithServiceNameL( 
       
   399                     EPhoneVoIPServiceUnavailable, serviceId );
       
   400                     
       
   401             handled = ETrue;
       
   402             }
       
   403             break;
       
   404             
       
   405         case EPhoneCmdHandoverToGsm:
       
   406             handled = ETrue;
       
   407             break;
       
   408 
       
   409         
       
   410         case EPhoneCmdHandoverToWlan:
       
   411             handled = ETrue;
       
   412             break;
       
   413             
       
   414         default:
       
   415             {
       
   416             RArray<CTelMenuExtension::TCallInfo> array;
       
   417             CleanupClosePushL( array );
       
   418             GetActiveCallArrayL( array );
       
   419             
       
   420             // Let extensions handle custom commands
       
   421             TRAP_IGNORE( handled = iExtensionHandler->HandleCommandL( 
       
   422                     ServiceIdForActivestCallL( array ),
       
   423                     aCommand ) );
       
   424 
       
   425             CleanupStack::PopAndDestroy( &array );
       
   426             }
       
   427             break;
       
   428         }
       
   429     
       
   430     return handled;
       
   431     }
       
   432 
       
   433 
       
   434 // -----------------------------------------------------------
       
   435 // From class MPhoneCustomization.
       
   436 // CPhoneCustomizationVoip::AllowAlphaNumericMode
       
   437 // -----------------------------------------------------------
       
   438 //
       
   439 TBool CPhoneCustomizationVoip::AllowAlphaNumericMode()
       
   440     {
       
   441     __LOGMETHODSTARTEND( PhoneUIVoIPExtension, 
       
   442         "CPhoneCustomizationVoip::AllowAlphaNumericMode" );
       
   443     
       
   444     TBool alphaModeSupported( EFalse );
       
   445     TRAP_IGNORE( alphaModeSupported = VoIPSupportedL() );
       
   446     
       
   447     return alphaModeSupported;
       
   448     }
       
   449 
       
   450 
       
   451 // -----------------------------------------------------------
       
   452 // From class MPhoneCustomization.
       
   453 // CPhoneCustomizationVoip::CustomizeSoftKeys
       
   454 // -----------------------------------------------------------
       
   455 //
       
   456 TInt CPhoneCustomizationVoip::CustomizeSoftKeys()
       
   457     {
       
   458     __LOGMETHODSTARTEND( PhoneUIVoIPExtension, 
       
   459         "CPhoneCustomizationVoip::CustomizeSoftKeys" );
       
   460     
       
   461     return CPhoneMainResourceResolver::Instance()->
       
   462         ResolveResourceID( EPhoneVoIPNumberAcqInternetSoftkey );
       
   463     }
       
   464 
       
   465 
       
   466 // -----------------------------------------------------------
       
   467 // From class MPhoneCustomization.
       
   468 // CPhoneCustomizationVoip::CustomizeCallHeaderText
       
   469 // -----------------------------------------------------------
       
   470 //
       
   471 TInt CPhoneCustomizationVoip::CustomizeCallHeaderText()
       
   472     {
       
   473     __LOGMETHODSTARTEND( PhoneUIVoIPExtension, 
       
   474         "CPhoneCustomizationVoip::CustomizeCallHeaderText" );
       
   475     
       
   476     return EPhoneVoIPPrivateAddress;
       
   477     }
       
   478 
       
   479 
       
   480 // -----------------------------------------------------------
       
   481 // From class MPhoneCustomization.
       
   482 // CPhoneCustomizationVoip::CustomizeBusyNoteText
       
   483 // -----------------------------------------------------------
       
   484 //
       
   485 TInt CPhoneCustomizationVoip::CustomizeBusyNoteText()
       
   486     {
       
   487     __LOGMETHODSTARTEND( PhoneUIVoIPExtension, 
       
   488         "CPhoneCustomizationVoip::CustomizeBusyNoteText" );
       
   489     
       
   490     TInt resource( EPhoneNumberBusy );
       
   491     
       
   492     const TPECallType callType =
       
   493         iStateMachine.PhoneEngineInfo()->CallTypeCommand();
       
   494     if ( callType == EPECallTypeVoIP )
       
   495         {
       
   496         resource = EPhoneVoIPNumberBusy;
       
   497         }
       
   498     
       
   499     return resource;
       
   500     }
       
   501 
       
   502 
       
   503 // -----------------------------------------------------------
       
   504 // From class MPhoneCustomization.
       
   505 // CPhoneCustomizationVoip::HandleCallFromNumberEntryL
       
   506 // -----------------------------------------------------------
       
   507 //
       
   508 TBool CPhoneCustomizationVoip::HandleCallFromNumberEntryL()
       
   509     {
       
   510     __LOGMETHODSTARTEND( PhoneUIVoIPExtension, 
       
   511         "CPhoneCustomizationVoip::HandleCallFromNumberEntryL" );
       
   512     
       
   513     TBool handled = EFalse;
       
   514     
       
   515     if ( StateUtils().IsVoipNumber() )
       
   516         {
       
   517         // Dial voip because invalid string for cs call in number entry/dialer.
       
   518         StateUtils().SelectServiceAndDialL();
       
   519         handled = ETrue;
       
   520         }
       
   521     
       
   522     return handled;
       
   523     }
       
   524 
       
   525 
       
   526 // -----------------------------------------------------------
       
   527 // From class MPhoneCustomization.
       
   528 // CPhoneCustomizationVoip::HandlePhoneEngineMessageL
       
   529 // -----------------------------------------------------------
       
   530 //
       
   531 TBool CPhoneCustomizationVoip::HandlePhoneEngineMessageL(
       
   532         const TInt aMessage, 
       
   533         TInt aCallId )
       
   534     {
       
   535     __LOGMETHODSTARTEND( PhoneUIVoIPExtension, 
       
   536         "CPhoneCustomizationVoip::HandlePhoneEngineMessageL" );
       
   537     
       
   538     TBool handled = ETrue;
       
   539     switch ( aMessage )
       
   540         {
       
   541         case MEngineMonitor::EPEMessageServiceEnabled:
       
   542         case MEngineMonitor::EPEMessageServiceDisabled:
       
   543             {
       
   544             iViewCommandHandle.ExecuteCommandL( 
       
   545                     EPhoneViewRemoveGlobalWaitNote );
       
   546             break;
       
   547             }
       
   548         case MEngineMonitor::EPEMessageServiceEnabling:
       
   549             {
       
   550             LaunchEnablingServiceNoteL();
       
   551             break; 
       
   552             }
       
   553         case MEngineMonitor::EPEMessageNoService:
       
   554             {
       
   555             SendGlobalErrorNoteL( EPhoneVoIPNoService );
       
   556             break; 
       
   557             }
       
   558         case MEngineMonitor::EPEMessageMovedPermanently:
       
   559             {
       
   560             iCallForwardHandler->
       
   561                 ShowMovedPermanentlyQueryL( aCallId );
       
   562             break;
       
   563             }    
       
   564         case MEngineMonitor::EPEMessageMultipleChoices:
       
   565             {
       
   566             iCallForwardHandler->
       
   567                 ShowMultipleChoicesQueryL( aCallId );
       
   568             break;
       
   569             }
       
   570         case MEngineMonitor::EPEMessageCallSecureStatusChanged:
       
   571             {
       
   572             HandleCallSecureStatusChangeL( aCallId );
       
   573             break;
       
   574             }
       
   575         case MEngineMonitor::EPEMessageTransferring:
       
   576             {
       
   577             iViewCommandHandle.ExecuteCommandL( EPhoneViewRemoveGlobalNote );
       
   578             CPhoneState* phoneState = 
       
   579                 static_cast< CPhoneState* >( iStateMachine.State() );    
       
   580             SendGlobalInfoNoteL( EPhoneInCallTransferred );
       
   581             break; 
       
   582             }
       
   583         case MEngineMonitor::EPEMessageRemoteForwarding:
       
   584             {
       
   585             SendGlobalErrorNoteL( EPhoneRemoteForwarding );
       
   586             break; 
       
   587             }
       
   588         default:
       
   589             handled = EFalse;
       
   590             break;
       
   591         }
       
   592     return handled;
       
   593     }
       
   594 
       
   595 // -----------------------------------------------------------
       
   596 // From class MPhoneCustomization.
       
   597 // CPhoneCustomizationVoip::HandleDialL
       
   598 // -----------------------------------------------------------
       
   599 //
       
   600 void CPhoneCustomizationVoip::HandleDialL( const TDesC& aNumber )
       
   601     {
       
   602     __LOGMETHODSTARTEND( PhoneUIVoIPExtension, 
       
   603         "CPhoneCustomizationVoip::HandleDialL" );
       
   604         
       
   605     StateUtils().SelectServiceAndDialL( aNumber, NULL );
       
   606     }
       
   607 
       
   608 // -----------------------------------------------------------
       
   609 // From class MPhoneButtonCustomization.
       
   610 // CPhoneCustomizationVoip::CustomizeTouchPaneButtons
       
   611 // -----------------------------------------------------------
       
   612 //
       
   613 void CPhoneCustomizationVoip::CustomizeTouchPaneButtons()
       
   614     {
       
   615     __LOGMETHODSTARTEND( PhoneUIVoIPExtension, 
       
   616         "CPhoneCustomizationVoip::CustomizeTouchPaneButtons" );
       
   617     }
       
   618 
       
   619 // -----------------------------------------------------------
       
   620 // CPhoneCustomizationVoip::VoIPSupportedL
       
   621 // -----------------------------------------------------------
       
   622 //
       
   623 TBool CPhoneCustomizationVoip::VoIPSupportedL()
       
   624     {
       
   625     __LOGMETHODSTARTEND( PhoneUIVoIPExtension, 
       
   626         "CPhoneCustomizationVoip::VoIPSupportedL" );
       
   627     
       
   628     TBool voipSupported( EFalse );
       
   629     
       
   630     CSPSettings* serviceProviderSettings = CSPSettings::NewL();
       
   631     voipSupported = serviceProviderSettings->IsFeatureSupported( 
       
   632         ESupportInternetCallFeature );            
       
   633     delete serviceProviderSettings;
       
   634     
       
   635     return voipSupported;   
       
   636     }
       
   637 
       
   638 
       
   639 // -----------------------------------------------------------
       
   640 // CPhoneCustomizationVoip::ModifyInCallMenuL
       
   641 // -----------------------------------------------------------
       
   642 //
       
   643 void CPhoneCustomizationVoip::ModifyInCallMenuL( TInt aResourceId, CEikMenuPane& aMenuPane )
       
   644     {
       
   645     __LOGMETHODSTARTEND( PhoneUIVoIPExtension, 
       
   646         "CPhoneCustomizationVoip::ModifyInCallMenuL" );
       
   647     
       
   648     if ( aResourceId != R_AVKON_MENUPANE_FEP_DEFAULT &&
       
   649         aResourceId != R_AVKON_MENUPANE_EDITTEXT_DEFAULT &&
       
   650         aResourceId != R_AVKON_MENUPANE_LANGUAGE_DEFAULT )
       
   651         {
       
   652         RArray<CTelMenuExtension::TCallInfo> array;
       
   653         CleanupClosePushL( array );
       
   654         
       
   655         GetActiveCallArrayL( array );
       
   656 
       
   657         // Use extensions for menu modifications 
       
   658         iExtensionHandler->ModifyInCallMenuL(
       
   659                 ServiceIdForActivestCallL( array ),
       
   660                 array,
       
   661                 aResourceId,
       
   662                 aMenuPane );
       
   663         
       
   664         __PHONELOG( EBasic, PhoneUIVoIPExtension,
       
   665             "CPhoneCustomizationVoip::ModifyInCallMenuL() plugin exists" );
       
   666         
       
   667         CleanupStack::PopAndDestroy( &array );
       
   668         }
       
   669     }
       
   670 
       
   671 
       
   672 // -----------------------------------------------------------
       
   673 // CPhoneCustomizationVoip::ModifyNumberAcquisitionMenuL
       
   674 // This function is called when user opens menu from dialler/number entry.
       
   675 // -----------------------------------------------------------
       
   676 //
       
   677 void CPhoneCustomizationVoip::ModifyNumberAcquisitionMenuL(
       
   678         TInt aResourceId, CEikMenuPane& aMenuPane )
       
   679     {
       
   680     __LOGMETHODSTARTEND( PhoneUIVoIPExtension, 
       
   681         "CPhoneCustomizationVoip::ModifyNumberAcquisitionMenuL");
       
   682     
       
   683     if ( ( aResourceId == R_PHONEUI_NUMBERACQ_OPTIONS_CALL_MENU ||
       
   684            aResourceId == R_PHONEUI_NUMBERACQ_OPTIONS_MENU ||
       
   685            aResourceId == R_PHONEUIDIALER_OPTIONS_MENU ) &&
       
   686            VoIPSupportedL() )
       
   687         {
       
   688         InsertInternetCallMenuItemL( aResourceId, aMenuPane );
       
   689         }
       
   690     
       
   691     if ( ( aResourceId == R_PHONEUI_NUMBERACQ_OPTIONS_MENU ||
       
   692            aResourceId == R_PHONEUI_NUMBERACQ_OPTIONS_MENU_VOIP ||
       
   693            aResourceId == R_PHONEUI_NUMBERACQ_OPTIONS_MENU_VOIP_WITH_SERVICE_NUMBER ) &&
       
   694            VoIPSupportedL() )
       
   695         {
       
   696         InsertTextInputModeChangeMenuItemL( aMenuPane );
       
   697         }
       
   698     }
       
   699 
       
   700 
       
   701 // -----------------------------------------------------------
       
   702 // CPhoneCustomizationVoip::InsertInternetCallMenuItemL
       
   703 // -----------------------------------------------------------
       
   704 //
       
   705 void CPhoneCustomizationVoip::InsertInternetCallMenuItemL( 
       
   706         TInt aResourceId, CEikMenuPane& aMenuPane )
       
   707     {
       
   708     __LOGMETHODSTARTEND( PhoneUIVoIPExtension, 
       
   709         "CPhoneCustomizationVoip::InsertInternetCallMenuItemL" );
       
   710 
       
   711     // get VoIP services
       
   712     RIdArray voipServices;
       
   713     CleanupClosePushL( voipServices );
       
   714     GetVoIPServiceIdsL( voipServices );
       
   715     
       
   716     CEikMenuPaneItem* voipMenuItem = NULL;
       
   717     
       
   718     if ( 1 == voipServices.Count() )
       
   719         {
       
   720         voipMenuItem = CreateMenuPaneItemLC( 
       
   721             EPhoneNumberAcqCmdInternetCall,
       
   722             voipServices[0] );
       
   723         }
       
   724     else
       
   725         {
       
   726         voipMenuItem = CreateMenuPaneItemLC( 
       
   727             EPhoneNumberAcqCmdInternetCall,
       
   728             CPhoneMainResourceResolver::Instance()->
       
   729                 ResolveResourceID( EPhoneVoIPCallTypeInternet ) );
       
   730         }
       
   731 
       
   732     HBufC* phoneNumber = PhoneNumberFromEntryLC();
       
   733 
       
   734     if ( aResourceId == R_PHONEUI_NUMBERACQ_OPTIONS_CALL_MENU )
       
   735         {
       
   736         if ( !CPhoneKeys::Validate( phoneNumber->Des() ) )
       
   737             {
       
   738             TInt index(KErrNotFound);
       
   739             if ( aMenuPane.MenuItemExists( EPhoneNumberAcqCmdCall, index ) )
       
   740                 {
       
   741                 aMenuPane.DeleteMenuItem( EPhoneNumberAcqCmdCall );
       
   742                 }
       
   743             
       
   744             if ( aMenuPane.MenuItemExists( EPhoneNumberAcqCmdVideoCall, index ) )
       
   745                 {
       
   746                 aMenuPane.DeleteMenuItem( EPhoneNumberAcqCmdVideoCall );
       
   747                 }
       
   748             }
       
   749         
       
   750         aMenuPane.AddMenuItemL( voipMenuItem->iData );
       
   751         }
       
   752     else if ( iStateMachine.PhoneEngineInfo()->PhoneNumberIsServiceCode() )
       
   753         {
       
   754         // When user writes string recognized as service code (eg.*#31# -> clir off)
       
   755         // call menu is not visible. Internet call must still be possible so 
       
   756         // internet call option is added here to the menu.
       
   757         
       
   758         // If number entry is empty don't add internet call option 
       
   759         if ( phoneNumber->Length() )
       
   760             {
       
   761             // Internet call item must be on the top of the menu
       
   762             aMenuPane.InsertMenuItemL( voipMenuItem->iData, 0 );
       
   763             }
       
   764         }
       
   765     
       
   766     CleanupStack::PopAndDestroy( 3, &voipServices );
       
   767     }
       
   768 
       
   769 
       
   770 // -----------------------------------------------------------
       
   771 // CPhoneCustomizationVoip::InsertTextInputModeChangeMenuItemL
       
   772 // -----------------------------------------------------------
       
   773 //
       
   774 void CPhoneCustomizationVoip::InsertTextInputModeChangeMenuItemL( 
       
   775         CEikMenuPane& aMenuPane )
       
   776     {
       
   777     __LOGMETHODSTARTEND( PhoneUIVoIPExtension, 
       
   778         "CPhoneCustomizationVoip::InsertTextInputModeChangeMenuItemL" );
       
   779     
       
   780     TInt modeChangeOptionIndex = KErrNotFound;
       
   781     if ( aMenuPane.MenuItemExists( 
       
   782              EPhoneNumberAcqCmdToggleNeAlphaMode, modeChangeOptionIndex ) ||
       
   783          aMenuPane.MenuItemExists( 
       
   784              EPhoneNumberAcqCmdToggleNeNumericMode, modeChangeOptionIndex ) )
       
   785         {
       
   786         __PHONELOG( EBasic, PhoneUIVoIPExtension,
       
   787             "InsertTextInputModeChangeMenuItemL, MENU ITEM ALREADY EXISTS" );
       
   788         __ASSERT_DEBUG( EFalse, Panic( EPhoneCtrlInvariant ) );
       
   789         }
       
   790     
       
   791     CEikMenuPaneItem* menuItem = NULL;
       
   792     TBool numberEntryInNumericMode = iViewCommandHandle.HandleCommandL( 
       
   793         EPhoneViewIsNumberEntryNumericMode ) == EPhoneViewResponseSuccess;
       
   794     if ( numberEntryInNumericMode )
       
   795         {
       
   796         menuItem = CreateMenuPaneItemLC( 
       
   797             EPhoneNumberAcqCmdToggleNeAlphaMode,
       
   798             R_PHONEUI_NUMBERACQ_OPTIONS_MENU_ITEM_ALPHA_MODE );
       
   799         }
       
   800     else
       
   801         {
       
   802         menuItem = CreateMenuPaneItemLC( 
       
   803             EPhoneNumberAcqCmdToggleNeNumericMode,
       
   804             R_PHONEUI_NUMBERACQ_OPTIONS_MENU_ITEM_NUMERIC_MODE );
       
   805         }
       
   806     
       
   807     // alpha/numeric mode option is always second item in number entry menu
       
   808     const TInt KTextInputModeChangeMenuItemIndex = 1;
       
   809     aMenuPane.InsertMenuItemL( 
       
   810         menuItem->iData, KTextInputModeChangeMenuItemIndex );
       
   811     CleanupStack::PopAndDestroy( menuItem );
       
   812     }
       
   813 
       
   814 
       
   815 // -----------------------------------------------------------
       
   816 // CPhoneCustomizationVoip::GetActiveCallArrayL
       
   817 // -----------------------------------------------------------
       
   818 //
       
   819 void CPhoneCustomizationVoip::GetActiveCallArrayL( 
       
   820         RArray<CTelMenuExtension::TCallInfo>& aArray )
       
   821     {
       
   822     __LOGMETHODSTARTEND( PhoneUIVoIPExtension, 
       
   823         "CPhoneCustomizationVoip::GetActiveCallArrayL");
       
   824     
       
   825     MPEEngineInfo* engineInfo = iStateMachine.PhoneEngine()->EngineInfo();
       
   826     
       
   827     for( TInt i = 0; i < KPEMaximumNumberOfCalls; i++ )
       
   828         {
       
   829         CTelMenuExtension::TCallInfo callInfo;
       
   830         callInfo.iCallId = i;
       
   831         callInfo.iServiceId = engineInfo->ServiceId( i );
       
   832         callInfo.iCallType = CTelMenuExtension::EUninitialized;
       
   833 
       
   834         switch( engineInfo->CallType( i ) )
       
   835             {
       
   836             case EPECallTypeUninitialized:
       
   837                 callInfo.iCallType = CTelMenuExtension::EUninitialized;
       
   838                 break;
       
   839             case EPECallTypeCSVoice:
       
   840                 callInfo.iCallType = CTelMenuExtension::ECsVoice;
       
   841                 break;
       
   842             case EPECallTypeVideo:
       
   843                 callInfo.iCallType = CTelMenuExtension::ECsVideo;
       
   844                 break;
       
   845             case EPECallTypeVoIP:
       
   846                 callInfo.iCallType = CTelMenuExtension::EPsVoice;
       
   847                 break;
       
   848             default:
       
   849                 break;
       
   850             }
       
   851         
       
   852         callInfo.iCallState = CTelMenuExtension::ENone;
       
   853         
       
   854         // Convert call bubble indications to call states
       
   855         switch( engineInfo->CallState( i ) )
       
   856             {
       
   857             // Call states                        0 - 499
       
   858             case EPEStateDialing:
       
   859             case EPEStateEmergencyDialing:
       
   860             case EPEStateConnecting:
       
   861                 callInfo.iCallState = CTelMenuExtension::EOutgoing;
       
   862                 break;
       
   863             case EPEStateAnswering:
       
   864             case EPEStateRinging:
       
   865                 callInfo.iCallState = CTelMenuExtension::EIncoming;
       
   866                 break;
       
   867 
       
   868             case EPEStateConnectedConference:
       
   869             case EPEStateConnected:
       
   870                 callInfo.iCallState = CTelMenuExtension::EActive;
       
   871                 break;
       
   872 
       
   873             case EPEStateHeldConference:
       
   874             case EPEStateHeld:
       
   875                 callInfo.iCallState = CTelMenuExtension::EOnHold;
       
   876                 break;
       
   877             
       
   878             case EPEStateHangingUpConference:
       
   879             case EPEStateRejecting:
       
   880             case EPEStateHangingUp:
       
   881             case EPEStateDisconnecting:
       
   882                 callInfo.iCallState = CTelMenuExtension::EDisconnecting;
       
   883                 break;
       
   884                 
       
   885             case EPEStateUnknown:
       
   886             case EPEStateIdle:
       
   887             case EPEStateConferenceIdle:
       
   888                 break;
       
   889                 
       
   890             // conference
       
   891             case EPEStateCreatingConference:
       
   892             case EPEStateSwappingConference:
       
   893             case EPEStateResumeHoldConference:
       
   894             // misc states.
       
   895             case EPEStateMaximumState:
       
   896             default:
       
   897                 User::Leave( KErrNotReady );
       
   898                 break;
       
   899             }
       
   900 
       
   901         if( callInfo.iCallState != CTelMenuExtension::ENone )
       
   902             {
       
   903             aArray.Append( callInfo );                                   
       
   904             }
       
   905 
       
   906         }
       
   907     }
       
   908 
       
   909 
       
   910 // -----------------------------------------------------------
       
   911 // CPhoneCustomizationVoip::ResolveMostActiveCallL
       
   912 // -----------------------------------------------------------
       
   913 //
       
   914 TInt CPhoneCustomizationVoip::ResolveMostActiveCallL( 
       
   915         const RArray<CTelMenuExtension::TCallInfo>& aArray )
       
   916     {
       
   917     __LOGMETHODSTARTEND( PhoneUIVoIPExtension, 
       
   918         "CPhoneCustomizationVoip::ResolveMostActiveCallL" );
       
   919     
       
   920     TInt incomingCallId( KErrNotFound );
       
   921     TInt activeCallId( KErrNotFound );
       
   922     TInt onholdCallId( KErrNotFound );
       
   923     TInt disconnectingCallId( KErrNotFound );
       
   924     
       
   925     for( TInt i = 0; i < aArray.Count(); i++ )
       
   926         {
       
   927         if( aArray[i].iCallState == CTelMenuExtension::EOutgoing )
       
   928             {
       
   929             // Always most active call
       
   930             return aArray[i].iCallId;
       
   931             }
       
   932         else if( aArray[i].iCallState == CTelMenuExtension::EActive )
       
   933             {
       
   934             activeCallId = aArray[i].iCallId;
       
   935             }
       
   936         else if( aArray[i].iCallState == CTelMenuExtension::EIncoming )
       
   937             {
       
   938             incomingCallId = aArray[i].iCallId;
       
   939             }
       
   940         else if( aArray[i].iCallState == CTelMenuExtension::EOnHold )
       
   941             {
       
   942             onholdCallId = aArray[i].iCallId;
       
   943             }
       
   944         else if( aArray[i].iCallState == CTelMenuExtension::EDisconnecting )
       
   945             {
       
   946             disconnectingCallId = aArray[i].iCallId;
       
   947             }
       
   948         }
       
   949     
       
   950     if( activeCallId != KErrNotFound )
       
   951         {
       
   952         return activeCallId;
       
   953         }
       
   954     else if( incomingCallId != KErrNotFound )
       
   955         {
       
   956         return incomingCallId;
       
   957         }
       
   958     else if( onholdCallId != KErrNotFound )
       
   959         {
       
   960         return onholdCallId;
       
   961         }
       
   962     else if( disconnectingCallId != KErrNotFound )
       
   963         {
       
   964         return disconnectingCallId;
       
   965         }
       
   966     else
       
   967         {
       
   968         User::Leave( KErrNotFound );
       
   969         }
       
   970     
       
   971     return KErrNotFound;
       
   972     }
       
   973 
       
   974 
       
   975 // -----------------------------------------------------------
       
   976 // CPhoneCustomizationVoip::ServiceIdForActivestCallL
       
   977 // (other items were commented in a header).
       
   978 // -----------------------------------------------------------
       
   979 //
       
   980 TUint CPhoneCustomizationVoip::ServiceIdForActivestCallL(
       
   981         const RArray<CTelMenuExtension::TCallInfo>& aCallArray )
       
   982     {   
       
   983     __LOGMETHODSTARTEND( PhoneUIVoIPExtension, 
       
   984         "CPhoneCustomizationVoip::ServiceIdForActivestCallL" );
       
   985     
       
   986     const TInt KActiveCallId = ResolveMostActiveCallL( aCallArray );
       
   987      
       
   988     MPEEngineInfo* engineInfo = iStateMachine.PhoneEngine()->EngineInfo();
       
   989     
       
   990     // Return service id for activest call
       
   991     return engineInfo->ServiceId( KActiveCallId ); 
       
   992     }
       
   993 
       
   994 
       
   995 // -----------------------------------------------------------
       
   996 // CPhoneCustomizationVoip::IsFeatureSupported()
       
   997 // (other items were commented in a header).
       
   998 // -----------------------------------------------------------
       
   999 //
       
  1000 TBool CPhoneCustomizationVoip::IsFeatureSupported( TFeature aFeature )
       
  1001     { 
       
  1002     __LOGMETHODSTARTEND( PhoneUIVoIPExtension, 
       
  1003         "CPhoneCustomizationVoip::IsFeatureSupported" );
       
  1004     
       
  1005     TBool ret( EFalse );
       
  1006 
       
  1007     TRAP_IGNORE( ret = CheckFeatureSupportByCallTypeL( aFeature ) );
       
  1008     
       
  1009     __PHONELOG1( EBasic, PhoneUIVoIPExtension, 
       
  1010         "CPhoneCustomizationVoip::IsFeatureSupported =%d", ret  );
       
  1011     
       
  1012     return ret;
       
  1013     }
       
  1014 
       
  1015 
       
  1016 // -----------------------------------------------------------
       
  1017 // CPhoneCustomizationVoip::CheckFeatureSupportByCallTypeL()
       
  1018 // (other items were commented in a header).
       
  1019 // -----------------------------------------------------------
       
  1020 //
       
  1021 TBool CPhoneCustomizationVoip::CheckFeatureSupportByCallTypeL( 
       
  1022         TFeature aFeature )
       
  1023     { 
       
  1024     __LOGMETHODSTARTEND( PhoneUIVoIPExtension, 
       
  1025         "CPhoneCustomizationVoip::CheckFeatureSupportByCallTypeL" );
       
  1026     
       
  1027     if ( aFeature != EFeatureConference &&
       
  1028          aFeature != EFeatureTransfer )
       
  1029         {
       
  1030         return ETrue;
       
  1031         }
       
  1032     
       
  1033     RArray<CTelMenuExtension::TCallInfo> array;
       
  1034     CleanupClosePushL( array );
       
  1035     GetActiveCallArrayL( array );
       
  1036     __PHONELOG1( EBasic, PhoneUIVoIPExtension, 
       
  1037         "CPhoneCustomizationVoip::CheckFeatureSupportByCallTypeL CallCount=%d", 
       
  1038         array.Count()  );
       
  1039     
       
  1040     TBool supported( ETrue );
       
  1041     TInt firstCallType = CTelMenuExtension::EUninitialized;
       
  1042     for( TInt i = 0; i < array.Count(); i++ )
       
  1043         {
       
  1044         if( array[i].iCallState == CTelMenuExtension::EOutgoing ||
       
  1045             array[i].iCallState == CTelMenuExtension::EActive ||
       
  1046             array[i].iCallState == CTelMenuExtension::EOnHold )
       
  1047             {
       
  1048             if( firstCallType == CTelMenuExtension::EUninitialized )
       
  1049                 {
       
  1050                 // Memorize first found call type
       
  1051                 firstCallType = array[i].iCallType;
       
  1052                 }
       
  1053             else if( firstCallType != array[i].iCallType )
       
  1054                 {
       
  1055                 // Found different call type
       
  1056                 supported = EFalse;
       
  1057                 break;
       
  1058                 }
       
  1059             }
       
  1060 
       
  1061         }
       
  1062     
       
  1063     CleanupStack::PopAndDestroy( &array );
       
  1064 
       
  1065     return supported;
       
  1066     }
       
  1067 
       
  1068 // -----------------------------------------------------------
       
  1069 // CPhoneCustomizationVoip::LaunchEnablingServiceNoteL
       
  1070 // -----------------------------------------------------------
       
  1071 //
       
  1072 void CPhoneCustomizationVoip::LaunchEnablingServiceNoteL()
       
  1073     {
       
  1074     __LOGMETHODSTARTEND( PhoneUIVoIPExtension, 
       
  1075         "CPhoneCustomizationVoip::LaunchEnablingServiceNoteL" )
       
  1076     
       
  1077     TPhoneCmdParamQuery queryParam;
       
  1078     queryParam.SetQueryType( EPhoneGlobalWaitNote );
       
  1079     queryParam.SetCommandParamId( 
       
  1080         TPhoneCommandParam::EPhoneParamIdGlobalWaitNote );
       
  1081     
       
  1082     RBuf serviceName;
       
  1083     CleanupClosePushL( serviceName );
       
  1084     TUint32 serviceId = 
       
  1085         iStateMachine.PhoneEngineInfo()->ServiceIdCommand(); 
       
  1086     static_cast<CPhoneStateMachineVoIP&>( iStateMachine ).
       
  1087         VoipErrorMessageHandler().GetServiceProviderNameL( 
       
  1088         serviceName, serviceId );
       
  1089     
       
  1090     RBuf noteText;
       
  1091     CleanupClosePushL( noteText );
       
  1092     noteText.Assign( StringLoader::LoadL( 
       
  1093     CPhoneMainResourceResolver::Instance()->ResolveResourceID( 
       
  1094         EPhoneVoIPEnablingServiceWaitNoteText ), serviceName ) );
       
  1095     
       
  1096     queryParam.SetDataText( &noteText );  
       
  1097     queryParam.SetDefaultCba( R_AVKON_SOFTKEYS_CANCEL );
       
  1098     
       
  1099     const TInt KEnableServiceTimeOutInMilliSecs = 60000;
       
  1100     queryParam.SetTimeOut( KEnableServiceTimeOutInMilliSecs );
       
  1101 
       
  1102     // configure custom command mappings for user responses
       
  1103     queryParam.SetCbaCommandMapping( 
       
  1104         EAknSoftkeyCancel, EPhoneCmdCancelServiceEnabling );
       
  1105     queryParam.SetCbaCommandMapping( 
       
  1106         KErrCancel, EPhoneCmdCancelServiceEnabling );
       
  1107     queryParam.SetCustomCommandForTimeOut( EPhoneCmdServiceEnablingTimedOut ); 
       
  1108     iViewCommandHandle.ExecuteCommandL( EPhoneViewShowQuery, &queryParam );
       
  1109      
       
  1110     CleanupStack::PopAndDestroy( &noteText );
       
  1111     CleanupStack::PopAndDestroy( &serviceName ); 
       
  1112     }
       
  1113 
       
  1114 
       
  1115 // ---------------------------------------------------------
       
  1116 //  CPhoneCustomizationVoip::SendGlobalErrorNoteL
       
  1117 // ---------------------------------------------------------
       
  1118 //
       
  1119 void CPhoneCustomizationVoip::SendGlobalErrorNoteL( TInt aResourceId )
       
  1120     {
       
  1121     __LOGMETHODSTARTEND( PhoneUIVoIPExtension, 
       
  1122         "CPhoneCustomizationVoip::SendGlobalErrorNoteL" );
       
  1123     
       
  1124     __ASSERT_DEBUG( aResourceId, Panic( EPhoneCtrlParameterNotInitialized ) );
       
  1125     
       
  1126     CPhoneState* phoneState = 
       
  1127         static_cast< CPhoneState* >( iStateMachine.State() );       
       
  1128             
       
  1129     phoneState->SendGlobalErrorNoteL( aResourceId );        
       
  1130     }
       
  1131 
       
  1132 
       
  1133 // ---------------------------------------------------------
       
  1134 //  CPhoneCustomizationVoip::SendGlobalInfoNoteL
       
  1135 // ---------------------------------------------------------
       
  1136 //
       
  1137 void CPhoneCustomizationVoip::SendGlobalInfoNoteL( TInt aResourceId )
       
  1138     {
       
  1139     __LOGMETHODSTARTEND( PhoneUIVoIPExtension, 
       
  1140         "CPhoneCustomizationVoip::SendGlobalInfoNoteL" );
       
  1141     
       
  1142     __ASSERT_DEBUG( aResourceId, Panic( EPhoneCtrlParameterNotInitialized ) );
       
  1143     
       
  1144     CPhoneState* phoneState = 
       
  1145         static_cast< CPhoneState* >( iStateMachine.State() );       
       
  1146     
       
  1147     phoneState->SendGlobalInfoNoteL( aResourceId );
       
  1148     }
       
  1149 
       
  1150 
       
  1151 // -----------------------------------------------------------
       
  1152 // CPhoneCustomizationVoip::HandleURIFittingToCallBubble
       
  1153 // -----------------------------------------------------------
       
  1154 //
       
  1155 void CPhoneCustomizationVoip::HandleURIFittingToCallBubble( 
       
  1156     const TDesC& aCLIText, TDes& aSipURI, TDes& aSipURIDomainPart )
       
  1157     {
       
  1158     __LOGMETHODSTARTEND( PhoneUIVoIPExtension,
       
  1159         "CPhoneCustomizationVoip::HandleURIFittingToCallBubble" );
       
  1160     
       
  1161     TInt cliLength = aCLIText.Length();
       
  1162     if ( KMaxLengthForSIPURIFirstLine > cliLength )
       
  1163         {
       
  1164         aSipURI.Copy( aCLIText );
       
  1165         aSipURIDomainPart.Copy( KNullDesC );
       
  1166         }
       
  1167     else if ( KMaxLengthForSIPURITwoLines > cliLength )
       
  1168         {
       
  1169         aSipURI.Copy( aCLIText.Mid( 0, KMaxLengthForSIPURIFirstLine ) );
       
  1170         aSipURIDomainPart.Copy( aCLIText.Mid( KMaxLengthForSIPURIFirstLine,
       
  1171             cliLength-KMaxLengthForSIPURIFirstLine ) );
       
  1172         }
       
  1173     else  
       
  1174         {
       
  1175         TInt atPosition = aCLIText.Find( KVoipAt );
       
  1176         if ( atPosition == KErrNotFound )
       
  1177             {
       
  1178             atPosition = KMaxLengthForSIPURIFirstLine;
       
  1179             }
       
  1180         aSipURI.Copy( aCLIText.Mid( 0, atPosition ) );
       
  1181         aSipURIDomainPart.Copy( aCLIText.Mid( atPosition,
       
  1182             ( cliLength-atPosition ) ) );
       
  1183         }      
       
  1184     }
       
  1185 
       
  1186 
       
  1187 // -----------------------------------------------------------
       
  1188 // CPhoneCustomizationVoip::StateUtils
       
  1189 // -----------------------------------------------------------
       
  1190 //
       
  1191 CPhoneStateUtilsVoip& CPhoneCustomizationVoip::StateUtils()
       
  1192     {
       
  1193     return static_cast<CPhoneStateMachineVoIP&>( iStateMachine ).StateUtils();
       
  1194     }
       
  1195 
       
  1196 
       
  1197 // -----------------------------------------------------------
       
  1198 // CPhoneCustomizationVoip::HandleSecureStatusChangeL
       
  1199 // -----------------------------------------------------------
       
  1200 //
       
  1201 void CPhoneCustomizationVoip::HandleCallSecureStatusChangeL( TInt aCallId )
       
  1202     {
       
  1203     __LOGMETHODSTARTEND( PhoneUIVoIPExtension, 
       
  1204         "CPhoneCustomizationVoip::HandleCallSecureStatusChangeL" );
       
  1205     
       
  1206     if ( KErrNotFound < aCallId )
       
  1207         {
       
  1208         if ( ( EPECallTypeVoIP == 
       
  1209             iStateMachine.PhoneEngineInfo()->CallType( aCallId ) ) &&
       
  1210             !iStateMachine.PhoneEngineInfo()->IsSecureCall( aCallId ) ) 
       
  1211             {
       
  1212             TInt state = iStateMachine.PhoneEngineInfo()->CallState( 
       
  1213                 aCallId );
       
  1214             switch ( state )
       
  1215                 {      
       
  1216                 case EPEStateConnected:
       
  1217                     {
       
  1218                     iViewCommandHandle.ExecuteCommand( 
       
  1219                         EPhoneViewCipheringInfoChangePlayTone );
       
  1220                     break;
       
  1221                     }
       
  1222                 case EPEStateDialing:
       
  1223                     {
       
  1224                     SendGlobalInfoNoteL( 
       
  1225                         EPhoneSSNotificationTextVoipSipsFailed );
       
  1226                     break;
       
  1227                     }
       
  1228                 default:
       
  1229                     break;
       
  1230                 
       
  1231                 }
       
  1232             }
       
  1233         }
       
  1234     }
       
  1235 
       
  1236 
       
  1237 // -----------------------------------------------------------
       
  1238 // CPhoneCustomizationVoip::CreateMenuPaneItemLC
       
  1239 // -----------------------------------------------------------
       
  1240 //
       
  1241 CEikMenuPaneItem* CPhoneCustomizationVoip::CreateMenuPaneItemLC( 
       
  1242         TInt aCommandId, TInt aTextResourceId ) const
       
  1243     {
       
  1244     __LOGMETHODSTARTEND( PhoneUIVoIPExtension, 
       
  1245         "CPhoneCustomizationVoip::CreateMenuPaneItemLC" );
       
  1246     
       
  1247     CEikMenuPaneItem::SData data;
       
  1248     data.iCommandId = aCommandId;
       
  1249     data.iCascadeId = 0;
       
  1250     data.iFlags = 0;
       
  1251     iCoeEnv.ReadResourceL( data.iText, aTextResourceId );    
       
  1252     data.iExtraText = KNullDesC();
       
  1253     
       
  1254     CEikMenuPaneItem* menuItem = new ( ELeave ) CEikMenuPaneItem();
       
  1255     CleanupStack::PushL( menuItem );
       
  1256     menuItem->iData = data;
       
  1257     
       
  1258     return menuItem;
       
  1259     }
       
  1260 
       
  1261 
       
  1262 // -----------------------------------------------------------
       
  1263 // CPhoneCustomizationVoip::CreateMenuPaneItemLC
       
  1264 // -----------------------------------------------------------
       
  1265 //
       
  1266 CEikMenuPaneItem* CPhoneCustomizationVoip::CreateMenuPaneItemLC(
       
  1267     TInt aCommandId, TServiceId aServiceId ) const
       
  1268     {
       
  1269     __LOGMETHODSTARTEND( PhoneUIVoIPExtension, 
       
  1270         "CPhoneCustomizationVoip::CreateMenuPaneItemLC" );
       
  1271 
       
  1272     CEikMenuPaneItem::SData data;
       
  1273     data.iCommandId = aCommandId;
       
  1274     data.iCascadeId = 0;
       
  1275     data.iFlags = 0;
       
  1276     data.iExtraText = KNullDesC();
       
  1277 
       
  1278     // insert service name
       
  1279     TBuf<KMaxVoIPServiceName> serviceName;
       
  1280     GetVoipServiceNameL( aServiceId, serviceName );
       
  1281     
       
  1282     HBufC* callText = StringLoader::LoadLC(
       
  1283         CPhoneMainResourceResolver::Instance()
       
  1284             ->ResolveResourceID( EPhoneVoIPNumberAcqXSPCall ),
       
  1285         serviceName );
       
  1286     
       
  1287     data.iText.Append( *callText );
       
  1288     
       
  1289     CleanupStack::PopAndDestroy( callText );
       
  1290 
       
  1291     CEikMenuPaneItem* menuItem = new ( ELeave ) CEikMenuPaneItem();
       
  1292     CleanupStack::PushL( menuItem );
       
  1293     menuItem->iData = data;
       
  1294 
       
  1295     return menuItem;
       
  1296     }
       
  1297 
       
  1298     
       
  1299 // -----------------------------------------------------------
       
  1300 // CPhoneCustomizationVoip::AddHandoverMenuItemIfNeededL
       
  1301 // -----------------------------------------------------------
       
  1302 //
       
  1303 void CPhoneCustomizationVoip::AddHandoverMenuItemIfNeededL( TInt /*aResourceId*/,
       
  1304         CEikMenuPane& /*aMenuPane*/ )
       
  1305     {
       
  1306     __LOGMETHODSTARTEND( PhoneUIVoIPExtension, 
       
  1307         "CPhoneCustomizationVoip::AddHandoverMenuItemIfNeededL" );
       
  1308     }
       
  1309     
       
  1310 // -----------------------------------------------------------
       
  1311 // CPhoneCustomizationVoip::GetVoIPServiceIdsL
       
  1312 // -----------------------------------------------------------
       
  1313 //
       
  1314 void CPhoneCustomizationVoip::GetVoIPServiceIdsL( RIdArray& aVoipServiceIds ) const
       
  1315     {
       
  1316     aVoipServiceIds.Reset();
       
  1317 
       
  1318     // Fetch the settings api.
       
  1319     CSPSettings* settingsApi = CSPSettings::NewLC();
       
  1320         
       
  1321     // read all service ids to array
       
  1322     RIdArray idArray;
       
  1323     CleanupClosePushL( idArray );
       
  1324         
       
  1325     if ( KErrNone == settingsApi->FindServiceIdsL( idArray ) )
       
  1326         {
       
  1327         // go throught all the services and check if any
       
  1328         // of them supports internet call
       
  1329         for ( TInt i = 0; idArray.Count() > i; i++)
       
  1330             {
       
  1331             // check if the service supports internet call
       
  1332             CSPProperty* property = CSPProperty::NewLC();
       
  1333 
       
  1334             // get attribute mask of the service
       
  1335             TRAPD( error, error = settingsApi->FindPropertyL( idArray[i],
       
  1336                 EPropertyServiceAttributeMask, *property ) );
       
  1337 
       
  1338             if ( KErrNone == error )
       
  1339                 {
       
  1340                 // read the value of mask property
       
  1341                 TInt mask = 0;
       
  1342                 error = property->GetValue( mask );
       
  1343                 if ( KErrNone == error )
       
  1344                     {
       
  1345                     if ( ( mask & ESupportsInternetCall )
       
  1346                         && ( mask & EIsVisibleInCallMenu ) )
       
  1347                         {
       
  1348                         aVoipServiceIds.Append( idArray[i] );
       
  1349                         }
       
  1350                     }
       
  1351                 }
       
  1352             CleanupStack::PopAndDestroy( property );
       
  1353             }
       
  1354         }
       
  1355 
       
  1356     CleanupStack::PopAndDestroy( 2, settingsApi );
       
  1357     }
       
  1358 
       
  1359 
       
  1360 // -----------------------------------------------------------
       
  1361 // CPhoneCustomizationVoip::GetVoIPServiceIdsL
       
  1362 // -----------------------------------------------------------
       
  1363 //
       
  1364 void CPhoneCustomizationVoip::GetVoipServiceNameL( TServiceId aServiceId, TDes& aServiceName ) const
       
  1365     {
       
  1366     CSPSettings* settingsApi = CSPSettings::NewLC();
       
  1367     CSPProperty* property = CSPProperty::NewLC();
       
  1368 
       
  1369     settingsApi->FindPropertyL( aServiceId, EServiceName, *property );
       
  1370     property->GetValue( aServiceName );
       
  1371     
       
  1372     CleanupStack::PopAndDestroy( 2, settingsApi );
       
  1373     }
       
  1374 
       
  1375 // -----------------------------------------------------------
       
  1376 // CPhoneCustomizationVoip::PhoneNumberFromEntryLC
       
  1377 // -----------------------------------------------------------
       
  1378 //
       
  1379 HBufC* CPhoneCustomizationVoip::PhoneNumberFromEntryLC() const
       
  1380     {
       
  1381     HBufC* phoneNumber = HBufC::NewLC( KPhoneNumberEntryBufferSize );
       
  1382     
       
  1383     TPtr ptr( phoneNumber->Des() );
       
  1384     TPhoneCmdParamString stringParam;
       
  1385     stringParam.SetString( &ptr );
       
  1386     iViewCommandHandle.ExecuteCommand(
       
  1387         EPhoneViewGetNumberFromEntry,
       
  1388         &stringParam );
       
  1389     
       
  1390     return phoneNumber;
       
  1391     }
       
  1392 
       
  1393 // End of File