williamr@4: /* williamr@4: * Copyright (c) 2002-2007 Nokia Corporation and/or its subsidiary(-ies). williamr@4: * All rights reserved. williamr@4: * This component and the accompanying materials are made available williamr@4: * under the terms of "Eclipse Public License v1.0" williamr@4: * which accompanies this distribution, and is available williamr@4: * at the URL "http://www.eclipse.org/legal/epl-v10.html". williamr@4: * williamr@4: * Initial Contributors: williamr@4: * Nokia Corporation - initial contribution. williamr@4: * williamr@4: * Contributors: williamr@4: * williamr@4: * Description: Uses notification framework to show a global progress dialog. williamr@4: * williamr@4: */ williamr@4: williamr@4: #ifndef __AKNGLOBALPROGRESSDIALOG_H__ williamr@4: #define __AKNGLOBALPROGRESSDIALOG_H__ williamr@4: williamr@4: #include williamr@4: #include williamr@4: #include williamr@4: #include williamr@4: williamr@4: class CAknSDData; williamr@4: williamr@4: /** williamr@4: * CAknGlobalProgressDialog williamr@4: * Uses notification framework to show a global progress dialog. williamr@4: * Usage: williamr@4: * Create an active object, start it and pass its TRequestStatus as a williamr@4: * parameter to ShowProgressDialogL. After the dialog gets dismissed, williamr@4: * the request status will hold the id of the pressed softkey. E.g. williamr@4: * If the user selected Cancel, the request status will hold -1. williamr@4: * williamr@4: * Example 1. Construct global progress dialog and set icon and image. williamr@4: * williamr@4: * iGlobalProgressDialog = CAknGlobalProgressDialog::NewL(); williamr@4: * iGlobalProgressDialog->SetIconL( williamr@4: * iIconText, williamr@4: * iIconFile, williamr@4: * iIconId, williamr@4: * iIconMaskId); williamr@4: * williamr@4: * iGlobalProgressDialog->SetImageL( williamr@4: * iImageFile, williamr@4: * iImageId, williamr@4: * iImageMaskId); williamr@4: * williamr@4: * Example 2. Show the global progress dialog: williamr@4: * williamr@4: * iGlobalProgressDialog->ShowMsgQueryL( williamr@4: * iObserver->iStatus, williamr@4: * iPrompt, williamr@4: * R_AVKON_SOFTKEYS_OK_CANCEL, williamr@4: * iFinalValue, williamr@4: * CAknQueryDialog::EConfirmationTone ); williamr@4: * williamr@4: * Example 3. Update the progress (current and final value of the process). williamr@4: * williamr@4: * iGlobalProgressDialog->UpdateProgressDialog( 100, 500 ); williamr@4: * williamr@4: * Example 4. Finish the progress williamr@4: * Needs to be called everytime the process has finished. williamr@4: * Dismisses the dialog. williamr@4: * williamr@4: * iGlobalProgressDialog->ProcessFinished(); williamr@4: * williamr@4: * Example 5. Get and handle the result in active object. williamr@4: * williamr@4: * void CMyActiveObject::RunL() williamr@4: * { williamr@4: * TBuf<120> msg = _L("Received: "); williamr@4: * // iStatus.Int() holds the return value williamr@4: * msg.AppendNum( iStatus.Int() ); williamr@4: * iEnv->InfoMsg(msg); // Show infomsg williamr@4: * Cancel(); williamr@4: * } williamr@4: * williamr@4: * Example 6. Cancel the progress dialog williamr@4: * williamr@4: * iGlobalProgressDialog->CancelProgressDialog(); williamr@4: */ williamr@4: williamr@4: NONSHARABLE_CLASS(CAknGlobalProgressDialog) : public CBase williamr@4: { williamr@4: public: williamr@4: IMPORT_C static CAknGlobalProgressDialog* NewL(); williamr@4: IMPORT_C static CAknGlobalProgressDialog* NewLC(); williamr@4: IMPORT_C ~CAknGlobalProgressDialog(); williamr@4: williamr@4: /** williamr@4: * Set icon for the progress dialog williamr@4: * Must be called before ShowProgressDialogL. williamr@4: * williamr@4: * @param aIconText Icon text williamr@4: * @param aIconFile Icon file williamr@4: * @param aIconId Icon id williamr@4: * @param aIconMaskId Mask id for icon williamr@4: */ williamr@4: IMPORT_C void SetIconL( const TDesC& aIconText, williamr@4: const TDesC& aIconFile, williamr@4: TInt aIconId = 0, williamr@4: TInt aIconMaskId = -1 ); williamr@4: williamr@4: /** williamr@4: * Set image for the progress dialog williamr@4: * Must be called before ShowProgressDialogL. williamr@4: * If not set, default image will be used, williamr@4: * i.e. EMbmAvkonQgn_note_progress williamr@4: * williamr@4: * @param aImageFile Image file williamr@4: * @param aImageId Image id williamr@4: * @param aImageMaskId Mask id for Image williamr@4: */ williamr@4: IMPORT_C void SetImageL( williamr@4: const TDesC& aImageFile, williamr@4: TInt aImageId = 0, williamr@4: TInt aImageMaskId = -1 ); williamr@4: williamr@4: /** williamr@4: * Shows global progress dialog asynchronously williamr@4: * williamr@4: * @param aStatus TRequestStatus which will be completed williamr@4: * when the dialog gets dismissed williamr@4: * @param aPrompt Prompt text williamr@4: * @param aSoftkeys Softkeys resource id williamr@4: * If not set default softkeys are used. williamr@4: * i.e. R_AVKON_SOFTKEYS_CANCEL williamr@4: * @param aFinalValue Final value of the process williamr@4: * @param aTone Tone to be played after completion williamr@4: */ williamr@4: IMPORT_C void ShowProgressDialogL( williamr@4: TRequestStatus& aStatus, williamr@4: const TDesC& aPrompt, williamr@4: TInt aSoftkeys = 0, williamr@4: TInt aFinalValue = 0, williamr@4: CAknNoteDialog::TTone aTone = CAknNoteDialog::ENoTone ); williamr@4: williamr@4: /** williamr@4: * Update Progress dialog with new progress values. williamr@4: * williamr@4: * @param aValue Current value of the process. williamr@4: * @param aFinalValue Final value of the process. If not given the williamr@4: * existing value is used. williamr@4: */ williamr@4: IMPORT_C void UpdateProgressDialog( williamr@4: TInt aValue, williamr@4: TInt aFinalValue = -1 ); williamr@4: williamr@4: /** williamr@4: * ProcessFinished. williamr@4: * Dismisses the dialog. Needs to be called after the williamr@4: * process has finished. williamr@4: */ williamr@4: IMPORT_C void ProcessFinished(); williamr@4: williamr@4: /** williamr@4: * Cancel the progress dialog. williamr@4: * Cancels the request and deletes the dialog. williamr@4: */ williamr@4: IMPORT_C void CancelProgressDialog(); williamr@4: williamr@4: /** williamr@4: * @since S60 2.6 williamr@4: * Set Skin ids for note image and icon. Must be called before ShowProgressDialogL in order williamr@4: * to have effect. No need to use this method if image from avkon.mbm is used. williamr@4: * williamr@4: * @aparam aImageId SkinId for image in query. If image not found from active skin, williamr@4: * default image / SetImageL definitions used instead. williamr@4: * williamr@4: * @aparam aIconId SkinId for icon in query. If image not found from active skin, williamr@4: * default icon / SetIconL definitions used instead. williamr@4: */ williamr@4: IMPORT_C void SetImageSkinIds( TAknsItemID& aImageId, TAknsItemID& aIconId ); williamr@4: williamr@4: /** williamr@4: * @since S60 3.1 williamr@4: * Sets additional information to be sent to secondary display. williamr@4: * Takes ownership of object. williamr@4: * Must be called before sending data to notifier to have effect. williamr@4: * @internal to S60 williamr@4: * williamr@4: * @aparam aData Data to be sent to cover UI. williamr@4: */ williamr@4: IMPORT_C void SetSecondaryDisplayData(CAknSDData* aData); williamr@4: williamr@4: private: williamr@4: /** williamr@4: * Default constructor. williamr@4: */ williamr@4: CAknGlobalProgressDialog(); williamr@4: williamr@4: /** williamr@4: * ConstructL. williamr@4: */ williamr@4: void ConstructL(); williamr@4: williamr@4: /** williamr@4: * Update notifier. williamr@4: */ williamr@4: void UpdateNotifier(); williamr@4: williamr@4: private: williamr@4: // Command send to server. williamr@4: TAknGlobalQueryCmd iCmd; williamr@4: // Final value of the process. williamr@4: TInt iFinalValue; williamr@4: // Current value of the process. williamr@4: TInt iValue; williamr@4: // Handle to session with notify server. williamr@4: RNotifier iNotify; williamr@4: // Buffer used to pass parameters to server. williamr@4: CBufFlat *iBuffer; williamr@4: // Pointer to iBuffer williamr@4: TPtrC8 iBufferPtr; williamr@4: williamr@4: // Id of the image. williamr@4: TInt iImageId; williamr@4: // Id of the image's mask. williamr@4: TInt iImageMaskId; williamr@4: // Id of the icon. williamr@4: TInt iIconId; williamr@4: // Id of the icon's mask. williamr@4: TInt iIconMaskId; williamr@4: williamr@4: // Icon's text. williamr@4: HBufC* iIconText; williamr@4: // Icon file name. williamr@4: HBufC* iIconFile; williamr@4: // Image file name. williamr@4: HBufC* iImageFile; williamr@4: williamr@4: TInt iImageSkinsMajorId; williamr@4: TInt iImageSkinsMinorId; williamr@4: williamr@4: TInt iIconSkinsMajorId; williamr@4: TInt iIconSkinsMinorId; williamr@4: CAknSDData* iAknSDData; williamr@4: TBuf8<1> iResultBuf; // Not really used, but needed to prevent buffer handling errors. williamr@4: }; williamr@4: williamr@4: #endif // __AKNGLOBALPROGRESSDIALOG_H__