phonecmdhandler/phonecmdhnlr/src/PhoneHandlerRedial.cpp
changeset 46 2fa1fa551b0b
parent 42 35488577e233
child 48 78df25012fda
equal deleted inserted replaced
42:35488577e233 46:2fa1fa551b0b
     1 /*
       
     2 * Copyright (c) 2002-2005 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 last number redial key press. 
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 // INCLUDE FILES
       
    20 
       
    21 #include "phonehandlerredial.h" 
       
    22 #include "phonehandlercontrol.h" 
       
    23 #include "phonehandlerdebug.h" 
       
    24 #include <RemConCallHandlingTarget.h> 
       
    25 #include <cphcltcommandhandler.h> 
       
    26 #include <phclttypes.h> 
       
    27 
       
    28 #ifdef SYMBIAN_ENABLE_SPLIT_HEADERS
       
    29 #include <logfilterandeventconstants.hrh>
       
    30 #endif
       
    31 
       
    32 // -----------------------------------------------------------------------------
       
    33 // CPhoneHandlerLastNumberRedial::CPhoneHandlerLastNumberRedial
       
    34 // C++ default constructor can NOT contain any code, that
       
    35 // might leave.
       
    36 // -----------------------------------------------------------------------------
       
    37 //
       
    38 CPhoneHandlerLastNumberRedial::CPhoneHandlerLastNumberRedial(
       
    39                             CPhoneHandlerControl& aControl,
       
    40                             TRemConExtCallHandlingApiOperationId aOperation )
       
    41 : iControl( aControl ), 
       
    42   iOperation( aOperation )
       
    43     {
       
    44     }
       
    45 
       
    46 // -----------------------------------------------------------------------------
       
    47 // CPhoneHandlerLastNumberRedial::ConstructL
       
    48 // Symbian 2nd phase constructor can leave.
       
    49 // -----------------------------------------------------------------------------
       
    50 //
       
    51 void CPhoneHandlerLastNumberRedial::ConstructL()
       
    52     {
       
    53     COM_TRACE_( "[PHONECMDHANDLER] CPhoneHandlerLastNumberRedial::ConstructL() start" );
       
    54     
       
    55     User::LeaveIfError(iFsSession.Connect());
       
    56 
       
    57     iLogClientPtr = CLogClient::NewL(iFsSession);
       
    58     iLogViewRecentPtr = CLogViewRecent::NewL(*iLogClientPtr);
       
    59     LoadServiceL();
       
    60     
       
    61     COM_TRACE_( "[PHONECMDHANDLER] CPhoneHandlerLastNumberRedial::ConstructL() end" );
       
    62     }
       
    63 
       
    64 // -----------------------------------------------------------------------------
       
    65 // CPhoneHandlerLastNumberRedial::NewL
       
    66 // Two-phased constructor.
       
    67 // -----------------------------------------------------------------------------
       
    68 //
       
    69 CPhoneHandlerLastNumberRedial* CPhoneHandlerLastNumberRedial::NewL( 
       
    70     CPhoneHandlerControl& aControl,
       
    71     TRemConExtCallHandlingApiOperationId aOperation )
       
    72     {
       
    73     CPhoneHandlerLastNumberRedial* self = 
       
    74         new (ELeave) CPhoneHandlerLastNumberRedial( aControl, aOperation );
       
    75     CleanupStack::PushL( self );
       
    76     self->ConstructL();
       
    77     CleanupStack::Pop( self );
       
    78     return self;
       
    79     }
       
    80 
       
    81 // Destructor
       
    82 CPhoneHandlerLastNumberRedial::~CPhoneHandlerLastNumberRedial()
       
    83     {
       
    84     COM_TRACE_( "[PHONECMDHANDLER] CPhoneHandlerLastNumberRedial::CPhoneHandlerLastNumberRedial() start" );
       
    85     
       
    86     delete iLogViewRecentPtr;
       
    87     delete iLogClientPtr;
       
    88     iFsSession.Close();
       
    89     
       
    90     COM_TRACE_( "[PHONECMDHANDLER] CPhoneHandlerLastNumberRedial::CPhoneHandlerLastNumberRedial() end" );
       
    91     }
       
    92 
       
    93 // -----------------------------------------------------------------------------
       
    94 // CPhoneHandlerLastNumberRedial::Process
       
    95 // Starts to process service.
       
    96 // (other items were commented in a header).
       
    97 // -----------------------------------------------------------------------------
       
    98 //
       
    99 void CPhoneHandlerLastNumberRedial::Process()
       
   100     {
       
   101     COM_TRACE_( "[PHONECMDHANDLER] CPhoneHandlerLastNumberRedial::Process() start" );
       
   102     
       
   103     TBool ret = EFalse;
       
   104         
       
   105     TRAPD( err, ret = iLogViewRecentPtr->
       
   106         SetRecentListL( KLogRecentOutgoingCalls, GetStatus() ) ); 
       
   107     if( KErrNone == err && ret )
       
   108         {
       
   109         COM_TRACE_( "[PHONECMDHANDLER] CPhoneHandlerLastNumberRedial::Process() There is last redial number" );
       
   110         Activate();
       
   111         }
       
   112     else
       
   113         {
       
   114         if( err != KErrNone )
       
   115             {
       
   116             COM_TRACE_1( "[PHONECMDHANDLER] CPhoneHandlerLastNumberRedial::Process() failed err=%d", err );
       
   117             RequestCompleted( err ); 
       
   118             }
       
   119         else
       
   120             {
       
   121             COM_TRACE_1( "[PHONECMDHANDLER] CPhoneHandlerLastNumberRedial::Process() failed err=%d", KErrNotFound );
       
   122             RequestCompleted( KErrNotFound ); 
       
   123             }
       
   124         }
       
   125         
       
   126     COM_TRACE_( "[PHONECMDHANDLER] CPhoneHandlerLastNumberRedial::Process() end" );
       
   127     }
       
   128 
       
   129 // -----------------------------------------------------------------------------
       
   130 // CPhoneHandlerLastNumberRedial::Delete
       
   131 // (other items were commented in a header).
       
   132 // -----------------------------------------------------------------------------
       
   133 //
       
   134 void CPhoneHandlerLastNumberRedial::Delete()
       
   135     {
       
   136     COM_TRACE_( "[PHONECMDHANDLER] CPhoneHandlerLastNumberRedial::Delete()" );
       
   137         
       
   138     delete this;
       
   139     }
       
   140 
       
   141 // -----------------------------------------------------------------------------
       
   142 // CPhoneHandlerLastNumberRedial::RequestCompleted
       
   143 // Handler for completed asynchronous calls.
       
   144 // (other items were commented in a header).
       
   145 // -----------------------------------------------------------------------------
       
   146 //
       
   147 void CPhoneHandlerLastNumberRedial::RequestCompleted( const TInt aError )
       
   148     {
       
   149     COM_TRACE_2( "[PHONECMDHANDLER] CPhoneHandlerLastNumberRedial::RequestCompleted() aError=%d, iState=%d", aError, iState );
       
   150     
       
   151     if( KErrNone != aError )
       
   152         {
       
   153         // cancel process and return an error code
       
   154         iState = EPhoneHandlerState2;
       
   155         }
       
   156     
       
   157     switch( iState )
       
   158         {
       
   159         case EPhoneHandlerState1:
       
   160             {
       
   161             NextState();
       
   162             
       
   163             const TDesC& number = iLogViewRecentPtr->Event().Number();
       
   164             COM_TRACE_1( "[PHONECMDHANDLER] CPhoneHandlerLastNumberRedial::RequestCompleted() phone number is %S", &number );
       
   165             // make a call with last dialed phone number
       
   166             iCommandHandler->Atd( GetStatus(), number );
       
   167 
       
   168             Activate(); 
       
   169             break;
       
   170             }
       
   171         
       
   172         case EPhoneHandlerState2:
       
   173             {
       
   174             NextState();
       
   175             iControl.CommandInitiator().SendResponse( GetStatus(), 
       
   176                                                       iOperation,
       
   177                                                       aError );
       
   178             Activate();
       
   179             break;
       
   180             }
       
   181             
       
   182         case EPhoneHandlerState3:
       
   183             {
       
   184             IdleState();
       
   185             delete this; 
       
   186             break;
       
   187             }
       
   188                 
       
   189         default:
       
   190             {
       
   191             COM_TRACE_( "[PHONECMDHANDLER] CPhoneHandlerLastNumberRedial::RequestCompleted() Unspecified state" );
       
   192             break;
       
   193             }
       
   194         };
       
   195         
       
   196     COM_TRACE_( "[PHONECMDHANDLER] CPhoneHandlerLastNumberRedial::RequestCompleted() end" );
       
   197     }
       
   198 
       
   199 // ========================== OTHER EXPORTED FUNCTIONS =========================
       
   200 
       
   201 //  End of File