williamr@2: /* williamr@2: * Copyright (c) 2002 Nokia Corporation and/or its subsidiary(-ies). williamr@2: * All rights reserved. williamr@2: * This component and the accompanying materials are made available williamr@4: * under the terms of "Eclipse Public License v1.0" williamr@2: * which accompanies this distribution, and is available williamr@4: * at the URL "http://www.eclipse.org/legal/epl-v10.html". williamr@2: * williamr@2: * Initial Contributors: williamr@2: * Nokia Corporation - initial contribution. williamr@2: * williamr@2: * Contributors: williamr@2: * williamr@2: * Description: williamr@2: * Declares a wait note wrapper. williamr@2: * williamr@2: */ williamr@2: williamr@2: williamr@2: #ifndef CAknWaitNoteWrapper_H williamr@2: #define CAknWaitNoteWrapper_H williamr@2: williamr@2: // INCLUDES williamr@2: #include williamr@2: #include williamr@2: williamr@2: williamr@2: // CONSTANTS williamr@2: class CAknWaitDialog; williamr@2: williamr@2: williamr@2: // CLASS DECLARATION williamr@2: williamr@2: /** williamr@2: * Abstract process divided into steps. williamr@2: */ williamr@2: class MAknBackgroundProcess williamr@2: { williamr@2: public: // interface williamr@2: /** williamr@2: * Completes one cycle of the process. williamr@2: */ williamr@2: virtual void StepL()=0; williamr@2: williamr@2: /** williamr@2: * Return true when the process is done. williamr@2: */ williamr@2: virtual TBool IsProcessDone() const =0; williamr@2: williamr@2: /** williamr@2: * Callback when the process is finished. williamr@2: */ williamr@2: virtual void ProcessFinished() { } williamr@2: williamr@2: /** williamr@2: * Callback when the dialog is dismissed williamr@2: */ williamr@2: virtual void DialogDismissedL(TInt /*aButtonId*/) { } williamr@2: williamr@2: /** williamr@2: * Handles error occurred in StepL williamr@2: * @param aError error code that occurred williamr@2: * @return translated error code. If this is != KErrNone process will be stopped. williamr@2: */ williamr@2: virtual TInt CycleError(TInt aError) { return aError; } williamr@2: }; williamr@2: williamr@2: /** williamr@2: * CAknWaitNoteWrapper class. williamr@2: */ williamr@2: NONSHARABLE_CLASS(CAknWaitNoteWrapper) : private CActive, private MProgressDialogCallback williamr@2: { williamr@2: public: // constructor and destructor williamr@2: IMPORT_C static CAknWaitNoteWrapper* NewL(); williamr@2: williamr@2: IMPORT_C ~CAknWaitNoteWrapper(); williamr@2: williamr@2: public: // interface williamr@2: /** williamr@2: * Executes the wait note and calls the cycle callback. williamr@2: * williamr@2: * @param aResId Resource id for the dialog. williamr@2: * @param aBackgroundProcess Callback interface. williamr@2: * @param aVisibilityDelayOff If set ETrue the dialog will be visible williamr@2: * immediality. Use only when the length of williamr@2: * the process is ALWAYS over 1.5 seconds. williamr@2: * @param aTone Will be played when the dialog is shown. williamr@2: * williamr@2: * @return true if success, false if wait note was canceled. williamr@2: */ williamr@2: IMPORT_C TBool ExecuteL(TInt aResId, MAknBackgroundProcess& aBackgroundProcess, williamr@2: TBool aVisibilityDelayOff = EFalse, const CAknNoteDialog::TTone& aTone = CAknNoteDialog::ENoTone); williamr@2: williamr@2: williamr@2: /** williamr@2: * Executes the wait note and calls the cycle callback. williamr@2: * Dynamically set note prompt. williamr@2: * williamr@2: * @param aResId Resource id for the dialog. williamr@2: * @param aBackgroundProcess Callback interface. williamr@2: * @param aPrompt Note Prompt williamr@2: * @param aVisibilityDelayOff If set ETrue the dialog will be visible williamr@2: * immediality. Use only when the length of williamr@2: * the process is ALWAYS over 1.5 seconds. williamr@2: * @param aTone Will be played when the dialog is shown. williamr@2: * williamr@2: * @return true if success, false if wait note was canceled. williamr@2: */ williamr@2: IMPORT_C TBool ExecuteL(TInt aResId, MAknBackgroundProcess& aBackgroundProcess, williamr@2: const TDesC& aPrompt, TBool aVisibilityDelayOff = EFalse, const CAknNoteDialog::TTone& aTone = CAknNoteDialog::ENoTone); williamr@2: williamr@2: /** williamr@2: * Return pointer to dialog williamr@2: */ williamr@2: inline CAknWaitDialog* WaitDialog() const; williamr@2: williamr@2: private: // from CActive williamr@2: void DoCancel(); williamr@2: void RunL(); williamr@2: TInt RunError(TInt aError); williamr@2: williamr@2: private: // from MProgressDialogCallback williamr@2: void DialogDismissedL(TInt aButtonId); williamr@2: williamr@2: private: // implementation williamr@2: class CWaitNote; williamr@2: williamr@2: CAknWaitNoteWrapper(); williamr@2: void NextCycle(); williamr@2: williamr@2: TBool NextCycleAndReturnL(); williamr@2: void CreateDialogL(TBool aVisibilityDelayOff, const CAknNoteDialog::TTone& aTone); williamr@2: williamr@2: williamr@2: private: // data members williamr@2: /// Ref: callback to client williamr@2: MAknBackgroundProcess* iBackgroundProcess; williamr@2: /// Own: error code from RunL williamr@2: TInt iRunError; williamr@2: /// Own: wait note dialog williamr@2: CAknWaitDialog* iWaitDialog; williamr@2: /// Own: is dialog dismissed williamr@2: TBool iIsDialogCanceled; williamr@2: /// Own: scheduler wait object, safe to use as direct member data. williamr@2: CActiveSchedulerWait iWait; williamr@2: ///Event generator for this AO (interval is zero seconds) williamr@2: RTimer iTimer; williamr@2: williamr@2: }; williamr@2: williamr@2: CAknWaitDialog* CAknWaitNoteWrapper::WaitDialog() const { return iWaitDialog;} williamr@2: williamr@2: #endif williamr@2: williamr@2: // End of File