commands/swi/swi.h
changeset 0 7f656887cf89
child 6 96d581d2147d
equal deleted inserted replaced
-1:000000000000 0:7f656887cf89
       
     1 // swi.h
       
     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 #ifndef _SWI_CMD_
       
    14 #define _SWI_CMD_
       
    15 
       
    16 #include <fshell/ioutils.h>
       
    17 #include <e32cmn.h>
       
    18 #include <swi/asynclauncher.h>
       
    19 #include <swi/sisregistrysession.h>
       
    20 #include <swi/sisregistryentry.h>
       
    21 #include <swi/sisregistrypackage.h>
       
    22 
       
    23 #ifndef SYMBIAN_JAVA_NOT_INCLUDED
       
    24 	#include <midpinstallationlaunchinfo.h>
       
    25 	#include <midletsuiteattributes.h>
       
    26 	#include <javafilehandle.h>
       
    27 	#include <javainstaller.h>
       
    28 	#include <javaremover.h>
       
    29 	#include <mjavainstallerui.h>
       
    30 	#include <mjardownloaderui.h>
       
    31 	#include <mjavaregistry.h>
       
    32 #endif // SYMBIAN_JAVA_NOT_INCLUDED
       
    33 
       
    34 using namespace IoUtils;
       
    35 using namespace Swi;
       
    36 
       
    37 //
       
    38 // MCmdSwiParent
       
    39 //
       
    40 class MCmdSwiParent
       
    41 	{
       
    42 public:
       
    43 	virtual RIoConsoleReadHandle& Input() = 0;
       
    44 	virtual RIoConsoleWriteHandle& Output(TInt aError = KErrNone) = 0;
       
    45 	virtual void Finished(const TInt aError) = 0;
       
    46 	virtual TBool GetAnswer() = 0;
       
    47 	};
       
    48 
       
    49 #ifndef SYMBIAN_JAVA_NOT_INCLUDED
       
    50 	//
       
    51 	// CSwiMidletInstallerAO
       
    52 	// active object managing the actual installation/uninstallation of jar/jad files
       
    53 	//
       
    54 	class CSwiMidletInstallerAO : public CActive, public MJavaInstallerUI, public MJarDownloaderUI, public MJavaRemoverUI
       
    55 		{
       
    56 	public:
       
    57 		static CSwiMidletInstallerAO* NewL(MCmdSwiParent& aParent, RFs& aFs, TBool aVerbose, TBool aQuiet);
       
    58 		~CSwiMidletInstallerAO();
       
    59 		
       
    60 		void InstallL(TFileName& aInstallFile);
       
    61 		void UninstallL(const TUid& aPackageUid);
       
    62 		void ListInstalledAppsL(TUid aAppUid, const TDesC& aMatchString);
       
    63 		TBool IsJad(TDes& aMidlet);
       
    64 		TBool IsJar(TDes& aMidlet);
       
    65 	
       
    66 		// java UI handlers
       
    67 		virtual TBool StartInstallL(const CMIDletSuiteAttributes& aMIDlet);
       
    68 		virtual TBool SelectDriveL(const CMIDletSuiteAttributes& aMIDlet, TInt aSpaceRequired, TChar& aDrive, TBool& aSufficientSpace);
       
    69 		virtual TBool ReplaceExistingMIDletL(const CMIDletSuiteAttributes& aMIDlet, const TAppVersion& aOldVersion);
       
    70 		virtual TBool UpgradeRMSL(const CMIDletSuiteAttributes& aMIDlet, const TAppVersion& aOldVersion);
       
    71 		virtual TBool MIDletUntrustedL(const CMIDletSuiteAttributes& aMIDlet);
       
    72 		virtual void CertificateHasNoRootL(const CMIDletSuiteAttributes& aMIDlet, const CPKIXCertChain& aCertChain, const CPKIXValidationResult& aValidationResult);
       
    73 		virtual void BadSignatureL(const CMIDletSuiteAttributes& aMIDlet, const CPKIXCertChain& aCertChain, const CPKIXValidationResult& aValidationResult);
       
    74 		virtual TBool PerformRevocationCheckL(TBool& aDoCheck);
       
    75 		virtual void StartRevocationCheckL();
       
    76 		virtual void FinishedRevocationCheckL();
       
    77 		virtual void StartIconConversionL();
       
    78 		virtual void FinishedIconConversionL();
       
    79 		virtual TBool OCSPWarningL(const CMIDletSuiteAttributes& aMIDlet, TRevocationMsg aRevocationMsg, const TOCSPOutcome* aOCSPOutcome);
       
    80 		virtual void OCSPErrorL(const CMIDletSuiteAttributes& aMIDlet, TRevocationMsg aRevocationMsg, const TOCSPOutcome* aOCSPOutcome);
       
    81 		virtual TBool MIDletInUseL(const CMIDletSuiteAttributes& aMIDlet);
       
    82 		virtual void OTAReportResponseL(TInt aOTAResponseCode, const TDesC& aReportBody);
       
    83 		virtual TInt CopyStarted(TInt aSize);
       
    84 		virtual TInt DownloadStarted(TInt aSize);
       
    85 		virtual TInt UpdateProgress(TInt aSize);
       
    86 		virtual TBool GetUsernamePasswordL(HBufC8*& aUsername, HBufC8*& aPassword);	
       
    87 		virtual TBool ConfirmRemovalL(const TDesC& aRemovalMessage);
       
    88 		virtual void InitialiseProgressBarL(TInt aMaximumLength);
       
    89 		virtual void UpdateProgressBarL(TInt aUnits);
       
    90 		virtual TBool MIDletInUseL();
       
    91 		virtual TBool FileInUseL(const TDesC& aFileName);
       
    92 	private:
       
    93 		CSwiMidletInstallerAO(MCmdSwiParent& aParent, RFs& aFs, TBool aVerbose, TBool aQuiet);
       
    94 		void ConstructL();
       
    95 		void DisplayPackageL(MJavaRegistryMIDletEntry& aPackage);
       
    96 		
       
    97 		inline RIoConsoleReadHandle& Stdin(){return iParent.Input();}
       
    98 		inline RIoConsoleWriteHandle& Stdout(){return iParent.Output();}
       
    99 		inline RIoConsoleWriteHandle& Stderr(){return iParent.Output(KErrGeneral);}
       
   100 	
       
   101 		// from CActive
       
   102 		void DoCancel();
       
   103 		void RunL();
       
   104 	private:
       
   105 		MCmdSwiParent& iParent;
       
   106 		RFs& iFs;
       
   107 		TBool iVerbose;
       
   108 		TBool iQuiet;
       
   109 		CJavaInstaller* iInstaller;
       
   110 		CJavaFileHandle* iJadHandle;
       
   111 		CJavaFileHandle* iJarHandle;
       
   112 		CMIDPInstallationLaunchInfo* iInfo;
       
   113 		CJavaRemover* iRemover;
       
   114 		};
       
   115 #endif // SYMBIAN_JAVA_NOT_INCLUDED
       
   116 
       
   117 //
       
   118 // CSwiSisInstallerAO
       
   119 // active object managing the actual installation/uninstallation of sis files
       
   120 //
       
   121 class CSwiSisInstallerAO : public CActive, public Swi::MUiHandler
       
   122 	{
       
   123 public:
       
   124 	static CSwiSisInstallerAO* NewL(MCmdSwiParent& aParent, RFs& aFs, TBool aVerbose, TBool aQuiet);
       
   125 	~CSwiSisInstallerAO();
       
   126 	
       
   127 	// user commands
       
   128 	void InstallL(TFileName& aInstallFile);
       
   129 	void UninstallL(const TUid& aPackageUid);
       
   130 	void ListInstalledAppsL(const TUid& aAppUid, const TDesC& aMatchString);
       
   131 	
       
   132 	// Swi UI handlers
       
   133 	virtual TBool DisplayTextL(const Swi::CAppInfo& aAppInfo, Swi::TFileTextOption aOption, const TDesC& aText);
       
   134 	virtual void DisplayErrorL(const Swi::CAppInfo& aAppInfo, Swi::TErrorDialog aType, const TDesC& aParam);
       
   135 	virtual TBool DisplayDependencyBreakL(const Swi::CAppInfo& aAppInfo, const RPointerArray<TDesC>& aComponents);
       
   136 	virtual TBool DisplayApplicationsInUseL(const Swi::CAppInfo& aAppInfo, const RPointerArray<TDesC>& aAppNames);
       
   137 	virtual TBool DisplayQuestionL(const Swi::CAppInfo& aAppInfo, Swi::TQuestionDialog aQuestion, const TDesC& aDes=KNullDesC);
       
   138 	virtual TBool DisplayInstallL(const Swi::CAppInfo& aAppInfo, const CApaMaskedBitmap* aLogo, const RPointerArray<Swi::CCertificateInfo>& aCertificates);
       
   139 	virtual TBool DisplayGrantCapabilitiesL(const Swi::CAppInfo& aAppInfo, const TCapabilitySet& aCapabilitySet);
       
   140 	virtual TInt DisplayLanguageL(const Swi::CAppInfo& aAppInfo, const RArray<TLanguage>& aLanguages);
       
   141 	virtual TInt DisplayDriveL(const Swi::CAppInfo& aAppInfo, TInt64 aSize, const RArray<TChar>& aDriveLetters, const RArray<TInt64>& aDriveSpaces);
       
   142 	virtual TBool DisplayUpgradeL(const Swi::CAppInfo& aAppInfo, const Swi::CAppInfo& aExistingAppInfo);
       
   143 	virtual TBool DisplayOptionsL(const Swi::CAppInfo& aAppInfo, const RPointerArray<TDesC>& aOptions, RArray<TBool>& aSelections);
       
   144 	virtual TBool HandleInstallEventL(const Swi::CAppInfo& aAppInfo, Swi::TInstallEvent aEvent, TInt aValue=0, const TDesC& aDes=KNullDesC);
       
   145 	virtual void HandleCancellableInstallEventL(const Swi::CAppInfo& aAppInfo, Swi::TInstallCancellableEvent aEvent, Swi::MCancelHandler& aCancelHandler, TInt aValue=0, const TDesC& aDes=KNullDesC);
       
   146 	virtual TBool DisplaySecurityWarningL(const Swi::CAppInfo& aAppInfo, Swi::TSignatureValidationResult aSigValidationResult, RPointerArray<CPKIXValidationResultBase>& aPkixResults, RPointerArray<Swi::CCertificateInfo>& aCertificates, TBool aInstallAnyway);
       
   147 	virtual TBool DisplayOcspResultL(const Swi::CAppInfo& aAppInfo, Swi::TRevocationDialogMessage aMessage, RPointerArray<TOCSPOutcome>& aOutcomes, RPointerArray<Swi::CCertificateInfo>& aCertificates, TBool aWarningOnly);
       
   148 	virtual void DisplayCannotOverwriteFileL(const Swi::CAppInfo& aAppInfo, const Swi::CAppInfo& aInstalledAppInfo, const TDesC& aFileName);
       
   149 	virtual TBool DisplayMissingDependencyL(const Swi::CAppInfo& aAppInfo, const TDesC& aDependencyName, TVersion aWantedVersionFrom, TVersion aWantedVersionTo, TVersion aInstalledVersion);
       
   150 	virtual TBool DisplayUninstallL(const Swi::CAppInfo& aAppInfo);
       
   151 private:
       
   152 	CSwiSisInstallerAO(MCmdSwiParent& aParent, RFs& aFs, TBool aVerbose, TBool aQuiet);
       
   153 	void ConstructL();
       
   154 	
       
   155 	void PrintDetails(Swi::CSisRegistryPackage& aPackage);
       
   156 	void DisplayPackageL(const TUid& aPackageUid);
       
   157 	Swi::CSisRegistryPackage* GetSisRegistryPackageL(const TUid& aPackageUid);
       
   158 
       
   159 	inline RIoConsoleReadHandle& Stdin(){return iParent.Input();}
       
   160 	inline RIoConsoleWriteHandle& Stdout(){return iParent.Output();}
       
   161 	inline RIoConsoleWriteHandle& Stderr(){return iParent.Output(KErrGeneral);}
       
   162 		
       
   163 	// from CActive
       
   164 	void DoCancel();
       
   165 	void RunL();
       
   166 private:
       
   167 	MCmdSwiParent& iParent;
       
   168 	TBool iVerbose;
       
   169 	TBool iQuiet;
       
   170 	CAsyncLauncher* iLauncher;
       
   171 	Swi::RSisRegistrySession iRegistrySession;
       
   172 	Swi::CInstallPrefs* iPrefs;
       
   173 	Swi::CSisRegistryPackage* iRegPackage;
       
   174 	TChar iCurrentDrive;
       
   175 	};
       
   176 
       
   177 //
       
   178 // CCmdSwi
       
   179 // Fshell-console based class handling swi related functionality
       
   180 //
       
   181 class CCmdSwi : public CCommandBase, public MCmdSwiParent
       
   182 	{
       
   183 public:
       
   184 	static CCommandBase* NewLC();
       
   185 	~CCmdSwi();
       
   186 private:
       
   187 	CCmdSwi();
       
   188 
       
   189 	// utilities
       
   190 	TBool IsMidlet();
       
   191 	
       
   192 	// fshell hooks
       
   193 	virtual const TDesC& Name() const;
       
   194 	virtual void DoRunL();
       
   195 	virtual void ArgumentsL(RCommandArgumentList& aArguments);
       
   196 	virtual void OptionsL(RCommandOptionList& aOptions);
       
   197 		
       
   198 	// MCmdSwiParent hooks 	
       
   199 	virtual RIoConsoleReadHandle& Input();
       
   200 	virtual RIoConsoleWriteHandle& Output(TInt aError);
       
   201 	virtual void Finished(const TInt aError);
       
   202 	virtual TBool GetAnswer();
       
   203 private:
       
   204 #ifndef SYMBIAN_JAVA_NOT_INCLUDED
       
   205 	CSwiMidletInstallerAO* iMidletHandler;
       
   206 #endif
       
   207 	CSwiSisInstallerAO* iSisHandler;
       
   208 	TFileName2 iSisFile;
       
   209 	enum 
       
   210 		{
       
   211 		EList,
       
   212 		EInstall,
       
   213 		EUninstall,
       
   214 		} iCommand;
       
   215 	TUid iUid;
       
   216 	HBufC* iMatch;
       
   217 	TBool iVerbose;
       
   218 	TBool iQuiet;
       
   219 	};
       
   220 
       
   221 #endif // _SWI_CMD_