|
1 /* |
|
2 * Copyright (c) 2003 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: Smart card command timer |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 // INCLUDE FILES |
|
21 #include "ScardAccessControl.h" |
|
22 #include "ScardBase.h" |
|
23 #include "ScardCommandTimer.h" |
|
24 #include "WimTrace.h" |
|
25 |
|
26 #ifdef _DEBUG // for logging |
|
27 #include "ScardLogs.h" |
|
28 #include <flogger.h> |
|
29 #endif |
|
30 |
|
31 // ============================ MEMBER FUNCTIONS =============================== |
|
32 |
|
33 // ----------------------------------------------------------------------------- |
|
34 // CScardCommandTimer::CScardCommandTimer |
|
35 // C++ default constructor can NOT contain any code, that |
|
36 // might leave. |
|
37 // ----------------------------------------------------------------------------- |
|
38 // |
|
39 CScardCommandTimer::CScardCommandTimer() |
|
40 : CActive( EPriorityNormal ) |
|
41 { |
|
42 _WIMTRACE(_L("WIM|Scard|CScardCommandTimer::CScardCommandTimer|Begin")); |
|
43 } |
|
44 |
|
45 // ----------------------------------------------------------------------------- |
|
46 // CScardCommandTimer::ConstructL |
|
47 // Symbian 2nd phase constructor can leave. |
|
48 // ----------------------------------------------------------------------------- |
|
49 // |
|
50 void CScardCommandTimer::ConstructL( |
|
51 TInt32 aTimeOut, |
|
52 CScardAccessControl* aController ) |
|
53 { |
|
54 _WIMTRACE(_L("WIM|Scard|CScardCommandTimer::ConstructL|Begin")); |
|
55 iTimeOut = aTimeOut; |
|
56 iController = aController; |
|
57 iTimer = new( ELeave ) RTimer; |
|
58 iTimer->CreateLocal(); |
|
59 CActiveScheduler::Add( this ); |
|
60 } |
|
61 |
|
62 // ----------------------------------------------------------------------------- |
|
63 // CScardCommandTimer::NewL |
|
64 // Two-phased constructor. |
|
65 // ----------------------------------------------------------------------------- |
|
66 // |
|
67 CScardCommandTimer* CScardCommandTimer::NewL( |
|
68 TInt32 aTimeOut, |
|
69 CScardAccessControl* aController ) |
|
70 { |
|
71 _WIMTRACE(_L("WIM|Scard|CScardCommandTimer::NewL|Begin")); |
|
72 __ASSERT_ALWAYS( aTimeOut >= 0, User::Leave( KScErrBadArgument ) ); |
|
73 CScardCommandTimer* self = new( ELeave ) CScardCommandTimer; |
|
74 |
|
75 CleanupStack::PushL( self ); |
|
76 self->ConstructL( aTimeOut, aController ); |
|
77 CleanupStack::Pop( self ); |
|
78 |
|
79 return self; |
|
80 } |
|
81 |
|
82 |
|
83 // Destructor |
|
84 CScardCommandTimer::~CScardCommandTimer() |
|
85 { |
|
86 _WIMTRACE(_L("WIM|Scard|CScardCommandTimer::~CScardCommandTimer|Begin")); |
|
87 if ( iTimer ) |
|
88 { |
|
89 Cancel(); |
|
90 delete iTimer; |
|
91 } |
|
92 } |
|
93 |
|
94 // ----------------------------------------------------------------------------- |
|
95 // CScardCommandTimer::StartTiming |
|
96 // Start the clock |
|
97 // ----------------------------------------------------------------------------- |
|
98 // |
|
99 void CScardCommandTimer::StartTiming() |
|
100 { |
|
101 _WIMTRACE(_L("WIM|Scard|CScardCommandTimer::StartTiming|Begin")); |
|
102 #ifdef _DEBUG |
|
103 RFileLogger::WriteFormat( KScardLogDir, KScardLogFileName, |
|
104 EFileLoggingModeAppend, |
|
105 _L( "CScardCommandTimer: start timer\n" ) ); |
|
106 #endif |
|
107 iTimer->After( iStatus, iTimeOut ); |
|
108 SetActive(); |
|
109 } |
|
110 |
|
111 // ----------------------------------------------------------------------------- |
|
112 // CScardCommandTimer::RunL |
|
113 // The timer finished, i.e. the command has timed out |
|
114 // ----------------------------------------------------------------------------- |
|
115 // |
|
116 void CScardCommandTimer::RunL() |
|
117 { |
|
118 _WIMTRACE(_L("WIM|Scard|CScardCommandTimer::RunL|Begin")); |
|
119 #ifdef _DEBUG |
|
120 RFileLogger::WriteFormat( KScardLogDir, KScardLogFileName, |
|
121 EFileLoggingModeAppend, |
|
122 _L( "CScardCommandTimer: timer expired\n" ) ); |
|
123 #endif |
|
124 iController->CancelByTimeOut( this ); |
|
125 delete iTimer; |
|
126 iTimer = NULL; |
|
127 } |
|
128 |
|
129 // ----------------------------------------------------------------------------- |
|
130 // CScardCommandTimer::DoCancel |
|
131 // ----------------------------------------------------------------------------- |
|
132 // |
|
133 void CScardCommandTimer::DoCancel() |
|
134 { |
|
135 _WIMTRACE(_L("WIM|Scard|CScardCommandTimer::DoCancel|Begin")); |
|
136 #ifdef _DEBUG |
|
137 RFileLogger::WriteFormat( KScardLogDir, KScardLogFileName, |
|
138 EFileLoggingModeAppend, |
|
139 _L( "CScardCommandTimer: cancel timer\n" ) ); |
|
140 #endif |
|
141 iTimer->Cancel(); |
|
142 } |
|
143 |
|
144 // End of File |