/*
* Copyright (c) 2009-2010 Nokia Corporation and/or its subsidiary(-ies).
* All rights reserved.
* This component and the accompanying materials are made available
* under the terms of "Eclipse Public License v1.0"
* which accompanies this distribution, and is available
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
*
* Initial Contributors:
* Nokia Corporation - initial contribution.
*
* Contributors:
*
* Description:
* CBootstrapAppUi application UI class declaration.
*
*
*/
#ifndef __BOOTSTRAPAPPUI_H__
#define __BOOTSTRAPAPPUI_H__
// INCLUDES
#include <aknappui.h>
#include <aknglobalconfirmationquery.h>
#include <downloadmgrclient.h>
#include <smartinstaller.rsg>
#include <swinstapi.h>
#include "debug.h"
const TInt KMaxDlConnectionAttempts = 6;
// FORWARD DECLARATIONS
class CBootstrapAppView;
class CAknGlobalNote;
class CGlobalWaitNoteObserver;
class CInstallObserver;
enum AppState
{
EInitialState, // 0
EChangesDownloadState,
EChangesParseState,
EADMDownloadState,
EADMInstallState,
EADMLaunchState
};
// Mandatory changes xml elements
_LIT8(KFieldVersion,"Version");
_LIT8(KFieldSisName,"SisFileName");
// Optional changes xml element
_LIT8(KFieldUrl,"Url");
enum XmlParserError
{
EErrorXmlNotWelformed,
EMissingVersion,
EInvalidVersion,
EMissingSisFileName,
};
struct AdmChangesInfo
{
AdmChangesInfo()
:iVersion(0,0,0),
iSisName(NULL),
iUrl(NULL)
{}
~AdmChangesInfo()
{
delete iSisName;
delete iUrl;
}
TVersion iVersion;
HBufC8 *iSisName;
HBufC8 *iUrl;
};
// CLASS DECLARATION
/**
* CBootstrapAppUi application UI class.
* Interacts with the user through the UI and request message processing
* from the handler class
*/
class CBootstrapAppUi : public CAknAppUi,
public MHttpDownloadMgrObserver
{
public: // Constructors and destructor
/**
* ConstructL.
* 2nd phase constructor.
*/
void ConstructL();
/**
* CBootstrapAppUi.
* C++ default constructor. This needs to be public due to
* the way the framework constructs the AppUi
*/
CBootstrapAppUi();
/**
* ~CBootstrapAppUi.
* Virtual Destructor.
*/
virtual ~CBootstrapAppUi();
void ExitWithError(const TInt& aResourceId );
private: // Functions from base classes
/**
* Push the application to background.
* Called by the framework when the application switches
* to foreground.
*/
void HandleForegroundEventL(TBool aForeground);
/**
* Sends application to background.
*/
void SendToBackgroundL(TBool aBackground = ETrue);
/**
* Check if the ADM is already present in the device or not
*/
TBool IsPackagePresentL(const TUid& aUid, TVersion& aVersion);
/*
* Installs the specified package
*/
void AsyncInstallPackageL(const TDesC& aResponseFilename);
TInt LaunchAdmL ();
void ShowGlobalWaitNoteL();
void StopGlobalWaitNoteL();
void SetFileNameInfoL();
void ShowNoteL( const TAknGlobalNoteType& aType , const TInt& aResourceId );
/**
* Fetch ADM from the web server.
*/
void DownloadL();
void CloseApp();
void DeleteFile(const TDesC& aFileName);
void WaitForInstallCompleteL();
TUint32 GetLatestInstalledL();
void HandleCommandL(TInt aCommand);
TInt ReadConfigurationL();
#ifdef FEATURE_BOOTSTRAP_SETIAP
void SetIAPL();
#endif
void ParseChangesInfoL( const TDesC& aChangesFileName );
public:
void HandleInstallCompleteL(const TInt& aStatus);
/**
*Handle the Global Query Response
*/
void HandleHttpFetchCompleteL(const TBool& aStatus);
/**
*Handle download manager events.
*/
void HandleDMgrEventL( RHttpDownload& aDownload, THttpDownloadEvent aEvent );
/**
* Handle user press cancel
*/
void HandleGlobalWaitNoteCancel(const TInt& aStatus);
private: // Data
/**
* The application view
* Owned by CBootstrapAppUi
*/
/**
* IAP for Download Manager. Passed to ADM.
*/
TInt32 iIAP;
HBufC* iDepFilename;
HBufC* iSisFileName;
/**
* URL provided by the configuration file to the server root or
* the default URL, if config file is missing.
*/
HBufC8* iConfigUrl;
/**
* URL
*/
HBufC8* iUrl;
HBufC* iDownloadFileName;
TBool iAllowForeground;
TBool iIsAdmInstalled;
TVersion iAdmInstalledVersion;
/*
* Downloadmanager object
*/
RHttpDownloadMgr iDownloadManager;
CAknGlobalNote* iGlobalWaitNote;
CGlobalWaitNoteObserver* iGlobalWaitNoteObserver;
TInt iGlobalWaitNoteId;
TUint32 iWrapperPackageUid;
TBool iPausable;
TInt iConnectionAttempts;
SwiUI::RSWInstSilentLauncher iLauncher;
SwiUI::TInstallOptionsPckg iOptionsPckg;
AppState iAppState;
TInt iInstallAttempt;
CInstallObserver* iInstallObsrv;
AdmChangesInfo iAdmChangesInfo;
TBool isIapCancelled;
INIT_OBJECT_DEBUG_LOG
};
#endif // __BootstrapAPPUI_H__
// End of File