satengine/SatServer/Commands/SetUpCallCmd/src/CSetUpCallHandler.cpp
changeset 0 ff3b6d0fd310
child 6 1b9ee3c7442d
equal deleted inserted replaced
-1:000000000000 0:ff3b6d0fd310
       
     1 /*
       
     2 * Copyright (c) 2002-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:  Handles SetUpCall command
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #include    <aiwinternaldialdata.h>
       
    20 #include    <aiwdialdataext.h>
       
    21 
       
    22 #include    <exterror.h>
       
    23 #include    <ccpdefs.h>
       
    24 
       
    25 #include    "MSatApi.h"
       
    26 #include    "MSatUtils.h"
       
    27 #include    "MSatSystemState.h"
       
    28 #include    "MSatUiSession.h"
       
    29 #include    "SatSOpcodes.h"
       
    30 #include    "MSatSUiClientHandler.h"
       
    31 #include    "CSetUpCallHandler.h"
       
    32 #include    "TSatExtErrorUtils.h"
       
    33 #include    "SatLog.h"
       
    34 
       
    35 const TUint8 KBCDAsterisk( 0x0A );
       
    36 const TUint8 KBCDDash( 0x0B );
       
    37 const TUint8 KBCDDTMF( 0x0C );
       
    38 const TUint8 KBCDWild( 0x0D );
       
    39 const TUint8 KBCDExpansion( 0x0E );
       
    40 
       
    41 const TUint8 KAsteriskChar( 0x2A );
       
    42 const TUint8 KDashChar( 0x23 );
       
    43 const TUint8 KDTMFChar( 0x70 );
       
    44 const TUint8 KWildChar( 0x77 );
       
    45 const TUint8 KExpansionChar( 0x2E );
       
    46 
       
    47 _LIT( KFixedSimEmergencyNumber, "112" );
       
    48 _LIT8( KContentType, "*" );
       
    49 // 3GPP TS 24.008
       
    50 const TInt KMaximumPhoneNumberLength( 80 );
       
    51 
       
    52 // ======== MEMBER FUNCTIONS ========
       
    53 
       
    54 // -----------------------------------------------------------------------------
       
    55 // Two-phased constructor.
       
    56 // -----------------------------------------------------------------------------
       
    57 //
       
    58 CSetUpCallHandler* CSetUpCallHandler::NewL( MSatUtils* aUtils )
       
    59     {
       
    60     LOG( SIMPLE, "SETUPCALL: CSetUpCallHandler::NewL calling" )
       
    61 
       
    62     CSetUpCallHandler* self = new( ELeave ) CSetUpCallHandler;
       
    63 
       
    64     CleanupStack::PushL( self );
       
    65     self->BaseConstructL( aUtils );
       
    66     self->ConstructL();
       
    67     CleanupStack::Pop( self );
       
    68 
       
    69     LOG( SIMPLE, "SETUPCALL: CSetUpCallHandler::NewL exiting" )
       
    70     return self;
       
    71     }
       
    72 
       
    73 // -----------------------------------------------------------------------------
       
    74 // Destructor.
       
    75 // -----------------------------------------------------------------------------
       
    76 //
       
    77 CSetUpCallHandler::~CSetUpCallHandler()
       
    78     {
       
    79     LOG( SIMPLE, "SETUPCALL: CSetUpCallHandler::~CSetUpCallHandler calling" )
       
    80 
       
    81     Cancel();
       
    82 
       
    83     if ( iServiceHandler )
       
    84         {
       
    85         delete iServiceHandler;
       
    86         iServiceHandler = NULL;
       
    87         }
       
    88 
       
    89     if ( iEmergencyCallApi )
       
    90         {
       
    91         delete iEmergencyCallApi;
       
    92         iEmergencyCallApi = NULL;
       
    93         }
       
    94 
       
    95     LOG( SIMPLE, "SETUPCALL: CSetUpCallHandler::~CSetUpCallHandler exiting" )
       
    96     }
       
    97 
       
    98 // -----------------------------------------------------------------------------
       
    99 // From class MSatEventObserver.
       
   100 // Event notification.
       
   101 // -----------------------------------------------------------------------------
       
   102 //
       
   103 void CSetUpCallHandler::Event( TInt aEvent )
       
   104     {
       
   105     LOG2( SIMPLE, "SETUPCALL: CSetUpCallHandler::Event calling,aEvent: %i",
       
   106           aEvent )
       
   107 
       
   108     if ( MSatUtils::ECallControlExecuting == aEvent )
       
   109         {
       
   110         LOG( SIMPLE,
       
   111             "SETUPCALL: CSetUpCallHandler::Event: ECallControlExecuting" )
       
   112         iCallControlActive = ETrue;
       
   113         }
       
   114     else if ( MSatUtils::ECallControlDone == aEvent )
       
   115         {
       
   116         LOG( SIMPLE, "SETUPCALL: CSetUpCallHandler::Event: ECallControlDone" )
       
   117         iCallControlActive = EFalse;
       
   118 
       
   119         // Check if SetUpCall command has arrived from SIM during CC execution
       
   120         // Emergency call is made immediate regardless of call control.
       
   121         if ( !IsActive() && iPCmdPending && !iEmergencyCall )
       
   122             {
       
   123             LOG( SIMPLE, 
       
   124             "SETUPCALL: CSetUpCallHandler::Event: setupcall" )
       
   125             iPCmdPending = EFalse;
       
   126             // Execute the setupcall.
       
   127             DoHandleCommand();
       
   128             }
       
   129         }
       
   130 
       
   131     CSatCommandHandler::Event( aEvent );
       
   132 
       
   133     LOG( SIMPLE, "SETUPCALL: CSetUpCallHandler::Event exiting" )
       
   134     }
       
   135 
       
   136 // -----------------------------------------------------------------------------
       
   137 // From class MSatCommand.
       
   138 // Response from the client.
       
   139 // -----------------------------------------------------------------------------
       
   140 //
       
   141 void CSetUpCallHandler::ClientResponse()
       
   142     {
       
   143     LOG( SIMPLE, "SETUPCALL: CSetUpCallHandler::ClientResponse calling" )
       
   144 
       
   145     if ( iQueryRsp.iAccepted )
       
   146         {
       
   147         // User accepted the call, make the call
       
   148         TRAPD( error, DoSetupCallL() );
       
   149 
       
   150         if ( KErrNone != error )
       
   151             {
       
   152             LOG2( NORMAL, 
       
   153             "SETUPCALL: CSetUpCallHandler::ClientResponse Dial failed: %i", 
       
   154             error )
       
   155 
       
   156             CompleteSetupCall( RSat::KCmdDataNotUnderstood );
       
   157             }
       
   158         }
       
   159     else
       
   160         {
       
   161         LOG( NORMAL, 
       
   162         "SETUPCALL: CSetUpCallHandler::ClientResponse User Cancel" )
       
   163 
       
   164         if ( iQueryRsp.iSessionTerminatedByUser )
       
   165             {
       
   166             LOG( SIMPLE, 
       
   167             "SETUPCALL: CSetUpCallHandler::ClientResponse TerminatedByUser" )
       
   168             // Notify sim session end command that next sim session end
       
   169             // should close the ui session.
       
   170             iUtils->NotifyEvent( MSatUtils::ESessionTerminatedByUser );
       
   171             }
       
   172 
       
   173         // End key is pressed during confirmation or user denied call setup,
       
   174         // KPCmdNotAcceptedByUser is an expected response,
       
   175         CompleteSetupCall( RSat::KPCmdNotAcceptedByUser );
       
   176         }
       
   177 
       
   178     LOG( SIMPLE, "SETUPCALL: CSetUpCallHandler::ClientResponse exiting" )
       
   179     }
       
   180 
       
   181 // -----------------------------------------------------------------------------
       
   182 // From class CActive.
       
   183 // Cancels the sat request.
       
   184 // -----------------------------------------------------------------------------
       
   185 //
       
   186 void CSetUpCallHandler::DoCancel()
       
   187     {
       
   188     LOG( SIMPLE, "SETUPCALL: CSetUpCallHandler::DoCancel calling" )
       
   189 
       
   190     iUtils->USatAPI().NotifySetUpCallCancel();
       
   191 
       
   192     LOG( SIMPLE, "SETUPCALL: CSetUpCallHandler::DoCancel exiting" )
       
   193     }
       
   194 
       
   195 // -----------------------------------------------------------------------------
       
   196 // From class CSatCommandHandler.
       
   197 // Requests the command notification.
       
   198 // -----------------------------------------------------------------------------
       
   199 //
       
   200 void CSetUpCallHandler::IssueUSATRequest( TRequestStatus& aStatus )
       
   201     {
       
   202     LOG( SIMPLE, "SETUPCALL: CSetUpCallHandler::IssueUSATRequest calling" )
       
   203 
       
   204     // Clear the IPC package.
       
   205     new (&iSetUpCallData) RSat::TSetUpCallV1();
       
   206     iPCmdPending = EFalse;
       
   207     iQueryRsp.iAccepted = EFalse;
       
   208 
       
   209     iUtils->USatAPI().NotifySetUpCall( aStatus, iSetUpCallPckg );
       
   210 
       
   211     LOG( SIMPLE, "SETUPCALL: CSetUpCallHandler::IssueUSATRequest exiting" )
       
   212     }
       
   213 
       
   214 // -----------------------------------------------------------------------------
       
   215 // From class CSatCommandHandler.
       
   216 // SetUpCall command is not allowed in following situations:
       
   217 //      - Phone is not registered to homenetwork and roaming.
       
   218 //      - phone is ringing, alerting or call is on and SetUpCall command
       
   219 //        is "make call only if not busy", "make call only if not busy wiht
       
   220 //        redial" or "Call type not set".
       
   221 // -----------------------------------------------------------------------------
       
   222 //
       
   223 TBool CSetUpCallHandler::CommandAllowed()
       
   224     {
       
   225     LOG( SIMPLE, "SETUPCALL: CSetUpCallHandler::CommandAllowed calling" )
       
   226     TBool commandAllowed( ETrue );
       
   227 
       
   228     // Emergency call can newer be denied.
       
   229     // The usage of constant emergency number is according to ETSI TS 31.111.
       
   230     iEmergencyCall =
       
   231         ( 0 == iSetUpCallData.iAddress.iTelNumber.Compare(
       
   232             KFixedSimEmergencyNumber ) );
       
   233 
       
   234     if ( !iEmergencyCall )
       
   235         {
       
   236         RMobilePhone::TMobilePhoneRegistrationStatus networkStatus(
       
   237             iUtils->SystemState().GetNetworkRegistrationStatus() );
       
   238 
       
   239         if ( ( ( RSat::EAlphaIdProvided !=
       
   240                      iSetUpCallData.iAlphaIdConfirmationPhase.iStatus ) &&
       
   241                ( ( RSat::ESelfExplanatory ==
       
   242                        iSetUpCallData.iIconIdConfirmationPhase.iQualifier ) ||
       
   243                  ( RSat::ENotSelfExplanatory ==
       
   244                        iSetUpCallData.iIconIdConfirmationPhase.iQualifier ) ) )
       
   245                  ||
       
   246              ( ( RSat::EAlphaIdProvided !=
       
   247                      iSetUpCallData.iAlphaIdCallSetUpPhase.iStatus ) &&
       
   248                ( ( RSat::ESelfExplanatory ==
       
   249                        iSetUpCallData.iIconIdCallSetUpPhase.iQualifier ) ||
       
   250                  ( RSat::ENotSelfExplanatory ==
       
   251                        iSetUpCallData.iIconIdCallSetUpPhase.iQualifier ) ) ) )
       
   252             {
       
   253             // Icon data is received without alpha id.
       
   254             CompleteSetupCall( RSat::KCmdDataNotUnderstood );
       
   255 
       
   256             commandAllowed = EFalse;
       
   257             LOG( SIMPLE, 
       
   258             "SETUPCALL: CSetUpCallHandler::CommandAllowed Icon received \
       
   259             without alpha id" )
       
   260             }
       
   261         else if ( ( RMobilePhone::ERegisteredOnHomeNetwork != networkStatus ) &&
       
   262                   ( RMobilePhone::ERegisteredRoaming != networkStatus ) )
       
   263             {
       
   264             // Not registered to network.
       
   265             CompleteSetupCall( RSat::KMeUnableToProcessCmd, RSat::KNoService );
       
   266 
       
   267             commandAllowed = EFalse;
       
   268             LOG( SIMPLE, 
       
   269             "SETUPCALL: CSetUpCallHandler::CommandAllowed Registration not \
       
   270             valid" )
       
   271             }
       
   272         else
       
   273             {
       
   274             LOG( SIMPLE, 
       
   275             "SETUPCALL: CSetUpCallHandler::CommandAllowed others" )
       
   276             // Call type
       
   277             const RSat::TSetUpCallType callType( iSetUpCallData.iType );
       
   278 
       
   279             // Command does not allow to make a call if busy
       
   280             const TBool dontMakeCallIfBusy(
       
   281                 ( RSat::EOnlyIfNotBusy == callType ) ||
       
   282                 ( RSat::EOnlyIfNotBusyWithRedial == callType ) ||
       
   283                 ( RSat::ESetUpCallTypeNotSet == callType ) );
       
   284 
       
   285             if ( dontMakeCallIfBusy )
       
   286                 {
       
   287                 LOG( SIMPLE, 
       
   288                 "SETUPCALL: CSetUpCallHandler::CommandAllowed \
       
   289                 dontMakeCallIfBusy true" )
       
   290                 // Is the call ongoing
       
   291                 const TBool callIsOngoing(
       
   292                     iUtils->SystemState().IsCallActive() );
       
   293 
       
   294                 // Is the call incoming
       
   295                 const TBool callIsIncoming(
       
   296                     iUtils->SystemState().IsCallIncoming() );
       
   297 
       
   298                 if ( callIsOngoing || callIsIncoming )
       
   299                     {
       
   300                     // Set the terminal response info.
       
   301                     CompleteSetupCall(
       
   302                         RSat::KMeUnableToProcessCmd,
       
   303                         RSat::KMeBusyOnCall );
       
   304 
       
   305                     commandAllowed = EFalse;
       
   306                     LOG( SIMPLE, 
       
   307                     "SETUPCALL: CSetUpCallHandler::CommandAllowed Busy" )
       
   308                     }
       
   309                 }
       
   310             }
       
   311 
       
   312         if ( commandAllowed )
       
   313             {
       
   314             LOG( SIMPLE, 
       
   315             "SETUPCALL: CSetUpCallHandler::CommandAllowed Allowed to call" )
       
   316 
       
   317             // Set icon command flag whether icon data was received and
       
   318             // set qualifier to no icon id
       
   319             // To be removed when icons are allowed in this command
       
   320             if ( ( RSat::ESelfExplanatory ==
       
   321                      iSetUpCallData.iIconIdConfirmationPhase.iQualifier ) ||
       
   322                  ( RSat::ENotSelfExplanatory ==
       
   323                      iSetUpCallData.iIconIdConfirmationPhase.iQualifier ) ||
       
   324                  ( RSat::ESelfExplanatory ==
       
   325                      iSetUpCallData.iIconIdCallSetUpPhase.iQualifier ) ||
       
   326                  ( RSat::ENotSelfExplanatory ==
       
   327                      iSetUpCallData.iIconIdCallSetUpPhase.iQualifier ) )
       
   328                 {
       
   329                 LOG( SIMPLE, "SETUPCALL:   ENoIconId" )
       
   330                 iIconCommand = ETrue;
       
   331                 iSetUpCallData.iIconIdConfirmationPhase.iQualifier =
       
   332                     RSat::ENoIconId;
       
   333                 iSetUpCallData.iIconIdCallSetUpPhase.iQualifier =
       
   334                     RSat::ENoIconId;
       
   335                 }
       
   336             else
       
   337                 {
       
   338                 iIconCommand = EFalse;
       
   339                 }
       
   340             }
       
   341         }
       
   342     else
       
   343         {
       
   344         LOG( SIMPLE, 
       
   345         "SETUPCALL: CSetUpCallHandler::CommandAllowed Emergency call" )
       
   346         }
       
   347 
       
   348     LOG( SIMPLE, "SETUPCALL: CSetUpCallHandler::CommandAllowed exiting" )
       
   349     
       
   350     return commandAllowed;
       
   351     }
       
   352 
       
   353 // -----------------------------------------------------------------------------
       
   354 // From class CSatCommandHandler.
       
   355 // Need for ui session.
       
   356 // -----------------------------------------------------------------------------
       
   357 //
       
   358 TBool CSetUpCallHandler::NeedUiSession()
       
   359     {
       
   360     LOG( NORMAL, "SETUPCALL: CSetUpCallHandler::NeedUiSession calling" )
       
   361 
       
   362     // Notify Cover UI if it's supported
       
   363     if ( iUtils->CoverUiSupported() )
       
   364         {
       
   365         LOG( NORMAL, 
       
   366         "SETUPCALL: CSetUpCallHandler::NeedUiSession CoverUiSupported" )
       
   367         TSatCommandData medEventData;
       
   368         medEventData.iPCmdNumber = RSat::ESetUpCall;
       
   369         medEventData.iAlphaId = iSetUpCallData.iAlphaIdCallSetUpPhase;
       
   370         medEventData.iDuration.iTimeUnit = RSat::ESeconds;
       
   371         medEventData.iDuration.iNumOfUnits = KSatDefaultDuration;
       
   372         medEventData.iIconID = iSetUpCallData.iIconIdCallSetUpPhase;
       
   373         TSatCommandPckg tPckg( medEventData );
       
   374         iUtils->RaiseSatEvent( tPckg );
       
   375         }
       
   376 
       
   377     LOG( NORMAL, "SETUPCALL: CSetUpCallHandler::NeedUiSession exiting" )
       
   378     return ETrue;
       
   379     }
       
   380 
       
   381 // -----------------------------------------------------------------------------
       
   382 // From class CSatCommandHandler.
       
   383 // Called when USAT API notifies that command.
       
   384 // -----------------------------------------------------------------------------
       
   385 //
       
   386 void CSetUpCallHandler::HandleCommand()
       
   387     {
       
   388     LOG( SIMPLE, "SETUPCALL: CSetUpCallHandler::HandleCommand calling" )
       
   389 
       
   390     if ( iEmergencyCall )
       
   391         {
       
   392         LOG( SIMPLE, 
       
   393         "SETUPCALL: CSetUpCallHandler::HandleCommand iEmergencyCall true" )
       
   394         TRAPD( err, CreateEmergencyCallL() );
       
   395         if ( KErrNone != err )
       
   396             {
       
   397             LOG2( SIMPLE, 
       
   398             "SETUPCALL: CSetUpCallHandler::HandleCommand DialEmergencyCallL \
       
   399             failed: %d", err )
       
   400 
       
   401             iEmergencyCall = EFalse;
       
   402 
       
   403             // Set the terminal response info.
       
   404             CompleteSetupCall(
       
   405                 RSat::KMeUnableToProcessCmd,
       
   406                 RSat::KNoSpecificMeProblem );
       
   407             }
       
   408         }
       
   409     else
       
   410         {
       
   411         const RSat::TAlphaIdStatus alphaIdStatus(
       
   412             iSetUpCallData.iAlphaIdCallSetUpPhase.iStatus );
       
   413 
       
   414         // If the alpha id is null, then use SAT name as a alpha identifier.
       
   415         if ( ( RSat::EAlphaIdNull == alphaIdStatus )  ||
       
   416              ( RSat::EAlphaIdNotPresent == alphaIdStatus ) )
       
   417             {
       
   418             LOG( SIMPLE, 
       
   419             "SETUPCALL: CSetUpCallHandler::HandleCommand set AlphaId" )
       
   420             iSetUpCallData.iAlphaIdCallSetUpPhase.iAlphaId =
       
   421                 iUtils->SatAppName();
       
   422             iSetUpCallData.iAlphaIdCallSetUpPhase.iStatus =
       
   423                 RSat::EAlphaIdProvided;
       
   424             }
       
   425 
       
   426         // Copy the data to package, which is sent to client.
       
   427         iQueryData.iCommand = ESatSSetUpCallQuery;
       
   428         iQueryData.iQueryText.Copy(
       
   429             iSetUpCallData.iAlphaIdConfirmationPhase.iAlphaId );
       
   430         iQueryData.iSimApplicationName.Copy( iUtils->SatAppName() );
       
   431         iQueryData.iAlphaIdStatus = ESatAlphaIdNotNull; // Always
       
   432         iQueryData.iIconId.iIdentifier =
       
   433             iSetUpCallData.iIconIdConfirmationPhase.iIdentifier;
       
   434 
       
   435         LOG2( SIMPLE, 
       
   436         "SETUPCALL: iSetUpCallData.iIconIdConfirmationPhase.iQualifier: %d",
       
   437         iSetUpCallData.iIconIdConfirmationPhase.iQualifier )
       
   438         switch ( iSetUpCallData.iIconIdConfirmationPhase.iQualifier )
       
   439             {
       
   440             case RSat::ESelfExplanatory:
       
   441                 {
       
   442                 // Icon qualifier is self explanatory (to display instead
       
   443                 // of the alpha id or text string).
       
   444                 iQueryData.iIconId.iIconQualifier = ESatSelfExplanatory;
       
   445                 break;
       
   446                 }
       
   447 
       
   448             case RSat::ENotSelfExplanatory:
       
   449                 {
       
   450                 // Icon qualifier is not self explanatory.
       
   451                 iQueryData.iIconId.iIconQualifier = ESatNotSelfExplanatory;
       
   452                 break;
       
   453                 }
       
   454 
       
   455             default:
       
   456                 {
       
   457                 // Icon qualifier not present
       
   458                 iQueryData.iIconId.iIconQualifier = ESatENoIconId;
       
   459                 break;
       
   460                 }
       
   461             }
       
   462 
       
   463         // If call control is active, set up call is made
       
   464         // after the call control note is showed in ui ie
       
   465         // ECallControlDone event is notified.
       
   466         if ( !iCallControlActive )
       
   467             {
       
   468             LOG( SIMPLE, 
       
   469             "SETUPCALL: CSetUpCallHandler::HandleCommand iCallControlActive \
       
   470             false" )
       
   471             iUtils->NotifyEvent( MSatUtils::ESetUpCallExecuting );
       
   472 
       
   473             TRAPD( regErr, iUtils->RegisterServiceRequestL(
       
   474                 ESatSProactiveQuery,
       
   475                 ESatSProactiveQueryResponse,
       
   476                 this ) );
       
   477             LOG2( SIMPLE, 
       
   478             "SETUPCALL: CSetUpCallHandler::HandleCommand regErr: %d", regErr )
       
   479             if ( KErrNone != regErr )
       
   480                 {
       
   481                 // Possible memory allocation error. Send error terminal
       
   482                 // response
       
   483                 UiLaunchFailed();
       
   484                 }
       
   485             else
       
   486                 {
       
   487                 // Send query to UI
       
   488                 iUtils->SatUiHandler().UiSession()->SendCommand(
       
   489                     &iQueryPckg,
       
   490                     &iQueryRspPckg,
       
   491                     ESatSProactiveQuery );
       
   492                 }
       
   493             }
       
   494         else
       
   495             {
       
   496             LOG( SIMPLE, 
       
   497             "SETUPCALL: CSetUpCallHandler::HandleCommand iCallControlActive \
       
   498             true" )
       
   499             // Set pending flag on
       
   500             iPCmdPending = ETrue;
       
   501             }
       
   502         }
       
   503 
       
   504     LOG( SIMPLE, "SETUPCALL: CSetUpCallHandler::HandleCommand exiting" )
       
   505     }
       
   506 
       
   507 // -----------------------------------------------------------------------------
       
   508 // From class CSatCommandHandler.
       
   509 // Indication that UI lanching failed.
       
   510 // -----------------------------------------------------------------------------
       
   511 //
       
   512 void CSetUpCallHandler::UiLaunchFailed()
       
   513     {
       
   514     LOG( SIMPLE, "SETUPCALL: CSetUpCallHandler::UiLaunchFailed calling" )
       
   515 
       
   516     CompleteSetupCall( RSat::KMeUnableToProcessCmd, 
       
   517                        RSat::KNoSpecificMeProblem );
       
   518 
       
   519     LOG( SIMPLE, "SETUPCALL: CSetUpCallHandler::UiLaunchFailed exiting" )
       
   520     }
       
   521 
       
   522 // -----------------------------------------------------------------------------
       
   523 // From class MAiwNotifyCallback.
       
   524 // Called when dial request is completed.
       
   525 // -----------------------------------------------------------------------------
       
   526 //
       
   527 TInt CSetUpCallHandler::HandleNotifyL(
       
   528     const TInt aCmdId,
       
   529     const TInt aEventId,
       
   530     CAiwGenericParamList& aEventParamList,
       
   531     const CAiwGenericParamList& /*aInParamList*/ )
       
   532     {
       
   533     LOG( SIMPLE, "SETUPCALL: CSetUpCallHandler::HandleNotifyL calling" )
       
   534 
       
   535     if ( KAiwCmdCall == aCmdId )
       
   536         {
       
   537         LOG2( SIMPLE, 
       
   538         "SETUPCALL: CSetUpCallHandler::HandleNotifyL  event: %d", aEventId )
       
   539         switch ( aEventId )
       
   540             {
       
   541             case KAiwEventError:
       
   542             case KAiwEventCompleted:
       
   543             case EGenericParamError: // This is due CCaUiPlugin behaviour.
       
   544                                      // Also overlaps event KAiwEventStarted.
       
   545                 {
       
   546                 LOG( SIMPLE, 
       
   547                 "SETUPCALL: CSetUpCallHandler::HandleNotifyL SetupCall \
       
   548                 Completed" )
       
   549 
       
   550                 // Fetch completion status.
       
   551                 TInt index( 0 );
       
   552                 const TAiwGenericParam* param = aEventParamList.FindFirst(
       
   553                     index, EGenericParamError );
       
   554 
       
   555                 if ( param )
       
   556                     {
       
   557                     LOG( SIMPLE, 
       
   558                     "SETUPCALL: CSetUpCallHandler::HandleNotifyL param true" )
       
   559                     
       
   560                     // Converts error number to symbian-formatted before 
       
   561                     // calling CompleteSetupCallWithStatus.
       
   562                     TInt error = TccpErrorToSymbianError( 
       
   563                         param->Value().AsTInt32() );
       
   564                     CompleteSetupCallWithStatus( error );
       
   565                     }
       
   566                 else
       
   567                     {
       
   568                     CompleteSetupCall( RSat::KSuccess );
       
   569                     }
       
   570                 }
       
   571                 break;
       
   572 
       
   573             case KAiwEventCanceled:
       
   574             case KAiwEventStopped:
       
   575             case KAiwEventQueryExit:
       
   576                 {
       
   577                 LOG( SIMPLE, 
       
   578                 "SETUPCALL: CSetUpCallHandler::HandleNotifyL SetupCall \
       
   579                 cancelled" )
       
   580 
       
   581                 CompleteSetupCallWithStatus( KErrAbort );
       
   582                 }
       
   583                 break;
       
   584 
       
   585             case KAiwEventOutParamCheck:
       
   586             case KAiwEventInParamCheck:
       
   587                 {
       
   588                 LOG( SIMPLE, 
       
   589                 "SETUPCALL: CSetUpCallHandler::HandleNotifyL SetupCall param \
       
   590                 fail" )
       
   591 
       
   592                 CompleteSetupCall( RSat::KCmdDataNotUnderstood );
       
   593                 }
       
   594                 break;
       
   595 
       
   596             default:
       
   597                 {
       
   598                 LOG( SIMPLE, 
       
   599                 "SETUPCALL: CSetUpCallHandler::HandleNotifyL Unknown event \
       
   600                 id" )
       
   601                 }
       
   602                 break;
       
   603 
       
   604             }
       
   605         }
       
   606 
       
   607     LOG( SIMPLE, "SETUPCALL: CSetUpCallHandler::HandleNotifyL exiting" )
       
   608     return KErrNone;
       
   609     }
       
   610 
       
   611 // -----------------------------------------------------------------------------
       
   612 // From class MAiwNotifyCallback.
       
   613 // Called when dial request is completed.
       
   614 // -----------------------------------------------------------------------------
       
   615 //
       
   616 void CSetUpCallHandler::HandleEmergencyDialL( const TInt aStatus )
       
   617     {
       
   618     LOG( SIMPLE, "SETUPCALL: CSetUpCallHandler::HandleEmergencyDialL calling" )
       
   619 
       
   620     iEmergencyCall = EFalse;
       
   621 
       
   622     if ( KErrNone == aStatus )
       
   623         {
       
   624         // Set result
       
   625         CompleteSetupCall( RSat::KSuccess );
       
   626         }
       
   627     else
       
   628         {
       
   629         CompleteSetupCall(
       
   630             RSat::KNetworkUnableToProcessCmd,
       
   631             RSat::KNoSpecificMeProblem );
       
   632 
       
   633         LOG( SIMPLE, 
       
   634         "SETUPCALL: CSetUpCallHandler::HandleEmergencyDialL Network unable \
       
   635         to process this" )
       
   636         }
       
   637 
       
   638     LOG( SIMPLE, "SETUPCALL: CSetUpCallHandler::HandleEmergencyDialL exiting" )
       
   639     }
       
   640 
       
   641 // -----------------------------------------------------------------------------
       
   642 // C++ default constructor can NOT contain any code, that
       
   643 // might leave.
       
   644 // -----------------------------------------------------------------------------
       
   645 //
       
   646 //lint -e{1403, 1769} Can not be initialized, harmless.
       
   647 CSetUpCallHandler::CSetUpCallHandler() :
       
   648     CSatCommandHandler(),
       
   649     iSetUpCallData(),
       
   650     iSetUpCallPckg( iSetUpCallData ),
       
   651     iSetUpCallRsp(),
       
   652     iSetUpCallRspPckg( iSetUpCallRsp ),
       
   653     iQueryData(),
       
   654     iQueryPckg( iQueryData ),
       
   655     iQueryRsp(),
       
   656     iQueryRspPckg( iQueryRsp ),
       
   657     // To be removed when icons are allowed in this command
       
   658     iIconCommand( EFalse )
       
   659     {
       
   660     LOG( SIMPLE,
       
   661         "SETUPCALL: CSetUpCallHandler::CSetUpCallHandler calling - exiting" )
       
   662     }
       
   663 
       
   664 // -----------------------------------------------------------------------------
       
   665 // Symbian 2nd phase constructor can leave.
       
   666 // -----------------------------------------------------------------------------
       
   667 //
       
   668 void CSetUpCallHandler::ConstructL()
       
   669     {
       
   670     LOG( SIMPLE, "SETUPCALL: CSetUpCallHandler::ConstructL calling" )
       
   671 
       
   672     // Create request handler. This is same that LaunchBrowser uses, so this
       
   673     // is needed also in HandleCommand - function.
       
   674     iUtils->RegisterServiceRequestL(
       
   675         ESatSProactiveQuery,
       
   676         ESatSProactiveQueryResponse,
       
   677         this );
       
   678 
       
   679     iUtils->RegisterL( this, MSatUtils::ECallControlExecuting );
       
   680     iUtils->RegisterL( this, MSatUtils::ECallControlDone );
       
   681 
       
   682     // Create service handler for normal call setup.
       
   683     iServiceHandler = CAiwServiceHandler::NewL();
       
   684 
       
   685     // Create dynamic resource to attach service handler.
       
   686     RCriteriaArray interest;
       
   687     CAiwCriteriaItem* item = CAiwCriteriaItem::NewLC(
       
   688         KAiwCmdCall,
       
   689         KAiwCmdCall,
       
   690         KContentType );
       
   691 
       
   692     TUid serviceClassBase;
       
   693     serviceClassBase.iUid = KAiwClassBase;
       
   694     item->SetServiceClass( serviceClassBase );
       
   695 
       
   696     interest.AppendL( item );
       
   697 
       
   698     // Attach to call service.
       
   699     iServiceHandler->AttachL( interest );
       
   700 
       
   701     CleanupStack::PopAndDestroy( item );
       
   702 
       
   703     LOG( SIMPLE, "SETUPCALL: CSetUpCallHandler::ConstructL exiting" )
       
   704     }
       
   705 
       
   706 // -----------------------------------------------------------------------------
       
   707 // Performs the request to dial
       
   708 // -----------------------------------------------------------------------------
       
   709 //
       
   710 void CSetUpCallHandler::DoSetupCallL()
       
   711     {
       
   712     LOG( SIMPLE, "SETUPCALL: CSetUpCallHandler::DoSetupCallL calling" )
       
   713 
       
   714     RSat::TSetUpCallType callType( iSetUpCallData.iType );
       
   715 
       
   716     TDes& telNumber( iSetUpCallData.iAddress.iTelNumber );
       
   717     CheckNumber( telNumber );
       
   718 
       
   719     // 80 is max length in SAT calls, AIW max length is 100
       
   720     if ( telNumber.Length() > KMaximumPhoneNumberLength )
       
   721         {
       
   722         LOG( SIMPLE, 
       
   723         "SETUPCALL: CSetUpCallHandler::DoSetupCallL telNumber too long" )
       
   724         User::Leave( KErrArgument );
       
   725         }
       
   726 
       
   727     TBuf< AIWDialDataExt::KMaximumNameLength > name;
       
   728     if ( RSat::EAlphaIdProvided ==
       
   729          iSetUpCallData.iAlphaIdCallSetUpPhase.iStatus )
       
   730         {
       
   731         LOG( SIMPLE, 
       
   732         "SETUPCALL: CSetUpCallHandler::DoSetupCallL EAlphaIdProvided" )
       
   733         name = iSetUpCallData.iAlphaIdCallSetUpPhase.iAlphaId;
       
   734         }
       
   735     else
       
   736         {
       
   737         LOG( SIMPLE, 
       
   738         "SETUPCALL: CSetUpCallHandler::DoSetupCallL set AlphaId" )
       
   739         name = iUtils->SatAppName();
       
   740         }
       
   741 
       
   742     // Make the phone call parameters.
       
   743     CAiwInternalDialData* dialData = CAiwInternalDialData::NewLC();
       
   744 
       
   745     dialData->SetCallType( CAiwDialData::EAIWVoice );
       
   746     dialData->SetWindowGroup( AIWDialData::KAiwGoToIdle );
       
   747     dialData->SetPhoneNumberL( telNumber );
       
   748     dialData->SetSATCall( ETrue );
       
   749     dialData->SetShowNumber( EFalse );
       
   750     dialData->SetNameL( name );
       
   751     dialData->SetAllowMatch( EFalse );
       
   752     // Remove the redial mechanism from S60 5.x.
       
   753     dialData->SetRedial( AIWDialDataExt::KAIWRedialOff );
       
   754 
       
   755     // check if we need to disconnect other calls
       
   756     if ( ( RSat::EDisconnectOtherCalls == callType ) ||
       
   757          ( RSat::EDisconnectOtherCallsWithRedial == callType ) )
       
   758         {
       
   759         LOG( SIMPLE, 
       
   760         "SETUPCALL: CSetUpCallHandler::DoSetupCallL end other call" )
       
   761         dialData->SetEndOtherCalls( ETrue );
       
   762         }
       
   763 
       
   764     if ( AIWInternalDialData::KAiwBearerLength >=
       
   765          iSetUpCallData.iCapabilityConfigParams.Length() )
       
   766         {
       
   767         LOG( NORMAL, 
       
   768         "SETUPCALL: CSetUpCallHandler::DoSetupCallL SetBearerL" )
       
   769         dialData->SetBearerL( iSetUpCallData.iCapabilityConfigParams );
       
   770         }
       
   771 
       
   772     if ( AIWInternalDialData::KAiwSubAddressLength >=
       
   773          iSetUpCallData.iSubAddress.Length() )
       
   774         {
       
   775         LOG( NORMAL, 
       
   776         "SETUPCALL: CSetUpCallHandler::DoSetupCallL SetSubAddressL" )
       
   777         dialData->SetSubAddressL( iSetUpCallData.iSubAddress );
       
   778         }
       
   779 
       
   780     CAiwGenericParamList& paramList = iServiceHandler->InParamListL();
       
   781     dialData->FillInParamListL( paramList );
       
   782 
       
   783     iServiceHandler->ExecuteServiceCmdL(
       
   784         KAiwCmdCall,
       
   785         paramList,
       
   786         iServiceHandler->OutParamListL(),
       
   787         0,
       
   788         this );
       
   789 
       
   790     CleanupStack::PopAndDestroy( dialData );
       
   791 
       
   792     LOG( SIMPLE, "SETUPCALL: CSetUpCallHandler::DoSetupCallL exiting" )
       
   793     }
       
   794 
       
   795 // -----------------------------------------------------------------------------
       
   796 // Return terminal response filled according to dial result.
       
   797 // -----------------------------------------------------------------------------
       
   798 //
       
   799 void CSetUpCallHandler::CompleteSetupCallWithStatus(
       
   800     const TInt32 aStatus )
       
   801     {
       
   802     LOG2( SIMPLE,
       
   803         "SETUPCALL: CSetUpCallHandler::CompleteSetupCallWithStatus calling: \
       
   804         %i", aStatus )
       
   805 
       
   806     // Form Terminal Response
       
   807     if ( KErrNone != aStatus )
       
   808         {
       
   809         switch ( aStatus )
       
   810             {
       
   811             case KErrGsmCCCallRejected:
       
   812                 {
       
   813                 LOG( SIMPLE, 
       
   814                 "SETUPCALL: CSetUpCallHandler::CompleteSetupCallWithStatus Call \
       
   815                 Control not allowed" )
       
   816                 // If SetUpCall is not allowed by SIM in Call Control, then
       
   817                 // give a correct response.
       
   818                 CompleteSetupCall(
       
   819                     RSat::KInteractionWithCCPermanentError,
       
   820                     RSat::KActionNotAllowed );
       
   821                 break;
       
   822                 }
       
   823 
       
   824             case KErrGsmCCBearerCapabilityNotAuthorised:
       
   825                 {
       
   826                 LOG( SIMPLE, 
       
   827                 "SETUPCALL: CSetUpCallHandler::CompleteSetupCallWithStatus \
       
   828                 Beyond ME Capabilities" )
       
   829                 // If bearer capability is not authorized, return correct value
       
   830                 CompleteSetupCall( RSat::KCmdBeyondMeCapabilities );
       
   831                 break;
       
   832                 }
       
   833 
       
   834             case KErrAbort:
       
   835                 {
       
   836                 LOG( SIMPLE, 
       
   837                 "SETUPCALL: CSetUpCallHandler::CompleteSetupCallWithStatus User \
       
   838                 abort" )
       
   839                 if ( iQueryRsp.iSessionTerminatedByUser )
       
   840                     {
       
   841                     LOG( SIMPLE, 
       
   842                     "SETUPCALL: CSetUpCallHandler::CompleteSetupCallWithStatus \
       
   843                     TerminatedByUser" )
       
   844                     // Notify sim session end command that next sim session end
       
   845                     // should close the ui session.
       
   846                     iUtils->NotifyEvent( MSatUtils::ESessionTerminatedByUser );
       
   847                     }
       
   848 
       
   849                 // User has ended redial mechanism.
       
   850                 CompleteSetupCall( RSat::KCallClearedBeforeConnectionOrReleased );
       
   851                 break;
       
   852                 }
       
   853 
       
   854             case KErrGeneral:
       
   855                 {
       
   856                 LOG( SIMPLE, 
       
   857                 "SETUPCALL: CSetUpCallHandler::CompleteSetupCallWithStatus Data \
       
   858                 not understood" )
       
   859                 CompleteSetupCall( RSat::KCmdDataNotUnderstood );
       
   860                 break;
       
   861                 }
       
   862 
       
   863             case KErrAccessDenied:
       
   864                 {
       
   865                 LOG( SIMPLE, 
       
   866                 "SETUPCALL: CSetUpCallHandler::CompleteSetupCallWithStatus \
       
   867                 Network unable to process this" )
       
   868                 CompleteSetupCall(
       
   869                     RSat::KNetworkUnableToProcessCmd,
       
   870                     RSat::KNoSpecificMeProblem );
       
   871                 break;
       
   872                 }
       
   873                 
       
   874             case KErrSatControl:
       
   875                 {
       
   876                 LOG( SIMPLE, 
       
   877                 "SETUPCALL: CSetUpCallHandler::CompleteSetupCallWithStatus \
       
   878                 Call Command performed, but modified by Call Control" )
       
   879                 // Call control modified the type of request indicated in
       
   880                 // the proactive command, and the action requested by 
       
   881                 // call control was performed successfully.
       
   882                 CompleteSetupCall( RSat::KModifiedByCallControl );
       
   883                 break;
       
   884                 }
       
   885                 
       
   886             default:
       
   887                 {
       
   888                 LOG( SIMPLE,
       
   889                 "SETUPCALL: CSetUpCallHandler::CompleteSetupCallWithStatus \
       
   890                 Network unable to process with error info" )
       
   891 
       
   892                 iSetUpCallRsp.iGeneralResult = RSat::KNetworkUnableToProcessCmd;
       
   893                 iSetUpCallRsp.iInfoType = RSat::KSatNetworkErrorInfo;
       
   894 
       
   895                 // Lower byte contains the error cause.
       
   896                 iSetUpCallRsp.iAdditionalInfo.SetLength( 1 );
       
   897 
       
   898                 // Get mapped additional info
       
   899                 TUint8 addInfo( TSatExtErrorUtils::MapError( aStatus ) );
       
   900                 iSetUpCallRsp.iAdditionalInfo[0] =
       
   901                     static_cast<TUint16>( addInfo );
       
   902 
       
   903                 // Send terminal response
       
   904                 TerminalRsp( RSat::ESetUpCall, iSetUpCallRspPckg );
       
   905                 break;
       
   906                 }
       
   907             }
       
   908         }
       
   909     else
       
   910         {
       
   911         // Convert terminal rsp if icon used
       
   912         RSat::TIconQualifier qualifier1(
       
   913             iSetUpCallData.iIconIdConfirmationPhase.iQualifier );
       
   914         RSat::TIconQualifier qualifier2(
       
   915             iSetUpCallData.iIconIdCallSetUpPhase.iQualifier );
       
   916 
       
   917         RSat::TPCmdResult result( RSat::KSuccess );
       
   918 
       
   919         // Icon support for call confirmtion phase not done.
       
   920         if ( !iQueryRsp.iRequestedIconDisplayed &&
       
   921            ( ( RSat::ESelfExplanatory == qualifier1 ) ||
       
   922              ( RSat::ENotSelfExplanatory == qualifier1 ) ) )
       
   923             {
       
   924             result = RSat::KSuccessRequestedIconNotDisplayed;
       
   925             LOG( SIMPLE, 
       
   926             "SETUPCALL: CSetUpCallHandler::CompleteSetupCallWithStatus \
       
   927             Confirmation icon not shown" )
       
   928             }
       
   929         // Icon support for call setup phase not done.
       
   930         else if ( ( RSat::ESelfExplanatory == qualifier2 ) ||
       
   931                   ( RSat::ENotSelfExplanatory == qualifier2 ) )
       
   932             {
       
   933             result = RSat::KSuccessRequestedIconNotDisplayed;
       
   934             LOG( SIMPLE, 
       
   935             "SETUPCALL: CSetUpCallHandler::CompleteSetupCallWithStatus Icon \
       
   936             not shown" )
       
   937             }
       
   938         // If command had icon data and was done succesfully, report that icon
       
   939         // was not shown.
       
   940         // To be removed when icons are allowed in this command.
       
   941         else
       
   942             {
       
   943             LOG( SIMPLE, 
       
   944             "SETUPCALL: CSetUpCallHandler::CompleteSetupCallWithStatus \
       
   945             others" )
       
   946             if ( iIconCommand )
       
   947                 {
       
   948                 LOG( SIMPLE, 
       
   949                 "SETUPCALL: CSetUpCallHandler::CompleteSetupCallWithStatus \
       
   950                 iIconCommand true" )
       
   951                 result = RSat::KSuccessRequestedIconNotDisplayed;
       
   952                 }
       
   953             }
       
   954 
       
   955         // Set result
       
   956         CompleteSetupCall( result );
       
   957         }
       
   958 
       
   959     LOG( SIMPLE,
       
   960         "SETUPCALL: CSetUpCallHandler::CompleteSetupCallWithStatus exiting" )
       
   961     }
       
   962 
       
   963 // -----------------------------------------------------------------------------
       
   964 // Return terminal response filled according to result.
       
   965 // -----------------------------------------------------------------------------
       
   966 //
       
   967 void CSetUpCallHandler::CompleteSetupCall(
       
   968     const RSat::TPCmdResult aGeneralResult )
       
   969     {
       
   970     LOG( SIMPLE, "SETUPCALL: CSetUpCallHandler::CompleteSetupCall calling" )
       
   971 
       
   972     // Fill Terminal Response.
       
   973     iSetUpCallRsp.iGeneralResult = aGeneralResult;
       
   974     iSetUpCallRsp.iInfoType = RSat::KNoAdditionalInfo;
       
   975     iSetUpCallRsp.iAdditionalInfo.Zero();
       
   976     iSetUpCallRsp.SetPCmdNumber( iSetUpCallData.PCmdNumber() );
       
   977 
       
   978     // Send terminal response.
       
   979     TerminalRsp( RSat::ESetUpCall, iSetUpCallRspPckg );
       
   980 
       
   981     LOG( SIMPLE, "SETUPCALL: CSetUpCallHandler::CompleteSetupCall exiting" )
       
   982     }
       
   983 
       
   984 // -----------------------------------------------------------------------------
       
   985 // Return terminal response filled according to result.
       
   986 // -----------------------------------------------------------------------------
       
   987 //
       
   988 void CSetUpCallHandler::CompleteSetupCall(
       
   989     const RSat::TPCmdResult aGeneralResult,
       
   990     const TInt16 aAdditionalInfo )
       
   991     {
       
   992     LOG( SIMPLE, "SETUPCALL: CSetUpCallHandler::CompleteSetupCall calling" )
       
   993 
       
   994     // Fill Terminal Response.
       
   995     iSetUpCallRsp.iGeneralResult = aGeneralResult;
       
   996     iSetUpCallRsp.iInfoType = RSat::KMeProblem;
       
   997     iSetUpCallRsp.iAdditionalInfo.SetLength( 1 );
       
   998     iSetUpCallRsp.iAdditionalInfo[0] = aAdditionalInfo;
       
   999     iSetUpCallRsp.SetPCmdNumber( iSetUpCallData.PCmdNumber() );
       
  1000 
       
  1001     // Send terminal response.
       
  1002     TerminalRsp( RSat::ESetUpCall, iSetUpCallRspPckg );
       
  1003 
       
  1004     LOG( SIMPLE, "SETUPCALL: CSetUpCallHandler::CompleteSetupCall exiting" )
       
  1005     }
       
  1006 
       
  1007 // -----------------------------------------------------------------------------
       
  1008 // Checks the dialling number string for extended BCD
       
  1009 // values. Changes them to correct characters
       
  1010 // see ETSI 11.11 10.5.1
       
  1011 // -----------------------------------------------------------------------------
       
  1012 //
       
  1013 void CSetUpCallHandler::CheckNumber( TDes& aNumber ) const
       
  1014     {
       
  1015     LOG( SIMPLE, "SETUPCALL: CSetUpCallHandler::CheckNumber calling" )
       
  1016 
       
  1017     for ( TInt i = 0; i < aNumber.Length(); i++ )
       
  1018         {
       
  1019         // check values
       
  1020         if ( KBCDAsterisk == aNumber[i] )
       
  1021             {
       
  1022             LOG( SIMPLE, 
       
  1023             "SETUPCALL: CSetUpCallHandler::CheckNumber KAsteriskChar" )
       
  1024             aNumber[i] = KAsteriskChar;
       
  1025             }
       
  1026 
       
  1027         if ( KBCDDash == aNumber[i] )
       
  1028             {
       
  1029             LOG( SIMPLE, 
       
  1030             "SETUPCALL: CSetUpCallHandler::CheckNumber KDashChar" )
       
  1031             aNumber[i] = KDashChar;
       
  1032             }
       
  1033 
       
  1034         if ( KBCDDTMF == aNumber[i] )
       
  1035             {
       
  1036             LOG( SIMPLE, 
       
  1037             "SETUPCALL: CSetUpCallHandler::CheckNumber KDTMFChar" )
       
  1038             aNumber[i] = KDTMFChar;
       
  1039             }
       
  1040 
       
  1041         if ( KBCDWild == aNumber[i] )
       
  1042             {
       
  1043             LOG( SIMPLE, 
       
  1044             "SETUPCALL: CSetUpCallHandler::CheckNumber KWildChar" )
       
  1045             aNumber[i] = KWildChar;
       
  1046             }
       
  1047 
       
  1048         if ( KBCDExpansion == aNumber[i] )
       
  1049             {
       
  1050             LOG( SIMPLE, 
       
  1051             "SETUPCALL: CSetUpCallHandler::CheckNumber KExpansionChar" )
       
  1052             aNumber[i] = KExpansionChar;
       
  1053             }
       
  1054         }
       
  1055     LOG2( SIMPLE, 
       
  1056     "SETUPCALL: CSetUpCallHandler::CheckNumber length of aNumber: %d",
       
  1057      aNumber.Length() )
       
  1058     LOG( SIMPLE, "SETUPCALL: CSetUpCallHandler::CheckNumber exiting" )
       
  1059     }
       
  1060 
       
  1061 // -----------------------------------------------------------------------------
       
  1062 // Converts a TCCP error to the corresponding symbian error.
       
  1063 // -----------------------------------------------------------------------------
       
  1064 //
       
  1065 TInt CSetUpCallHandler::TccpErrorToSymbianError( const TInt aTccpError ) const
       
  1066     {
       
  1067     LOG( SIMPLE, "SETUPCALL: CSetUpCallHandler::TccpErrorToSymbianError \
       
  1068         calling" )
       
  1069     
       
  1070     // Error to be returned after mapped from aTccpError;
       
  1071     // Initialized with default value KErrAccessDenied.
       
  1072     TInt retValue( KErrAccessDenied );
       
  1073     
       
  1074     // Convert TCCP Error to Symbian Error in the switch braces.
       
  1075     switch ( aTccpError )
       
  1076         {
       
  1077         case ECCPErrorNone:
       
  1078         case ECCPErrorNotFound:
       
  1079         case ECCPErrorGeneral:
       
  1080         case ECCPErrorCancel:
       
  1081         case ECCPErrorNoMemory:
       
  1082         case ECCPErrorNotSupported:
       
  1083         case ECCPErrorAlreadyInUse:
       
  1084         case ECCPErrorNotReady:
       
  1085             {
       
  1086             retValue = aTccpError;
       
  1087             break;
       
  1088             }
       
  1089             
       
  1090         case ECCPErrorCCCallRejected:
       
  1091             {
       
  1092             retValue = KErrGsmCCCallRejected;
       
  1093             break;
       
  1094             }
       
  1095             
       
  1096         case ECCPRequestFailure:
       
  1097             {
       
  1098             retValue = KErrGsmMMCongestion;
       
  1099             break;
       
  1100             }
       
  1101             
       
  1102         case ECCPErrorCCBearerCapabilityNotAuthorised:
       
  1103         case ECCPErrorBadRequest:
       
  1104             {
       
  1105             retValue = KErrGsmCCBearerCapabilityNotAuthorised;
       
  1106             break;
       
  1107             }
       
  1108             
       
  1109         case ECCPErrorAccessDenied:
       
  1110             {
       
  1111             retValue = KErrAccessDenied;
       
  1112             break;
       
  1113             }
       
  1114         
       
  1115          //The following are KErrGsmCallControlBase group.
       
  1116         case ECCPErrorNotReached:
       
  1117             {
       
  1118             retValue = KErrGsmCCUnassignedNumber;
       
  1119             break;
       
  1120             }
       
  1121             
       
  1122         case ECCPErrorBusy:
       
  1123             {
       
  1124             retValue = KErrGsmCCUserBusy;
       
  1125             break;
       
  1126             }
       
  1127             
       
  1128         case ECCPErrorMovedPermanently:
       
  1129             {
       
  1130             retValue = KErrGsmCCNumberChanged;
       
  1131             break;
       
  1132             }
       
  1133             
       
  1134         case ECCPErrorInvalidURI:
       
  1135             {
       
  1136             retValue = KErrGsmCCInvalidNumberFormat;
       
  1137             break;
       
  1138             }
       
  1139             
       
  1140         case ECCPErrorNetworkOutOfOrder:
       
  1141             {
       
  1142             retValue = KErrGsmCCNetworkOutOfOrder;
       
  1143             break;
       
  1144             }
       
  1145             
       
  1146         case ECCPErrorCCNoRouteToDestination:
       
  1147             {
       
  1148             retValue = KErrGsmCCNoRouteToDestination;
       
  1149             break;
       
  1150             }
       
  1151 
       
  1152         case ECCPErrorCCDestinationOutOfOrder:
       
  1153             {
       
  1154             retValue = KErrGsmCCDestinationOutOfOrder;
       
  1155             break;
       
  1156             }
       
  1157             
       
  1158         case ECCPErrorCCResourceNotAvailable:
       
  1159             {
       
  1160             retValue = KErrGsmCCResourceNotAvailable;
       
  1161             break;
       
  1162             }
       
  1163             
       
  1164 
       
  1165         case ECCPErrorCCInvalidTransitNetworkSelection:
       
  1166             {
       
  1167             retValue = KErrGsmCCInvalidTransitNetworkSelection;
       
  1168             break;
       
  1169             }
       
  1170             
       
  1171         case ECCPErrorCCIncompatibleDestination:
       
  1172             {
       
  1173             retValue = KErrGsmCCIncompatibleDestination;
       
  1174             break;
       
  1175             }
       
  1176             
       
  1177         case ECCPErrorCCIncompatibleMessageInCallState:
       
  1178             {
       
  1179             retValue = KErrGsmCCIncompatibleMessageInCallState;
       
  1180             break;
       
  1181             }
       
  1182 
       
  1183         case ECCPErrorCCIncompatibleMessageInProtocolState:
       
  1184             {
       
  1185             retValue = KErrGsmCCIncompatibleMessageInProtocolState;
       
  1186             break;
       
  1187             }
       
  1188             
       
  1189         case ECCPErrorCCNormalCallClearing:
       
  1190             {
       
  1191             retValue = KErrGsmCCNormalCallClearing;
       
  1192             break;
       
  1193             }
       
  1194             
       
  1195         case ECCPErrorCCUserAlertingNoAnswer:
       
  1196             {
       
  1197             retValue = KErrGsmCCUserAlertingNoAnswer;
       
  1198             break;
       
  1199             }
       
  1200 
       
  1201         case ECCPErrorCCUserNotResponding:
       
  1202             {
       
  1203             retValue = KErrGsmCCUserNotResponding;
       
  1204             break;
       
  1205             }
       
  1206 
       
  1207         case ECCPErrorCCPreemption:
       
  1208             {
       
  1209             retValue = KErrGsmCCPreemption;
       
  1210             break;
       
  1211             }
       
  1212             
       
  1213         case ECCPErrorCCFacilityRejected:
       
  1214             {
       
  1215             retValue = KErrGsmCCFacilityRejected;
       
  1216             break;
       
  1217             }
       
  1218 
       
  1219         case ECCPErrorCCResponseToStatusEnquiry:
       
  1220             {
       
  1221             retValue = KErrGsmCCResponseToStatusEnquiry;
       
  1222             break;
       
  1223             }
       
  1224             
       
  1225         case ECCPErrorCCInvalidMandatoryInformation:
       
  1226             {
       
  1227             retValue = KErrGsmCCInvalidMandatoryInformation;
       
  1228             break;
       
  1229             }
       
  1230             
       
  1231         case ECCPErrorCCNonExistentMessageType:
       
  1232             {
       
  1233             retValue = KErrGsmCCNonExistentMessageType;
       
  1234             break;
       
  1235             }
       
  1236 
       
  1237         case ECCPErrorCCNonExistentInformationElement:
       
  1238             {
       
  1239             retValue = KErrGsmCCNonExistentInformationElement;
       
  1240             break;
       
  1241             }
       
  1242 
       
  1243         case ECCPErrorCCNoChannelAvailable:
       
  1244             {
       
  1245             retValue = KErrGsmCCNoChannelAvailable;
       
  1246             break;
       
  1247             }
       
  1248 
       
  1249         case ECCPErrorCCRequestedFacilityNotSubscribed:
       
  1250             {
       
  1251             retValue = KErrGsmCCRequestedFacilityNotSubscribed;
       
  1252             break;
       
  1253             }
       
  1254 
       
  1255         case ECCPErrorCCIncomingCallsBarredInCug:
       
  1256             {
       
  1257             retValue = KErrGsmCCIncomingCallsBarredInCug;
       
  1258             break;
       
  1259             }
       
  1260             
       
  1261         case ECCPErrorUserNotInCug:
       
  1262             {
       
  1263             retValue = KErrGsmCCUserNotInCug;
       
  1264             break;
       
  1265             }
       
  1266             
       
  1267         case ECCPErrorCCRecoveryOnTimerExpiry:
       
  1268             {
       
  1269             retValue = KErrGsmCCRecoveryOnTimerExpiry;
       
  1270             break;
       
  1271             }
       
  1272 
       
  1273         case ECCPErrorCCBearerCapabilityNotCurrentlyAvailable:
       
  1274             {
       
  1275             retValue = KErrGsmCCBearerCapabilityNotCurrentlyAvailable;
       
  1276             break;
       
  1277             }
       
  1278 
       
  1279         case ECCPErrorCCServiceNotAvailable:
       
  1280             {
       
  1281             retValue = KErrGsmCCServiceNotAvailable;
       
  1282             break;
       
  1283             }
       
  1284 
       
  1285         case ECCPErrorCCBearerServiceNotImplemented:
       
  1286             {
       
  1287             retValue = KErrGsmCCBearerServiceNotImplemented;
       
  1288             break;
       
  1289             }
       
  1290 
       
  1291         case ECCPErrorCCOnlyRestrictedDigitalInformationBCAvailable:
       
  1292             {
       
  1293             retValue = KErrGsmCCOnlyRestrictedDigitalInformationBCAvailable;
       
  1294             break;
       
  1295             }
       
  1296             
       
  1297         case ECCPErrorCCServiceNotImplemented:
       
  1298             {
       
  1299             retValue = KErrGsmCCServiceNotImplemented;
       
  1300             break;
       
  1301             }
       
  1302             
       
  1303         case ECCPErrorCCUnspecifiedInterworkingError:
       
  1304             {
       
  1305             retValue = KErrGsmCCUnspecifiedInterworkingError;
       
  1306             break;
       
  1307             }
       
  1308             
       
  1309         case ECCPErrorSatControl:
       
  1310             {
       
  1311             retValue = KErrSatControl;
       
  1312             break;
       
  1313             }
       
  1314                 
       
  1315         default:
       
  1316             {
       
  1317             retValue = KErrAccessDenied;
       
  1318             break;
       
  1319             }
       
  1320         }
       
  1321         
       
  1322     LOG2( SIMPLE, 
       
  1323         "SETUPCALL: CSetUpCallHandler::TccpErrorToSymbianError TCCP error:%d",
       
  1324          aTccpError)
       
  1325     LOG2( SIMPLE, 
       
  1326         "SETUPCALL: CSetUpCallHandler::TccpErrorToSymbianError \
       
  1327         mapped Symbian Error:%d", retValue)
       
  1328     LOG( SIMPLE, "SETUPCALL: CSetUpCallHandler::TccpErrorToSymbianError \
       
  1329         exiting" )
       
  1330     
       
  1331     return retValue;
       
  1332     }
       
  1333 
       
  1334 // -----------------------------------------------------------------------------
       
  1335 // Create emergency call
       
  1336 // -----------------------------------------------------------------------------
       
  1337 //
       
  1338 void CSetUpCallHandler::CreateEmergencyCallL()
       
  1339     {
       
  1340     LOG( SIMPLE, "SETUPCALL: CSetUpCallHandler::CreateEmergencyCallL calling" )
       
  1341     
       
  1342     if( !iEmergencyCallApi )
       
  1343         {
       
  1344         // Create service handler for emergency call setup..
       
  1345         LOG( SIMPLE, "SETUPCALL: CSetUpCallHandler::CreateEmergencyCallL\
       
  1346          create emergency call handler" )
       
  1347         iEmergencyCallApi = CPhCltEmergencyCall::NewL( this );
       
  1348         }
       
  1349     
       
  1350     iEmergencyCallApi->DialEmergencyCallL( 
       
  1351         iSetUpCallData.iAddress.iTelNumber );
       
  1352     LOG( SIMPLE, "SETUPCALL: CSetUpCallHandler::CreateEmergencyCallL exiting" )    
       
  1353     }
       
  1354 
       
  1355 // End Of File