phoneapp/phoneuivoipextension/src/cphonevoiperrormessageshandler.cpp
changeset 0 5f000ab63145
child 24 41a7f70b3818
equal deleted inserted replaced
-1:000000000000 0:5f000ab63145
       
     1 /*
       
     2 * Copyright (c) 2008 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 CPhoneVoIPErrorMessagesHandler class.
       
    15 *
       
    16 */
       
    17 
       
    18 // INCLUDES
       
    19 
       
    20 #include <ccpdefs.h>
       
    21 #include <mpeengineinfo.h>
       
    22 #include <StringLoader.h>
       
    23 
       
    24 #include <ccherror.h>
       
    25 
       
    26 #include <spsettings.h>
       
    27 #include <spentry.h>
       
    28 
       
    29 #include <telephonydomainpskeys.h>
       
    30 #include <UikonInternalPSKeys.h>
       
    31 #include <aknnotedialog.h>
       
    32 
       
    33 #include "cphonevoiperrormessageshandler.h"
       
    34 #include "cphonemainerrormessageshandler.h"
       
    35 #include "cphoneerrormessageshandler.h"
       
    36 #include "cphonestatehandle.h"
       
    37 #include "phonerssvoip.h"
       
    38 #include "phonelogger.h"
       
    39 #include "tphonecmdparamglobalnote.h"
       
    40 #include "tphonecmdparaminteger.h"
       
    41 #include "cphonemainresourceresolver.h"
       
    42 #include "phoneui.pan"
       
    43 #include "cphonepubsubproxy.h"
       
    44 #include "tphonecmdparamboolean.h"
       
    45 #include "cphonestatemachinevoip.h"
       
    46 #include "cphonecustomizationvoip.h"
       
    47 
       
    48 // ================= MEMBER FUNCTIONS =======================
       
    49 
       
    50 // C++ default constructor can NOT contain any code, that
       
    51 // might leave.
       
    52 //
       
    53 CPhoneVoIPErrorMessagesHandler::CPhoneVoIPErrorMessagesHandler(
       
    54     MPhoneViewCommandHandle* aViewCommandHandle,
       
    55     MPhoneStateMachine* aPhoneStateMachine ) :
       
    56     CPhoneErrorMessagesHandler( aViewCommandHandle, aPhoneStateMachine )
       
    57     {
       
    58     static_cast<CPhoneStateMachineVoIP*>( iStateMachine )->
       
    59         SetVoipErrorMessageHandler( *this );
       
    60     }
       
    61 
       
    62 // -----------------------------------------------------------
       
    63 // CPhoneErrorMessagesHandler::~CPhoneErrorMessagesHandler()
       
    64 // Destructor
       
    65 // (other items were commented in a header).
       
    66 // -----------------------------------------------------------
       
    67 //
       
    68 CPhoneVoIPErrorMessagesHandler::~CPhoneVoIPErrorMessagesHandler()
       
    69     {
       
    70      
       
    71     }
       
    72 
       
    73 // -----------------------------------------------------------------------------
       
    74 // CPhoneVoIPErrorMessagesHandler::ConstructL
       
    75 // Symbian 2nd phase constructor can leave.
       
    76 // -----------------------------------------------------------------------------
       
    77 //
       
    78 void CPhoneVoIPErrorMessagesHandler::ConstructL()
       
    79     {
       
    80     // Register error handler
       
    81     CPhoneMainErrorMessagesHandler::Instance()->
       
    82         RegisterErrorMessagesHandler( this );
       
    83     }
       
    84 
       
    85 // -----------------------------------------------------------
       
    86 // CPhoneVoIPErrorMessagesHandler::NewL()
       
    87 // Constructor
       
    88 // -----------------------------------------------------------
       
    89 //
       
    90 CPhoneVoIPErrorMessagesHandler* CPhoneVoIPErrorMessagesHandler::NewL(
       
    91     MPhoneViewCommandHandle* aViewCommandHandle,
       
    92     MPhoneStateMachine* aPhoneStateMachine )
       
    93     {
       
    94     CPhoneVoIPErrorMessagesHandler* self =
       
    95         new( ELeave ) CPhoneVoIPErrorMessagesHandler(
       
    96             aViewCommandHandle,
       
    97             aPhoneStateMachine );
       
    98     CleanupStack::PushL( self );
       
    99     self->ConstructL();
       
   100     CleanupStack::Pop( self );
       
   101     return self;
       
   102     }
       
   103 
       
   104 // -----------------------------------------------------------
       
   105 // CPhoneVoIPErrorMessagesHandler::ShowErrorSpecificNoteL
       
   106 // -----------------------------------------------------------
       
   107 //
       
   108 void CPhoneVoIPErrorMessagesHandler::ShowErrorSpecificNoteL( 
       
   109     const TPEErrorInfo& aErrorInfo )
       
   110     {
       
   111     __LOGMETHODSTARTEND(PhoneUIVoIPExtension, "CPhoneVoipErrorMessagesHandler::ShowErrorSpecificNoteL()");
       
   112 
       
   113     __PHONELOG1( EBasic, PhoneUIVoIPExtension,
       
   114             "CPhoneVoIPErrorMessagesHandler::ShowErrorSpecificNoteL - aErrorInfo.iErrorCode =%d ",
       
   115             aErrorInfo.iErrorCode);
       
   116 
       
   117     if ( aErrorInfo.iErrorType == EPECcp && IsVoIPCall( aErrorInfo.iCallId ) )
       
   118         {
       
   119         switch( aErrorInfo.iErrorCode )
       
   120             {
       
   121             case ECCPErrorNotAcceptable:
       
   122             case ECCPErrorCCServiceNotImplemented:
       
   123                 SendGlobalErrorNoteL( EPhoneVoIPNoAudioSupport );
       
   124                 break;
       
   125 
       
   126             case ECCPLocalResumeFail:
       
   127                 if ( HasSwapFailed() )
       
   128                     {
       
   129                     SendGlobalErrorNoteL( EPhoneVoIPSwapFail );
       
   130                     }
       
   131                 else
       
   132                     {
       
   133                     HandleHoldErrorNotesL( aErrorInfo.iCallId, EFalse );
       
   134                     }
       
   135                 break;
       
   136             case ECCPLocalHoldFail:
       
   137                 if ( HasSwapFailed() )
       
   138                     {
       
   139                     SendGlobalErrorNoteL( EPhoneVoIPSwapFail );
       
   140                     }
       
   141                 else
       
   142                     {
       
   143                     HandleHoldErrorNotesL( aErrorInfo.iCallId, ETrue );
       
   144                     }
       
   145                 break;
       
   146 
       
   147             case ECCPServerFailure:
       
   148             case ECCPErrorNetworkBusy:
       
   149                 SendGlobalErrorNoteL( EPhoneVoIPNoService );
       
   150                 break;
       
   151 
       
   152             case ECCPErrorNotReached:
       
   153                 SendGlobalErrorNoteL( EPhoneVoIPNotFound );
       
   154                 break;
       
   155             case ECCPErrorCCIncompatibleDestination:
       
   156                 SendGlobalErrorNoteL( EPhoneVoIPAddressNotInUse );
       
   157                 break;
       
   158 
       
   159             case ECCPErrorTimedOut:
       
   160             case ECCPErrorCCNoRouteToDestination:
       
   161                 SendGlobalErrorNoteL( EPhoneVoIPRequestTimeOut );
       
   162                 break;
       
   163 
       
   164             case KErrArgument:
       
   165             case ECCPErrorInvalidPhoneNumber:
       
   166             case ECCPErrorInvalidURI:
       
   167                 SendGlobalErrorNoteL( EPhoneVoIPInvalidRecipientAddress );
       
   168                 break;
       
   169 
       
   170             case ECCPErrorBusy:
       
   171             case ECCPErrorCCCallRejected:
       
   172                 SendGlobalErrorNoteL( EPhoneVoIPNumberBusy );
       
   173                 break;
       
   174 
       
   175             case ECCPErrorMovedPermanently:
       
   176                 SendGlobalErrorNoteL( EPhoneVoIPAddressNotInUse );
       
   177                 break;
       
   178 
       
   179             case ECCPErrorCCUserNotResponding:
       
   180             case ECCPErrorNotResponding:
       
   181 
       
   182                 SendGlobalErrorNoteL( EPhoneVoIPNoAnswer );
       
   183                 break;
       
   184   
       
   185             case ECCPGlobalFailure:
       
   186                 SendGlobalErrorNoteL( EPhoneVoIPErrorInConnection );
       
   187                 break;
       
   188 
       
   189             case ECCPSecureCallFailed:    
       
   190             case ECCPErrorUnacceptableChannel:
       
   191                 SendGlobalErrorNoteL( EPhoneSSNotificationTextVoipSipsFailed );
       
   192                 break;
       
   193 
       
   194             case ECCPErrorNetworkOutOfOrder:
       
   195             case ECCPErrorMedia:
       
   196                 SendGlobalErrorNoteL( EPhoneVoIPNetworkError );
       
   197                 break;
       
   198                  
       
   199             case ECCPTransferFailed:
       
   200                 iViewCommandHandle->ExecuteCommandL( EPhoneViewRemoveGlobalNote );
       
   201                 SendGlobalErrorNoteL( EPhoneVoIPTransferFail );
       
   202                 break;
       
   203 
       
   204             case ECCPErrorNoService:
       
   205                 {
       
   206                 TInt serviceID = iStateMachine->PhoneEngineInfo()->ServiceId(
       
   207                     aErrorInfo.iCallId );
       
   208                 ShowErrorNoteWithServiceNameL( EPhoneVoIPServiceUnavailable,
       
   209                     serviceID );
       
   210                 }
       
   211                 break;
       
   212             default:
       
   213                 CPhoneErrorMessagesHandler::ShowErrorSpecificNoteL( aErrorInfo );
       
   214                 break;
       
   215             }
       
   216         }
       
   217     else if ( aErrorInfo.iErrorType == EPECch )
       
   218         {
       
   219         ShowRegistrationErrorNotesL( aErrorInfo.iErrorCode );   
       
   220         }
       
   221     else
       
   222         {
       
   223         CPhoneErrorMessagesHandler::ShowErrorSpecificNoteL( aErrorInfo );
       
   224         }
       
   225     }
       
   226 
       
   227 // -----------------------------------------------------------
       
   228 // CPhoneVoipErrorMessagesHandler::IsVoIPCall
       
   229 // -----------------------------------------------------------
       
   230 //
       
   231 TBool CPhoneVoIPErrorMessagesHandler::IsVoIPCall( const TInt aCallId ) const
       
   232     {
       
   233     __LOGMETHODSTARTEND( PhoneUIVoIPExtension, "CPhoneVoIPErrorMessagesHandler::IsVoipCall() ");
       
   234 
       
   235     if( aCallId == KErrNotFound )
       
   236         {
       
   237         // Illegal call id, check call type command
       
   238         return ( iStateMachine->PhoneEngineInfo()->CallTypeCommand()
       
   239             == EPECallTypeVoIP );
       
   240         }
       
   241 
       
   242     return ( iStateMachine->PhoneEngineInfo()
       
   243         ->CallType( aCallId )== EPECallTypeVoIP );
       
   244     }
       
   245 
       
   246 // -----------------------------------------------------------
       
   247 // CPhoneVoipErrorMessagesHandler::HandleHoldErrorNotesL
       
   248 // -----------------------------------------------------------
       
   249 //
       
   250 void CPhoneVoIPErrorMessagesHandler::HandleHoldErrorNotesL( 
       
   251     const TInt aCallId, TBool aHold )
       
   252     {
       
   253     __LOGMETHODSTARTEND( PhoneUIVoIPExtension, "CPhoneVoIPErrorMessagesHandler::HandleHoldNoteL()");
       
   254     
       
   255     TPhoneCmdParamGlobalNote globalNoteParam;
       
   256     HBufC* text = HBufC::NewLC( KPhoneContactNameMaxLength );
       
   257     TPtr tmp = text->Des();
       
   258 
       
   259     // Should add name( or RemotePartyName or CompanyName) to Note, if someone found
       
   260     GetRemoteInfoDataL( aCallId, tmp );
       
   261     
       
   262     if ( text->Length() )
       
   263         {
       
   264         // RemotePartyName, CompanyName or RemoteName found
       
   265         // Resource text which will use found text will be loaded later
       
   266         TInt resource( EPhoneVoIPResumeFail );
       
   267         if ( aHold )
       
   268             {
       
   269             resource = EPhoneVoIPHoldFail;    
       
   270             }
       
   271         
       
   272         // qtn_voip_resume_failed / qtn_voip_hold_failed
       
   273         globalNoteParam.SetTextResourceId(
       
   274             CPhoneMainResourceResolver::Instance()->
       
   275                 ResolveResourceID( resource ) );
       
   276         }
       
   277     else
       
   278         {
       
   279         // Decides note with call id
       
   280         // Resource is loaded here
       
   281         TInt resource = EPhoneVoIPResumeNumberFail;
       
   282         if ( aHold )
       
   283             {
       
   284             resource = EPhoneVoIPHoldNumberFail;    
       
   285             }
       
   286         
       
   287         // qtn_voip_resume_number_failed / qtn_voip_hold_number_failed
       
   288         const TInt tmpResourceId = CPhoneMainResourceResolver::Instance()->
       
   289             ResolveResourceID( resource );
       
   290         
       
   291         TInt callId = aCallId;
       
   292         callId++; // Real call id index starts from 0, increase value by one
       
   293         CleanupStack::PopAndDestroy( text ); // Delete reserver buffer
       
   294         text = StringLoader::LoadLC( 
       
   295                 tmpResourceId, 
       
   296                 callId, 
       
   297                 CCoeEnv::Static() ); // Load new buffer
       
   298 
       
   299         }
       
   300      
       
   301     globalNoteParam.SetText( *text );
       
   302     globalNoteParam.SetType( EAknGlobalConfirmationNote );
       
   303     globalNoteParam.SetTone( EAvkonSIDInformationTone );
       
   304             
       
   305     iViewCommandHandle->ExecuteCommandL( 
       
   306             EPhoneViewShowGlobalNote, &globalNoteParam );
       
   307     
       
   308     CleanupStack::PopAndDestroy( text );
       
   309     }
       
   310 
       
   311 // -----------------------------------------------------------
       
   312 // CPhoneVoIPErrorMessagesHandler::GetRemoteInfoDataL
       
   313 // -----------------------------------------------------------
       
   314 //
       
   315 void CPhoneVoIPErrorMessagesHandler::GetRemoteInfoDataL( 
       
   316     TInt aCallId,
       
   317     TDes& aData ) const 
       
   318     {
       
   319     __LOGMETHODSTARTEND( PhoneUIVoIPExtension, 
       
   320             "CPhoneVoIPErrorMessagesHandler::GetRemoteInfoDataL()" );
       
   321     __ASSERT_DEBUG( iStateMachine->PhoneEngineInfo(),
       
   322             Panic( EPhoneCtrlInvariant ) );
       
   323 
       
   324     // Note next if-statements are in priority order so be careful if you change order
       
   325     // or add new if-statements.
       
   326     if ( iStateMachine->PhoneEngineInfo()->RemoteName( aCallId ).Length() )
       
   327         {
       
   328         __PHONELOG1( EBasic, PhoneUIVoIPExtension, 
       
   329             "CPhoneVoIPErrorMessagesHandler::GetRemoteInfoDataL - remote name = %S", 
       
   330             &iStateMachine->PhoneEngineInfo()->RemoteName( aCallId ) );
       
   331 
       
   332         if ( iStateMachine->PhoneEngineInfo()->RemoteName( aCallId ).Length()
       
   333              < KPhoneContactNameMaxLength )
       
   334             {
       
   335             // Display the contact name if it is available
       
   336             aData.Copy( iStateMachine->PhoneEngineInfo()->RemoteName( aCallId ) );
       
   337             }
       
   338         }
       
   339     else if ( iStateMachine->PhoneEngineInfo()->RemoteCompanyName( aCallId ).Length() )
       
   340          {
       
   341          __PHONELOG1( EBasic, PhoneUIVoIPExtension, 
       
   342              "CPhoneVoIPErrorMessagesHandler::GetRemoteInfoDataL - remote company name = %S", 
       
   343              &iStateMachine->PhoneEngineInfo()->RemoteCompanyName( aCallId ) );
       
   344          
       
   345          if ( iStateMachine->PhoneEngineInfo()->RemoteCompanyName( aCallId ).Length()
       
   346               < KPhoneContactNameMaxLength )
       
   347              {            
       
   348              // Display the company name if it is available
       
   349              aData.Copy( iStateMachine->PhoneEngineInfo()->RemoteCompanyName( aCallId ) );
       
   350              }
       
   351          }
       
   352     else if( iStateMachine->PhoneEngineInfo()->RemotePartyName( aCallId ).Length() )
       
   353         {
       
   354         __PHONELOG1( EBasic, PhoneUIVoIPExtension, 
       
   355             "CPhoneVoIPErrorMessagesHandler::GetRemoteInfoDataL - remote party name = %S", 
       
   356             &iStateMachine->PhoneEngineInfo()->RemotePartyName( aCallId ) );
       
   357         
       
   358         if ( iStateMachine->PhoneEngineInfo()->RemotePartyName( aCallId ).Length()
       
   359              < KPhoneContactNameMaxLength )
       
   360             {            
       
   361             // Display the remote party name if it is available
       
   362             aData.Copy( iStateMachine->PhoneEngineInfo()->RemotePartyName( aCallId ) );
       
   363             }
       
   364         }
       
   365     else
       
   366         {
       
   367         __PHONELOG( EBasic, PhoneUIVoIPExtension, 
       
   368             "CPhoneVoIPErrorMessagesHandler::GetRemoteInfoDataL - not found" );
       
   369         aData.Zero();
       
   370         }
       
   371     }
       
   372 
       
   373 // -----------------------------------------------------------
       
   374 // CPhoneVoIPErrorMessagesHandler::ShowRegistrationErrorNotesL
       
   375 // -----------------------------------------------------------
       
   376 //
       
   377 void CPhoneVoIPErrorMessagesHandler::ShowRegistrationErrorNotesL( 
       
   378     TInt aErrorCode )
       
   379     {
       
   380     __LOGMETHODSTARTEND( PhoneUIVoIPExtension, 
       
   381               "CPhoneVoIPErrorMessagesHandler::ShowRegistrationErrorNotesL()" );
       
   382     // Dismiss service enabling wait note
       
   383     iViewCommandHandle->ExecuteCommandL( EPhoneViewRemoveGlobalWaitNote );
       
   384     
       
   385     switch ( aErrorCode )
       
   386         {
       
   387         case KCCHErrorAccessPointNotDefined:
       
   388             {
       
   389             TUint32 serviceId = 
       
   390                 iStateMachine->PhoneEngineInfo()->ServiceIdCommand();
       
   391             ShowErrorNoteWithServiceNameL( EPhoneVoIPNoConnectionsDefined,
       
   392                 serviceId );
       
   393             break;
       
   394             }
       
   395         case KCCHErrorBandwidthInsufficient:   
       
   396             {
       
   397             TUint32 serviceId = 
       
   398                 iStateMachine->PhoneEngineInfo()->ServiceIdCommand();
       
   399             ShowErrorNoteWithServiceNameL( EPhoneVoIPCallsNotSupported,
       
   400                 serviceId );
       
   401             break;
       
   402             }
       
   403         case KCCHErrorInvalidSettings:
       
   404             {
       
   405             TUint32 serviceId = 
       
   406                 iStateMachine->PhoneEngineInfo()->ServiceIdCommand();
       
   407             ShowErrorNoteWithServiceNameL( EPhoneVoIPDefectiveSettings,
       
   408                 serviceId );
       
   409             break;
       
   410             }
       
   411         case KCCHErrorAuthenticationFailed:
       
   412             {
       
   413             SendGlobalErrorNoteL( EPhoneVoIPAuthenticationFailed );
       
   414             break;
       
   415             }
       
   416         case KCCHErrorInvalidIap:
       
   417         case KCCHErrorNetworkLost:
       
   418         case KCCHErrorServiceNotResponding:
       
   419             {
       
   420             TUint32 serviceId = 
       
   421                 iStateMachine->PhoneEngineInfo()->ServiceIdCommand();
       
   422             ShowErrorNoteWithServiceNameL( EPhoneVoIPNoConnectionsAvailable,
       
   423                 serviceId );
       
   424             break;
       
   425             }
       
   426         case KCCHErrorLoginFailed: 
       
   427         default:
       
   428             {
       
   429             TUint32 serviceId = 
       
   430                iStateMachine->PhoneEngineInfo()->ServiceIdCommand();
       
   431             ShowErrorNoteWithServiceNameL( EPhoneVoIPServiceUnavailable,
       
   432                serviceId );
       
   433             break;
       
   434             }
       
   435         }
       
   436     }
       
   437 
       
   438 // ---------------------------------------------------------
       
   439 //  CPhoneVoIPErrorMessagesHandler::SendGlobalErrorNoteWithTextL
       
   440 // ---------------------------------------------------------
       
   441 //
       
   442 void CPhoneVoIPErrorMessagesHandler::SendGlobalErrorNoteWithTextL( 
       
   443     TInt aResourceId,
       
   444     RBuf& aText )
       
   445     {
       
   446     __LOGMETHODSTARTEND( PhoneUIVoIPExtension, 
       
   447         "CPhoneVoIPErrorMessagesHandler::SendGlobalErrorNoteL()" );
       
   448     __ASSERT_DEBUG( aResourceId, Panic( EPhoneCtrlParameterNotInitialized ) );
       
   449 
       
   450     if ( CPhonePubSubProxy::Instance()->Value( 
       
   451             KPSUidUikon, KUikGlobalNotesAllowed ) == 1 )
       
   452         {
       
   453         // Re-enable global notes
       
   454         TPhoneCmdParamBoolean globalNotifierParam;
       
   455         globalNotifierParam.SetBoolean( EFalse );
       
   456         iViewCommandHandle->ExecuteCommandL( 
       
   457              EPhoneViewSetGlobalNotifiersDisabled,
       
   458             &globalNotifierParam );
       
   459             
       
   460         TPhoneCmdParamGlobalNote globalNoteParam;
       
   461         globalNoteParam.SetType( EAknGlobalErrorNote );
       
   462         globalNoteParam.SetTextResourceId( 
       
   463             CPhoneMainResourceResolver::Instance()->
       
   464             ResolveResourceID( aResourceId ) );
       
   465         globalNoteParam.SetText( aText );
       
   466         globalNoteParam.SetTone( CAknNoteDialog::EErrorTone );
       
   467 
       
   468         iViewCommandHandle->ExecuteCommandL(  
       
   469             EPhoneViewShowGlobalNote, &globalNoteParam );
       
   470         } 
       
   471     }
       
   472 
       
   473 // -----------------------------------------------------------
       
   474 // CPhoneVoIPErrorMessagesHandler::GetServiceProviderNameL
       
   475 // -----------------------------------------------------------
       
   476 //
       
   477 void CPhoneVoIPErrorMessagesHandler::GetServiceProviderNameL( 
       
   478     RBuf& aServiceName, 
       
   479     TUint32 aServiceId )
       
   480     { 
       
   481     __LOGMETHODSTARTEND( PhoneUIVoIPExtension, 
       
   482                  "CPhoneVoIPErrorMessagesHandler::GetServiceProviderNameL" )
       
   483     CSPEntry* serviceEntry = CSPEntry::NewLC();
       
   484     
       
   485     CSPSettings* serviceProviderSettings = CSPSettings::NewLC();
       
   486     
       
   487     User::LeaveIfError(
       
   488         serviceProviderSettings->FindEntryL( aServiceId, *serviceEntry ) );
       
   489     
       
   490     User::LeaveIfError(
       
   491         aServiceName.Create( serviceEntry->GetServiceName() ) );
       
   492       
       
   493     CleanupStack::PopAndDestroy( serviceProviderSettings );
       
   494     CleanupStack::PopAndDestroy( serviceEntry );
       
   495     }
       
   496 
       
   497 // -----------------------------------------------------------
       
   498 // CPhoneVoIPErrorMessagesHandler::ShowErrorNoteContainingServiceNameL
       
   499 // -----------------------------------------------------------
       
   500 //
       
   501 void CPhoneVoIPErrorMessagesHandler::ShowErrorNoteWithServiceNameL( 
       
   502     TInt aResourceId, 
       
   503     TUint32 aServiceId )
       
   504     {
       
   505     __LOGMETHODSTARTEND( PhoneUIVoIPExtension, 
       
   506         "CPhoneVoIPErrorMessagesHandler::ShowErrorNoteWithServiceNameL" )
       
   507     RBuf serviceName;
       
   508     CleanupClosePushL( serviceName );
       
   509     GetServiceProviderNameL( serviceName, aServiceId );
       
   510     SendGlobalErrorNoteWithTextL( aResourceId, serviceName );
       
   511     CleanupStack::PopAndDestroy( &serviceName );
       
   512     }
       
   513 
       
   514 // -----------------------------------------------------------
       
   515 // CPhoneVoIPErrorMessagesHandler::HasSwapFailed
       
   516 // -----------------------------------------------------------
       
   517 //
       
   518 TBool CPhoneVoIPErrorMessagesHandler::HasSwapFailed() const
       
   519     {
       
   520     TPEState callState( EPEStateUnknown );
       
   521     TPECallType callType( EPECallTypeUninitialized );
       
   522     TPEState confCallState( EPEStateUnknown );
       
   523     
       
   524     TInt connectedCalls( 0 );
       
   525     TInt heldCalls( 0 );
       
   526     TInt voipCalls( 0 );
       
   527     TBool ret( EFalse );
       
   528     
       
   529     for ( TInt i=0; i < KPEMaximumNumberOfVoiceCalls; i++ )
       
   530         {
       
   531         callState = iStateMachine->PhoneEngineInfo()->CallState( i );
       
   532         callType = iStateMachine->PhoneEngineInfo()->CallType( i );
       
   533         
       
   534         if ( EPEStateConnected == callState )
       
   535             {
       
   536             connectedCalls++;
       
   537             
       
   538             if ( EPECallTypeVoIP == callType )
       
   539                 {
       
   540                 voipCalls++;
       
   541                 }
       
   542             }
       
   543         else if ( EPEStateHeld == callState )
       
   544             {
       
   545             heldCalls++;
       
   546             
       
   547             if ( EPECallTypeVoIP == callType )
       
   548                 {
       
   549                 voipCalls++;
       
   550                 }
       
   551             }
       
   552         }
       
   553     
       
   554     confCallState = iStateMachine->PhoneEngineInfo()->CallState( KPEConferenceCallID );
       
   555 
       
   556     // At least one of the calls is VoIP call (conference or single)
       
   557     if ( voipCalls )
       
   558         {
       
   559         if ( EPEStateConferenceIdle == confCallState )
       
   560             {
       
   561             // Look for connected/hold and hold/hold combinations
       
   562             if ( ( 1 == connectedCalls && 1 == heldCalls ) ||
       
   563                    2 == heldCalls )
       
   564                 {
       
   565                 ret = ETrue;
       
   566                 }
       
   567             }
       
   568         /* Check scenario that the other call is conference
       
   569          * 1) Putting VoIP call on hold fails, as a result there is a single connected 
       
   570          *    call and conference is on hold
       
   571          * 2) Resuming VoIP call fails, all calls are on hold (because conference is 
       
   572          *    first put on hold successfully)
       
   573          */
       
   574         else if ( ( 1 == connectedCalls && EPEStateHeldConference == confCallState ) ||
       
   575                  ( 0 == connectedCalls && EPEStateHeldConference == confCallState ) )
       
   576             {
       
   577             ret = ETrue;
       
   578             }
       
   579         }
       
   580 
       
   581     __PHONELOG1( EBasic, PhoneUIVoIPExtension, "CPhoneVoIPErrorMessagesHandler::HasSwapFailed() returned %D", ret );
       
   582     
       
   583     return ret;
       
   584     }
       
   585 
       
   586 // End of File