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