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