|
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: Listens removal event from WimServer |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 // INCLUDE FILES |
|
20 |
|
21 #include "WimTokenListener.h" |
|
22 #include "WimTrace.h" |
|
23 //#include "WimDebug.h" |
|
24 |
|
25 // ============================ MEMBER FUNCTIONS =============================== |
|
26 |
|
27 // ----------------------------------------------------------------------------- |
|
28 // CWimTokenListener::CWimTokenListener() |
|
29 // Default constructor |
|
30 // ----------------------------------------------------------------------------- |
|
31 // |
|
32 CWimTokenListener::CWimTokenListener( CWimSecModule* aWimSecModule ) |
|
33 : CActive ( EPriorityNormal ), |
|
34 iWimSecModule( aWimSecModule ), |
|
35 iClientStatus( NULL ) |
|
36 { |
|
37 } |
|
38 |
|
39 // ----------------------------------------------------------------------------- |
|
40 // CWimTokenListener::ConstructL() |
|
41 // Second phase constructor |
|
42 // ----------------------------------------------------------------------------- |
|
43 // |
|
44 void CWimTokenListener::ConstructL() |
|
45 { |
|
46 _WIMTRACE ( _L( "CWimTokenListener::ConstructL()" ) ); |
|
47 CActiveScheduler::Add( this ); |
|
48 } |
|
49 |
|
50 // ----------------------------------------------------------------------------- |
|
51 // CWimTokenListener::NewL() |
|
52 // Two-phased constructor. |
|
53 // ----------------------------------------------------------------------------- |
|
54 // |
|
55 CWimTokenListener* CWimTokenListener::NewL( CWimSecModule* aWimSecModule ) |
|
56 { |
|
57 _WIMTRACE ( _L( "CWimTokenListener::NewL()" ) ); |
|
58 CWimTokenListener* self = new( ELeave ) CWimTokenListener( aWimSecModule ); |
|
59 CleanupStack::PushL( self ); |
|
60 self->ConstructL(); |
|
61 CleanupStack::Pop( self ); |
|
62 return self; |
|
63 } |
|
64 |
|
65 // ----------------------------------------------------------------------------- |
|
66 // CWimTokenListener::~CWimTokenListener() |
|
67 // Destructor |
|
68 // ----------------------------------------------------------------------------- |
|
69 // |
|
70 CWimTokenListener::~CWimTokenListener() |
|
71 { |
|
72 _WIMTRACE ( _L( "CWimTokenListener::~CWimTokenListener()" ) ); |
|
73 ClearClientStatus(); // Complete UI's request if needed |
|
74 if ( iWimSecModule && ( iTokenStatus == KRequestPending ) ) |
|
75 { |
|
76 iWimSecModule->CancelNotifyOnRemoval(); // Cancel listening in WimServer |
|
77 } |
|
78 Cancel(); |
|
79 } |
|
80 |
|
81 // ----------------------------------------------------------------------------- |
|
82 // CWimTokenListener::StartListening() |
|
83 // Start listening of Scard removal status |
|
84 // ----------------------------------------------------------------------------- |
|
85 // |
|
86 void CWimTokenListener::StartListening() |
|
87 { |
|
88 _WIMTRACE ( _L( "CWimTokenListener::StartListening()" ) ); |
|
89 iStatus = KRequestPending; |
|
90 iTokenStatus = KRequestPending; |
|
91 iWimSecModule->NotifyOnRemoval( iStatus ); |
|
92 SetActive(); |
|
93 } |
|
94 |
|
95 // ----------------------------------------------------------------------------- |
|
96 // CWimTokenListener::SetClientStatus() |
|
97 // Store client status |
|
98 // ----------------------------------------------------------------------------- |
|
99 // |
|
100 void CWimTokenListener::SetClientStatus( TRequestStatus& aStatus ) |
|
101 { |
|
102 _WIMTRACE ( _L( "CWimTokenListener::SetClientStatus()" ) ); |
|
103 iClientStatus = &aStatus; |
|
104 } |
|
105 |
|
106 // ----------------------------------------------------------------------------- |
|
107 // CWimTokenListener::ClearClientStatus() |
|
108 // If client request is still pending complete request with KErrCancel |
|
109 // ----------------------------------------------------------------------------- |
|
110 // |
|
111 void CWimTokenListener::ClearClientStatus() |
|
112 { |
|
113 _WIMTRACE ( _L( "CWimTokenListener::ClearClientStatus()" ) ); |
|
114 // If request is still pending, complete it with KErrCancel |
|
115 // RequestComplete sets iClientStatus to NULL |
|
116 if ( iClientStatus ) |
|
117 { |
|
118 User::RequestComplete( iClientStatus, KErrCancel ); |
|
119 } |
|
120 } |
|
121 |
|
122 // ----------------------------------------------------------------------------- |
|
123 // CWimTokenListener::RunL() |
|
124 // Complete asyncronous request |
|
125 // ----------------------------------------------------------------------------- |
|
126 // |
|
127 void CWimTokenListener::RunL() |
|
128 { |
|
129 switch ( iStatus.Int() ) |
|
130 { |
|
131 case KErrNone: |
|
132 { |
|
133 iTokenStatus = KErrHardwareNotAvailable; |
|
134 break; |
|
135 } |
|
136 case KErrCancel: |
|
137 { |
|
138 iTokenStatus = KErrCancel; |
|
139 break; |
|
140 } |
|
141 default: |
|
142 { |
|
143 iTokenStatus = iStatus.Int(); |
|
144 break; |
|
145 } |
|
146 } |
|
147 |
|
148 if ( iClientStatus ) // Complete the request if pending |
|
149 { |
|
150 User::RequestComplete( iClientStatus, iStatus.Int() ); |
|
151 } |
|
152 } |
|
153 |
|
154 // ----------------------------------------------------------------------------- |
|
155 // CWimTokenListener::DoCancel() |
|
156 // Nothing to do here |
|
157 // ----------------------------------------------------------------------------- |
|
158 // |
|
159 void CWimTokenListener::DoCancel() |
|
160 { |
|
161 _WIMTRACE ( _L( "CWimTokenListener::DoCancel()" ) ); |
|
162 } |
|
163 |
|
164 // ----------------------------------------------------------------------------- |
|
165 // CWimTokenListener::TokenStatus() |
|
166 // Return the staus of token |
|
167 // ----------------------------------------------------------------------------- |
|
168 // |
|
169 TInt CWimTokenListener::TokenStatus() |
|
170 { |
|
171 _WIMTRACE ( _L( "CWimTokenListener::TokenStatus()" ) ); |
|
172 return iTokenStatus; |
|
173 } |