phoneengine/phonemodel/src/cpetimer.cpp
changeset 0 5f000ab63145
equal deleted inserted replaced
-1:000000000000 0:5f000ab63145
       
     1 /*
       
     2 * Copyright (c) 2002-2004 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:  This module contains the implementation of CPETimer class 
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 // INCLUDE FILES
       
    20 #include "cpetimer.h"
       
    21 #include "mpephonemodelinternal.h"
       
    22 
       
    23 // EXTERNAL DATA STRUCTURES
       
    24 // None.
       
    25 
       
    26 // EXTERNAL FUNCTION PROTOTYPES  
       
    27 // None.
       
    28 
       
    29 // CONSTANTS
       
    30 // None.
       
    31 
       
    32 // MACROS
       
    33 // None.
       
    34 
       
    35 // LOCAL CONSTANTS AND MACROS
       
    36 // None.
       
    37 
       
    38 // MODULE DATA STRUCTURES
       
    39 // None.
       
    40 
       
    41 // LOCAL FUNCTION PROTOTYPES
       
    42 // None.
       
    43 
       
    44 // FORWARD DECLARATIONS
       
    45 //None
       
    46 
       
    47 // ==================== LOCAL FUNCTIONS ========================================
       
    48 // None.
       
    49 
       
    50 // ================= MEMBER FUNCTIONS ==========================================
       
    51 
       
    52 // -----------------------------------------------------------------------------
       
    53 // CPETimer::CPETimer
       
    54 // C++ default constructor can NOT contain any code, that
       
    55 // might leave.
       
    56 // -----------------------------------------------------------------------------
       
    57 //
       
    58 CPETimer::CPETimer
       
    59         (
       
    60         MPEPhoneModelInternal& aModel   //MPEPhoneModelInternal is used to message sending.
       
    61         ) : CActive( EPriorityStandard ), 
       
    62             iModel( aModel )
       
    63     {
       
    64     CActiveScheduler::Add( this );
       
    65     }
       
    66 // -----------------------------------------------------------------------------
       
    67 // CPETimer::ConstructL
       
    68 // Symbian 2nd phase constructor can leave.
       
    69 // -----------------------------------------------------------------------------
       
    70 //
       
    71 void CPETimer::ConstructL()
       
    72     {
       
    73     User::LeaveIfError( iTimer.CreateLocal() );
       
    74     }
       
    75 
       
    76 // -----------------------------------------------------------------------------
       
    77 // CPETimer::NewL
       
    78 // Two-phased constructor.
       
    79 // -----------------------------------------------------------------------------
       
    80 //
       
    81 CPETimer* CPETimer::NewL(
       
    82     MPEPhoneModelInternal& aModel )
       
    83     {
       
    84     CPETimer* self = new ( ELeave ) CPETimer ( aModel );
       
    85     CleanupStack::PushL( self );
       
    86     self->ConstructL();
       
    87     CleanupStack::Pop( self );
       
    88     return self;
       
    89     }
       
    90 
       
    91 // Destructor
       
    92 CPETimer::~CPETimer
       
    93         (
       
    94         // None.
       
    95         )
       
    96     {
       
    97     Cancel();
       
    98     iTimer.Close();
       
    99     }
       
   100 
       
   101 // -----------------------------------------------------------------------------
       
   102 // CPETimer::ResetTimer
       
   103 // Starts CPEtimer object
       
   104 // (other items were commented in a header).
       
   105 // -----------------------------------------------------------------------------
       
   106 //
       
   107 void CPETimer::ResetTimer
       
   108         (
       
   109         // None
       
   110         )
       
   111     {
       
   112     Cancel();
       
   113     }
       
   114 
       
   115 // -----------------------------------------------------------------------------
       
   116 // CPETimer::StartTimer
       
   117 // Starts CPEtimer object
       
   118 // (other items were commented in a header).
       
   119 // -----------------------------------------------------------------------------
       
   120 //
       
   121 TInt CPETimer::StartTimer
       
   122         (
       
   123         const TTimeIntervalMicroSeconds32 aSeconds, // includes timer delay
       
   124         const MEngineMonitor::TPEMessagesFromPhoneEngine aResponseMessage,          // the identification number of the response message
       
   125         const TInt aCallId                          // the identification number of the call
       
   126         )
       
   127     {
       
   128     TInt errorCode( ECCPErrorAlreadyInUse );
       
   129     if ( !IsActive() )
       
   130         {
       
   131         iTimer.Cancel();
       
   132         iResponseMessage = aResponseMessage;
       
   133         iCallId = aCallId;
       
   134         iTimer.After( iStatus,  aSeconds );
       
   135         SetActive( );
       
   136         errorCode = ECCPErrorNone;    
       
   137         }
       
   138     return errorCode;
       
   139     
       
   140     }
       
   141 
       
   142 // -----------------------------------------------------------------------------
       
   143 // CPETimer::DoCancel
       
   144 // Cancels active object requests
       
   145 // Method switches the asyncronous request by call status
       
   146 // (other items were commented in a header).
       
   147 // -----------------------------------------------------------------------------
       
   148 //
       
   149 void CPETimer::DoCancel
       
   150         (
       
   151         // None
       
   152         )
       
   153     {
       
   154     iTimer.Cancel();
       
   155     iCallId = KPECallIdNotUsed;
       
   156     }
       
   157 
       
   158 // -----------------------------------------------------------------------------
       
   159 // CPETimer::GetCallId
       
   160 // Gets the identification number of the call from intance variable.
       
   161 // (other items were commented in a header).
       
   162 // -----------------------------------------------------------------------------
       
   163 //
       
   164 void CPETimer::GetCallId
       
   165         (
       
   166         TInt& aCallId   // Includes identification number of the call.
       
   167         ) const
       
   168     {
       
   169     aCallId = iCallId;
       
   170     }
       
   171 
       
   172 // -----------------------------------------------------------------------------
       
   173 // CPETimer::RunL
       
   174 // Method gets notification from etel that asyncronous request is completed.
       
   175 // (other items were commented in a header).
       
   176 // -----------------------------------------------------------------------------
       
   177 //
       
   178 void CPETimer::RunL
       
   179         (
       
   180         // None.
       
   181         )
       
   182     {
       
   183     if (iStatus != KErrCancel)
       
   184         {   
       
   185         iModel.SendMessage( iResponseMessage, iCallId );
       
   186         }
       
   187     }
       
   188     
       
   189 // ================= OTHER EXPORTED FUNCTIONS ===============================
       
   190 //None
       
   191     
       
   192 // End of File