2 * Copyright (c) 2002 Nokia Corporation and/or its subsidiary(-ies).
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".
9 * Initial Contributors:
10 * Nokia Corporation - initial contribution.
15 * Declares a wait note wrapper.
20 #ifndef CAknWaitNoteWrapper_H
21 #define CAknWaitNoteWrapper_H
25 #include <AknProgressDialog.h>
35 * Abstract process divided into steps.
37 class MAknBackgroundProcess
41 * Completes one cycle of the process.
43 virtual void StepL()=0;
46 * Return true when the process is done.
48 virtual TBool IsProcessDone() const =0;
51 * Callback when the process is finished.
53 virtual void ProcessFinished() { }
56 * Callback when the dialog is dismissed
58 virtual void DialogDismissedL(TInt /*aButtonId*/) { }
61 * Handles error occurred in StepL
62 * @param aError error code that occurred
63 * @return translated error code. If this is != KErrNone process will be stopped.
65 virtual TInt CycleError(TInt aError) { return aError; }
69 * CAknWaitNoteWrapper class.
71 NONSHARABLE_CLASS(CAknWaitNoteWrapper) : private CActive, private MProgressDialogCallback
73 public: // constructor and destructor
74 IMPORT_C static CAknWaitNoteWrapper* NewL();
76 IMPORT_C ~CAknWaitNoteWrapper();
80 * Executes the wait note and calls the cycle callback.
82 * @param aResId Resource id for the dialog.
83 * @param aBackgroundProcess Callback interface.
84 * @param aVisibilityDelayOff If set ETrue the dialog will be visible
85 * immediality. Use only when the length of
86 * the process is ALWAYS over 1.5 seconds.
87 * @param aTone Will be played when the dialog is shown.
89 * @return true if success, false if wait note was canceled.
91 IMPORT_C TBool ExecuteL(TInt aResId, MAknBackgroundProcess& aBackgroundProcess,
92 TBool aVisibilityDelayOff = EFalse, const CAknNoteDialog::TTone& aTone = CAknNoteDialog::ENoTone);
96 * Executes the wait note and calls the cycle callback.
97 * Dynamically set note prompt.
99 * @param aResId Resource id for the dialog.
100 * @param aBackgroundProcess Callback interface.
101 * @param aPrompt Note Prompt
102 * @param aVisibilityDelayOff If set ETrue the dialog will be visible
103 * immediality. Use only when the length of
104 * the process is ALWAYS over 1.5 seconds.
105 * @param aTone Will be played when the dialog is shown.
107 * @return true if success, false if wait note was canceled.
109 IMPORT_C TBool ExecuteL(TInt aResId, MAknBackgroundProcess& aBackgroundProcess,
110 const TDesC& aPrompt, TBool aVisibilityDelayOff = EFalse, const CAknNoteDialog::TTone& aTone = CAknNoteDialog::ENoTone);
113 * Return pointer to dialog
115 inline CAknWaitDialog* WaitDialog() const;
117 private: // from CActive
120 TInt RunError(TInt aError);
122 private: // from MProgressDialogCallback
123 void DialogDismissedL(TInt aButtonId);
125 private: // implementation
128 CAknWaitNoteWrapper();
131 TBool NextCycleAndReturnL();
132 void CreateDialogL(TBool aVisibilityDelayOff, const CAknNoteDialog::TTone& aTone);
135 private: // data members
136 /// Ref: callback to client
137 MAknBackgroundProcess* iBackgroundProcess;
138 /// Own: error code from RunL
140 /// Own: wait note dialog
141 CAknWaitDialog* iWaitDialog;
142 /// Own: is dialog dismissed
143 TBool iIsDialogCanceled;
144 /// Own: scheduler wait object, safe to use as direct member data.
145 CActiveSchedulerWait iWait;
146 ///Event generator for this AO (interval is zero seconds)
151 CAknWaitDialog* CAknWaitNoteWrapper::WaitDialog() const { return iWaitDialog;}