|
1 /* |
|
2 * Copyright (c) 2002 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: Timer for Tcp CirWatcher. |
|
15 * |
|
16 * |
|
17 */ |
|
18 |
|
19 |
|
20 // INCLUDES |
|
21 #include "TcpCirWatcher.h" |
|
22 #include "TcpCirWatcherTimer.h" |
|
23 |
|
24 // ================= MEMBER FUNCTIONS ======================= |
|
25 |
|
26 // --------------------------------------------------------- |
|
27 // C++ constructor may NOT contain any code, that |
|
28 // might leave. |
|
29 // --------------------------------------------------------- |
|
30 // |
|
31 CTcpCirWatcherTimer::CTcpCirWatcherTimer( MTcpCirWatcherTimerCallback* aCallback ) : |
|
32 CActive( 0 ), |
|
33 iCallback( aCallback ) |
|
34 |
|
35 { |
|
36 } |
|
37 |
|
38 // --------------------------------------------------------- |
|
39 // Symbian OS constructor may leave. |
|
40 // |
|
41 // --------------------------------------------------------- |
|
42 // |
|
43 void CTcpCirWatcherTimer::ConstructL() |
|
44 { |
|
45 User::LeaveIfError( iTimer.CreateLocal() ); |
|
46 CActiveScheduler::Add( this ); |
|
47 } |
|
48 |
|
49 // --------------------------------------------------------- |
|
50 // Two-phased constructor. |
|
51 // |
|
52 // --------------------------------------------------------- |
|
53 // |
|
54 CTcpCirWatcherTimer* CTcpCirWatcherTimer::NewL( MTcpCirWatcherTimerCallback* aCallback ) |
|
55 { |
|
56 CTcpCirWatcherTimer* self = new ( ELeave ) CTcpCirWatcherTimer( aCallback ); |
|
57 CleanupStack::PushL( self ); |
|
58 self->ConstructL(); |
|
59 CleanupStack::Pop(); |
|
60 return self; |
|
61 } |
|
62 |
|
63 // --------------------------------------------------------- |
|
64 // Destructor |
|
65 // |
|
66 // --------------------------------------------------------- |
|
67 // |
|
68 CTcpCirWatcherTimer::~CTcpCirWatcherTimer() |
|
69 { |
|
70 #ifdef _DEBUG |
|
71 CTcpCirWatcher::WriteToLog( _L8( "CTcpCirWatcherTimer::~CTcpCirWatcherTimer(), destructor called." ) ); |
|
72 #endif |
|
73 Cancel(); |
|
74 iTimer.Close(); |
|
75 } |
|
76 |
|
77 |
|
78 // --------------------------------------------------------- |
|
79 // CTcpCirWatcherTimer::ActivateTimer |
|
80 // |
|
81 // --------------------------------------------------------- |
|
82 // |
|
83 void CTcpCirWatcherTimer::ActivateTimer( const TTimeIntervalMicroSeconds32 aDelay, |
|
84 const TInt aCurrentTask ) |
|
85 { |
|
86 __ASSERT_ALWAYS( !IsActive(), User::Panic( _L( "CTcpCirWatcherTimer" ), 1 ) ); |
|
87 iCurrentTask = aCurrentTask; |
|
88 iTimer.After( iStatus, aDelay ); |
|
89 #ifdef _DEBUG |
|
90 CTcpCirWatcher::WriteToLog( _L8( "CTcpCirWatcherTimer activated." ) ); |
|
91 #endif |
|
92 SetActive(); |
|
93 } |
|
94 |
|
95 // --------------------------------------------------------- |
|
96 // CTcpCirWatcherTimer::RunL() |
|
97 // |
|
98 // --------------------------------------------------------- |
|
99 // |
|
100 void CTcpCirWatcherTimer::RunL() |
|
101 { |
|
102 #ifdef _DEBUG |
|
103 CTcpCirWatcher::WriteToLog( _L8( "CTcpCirWatcherTimer::RunL()." ) ); |
|
104 #endif |
|
105 iCallback->HandleTimerEventL( iCurrentTask ); |
|
106 iCurrentTask = 0; |
|
107 } |
|
108 |
|
109 // --------------------------------------------------------- |
|
110 // CTcpCirWatcherTimer::DoCancel() |
|
111 // --------------------------------------------------------- |
|
112 // |
|
113 void CTcpCirWatcherTimer::DoCancel() |
|
114 { |
|
115 iTimer.Cancel(); |
|
116 iCurrentTask = 0; |
|
117 #ifdef _DEBUG |
|
118 CTcpCirWatcher::WriteToLog( _L8( "CTcpCirWatcherTimer::DoCancel()" ) ); |
|
119 #endif |
|
120 } |
|
121 |
|
122 // End of File |
|
123 |