natfw/natfwturnplugin/src/natfwturnactivedestinationtimer.cpp
changeset 0 1bce908db942
equal deleted inserted replaced
-1:000000000000 0:1bce908db942
       
     1 /*
       
     2 * Copyright (c) 2007 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:    Is used to time actions related to setting Active
       
    15 *                Destination request.
       
    16 *
       
    17 */
       
    18 
       
    19 
       
    20 
       
    21 
       
    22 #include "natfwturnactivedestinationtimer.h"
       
    23 #include "natfwturnpluginlogs.h"
       
    24 #include "natfwtimerobserver.h"
       
    25 
       
    26 
       
    27 // ======== MEMBER FUNCTIONS ========
       
    28 
       
    29 // ---------------------------------------------------------------------------
       
    30 // C++ default constructor
       
    31 // ---------------------------------------------------------------------------
       
    32 //
       
    33 CNATFWTurnActiveDestinationTimer::CNATFWTurnActiveDestinationTimer(
       
    34     MNATFWTimerObserver& aObserver ) : CActive( EPriorityStandard ), 
       
    35     iObserver( aObserver )
       
    36     {
       
    37     __TURNPLUGIN( 
       
    38     "CNATFWTurnActiveDestinationTimer::CNATFWTurnActiveDestinationTimer" )
       
    39     CActiveScheduler::Add( this );
       
    40     }
       
    41 
       
    42 
       
    43 // ---------------------------------------------------------------------------
       
    44 // Symbian constructor
       
    45 // Creates timer service.
       
    46 // ---------------------------------------------------------------------------
       
    47 //
       
    48 void CNATFWTurnActiveDestinationTimer::ConstructL()
       
    49     {
       
    50     __TURNPLUGIN( "CNATFWTurnActiveDestinationTimer::ConstructL" )
       
    51 
       
    52     User::LeaveIfError( iTimer.CreateLocal() );
       
    53     }
       
    54 
       
    55 
       
    56 // ---------------------------------------------------------------------------
       
    57 // Symbian constructor
       
    58 // ---------------------------------------------------------------------------
       
    59 //
       
    60 CNATFWTurnActiveDestinationTimer* CNATFWTurnActiveDestinationTimer::NewL(
       
    61     MNATFWTimerObserver& aObserver )
       
    62     {
       
    63     __TURNPLUGIN( "CNATFWTurnActiveDestinationTimer::NewL" )
       
    64     CNATFWTurnActiveDestinationTimer* self = 
       
    65         CNATFWTurnActiveDestinationTimer::NewLC( aObserver );
       
    66     CleanupStack::Pop( self );
       
    67     return self;
       
    68     }
       
    69 
       
    70 
       
    71 // ---------------------------------------------------------------------------
       
    72 // Symbian constructor
       
    73 // ---------------------------------------------------------------------------
       
    74 //
       
    75 CNATFWTurnActiveDestinationTimer* CNATFWTurnActiveDestinationTimer::NewLC(
       
    76     MNATFWTimerObserver& aObserver )
       
    77     {
       
    78     __TURNPLUGIN( "CNATFWTurnActiveDestinationTimer::NewLC" )
       
    79     CNATFWTurnActiveDestinationTimer* self = 
       
    80          new( ELeave ) CNATFWTurnActiveDestinationTimer( aObserver );
       
    81     CleanupStack::PushL( self );
       
    82     self->ConstructL();
       
    83     return self;
       
    84     }
       
    85 
       
    86 
       
    87 // ---------------------------------------------------------------------------
       
    88 // Destructor
       
    89 // ---------------------------------------------------------------------------
       
    90 //
       
    91 CNATFWTurnActiveDestinationTimer::~CNATFWTurnActiveDestinationTimer()
       
    92     {
       
    93     __TURNPLUGIN( 
       
    94     "CNATFWTurnActiveDestinationTimer::~CNATFWTurnActiveDestinationTimer" )
       
    95     Cancel();
       
    96     iTimer.Close();
       
    97     }
       
    98 
       
    99 
       
   100 // ---------------------------------------------------------------------------
       
   101 // CNATFWTurnActiveDestinationTimer::StartTimer
       
   102 // ---------------------------------------------------------------------------
       
   103 //
       
   104 void CNATFWTurnActiveDestinationTimer::StartTimer( TUint32 aInterval,
       
   105                                                    TUint aStreamId,
       
   106                                                    TUint aConnectionId )
       
   107     {
       
   108     __TURNPLUGIN( "CNATFWTurnActiveDestinationTimer::StartTimer" )
       
   109     
       
   110     iStreamId = aStreamId;
       
   111     iConnectionId = aConnectionId;
       
   112     
       
   113     if ( !IsActive() )
       
   114         {
       
   115         iTimer.After( iStatus, aInterval );
       
   116         SetActive();
       
   117         }
       
   118     }
       
   119 
       
   120 
       
   121 // ---------------------------------------------------------------------------
       
   122 // From class CActive
       
   123 // CNATFWTurnActiveDestinationTimer::RunL
       
   124 // ---------------------------------------------------------------------------
       
   125 //
       
   126 void CNATFWTurnActiveDestinationTimer::RunL()
       
   127     {
       
   128     __TURNPLUGIN( "CNATFWTurnActiveDestinationTimer::RunL" )
       
   129 
       
   130     iObserver.TimerTriggeredL( iStreamId, iConnectionId );
       
   131     }
       
   132 
       
   133 
       
   134 // ---------------------------------------------------------------------------
       
   135 // From class CActive
       
   136 // CNATFWTurnActiveDestinationTimer::DoCancel
       
   137 // ---------------------------------------------------------------------------
       
   138 //
       
   139 void CNATFWTurnActiveDestinationTimer::DoCancel()
       
   140     {
       
   141     __TURNPLUGIN( "CNATFWTurnActiveDestinationTimer::DoCancel" )
       
   142     iTimer.Cancel();
       
   143     }
       
   144 
       
   145 // End of file