|
1 /* |
|
2 * Copyright (c) 2002-2009 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: Declaration of the CSecModUIModel class |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #ifndef CSECMODUIMODEL_H |
|
20 #define CSECMODUIMODEL_H |
|
21 |
|
22 // INCLUDES |
|
23 #include <e32base.h> |
|
24 #include <bamdesca.h> |
|
25 #include <ct/rmpointerarray.h> |
|
26 #include <f32file.h> |
|
27 |
|
28 #include <qlist.h> |
|
29 #include <qlabel.h> |
|
30 #include <qvector.h> |
|
31 #include <qpair.h> |
|
32 |
|
33 class QString; |
|
34 class HbListWidget; |
|
35 |
|
36 // CONSTANTS |
|
37 const TInt KMaxSettItemSize = 200; |
|
38 |
|
39 const TInt KPinGSettIndex = 0; |
|
40 const TInt KPinNrSettIndex = 1; |
|
41 |
|
42 const TUid KUidSecMod = { 0x101F8668 }; |
|
43 |
|
44 // Panic strings |
|
45 _LIT(KPanicNullPointer, "SecModUI: invalid pointer"); |
|
46 _LIT(KPanicIndexOutOfRange, "SecModUI: array indexed out of range"); |
|
47 |
|
48 // FORWARD DECLARATIONS |
|
49 class CUnifiedKeyStore; |
|
50 class MCTAuthenticationObject; |
|
51 class MCTAuthenticationObjectList; |
|
52 class CSecModUISyncWrapper; |
|
53 class MCTKeyStore; |
|
54 class MCTToken; |
|
55 |
|
56 class QString; |
|
57 |
|
58 // FUNCTION PROTOTYPES |
|
59 GLREF_C void Panic( TInt aPanic ); |
|
60 |
|
61 // CLASS DECLARATION |
|
62 |
|
63 /** |
|
64 * class CSecModUIModel |
|
65 * Model of the application |
|
66 * |
|
67 * @lib SecModUI.lib |
|
68 * @since Series 60 3.0 |
|
69 */ |
|
70 class CSecModUIModel : public CBase |
|
71 { |
|
72 public: // Constructors and destructLoadTokenLabelsLor |
|
73 |
|
74 /** |
|
75 * Two-phased constructor. |
|
76 */ |
|
77 static CSecModUIModel* NewL(); |
|
78 |
|
79 /** |
|
80 * Destructor. |
|
81 */ |
|
82 virtual ~CSecModUIModel(); |
|
83 |
|
84 public: // New functions |
|
85 /** |
|
86 * Initializes unified keystore |
|
87 */ |
|
88 void InitializeKeyStoreL(); |
|
89 |
|
90 /** |
|
91 * Retrieves the description and location of all tokens. |
|
92 * @return Map containing the label and the appripriate location. |
|
93 */ |
|
94 QMap<QString,QString> LoadTokenLabelsL(); |
|
95 |
|
96 /** |
|
97 * Shows error note if needed. |
|
98 * @param aError |
|
99 * @return void |
|
100 */ |
|
101 void ShowErrorNote(TInt aError) const; |
|
102 |
|
103 /** |
|
104 * Retrieves the appropriate token based on the index. |
|
105 * @param aTokenIndex Index of the token to be opened. |
|
106 * @return void |
|
107 */ |
|
108 void OpenTokenL(TInt aTokenIndex); |
|
109 |
|
110 /** |
|
111 * Initialize the auth objects and return the total count. |
|
112 * @param aItemArray contains localised stings |
|
113 * @return void |
|
114 */ |
|
115 TInt CheckCodeViewStringsL(); |
|
116 |
|
117 /** |
|
118 * Retrieves description of the token based on UID of the current active keystore. |
|
119 * @return Description |
|
120 */ |
|
121 QString TokenLabelForTitle() const; |
|
122 |
|
123 /** |
|
124 * Returns status of the selected auth object. |
|
125 * @param index |
|
126 * @return status |
|
127 */ |
|
128 TUint32 AuthStatus(TInt aIndex) const; |
|
129 |
|
130 /** |
|
131 * Returns status of the auth object based on its persistent properties set |
|
132 * by security module implementation. |
|
133 * @param aIndex Index of the authentication object |
|
134 * @param aShowBlockedNote If ETrue, shows code blocked if code is blocked. |
|
135 * @return status of the pin. |
|
136 */ |
|
137 QString PINStatus( TInt aIndex, TBool aShowBlockedNote ) const; |
|
138 |
|
139 /** |
|
140 * Checks whether the Pin is still available. |
|
141 * @param aIndex Index of the authentication object. |
|
142 * @return status |
|
143 */ |
|
144 TBool PinOpen(TInt aIndex) const; |
|
145 |
|
146 /** |
|
147 * Based on the property of auth object the pin can be |
|
148 * changed or unblocked. |
|
149 * @param aIndex Index of the auth object |
|
150 * @return ?description |
|
151 */ |
|
152 void ChangeOrUnblockPinL(TInt aIndex); |
|
153 |
|
154 /** |
|
155 * Changes the value of the PIN. |
|
156 * @param aIndex Index of the AO |
|
157 * @return void |
|
158 */ |
|
159 void ChangePinL(TInt aIndex); |
|
160 |
|
161 /** |
|
162 * Toggles the value of auth object if possible. |
|
163 * @param ?arg1 ?description |
|
164 * @return ?description |
|
165 */ |
|
166 TInt ChangeCodeRequest(TInt aIndex); |
|
167 |
|
168 /** |
|
169 * If the auth object is open then closes it. |
|
170 * @param aIndex Index of the AO to be closed. |
|
171 * @return void |
|
172 */ |
|
173 void CloseAuthObjL(TInt aIndex); |
|
174 |
|
175 /** |
|
176 * Unblocks PIN |
|
177 * @param aIndex Index of the AO |
|
178 * @return void |
|
179 */ |
|
180 void UnblockPinL(TInt aIndex); |
|
181 |
|
182 /** |
|
183 * Deletes key from the appropriate keystore. |
|
184 * @param aTokenIndex Index of the token to be deleted. |
|
185 * @return ETrue if keystore was deleted. |
|
186 */ |
|
187 void DeleteKeysL(TInt aTokenIndex); |
|
188 |
|
189 /** |
|
190 * Returns ETrue if PIN is changeable. |
|
191 * @param aIndex Index of the AO |
|
192 * @return ETrue / EFalse |
|
193 */ |
|
194 TBool PinChangeable(TInt aIndex) const; |
|
195 |
|
196 /** |
|
197 * Displays security module details dialog. |
|
198 * @param aTokenIndex Index of the token, which details are shown. |
|
199 * @return void |
|
200 */ |
|
201 QVector< QPair<QString,QString> > SecModDetailsL(TInt aTokenIndex); |
|
202 |
|
203 /** |
|
204 * Displays details dialog of the active security module . |
|
205 * @return void |
|
206 */ |
|
207 QVector< QPair<QString,QString> > GetSecModDetailsL(); |
|
208 |
|
209 /** |
|
210 * Appends the location of the keystore. |
|
211 * @return void |
|
212 */ |
|
213 void AppendLocation( QVector< QPair<QString,QString> >& aSecModDetails, |
|
214 TUid aLocUid, |
|
215 QString aCertDisplayDetails ); |
|
216 |
|
217 /** |
|
218 * Appends the value of a label if present otherwise appends empty descriotion. |
|
219 * @return void |
|
220 */ |
|
221 void AppendItem( QVector< QPair<QString,QString> >& aSecModDetails, |
|
222 QString aLabel, |
|
223 const TDesC& aValue, |
|
224 QString aNullDescription ); |
|
225 |
|
226 /** |
|
227 * Generate details of signing security module. |
|
228 * @return void |
|
229 */ |
|
230 void AppendPinNRs(QVector< QPair<QString,QString> >& aSecModDetails); |
|
231 |
|
232 QVector< QPair<QString, TUint32> > AuthDetails(); |
|
233 |
|
234 /** |
|
235 * Changes PIN-NR |
|
236 * @param aIndex Index of the AO |
|
237 * @return void |
|
238 */ |
|
239 void ChangePinNrL(TInt aIndex); |
|
240 |
|
241 /** |
|
242 * Unblocks PIN-NR |
|
243 * @param aIndex Index of the AO |
|
244 * @return void |
|
245 */ |
|
246 void UnblockPinNrL(TInt aIndex); |
|
247 |
|
248 /** |
|
249 * Retrieves the UID of the current active keystore. |
|
250 * @return uid |
|
251 */ |
|
252 TInt KeyStoreUID(); |
|
253 |
|
254 /** |
|
255 * Retrieves the auth object at the speficied index. |
|
256 * @return auth object |
|
257 */ |
|
258 const MCTAuthenticationObject& AuthObj(TInt aIndex); |
|
259 |
|
260 /** |
|
261 * Returns ETrue if PIN is unblockable. |
|
262 * @param aIndex Index of the AO |
|
263 * @return ETrue / EFalse |
|
264 */ |
|
265 TBool PinUnblockable(TInt aIndex) const; |
|
266 |
|
267 |
|
268 /** |
|
269 * Returns ETrue if PIN request can be disabled / enabled. |
|
270 * @param aIndex Index of the AO |
|
271 * @return ETrue / EFalse |
|
272 */ |
|
273 TBool PinRequestChangeable(TInt aIndex) const; |
|
274 |
|
275 /** |
|
276 * Returns ETrue if token is deletable. |
|
277 * @param aTokenIndex Index of the token to be deleted. |
|
278 * @return ETrue / EFalse |
|
279 */ |
|
280 TBool IsTokenDeletable(TInt aTokenIndex); |
|
281 |
|
282 |
|
283 private: |
|
284 |
|
285 /** |
|
286 * C++ default constructor. |
|
287 */ |
|
288 CSecModUIModel(); |
|
289 |
|
290 /** |
|
291 * By default Symbian 2nd phase constructor is private. |
|
292 */ |
|
293 void ConstructL(); |
|
294 |
|
295 void ResetAndDestroyCTObjects(); |
|
296 |
|
297 void ResetAndDestroyAOs(); |
|
298 |
|
299 void InitAuthObjectsL(); |
|
300 |
|
301 void ListAuthObjectsL(); |
|
302 |
|
303 void CreateSettingItem(const TDesC& aTitle, |
|
304 const TDesC& aValue, |
|
305 TDes& aItem) const; |
|
306 |
|
307 QString Location( TUid aUid ) const; |
|
308 |
|
309 void AppendPinNRsL( TDes& aMessage ) const; |
|
310 |
|
311 private: |
|
312 // DATA TYPES |
|
313 enum TSecModPanicCode |
|
314 { |
|
315 EPanicNullPointer, |
|
316 EPanicIndexOutOfRange |
|
317 }; |
|
318 |
|
319 private: // Data |
|
320 // Resource file offsets |
|
321 TInt iResourceFileOffset; |
|
322 TInt iResourceFileOffset2; |
|
323 TInt iResourceFileOffset3; |
|
324 |
|
325 CSecModUISyncWrapper* iWrapper; // owned |
|
326 RFs iRfs; |
|
327 |
|
328 /** |
|
329 * Crypto Token objects |
|
330 */ |
|
331 CUnifiedKeyStore* iUnifiedKeyStore; // owned |
|
332 MCTKeyStore* iKeyStore; // not owned |
|
333 MCTAuthenticationObjectList* iAOList; // owned, items not owned |
|
334 RMPointerArray<MCTAuthenticationObject> iAOArray; // items not owned |
|
335 |
|
336 RMPointerArray<MCTKeyStore> iAOKeyStores; // items not owned |
|
337 }; |
|
338 |
|
339 #endif // CSECMODUIMODEL_H |
|
340 |
|
341 // End of File |