williamr@2: /* williamr@2: * Copyright (c) 2002-2007 Nokia Corporation and/or its subsidiary(-ies). williamr@2: * All rights reserved. williamr@2: * This component and the accompanying materials are made available williamr@2: * under the terms of the License "Symbian Foundation License v1.0" to Symbian Foundation members and "Symbian Foundation End User License Agreement v1.0" to non-members williamr@2: * which accompanies this distribution, and is available williamr@2: * at the URL "http://www.symbianfoundation.org/legal/licencesv10.html". williamr@2: * williamr@2: * Initial Contributors: williamr@2: * Nokia Corporation - initial contribution. williamr@2: * williamr@2: * Contributors: williamr@2: * williamr@2: * Description: Dialog used to selection target memory. williamr@2: * williamr@2: */ williamr@2: williamr@2: williamr@2: #ifndef C_AKNMEMORYSELECTIONDIALOG_H williamr@2: #define C_AKNMEMORYSELECTIONDIALOG_H williamr@2: williamr@2: #include williamr@2: #include // CDesCArray williamr@2: williamr@2: class CAknMemorySelectionModel; williamr@2: class CAknMemorySelectionEventHandler; williamr@2: class MAknMemorySelectionObserver; williamr@2: class TDriveInfo; williamr@2: class CAknIconArray; williamr@2: williamr@2: /** williamr@2: * A class that launches a pop-up dialog for memory selection. williamr@2: * williamr@2: * @lib CommonDialogs.lib williamr@2: * @since S60 1.2 williamr@2: */ williamr@2: NONSHARABLE_CLASS(CAknMemorySelectionDialog) : public CAknCommonDialogsBase williamr@2: { williamr@2: williamr@2: public: williamr@2: williamr@2: // Enumerations williamr@2: /** williamr@2: * @Deprecated: This only works with fixed C: and E: drives. williamr@2: * Enumerations for memory items in listbox . williamr@2: */ williamr@2: enum TMemory williamr@2: { williamr@2: EPhoneMemory = 0, // C: williamr@2: EMemoryCard, // E: williamr@2: EMemoryCount // must remain last one williamr@2: }; williamr@2: williamr@2: // Constructors and destructors williamr@2: williamr@2: /** williamr@2: * Static constructor. williamr@2: * williamr@2: * @since S60 3.2 williamr@2: * @param aDialogType Defines the type of the dialog in order to read williamr@2: * correct default settings for title and softkeys from resource. williamr@2: * @param aShowUnavailableDrives Defines whether unavailable or corrupted williamr@2: * drives are shown in memory selection list or not. williamr@2: * @return Returns a pointer to an instance of itself. williamr@2: */ williamr@2: IMPORT_C static CAknMemorySelectionDialog* NewL( williamr@2: TCommonDialogType aDialogType, williamr@2: TBool aShowUnavailableDrives ); williamr@2: williamr@2: williamr@2: /** williamr@2: * Static constructor. williamr@2: * williamr@2: * @since S60 3.2 williamr@2: * @param aDialogType Defines the type of the dialog in order to read williamr@2: * correct default settings for title and softkeys from resource. williamr@2: * @param aResourceId A resource id (MEMORYSELECTIONDIALOG). williamr@2: * @param aShowUnavailableDrives Defines whether unavailable or corrupted williamr@2: * drives are shown in memory selection list or not. williamr@2: * @return Returns a pointer to an instance of itself. williamr@2: */ williamr@2: IMPORT_C static CAknMemorySelectionDialog* NewL( williamr@2: TCommonDialogType aDialogType, williamr@2: TInt aResourceId, williamr@2: TBool aShowUnavailableDrives ); williamr@2: williamr@2: /** williamr@2: * Static constructor. williamr@2: * williamr@2: * @since S60 3.2 williamr@2: * @param aDialogType Defines the type of the dialog in order to read williamr@2: * correct default settings for title and softkeys from resource. williamr@2: * @param aResourceId A resource id (MEMORYSELECTIONDIALOG). williamr@2: * @param aShowUnavailableDrives Defines whether unavailable or corrupted williamr@2: * drives are shown in memory selection list or not. williamr@2: * @param aIncludedMedias bit flag definition of which medias are williamr@2: * included in the dialog. See TMemoryTypes. williamr@2: * @return Returns a pointer to an instance of itself. williamr@2: */ williamr@2: IMPORT_C static CAknMemorySelectionDialog* NewL( williamr@2: TCommonDialogType aDialogType, williamr@2: TInt aResourceId, williamr@2: TBool aShowUnavailableDrives, williamr@2: TInt aIncludedMedias ); williamr@2: williamr@2: IMPORT_C virtual ~CAknMemorySelectionDialog(); williamr@2: williamr@2: // New functions williamr@2: williamr@2: /** williamr@2: * Sets an observer which is asked if the selected item can be selected. williamr@2: * williamr@2: * @param aObserver A pointer to an observer. williamr@2: */ williamr@2: IMPORT_C void SetObserver( MAknMemorySelectionObserver* aObserver ); williamr@2: williamr@2: /** williamr@2: * Sets title for the dialog. williamr@2: * williamr@2: * @param aText Title text. williamr@2: */ williamr@2: IMPORT_C void SetTitleL( const TDesC& aText ); williamr@2: williamr@2: /** williamr@2: * Sets the text used for left softkey. williamr@2: * williamr@2: * @param aText The text used for left softkey. williamr@2: */ williamr@2: IMPORT_C void SetLeftSoftkeyL( const TDesC& aText ); williamr@2: williamr@2: /** williamr@2: * Sets the text used for right softkey. williamr@2: * williamr@2: * @param aText The text used for right softkey. williamr@2: */ williamr@2: IMPORT_C void SetRightSoftkeyL( const TDesC& aText ); williamr@2: williamr@2: /** williamr@2: * Gets an item from memory selection dialog at specified index. williamr@2: * williamr@2: * @param aIndex Index to the item in the memory selection list. williamr@2: * @param aItem A reference to a descriptor where the item is stored. williamr@2: */ williamr@2: IMPORT_C void GetItem( TInt aIndex, TDes& aItem ); williamr@2: williamr@2: /** williamr@2: * Gets the location paths of a memory. williamr@2: * williamr@2: * @param aSelectedMemory The memory that was selected. williamr@2: * @param aRootPath A pointer to a descriptor where the root path williamr@2: * of the selected memory is stored. Must have KMaxFileName space. williamr@2: * Set to NULL to ignore. williamr@2: * @param aDefaultFolder A pointer to a descriptor where the default folder williamr@2: * of the selected memory is stored. Must have KMaxFileName space. williamr@2: * Set to NULL to ignore. williamr@2: */ williamr@2: IMPORT_C void GetMemories( TMemory aSelectedMemory, williamr@2: TDes* aRootPath, williamr@2: TDes* aDefaultFolder ); williamr@2: williamr@2: /** williamr@2: * Executes the memory selection dialog. Virtual to allow derivation. williamr@2: * williamr@2: * @param aSelectedMemory A reference to a memory (TMemory). williamr@2: * If one of the memories is selected, the selected memory is williamr@2: * stored to the parameter. williamr@2: * @return Returns true if user has selected an item and false williamr@2: * if user hits cancel. williamr@2: */ williamr@2: IMPORT_C virtual TReturnKey ExecuteL( TMemory& aSelectedMemory ); williamr@2: williamr@2: /** williamr@2: * Executes the memory selection dialog. Virtual to allow derivation. williamr@2: * williamr@2: * @param aSelectedMemory A reference to a memory (TMemory). williamr@2: * If one of the memories is selected, the selected memory is williamr@2: * stored to the parameter. williamr@2: * @param aRootPath A pointer to a descriptor where the root path williamr@2: * of the selected memory is stored. williamr@2: * @param aDefaultFolder A pointer to a descriptor where the default folder williamr@2: * of the selected memory is stored. williamr@2: * @return Returns true if user has selected an item and false williamr@2: * if user hits cancel. williamr@2: */ williamr@2: IMPORT_C virtual TReturnKey ExecuteL( williamr@2: TMemory& aSelectedMemory, williamr@2: TDes* aRootPath, TDes* aDefaultFolder ); williamr@2: williamr@2: /** williamr@2: * A static method that launches a memory selection dialog. williamr@2: * @see RunL() williamr@2: */ williamr@2: IMPORT_C static TBool RunDlgLD( williamr@2: TMemory& aSelectedMemory, williamr@2: MAknMemorySelectionObserver* aObserver = NULL ); williamr@2: williamr@2: /** williamr@2: * A static method that launches a memory selection dialog. williamr@2: * @see RunL() williamr@2: */ williamr@2: IMPORT_C static TBool RunDlgLD( williamr@2: TMemory& aSelectedMemory, williamr@2: const TDesC& aTitle, williamr@2: MAknMemorySelectionObserver* aObserver = NULL ); williamr@2: williamr@2: /** williamr@2: * A static method that launches a memory selection dialog. williamr@2: * @see RunL() williamr@2: */ williamr@2: IMPORT_C static TBool RunDlgLD( williamr@2: TMemory& aSelectedMemory, williamr@2: TInt aResourceId, williamr@2: TDes* aRootPath = NULL, TDes* aDefaultFolder = NULL, williamr@2: MAknMemorySelectionObserver* aObserver = NULL ); williamr@2: williamr@2: /** williamr@2: * Returns the number of items in list box array. williamr@2: * Not exported, for CFD internal use only. williamr@2: * williamr@2: * @return Returns the number of items in list box array. williamr@2: */ williamr@2: TInt NumberOfItems() const; williamr@2: williamr@2: /** williamr@2: * Maps drive paths according to selected listbox item. This function is williamr@2: * valid for dynamic drives. The prerequisite for this function is that williamr@2: * iRootPathArray and additionally iDefaultFolderArray indexes map williamr@2: * correctly to iModel's listbox items. williamr@2: * williamr@2: * @since S60 3.2 williamr@2: * @param aLbxIndex Index to the selected listbox item. williamr@2: * @param aRootPath A pointer to a descriptor where the root path of the williamr@2: * selected drive will be stored. Must have KMaxFileName space. williamr@2: * Set to NULL to ignore. williamr@2: * @param aDefaultFolder A pointer to a descriptor where the default folder williamr@2: * of the selected drive will be stored. Must have williamr@2: * KMaxFileNamespace. williamr@2: * Set to NULL to ignore. williamr@2: * @return Return error code williamr@2: * KErrNone The drive is found in internal drive list williamr@2: * KErrNotFound The drive is not visible to user or does not exist williamr@2: */ williamr@2: TInt GetDrivePaths( TInt aLbxIndex, williamr@2: TDes* aRootPath, williamr@2: TDes* aDefaultFolder ); williamr@2: williamr@2: protected: williamr@2: williamr@2: // Constructors and destructors williamr@2: williamr@2: CAknMemorySelectionDialog( TCommonDialogType aDialogType ); williamr@2: williamr@2: /** williamr@2: * Constructs class from resource williamr@2: * williamr@2: * @param aResourceId ID of the resource. Can be zero. williamr@2: * @param aShowUnavailableDrives Defines whether unavailable or corrupted williamr@2: * drives are shown in memory selection list or not. williamr@2: */ williamr@2: virtual void ConstructFromResourceL( williamr@2: TInt aResourceId, williamr@2: TBool aShowUnavailableDrives ); williamr@2: williamr@2: /** williamr@2: * Constructs class from resource williamr@2: * williamr@2: * @param aResourceId ID of the resource. Can be zero. williamr@2: * @param aShowUnavailableDrives Defines whether unavailable or corrupted williamr@2: * drives are shown in memory selection list or not. williamr@2: * @param aIncludedMedias bit flag definition of which medias are williamr@2: * included in the dialog. See TMemoryTypes. williamr@2: */ williamr@2: virtual void ConstructFromResourceL( williamr@2: TInt aResourceId, williamr@2: TBool aShowUnavailableDrives, williamr@2: TInt aIncludedMedias ); williamr@2: williamr@2: private: williamr@2: williamr@2: // New functions williamr@2: williamr@2: /** williamr@2: * A static method for launching a memory selection dialog. williamr@2: * Creates, constructs, runs and deletes a memory selection dialog with williamr@2: * different parameters. williamr@2: * williamr@2: * @param aResourceId An id of a resource. williamr@2: * @param aSelectedMemory A reference to a memory described in ExecuteL. williamr@2: * @param aRootPath A pointer to a descriptor where the root path williamr@2: * of the selected memory is stored. williamr@2: * @param aDefaultFolder A pointer to a descriptor where the default folder williamr@2: * of the selected memory is stored. williamr@2: * @param aTitle A title for memory selection dialog. williamr@2: * @param aObserver An observer which is asked if the selected item williamr@2: * can be selected. Implemented in application.. williamr@2: */ williamr@2: static TBool RunL( williamr@2: TInt aResourceId, williamr@2: TMemory& aSelectedMemory, williamr@2: TDes* aRootPath, williamr@2: TDes* aDefaultFolder, williamr@2: const TDesC& aTitle, williamr@2: MAknMemorySelectionObserver* aObserver ); williamr@2: williamr@2: williamr@2: /** williamr@2: * Sets id to a default CFD resource depending on dialog type. williamr@2: */ williamr@2: void SetResourceId( TInt& aResourceId, TCommonDialogType aDialogType ) williamr@2: const; williamr@2: williamr@2: /** williamr@2: * Reads settings from resource. williamr@2: * williamr@2: * @param aResourceId Resource's ID to be read. williamr@2: * @param aResourceDefined If user defines the resource. williamr@2: */ williamr@2: void ReadFromResourceL( TInt aResourceId, TBool aResourceDefined ); williamr@2: williamr@2: /** williamr@2: * Loads icons into the icon-array. williamr@2: * @param aIconArray Array of which to append the loaded icons. williamr@2: * @param aDoubleStyle Is the dialog doublestyle. williamr@2: */ williamr@2: void LoadIconsL( CAknIconArray* aIconArray, TBool aDoubleStyle ); williamr@2: williamr@2: /** williamr@2: * Loads default root and default paths of phone memory & memory card williamr@2: */ williamr@2: void GetSystemPathsL(); williamr@2: williamr@2: protected: // Data williamr@2: williamr@2: // Own: Dialog type williamr@2: TCommonDialogType iDialogType; williamr@2: williamr@2: // Own: Model williamr@2: CAknMemorySelectionModel* iModel; williamr@2: williamr@2: // Own: Event handler williamr@2: CAknMemorySelectionEventHandler* iEventHandler; williamr@2: williamr@2: // Ref: Observer williamr@2: MAknMemorySelectionObserver* iObserver; williamr@2: williamr@2: // Own: Title williamr@2: HBufC* iTitle; williamr@2: williamr@2: // Own: Left softkey text williamr@2: HBufC* iLeftSoftkey; williamr@2: williamr@2: // Own: Right softkey text williamr@2: HBufC* iRightSoftkey; williamr@2: williamr@2: // Own: Root path array williamr@2: // iDynamicDrivesEnabled indicates the content of this array. williamr@2: CDesCArrayFlat iRootPathArray; williamr@2: williamr@2: // Own: Default folder array williamr@2: CDesCArrayFlat iDefaultFolderArray; williamr@2: williamr@2: // Own: ETrue if dynamic drive reading is enabled williamr@2: // EFalse if drives are static (C: and E:). williamr@2: // This affects iRootPathArray and iDefaultFolderArray content and williamr@2: // ordering. williamr@2: TBool iDynamicDrivesEnabled; williamr@2: williamr@2: TInt iIncludedMedias; williamr@2: }; williamr@2: williamr@2: #endif // C_AKNMEMORYSELECTIONDIALOG_H