1 /* |
|
2 * Copyright (c) 2010 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: Base class for SISX SIF plugin UI handlers. |
|
15 * |
|
16 */ |
|
17 |
|
18 #include "sisxsifpluginuihandlerbase.h" // CSisxSifPluginUiHandlerBase |
|
19 #include "sisxsifplugininstallparams.h" // CSisxSifPluginInstallParams |
|
20 #include "sisxsifpluginerrorhandler.h" // CSisxSifPluginErrorHandler |
|
21 #include "sisxsifcleanuputils.h" // CleanupResetAndDestroyPushL |
|
22 #include <centralrepository.h> // CRepository |
|
23 #include <SWInstallerInternalCRKeys.h> // KCRUidSWInstallerSettings |
|
24 #include <hb/hbwidgets/hbdevicemessageboxsymbian.h> // CHbDeviceMessageBoxSymbian |
|
25 #include <usif/scr/screntries.h> // CComponentEntry |
|
26 |
|
27 using namespace Usif; |
|
28 |
|
29 |
|
30 // ======== MEMBER FUNCTIONS ======== |
|
31 |
|
32 // --------------------------------------------------------------------------- |
|
33 // CSisxSifPluginUiHandlerBase::CSisxSifPluginUiHandlerBase() |
|
34 // --------------------------------------------------------------------------- |
|
35 // |
|
36 CSisxSifPluginUiHandlerBase::CSisxSifPluginUiHandlerBase( RFs& aFs, |
|
37 CSisxSifPluginErrorHandler& aErrorHandler ) : iFs( aFs ), |
|
38 iErrorHandler( aErrorHandler ) |
|
39 { |
|
40 } |
|
41 |
|
42 // --------------------------------------------------------------------------- |
|
43 // CSisxSifPluginUiHandlerBase::~CSisxSifPluginUiHandlerBase() |
|
44 // --------------------------------------------------------------------------- |
|
45 // |
|
46 CSisxSifPluginUiHandlerBase::~CSisxSifPluginUiHandlerBase() |
|
47 { |
|
48 delete iInstallParams; |
|
49 delete iPublishSifOperationInfo; |
|
50 delete iGlobalComponentId; |
|
51 } |
|
52 |
|
53 // --------------------------------------------------------------------------- |
|
54 // CSisxSifPluginUiHandlerBase::SetInstallParamsL() |
|
55 // --------------------------------------------------------------------------- |
|
56 // |
|
57 void CSisxSifPluginUiHandlerBase::SetInstallParamsL( |
|
58 const CSisxSifPluginInstallParams& aInstallParams ) |
|
59 { |
|
60 if( iInstallParams ) |
|
61 { |
|
62 delete iInstallParams; |
|
63 iInstallParams = NULL; |
|
64 } |
|
65 iInstallParams = CSisxSifPluginInstallParams::NewL( aInstallParams ); |
|
66 } |
|
67 |
|
68 // --------------------------------------------------------------------------- |
|
69 // CSisxSifPluginUiHandlerBase::SetMaxInstalledSize() |
|
70 // --------------------------------------------------------------------------- |
|
71 // |
|
72 void CSisxSifPluginUiHandlerBase::SetMaxInstalledSize( TInt aSize ) |
|
73 { |
|
74 iMaxInstalledSize = aSize; |
|
75 } |
|
76 |
|
77 // --------------------------------------------------------------------------- |
|
78 // CSisxSifPluginUiHandlerBase::SetDriveSelectionRequired() |
|
79 // --------------------------------------------------------------------------- |
|
80 // |
|
81 void CSisxSifPluginUiHandlerBase::SetDriveSelectionRequired( TBool aIsRequired ) |
|
82 { |
|
83 iIsDriveSelectionRequired = aIsRequired; |
|
84 } |
|
85 |
|
86 // --------------------------------------------------------------------------- |
|
87 // CSisxSifPluginUiHandlerBase::IsOcspMandatoryL() |
|
88 // --------------------------------------------------------------------------- |
|
89 // |
|
90 TBool CSisxSifPluginUiHandlerBase::IsOcspMandatoryL() const |
|
91 { |
|
92 CRepository* cenRep = CRepository::NewLC( KCRUidSWInstallerSettings ); |
|
93 TInt ocspProcedure = ESWInstallerOcspProcedureOff; |
|
94 User::LeaveIfError( cenRep->Get( KSWInstallerOcspProcedure, ocspProcedure ) ); |
|
95 CleanupStack::PopAndDestroy( cenRep ); |
|
96 return ( ocspProcedure == ESWInstallerOcspProcedureMust ); |
|
97 } |
|
98 |
|
99 // --------------------------------------------------------------------------- |
|
100 // CSisxSifPluginUiHandlerBase::PublishStartL() |
|
101 // --------------------------------------------------------------------------- |
|
102 // |
|
103 void CSisxSifPluginUiHandlerBase::PublishStartL( const CComponentInfo::CNode& aRootNode ) |
|
104 { |
|
105 RPointerArray<HBufC> appNames; |
|
106 CleanupResetAndDestroyPushL( appNames ); |
|
107 RPointerArray<HBufC> appIcons; |
|
108 CleanupResetAndDestroyPushL( appIcons ); |
|
109 |
|
110 const RPointerArray<CComponentInfo::CApplicationInfo>& apps = aRootNode.Applications(); |
|
111 for( TInt index = 0; index < apps.Count(); ++index ) |
|
112 { |
|
113 HBufC* name = apps[ index ]->Name().AllocLC(); |
|
114 appNames.AppendL( name ); |
|
115 CleanupStack::Pop( name ); |
|
116 HBufC* icon = apps[ index ]->IconFileName().AllocLC(); |
|
117 appIcons.AppendL( icon ); |
|
118 CleanupStack::Pop( icon ); |
|
119 } |
|
120 |
|
121 if( iGlobalComponentId ) |
|
122 { |
|
123 delete iGlobalComponentId; |
|
124 iGlobalComponentId = NULL; |
|
125 } |
|
126 iGlobalComponentId = aRootNode.GlobalComponentId().AllocL(); |
|
127 |
|
128 CSifOperationStartData* data = CSifOperationStartData::NewLC( *iGlobalComponentId, |
|
129 aRootNode.ComponentName(), appNames, appIcons, aRootNode.MaxInstalledSize(), |
|
130 KNullDesC, KNullDesC, aRootNode.SoftwareTypeName(), iOperationPhase ); |
|
131 |
|
132 if( !iPublishSifOperationInfo ) |
|
133 { |
|
134 iPublishSifOperationInfo = CPublishSifOperationInfo::NewL(); |
|
135 } |
|
136 iPublishSifOperationInfo->PublishStartL( *data ); |
|
137 |
|
138 CleanupStack::PopAndDestroy( 3, &appNames ); // data, appIcons, appNames |
|
139 } |
|
140 |
|
141 // --------------------------------------------------------------------------- |
|
142 // CSisxSifPluginUiHandlerBase::PublishStartL() |
|
143 // --------------------------------------------------------------------------- |
|
144 // |
|
145 void CSisxSifPluginUiHandlerBase::PublishStartL( const CComponentEntry& aEntry ) |
|
146 { |
|
147 RPointerArray<HBufC> appNames; |
|
148 CleanupResetAndDestroyPushL( appNames ); |
|
149 RPointerArray<HBufC> appIcons; |
|
150 CleanupResetAndDestroyPushL( appIcons ); |
|
151 |
|
152 if( iGlobalComponentId ) |
|
153 { |
|
154 delete iGlobalComponentId; |
|
155 iGlobalComponentId = NULL; |
|
156 } |
|
157 iGlobalComponentId = aEntry.GlobalId().AllocL(); |
|
158 |
|
159 CSifOperationStartData* data = CSifOperationStartData::NewLC( *iGlobalComponentId, |
|
160 aEntry.Name(), appNames, appIcons, aEntry.ComponentSize(), |
|
161 KNullDesC, KNullDesC, aEntry.SoftwareType(), iOperationPhase ); |
|
162 |
|
163 if( !iPublishSifOperationInfo ) |
|
164 { |
|
165 iPublishSifOperationInfo = CPublishSifOperationInfo::NewL(); |
|
166 } |
|
167 iPublishSifOperationInfo->PublishStartL( *data ); |
|
168 |
|
169 CleanupStack::PopAndDestroy( 3, &appNames ); // data, appIcons, appNames |
|
170 } |
|
171 |
|
172 // --------------------------------------------------------------------------- |
|
173 // CSisxSifPluginUiHandlerBase::PublishProgressL() |
|
174 // --------------------------------------------------------------------------- |
|
175 // |
|
176 void CSisxSifPluginUiHandlerBase::PublishProgressL( TSifOperationSubPhase aSubPhase ) |
|
177 { |
|
178 User::LeaveIfNull( iPublishSifOperationInfo ); |
|
179 CSifOperationProgressData* data = CSifOperationProgressData::NewLC( *iGlobalComponentId, |
|
180 iOperationPhase, aSubPhase, iProgressBarCurrentValue, iProgressBarFinalValue ); |
|
181 iPublishSifOperationInfo->PublishProgressL( *data ); |
|
182 CleanupStack::PopAndDestroy( data ); |
|
183 } |
|
184 |
|
185 // --------------------------------------------------------------------------- |
|
186 // CSisxSifPluginUiHandlerBase::PublishCompletionL() |
|
187 // --------------------------------------------------------------------------- |
|
188 // |
|
189 void CSisxSifPluginUiHandlerBase::PublishCompletionL() |
|
190 { |
|
191 User::LeaveIfNull( iPublishSifOperationInfo ); |
|
192 CSifOperationEndData* data = CSifOperationEndData::NewLC( *iGlobalComponentId, |
|
193 iErrorHandler.ErrorCategory(), iErrorHandler.ErrorCode(), |
|
194 iErrorHandler.ErrorMessage(), iErrorHandler.ErrorMessageDetails() ); |
|
195 iPublishSifOperationInfo->PublishCompletionL( *data ); |
|
196 CleanupStack::PopAndDestroy( data ); |
|
197 } |
|
198 |
|
199 // --------------------------------------------------------------------------- |
|
200 // CSisxSifPluginUiHandlerBase::SetErrorL() |
|
201 // --------------------------------------------------------------------------- |
|
202 // |
|
203 void CSisxSifPluginUiHandlerBase::SetErrorL( TInt aErrorCode, TInt aExtErrorCode ) |
|
204 { |
|
205 iErrorHandler.SetErrorCode( aErrorCode ); |
|
206 iErrorHandler.SetExtendedErrorCode( aExtErrorCode ); |
|
207 |
|
208 // TODO: localized UI strings needed |
|
209 switch( iErrorHandler.ErrorCategory() ) |
|
210 { |
|
211 case ELowMemory: |
|
212 // txt_error_info_there_is_not_enough_memory_currentl |
|
213 iErrorHandler.SetErrorMessage( _L("There is not enough memory currently.") ); |
|
214 break; |
|
215 case ELowDiskSpace: |
|
216 // txt_error_info_there_is_not_enough_space_currently |
|
217 iErrorHandler.SetErrorMessage( _L("There is not enough space currently in this drive.") ); |
|
218 break; |
|
219 case ENetworkUnavailable: |
|
220 // txt_error_info_network_is_unavailable_currently |
|
221 iErrorHandler.SetErrorMessage( _L("Network is unavailable currently.") ); |
|
222 break; |
|
223 case EInstallerBusy: |
|
224 // txt_error_info_installer_is_busy_currently |
|
225 iErrorHandler.SetErrorMessage( _L("Installer is busy currently.") ); |
|
226 break; |
|
227 case ECorruptedPackage: |
|
228 // txt_error_info_installation_package_is_corrupted |
|
229 iErrorHandler.SetErrorMessage( _L("Installation package is corrupted. You may want to try again.") ); |
|
230 break; |
|
231 case EApplicationNotCompatible: |
|
232 // txt_error_info_application_is_not_compatible_with |
|
233 iErrorHandler.SetErrorMessage( _L("Application is not compatible with this device.") ); |
|
234 break; |
|
235 case ESecurityError: |
|
236 // txt_error_info_there_is_a_security_issue_with_this |
|
237 iErrorHandler.SetErrorMessage( _L("There is a security issue with this application.") ); |
|
238 break; |
|
239 case EUnexpectedError: |
|
240 case EUnknown: |
|
241 // txt_error_info_an_unexpected_error_occurred |
|
242 iErrorHandler.SetErrorMessage( _L("An unexpected error occurred.") ); |
|
243 break; |
|
244 case EUserCancelled: |
|
245 if( iOperationPhase == EInstalling ) |
|
246 { |
|
247 // txt_error_info_application_not_installed |
|
248 iErrorHandler.SetErrorMessage( _L("Application not installed.") ); |
|
249 } |
|
250 else |
|
251 { |
|
252 // txt_error_info_application_not_deleted |
|
253 iErrorHandler.SetErrorMessage( _L("Application not deleted. ") ); |
|
254 } |
|
255 break; |
|
256 case EUninstallationBlocked: |
|
257 // txt_error_info_application_cannot_be_deleted |
|
258 iErrorHandler.SetErrorMessage( _L("Application cannot be deleted.") ); |
|
259 break; |
|
260 case ENone: |
|
261 default: |
|
262 break; |
|
263 } |
|
264 } |
|
265 |
|
266 // --------------------------------------------------------------------------- |
|
267 // CSisxSifPluginUiHandlerBase::SetErrorL() |
|
268 // --------------------------------------------------------------------------- |
|
269 // |
|
270 void CSisxSifPluginUiHandlerBase::SetErrorL( TInt aErrorCode, TInt aExtErrorCode, |
|
271 const TDesC& aErrMsgDetails ) |
|
272 { |
|
273 SetErrorL( aErrorCode, aExtErrorCode ); |
|
274 iErrorHandler.SetErrorMessageDetails( aErrMsgDetails ); |
|
275 } |
|
276 |
|
277 // --------------------------------------------------------------------------- |
|
278 // CSisxSifPluginUiHandlerBase::SetErrorSwiErrorL() |
|
279 // --------------------------------------------------------------------------- |
|
280 // |
|
281 void CSisxSifPluginUiHandlerBase::SetErrorSwiErrorL( Swi::TErrorDialog aType, |
|
282 const TDesC& /*aParam*/ ) |
|
283 { |
|
284 // TODO: localised detailed error messages |
|
285 // TODO: append aParam when message supports parameters |
|
286 TBuf<512> details; |
|
287 switch( aType ) |
|
288 { |
|
289 case Swi::EUiAlreadyInRom: |
|
290 details.Copy(_L("EUiAlreadyInRom")); |
|
291 break; |
|
292 case Swi::EUiMissingDependency: |
|
293 details.Copy(_L("EUiMissingDependency")); |
|
294 break; |
|
295 case Swi::EUiRequireVer: |
|
296 details.Copy(_L("EUiRequireVer")); |
|
297 break; |
|
298 case Swi::EUiRequireVerOrGreater: |
|
299 details.Copy(_L("EUiRequireVerOrGreater")); |
|
300 break; |
|
301 case Swi::EUiFileCorrupt: |
|
302 details.Copy(_L("EUiFileCorrupt")); |
|
303 break; |
|
304 case Swi::EUiDiskNotPresent: |
|
305 details.Copy(_L("EUiDiskNotPresent")); |
|
306 break; |
|
307 case Swi::EUiCannotRead: |
|
308 details.Copy(_L("EUiCannotRead")); |
|
309 break; |
|
310 case Swi::EUiCannotDelete: |
|
311 details.Copy(_L("EUiCannotDelete")); |
|
312 break; |
|
313 case Swi::EUiInvalidFileName: |
|
314 details.Copy(_L("EUiInvalidFileName")); |
|
315 break; |
|
316 case Swi::EUiFileNotFound: |
|
317 details.Copy(_L("EUiFileNotFound")); |
|
318 break; |
|
319 case Swi::EUiInsufficientSpaceOnDrive: |
|
320 details.Copy(_L("EUiInsufficientSpaceOnDrive")); |
|
321 break; |
|
322 case Swi::EUiCapabilitiesCannotBeGranted: |
|
323 // aParam contains list of capability names |
|
324 details.Copy(_L("Cannot grant capabilities requested by the application.")); |
|
325 break; |
|
326 case Swi::EUiUnknownFile: |
|
327 details.Copy(_L("EUiUnknownFile")); |
|
328 break; |
|
329 case Swi::EUiMissingBasePackage: |
|
330 details.Copy(_L("EUiMissingBasePackage")); |
|
331 break; |
|
332 case Swi::EUiConstraintsExceeded: |
|
333 details.Copy(_L("EUiConstraintsExceeded")); |
|
334 break; |
|
335 case Swi::EUiSIDViolation: |
|
336 details.Copy(_L("EUiSIDViolation")); |
|
337 break; |
|
338 case Swi::EUiVIDViolation: |
|
339 details.Copy(_L("EUiVIDViolation")); |
|
340 break; |
|
341 case Swi::EUiNoMemoryInDrive: |
|
342 details.Copy(_L("EUiNoMemoryInDrive")); |
|
343 break; |
|
344 case Swi::EUiUIDPackageViolation: |
|
345 details.Copy(_L("EUiUIDPackageViolation")); |
|
346 break; |
|
347 case Swi::EUiOSExeViolation: |
|
348 details.Copy(_L("EUiOSExeViolation")); |
|
349 break; |
|
350 case Swi::EUiSIDMismatch: |
|
351 details.Copy(_L("EUiSIDMismatch")); |
|
352 break; |
|
353 case Swi::EUiBlockingEclipsingFile: |
|
354 details.Copy(_L("EUiBlockingEclipsingFile")); |
|
355 break; |
|
356 default: |
|
357 break; |
|
358 } |
|
359 |
|
360 SetErrorL( KErrGeneral, aType, details ); |
|
361 } |
|
362 |
|
363 // --------------------------------------------------------------------------- |
|
364 // CSisxSifPluginUiHandlerBase::SetOcspErrorL() |
|
365 // --------------------------------------------------------------------------- |
|
366 // |
|
367 void CSisxSifPluginUiHandlerBase::SetOcspErrorL( Swi::TRevocationDialogMessage aMessage ) |
|
368 { |
|
369 // TODO: localised error strings needed |
|
370 iErrorHandler.SetErrorMessage( _L("Unable to check certificate validity online." ) ); |
|
371 iErrorHandler.SetExtendedErrorCode( aMessage ); |
|
372 switch( aMessage ) |
|
373 { |
|
374 case Swi::EInvalidRevocationServerUrl: |
|
375 iErrorHandler.SetErrorCode( KErrGeneral ); |
|
376 iErrorHandler.SetErrorMessageDetails( _L("Invalid server URL. Check settings.") ); |
|
377 break; |
|
378 case Swi::EUnableToObtainCertificateStatus: |
|
379 iErrorHandler.SetErrorCode( KErrGeneral ); |
|
380 iErrorHandler.SetErrorMessageDetails( _L("Unable to obtain certificate status. Try again later.") ); |
|
381 break; |
|
382 case Swi::EResponseSignatureValidationFailure: |
|
383 iErrorHandler.SetErrorCode( KErrGeneral ); |
|
384 iErrorHandler.SetErrorMessageDetails( _L("Response signature validation failure. Check settings.") ); |
|
385 break; |
|
386 case Swi::EInvalidRevocationServerResponse: |
|
387 iErrorHandler.SetErrorCode( KErrGeneral ); |
|
388 iErrorHandler.SetErrorMessageDetails( _L("The OCSP server reply is invalid. Check settings.") ); |
|
389 break; |
|
390 case Swi::EInvalidCertificateStatusInformation: |
|
391 case Swi::ECertificateStatusIsUnknownSelfSigned: |
|
392 iErrorHandler.SetErrorCode( KErrGeneral ); |
|
393 iErrorHandler.SetErrorMessageDetails( _L("Invalid certificate status information. Try again later.") ); |
|
394 break; |
|
395 case Swi::ECertificateStatusIsUnknown: |
|
396 iErrorHandler.SetErrorCode( KErrGeneral ); |
|
397 iErrorHandler.SetErrorMessageDetails( _L("Unknown certificate. Try again later.") ); |
|
398 break; |
|
399 case Swi::ECertificateStatusIsRevoked: |
|
400 iErrorHandler.SetErrorCode( KErrAccessDenied ); |
|
401 iErrorHandler.SetErrorMessageDetails( _L("The certificate has been revoked.") ); |
|
402 break; |
|
403 default: |
|
404 break; |
|
405 } |
|
406 } |
|
407 |
|
408 // --------------------------------------------------------------------------- |
|
409 // CSisxSifPluginUiHandlerBase::ShowQuestionL() |
|
410 // --------------------------------------------------------------------------- |
|
411 // |
|
412 TBool CSisxSifPluginUiHandlerBase::ShowQuestionL( const TDesC& aText ) const |
|
413 { |
|
414 TBool questionAccepted = EFalse; |
|
415 |
|
416 CHbDeviceMessageBoxSymbian *note = NULL; |
|
417 note = CHbDeviceMessageBoxSymbian::NewL( CHbDeviceMessageBoxSymbian::EQuestion ); |
|
418 CleanupStack::PushL( note ); |
|
419 |
|
420 note->SetTextL( aText ); |
|
421 note->SetTimeout( 0 ); |
|
422 if( note->ExecL() == CHbDeviceMessageBoxSymbian::EAcceptButton ) |
|
423 { |
|
424 questionAccepted = ETrue; |
|
425 } |
|
426 |
|
427 CleanupStack::PopAndDestroy( note ); |
|
428 return questionAccepted; |
|
429 } |
|
430 |
|
431 // --------------------------------------------------------------------------- |
|
432 // CSisxSifPluginUiHandlerBase::ShowQuestionWithContinueL() |
|
433 // --------------------------------------------------------------------------- |
|
434 // |
|
435 void CSisxSifPluginUiHandlerBase::ShowQuestionWithContinueL( const TDesC& aText ) const |
|
436 { |
|
437 CHbDeviceMessageBoxSymbian *note = NULL; |
|
438 note = CHbDeviceMessageBoxSymbian::NewL( CHbDeviceMessageBoxSymbian::EQuestion ); |
|
439 CleanupStack::PushL( note ); |
|
440 |
|
441 note->SetTextL( aText ); |
|
442 note->SetTimeout( 0 ); |
|
443 note->SetButton( CHbDeviceMessageBoxSymbian::EAcceptButton, EFalse ); |
|
444 note->SetButton( CHbDeviceMessageBoxSymbian::ERejectButton, ETrue ); |
|
445 // TODO: localized UI string needed |
|
446 note->SetButtonTextL( CHbDeviceMessageBoxSymbian::ERejectButton, _L("Continue") ); |
|
447 (void)note->ExecL(); |
|
448 |
|
449 CleanupStack::PopAndDestroy( note ); |
|
450 } |
|
451 |
|