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.
williamr@2
     1
/*
williamr@2
     2
* Copyright (c) 2002 Nokia Corporation and/or its subsidiary(-ies).
williamr@2
     3
* All rights reserved.
williamr@2
     4
* This component and the accompanying materials are made available
williamr@4
     5
* under the terms of "Eclipse Public License v1.0"
williamr@2
     6
* which accompanies this distribution, and is available
williamr@4
     7
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
williamr@2
     8
*
williamr@2
     9
* Initial Contributors:
williamr@2
    10
* Nokia Corporation - initial contribution.
williamr@2
    11
*
williamr@2
    12
* Contributors:
williamr@2
    13
*
williamr@2
    14
* Description: 
williamr@2
    15
*     Declares a wait note wrapper.
williamr@2
    16
*
williamr@2
    17
*/
williamr@2
    18
williamr@2
    19
williamr@2
    20
#ifndef CAknWaitNoteWrapper_H
williamr@2
    21
#define CAknWaitNoteWrapper_H
williamr@2
    22
williamr@2
    23
// INCLUDES
williamr@2
    24
#include <e32base.h>
williamr@2
    25
#include <AknProgressDialog.h>
williamr@2
    26
williamr@2
    27
williamr@2
    28
// CONSTANTS
williamr@2
    29
class CAknWaitDialog;
williamr@2
    30
williamr@2
    31
williamr@2
    32
// CLASS DECLARATION
williamr@2
    33
williamr@2
    34
/**
williamr@2
    35
 * Abstract process divided into steps.
williamr@2
    36
 */
williamr@2
    37
class MAknBackgroundProcess
williamr@2
    38
    {
williamr@2
    39
    public: // interface
williamr@2
    40
        /**
williamr@2
    41
         * Completes one cycle of the process.
williamr@2
    42
         */
williamr@2
    43
        virtual void StepL()=0;
williamr@2
    44
williamr@2
    45
        /**
williamr@2
    46
         * Return true when the process is done.
williamr@2
    47
         */
williamr@2
    48
        virtual TBool IsProcessDone() const =0;
williamr@2
    49
williamr@2
    50
        /**
williamr@2
    51
         * Callback when the process is finished.
williamr@2
    52
         */
williamr@2
    53
        virtual void ProcessFinished() { }
williamr@2
    54
williamr@2
    55
        /**
williamr@2
    56
        * Callback when the dialog is dismissed
williamr@2
    57
        */
williamr@2
    58
        virtual void DialogDismissedL(TInt /*aButtonId*/) { }
williamr@2
    59
williamr@2
    60
        /**
williamr@2
    61
         * Handles error occurred in StepL
williamr@2
    62
         * @param aError error code that occurred
williamr@2
    63
         * @return translated error code. If this is != KErrNone process will be stopped.
williamr@2
    64
         */
williamr@2
    65
        virtual TInt CycleError(TInt aError) { return aError; }
williamr@2
    66
    };
williamr@2
    67
williamr@2
    68
/**
williamr@2
    69
 * CAknWaitNoteWrapper class.
williamr@2
    70
 */
williamr@2
    71
NONSHARABLE_CLASS(CAknWaitNoteWrapper) : private CActive, private MProgressDialogCallback
williamr@2
    72
    {
williamr@2
    73
    public: // constructor and destructor
williamr@2
    74
        IMPORT_C static CAknWaitNoteWrapper* NewL();
williamr@2
    75
        
williamr@2
    76
        IMPORT_C ~CAknWaitNoteWrapper();
williamr@2
    77
williamr@2
    78
    public: // interface
williamr@2
    79
        /**
williamr@2
    80
         * Executes the wait note and calls the cycle callback.
williamr@2
    81
		 *
williamr@2
    82
		 * @param aResId                Resource id for the dialog.
williamr@2
    83
         * @param aBackgroundProcess    Callback interface.
williamr@2
    84
         * @param aVisibilityDelayOff   If set ETrue the dialog will be visible
williamr@2
    85
         *                              immediality. Use only when the length of
williamr@2
    86
         *                              the process is ALWAYS over 1.5 seconds.
williamr@2
    87
         * @param aTone                 Will be played when the dialog is shown.
williamr@2
    88
         *
williamr@2
    89
		 * @return true if success, false if wait note was canceled.
williamr@2
    90
         */
williamr@2
    91
        IMPORT_C TBool ExecuteL(TInt aResId, MAknBackgroundProcess& aBackgroundProcess,
williamr@2
    92
            TBool aVisibilityDelayOff = EFalse, const CAknNoteDialog::TTone& aTone = CAknNoteDialog::ENoTone); 
williamr@2
    93
williamr@2
    94
williamr@2
    95
		 /**
williamr@2
    96
         * Executes the wait note and calls the cycle callback.
williamr@2
    97
		 * Dynamically set note prompt.
williamr@2
    98
		 *
williamr@2
    99
		 * @param aResId                Resource id for the dialog.
williamr@2
   100
         * @param aBackgroundProcess    Callback interface.
williamr@2
   101
         * @param aPrompt               Note Prompt
williamr@2
   102
		 * @param aVisibilityDelayOff   If set ETrue the dialog will be visible
williamr@2
   103
         *                              immediality. Use only when the length of
williamr@2
   104
         *                              the process is ALWAYS over 1.5 seconds.
williamr@2
   105
         * @param aTone                 Will be played when the dialog is shown.
williamr@2
   106
         *
williamr@2
   107
		 * @return true if success, false if wait note was canceled.
williamr@2
   108
         */
williamr@2
   109
        IMPORT_C TBool ExecuteL(TInt aResId, MAknBackgroundProcess& aBackgroundProcess,
williamr@2
   110
			const TDesC& aPrompt, TBool aVisibilityDelayOff = EFalse, const CAknNoteDialog::TTone& aTone = CAknNoteDialog::ENoTone); 
williamr@2
   111
williamr@2
   112
		/**
williamr@2
   113
		* Return pointer to dialog
williamr@2
   114
		*/
williamr@2
   115
		inline CAknWaitDialog* WaitDialog() const; 
williamr@2
   116
williamr@2
   117
    private: // from CActive
williamr@2
   118
	    void DoCancel();
williamr@2
   119
	    void RunL();
williamr@2
   120
        TInt RunError(TInt aError);
williamr@2
   121
williamr@2
   122
    private:  // from MProgressDialogCallback
williamr@2
   123
        void DialogDismissedL(TInt aButtonId);
williamr@2
   124
williamr@2
   125
    private: // implementation
williamr@2
   126
        class CWaitNote;
williamr@2
   127
williamr@2
   128
        CAknWaitNoteWrapper();
williamr@2
   129
        void NextCycle();
williamr@2
   130
williamr@2
   131
		TBool NextCycleAndReturnL();
williamr@2
   132
		void CreateDialogL(TBool aVisibilityDelayOff, const CAknNoteDialog::TTone& aTone);
williamr@2
   133
williamr@2
   134
williamr@2
   135
    private: // data members
williamr@2
   136
        /// Ref: callback to client
williamr@2
   137
        MAknBackgroundProcess* iBackgroundProcess;
williamr@2
   138
        /// Own: error code from RunL
williamr@2
   139
        TInt iRunError;
williamr@2
   140
        /// Own: wait note dialog
williamr@2
   141
        CAknWaitDialog* iWaitDialog;
williamr@2
   142
        /// Own: is dialog dismissed
williamr@2
   143
        TBool iIsDialogCanceled;
williamr@2
   144
		/// Own: scheduler wait object, safe to use as direct member data.
williamr@2
   145
		CActiveSchedulerWait iWait;
williamr@2
   146
		///Event generator for this AO (interval is zero seconds)
williamr@2
   147
		RTimer iTimer;
williamr@2
   148
williamr@2
   149
    };
williamr@2
   150
williamr@2
   151
CAknWaitDialog* CAknWaitNoteWrapper::WaitDialog() const { return iWaitDialog;}
williamr@2
   152
williamr@2
   153
#endif
williamr@2
   154
williamr@2
   155
// End of File