|
1 /* |
|
2 * Copyright (c) 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: This file contains the header file of the CAtsLogger |
|
15 * class. |
|
16 * |
|
17 */ |
|
18 #include "TestSecurityInstUIHandler.h" |
|
19 |
|
20 /** |
|
21 * Creates a new Instance of the CTestSecurityInstUIHandler and calls the |
|
22 * appropriate ConsturctL |
|
23 * @param None |
|
24 * @return CTestSecurityInstUIHandler* |
|
25 * |
|
26 */ |
|
27 CTestSecurityInstUIHandler* CTestSecurityInstUIHandler::NewL() |
|
28 { |
|
29 CTestSecurityInstUIHandler* self=new(ELeave) CTestSecurityInstUIHandler(); |
|
30 CleanupStack::PushL(self); |
|
31 self->ConstructL(); |
|
32 CleanupStack::Pop(); |
|
33 return self; |
|
34 } |
|
35 |
|
36 /** |
|
37 * Constructor for CTestSecurityInstUIHandler |
|
38 */ |
|
39 CTestSecurityInstUIHandler::CTestSecurityInstUIHandler() |
|
40 : iDispInstall(TRUE), |
|
41 iDispGrantCapabilities(TRUE), |
|
42 iDispUnInstall(TRUE), |
|
43 iDispLanguage(0), |
|
44 iDispDialect(0), |
|
45 iDispDrive('C'), |
|
46 iDispUpgrade(TRUE), |
|
47 iDispDependencyBreak(TRUE), |
|
48 iDispQuestion(TRUE), |
|
49 iDispSecurityWarning(TRUE), |
|
50 iDispRevocationQuery(TRUE), |
|
51 iDispApplicationInUse(TRUE), |
|
52 iDispTextDialog(TRUE), |
|
53 iDispOptions(0), |
|
54 iAppUID(0), |
|
55 iErrCode(KErrNothing) |
|
56 { |
|
57 } |
|
58 |
|
59 /** |
|
60 * Second stage constructor for CTestSecurityInstUIHandler |
|
61 */ |
|
62 void CTestSecurityInstUIHandler::ConstructL() |
|
63 { |
|
64 } |
|
65 |
|
66 /** |
|
67 * Destructor for CTestSecurityInstUIHandler |
|
68 */ |
|
69 CTestSecurityInstUIHandler::~CTestSecurityInstUIHandler() |
|
70 { |
|
71 iDispInstall = FALSE; |
|
72 iDispGrantCapabilities = FALSE; |
|
73 iDispUnInstall = FALSE; |
|
74 iDispLanguage = 0; |
|
75 iDispDialect = 0; |
|
76 iDispDrive = 'C'; |
|
77 iDispUpgrade = FALSE; |
|
78 iDispDependencyBreak = FALSE; |
|
79 iDispQuestion = FALSE; |
|
80 iDispSecurityWarning = FALSE; |
|
81 iDispRevocationQuery = FALSE; |
|
82 iDispApplicationInUse = FALSE; |
|
83 iDispTextDialog = FALSE; |
|
84 iDispOptions = 0; |
|
85 iAppUID = 0; |
|
86 |
|
87 iErrCode = KErrNothing; |
|
88 } |
|
89 |
|
90 /** |
|
91 * Displays a dialog at the beginning of an installation with details about the SISX package |
|
92 * being installed. This dialog must be shown in TrustedUI mode. |
|
93 * |
|
94 * @param aAppInfo Information about the application. |
|
95 * @param aLogo The logo data in the SISX file. If no logo is present it will be NULL. |
|
96 * @param aCertificates An array of end entity certificates, one for each chain in the SISX file. |
|
97 * If the SISX file is unsigned this array will have zero length. |
|
98 * |
|
99 * @note Trusted UI |
|
100 * |
|
101 * @return ETrue if the user pressed the Yes button to continue the install, |
|
102 * EFalse if the user pressed the No button, aborting the installation. |
|
103 */ |
|
104 TBool CTestSecurityInstUIHandler::DisplayInstallL(const CAppInfo& /*aAppInfo*/, |
|
105 const CApaMaskedBitmap* /*aLogo*/, |
|
106 const RPointerArray< CCertificateInfo >& /*aCertificates*/) |
|
107 { |
|
108 return iDispInstall; |
|
109 } |
|
110 |
|
111 /** |
|
112 * Displays a dialog requesting that the user grants these capabilities to the SISX package |
|
113 * being installed. This dialog must be shown in TrustedUI mode. |
|
114 * |
|
115 * @param aAppInfo Information about the application. |
|
116 * @param aCapabilitySet The capabilities requested by the SISX package. |
|
117 * |
|
118 * @note Trusted UI |
|
119 * |
|
120 * @return ETrue to continue the installation, or EFalse to abort the installation. |
|
121 */ |
|
122 TBool CTestSecurityInstUIHandler::DisplayGrantCapabilitiesL(const CAppInfo& /*aAppInfo*/, |
|
123 const TCapabilitySet& /*aCapabilitySet*/) |
|
124 { |
|
125 return iDispGrantCapabilities; |
|
126 } |
|
127 |
|
128 /** |
|
129 * Requests preferred language and dialect information from the UI. |
|
130 * |
|
131 * @param aAppInfo Information about the application. |
|
132 * @param aLanguages Array of languages supported by the SIS file. |
|
133 * |
|
134 * @return Must return index in the passed array that corresponds to the user's selected |
|
135 * preferred language. If out-of-bounds value is returned, the engine will abort |
|
136 * installation. |
|
137 */ |
|
138 TInt CTestSecurityInstUIHandler::DisplayLanguageL(const CAppInfo& /*aAppInfo*/, |
|
139 const RArray<TLanguage>& aLanguages) |
|
140 { |
|
141 TInt languageCode = iDispLanguage; |
|
142 TInt index; |
|
143 |
|
144 // Return the index value in the array which matches the language code |
|
145 // obtained from the ini file. |
|
146 for (index=0; index<aLanguages.Count(); index++) |
|
147 { |
|
148 if (aLanguages[index] == (TLanguage)languageCode) |
|
149 { |
|
150 return index; |
|
151 } |
|
152 } |
|
153 // Language Code did not match - error |
|
154 iErrCode = KErrLanguage; |
|
155 |
|
156 return languageCode; |
|
157 } |
|
158 |
|
159 /** |
|
160 * Requests the drive to install the package on, from the UI. |
|
161 * |
|
162 * @param aAppInfo Information about the application. |
|
163 * @param aSize Total size of the files that will be installed on the configurable drive. |
|
164 * @param aDriveLetters Array of drive letters on which the package can be installed. |
|
165 * @param aDriveSpaces Array of space free (in bytes) on each of the drives in the aDriveLetters array. |
|
166 * |
|
167 * @return An index in the drive array. If the index is out of range the engine will abort |
|
168 * the installation. |
|
169 */ |
|
170 TInt CTestSecurityInstUIHandler::DisplayDriveL(const CAppInfo& /*aAppInfo*/, |
|
171 TInt64 /*aSize*/, |
|
172 const RArray<TChar>& aDriveLetters, |
|
173 const RArray<TInt64>& /*aDriveSpaces*/) |
|
174 { |
|
175 TInt index; |
|
176 TInt driveIndex=0; |
|
177 for (index=0; index < aDriveLetters.Count(); index++) |
|
178 { |
|
179 if (aDriveLetters[index] == iDispDrive) |
|
180 { |
|
181 driveIndex = index; |
|
182 break; |
|
183 } |
|
184 } |
|
185 |
|
186 if (index == aDriveLetters.Count()) // Out of range error |
|
187 { |
|
188 iErrCode = KErrDrive; |
|
189 driveIndex = index; |
|
190 } |
|
191 return driveIndex; |
|
192 } |
|
193 |
|
194 /** |
|
195 * Displays a dialog asking whether we want to upgrade an application present on the device. |
|
196 * |
|
197 * @param aAppInfo Information about the application being installed. |
|
198 * @param aExistingAppInfo Information about the existing application. |
|
199 * |
|
200 * @return ETrue if the user pressed the Yes button, |
|
201 * EFalse if the user pressed the No button. |
|
202 */ |
|
203 TBool CTestSecurityInstUIHandler::DisplayUpgradeL(const CAppInfo& /*aAppInfo*/, |
|
204 const CAppInfo& /*aExistingAppInfo*/) |
|
205 { |
|
206 return iDispUpgrade; |
|
207 } |
|
208 |
|
209 /** |
|
210 * Displays a dialog box asking which options the user wishes to install. |
|
211 * |
|
212 * @param aAppInfo Information about the application. |
|
213 * @param aOptions An array of option names. |
|
214 * @param aSelections An array of booleans, corresponding to the aOptions array. |
|
215 * |
|
216 * @return ETrue on success, EFalse on error. |
|
217 */ |
|
218 TBool CTestSecurityInstUIHandler::DisplayOptionsL(const CAppInfo& /*aAppInfo*/, |
|
219 const RPointerArray<TDesC>& aOptions, |
|
220 RArray<TBool>& aSelections) |
|
221 { |
|
222 |
|
223 TInt index; |
|
224 TBool setFlag = EFalse; |
|
225 |
|
226 for (index=0; index<aOptions.Count();index++) |
|
227 { |
|
228 if (index == iDispOptions) |
|
229 { |
|
230 aSelections[index] = ETrue; |
|
231 setFlag = ETrue; |
|
232 } |
|
233 else |
|
234 { |
|
235 aSelections[index] = EFalse; |
|
236 } |
|
237 } |
|
238 |
|
239 if (setFlag == (TBool)ETrue) |
|
240 { |
|
241 return ETrue; |
|
242 } |
|
243 else |
|
244 { |
|
245 iErrCode = KErrOptions; |
|
246 return EFalse; |
|
247 } |
|
248 } |
|
249 |
|
250 /** |
|
251 * Informs the UI of events occurring during installation. |
|
252 * |
|
253 * @param aEvent The event which has occurred. |
|
254 * @param aValue The value associated with the event if applicable. |
|
255 * @param aDes A descriptor associated with the event if applicable. |
|
256 * @return TBool Always returns ETrue to indicate the Install Event is always handled |
|
257 */ |
|
258 TBool CTestSecurityInstUIHandler::HandleInstallEventL(const CAppInfo& /*aAppInfo*/, |
|
259 TInstallEvent aEvent, |
|
260 TInt /*aValue=0*/, |
|
261 const TDesC& /*aDes=KNullDesC*/) |
|
262 { |
|
263 switch (aEvent) |
|
264 { |
|
265 case EEventSetProgressBarFinalValue: |
|
266 break; |
|
267 case EEventUpdateProgressBar: |
|
268 break; |
|
269 case EEventAbortedInstall: |
|
270 iErrCode = KErrAbortInstall; |
|
271 break; |
|
272 case EEventCompletedInstall: |
|
273 break; |
|
274 case EEventCompletedUnInstall: |
|
275 break; |
|
276 case EEventAbortedUnInstall: |
|
277 iErrCode = KErrAbortUnInstall; |
|
278 break; |
|
279 case EEventCompletedNoMessage: |
|
280 break; |
|
281 case EEventLeave: |
|
282 iErrCode = KErrLeave; |
|
283 break; |
|
284 case EEventOcspCheckEnd: |
|
285 break; |
|
286 default: |
|
287 break; |
|
288 } |
|
289 return ETrue; |
|
290 } |
|
291 |
|
292 /** |
|
293 * Informs the UI of cancellable events occurring during installation. |
|
294 * |
|
295 * @param aEvent The event which has occurred. |
|
296 * @param aCancelHandler This mix-in is used to inform Software Install that the user has |
|
297 * pressed the cancel button on the dialog. |
|
298 * @param aValue The value associated with the event if applicable. |
|
299 * @param aDes A descriptor associated with the event if applicable. |
|
300 */ |
|
301 void CTestSecurityInstUIHandler::HandleCancellableInstallEventL(const CAppInfo& /*aAppInfo*/, |
|
302 TInstallCancellableEvent aEvent, |
|
303 MCancelHandler& /*aCancelHandler*/, |
|
304 TInt /*aValue=0*/, |
|
305 const TDesC& /*aDes=KNullDesC*/) |
|
306 { |
|
307 switch (aEvent) |
|
308 { |
|
309 case EEventRemovingFiles: |
|
310 break; |
|
311 case EEventShuttingDownApps: |
|
312 break; |
|
313 case EEventCopyingFiles: |
|
314 break; |
|
315 case EEventOcspCheckStart: |
|
316 break; |
|
317 default: |
|
318 break; |
|
319 } |
|
320 } |
|
321 |
|
322 /** |
|
323 * Displays a dialog indicating that the package is unsigned, or that signature validation has failed. |
|
324 * |
|
325 * @param aAppInfo Information about the application. |
|
326 * @param aSigValidationResult The result of signature validation. |
|
327 * @param aPkixResult Results of a validation of the PKIX certificate chain. |
|
328 * Note that is can be NULL, in this case no validation results are available. |
|
329 * @param aCertificates An array containing information about the certificates in the chain. |
|
330 * @param aInstallAnyway ETrue if installation is allowed to continue. |
|
331 * |
|
332 * @return ETrue to continue the installation, EFalse to abort. |
|
333 */ |
|
334 TBool CTestSecurityInstUIHandler::DisplaySecurityWarningL(const CAppInfo& /*aAppInfo*/, |
|
335 Swi::TSignatureValidationResult /*aSigValidationResult*/, |
|
336 RPointerArray<CPKIXValidationResultBase>& /*aPkixResults*/, |
|
337 RPointerArray<CCertificateInfo>& /*aCertificates*/, |
|
338 TBool /*aInstallAnyway*/) |
|
339 { |
|
340 return ETrue; |
|
341 } |
|
342 |
|
343 /** |
|
344 * Displays a dialog indicating that there was an error carrying out online certificate status checking. |
|
345 * |
|
346 * @param aMessage The error which occurred during online certificate status checking |
|
347 * @param aOutcome The outcome of the OCSP check. If no outcome can be given, it will be NULL. |
|
348 * @param aWarningOnly ETrue if the installation is allowed to continue after a warning, EFalse otherwise. |
|
349 * |
|
350 * @return ETrue on success, EFalse on error. |
|
351 */ |
|
352 TBool CTestSecurityInstUIHandler::DisplayOcspResultL(const CAppInfo& /*aAppInfo*/, |
|
353 TRevocationDialogMessage /*aMessage*/, |
|
354 RPointerArray<TOCSPOutcome>& /*aOutcomes*/, |
|
355 RPointerArray<CCertificateInfo>& /*aCertificates*/, |
|
356 TBool aWarningOnly) |
|
357 { |
|
358 return aWarningOnly; |
|
359 } |
|
360 |
|
361 /** |
|
362 * Used to inform the user the installation they are attempting is trying to overwrite |
|
363 * a file that does not belong to it. Following this message installation is aborted. |
|
364 * |
|
365 * @param aAppInfo Information about the application. |
|
366 * @param aInstalledAppInfo Information about the application that owns the file in question. |
|
367 * @param aFileName The filename of the file in question |
|
368 */ |
|
369 void CTestSecurityInstUIHandler::DisplayCannotOverwriteFileL(const CAppInfo& /*aAppInfo*/, |
|
370 const CAppInfo& /*aInstalledAppInfo*/, |
|
371 const TDesC& /*aFileName*/) |
|
372 { |
|
373 iErrCode = KErrCannotOverwriteFile; |
|
374 } |
|
375 |
|
376 /** |
|
377 * Displays a dialog at the start of the uninstallation with information about the application |
|
378 * to be uninstalled. The user may cancel the uninstallation at this stage. This dialog must |
|
379 * be shown in TrustedUI mode. |
|
380 * |
|
381 * @param aAppInfo Information about the application. |
|
382 * |
|
383 * @note Trusted UI |
|
384 * |
|
385 * @return ETrue to continue the uninstallation, or EFalse to abort the uninstallation. |
|
386 */ |
|
387 TBool CTestSecurityInstUIHandler::DisplayUninstallL(const CAppInfo& /*aAppInfo*/) |
|
388 { |
|
389 return iDispUnInstall; |
|
390 } |
|
391 |
|
392 /** |
|
393 * Displays a dialog containing text. This dialog has only a Continue button if aOption is |
|
394 * EInstFileTextOptionContinue, or Yes and No buttons otherwise. |
|
395 * |
|
396 * @param aAppInfo Information about the application. |
|
397 * @param aOption The type of dialog box to display. |
|
398 * @param aText The text to display |
|
399 * |
|
400 * @return ETrue if the user wants to go forward, EFalse otherwise. |
|
401 */ |
|
402 TBool CTestSecurityInstUIHandler::DisplayTextL(const CAppInfo& /*aAppInfo*/, |
|
403 TFileTextOption /*aOption*/, |
|
404 const TDesC& /*aText*/) |
|
405 { |
|
406 return iDispTextDialog; |
|
407 } |
|
408 |
|
409 /** |
|
410 * Displays a dialog showing an error message. |
|
411 * |
|
412 * @param aAppInfo Information about the application. |
|
413 * @param aType The error message to display. |
|
414 * @param aParam An error specific parameter. |
|
415 */ |
|
416 void CTestSecurityInstUIHandler::DisplayErrorL(const CAppInfo& /*aAppInfo*/, |
|
417 TErrorDialog /*aType*/, |
|
418 const TDesC& /*aParam*/) |
|
419 { |
|
420 iErrCode = KErrError; |
|
421 } |
|
422 |
|
423 /** |
|
424 * Displays a dialog indicating that a component which is being uninstalled is a dependency |
|
425 * of another component installed. |
|
426 * |
|
427 * @param aAppInfo Information about the application. |
|
428 * @param aComponents An array of components which depend on components of the application |
|
429 * |
|
430 * @return ETrue to continue the uninstallation, EFalse to abort. |
|
431 */ |
|
432 TBool CTestSecurityInstUIHandler::DisplayDependencyBreakL(const CAppInfo& /*aAppInfo*/, |
|
433 const RPointerArray<TDesC>& /*aComponents*/) |
|
434 { |
|
435 return iDispDependencyBreak; |
|
436 } |
|
437 |
|
438 /** |
|
439 * Informs user that the applications are in use during an uninstallation. |
|
440 * Return ETrue if the user wishes to continue the removal process and |
|
441 * close the applications anyway |
|
442 * |
|
443 * @param aAppNames An array containing the name of the application in use. |
|
444 * |
|
445 * @return ETrue if the user wishes to continue with removal. |
|
446 */ |
|
447 TBool CTestSecurityInstUIHandler::DisplayApplicationsInUseL(const CAppInfo& /*aAppInfo*/, |
|
448 const RPointerArray<TDesC>& /*aAppNames*/) |
|
449 { |
|
450 return iDispApplicationInUse; |
|
451 } |
|
452 |
|
453 /** |
|
454 * Displays a generic question dialog with a Yes/No answer. |
|
455 * |
|
456 * @param aAppInfo Information about the application. |
|
457 * @param aQuestion The question to ask. |
|
458 * @param aDes A descriptor associated with the question if applicable. |
|
459 * |
|
460 * @return ETrue if the user pressed the Yes button, |
|
461 * EFalse if the user pressed the No button. |
|
462 */ |
|
463 TBool CTestSecurityInstUIHandler::DisplayQuestionL(const CAppInfo& /*aAppInfo*/, |
|
464 TQuestionDialog aQuestion, const TDesC& /*aDes=KNullDesC*/) |
|
465 { |
|
466 |
|
467 switch(aQuestion) |
|
468 { |
|
469 case EQuestionIncompatible: |
|
470 break; |
|
471 default: |
|
472 break; |
|
473 } |
|
474 |
|
475 return iDispQuestion; |
|
476 } |
|
477 |
|
478 TBool CTestSecurityInstUIHandler::DisplayMissingDependencyL(const CAppInfo& /*aAppInfo*/, |
|
479 const TDesC& /*aDependencyName*/,TVersion /*aWantedVersionFrom*/, |
|
480 TVersion /*aWantedVersionTo*/,TVersion /*aInstalledVersion*/) |
|
481 { |
|
482 return ETrue; |
|
483 } |
|
484 |