commands/swi/swi.cpp
changeset 0 7f656887cf89
child 6 96d581d2147d
equal deleted inserted replaced
-1:000000000000 0:7f656887cf89
       
     1 // swi.cpp
       
     2 // 
       
     3 // Copyright (c) 2008 - 2010 Accenture. All rights reserved.
       
     4 // This component and the accompanying materials are made available
       
     5 // under the terms of the "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 // Accenture - Initial contribution
       
    11 //
       
    12 
       
    13 #include "swi.h"
       
    14 #include <fshell/common.mmh>
       
    15 #include <fshell/ltkutils.h>
       
    16 
       
    17 typedef TBuf<1> TUserInput;
       
    18 _LIT(KSwiYes,	"y");
       
    19 _LIT(KSwiNo,	"n");
       
    20 _LIT(KSwiJarExtension,	"*.jar");
       
    21 _LIT(KSwiJadExtension,	"*.jad");
       
    22 #ifndef SYMBIAN_JAVA_NOT_INCLUDED
       
    23 _LIT8(KDefaultJadMimeType, "text/vnd.sun.j2me.app-descriptor");
       
    24 _LIT8(KDefaultJarMimeType, "application/java-archive");
       
    25 #endif
       
    26 _LIT(KDefaultMatch, "*");
       
    27 
       
    28 //
       
    29 // CCmdSwi
       
    30 // class to handle the fshell console user interaction
       
    31 //
       
    32 CCommandBase* CCmdSwi::NewLC()
       
    33 	{
       
    34 	CCmdSwi* self = new(ELeave) CCmdSwi();
       
    35 	CleanupStack::PushL(self);
       
    36 	self->BaseConstructL();
       
    37 	return self;
       
    38 	}
       
    39 
       
    40 CCmdSwi::~CCmdSwi()
       
    41 	{
       
    42 #ifndef SYMBIAN_JAVA_NOT_INCLUDED
       
    43 	delete iMidletHandler;
       
    44 #endif
       
    45 	delete iSisHandler;
       
    46 	delete iMatch;
       
    47 	}
       
    48 
       
    49 CCmdSwi::CCmdSwi():
       
    50 CCommandBase(CCommandBase::EManualComplete)
       
    51 	{
       
    52 	}
       
    53 
       
    54 const TDesC& CCmdSwi::Name() const
       
    55 	{
       
    56 	_LIT(KName, "swi");
       
    57 	return KName;
       
    58 	}
       
    59 
       
    60 void CCmdSwi::ArgumentsL(RCommandArgumentList& aArguments)
       
    61 	{
       
    62 	aArguments.AppendEnumL((TInt&)iCommand, _L("operation"));
       
    63 
       
    64 	_LIT(KArgFilename, "sis-file");
       
    65 	aArguments.AppendFileNameL(iSisFile, KArgFilename);
       
    66 	}
       
    67 	
       
    68 void CCmdSwi::OptionsL(RCommandOptionList& aOptions)
       
    69 	{
       
    70 	_LIT(KOptUid, "uid");
       
    71 	aOptions.AppendUintL((TUint&)iUid.iUid, KOptUid);
       
    72 
       
    73 	_LIT(KOptVerbose, "verbose");
       
    74 	aOptions.AppendBoolL(iVerbose, KOptVerbose);
       
    75 
       
    76 	_LIT(KOptQuiet, "quiet");
       
    77 	aOptions.AppendBoolL(iQuiet, KOptQuiet);
       
    78 
       
    79 	_LIT(KOptMatch, "match");
       
    80 	aOptions.AppendStringL(iMatch, KOptMatch);
       
    81 	}
       
    82 
       
    83 void CCmdSwi::DoRunL()
       
    84 	{
       
    85 	if (iMatch == NULL)
       
    86 		{
       
    87 		iMatch = KDefaultMatch().AllocL();
       
    88 		}
       
    89 
       
    90 	iSisHandler = CSwiSisInstallerAO::NewL(*this, FsL(), iVerbose, iQuiet);
       
    91 #ifndef SYMBIAN_JAVA_NOT_INCLUDED
       
    92 	iMidletHandler = CSwiMidletInstallerAO::NewL(*this, FsL(), iVerbose, iQuiet);
       
    93 #endif
       
    94 
       
    95 	switch (iCommand)
       
    96 		{
       
    97 	case EList:
       
    98 		//TODO matching
       
    99 		TRAPL(iSisHandler->ListInstalledAppsL(iUid, *iMatch), _L("Couldn't list installed SIS files"));
       
   100 #ifndef SYMBIAN_JAVA_NOT_INCLUDED
       
   101 		TRAPL(iMidletHandler->ListInstalledAppsL(iUid, *iMatch), _L("Couldn't list installed midlets"));
       
   102 #endif
       
   103 		Complete(KErrNone);
       
   104 		break;
       
   105 		
       
   106 	case EUninstall:
       
   107 		if (!iOptions.IsPresent(&iUid))
       
   108 			{
       
   109 			LeaveIfErr(KErrArgument, _L("UID must be specified for \"uninstall\""));
       
   110 			}
       
   111 		TRAPD(error, iSisHandler->UninstallL(iUid));
       
   112 		if (error != KErrNone)
       
   113 			{
       
   114 #ifndef SYMBIAN_JAVA_NOT_INCLUDED
       
   115 			// possibly a midlet
       
   116 			TRAP(error, iMidletHandler->UninstallL(iUid));
       
   117 #endif
       
   118 			}
       
   119 		LeaveIfErr(error, _L("Failed to uninstall package 0x%08x"), iUid.iUid);
       
   120 		break;
       
   121 		
       
   122 	case EInstall:
       
   123 		if (!iArguments.IsPresent(1))
       
   124 			{
       
   125 			LeaveIfErr(KErrArgument, _L("SIS file must be specified for \"install\""));
       
   126 			}
       
   127 		User::LeaveIfError(Stdin().SetReadMode(RIoReadHandle::ELine));
       
   128 #ifndef SYMBIAN_JAVA_NOT_INCLUDED
       
   129 		if (IsMidlet())
       
   130 			{
       
   131 			TRAPL(iMidletHandler->InstallL(iSisFile), _L("Failed to install midlet '%S'"), &iSisFile);
       
   132 			}
       
   133 		else
       
   134 #endif
       
   135 			{
       
   136 			TRAPL(iSisHandler->InstallL(iSisFile), _L("Failed to install sis '%S'"), &iSisFile);
       
   137 			}
       
   138 		break;
       
   139 		}
       
   140 
       
   141 	}
       
   142 	
       
   143 TBool CCmdSwi::IsMidlet()
       
   144 	{
       
   145 	if ((iSisFile.MatchF(KSwiJarExtension) != KErrNotFound) || (iSisFile.MatchF(KSwiJadExtension) != KErrNotFound))
       
   146 		return ETrue;
       
   147 	return EFalse;
       
   148 	}
       
   149 
       
   150 //
       
   151 // CCmdSwi::GetAnswer
       
   152 // only for use when not in quiet mode
       
   153 // Reads input from stdin, determines whether it's a 'yes' or 'no', returning ETrue, EFalse respectively
       
   154 //
       
   155 TBool CCmdSwi::GetAnswer()
       
   156 	{
       
   157 	ASSERT(!iQuiet);
       
   158 	TUserInput in;
       
   159 	for (;;)
       
   160 		{
       
   161 		if (Stdin().Read(in) != KErrNone)
       
   162 			{
       
   163 			return EFalse;
       
   164 			}
       
   165 		Stdout().Write(in);
       
   166 		if (in.MatchF(KSwiYes) == 0)
       
   167 			{
       
   168 			return ETrue;
       
   169 			}
       
   170 		if (in.MatchF(KSwiNo) == 0)
       
   171 			{
       
   172 			return EFalse;
       
   173 			}
       
   174 		// else it's an unrecognised response
       
   175 		}
       
   176 	}
       
   177 
       
   178 //
       
   179 // MCmdSwiParent hooks
       
   180 //
       
   181 RIoConsoleReadHandle& CCmdSwi::Input()
       
   182 	{
       
   183 	return Stdin();
       
   184 	}
       
   185 
       
   186 RIoConsoleWriteHandle& CCmdSwi::Output(TInt aError)
       
   187 	{
       
   188 	if (aError == KErrNone)
       
   189 		{
       
   190 		return Stdout();
       
   191 		}
       
   192 	return Stderr();
       
   193 	}
       
   194 
       
   195 //
       
   196 // CCmdSwi::Finished
       
   197 // callback from the underlying AO's RunL
       
   198 //
       
   199 void CCmdSwi::Finished(const TInt aError)
       
   200 	{
       
   201 	Complete(aError);
       
   202 	}
       
   203 
       
   204 //
       
   205 // Sis installer AO
       
   206 //
       
   207 CSwiSisInstallerAO* CSwiSisInstallerAO::NewL(MCmdSwiParent& aParent, RFs& aFs, TBool aVerbose, TBool aQuiet)
       
   208 	{
       
   209 	CSwiSisInstallerAO* self = new (ELeave) CSwiSisInstallerAO(aParent, aFs, aVerbose, aQuiet);
       
   210 	CleanupStack::PushL(self);
       
   211 	self->ConstructL();
       
   212 	CleanupStack::Pop(self);
       
   213 	return self;
       
   214 	}
       
   215 
       
   216 CSwiSisInstallerAO::CSwiSisInstallerAO(MCmdSwiParent& aParent, RFs& aFs, TBool aVerbose, TBool aQuiet)
       
   217 	: CActive(CActive::EPriorityStandard), iParent(aParent), iVerbose(aVerbose), iQuiet(aQuiet), iCurrentDrive('c')
       
   218 	{
       
   219 	TFileName sessionPath;
       
   220 	TInt err = aFs.SessionPath(sessionPath);
       
   221 	if (err == KErrNone)
       
   222 		{
       
   223 		iCurrentDrive = sessionPath[0];
       
   224 		iCurrentDrive.LowerCase();
       
   225 		}
       
   226 	CActiveScheduler::Add(this);
       
   227 	}
       
   228 
       
   229 CSwiSisInstallerAO::~CSwiSisInstallerAO()
       
   230 	{
       
   231 	Cancel();
       
   232 	delete iLauncher;
       
   233 	delete iRegPackage;
       
   234 	iRegistrySession.Close();
       
   235 	delete iPrefs;
       
   236 	}
       
   237 
       
   238 void CSwiSisInstallerAO::ConstructL()
       
   239 	{
       
   240 	iLauncher = CAsyncLauncher::NewL();
       
   241 	User::LeaveIfError(iRegistrySession.Connect());
       
   242 	iPrefs = Swi::CInstallPrefs::NewL();
       
   243 	iPrefs->SetPerformRevocationCheck(EFalse); // TODO - not currently supported in CCmdSwi
       
   244 	}
       
   245 
       
   246 void CSwiSisInstallerAO::RunL()
       
   247 	{
       
   248 	iParent.Finished(iStatus.Int());
       
   249 	}
       
   250 
       
   251 void CSwiSisInstallerAO::DoCancel()
       
   252 	{
       
   253 	iLauncher->CancelOperation();
       
   254 	iParent.Finished(KErrCancel);
       
   255 	}
       
   256 
       
   257 void CSwiSisInstallerAO::PrintDetails(Swi::CSisRegistryPackage& aPackage)
       
   258 	{
       
   259 	if (iVerbose)
       
   260 		{
       
   261 		TName myBuf;
       
   262 		myBuf.Format(_L("\r\nName:\t%S\r\n"), &aPackage.Name());
       
   263 		Stdout().Write(myBuf);
       
   264 		myBuf.Format(_L("Vendor:\t%S\r\n"), &aPackage.Vendor());
       
   265 		Stdout().Write(myBuf);
       
   266 		myBuf.Format(_L("Uid:\t0x%x\r\n"), aPackage.Uid());
       
   267 		Stdout().Write(myBuf);
       
   268 		}
       
   269 	else
       
   270 		{
       
   271 		TBuf<256> buf; buf.Format(_L("0x%08x: "), aPackage.Uid());
       
   272 		Stdout().Write(buf);
       
   273 		Stdout().Write(aPackage.Name());
       
   274 		Stdout().Write(_L("\r\n"));
       
   275 		}
       
   276 	}
       
   277 
       
   278 void CSwiSisInstallerAO::InstallL(TFileName& aInstallFile)
       
   279 	{
       
   280 	// install regular sis file
       
   281 	ASSERT(iPrefs);
       
   282 	ASSERT(iLauncher);
       
   283 	iLauncher->InstallL(*this, aInstallFile, *iPrefs, iStatus);
       
   284 	SetActive();
       
   285 	}
       
   286 
       
   287 void CSwiSisInstallerAO::UninstallL(const TUid& aPackageUid)
       
   288 	{
       
   289 	// remove regular sis file
       
   290 	ASSERT(iLauncher);
       
   291 	ASSERT(!iRegPackage);
       
   292 	Swi::CSisRegistryPackage* iRegPackage = GetSisRegistryPackageL(aPackageUid);
       
   293 	iLauncher->UninstallL(*this, *iRegPackage, iStatus);
       
   294 	SetActive();
       
   295 	}
       
   296 
       
   297 //
       
   298 // CSwiSisInstallerAO::ListInstalledAppsL
       
   299 // lists apps currently installed on the device
       
   300 //
       
   301 void CSwiSisInstallerAO::ListInstalledAppsL(const TUid& aAppUid, const TDesC& aMatchString)
       
   302 	{
       
   303 	if (aAppUid.iUid != 0)
       
   304 		{
       
   305 		DisplayPackageL(aAppUid);
       
   306 		}
       
   307 	else
       
   308 		{
       
   309 		ASSERT(iRegistrySession.Handle() > 0);
       
   310 		RPointerArray<CSisRegistryPackage> packages;
       
   311 		LtkUtils::CleanupResetAndDestroyPushL(packages);
       
   312 		iRegistrySession.InstalledPackagesL(packages);
       
   313 		if (packages.Count() <= 0)
       
   314 			{
       
   315 			User::Leave(KErrNotFound);
       
   316 			}
       
   317 		TInt count = 0;
       
   318 		const TInt endCount = packages.Count();
       
   319 		do
       
   320 			{
       
   321 			CSisRegistryPackage* current = packages[count++];
       
   322 			if ((current->Name().MatchF(aMatchString) >= 0) || (current->Vendor().MatchF(aMatchString) >= 0))
       
   323 				{
       
   324 				PrintDetails(*current);
       
   325 				}
       
   326 			} while (count < endCount);
       
   327 		CleanupStack::PopAndDestroy(&packages);
       
   328 		}
       
   329 	}
       
   330 
       
   331 //
       
   332 // CSwiSisInstallerAO::DisplayPackageL
       
   333 // find information on the specified package uid and display it on the console
       
   334 //
       
   335 void CSwiSisInstallerAO::DisplayPackageL(const TUid& aPackageUid)
       
   336 	{
       
   337 	ASSERT(iRegistrySession.Handle() > 0);
       
   338 	Swi::RSisRegistryEntry entry;
       
   339 	User::LeaveIfError(entry.Open(iRegistrySession, aPackageUid));
       
   340 	CleanupClosePushL(entry);
       
   341 	Swi::CSisRegistryPackage* registryPackage = entry.PackageL();
       
   342 	CleanupStack::PushL(registryPackage);
       
   343 	PrintDetails(*registryPackage);
       
   344 	CleanupStack::PopAndDestroy(2, &entry);	
       
   345 	}
       
   346 
       
   347 //
       
   348 // CSwiSisInstallerAO::GetSisRegistryPackageL
       
   349 // locate the sis registry package corresponding to the specified package ui
       
   350 //
       
   351 Swi::CSisRegistryPackage* CSwiSisInstallerAO::GetSisRegistryPackageL(const TUid& aPackageUid)
       
   352 	{
       
   353 	ASSERT(iRegistrySession.Handle() > 0);
       
   354 	if (!iRegistrySession.IsInstalledL(aPackageUid))
       
   355 		{
       
   356 		User::Leave(KErrNotFound); // invalid uid
       
   357 		}
       
   358 	// else iterate through the installed packages to find ours
       
   359 	RPointerArray<Swi::CSisRegistryPackage> packages;
       
   360 	iRegistrySession.InstalledPackagesL(packages);
       
   361 	if (packages.Count() <= 0)
       
   362 		{
       
   363 		User::Leave(KErrNotFound);
       
   364 		}
       
   365 	TInt count = 0;
       
   366 	const TInt endCount = packages.Count();
       
   367 	Swi::CSisRegistryPackage* found = NULL;
       
   368 	do
       
   369 		{
       
   370 		Swi::CSisRegistryPackage* current = packages[count];
       
   371 		 if (current->Uid() == aPackageUid)
       
   372 			{
       
   373 			found = current;
       
   374 			break;
       
   375 			}
       
   376 		count++;
       
   377 		} while (count < endCount);
       
   378 	ASSERT(found); // IsInstalledL stated it's in there
       
   379 	return found; 
       
   380 	}
       
   381 
       
   382 //
       
   383 // SWI UI Hooks
       
   384 //
       
   385 TBool CSwiSisInstallerAO::DisplayTextL(const Swi::CAppInfo& /*aAppInfo*/, Swi::TFileTextOption /*aOption*/, const TDesC& aText)
       
   386 	{
       
   387 	TBool response = ETrue; // default, the user will continue with the installation/uninstallation
       
   388 	if (!iQuiet)
       
   389 		{
       
   390 		Stdout().Write(aText);
       
   391 		Stdout().Write(_L("Continue [y/n]?\r\n"));
       
   392 		response = iParent.GetAnswer();
       
   393 		}
       
   394 	return response;
       
   395 	}
       
   396 
       
   397 void CSwiSisInstallerAO::DisplayErrorL(const Swi::CAppInfo& /*aAppInfo*/, Swi::TErrorDialog aType, const TDesC& /*aParam*/)
       
   398 	{
       
   399 	if (iVerbose)
       
   400 		{
       
   401 		switch (aType)
       
   402 			{
       
   403 			case Swi::EUiAlreadyInRom:
       
   404 				Stderr().Write(_L("\r\nCannot overwrite a ROM component.\r\n"));
       
   405 			break;
       
   406 			
       
   407 			case Swi::EUiMissingDependency:
       
   408 				Stderr().Write(_L("\r\nMissing a dependency.\r\n"));
       
   409 			break;
       
   410 			
       
   411 			case Swi::EUiRequireVer:
       
   412 				Stderr().Write(_L("\r\nA dependency exists on a specific version of an application which is different from the one installed.\r\n"));
       
   413 			break;
       
   414 
       
   415 			case Swi::EUiFileCorrupt:
       
   416 				Stderr().Write(_L("\r\nSISX file corrupt. Checksums stored in file do not match actual.\r\n"));
       
   417 			break;
       
   418 
       
   419 			case Swi::EUiDiskNotPresent:
       
   420 				Stderr().Write(_L("\r\nAll your bases are belong to us. <disk not present>\r\n"));
       
   421 			break;
       
   422 
       
   423 			case Swi::EUiCannotRead:
       
   424 				Stderr().Write(_L("\r\nCannot read a file which is needed in order to proceed.\r\n"));
       
   425 			break;
       
   426 
       
   427 			case Swi::EUiCannotDelete:
       
   428 				Stderr().Write(_L("\r\nCannot delete a file.\r\n"));
       
   429 			break;
       
   430 
       
   431 			case Swi::EUiInvalidFileName:
       
   432 				Stderr().Write(_L("\r\nA filename specified in the SISX package is not valid.\r\n"));
       
   433 			break;
       
   434 
       
   435 			case Swi::EUiInsufficientSpaceOnDrive:
       
   436 				Stderr().Write(_L("\r\nInsufficient space on the drive.\r\n"));
       
   437 			break;
       
   438 
       
   439 			case Swi::EUiCapabilitiesCannotBeGranted:
       
   440 				Stderr().Write(_L("\r\nApplication requires system capability it is not signed for.\r\n"));
       
   441 			break;
       
   442 
       
   443 			case Swi::EUiUnknownFile:
       
   444 				Stderr().Write(_L("\r\nNot a recognised SISX file.\r\n"));
       
   445 			break;
       
   446 
       
   447 			case Swi::EUiMissingBasePackage:
       
   448 				Stderr().Write(_L("\r\nA base package required for installation is not present.\r\n"));
       
   449 			break;
       
   450 
       
   451 			case Swi::EUiConstraintsExceeded:
       
   452 				Stderr().Write(_L("\r\nConstraints imposed by a developer mode certificate have been exceeded.\r\n"));
       
   453 			break;
       
   454 
       
   455 			case Swi::EUiSIDViolation:
       
   456 				Stderr().Write(_L("\r\nThe package contains a file with a protected SID which is not signed for.\r\n"));
       
   457 			break;
       
   458 
       
   459 			case Swi::EUiVIDViolation:
       
   460 				Stderr().Write(_L("\r\nThe package contains a file with a protected VID which is not signed for.\r\n"));
       
   461 			break;
       
   462 
       
   463 			case Swi::EUiSIDMismatch:
       
   464 				Stderr().Write(_L("\r\nMismatched SID.\r\n"));
       
   465 			break;
       
   466 
       
   467 			case Swi::EUiBlockingEclipsingFile:
       
   468 				Stderr().Write(_L("\r\nThe package contains an invalid eclipsing file which is already in the device other than ROM.\r\n"));
       
   469 			break;
       
   470 
       
   471 			default:
       
   472 				{
       
   473 				TBuf<64> buf;
       
   474 				buf.Format(_L("\r\nAn error %d has occured. Aborting.\r\n"), aType);
       
   475 				Stderr().Write(buf);
       
   476 				}
       
   477 			break;
       
   478 			};
       
   479 		}
       
   480 	}
       
   481 	
       
   482 TBool CSwiSisInstallerAO::DisplayDependencyBreakL(const Swi::CAppInfo& /*aAppInfo*/, const RPointerArray<TDesC>& /*aComponents*/)
       
   483 	{
       
   484 	TBool response = ETrue; // default response is to continue with uninstallation
       
   485 	if (iVerbose)
       
   486 		{
       
   487 		Stdout().Write(_L("\r\nComponent being uninstalled has dependencies which may no longer work. Continue uninstalling [y/n]?\r\n"));
       
   488 		response = iParent.GetAnswer();
       
   489 		}
       
   490 	return response;
       
   491 	}
       
   492 
       
   493 TBool CSwiSisInstallerAO::DisplayApplicationsInUseL(const Swi::CAppInfo& /*aAppInfo*/, const RPointerArray<TDesC>& /*aAppNames*/)
       
   494 	{
       
   495 	TBool response = EFalse; // EFalse indicates we don't continue with uninstallation
       
   496 	if (!iQuiet)
       
   497 		{
       
   498 		Stdout().Write(_L("\r\nApplication is currently open. Continue uninstalling? [y/n]\r\n"));
       
   499 		response = iParent.GetAnswer();
       
   500 		}
       
   501 	if (!response)
       
   502 		{
       
   503 		Stderr().Write(_L("Uninstall aborted. Application will not be closed.\r\n"));
       
   504 		}
       
   505 	return response;
       
   506 	}
       
   507 
       
   508 TBool CSwiSisInstallerAO::DisplayQuestionL(const Swi::CAppInfo& /* aAppInfo */, Swi::TQuestionDialog aQuestion, const TDesC& aDes)
       
   509 	{
       
   510 	TBool response = ETrue; // default behaviour assumes the user presses 'Yes' to any question
       
   511 	if (!iQuiet)
       
   512 		{
       
   513 		if (aQuestion == Swi::EQuestionIncompatible)
       
   514 			{
       
   515 			Stdout().Write(_L("\r\nApplication is not compatible with this device. Install anyway [y/n]?"));
       
   516 			}
       
   517 		else if (aQuestion == Swi::EQuestionOverwriteFile)
       
   518 			{
       
   519 			Stdout().Write(_L("\r\nSome system files will be overwritten by this installation. Install anyway [y/n]?"));
       
   520 			}
       
   521 		else
       
   522 			{
       
   523 			TBuf<128> buf; buf.Format(_L("Unrecognised question from engine %d\r\n"), aQuestion);
       
   524 			Stderr().Write(buf);
       
   525 			User::Leave(KErrNotSupported);
       
   526 			}
       
   527 
       
   528 		if (aDes.Length() > 0)
       
   529 			{
       
   530 			Stdout().Write(aDes);
       
   531 			}
       
   532 		Stdout().Write(_L("\r\n"));
       
   533 		response = iParent.GetAnswer();
       
   534 		}
       
   535 	return response;
       
   536 	}
       
   537 	
       
   538 TBool CSwiSisInstallerAO::DisplayInstallL(const Swi::CAppInfo& aAppInfo, const CApaMaskedBitmap* /*aLogo*/, const RPointerArray<Swi::CCertificateInfo>& /*aCertificates*/)
       
   539 	{
       
   540 	if (iVerbose)
       
   541 		{
       
   542 		TBuf<256> myBuf;
       
   543 		myBuf.Format(_L("NAME:\t\t%S\r\n"), &aAppInfo.AppName());
       
   544 		Stdout().Write(myBuf);
       
   545 		myBuf.Format(_L("VENDOR:\t\t%S\r\n"), &aAppInfo.AppVendor());
       
   546 		Stdout().Write(myBuf);
       
   547 		myBuf.Format(_L("VERSION:\t%d.%d.%d\r\n"), aAppInfo.AppVersion().iMajor, aAppInfo.AppVersion().iMinor, aAppInfo.AppVersion().iBuild);
       
   548 		Stdout().Write(myBuf);
       
   549 		}
       
   550 	TBool response = ETrue; // default behaviour is to continue the install
       
   551 	return response;
       
   552 	}
       
   553 	
       
   554 TBool CSwiSisInstallerAO::DisplayGrantCapabilitiesL(const Swi::CAppInfo& /*aAppInfo*/, const TCapabilitySet& /*aCapabilitySet*/)
       
   555 	{
       
   556 	TBool response = ETrue; // default behaviour is to continue the install
       
   557 	if (iVerbose)
       
   558 		{
       
   559 		// todo verbose mode
       
   560 		Stdout().Write(_L("\r\nTODO - CCmdSwi::DisplayGrantCapabilitiesL\r\n"));
       
   561 		}
       
   562 	return response;
       
   563 	}
       
   564 	
       
   565 TInt CSwiSisInstallerAO::DisplayLanguageL(const Swi::CAppInfo& /*aAppInfo*/, const RArray<TLanguage>& /*aLanguages*/)
       
   566 	{
       
   567 	if (iVerbose)
       
   568 		{
       
   569 		// todo verbose mode
       
   570 		Stdout().Write(_L("\r\nTODO - CCmdSwi::DisplayLanguageL\r\n"));
       
   571 		}
       
   572 	return 0; // the first language
       
   573 	}
       
   574 	
       
   575 TInt CSwiSisInstallerAO::DisplayDriveL(const Swi::CAppInfo& /*aAppInfo*/, TInt64 aSize, const RArray<TChar>& aDriveLetters, const RArray<TInt64>& aDriveSpaces)
       
   576 	{
       
   577 	TInt response = 0; // default to the first known drive
       
   578 	for (TInt i = 0; i < aDriveLetters.Count(); i++)
       
   579 		{
       
   580 		TChar letter = aDriveLetters[i];
       
   581 		letter.LowerCase();
       
   582 		if (letter == iCurrentDrive)
       
   583 			{
       
   584 			response = i; // Default to using the CWD drive, if it is in the list of available drives
       
   585 			break;
       
   586 			}
       
   587 		}
       
   588 
       
   589 	if (!iQuiet)
       
   590 		{
       
   591 		TBuf<128> info;
       
   592 		info.Format(_L("Application requires %d bytes free space. Please select installation drive:\r\n"), aSize);
       
   593 		Stdout().Write(info);
       
   594 		for (TInt ii = 0 ; ii < aDriveLetters.Count() ; ii++)
       
   595 			{
       
   596 			info.Format(_L("%d. \'"), ii);		// pseudo-drive number
       
   597 			info.Append(aDriveLetters[ii]);		// drive letter
       
   598 			info.Append(_L("\' "));
       
   599 			info.AppendNum(aDriveSpaces[ii]); // free space
       
   600 			info.Append(_L(" bytes free\r\n"));
       
   601 			Stdout().Write(info);
       
   602 			}
       
   603 		TUserInput in;
       
   604 		User::LeaveIfError(Stdin().Read(in));
       
   605 		TLex lex(in);
       
   606 		User::LeaveIfError(lex.Val(response));
       
   607 		}
       
   608 	return response;
       
   609 	}
       
   610 	
       
   611 TBool CSwiSisInstallerAO::DisplayUpgradeL(const Swi::CAppInfo& /*aAppInfo*/, const Swi::CAppInfo& /*aExistingAppInfo*/)
       
   612 	{
       
   613 	TBool response = ETrue; // default behaviour is to continue the install
       
   614 	if (!iQuiet)
       
   615 		{
       
   616 		Stdout().Write(_L("Do you wish to replace the existing installed application [y/n]?\r\n"));
       
   617 		response = iParent.GetAnswer();
       
   618 		}
       
   619 	return response;
       
   620 	}
       
   621 	
       
   622 TBool CSwiSisInstallerAO::DisplayOptionsL(const Swi::CAppInfo& /*aAppInfo*/, const RPointerArray<TDesC>& /*aOptions*/, RArray<TBool>& /*aSelections*/)
       
   623 	{
       
   624 	TBool response = ETrue; // default behaviour is to continue the install
       
   625 	if (iVerbose)
       
   626 		{
       
   627 		// todo verbose mode
       
   628 		Stdout().Write(_L("TODO - CCmdSwi::DisplayOptionsL\r\n"));
       
   629 		}
       
   630 	return response;
       
   631 	}
       
   632 	
       
   633 TBool CSwiSisInstallerAO::HandleInstallEventL(const Swi::CAppInfo& /*aAppInfo*/, Swi::TInstallEvent aEvent, TInt /*aValue*/, const TDesC& /*aDes*/)
       
   634 	{
       
   635 	TBool response = ETrue; // default behaviour is to continue the install
       
   636 	if (iVerbose)
       
   637 		{
       
   638 		switch (aEvent)
       
   639 			{
       
   640 			case Swi::EEventUpdateProgressBar:
       
   641 				Stdout().Write(_L("."));
       
   642 			break;
       
   643 			
       
   644 			case Swi::EEventCompletedInstall:
       
   645 			case Swi::EEventCompletedUnInstall:
       
   646 				{
       
   647 				Stdout().Write(_L("\r\nComplete\r\n"));
       
   648 				}
       
   649 			break;
       
   650 
       
   651 			default:
       
   652 				// do nothing to inform the user of other cases
       
   653 			break;
       
   654 			};
       
   655 		}
       
   656 	return response;
       
   657 	}
       
   658 	
       
   659 void CSwiSisInstallerAO::HandleCancellableInstallEventL(const Swi::CAppInfo& /*aAppInfo*/, Swi::TInstallCancellableEvent aEvent, Swi::MCancelHandler& /*aCancelHandler*/, TInt /*aValue*/, const TDesC& /*aDes*/)
       
   660 	{
       
   661 	if (iVerbose)
       
   662 		{
       
   663 		switch (aEvent)
       
   664 			{
       
   665 			case Swi::EEventRemovingFiles:
       
   666 				{
       
   667 				Stdout().Write(_L("\r\nRemoving files\r\n"));
       
   668 				}
       
   669 			break;
       
   670 			
       
   671 			case Swi::EEventShuttingDownApps:
       
   672 				{
       
   673 				Stdout().Write(_L("Closing App\r\n"));
       
   674 				}
       
   675 			break;
       
   676 
       
   677 			case Swi::EEventCopyingFiles:
       
   678 				{
       
   679 				Stdout().Write(_L("Copying files\r\n"));
       
   680 				}
       
   681 			break;
       
   682 
       
   683 			default:
       
   684 			break;
       
   685 			};
       
   686 		}
       
   687 	}
       
   688 
       
   689 TBool CSwiSisInstallerAO::DisplaySecurityWarningL(const Swi::CAppInfo& /*aAppInfo*/, Swi::TSignatureValidationResult /*aSigValidationResult*/, RPointerArray<CPKIXValidationResultBase>& /*aPkixResults*/, RPointerArray<Swi::CCertificateInfo>& /*aCertificates*/, TBool /*aInstallAnyway*/)
       
   690 	{
       
   691 	TBool response = ETrue; // default behaviour is to continue the install
       
   692 	if (!iQuiet)
       
   693 		{
       
   694 		Stdout().Write(_L("\r\nApplication signature cannot be validated. Continue installing [y/n]?\r\n"));
       
   695 		response = iParent.GetAnswer();
       
   696 		}
       
   697 	return response;
       
   698 	}
       
   699 	
       
   700 TBool CSwiSisInstallerAO::DisplayOcspResultL(const Swi::CAppInfo& /*aAppInfo*/, Swi::TRevocationDialogMessage /*aMessage*/, RPointerArray<TOCSPOutcome>& /*aOutcomes*/, RPointerArray<Swi::CCertificateInfo>& /*aCertificates*/, TBool /*aWarningOnly*/)
       
   701 	{
       
   702 	TBool response = ETrue; // default behaviour is to continue the install
       
   703 	if (iVerbose)
       
   704 		{
       
   705 		// todo verbose mode
       
   706 		Stdout().Write(_L("TODO - CCmdSwi::DisplayOcspResultL\r\n"));
       
   707 		}
       
   708 	return response;	
       
   709 	}
       
   710 	
       
   711 void CSwiSisInstallerAO::DisplayCannotOverwriteFileL(const Swi::CAppInfo& /*aAppInfo*/, const Swi::CAppInfo& /*aInstalledAppInfo*/, const TDesC& aFileName)
       
   712 	{
       
   713 	if (iVerbose)
       
   714 		{
       
   715 		Stdout().Write(_L("\r\nCannot overwrite a file required for installation. Aborting -"));
       
   716 		Stdout().Write(aFileName);
       
   717 		Stdout().Write(_L(" - \r\n"));
       
   718 		}
       
   719 	}
       
   720 	
       
   721 TBool CSwiSisInstallerAO::DisplayMissingDependencyL(const Swi::CAppInfo& /*aAppInfo*/, const TDesC& aDependencyName, TVersion /*aWantedVersionFrom*/, TVersion /*aWantedVersionTo*/, TVersion /*aInstalledVersion*/)
       
   722 	{
       
   723 	TBool response = ETrue; // default behaviour is to continue the install
       
   724 	if (!iQuiet)
       
   725 		{
       
   726 		Stdout().Write(_L("Warning: Depedency is missing or has incorrect version - "));
       
   727 		Stdout().Write(aDependencyName);
       
   728 		Stdout().Write(_L(" - \r\n"));
       
   729 		}
       
   730 	return response;	
       
   731 	}
       
   732 	
       
   733 TBool CSwiSisInstallerAO::DisplayUninstallL(const Swi::CAppInfo& aAppInfo)
       
   734 	{
       
   735 	if (iVerbose)
       
   736 		{
       
   737 		TName myBuf;
       
   738 		myBuf.Format(_L("NAME:\t\t%S\r\n"), &aAppInfo.AppName());
       
   739 		Stdout().Write(myBuf);
       
   740 		myBuf.Format(_L("VENDOR:\t\t%S\r\n"), &aAppInfo.AppVendor());
       
   741 		Stdout().Write(myBuf);
       
   742 		myBuf.Format(_L("VERSION:\t%d.%d.%d\r\n"), aAppInfo.AppVersion().iMajor, aAppInfo.AppVersion().iMinor, aAppInfo.AppVersion().iBuild);
       
   743 		Stdout().Write(myBuf);
       
   744 		}
       
   745 	TBool response = ETrue; // default behaviour is to continue the uninstall
       
   746 	return response;	
       
   747 	}
       
   748 
       
   749 #ifndef SYMBIAN_JAVA_NOT_INCLUDED
       
   750 //
       
   751 // java ui installer
       
   752 //
       
   753 CSwiMidletInstallerAO* CSwiMidletInstallerAO::NewL(MCmdSwiParent& aParent, RFs& aFs, TBool aVerbose, TBool aQuiet)
       
   754 	{
       
   755 	CSwiMidletInstallerAO* self = new (ELeave) CSwiMidletInstallerAO(aParent, aFs, aVerbose, aQuiet);
       
   756 	CleanupStack::PushL(self);
       
   757 	self->ConstructL();
       
   758 	CleanupStack::Pop(self);
       
   759 	return self;
       
   760 	}
       
   761 
       
   762 CSwiMidletInstallerAO::CSwiMidletInstallerAO(MCmdSwiParent& aParent, RFs& aFs, TBool aVerbose, TBool aQuiet)
       
   763 	: CActive(CActive::EPriorityStandard), iParent(aParent), iFs(aFs), iVerbose(aVerbose), iQuiet(aQuiet)
       
   764 	{
       
   765 	CActiveScheduler::Add(this);
       
   766 	}
       
   767 
       
   768 CSwiMidletInstallerAO::~CSwiMidletInstallerAO()
       
   769 	{
       
   770 	Cancel();
       
   771 	if (iInstaller)
       
   772 		delete iInstaller;
       
   773 	if (iJadHandle)
       
   774 		iJadHandle->CloseFileHandle();
       
   775 	if (iJarHandle)
       
   776 		iJarHandle->CloseFileHandle();
       
   777 	if (iInfo)
       
   778 		delete iInfo;
       
   779 	if (iRemover)
       
   780 		delete iRemover;
       
   781 	}
       
   782 
       
   783 void CSwiMidletInstallerAO::ConstructL()
       
   784 	{
       
   785 	iInstaller = CJavaInstaller::NewL(*this, *this, KNullDesC8, EFalse, 0);
       
   786 	}
       
   787 
       
   788 TBool CSwiMidletInstallerAO::IsJad(TDes& aMidlet)
       
   789 	{
       
   790 	if (aMidlet.MatchF(KSwiJadExtension) > 0)
       
   791 		return ETrue;
       
   792 	return EFalse;
       
   793 	}
       
   794 
       
   795 TBool CSwiMidletInstallerAO::IsJar(TDes& aMidlet)
       
   796 	{
       
   797 	if (aMidlet.MatchF(KSwiJarExtension) > 0)
       
   798 		return ETrue;
       
   799 	return EFalse;
       
   800 	}
       
   801 
       
   802 void CSwiMidletInstallerAO::ListInstalledAppsL(TUid aAppUid, const TDesC& aMatchString)
       
   803 	{
       
   804 	MJavaRegistry* reg = MJavaRegistry::CreateL();
       
   805 	RArray<TUid> list;
       
   806 	TInt count = 0;
       
   807 	CleanupStack::PushL(reg);
       
   808 	if ((aAppUid.iUid != 0) && (reg->SuiteEntryExistsL(aAppUid)))
       
   809 		{
       
   810 		MJavaRegistrySuiteEntry* suite = reg->SuiteEntryL(aAppUid);
       
   811 		CleanupStack::PushL(suite);
       
   812 		suite->MIDletUidsL(list);
       
   813 		while (count < list.Count())
       
   814 			{
       
   815 			MJavaRegistryMIDletEntry* entry = reg->MIDletEntryL(list[count++]);
       
   816 			CleanupStack::PushL(entry);
       
   817 			DisplayPackageL(*entry);
       
   818 			CleanupStack::Pop(entry);
       
   819 			entry->Release();
       
   820 			}
       
   821 		CleanupStack::Pop(suite);
       
   822 		suite->Release();
       
   823 		}
       
   824 	else
       
   825 		{
       
   826 		reg->InstalledMIDletUidsL(list);
       
   827 		while (count < list.Count())
       
   828 			{
       
   829 			MJavaRegistryMIDletEntry* entry = reg->MIDletEntryL(list[count++]);
       
   830 			CleanupStack::PushL(entry);
       
   831 			if ((entry->MIDletNameL().MatchF(aMatchString)>=0) || (entry->SuiteEntryL().VendorL().MatchF(aMatchString)>=0))
       
   832 				{
       
   833 				DisplayPackageL(*entry);
       
   834 				}
       
   835 			CleanupStack::Pop(entry);
       
   836 			entry->Release();
       
   837 			}
       
   838 		}
       
   839 	CleanupStack::Pop(reg);
       
   840 	}
       
   841 
       
   842 //
       
   843 // CSwiMidleInstallerAO::DisplayPackageL
       
   844 // find information on the specified package uid and display it on the console
       
   845 //
       
   846 void CSwiMidletInstallerAO::DisplayPackageL(MJavaRegistryMIDletEntry& aPackage)
       
   847 	{
       
   848 	TName myBuf;
       
   849 	myBuf.Format(_L("\r\nNAME:\t%S\r\n"), &aPackage.MIDletNameL());
       
   850 	Stdout().Write(myBuf);
       
   851 	myBuf.Format(_L("VENDOR:\t%S\r\n"), &aPackage.SuiteEntryL().VendorL());
       
   852 	Stdout().Write(myBuf);
       
   853 	myBuf.Format(_L("UID:\t0x%x\r\n"), aPackage.SuiteEntryL().UidL());
       
   854 	Stdout().Write(myBuf);
       
   855 	}
       
   856 
       
   857 //
       
   858 // CSwiMidletInstallerAO::InstallL
       
   859 // installs a jar/jad midp 1.0/2.0-compatible midlet
       
   860 //
       
   861 void CSwiMidletInstallerAO::InstallL(TFileName& aInstallFile)
       
   862 	{
       
   863 	ASSERT(iInstaller);
       
   864 	ASSERT(!iInfo);
       
   865 	ASSERT(!iJarHandle);
       
   866 	ASSERT(!iJadHandle);
       
   867 	if (aInstallFile.Length() <= 0)
       
   868 		{
       
   869 		User::Leave(KErrNotFound);
       
   870 		}
       
   871 	if (iVerbose)
       
   872 		{
       
   873 		Stdout().Write(_L("Installing Midlet...\r\n"));
       
   874 		}
       
   875 	const TInt length = aInstallFile.Length() - 3; // the java midlet filename minus the jad/jar extension name
       
   876 	TFileName sisterFile(aInstallFile.Left(length));
       
   877 	if (IsJad(aInstallFile))
       
   878 		{
       
   879 		iJadHandle = CJavaFileHandle::NewL(iFs, aInstallFile, KNullDesC, KDefaultJadMimeType());
       
   880 		// name the associated jar file
       
   881 		sisterFile.Append(_L("jar"));
       
   882 		iJarHandle = CJavaFileHandle::NewL(iFs, sisterFile, KNullDesC, KDefaultJarMimeType());
       
   883 		}
       
   884 	else
       
   885 		{
       
   886 		ASSERT(IsJar(aInstallFile));
       
   887 		iJarHandle = CJavaFileHandle::NewL(iFs, aInstallFile, KNullDesC, KDefaultJarMimeType());
       
   888 		// name the associated jad file
       
   889 		sisterFile.Append(_L("jad"));
       
   890 		iJadHandle = CJavaFileHandle::NewL(iFs, sisterFile, KNullDesC, KDefaultJadMimeType());
       
   891 		}
       
   892 	iInfo = CMIDPInstallationLaunchInfo::NewL(iFs, *iJadHandle, *iJarHandle);
       
   893 	iInstaller->Install(*iInfo, iStatus);
       
   894 	SetActive();
       
   895 	}
       
   896 
       
   897 //
       
   898 // CSwiMidletInstallerAO::Uninstall
       
   899 // uninstalls a jar/jad midp 1.0/2.0-compatible midlet
       
   900 //
       
   901 void CSwiMidletInstallerAO::UninstallL(const TUid& aPackageUid)
       
   902 	{
       
   903 	ASSERT(!iRemover);
       
   904 	if (iVerbose)
       
   905 		{
       
   906 		Stdout().Write(_L("Removing Midlet...\r\n"));
       
   907 		}
       
   908 	iRemover = CJavaRemover::NewL(aPackageUid, *this);
       
   909 	iRemover->Remove(iStatus);
       
   910 	SetActive();
       
   911 	}
       
   912 
       
   913 void CSwiMidletInstallerAO::RunL()
       
   914 	{
       
   915 	iParent.Finished(iStatus.Int());
       
   916 	}
       
   917 
       
   918 void CSwiMidletInstallerAO::DoCancel()
       
   919 	{
       
   920 	ASSERT(iInstaller);
       
   921 	ASSERT(iRemover);
       
   922 	iInstaller->Cancel();
       
   923 	iRemover->Cancel();
       
   924 	iParent.Finished(KErrCancel);
       
   925 	}
       
   926 
       
   927 //
       
   928 // java installer UI hooks
       
   929 //
       
   930 TBool CSwiMidletInstallerAO::StartInstallL(const CMIDletSuiteAttributes& aMIDlet)
       
   931 	{
       
   932 	if (iVerbose)
       
   933 		{
       
   934 		TName myBuf;
       
   935 		myBuf.Format(_L("\r\nNAME:\t\t%S\r\n"), &aMIDlet.MIDletName());
       
   936 		Stdout().Write(myBuf);
       
   937 		myBuf.Format(_L("VENDOR:\t\t%S\r\n"), &aMIDlet.MIDletVendor());
       
   938 		Stdout().Write(myBuf);
       
   939 		myBuf.Format(_L("VERSION:\t%d.%d.%d\r\n"), aMIDlet.MIDletVersion().iMajor, aMIDlet.MIDletVersion().iMinor, aMIDlet.MIDletVersion().iBuild);
       
   940 		Stdout().Write(myBuf);
       
   941 		}
       
   942 	TBool response = ETrue; // default behaviour is to continue the install
       
   943 	return response;
       
   944 	}
       
   945 
       
   946 TBool CSwiMidletInstallerAO::SelectDriveL(const CMIDletSuiteAttributes& /*aMIDlet*/, TInt aSpaceRequired, TChar& aDrive, TBool& aSufficientSpace)
       
   947 	{
       
   948 	aSufficientSpace = ETrue;
       
   949 	aDrive = 'c';
       
   950 	if (iQuiet)
       
   951 		{
       
   952 		// Default to CWD drive if writeable
       
   953 		TFileName sessionPath;
       
   954 		TInt err = iFs.SessionPath(sessionPath);
       
   955 		if (err == KErrNone)
       
   956 			{
       
   957 			TChar drive = sessionPath[0];
       
   958 			drive.LowerCase();
       
   959 			TVolumeInfo volInfo;
       
   960 			if (iFs.Volume(volInfo, ((TUint)drive)-'a') == KErrNone && volInfo.iFree >= aSpaceRequired && !(volInfo.iDrive.iDriveAtt & KDriveAttRom) && !(volInfo.iDrive.iMediaAtt & KMediaAttWriteProtected))
       
   961 				{
       
   962 				aDrive = drive;
       
   963 				}
       
   964 			}
       
   965 		}
       
   966 	else
       
   967 		{
       
   968 		// ask the question
       
   969 		TBuf<128> info;
       
   970 		info.Format(_L("Midlet requires %d bytes free space. Please select installation drive:\r\n"), aSpaceRequired);
       
   971 		Stdout().Write(info);
       
   972 
       
   973 		// cycle through drive list checking for existing drive
       
   974 		TDriveList drives;
       
   975 		TVolumeInfo volume;
       
   976 		TChar driveChar;
       
   977 		TBool displayed = EFalse;
       
   978 		User::LeaveIfError(iFs.DriveList(drives));
       
   979 		for (TInt ii = 0 ; ii < KMaxDrives ; ii++)
       
   980 			{
       
   981 			if (drives[ii])
       
   982 				{
       
   983 				// drive exists
       
   984 				if (KErrNone == iFs.Volume(volume, ii))
       
   985 					{
       
   986 					// drive is present
       
   987 					if (volume.iFree >= aSpaceRequired)
       
   988 						{
       
   989 						// drive has sufficient space
       
   990 						aSufficientSpace = ETrue;
       
   991 						if (!(volume.iDrive.iDriveAtt & KDriveAttRom) && 
       
   992 							!(volume.iDrive.iMediaAtt & KMediaAttWriteProtected))
       
   993 							{
       
   994 							// drive is not a rom drive and is not write protected
       
   995 							User::LeaveIfError(iFs.DriveToChar(ii, driveChar));
       
   996 							info.Format(_L("%d. \'"), ii);		// drive number
       
   997 							info.Append(driveChar);		// drive letter
       
   998 							info.Append(_L("\' "));
       
   999 							info.AppendNum(volume.iFree); // free space
       
  1000 							info.Append(_L(" bytes free\r\n"));
       
  1001 							Stdout().Write(info);
       
  1002 							displayed = ETrue;
       
  1003 							}
       
  1004 						}
       
  1005 					}
       
  1006 				}
       
  1007 			}
       
  1008 		// get the answer
       
  1009 		if (displayed)
       
  1010 			{
       
  1011 			TUserInput in;
       
  1012 			User::LeaveIfError(Stdin().Read(in));
       
  1013 			TLex lex(in);
       
  1014 			TInt response;
       
  1015 			User::LeaveIfError(lex.Val(response));
       
  1016 			User::LeaveIfError(iFs.DriveToChar(response, aDrive));
       
  1017 			}
       
  1018 		else
       
  1019 			{
       
  1020 			Stdout().Write(_L("Error. No drives capable of supporting midlet install. Aborting\r\n"));
       
  1021 			return EFalse;
       
  1022 			}
       
  1023 		}
       
  1024 	return ETrue;
       
  1025 	}
       
  1026 
       
  1027 TBool CSwiMidletInstallerAO::ReplaceExistingMIDletL(const CMIDletSuiteAttributes& /*aMIDlet*/, const TAppVersion& /*aOldVersion*/)
       
  1028 	{
       
  1029 	TBool response = ETrue; // default behaviour is to continue the install
       
  1030 	if (!iQuiet)
       
  1031 		{
       
  1032 		Stdout().Write(_L("Do you wish to replace the existing midlet [y/n]?\r\n"));
       
  1033 		response = iParent.GetAnswer();
       
  1034 		}
       
  1035 	return response;
       
  1036 	}
       
  1037 	
       
  1038 TBool CSwiMidletInstallerAO::UpgradeRMSL(const CMIDletSuiteAttributes& /*aMIDlet*/, const TAppVersion& /*aOldVersion*/)
       
  1039 	{
       
  1040 	TBool response = ETrue; // default behaviour is to continue the install
       
  1041 	if (!iQuiet)
       
  1042 		{
       
  1043 		Stdout().Write(_L("Do you wish to upgrade the existing midlet [y/n]?\r\n"));
       
  1044 		response = iParent.GetAnswer();
       
  1045 		}
       
  1046 	return response;
       
  1047 	}
       
  1048 
       
  1049 TBool CSwiMidletInstallerAO::MIDletUntrustedL(const CMIDletSuiteAttributes& /*aMIDlet*/)
       
  1050 	{
       
  1051 	TBool response = ETrue; // default behaviour is to continue the install
       
  1052 	if (!iQuiet)
       
  1053 		{
       
  1054 		Stdout().Write(_L("\r\nMidlet is untrusted. Continue installing [y/n]?\r\n"));
       
  1055 		response = iParent.GetAnswer();
       
  1056 		}
       
  1057 	return response;
       
  1058 	}
       
  1059 
       
  1060 void CSwiMidletInstallerAO::CertificateHasNoRootL(const CMIDletSuiteAttributes& /*aMIDlet*/, const CPKIXCertChain& /*aCertChain*/, const CPKIXValidationResult& /*aValidationResult*/)
       
  1061 	{
       
  1062 	Stderr().Write(_L("\r\nCertificate attached to midlet has no identifiable root. Aborting installation.\r\n"));
       
  1063 	}
       
  1064 
       
  1065 void CSwiMidletInstallerAO::BadSignatureL(const CMIDletSuiteAttributes& /*aMIDlet*/, const CPKIXCertChain& /*aCertChain*/, const CPKIXValidationResult& /*aValidationResult*/)
       
  1066 	{
       
  1067 	if (iVerbose)
       
  1068 		{
       
  1069 		Stdout().Write(_L("\r\nWarning: Midlet certificate chain is incomplete. Continuing installation\r\n"));
       
  1070 		}
       
  1071 	}
       
  1072 
       
  1073 TBool CSwiMidletInstallerAO::PerformRevocationCheckL(TBool& aDoCheck)
       
  1074 	{
       
  1075 	aDoCheck = EFalse;
       
  1076 	return ETrue;
       
  1077 	}
       
  1078 
       
  1079 void CSwiMidletInstallerAO::StartRevocationCheckL()
       
  1080 	{
       
  1081 	if (iVerbose)
       
  1082 		{
       
  1083 		Stdout().Write(_L("\r\nStarted: Revocation check\r\n"));
       
  1084 		}
       
  1085 	}
       
  1086 
       
  1087 void CSwiMidletInstallerAO::FinishedRevocationCheckL()
       
  1088 	{
       
  1089 	if (iVerbose)
       
  1090 		{
       
  1091 		Stdout().Write(_L("\r\nFinished: Revocation check\r\n"));
       
  1092 		}
       
  1093 	}
       
  1094 
       
  1095 void CSwiMidletInstallerAO::StartIconConversionL()
       
  1096 	{
       
  1097 	}
       
  1098 
       
  1099 void CSwiMidletInstallerAO::FinishedIconConversionL()
       
  1100 	{
       
  1101 	}
       
  1102 
       
  1103 TBool CSwiMidletInstallerAO::OCSPWarningL(const CMIDletSuiteAttributes& /*aMIDlet*/, TRevocationMsg /*aRevocationMsg*/, const TOCSPOutcome* /*aOCSPOutcome*/)
       
  1104 	{
       
  1105 	if (iVerbose)
       
  1106 		{
       
  1107 		Stdout().Write(_L("\r\nWarning: OCSP failure. Continuing installation.\r\n"));
       
  1108 		}
       
  1109 	return ETrue;
       
  1110 	}
       
  1111 
       
  1112 void CSwiMidletInstallerAO::OCSPErrorL(const CMIDletSuiteAttributes& /*aMIDlet*/, TRevocationMsg /*aRevocationMsg*/, const TOCSPOutcome* /*aOCSPOutcome*/)
       
  1113 	{
       
  1114 	Stderr().Write(_L("\r\nOCSP Error. Aborting installation.\r\n"));
       
  1115 	}
       
  1116 
       
  1117 TBool CSwiMidletInstallerAO::MIDletInUseL(const CMIDletSuiteAttributes& /*aMIDlet*/)
       
  1118 	{
       
  1119 	TBool response = EFalse; // EFalse indicates we don't continue with uninstallation
       
  1120 	if (!iQuiet)
       
  1121 		{
       
  1122 		// print the question
       
  1123 		Stdout().Write(_L("\r\nMidlet is currently open. Continue installing? [y/n]\r\n"));
       
  1124 		
       
  1125 		// get the answer
       
  1126 		TUserInput in;
       
  1127 		const TInt error = Stdin().Read(in);
       
  1128 		if ((error == KErrNone) && (in.MatchF(KSwiYes) == 0))
       
  1129 			{
       
  1130 			response = ETrue;
       
  1131 			}
       
  1132 		}
       
  1133 	if (!response)
       
  1134 		{
       
  1135 		Stderr().Write(_L("Uninstall aborted. Midlet has not been closed.\r\n"));
       
  1136 		}
       
  1137 	return response;
       
  1138 	}
       
  1139 
       
  1140 void CSwiMidletInstallerAO::OTAReportResponseL(TInt aOTAResponseCode, const TDesC& /*aReportBody*/)
       
  1141 	{
       
  1142 	if (iVerbose)
       
  1143 		{
       
  1144 		switch (aOTAResponseCode)
       
  1145 			{
       
  1146 			case CJavaMIDletInstallationResult::EOkay:
       
  1147 				Stdout().Write(_L("\r\nComplete\r\n"));
       
  1148 			break;
       
  1149 			
       
  1150 			default:
       
  1151 				Stdout().Write(_L("Abort\r\n"));
       
  1152 			break;
       
  1153 			};
       
  1154 		}
       
  1155 	}
       
  1156 
       
  1157 TInt CSwiMidletInstallerAO::CopyStarted(TInt /*aSize*/)
       
  1158 	{
       
  1159 	return KErrNone;
       
  1160 	}
       
  1161 
       
  1162 TInt CSwiMidletInstallerAO::DownloadStarted(TInt /*aSize*/)
       
  1163 	{
       
  1164 	if (iVerbose)
       
  1165 		{
       
  1166 		Stdout().Write(_L("Downloading midlet\r\n"));
       
  1167 		}
       
  1168 	return KErrNone;
       
  1169 	}
       
  1170 
       
  1171 TInt CSwiMidletInstallerAO::UpdateProgress(TInt /*aSize*/)
       
  1172 	{
       
  1173 	if (iVerbose)
       
  1174 		{
       
  1175 		Stdout().Write(_L("."));
       
  1176 		}
       
  1177 	return KErrNone;
       
  1178 	}
       
  1179 
       
  1180 TBool CSwiMidletInstallerAO::GetUsernamePasswordL(HBufC8*& /*aUsername*/, HBufC8*& /*aPassword*/)
       
  1181 	{
       
  1182 	if (iVerbose)
       
  1183 		{
       
  1184 		Stdout().Write(_L("\r\nTODO: CCmdSwi::GetUsernamePasswordL\r\n"));
       
  1185 		}
       
  1186 	return EFalse;
       
  1187 	}
       
  1188 
       
  1189 TBool CSwiMidletInstallerAO::ConfirmRemovalL(const TDesC& /*aRemovalMessage*/)
       
  1190 	{
       
  1191 	TBool response = ETrue; // default behaviour is to continue the uninstall
       
  1192 	return response;	
       
  1193 	}
       
  1194 
       
  1195 void CSwiMidletInstallerAO::InitialiseProgressBarL(TInt /*aMaximumLength*/)
       
  1196 	{
       
  1197 	}
       
  1198 
       
  1199 void CSwiMidletInstallerAO::UpdateProgressBarL(TInt /*aUnits*/)
       
  1200 	{
       
  1201 	if (iVerbose)
       
  1202 		{
       
  1203 		Stdout().Write(_L("."));
       
  1204 		}
       
  1205 	}
       
  1206 
       
  1207 TBool CSwiMidletInstallerAO::MIDletInUseL()
       
  1208 	{
       
  1209 	TBool response = EFalse; // EFalse indicates we don't continue with uninstallation
       
  1210 	if (!iQuiet)
       
  1211 		{
       
  1212 		// print the question
       
  1213 		Stdout().Write(_L("\r\nApplication is currently open. Continue uninstalling? [y/n]\r\n"));
       
  1214 		
       
  1215 		// get the answer
       
  1216 		TUserInput in;
       
  1217 		const TInt error = Stdin().Read(in);
       
  1218 		if ((error == KErrNone) && (in.MatchF(KSwiYes) == 0))
       
  1219 			{
       
  1220 			response = ETrue;
       
  1221 			}
       
  1222 		}
       
  1223 	return response;
       
  1224 	}
       
  1225 
       
  1226 TBool CSwiMidletInstallerAO::FileInUseL(const TDesC& /*aFileName*/)
       
  1227 	{
       
  1228 	TBool response = EFalse; // EFalse indicates we don't continue with uninstallation
       
  1229 	if (!iQuiet)
       
  1230 		{
       
  1231 		// print the question
       
  1232 		Stdout().Write(_L("\r\nApplication has a file handle open. Continue uninstalling? [y/n]\r\n"));
       
  1233 		
       
  1234 		// get the answer
       
  1235 		TUserInput in;
       
  1236 		const TInt error = Stdin().Read(in);
       
  1237 		if ((error == KErrNone) && (in.MatchF(KSwiYes) == 0))
       
  1238 			{
       
  1239 			response = ETrue;
       
  1240 			}
       
  1241 		}
       
  1242 	return response;
       
  1243 	}
       
  1244 
       
  1245 #endif //  SYMBIAN_JAVA_NOT_INCLUDED
       
  1246 
       
  1247 #ifdef EXE_BUILD
       
  1248 EXE_BOILER_PLATE(CCmdSwi)
       
  1249 #endif
       
  1250