satengine/SatServer/Commands/SetUpCallCmd/src/csetupcallrequesthandler.cpp
changeset 12 ae8abd0db65c
child 19 e44a8c097b15
equal deleted inserted replaced
0:ff3b6d0fd310 12:ae8abd0db65c
       
     1 /*
       
     2 * Copyright (c) 2009-2010 Nokia Corporation and/or its subsidiary(-ies). 
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:  Create the call and emergency call to ETelMM
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #include <etelmm.h>
       
    20 #include <mmtsy_names.h>
       
    21 
       
    22 
       
    23 #include "csetupcallrequesthandler.h"
       
    24 #include "CSetUpCallHandler.h"
       
    25 #include "msatasynctosync.h"
       
    26 #include "SatLog.h"
       
    27 
       
    28 // ================= MEMBER FUNCTIONS =======================
       
    29 
       
    30 // -----------------------------------------------------------------------------
       
    31 // CSetupCallRequestHandler::CSetupCallRequestHandler
       
    32 // The class constructor.
       
    33 // -----------------------------------------------------------------------------
       
    34 //
       
    35 CSetupCallRequestHandler::CSetupCallRequestHandler(
       
    36                 MSatMultiModeApi& aPhone, CSetUpCallHandler* aDispatcher )
       
    37     : CActive( EPriorityStandard ), iPhone( aPhone ), 
       
    38       iDispatcher( aDispatcher )
       
    39     {
       
    40     LOG( SIMPLE,
       
    41         "SETUPCALL: CSetupCallRequestHandler::CSetupCallRequestHandler \
       
    42         calling" )
       
    43 
       
    44     CActiveScheduler::Add( this );
       
    45 
       
    46     LOG( SIMPLE,
       
    47         "SETUPCALL: CSetupCallRequestHandler::CSetupCallRequestHandler \
       
    48         exiting" )
       
    49     }
       
    50 
       
    51 // -----------------------------------------------------------------------------
       
    52 // CSetupCallRequestHandler::NewL
       
    53 // Two-phased constructor.
       
    54 // -----------------------------------------------------------------------------
       
    55 //
       
    56 CSetupCallRequestHandler* CSetupCallRequestHandler::NewL(
       
    57     MSatMultiModeApi& aPhone, CSetUpCallHandler* aDispatcher )
       
    58     {
       
    59     LOG( SIMPLE, "SETUPCALL: CSetupCallRequestHandler::NewL calling" )
       
    60 
       
    61     CSetupCallRequestHandler* self =
       
    62         new ( ELeave ) CSetupCallRequestHandler( aPhone, aDispatcher );
       
    63  
       
    64     CleanupStack::PushL( self );
       
    65     self->ConstructL();
       
    66     CleanupStack::Pop( self );
       
    67     
       
    68     LOG( SIMPLE, "SETUPCALL: CSetupCallRequestHandler::NewL exiting" )
       
    69     return self;
       
    70     }
       
    71 
       
    72 // -----------------------------------------------------------------------------
       
    73 // CSetupCallRequestHandler::ConstructL
       
    74 // Two-phased constructor.
       
    75 // -----------------------------------------------------------------------------
       
    76 //
       
    77 void CSetupCallRequestHandler::ConstructL()
       
    78     {
       
    79     LOG( SIMPLE, "SETUPCALL: CSetupCallRequestHandler::ConstructL calling" )
       
    80     iStatusHandler = CSetupCallStatusHandler::NewL( iPhone, this );
       
    81     LOG( SIMPLE, "SETUPCALL: CSetupCallRequestHandler::ConstructL exiting" )    
       
    82     }
       
    83 
       
    84 // -----------------------------------------------------------------------------
       
    85 // CSetupCallRequestHandler::~CSetupCallRequestHandler
       
    86 // Destructor
       
    87 // -----------------------------------------------------------------------------
       
    88 //
       
    89 CSetupCallRequestHandler::~CSetupCallRequestHandler()
       
    90     {
       
    91     LOG( SIMPLE, "SETUPCALL: \
       
    92             CSetupCallRequestHandler::~CSetupCallRequestHandler calling" )
       
    93     Cancel();
       
    94     iDispatcher = NULL;
       
    95     delete iStatusHandler;
       
    96     
       
    97     LOG( SIMPLE, "SETUPCALL: \
       
    98             CSetupCallRequestHandler::~CSetupCallRequestHandler exiting" )
       
    99     }
       
   100 
       
   101 // -----------------------------------------------------------------------------
       
   102 // CSetupCallRequestHandler::DialNumber
       
   103 // -----------------------------------------------------------------------------
       
   104 //
       
   105 void CSetupCallRequestHandler::DialNumber( const TDesC8& aCallParams,
       
   106                   const TDesC& aTelNumber, TBool aTerminateOtherCall,
       
   107                   MSatAsyncToSync* aAsyncToSync )
       
   108     {
       
   109     LOG( SIMPLE, "SETUPCALL: CSetupCallRequestHandler::DialNumber calling" )
       
   110  
       
   111     TInt terminateRes ( KErrNone );
       
   112     
       
   113     if( aTerminateOtherCall )
       
   114         {
       
   115         if( aAsyncToSync )
       
   116             {
       
   117             iPhone.TerminateAllCalls( aAsyncToSync->RequestStatus() );
       
   118             terminateRes = aAsyncToSync->SetActiveAndWait();
       
   119             }
       
   120         else
       
   121             {
       
   122             LOG( SIMPLE, "SETUPCALL: CSetupCallRequestHandler::DialNumber \
       
   123                     bad MSatAsyncToSync pointer" )
       
   124             terminateRes  = KErrGeneral;
       
   125             }
       
   126         }
       
   127     
       
   128     if( !IsActive() )
       
   129         {
       
   130         if( KErrNone == terminateRes )
       
   131             {
       
   132             iPhone.DialNoFdnCheck( iStatus, aCallParams, aTelNumber );
       
   133             if ( iStatusHandler )
       
   134                 {
       
   135                 iStatusHandler->Start();
       
   136                 }
       
   137             SetActive();
       
   138             }
       
   139         else
       
   140             {
       
   141             iDispatcher->SetupCallRequestComplete( terminateRes );
       
   142             }
       
   143         }
       
   144     else
       
   145         {
       
   146         iDispatcher->SetupCallRequestComplete( KErrInUse );
       
   147         }
       
   148     
       
   149     LOG( SIMPLE, "SETUPCALL: CSetupCallRequestHandler::DialNumber exiting" )
       
   150     }
       
   151 
       
   152 // -----------------------------------------------------------------------------
       
   153 // CSetupCallRequestHandler::DialEmergencyCall
       
   154 // -----------------------------------------------------------------------------
       
   155 //
       
   156 void CSetupCallRequestHandler::DialEmergencyCall( const TDesC& aTelNumber )
       
   157     {
       
   158     LOG( SIMPLE, "SETUPCALL: CSetupCallRequestHandler::DialNumber calling" )
       
   159      
       
   160     if( !IsActive() )
       
   161         {
       
   162         iEmergencyCall = ETrue;
       
   163         iPhone.DialEmergencyCall( iStatus, aTelNumber );
       
   164         SetActive();
       
   165         }
       
   166     else
       
   167         {
       
   168         iDispatcher->SetupCallRequestComplete( KErrInUse );
       
   169         }
       
   170     
       
   171     LOG( SIMPLE, "SETUPCALL: CSetupCallRequestHandler::DialEmergencyCall exiting" )
       
   172     }
       
   173 
       
   174 // -----------------------------------------------------------------------------
       
   175 // CSetupCallRequestHandler::RunL
       
   176 // Handles the command.
       
   177 // -----------------------------------------------------------------------------
       
   178 //
       
   179 void CSetupCallRequestHandler::RunL()
       
   180     {
       
   181     LOG( SIMPLE, "SETUPCALL: CSetupCallRequestHandler::RunL calling" )
       
   182     
       
   183     LOG2( NORMAL, "SETUPCALL: CSetupCallRequestHandler::RunL\
       
   184           iStatus == %i", iStatus.Int() )
       
   185 
       
   186     if( !iResponsed )
       
   187         {
       
   188         if ( iEmergencyCall || KErrNone == iStatus.Int() )
       
   189             {
       
   190             iEmergencyCall = EFalse;
       
   191             iDispatcher->SetupCallRequestComplete( iStatus.Int() );
       
   192             }
       
   193         else
       
   194             {
       
   195             RMobileCall::TMobileCallInfoV8 info;
       
   196             RMobileCall::TMobileCallInfoV8Pckg infoPkg( info );
       
   197             TInt res = iPhone.GetMobileCallInfo( infoPkg );
       
   198         
       
   199             LOG2( NORMAL, "SETUPCALL: CSetupCallRequestHandler::\
       
   200                   HandleSetupCallStatusChange exit code == %i",
       
   201                   info.iExitCode )
       
   202         
       
   203             if( ( KErrNone == res ) && 
       
   204                     (KErrNone != info.iExitCode) &&
       
   205                     (KErrNotFound != info.iExitCode) )
       
   206                 {
       
   207                 iDispatcher->SetupCallRequestComplete( info.iExitCode );
       
   208                 }
       
   209             else
       
   210                 {
       
   211                 iDispatcher->SetupCallRequestComplete( iStatus.Int() );
       
   212                 }
       
   213             }
       
   214         }
       
   215    
       
   216     if( iStatusHandler )
       
   217         {
       
   218         iStatusHandler->Cancel();
       
   219         }
       
   220     iResponsed = EFalse;
       
   221     LOG( SIMPLE, "SETUPCALL: CSetupCallRequestHandler::RunL exiting" )
       
   222     }
       
   223 
       
   224 // -----------------------------------------------------------------------------
       
   225 // CSetupCallRequestHandler::CancelOperation
       
   226 // -----------------------------------------------------------------------------
       
   227 //
       
   228 void CSetupCallRequestHandler::CancelOperation()
       
   229     {
       
   230     LOG( SIMPLE, "SETUPCALL: \
       
   231                   CSetupCallRequestHandler::CancelOperation calling" )
       
   232     iPhone.DialCancel();
       
   233     if( iStatusHandler )
       
   234         {
       
   235         iStatusHandler->Cancel();
       
   236         }
       
   237     LOG( SIMPLE, 
       
   238         "SETUPCALL: CSetupCallRequestHandler::CancelOperation exiting" )
       
   239     }
       
   240 
       
   241 // -----------------------------------------------------------------------------
       
   242 // From class CActive.
       
   243 // Cancels the sat request.
       
   244 // -----------------------------------------------------------------------------
       
   245 //
       
   246 void CSetupCallRequestHandler::DoCancel()
       
   247     {
       
   248     LOG( SIMPLE, "SETUPCALL: CSetupCallRequestHandler::DoCancel calling" )
       
   249     CancelOperation();
       
   250     LOG( SIMPLE, "SETUPCALL: CSetupCallRequestHandler::DoCancel exiting" )
       
   251     }
       
   252 
       
   253 // -----------------------------------------------------------------------------
       
   254 // CSetupCallRequestHandler::HandleConnectingStatusChange
       
   255 // -----------------------------------------------------------------------------
       
   256 //
       
   257 void CSetupCallRequestHandler::CallSatatusChanged( const TInt aStatus )
       
   258     {
       
   259     LOG( SIMPLE, "SETUPCALL: CSetupCallRequestHandler::\
       
   260             CallSatatusChanged  calling" )
       
   261     
       
   262     LOG2( NORMAL, "SETUPCALL: CSetupCallRequestHandler::\
       
   263         CallSatatusChanged status == %i", aStatus )
       
   264     // We only care about the connecting status, after call is
       
   265     // connecting, we can send the respones to the SIM. For other status we will
       
   266     // waiting for the status of DialNumber.    
       
   267     if( ( aStatus == RMobileCall::EStatusConnected )
       
   268         || ( aStatus == RMobileCall::EStatusConnecting ))
       
   269         {
       
   270         iResponsed = ETrue;
       
   271         iDispatcher->SetupCallRequestComplete( KErrNone );
       
   272         }
       
   273     else
       
   274         {
       
   275         if ( iStatusHandler )
       
   276             {
       
   277             iStatusHandler->Start();
       
   278             }
       
   279         }
       
   280 
       
   281     LOG( SIMPLE, "SETUPCALL: CSetupCallRequestHandler::\
       
   282             CallSatatusChanged  exiting" )
       
   283     }
       
   284 
       
   285 
       
   286 //  End of File