williamr@2: /* williamr@2: * Copyright (c) 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@4: * under the terms of "Eclipse Public License v1.0" williamr@2: * which accompanies this distribution, and is available williamr@4: * at the URL "http://www.eclipse.org/legal/epl-v10.html". williamr@2: * williamr@2: * Initial Contributors: williamr@2: * Nokia Corporation - initial contribution. williamr@2: * williamr@2: * Contributors: williamr@2: * williamr@2: * Description: New memory selection dialog to support multiple drives. williamr@2: * williamr@2: */ williamr@2: williamr@2: williamr@2: williamr@2: #ifndef C_AKNMEMORYSELECTIONDIALOGMULTIDRIVE_H williamr@2: #define C_AKNMEMORYSELECTIONDIALOGMULTIDRIVE_H williamr@2: williamr@2: #include williamr@2: #include // CDesCArray williamr@2: #include // TDriveNumber williamr@2: williamr@2: class CAknMemorySelectionModelMultiDrive; 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 (drive) selection. williamr@2: * williamr@2: * It is used to replace CAknMemorySelectionDialog class to support multiple williamr@2: * drives. williamr@2: * williamr@2: * @lib CommonDialogs.lib williamr@2: * @since S60 5.0 williamr@2: */ williamr@2: NONSHARABLE_CLASS( CAknMemorySelectionDialogMultiDrive ) williamr@2: : public CAknCommonDialogsBase williamr@2: { williamr@2: public: williamr@2: williamr@2: williamr@2: // Constructors and destructors williamr@2: williamr@2: /** williamr@2: * Static constructor. williamr@2: * williamr@2: * @since S60 5.0 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 CAknMemorySelectionDialogMultiDrive* 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 5.0 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). "Locations" williamr@2: * part of resource is not used any more. 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 CAknMemorySelectionDialogMultiDrive* 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 5.0 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). "Locations" williamr@2: * part of resource is not used any more. 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 CAknMemorySelectionDialogMultiDrive* NewL( williamr@2: TCommonDialogType aDialogType, williamr@2: TInt aResourceId, williamr@2: TBool aShowUnavailableDrives, williamr@2: TInt aIncludedMedias ); williamr@2: williamr@2: IMPORT_C virtual ~CAknMemorySelectionDialogMultiDrive(); williamr@2: williamr@2: // New functions williamr@2: williamr@2: /** williamr@2: * Sets title for the dialog. williamr@2: * williamr@2: * @since S60 5.0 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: * @since S60 5.0 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: * @since S60 5.0 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: /** williamr@2: * Executes the memory selection dialog. Virtual to allow derivation. williamr@2: * williamr@2: * @since S60 5.0 williamr@2: * @param aSelectedDrive A reference to a drive. williamr@2: * If one of the drives is selected, the selected drive 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( TDriveNumber& aSelectedDrive ); williamr@2: williamr@2: /** williamr@2: * Executes the memory selection dialog. Virtual to allow derivation. williamr@2: * williamr@2: * @since S60 5.0 williamr@2: * @param aSelectedDrive A reference to a drive. williamr@2: * If one of the drives is selected, the selected drive 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: TDriveNumber& aSelectedDrive, williamr@2: TDes* aRootPath, TDes* aDefaultFolder ); williamr@2: williamr@2: /** williamr@2: * A static method that launches a memory selection dialog. williamr@2: * williamr@2: * @since S60 5.0 williamr@2: * @see RunL() williamr@2: */ williamr@2: IMPORT_C static TBool RunDlgLD( TDriveNumber& aSelectedDrive ); williamr@2: williamr@2: /** williamr@2: * New overloaded function to support multiple drives. williamr@2: * A static method that launches a memory selection dialog. williamr@2: * williamr@2: * @since S60 5.0 williamr@2: * @see RunL() williamr@2: */ williamr@2: IMPORT_C static TBool RunDlgLD( williamr@2: TDriveNumber& aSelectedDrive, const TDesC& aTitle ); williamr@2: williamr@2: /** williamr@2: * A static method that launches a memory selection dialog. williamr@2: * williamr@2: * @since S60 5.0 williamr@2: * @see RunL() williamr@2: */ williamr@2: IMPORT_C static TBool RunDlgLD( williamr@2: TDriveNumber& aSelectedDrive, williamr@2: TInt aResourceId, williamr@2: TDes* aRootPath = NULL, williamr@2: TDes* aDefaultFolder = 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 drive number. This function is valid williamr@2: * for dynamic drives. williamr@2: * williamr@2: * @since S60 5.0 williamr@2: * @param aDrive Drive number. 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( TDriveNumber aDrive, williamr@2: TDes* aRootPath, williamr@2: TDes* aDefaultFolder ); 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 5.0 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: /** williamr@2: * Add user defined root path and default folder into memory selection williamr@2: * dialog. It is used to replace old user defined resource. williamr@2: * williamr@2: * @since S60 5.0 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: * The user defined root path will be added after each drive's root williamr@2: * path. For example, if user specifics "Sounds\Digital\" for root williamr@2: * path, then the root paths for all drives will be: williamr@2: * C:\Data\Sounds\Digital\ williamr@2: * E:\Sounds\Digital\ williamr@2: * F:\Sounds\Digital\ williamr@2: * ... williamr@2: * williamr@2: * @param aDefaultFolder A pointer to a descriptor where the default folder williamr@2: * of the selected drive will be stored. Must have KMaxFileName williamr@2: * space. The user defined root path will be added after each drive's williamr@2: * root path. Set to NULL to ignore. For example, if user specifics williamr@2: * "MyFolder\" for default folder, then the default folders of all williamr@2: * drives will be: williamr@2: * \"MyFolder\" williamr@2: * ... williamr@2: * The trailing backslash will be added automatically whether user williamr@2: * add it or not. williamr@2: * williamr@2: * @return Return error code williamr@2: */ williamr@2: IMPORT_C TInt AddDrivePathsL( const TDesC& aRootPath, williamr@2: const TDesC& aDefaultFolder ); williamr@2: williamr@2: /** williamr@2: * Gets item index based on given drive number. williamr@2: * williamr@2: * @since S60 5.0 williamr@2: * @param aDrive Drive to be searched. williamr@2: * @return Return item index if given drive is found in memory selection williamr@2: * dialog's drive list. Othewise return KErrNotFound williamr@2: */ williamr@2: IMPORT_C TInt FindIndexByDrive( const TDriveNumber& aDrive ); williamr@2: williamr@2: /** williamr@2: * Get drive number based on item index in the listbox williamr@2: * williamr@2: * @param aIndex Listbox's item index. williamr@2: * @return Return drive number williamr@2: */ williamr@2: TDriveNumber FindDriveByIndex( const TInt aIndex ); williamr@2: williamr@2: /** williamr@2: * Check if there is any unavailable MMC (not inserted). williamr@2: * williamr@2: * @return ETrue There is at least one MMC unavailble. williamr@2: * EFalse MMC inserted. williamr@2: */ williamr@2: TBool HasUnavailbleMMC(); williamr@2: williamr@2: /** williamr@2: * Update model. williamr@2: * */ williamr@2: void UpdateModelL(); williamr@2: williamr@2: protected: williamr@2: williamr@2: // Constructors and destructors williamr@2: williamr@2: CAknMemorySelectionDialogMultiDrive( 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: * New overloaded function to support multiple drives. 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: * @since S60 5.0 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: */ williamr@2: static TBool RunL( williamr@2: TInt aResourceId, williamr@2: TDriveNumber& aSelectedDrive, williamr@2: TDes* aRootPath, williamr@2: TDes* aDefaultFolder, williamr@2: const TDesC& aTitle ); 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: void ReadFromResourceL( TInt aResourceId ); 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: * Get all user visible drives with information of their root paths and williamr@2: * default folders. williamr@2: * Internal usage for memory selection dialog williamr@2: * @param aUserDefinedId Is the user defined resource id; williamr@2: */ williamr@2: void GetSystemDrivesL( TInt aUserDefinedId ); williamr@2: williamr@2: protected: williamr@2: williamr@2: // Data williamr@2: williamr@2: // Own: Dialog type williamr@2: TCommonDialogType iDialogType; williamr@2: williamr@2: // Own: Model williamr@2: CAknMemorySelectionModelMultiDrive* iModel; williamr@2: williamr@2: // Own: Event handler williamr@2: CAknMemorySelectionEventHandler* iEventHandler; 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: 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: /** williamr@2: * Indicate which media types of drives could be visible. williamr@2: */ williamr@2: TInt iIncludedMedias; williamr@2: williamr@2: }; williamr@2: williamr@2: #endif // C_AKNMEMORYSELECTIONDIALOGMULTIDRIVE_H