|
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: SmartCard server. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 #ifndef CSCARDSERVER_H |
|
21 #define CSCARDSERVER_H |
|
22 |
|
23 // INCLUDES |
|
24 #include "ScardReaderLauncher.h" |
|
25 |
|
26 |
|
27 // FORWARD DECLARATIONS |
|
28 class CScardAccessControl; |
|
29 class CScardAccessControlRegistry; |
|
30 class CScardSession; |
|
31 class CScardNotifyRegistry; |
|
32 class CScardReaderRegistry; |
|
33 class CScardResourceRegistry; |
|
34 class CScardConnectionRegistry; |
|
35 |
|
36 |
|
37 // CLASS DECLARATION |
|
38 |
|
39 /** |
|
40 * Server class. |
|
41 * Contains an object container index which provides subsessions with |
|
42 * object containers. |
|
43 * |
|
44 * @lib Scard.lib |
|
45 * @since Series60 2.1 |
|
46 */ |
|
47 class CScardServer : public CServer2, public MScardReaderService |
|
48 { |
|
49 public: // Constructors and destructor |
|
50 |
|
51 /** |
|
52 * Two-phased constructor. |
|
53 */ |
|
54 static CScardServer* NewL(); |
|
55 |
|
56 /** |
|
57 * Destructor. |
|
58 */ |
|
59 virtual ~CScardServer(); |
|
60 |
|
61 public: // New functions |
|
62 |
|
63 /** |
|
64 * Panic server |
|
65 * @param aPanic Panic code |
|
66 * @return void |
|
67 */ |
|
68 static void PanicServer( const TInt aPanic ); |
|
69 |
|
70 /** |
|
71 * List the readers, which have not opened yet. |
|
72 * @param aStarted Thread parameter |
|
73 * @return TInt |
|
74 */ |
|
75 static TInt ThreadFunction( TAny* aStarted ); |
|
76 |
|
77 /** |
|
78 * Opens session. |
|
79 * @param aVersion Version of the server |
|
80 * @return Pointer to created session |
|
81 */ |
|
82 virtual CSession2* CScardServer::NewSessionL( |
|
83 const TVersion& aVersion, |
|
84 const RMessage2& aMessage ) const; |
|
85 |
|
86 /** |
|
87 * Return pointers to registries. |
|
88 * @return Pointer to CScardNotifyRegistry object |
|
89 */ |
|
90 inline CScardNotifyRegistry* NotifyRegistry() const; |
|
91 |
|
92 /** |
|
93 * Return pointer to reader registry. |
|
94 * @return Pointer to CScardReaderRegistry object |
|
95 */ |
|
96 inline CScardReaderRegistry* FactoryRegistry() const; |
|
97 |
|
98 /** |
|
99 * Return pointer to an access controller. |
|
100 * @param aReaderID Reader ID |
|
101 * @return Pointer to CScardAccessControl object |
|
102 */ |
|
103 inline CScardAccessControl* FindAccessControl( |
|
104 const TReaderID aReaderID ) const; |
|
105 |
|
106 /** |
|
107 * Scan through the readers to see if this reader is supported |
|
108 * (so it is usable). |
|
109 * @param aReaderName Name of the reader |
|
110 * @return ETrue if reader is supported else EFalse |
|
111 */ |
|
112 inline const TBool ReaderSupported( |
|
113 const TScardReaderName& aReaderName ) const; |
|
114 |
|
115 /** |
|
116 * Scan the access controllers to see if reader is loaded at the moment. |
|
117 * @param aReaderName Name of the reader |
|
118 * @return ETrue if reader is in use, otherwise EFalse |
|
119 */ |
|
120 inline const TBool ReaderInUse( |
|
121 const TScardReaderName& aReaderName ) const; |
|
122 |
|
123 /** |
|
124 * Scan the database to see if group is loaded at the moment. |
|
125 * @param aGroupName Name of the group |
|
126 * @return ETrue if group is in use, otherwise EFalse |
|
127 */ |
|
128 inline const TBool GroupInUse( |
|
129 const TScardReaderName& aGroupName ) const; |
|
130 |
|
131 /** |
|
132 * Return pointer to notify observer. |
|
133 * @return Pointer to MScardNotifyObserver object |
|
134 */ |
|
135 inline MScardNotifyObserver* NotifyObserver(); |
|
136 |
|
137 /** |
|
138 * Return pointer to access control registry object. |
|
139 * @return Pointer to CScardAccessControlRegistry object |
|
140 */ |
|
141 inline CScardAccessControlRegistry* AccessRegistry() const; |
|
142 |
|
143 /** |
|
144 * Return pointer to reader registry object. |
|
145 * @return Pointer to CScardReaderRegistry object |
|
146 */ |
|
147 inline CScardReaderRegistry* ReaderRegistry() const; |
|
148 |
|
149 /** |
|
150 * Return pointer to connection registry object. |
|
151 * @return Pointer to CScardConnectionRegistry object |
|
152 */ |
|
153 inline CScardConnectionRegistry* ConnectionRegistry() const; |
|
154 |
|
155 /** |
|
156 * Return pointer to Reader service object |
|
157 * @return Pointer to MScardReaderService object |
|
158 */ |
|
159 inline MScardReaderService* ReaderService(); |
|
160 |
|
161 /** |
|
162 * Scan database to see ID belonging to this name. |
|
163 * @param aFriendlyName DB Name |
|
164 * @return Reader ID for given reader name |
|
165 */ |
|
166 inline const TReaderID ReaderID( |
|
167 const TScardReaderName& aFriendlyName ) const; |
|
168 |
|
169 /** |
|
170 * Scan the database for the name belonging to this ID. |
|
171 * @param aReaderID Reader ID |
|
172 * @return Name of the given reader ID |
|
173 */ |
|
174 inline const TScardReaderName FriendlyName( |
|
175 const TReaderID aReaderID ) const; |
|
176 |
|
177 /** |
|
178 * Connect to reader. |
|
179 * @param aSession Pointer to session |
|
180 * @param aMessage Message |
|
181 * @return void |
|
182 */ |
|
183 inline void ConnectToReaderL( CScardSession* aSession, |
|
184 const RMessage2& aMessage ); |
|
185 |
|
186 /** |
|
187 * If a card is inserted / removed, we need to update the list |
|
188 * of cards in use. |
|
189 * @param aEvent Card event |
|
190 * @param aReaderID Reader ID |
|
191 * @return void |
|
192 */ |
|
193 inline void CardEvent( const TScardServiceStatus aEvent, |
|
194 const TReaderID aReaderID ); |
|
195 |
|
196 private: |
|
197 |
|
198 /** |
|
199 * C++ default constructor. |
|
200 */ |
|
201 CScardServer(); |
|
202 |
|
203 /** |
|
204 * By default Symbian 2nd phase constructor is private. |
|
205 */ |
|
206 void ConstructL(); |
|
207 |
|
208 private: // Data |
|
209 // Pointer to connection registry. Owned. |
|
210 CScardConnectionRegistry* iConnectionRegistry; |
|
211 // Pointer to access control registry. Owned. |
|
212 CScardAccessControlRegistry* iControlRegistry; |
|
213 // Pointer to notify registry. Owned. |
|
214 CScardNotifyRegistry* iNotifyRegistry; |
|
215 // Pointer to reader registry. Owned. |
|
216 CScardReaderRegistry* iReaderFactoryRegistry; |
|
217 // Pointer to resource registry. Owned. |
|
218 CScardResourceRegistry* iResourceRegistry; |
|
219 // Name of the server. Owned. |
|
220 HBufC* iName; |
|
221 }; |
|
222 |
|
223 #include "ScardServer.inl" |
|
224 |
|
225 #endif // CSCARDSERVER_H |
|
226 |
|
227 // End of File |