epoc32/include/mw/aknwaitnotewrapper.h
author William Roberts <williamr@symbian.org>
Wed, 31 Mar 2010 12:33:34 +0100
branchSymbian3
changeset 4 837f303aceeb
parent 2 2fe1408b6811
permissions -rw-r--r--
Current Symbian^3 public API header files (from PDK 3.0.h)
This is the epoc32/include tree with the "platform" subtrees removed, and
all but a selected few mbg and rsg files removed.
     1 /*
     2 * Copyright (c) 2002 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 a wait note wrapper.
    16 *
    17 */
    18 
    19 
    20 #ifndef CAknWaitNoteWrapper_H
    21 #define CAknWaitNoteWrapper_H
    22 
    23 // INCLUDES
    24 #include <e32base.h>
    25 #include <AknProgressDialog.h>
    26 
    27 
    28 // CONSTANTS
    29 class CAknWaitDialog;
    30 
    31 
    32 // CLASS DECLARATION
    33 
    34 /**
    35  * Abstract process divided into steps.
    36  */
    37 class MAknBackgroundProcess
    38     {
    39     public: // interface
    40         /**
    41          * Completes one cycle of the process.
    42          */
    43         virtual void StepL()=0;
    44 
    45         /**
    46          * Return true when the process is done.
    47          */
    48         virtual TBool IsProcessDone() const =0;
    49 
    50         /**
    51          * Callback when the process is finished.
    52          */
    53         virtual void ProcessFinished() { }
    54 
    55         /**
    56         * Callback when the dialog is dismissed
    57         */
    58         virtual void DialogDismissedL(TInt /*aButtonId*/) { }
    59 
    60         /**
    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.
    64          */
    65         virtual TInt CycleError(TInt aError) { return aError; }
    66     };
    67 
    68 /**
    69  * CAknWaitNoteWrapper class.
    70  */
    71 NONSHARABLE_CLASS(CAknWaitNoteWrapper) : private CActive, private MProgressDialogCallback
    72     {
    73     public: // constructor and destructor
    74         IMPORT_C static CAknWaitNoteWrapper* NewL();
    75         
    76         IMPORT_C ~CAknWaitNoteWrapper();
    77 
    78     public: // interface
    79         /**
    80          * Executes the wait note and calls the cycle callback.
    81 		 *
    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.
    88          *
    89 		 * @return true if success, false if wait note was canceled.
    90          */
    91         IMPORT_C TBool ExecuteL(TInt aResId, MAknBackgroundProcess& aBackgroundProcess,
    92             TBool aVisibilityDelayOff = EFalse, const CAknNoteDialog::TTone& aTone = CAknNoteDialog::ENoTone); 
    93 
    94 
    95 		 /**
    96          * Executes the wait note and calls the cycle callback.
    97 		 * Dynamically set note prompt.
    98 		 *
    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.
   106          *
   107 		 * @return true if success, false if wait note was canceled.
   108          */
   109         IMPORT_C TBool ExecuteL(TInt aResId, MAknBackgroundProcess& aBackgroundProcess,
   110 			const TDesC& aPrompt, TBool aVisibilityDelayOff = EFalse, const CAknNoteDialog::TTone& aTone = CAknNoteDialog::ENoTone); 
   111 
   112 		/**
   113 		* Return pointer to dialog
   114 		*/
   115 		inline CAknWaitDialog* WaitDialog() const; 
   116 
   117     private: // from CActive
   118 	    void DoCancel();
   119 	    void RunL();
   120         TInt RunError(TInt aError);
   121 
   122     private:  // from MProgressDialogCallback
   123         void DialogDismissedL(TInt aButtonId);
   124 
   125     private: // implementation
   126         class CWaitNote;
   127 
   128         CAknWaitNoteWrapper();
   129         void NextCycle();
   130 
   131 		TBool NextCycleAndReturnL();
   132 		void CreateDialogL(TBool aVisibilityDelayOff, const CAknNoteDialog::TTone& aTone);
   133 
   134 
   135     private: // data members
   136         /// Ref: callback to client
   137         MAknBackgroundProcess* iBackgroundProcess;
   138         /// Own: error code from RunL
   139         TInt iRunError;
   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)
   147 		RTimer iTimer;
   148 
   149     };
   150 
   151 CAknWaitDialog* CAknWaitNoteWrapper::WaitDialog() const { return iWaitDialog;}
   152 
   153 #endif
   154 
   155 // End of File