|
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 // INCLUDE FILES |
|
20 #include "Scard.h" |
|
21 #include "ScardBase.h" |
|
22 #include "ScardListener.h" |
|
23 #include "ScardClsv.h" |
|
24 #include "WimTrace.h" |
|
25 |
|
26 |
|
27 // ============================ MEMBER FUNCTIONS =============================== |
|
28 |
|
29 // ----------------------------------------------------------------------------- |
|
30 // C++ default constructor can NOT contain any code, that |
|
31 // might leave. |
|
32 // ----------------------------------------------------------------------------- |
|
33 // |
|
34 EXPORT_C CScardListener::CScardListener( RScard* aScard ) |
|
35 : CActive( CActive::EPriorityStandard ) |
|
36 { |
|
37 _WIMTRACE(_L("WIM|Scard|CScardListener::CScardListener|Begin")); |
|
38 __ASSERT_ALWAYS( aScard, User::Panic( _L( "NULL pointer" ), |
|
39 KErrArgument ) ); |
|
40 iScard = aScard; |
|
41 CActiveScheduler::Add( this ); |
|
42 } |
|
43 |
|
44 // Destructor |
|
45 EXPORT_C CScardListener::~CScardListener() |
|
46 { |
|
47 _WIMTRACE(_L("WIM|Scard|CScardListener::~CScardListener|Begin")); |
|
48 Cancel(); // Make sure we're cancelled |
|
49 _WIMTRACE(_L("WIM|Scard|CScardListener::~CScardListener|End")); |
|
50 } |
|
51 |
|
52 |
|
53 // ----------------------------------------------------------------------------- |
|
54 // CScardListener::ListenCardEvents |
|
55 // Start listening card events |
|
56 // ----------------------------------------------------------------------------- |
|
57 // |
|
58 EXPORT_C TInt CScardListener::ListenCardEvents( |
|
59 const TScardReaderName& aReaderName ) |
|
60 { |
|
61 _WIMTRACE(_L("WIM|Scard|CScardListener::ListenCardEvents|Begin")); |
|
62 iReaderName.Copy( aReaderName ); |
|
63 TInt err = NotifyChange( iStatus, aReaderName ); |
|
64 SetActive(); |
|
65 return err; |
|
66 } |
|
67 |
|
68 // ----------------------------------------------------------------------------- |
|
69 // CScardListener::DoCancel |
|
70 // Listening cancelled |
|
71 // ----------------------------------------------------------------------------- |
|
72 // |
|
73 EXPORT_C void CScardListener::DoCancel() |
|
74 { |
|
75 _WIMTRACE(_L("WIM|Scard|CScardListener::DoCancel|Begin")); |
|
76 CancelNotifyChange(iReaderName ); |
|
77 } |
|
78 |
|
79 // ----------------------------------------------------------------------------- |
|
80 // CScardListener::RunL |
|
81 // Handle event we have got |
|
82 // ----------------------------------------------------------------------------- |
|
83 // |
|
84 EXPORT_C void CScardListener::RunL() |
|
85 { |
|
86 _WIMTRACE(_L("WIM|Scard|CScardListener::RunL|Begin")); |
|
87 TScardServiceStatus event = (TScardServiceStatus) iStatus.Int(); |
|
88 //iStatus = KRequestPending; |
|
89 //SetActive(); |
|
90 ProcessEvent( event ); |
|
91 _WIMTRACE(_L("WIM|Scard|CScardListener::RunL|END")); |
|
92 } |
|
93 |
|
94 // ----------------------------------------------------------------------------- |
|
95 // CScardListener::NotifyChange |
|
96 // Send NotifyChange opcode to server |
|
97 // ----------------------------------------------------------------------------- |
|
98 // |
|
99 TInt CScardListener::NotifyChange( |
|
100 TRequestStatus& aStatus, |
|
101 const TScardReaderName& aFriendlyName ) |
|
102 { |
|
103 _WIMTRACE(_L("WIM|Scard|CScardListener::NotifyChange|Begin")); |
|
104 aStatus = KRequestPending; |
|
105 iPckg = &aStatus; |
|
106 //TPckgBuf<TRequestStatus*> pckg( &aStatus ); |
|
107 |
|
108 TIpcArgs args( &iPckg, &aFriendlyName ); |
|
109 iScard->SendReceive( EScardServerNotifyChange, args, aStatus ); |
|
110 return KErrNone; |
|
111 } |
|
112 |
|
113 // ----------------------------------------------------------------------------- |
|
114 // CScardListener::CancelNotifyChange |
|
115 // Send CancelNotifyChange opcode to server |
|
116 // ----------------------------------------------------------------------------- |
|
117 // |
|
118 /*void CScardListener::CancelNotifyChange( |
|
119 TRequestStatus& aStatus, |
|
120 const TScardReaderName& aFriendlyName ) |
|
121 { |
|
122 _WIMTRACE(_L("WIM|Scard|CScardListener::CancelNotifyChange|Begin")); |
|
123 |
|
124 //TPckgBuf<TRequestStatus*> pckg( &aStatus ); |
|
125 iPckg = &aStatus; |
|
126 |
|
127 TIpcArgs args( &iPckg, &aFriendlyName ); |
|
128 |
|
129 iScard->SendReceive( EScardServerCancelNotifyChange, args ); |
|
130 _WIMTRACE(_L("WIM|Scard|CScardListener::CancelNotifyChange|End")); |
|
131 }*/ |
|
132 |
|
133 |
|
134 TInt CScardListener::CancelNotifyChange( const TScardReaderName& aFriendlyName ) |
|
135 { |
|
136 _WIMTRACE(_L("WIM|Scard|CScardListener::CancelNotifyChange|Begin")); |
|
137 |
|
138 //this parameter is not used in server side |
|
139 //It will be useful if there is a multiple scard listener |
|
140 //currently only wimserver is the scard listener, so by calling |
|
141 //this function, the array of listener will be cleaned. |
|
142 TIpcArgs args( &iPckg, &aFriendlyName ); |
|
143 |
|
144 return iScard->SendReceive( EScardServerCancelNotifyChange, args ); |
|
145 _WIMTRACE(_L("WIM|Scard|CScardListener::CancelNotifyChange|End")); |
|
146 } |
|
147 |
|
148 // End of File |