smartinstaller/adm/inc/ADMAppUi.h
branchADM
changeset 48 364021cecc90
equal deleted inserted replaced
47:3f419852be07 48:364021cecc90
       
     1 /*
       
     2 * Copyright (c) 2009-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: 
       
    15 *     Declares UI class for application.
       
    16 *
       
    17 *
       
    18 */
       
    19 
       
    20 
       
    21 #ifndef __ADMAPPUI_h__
       
    22 #define __ADMAPPUI_h__
       
    23 
       
    24 // INCLUDE FILES
       
    25 #include <aknappui.h>
       
    26 #include <aknglobalnote.h>
       
    27 #include <aknglobalconfirmationquery.h>
       
    28 #include <etelmm.h>
       
    29 #include <flogger.h>
       
    30 #include "progressdialog.h"
       
    31 #include "globalwaitnote.h"
       
    32 #include "globalqueryobserver.h"
       
    33 #include "ADMDownloadHandler.h"
       
    34 #include "ADMInstallManager.h"
       
    35 #include "networkstatusobserver.h"
       
    36 
       
    37 #include "debug.h"
       
    38 
       
    39 _LIT(KADMPrivatePath, "c:\\private\\2002CCCE\\");
       
    40 _LIT(KADMResumeInfoFile, "c:\\private\\2002CCCE\\resume");
       
    41 
       
    42 // FORWARD DECLARATIONS
       
    43 class CEikonEnv;
       
    44 class CStateMachine;
       
    45 class CDepTree;
       
    46 class CXmlParser;
       
    47 class CSisParser;
       
    48 class CPackageInfo;
       
    49 class CAknGlobalNote;
       
    50 class CGlobalQueryObserver;
       
    51 class CGlobalWaitNoteObserver;
       
    52 class CNetworkStatusListener;
       
    53 
       
    54 enum TExitReason
       
    55 	{
       
    56 	EExitNoError = 0,
       
    57 	EUserCancelled,
       
    58 	EDownloadFailed,
       
    59 	EInsufficientMemory,
       
    60 	EDeviceNotSupported,       // 5
       
    61 	EInstallationFailed,
       
    62 	EInvalidBootstrapVersion,
       
    63 	ERootInstallationFailed,
       
    64 
       
    65 	ELastExitState
       
    66 	};
       
    67 
       
    68 // Maximum length of the size prefix ("kB", "MB", "GB"). Must match resource
       
    69 // file definition (TBUF16).
       
    70 const TInt KMaxPrefixLen = 16;
       
    71 
       
    72 // CLASS DECLARATION
       
    73 /**
       
    74  * CADMAppUi application UI class.
       
    75  * Interacts with the user through the UI and request message processing
       
    76  * from the handler class
       
    77  */
       
    78 class CADMAppUi : public CAknAppUi,
       
    79 	public CGlobalQueryObserver::MGlobalQueryClient,
       
    80 	public CProgressDialog::MProgressDialogClient,
       
    81 	public CGlobalWaitNote::MGlobalWaitNoteClient
       
    82 	{
       
    83 public:
       
    84 	// Constructors and destructor
       
    85 
       
    86 	/**
       
    87 	 * ConstructL.
       
    88 	 * 2nd phase constructor.
       
    89 	 */
       
    90 	void ConstructL();
       
    91 
       
    92 	/**
       
    93 	 * CADMAppUi.
       
    94 	 * C++ default constructor. This needs to be public due to
       
    95 	 * the way the framework constructs the AppUi
       
    96 	 */
       
    97 	CADMAppUi();
       
    98 
       
    99 	/**
       
   100 	 * ~CADMAppUi.
       
   101 	 * Virtual Destructor.
       
   102 	 */
       
   103 	virtual ~CADMAppUi();
       
   104 
       
   105 	/**
       
   106 	* Handle the Global Query Response
       
   107 	*/
       
   108 	void HandleGlobalQueryResponseL(const TInt aResponse);
       
   109 
       
   110 	// Returns EikonEnv
       
   111 	inline CEikonEnv* EikonEnv() const { return iEikonEnv; }
       
   112 
       
   113 	// -------------------------------------------------------------------------
       
   114 	// Interfaces for CStateFactory
       
   115 	/**
       
   116 	 * Displays proper error dialogs before starting the cleanups.
       
   117 	 * This function MUST NOT LEAVE.
       
   118 	 */
       
   119 	void HandleFailure();
       
   120 
       
   121 	/**
       
   122 	 * Shows the final error message, if any, and exits the application.
       
   123 	 */
       
   124 	void ExitApp();
       
   125 
       
   126 	/**
       
   127 	 * Shows the progress bar.
       
   128 	 */
       
   129 	void ShowGlobalProgressL(const TInt aResourceId, const TInt aStartValue, const TInt aEndValue, const TInt aCurrent = -1, const TInt aLast = -1);
       
   130 
       
   131 	/**
       
   132 	 * Shows global error dialog with 'OK' CBA.
       
   133 	 */
       
   134 	void ShowGlobalErrorQueryL(const TInt aResourceId);
       
   135 
       
   136 	/**
       
   137 	 * Display global query seeking user permission
       
   138 	 * to fetch dependencies from the web server.
       
   139 	 */
       
   140 	void ShowDownloadQueryL(const TInt aResourceId, const TInt aInfoResourceId = -1);
       
   141 
       
   142 	/**
       
   143 	 * Shows the application launch confirmation prompt.
       
   144 	 */
       
   145 	void ShowLaunchPromptL(const TDesC& aAppName, const TDesC& aIconFilename = KNullDesC);
       
   146 
       
   147 	/**
       
   148 	 * Deletes a file pointed by aFilename.
       
   149 	 */
       
   150 	void DeleteFile(const TDesC& aFilename);
       
   151 
       
   152 	// -------------------------------------------------------------------------
       
   153 
       
   154 private:
       
   155 	// Functions from base classes
       
   156 
       
   157 	/**
       
   158 	 * From CEikAppUi, HandleCommandL.
       
   159 	 * Takes care of command handling.
       
   160 	 * @param aCommand Command to be handled.
       
   161 	 */
       
   162 	void HandleCommandL(TInt aCommand);
       
   163 
       
   164 	/**
       
   165 	 * Window server event. Handles key presses.
       
   166 	 */
       
   167 	void HandleWsEventL( const TWsEvent& aEvent, CCoeControl* aDestination );
       
   168 
       
   169 	//From MProgressDialogClient
       
   170 	void ProgressDialogCancelled();
       
   171 	void WaitNoteCancelled();
       
   172 
       
   173 	TInt ShowGlobalNoteL( const TAknGlobalNoteType aType , const TInt aResourceId );
       
   174 	TInt ShowExitNoteL();
       
   175 	void ShowWaitNoteL( const TInt aResourceId, const TBool aCancellable, const TInt aDetailedResourceId = -1 );
       
   176 	void ShowWaitNoteNumL( const TInt aResourceId, const TInt aCurrent, const TInt aLast );
       
   177 	void CancelWaitNote();
       
   178 	void CancelProgressBar();
       
   179 	void ProcessCommandLineArgsL();
       
   180 
       
   181 	/**
       
   182 	 * Verifies available disk space.
       
   183 	 *
       
   184 	 * Returns true, if enough disk space is available
       
   185 	 */
       
   186 	TBool VerifyAvailableDiskSpaceL();
       
   187 
       
   188 	/**
       
   189 	 * Pretty prints aSize to aDescr and prefixes it with kB, MB or GB
       
   190 	 * depending on the value of aSize.
       
   191 	 */
       
   192 	void PrettyPrint(const TUint32 aSize, TDes &aDescr);
       
   193 
       
   194 	/**
       
   195 	 * Reads the resources.
       
   196 	 *
       
   197 	 * Leaves with standard error codes, if it encounters errors.
       
   198 	 */
       
   199 	void ReadStaticResourcesL();
       
   200 
       
   201 	/**
       
   202 	 * Loads required icons.
       
   203 	 */
       
   204 	void LoadIconsL();
       
   205 
       
   206 	/**
       
   207 	 * Reads the configuration file.
       
   208 	 *
       
   209 	 * @return KErrNone if all succesful, error code otherwise
       
   210 	 */
       
   211 	TInt ReadConfigurationL();
       
   212 
       
   213 	/**
       
   214 	 * Returns the phone information
       
   215 	 *
       
   216 	 * @return KErrNone, if phone information was succesfully retrieved, error number otherwise.
       
   217 	 */
       
   218 	TInt GetPhoneInformation();
       
   219 
       
   220 	/**
       
   221 	 * Returns roaming status.
       
   222 	 *
       
   223 	 * @return ETrue, if phone is roaming
       
   224 	 */
       
   225 	TBool RegisteredRoaming();
       
   226 
       
   227 	/**
       
   228 	 * Returns the phone memory drive.
       
   229 	 *
       
   230 	 * @return Phone memory drive
       
   231 	 */
       
   232 	TInt PhoneMemoryDrive();
       
   233 
       
   234 	/**
       
   235 	 * Returns the memory card drive.
       
   236 	 *
       
   237 	 * @return Memory card drive
       
   238 	 */
       
   239 	TInt MemoryCardDrive();
       
   240 
       
   241 	/**
       
   242 	 * Returns true, if the user selected IAP is a WLAN access point.
       
   243 	 */
       
   244 	TBool UsingWLAN();
       
   245 
       
   246 	/**
       
   247 	 * Returns the Bearer type corresponding to the selected IAP Id.
       
   248 	 *
       
   249 	 * @return Bearer type
       
   250 	 */
       
   251 	TInt BearerType();
       
   252 
       
   253 	/**
       
   254 	 * Read the bootstrap version and file names from the resume file.
       
   255 	 *
       
   256 	 * @return Standard Symbian error code
       
   257 	 */
       
   258 	TInt ReadResumeInfoL();
       
   259 
       
   260 private:
       
   261 	friend class CStateMachine;
       
   262 	friend class CDownloadHandler;
       
   263 
       
   264 	/**
       
   265 	 * State machine running the application logic.
       
   266 	 */
       
   267 	CStateMachine*     iStateMachine;
       
   268 
       
   269 	/**
       
   270 	 * Application exit reason
       
   271 	 */
       
   272 	TExitReason iExitReason;
       
   273 
       
   274 	/**
       
   275 	 * Silent installation completion status
       
   276 	 */
       
   277 	TBool iSilentInstallationOk;
       
   278 
       
   279 	/**
       
   280 	 * Set to ETrue, if non-silent installation was used. Used to hide
       
   281 	 * our "Installation complete" note.
       
   282 	 */
       
   283 	TBool iNonSilentInstallation;
       
   284 
       
   285 	CProgressDialog* iProgress;
       
   286 	CGlobalWaitNote* iWaitNote;
       
   287 	CAknGlobalConfirmationQuery* iGlobalConfirmationQuery;
       
   288 	CGlobalQueryObserver* iGlobalQueryObserver;
       
   289 
       
   290 	/**
       
   291 	 * Full path to the application icon we're installing. Provided in the
       
   292 	 * installer/wrapper package.
       
   293 	 */
       
   294 	HBufC* iAppIconFilename;
       
   295 
       
   296 	/**
       
   297 	 * Holds the current string shown in the query dialog
       
   298 	 */
       
   299 	HBufC* iQueryMessage;
       
   300 
       
   301 	/**
       
   302 	 * Path to dependency name. Given as a command line parameter.
       
   303 	 */
       
   304 	HBufC* iDepFileName;
       
   305 
       
   306 	/**
       
   307 	 * Path to the application sis file. Given as a command line parameter.
       
   308 	 */
       
   309 	HBufC* iSisFileName;
       
   310 
       
   311 	/**
       
   312 	 * The application name to be installed. Read from the resume file,
       
   313 	 * not available if not resuming the installation.
       
   314 	 */
       
   315 	HBufC* iMainAppName;
       
   316 
       
   317 	/**
       
   318 	 * Bootstrap version that was used to launch ADM.
       
   319 	 */
       
   320 	TInt iBootstrapVersion;
       
   321 
       
   322 	/**
       
   323 	 * IAP for the download manager. We try to utilise any existing connection.
       
   324 	 * If that is not available, browser default IAP will be used, if set.
       
   325 	 * If that is not available, user will be prompted for the IAP.
       
   326 	 */
       
   327 	TUint32 iIAP;
       
   328 
       
   329 	/**
       
   330 	 * URL to server stored to config.ini. If configuration file does not exist,
       
   331 	 * default hard-coded (KDefaultDepServerName) URL is used.
       
   332 	 */
       
   333 	HBufC8* iConfigUrl;
       
   334 
       
   335 	/**
       
   336 	 * The wrapper package UID. This package will be uninstalled
       
   337 	 * after succesful installation as it is not required any longer.
       
   338 	 */
       
   339 	TUid iWrapperPackageUid;
       
   340 
       
   341 	/**
       
   342 	 * Handle to file server we got from CEikonEnv::Static()->FsSession().
       
   343 	 */
       
   344 	RFs iRfs;
       
   345 
       
   346 	/**
       
   347 	 * Telephony Server (etelmm).
       
   348 	 */
       
   349 	RTelServer iTelServer;
       
   350 
       
   351 	/**
       
   352 	 * Phone Object
       
   353 	 */
       
   354 	RMobilePhone iPhone;
       
   355 
       
   356 	/**
       
   357 	 * Software version string
       
   358 	 */
       
   359 	HBufC* iSwVersion; ///< owned
       
   360 
       
   361 	/**
       
   362 	 * Machine UID
       
   363 	 */
       
   364 	TInt iMachineUid;
       
   365 
       
   366 	/**
       
   367 	 * True, if resuming installation
       
   368 	 */
       
   369 	TBool iResumingInstallation;
       
   370 
       
   371 	/**
       
   372 	 * True, if installation resume information is required
       
   373 	 */
       
   374 	TBool iIsResumeRequired;
       
   375 
       
   376 	/**
       
   377 	 * True, if Ovi Store client is running
       
   378 	 */
       
   379 	TBool iOviStoreRunning;
       
   380 
       
   381 	/**
       
   382 	* True, if App Launch is possible.
       
   383 	 */
       
   384 	TBool iAppLaunch;
       
   385 
       
   386 #ifdef _DEBUG
       
   387 	/**
       
   388 	 * Manufacturer ID as described by EHalData.
       
   389 	 */
       
   390 	TInt iManufacturer;
       
   391 
       
   392 	/**
       
   393 	 * Model ID
       
   394 	 */
       
   395 	TInt iModel;
       
   396 
       
   397 	/**
       
   398 	 * Hardware revision
       
   399 	 */
       
   400 	TInt iHardwareRev;
       
   401 
       
   402 	/**
       
   403 	 * Software revision
       
   404 	 */
       
   405 	TInt iSoftwareRev;
       
   406 
       
   407 	/**
       
   408 	 * Device family
       
   409 	 */
       
   410 	TInt iDeviceFamily;
       
   411 
       
   412 	/**
       
   413 	 * Device family revision
       
   414 	 */
       
   415 	TInt iDeviceFamilyRev;
       
   416 
       
   417 	/**
       
   418 	 * CPU architecture
       
   419 	 */
       
   420 	TInt iCpuArch;
       
   421 
       
   422 	/**
       
   423 	 * CPU ABI
       
   424 	 */
       
   425 	TInt iCpuABI;
       
   426 
       
   427 	/**
       
   428 	 * CPU speed
       
   429 	 */
       
   430 	TInt iCpuSpeed;
       
   431 #endif
       
   432 
       
   433 	/**
       
   434 	 * Localised resource strings for "kB", "MB" and "GB" used by PrettyPrint().
       
   435 	 */
       
   436 	TBuf<KMaxPrefixLen> iPrefixKb;
       
   437 	TBuf<KMaxPrefixLen> iPrefixMb;
       
   438 	TBuf<KMaxPrefixLen> iPrefixGb;
       
   439 
       
   440 	INIT_OBJECT_DEBUG_LOG
       
   441 	};
       
   442 
       
   443 #endif // __ADMAPPUI_h__
       
   444 
       
   445 // End of File