|
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 for smard card events |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 // INCLUDE FILES |
|
21 #include "ScardBase.h" |
|
22 #include "WimScardListener.h" |
|
23 #include "WimServer.h" |
|
24 #include "WimSession.h" |
|
25 #include "WimTrace.h" |
|
26 |
|
27 |
|
28 // ============================ MEMBER FUNCTIONS =============================== |
|
29 |
|
30 // ----------------------------------------------------------------------------- |
|
31 // C++ default constructor can NOT contain any code, that |
|
32 // might leave. |
|
33 // ----------------------------------------------------------------------------- |
|
34 // |
|
35 CWimScardListener::CWimScardListener( |
|
36 RScard* aScard, |
|
37 TUint8 aUiReaderID, |
|
38 const TScardReaderName& aName ) |
|
39 : CScardListener( aScard ), |
|
40 iUiReaderID( aUiReaderID ), |
|
41 iName( aName ) |
|
42 |
|
43 { |
|
44 _WIMTRACE(_L("WIM | WIMServer | CWimScardListener::CWimScardListener | Begin")); |
|
45 } |
|
46 |
|
47 // Destructor |
|
48 CWimScardListener::~CWimScardListener() |
|
49 { |
|
50 _WIMTRACE(_L("WIM | WIMServer | CWimScardListener::~CWimScardListener | Begin")); |
|
51 } |
|
52 |
|
53 // ----------------------------------------------------------------------------- |
|
54 // CWimScardListener::NewL |
|
55 // Two-phased constructor. |
|
56 // ----------------------------------------------------------------------------- |
|
57 // |
|
58 CWimScardListener* CWimScardListener::NewL( |
|
59 RScard* aScard, |
|
60 TUint8 aUiReaderID, |
|
61 const TScardReaderName& aName ) |
|
62 { |
|
63 _WIMTRACE(_L("WIM | WIMServer | CWimScardListener::NewL | Begin")); |
|
64 CWimScardListener* self = new( ELeave ) CWimScardListener( aScard, |
|
65 aUiReaderID, aName ); |
|
66 CleanupStack::PushL( self ); |
|
67 self->ConstructL(); |
|
68 CleanupStack::Pop( self ); |
|
69 return self; |
|
70 } |
|
71 |
|
72 // ----------------------------------------------------------------------------- |
|
73 // CWimScardListener::ConstructL |
|
74 // Symbian 2nd phase constructor can leave. |
|
75 // ----------------------------------------------------------------------------- |
|
76 // |
|
77 void CWimScardListener::ConstructL() |
|
78 { |
|
79 _WIMTRACE(_L("WIM | WIMServer | CWimScardListener::ConstructL | Begin")); |
|
80 User::LeaveIfError( ListenCardEvents( iName ) ); // Start listening events |
|
81 iServer = CWimServer::Server(); |
|
82 } |
|
83 |
|
84 // ----------------------------------------------------------------------------- |
|
85 // CWimScardListener::ProcessEvent |
|
86 // Card has been inserted/removed. From this point you have to inform |
|
87 // WIMI & client what has happened. |
|
88 // ----------------------------------------------------------------------------- |
|
89 // |
|
90 void CWimScardListener::ProcessEvent( const TScardServiceStatus aEvent ) |
|
91 { |
|
92 _WIMTRACE(_L("WIM | WIMServer | CWimScardListener::ProcessEvent | Begin")); |
|
93 |
|
94 switch ( aEvent ) |
|
95 { |
|
96 case EScardInserted: |
|
97 { |
|
98 _WIMTRACE(_L("WIM | WIMServer | CWimScardListener::ProcessEvent Inserted")); |
|
99 break; |
|
100 } |
|
101 |
|
102 case EScardRemoved: |
|
103 { |
|
104 _WIMTRACE(_L("WIM | WIMServer | CWimScardListener::ProcessEvent Removed")); |
|
105 RArray<CWimSession*> sessions; |
|
106 TRAPD( err, iServer->GetSessionsL( sessions ) ); |
|
107 |
|
108 if ( !err ) // Got sessions correctly |
|
109 { |
|
110 // Loop through all sessions and notify all clients that are |
|
111 // requesting the notification |
|
112 for ( TInt i( 0 ); i < sessions.Count(); i++ ) |
|
113 { |
|
114 sessions[i]->NotifyComplete(); |
|
115 } |
|
116 sessions.Reset(); |
|
117 // Close WIMI |
|
118 if( CWimServer::iWimInitialized ) |
|
119 { |
|
120 WIMI_CloseDownReq(); |
|
121 } |
|
122 CWimServer::SetWimInitialized( EFalse, KErrHardwareNotAvailable ); |
|
123 } |
|
124 break; |
|
125 } |
|
126 |
|
127 default: |
|
128 { |
|
129 _WIMTRACE(_L("WIM | WIMServer | CWimScardListener::ProcessEvent Unexpected smart card event")); |
|
130 break; |
|
131 } |
|
132 } |
|
133 _WIMTRACE(_L("WIM | WIMServer | CWimScardListener::ProcessEvent | End")); |
|
134 } |
|
135 |
|
136 // End of File |