1.1 --- a/epoc32/include/mw/caknmemoryselectiondialogmultidrive.h Tue Nov 24 13:55:44 2009 +0000
1.2 +++ b/epoc32/include/mw/caknmemoryselectiondialogmultidrive.h Tue Mar 16 16:12:26 2010 +0000
1.3 @@ -1,1 +1,438 @@
1.4 -caknmemoryselectiondialogmultidrive.h
1.5 +/*
1.6 +* Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies).
1.7 +* All rights reserved.
1.8 +* This component and the accompanying materials are made available
1.9 +* 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
1.10 +* which accompanies this distribution, and is available
1.11 +* at the URL "http://www.symbianfoundation.org/legal/licencesv10.html".
1.12 +*
1.13 +* Initial Contributors:
1.14 +* Nokia Corporation - initial contribution.
1.15 +*
1.16 +* Contributors:
1.17 +*
1.18 +* Description: New memory selection dialog to support multiple drives.
1.19 +*
1.20 +*/
1.21 +
1.22 +
1.23 +
1.24 +#ifndef C_AKNMEMORYSELECTIONDIALOGMULTIDRIVE_H
1.25 +#define C_AKNMEMORYSELECTIONDIALOGMULTIDRIVE_H
1.26 +
1.27 +#include <CAknCommonDialogsBase.h>
1.28 +#include <badesca.h> // CDesCArray
1.29 +#include <f32file.h> // TDriveNumber
1.30 +
1.31 +class CAknMemorySelectionModelMultiDrive;
1.32 +class CAknMemorySelectionEventHandler;
1.33 +class MAknMemorySelectionObserver;
1.34 +class TDriveInfo;
1.35 +class CAknIconArray;
1.36 +
1.37 +/**
1.38 + * A class that launches a pop-up dialog for memory (drive) selection.
1.39 + *
1.40 + * It is used to replace CAknMemorySelectionDialog class to support multiple
1.41 + * drives.
1.42 + *
1.43 + * @lib CommonDialogs.lib
1.44 + * @since S60 5.0
1.45 + */
1.46 +NONSHARABLE_CLASS( CAknMemorySelectionDialogMultiDrive )
1.47 + : public CAknCommonDialogsBase
1.48 + {
1.49 +public:
1.50 +
1.51 +
1.52 +// Constructors and destructors
1.53 +
1.54 + /**
1.55 + * Static constructor.
1.56 + *
1.57 + * @since S60 5.0
1.58 + * @param aDialogType Defines the type of the dialog in order to read
1.59 + * correct default settings for title and softkeys from resource.
1.60 + * @param aShowUnavailableDrives Defines whether unavailable or corrupted
1.61 + * drives are shown in memory selection list or not.
1.62 + * @return Returns a pointer to an instance of itself.
1.63 + */
1.64 + IMPORT_C static CAknMemorySelectionDialogMultiDrive* NewL(
1.65 + TCommonDialogType aDialogType,
1.66 + TBool aShowUnavailableDrives );
1.67 +
1.68 +
1.69 + /**
1.70 + * Static constructor.
1.71 + *
1.72 + * @since S60 5.0
1.73 + * @param aDialogType Defines the type of the dialog in order to read
1.74 + * correct default settings for title and softkeys from resource.
1.75 + * @param aResourceId A resource id (MEMORYSELECTIONDIALOG). "Locations"
1.76 + * part of resource is not used any more.
1.77 + * @param aShowUnavailableDrives Defines whether unavailable or corrupted
1.78 + * drives are shown in memory selection list or not.
1.79 + * @return Returns a pointer to an instance of itself.
1.80 + */
1.81 + IMPORT_C static CAknMemorySelectionDialogMultiDrive* NewL(
1.82 + TCommonDialogType aDialogType,
1.83 + TInt aResourceId,
1.84 + TBool aShowUnavailableDrives );
1.85 +
1.86 + /**
1.87 + * Static constructor.
1.88 + *
1.89 + * @since S60 5.0
1.90 + * @param aDialogType Defines the type of the dialog in order to read
1.91 + * correct default settings for title and softkeys from resource.
1.92 + * @param aResourceId A resource id (MEMORYSELECTIONDIALOG). "Locations"
1.93 + * part of resource is not used any more.
1.94 + * @param aShowUnavailableDrives Defines whether unavailable or corrupted
1.95 + * drives are shown in memory selection list or not.
1.96 + * @param aIncludedMedias bit flag definition of which medias are
1.97 + * included in the dialog. See TMemoryTypes.
1.98 + * @return Returns a pointer to an instance of itself.
1.99 + */
1.100 + IMPORT_C static CAknMemorySelectionDialogMultiDrive* NewL(
1.101 + TCommonDialogType aDialogType,
1.102 + TInt aResourceId,
1.103 + TBool aShowUnavailableDrives,
1.104 + TInt aIncludedMedias );
1.105 +
1.106 + IMPORT_C virtual ~CAknMemorySelectionDialogMultiDrive();
1.107 +
1.108 +// New functions
1.109 +
1.110 + /**
1.111 + * Sets title for the dialog.
1.112 + *
1.113 + * @since S60 5.0
1.114 + * @param aText Title text.
1.115 + */
1.116 + IMPORT_C void SetTitleL( const TDesC& aText );
1.117 +
1.118 + /**
1.119 + * Sets the text used for left softkey.
1.120 + *
1.121 + * @since S60 5.0
1.122 + * @param aText The text used for left softkey.
1.123 + */
1.124 + IMPORT_C void SetLeftSoftkeyL( const TDesC& aText );
1.125 +
1.126 + /**
1.127 + * Sets the text used for right softkey.
1.128 + *
1.129 + * @param aText The text used for right softkey.
1.130 + */
1.131 + IMPORT_C void SetRightSoftkeyL( const TDesC& aText );
1.132 +
1.133 + /**
1.134 + * Gets an item from memory selection dialog at specified index.
1.135 + *
1.136 + * @since S60 5.0
1.137 + * @param aIndex Index to the item in the memory selection list.
1.138 + * @param aItem A reference to a descriptor where the item is stored.
1.139 + */
1.140 + IMPORT_C void GetItem( TInt aIndex, TDes& aItem );
1.141 +
1.142 +
1.143 + /**
1.144 + * Executes the memory selection dialog. Virtual to allow derivation.
1.145 + *
1.146 + * @since S60 5.0
1.147 + * @param aSelectedDrive A reference to a drive.
1.148 + * If one of the drives is selected, the selected drive is
1.149 + * stored to the parameter.
1.150 + * @return Returns true if user has selected an item and false
1.151 + * if user hits cancel.
1.152 + */
1.153 + IMPORT_C virtual TReturnKey ExecuteL( TDriveNumber& aSelectedDrive );
1.154 +
1.155 + /**
1.156 + * Executes the memory selection dialog. Virtual to allow derivation.
1.157 + *
1.158 + * @since S60 5.0
1.159 + * @param aSelectedDrive A reference to a drive.
1.160 + * If one of the drives is selected, the selected drive is
1.161 + * stored to the parameter.
1.162 + * @param aRootPath A pointer to a descriptor where the root path
1.163 + * of the selected memory is stored.
1.164 + * @param aDefaultFolder A pointer to a descriptor where the default folder
1.165 + * of the selected memory is stored.
1.166 + * @return Returns true if user has selected an item and false
1.167 + * if user hits cancel.
1.168 + */
1.169 + IMPORT_C virtual TReturnKey ExecuteL(
1.170 + TDriveNumber& aSelectedDrive,
1.171 + TDes* aRootPath, TDes* aDefaultFolder );
1.172 +
1.173 + /**
1.174 + * A static method that launches a memory selection dialog.
1.175 + *
1.176 + * @since S60 5.0
1.177 + * @see RunL()
1.178 + */
1.179 + IMPORT_C static TBool RunDlgLD( TDriveNumber& aSelectedDrive );
1.180 +
1.181 + /**
1.182 + * New overloaded function to support multiple drives.
1.183 + * A static method that launches a memory selection dialog.
1.184 + *
1.185 + * @since S60 5.0
1.186 + * @see RunL()
1.187 + */
1.188 + IMPORT_C static TBool RunDlgLD(
1.189 + TDriveNumber& aSelectedDrive, const TDesC& aTitle );
1.190 +
1.191 + /**
1.192 + * A static method that launches a memory selection dialog.
1.193 + *
1.194 + * @since S60 5.0
1.195 + * @see RunL()
1.196 + */
1.197 + IMPORT_C static TBool RunDlgLD(
1.198 + TDriveNumber& aSelectedDrive,
1.199 + TInt aResourceId,
1.200 + TDes* aRootPath = NULL,
1.201 + TDes* aDefaultFolder = NULL );
1.202 +
1.203 + /**
1.204 + * Returns the number of items in list box array.
1.205 + * Not exported, for CFD internal use only.
1.206 + *
1.207 + * @return Returns the number of items in list box array.
1.208 + */
1.209 + TInt NumberOfItems() const;
1.210 +
1.211 + /**
1.212 + * Maps drive paths according to drive number. This function is valid
1.213 + * for dynamic drives.
1.214 + *
1.215 + * @since S60 5.0
1.216 + * @param aDrive Drive number.
1.217 + * @param aRootPath A pointer to a descriptor where the root path of the
1.218 + * selected drive will be stored. Must have KMaxFileName space.
1.219 + * Set to NULL to ignore.
1.220 + * @param aDefaultFolder A pointer to a descriptor where the default folder
1.221 + * of the selected drive will be stored. Must have
1.222 + * KMaxFileNamespace.
1.223 + * Set to NULL to ignore.
1.224 + * @return Return error code
1.225 + * KErrNone The drive is found in internal drive list
1.226 + * KErrNotFound The drive is not visible to user or does not exist
1.227 + */
1.228 + TInt GetDrivePaths( TDriveNumber aDrive,
1.229 + TDes* aRootPath,
1.230 + TDes* aDefaultFolder );
1.231 +
1.232 + /**
1.233 + * Maps drive paths according to selected listbox item. This function is
1.234 + * valid for dynamic drives. The prerequisite for this function is that
1.235 + * iRootPathArray and additionally iDefaultFolderArray indexes map
1.236 + * correctly to iModel's listbox items.
1.237 + *
1.238 + * @since S60 5.0
1.239 + * @param aLbxIndex Index to the selected listbox item.
1.240 + * @param aRootPath A pointer to a descriptor where the root path of the
1.241 + * selected drive will be stored. Must have KMaxFileName space.
1.242 + * Set to NULL to ignore.
1.243 + * @param aDefaultFolder A pointer to a descriptor where the default folder
1.244 + * of the selected drive will be stored. Must have
1.245 + * KMaxFileNamespace.
1.246 + * Set to NULL to ignore.
1.247 + * @return Return error code
1.248 + * KErrNone The drive is found in internal drive list
1.249 + * KErrNotFound The drive is not visible to user or does not exist
1.250 + */
1.251 + TInt GetDrivePaths( TInt aLbxIndex,
1.252 + TDes* aRootPath,
1.253 + TDes* aDefaultFolder );
1.254 +
1.255 + /**
1.256 + * Add user defined root path and default folder into memory selection
1.257 + * dialog. It is used to replace old user defined resource.
1.258 + *
1.259 + * @since S60 5.0
1.260 + * @param aRootPath A pointer to a descriptor where the root path of the
1.261 + * selected drive will be stored. Must have KMaxFileName space.
1.262 + * Set to NULL to ignore.
1.263 + * The user defined root path will be added after each drive's root
1.264 + * path. For example, if user specifics "Sounds\Digital\" for root
1.265 + * path, then the root paths for all drives will be:
1.266 + * C:\Data\Sounds\Digital\
1.267 + * E:\Sounds\Digital\
1.268 + * F:\Sounds\Digital\
1.269 + * ...
1.270 + *
1.271 + * @param aDefaultFolder A pointer to a descriptor where the default folder
1.272 + * of the selected drive will be stored. Must have KMaxFileName
1.273 + * space. The user defined root path will be added after each drive's
1.274 + * root path. Set to NULL to ignore. For example, if user specifics
1.275 + * "MyFolder\" for default folder, then the default folders of all
1.276 + * drives will be:
1.277 + * <C drive's root path>\"MyFolder\"
1.278 + * ...
1.279 + * The trailing backslash will be added automatically whether user
1.280 + * add it or not.
1.281 + *
1.282 + * @return Return error code
1.283 + */
1.284 + IMPORT_C TInt AddDrivePathsL( const TDesC& aRootPath,
1.285 + const TDesC& aDefaultFolder );
1.286 +
1.287 + /**
1.288 + * Gets item index based on given drive number.
1.289 + *
1.290 + * @since S60 5.0
1.291 + * @param aDrive Drive to be searched.
1.292 + * @return Return item index if given drive is found in memory selection
1.293 + * dialog's drive list. Othewise return KErrNotFound
1.294 + */
1.295 + IMPORT_C TInt FindIndexByDrive( const TDriveNumber& aDrive );
1.296 +
1.297 + /**
1.298 + * Get drive number based on item index in the listbox
1.299 + *
1.300 + * @param aIndex Listbox's item index.
1.301 + * @return Return drive number
1.302 + */
1.303 + TDriveNumber FindDriveByIndex( const TInt aIndex );
1.304 +
1.305 + /**
1.306 + * Check if there is any unavailable MMC (not inserted).
1.307 + *
1.308 + * @return ETrue There is at least one MMC unavailble.
1.309 + * EFalse MMC inserted.
1.310 + */
1.311 + TBool HasUnavailbleMMC();
1.312 +
1.313 + /**
1.314 + * Update model.
1.315 + * */
1.316 + void UpdateModelL();
1.317 +
1.318 +protected:
1.319 +
1.320 +// Constructors and destructors
1.321 +
1.322 + CAknMemorySelectionDialogMultiDrive( TCommonDialogType aDialogType );
1.323 +
1.324 + /**
1.325 + * Constructs class from resource
1.326 + *
1.327 + * @param aResourceId ID of the resource. Can be zero.
1.328 + * @param aShowUnavailableDrives Defines whether unavailable or corrupted
1.329 + * drives are shown in memory selection list or not.
1.330 + */
1.331 + virtual void ConstructFromResourceL(
1.332 + TInt aResourceId,
1.333 + TBool aShowUnavailableDrives );
1.334 +
1.335 + /**
1.336 + * Constructs class from resource
1.337 + *
1.338 + * @param aResourceId ID of the resource. Can be zero.
1.339 + * @param aShowUnavailableDrives Defines whether unavailable or corrupted
1.340 + * drives are shown in memory selection list or not.
1.341 + * @param aIncludedMedias bit flag definition of which medias are
1.342 + * included in the dialog. See TMemoryTypes.
1.343 + */
1.344 + virtual void ConstructFromResourceL(
1.345 + TInt aResourceId,
1.346 + TBool aShowUnavailableDrives,
1.347 + TInt aIncludedMedias );
1.348 +
1.349 +private:
1.350 +
1.351 +// New functions
1.352 +
1.353 + /**
1.354 + * New overloaded function to support multiple drives.
1.355 + * A static method for launching a memory selection dialog.
1.356 + * Creates, constructs, runs and deletes a memory selection dialog with
1.357 + * different parameters.
1.358 + *
1.359 + * @since S60 5.0
1.360 + * @param aResourceId An id of a resource.
1.361 + * @param aSelectedMemory A reference to a memory described in ExecuteL.
1.362 + * @param aRootPath A pointer to a descriptor where the root path
1.363 + * of the selected memory is stored.
1.364 + * @param aDefaultFolder A pointer to a descriptor where the default folder
1.365 + * of the selected memory is stored.
1.366 + * @param aTitle A title for memory selection dialog.
1.367 + */
1.368 + static TBool RunL(
1.369 + TInt aResourceId,
1.370 + TDriveNumber& aSelectedDrive,
1.371 + TDes* aRootPath,
1.372 + TDes* aDefaultFolder,
1.373 + const TDesC& aTitle );
1.374 +
1.375 + /**
1.376 + * Sets id to a default CFD resource depending on dialog type.
1.377 + */
1.378 + void SetResourceId( TInt& aResourceId, TCommonDialogType aDialogType )
1.379 + const;
1.380 +
1.381 + /**
1.382 + * Reads settings from resource.
1.383 + */
1.384 + void ReadFromResourceL( TInt aResourceId );
1.385 +
1.386 + /**
1.387 + * Loads icons into the icon-array.
1.388 + * @param aIconArray Array of which to append the loaded icons.
1.389 + * @param aDoubleStyle Is the dialog doublestyle.
1.390 + */
1.391 + void LoadIconsL( CAknIconArray* aIconArray, TBool aDoubleStyle );
1.392 +
1.393 + /**
1.394 + * Get all user visible drives with information of their root paths and
1.395 + * default folders.
1.396 + * Internal usage for memory selection dialog
1.397 + * @param aUserDefinedId Is the user defined resource id;
1.398 + */
1.399 + void GetSystemDrivesL( TInt aUserDefinedId );
1.400 +
1.401 +protected:
1.402 +
1.403 +// Data
1.404 +
1.405 + // Own: Dialog type
1.406 + TCommonDialogType iDialogType;
1.407 +
1.408 + // Own: Model
1.409 + CAknMemorySelectionModelMultiDrive* iModel;
1.410 +
1.411 + // Own: Event handler
1.412 + CAknMemorySelectionEventHandler* iEventHandler;
1.413 +
1.414 + // Own: Title
1.415 + HBufC* iTitle;
1.416 +
1.417 + // Own: Left softkey text
1.418 + HBufC* iLeftSoftkey;
1.419 +
1.420 + // Own: Right softkey text
1.421 + HBufC* iRightSoftkey;
1.422 +
1.423 + // Own: Root path array
1.424 + CDesCArrayFlat iRootPathArray;
1.425 +
1.426 + // Own: Default folder array
1.427 + CDesCArrayFlat iDefaultFolderArray;
1.428 +
1.429 + // Own: ETrue if dynamic drive reading is enabled
1.430 + // EFalse if drives are static (C: and E:).
1.431 + // This affects iRootPathArray and iDefaultFolderArray content and
1.432 + // ordering.
1.433 + TBool iDynamicDrivesEnabled;
1.434 +
1.435 + /**
1.436 + * Indicate which media types of drives could be visible.
1.437 + */
1.438 + TInt iIncludedMedias;
1.439 +
1.440 + };
1.441 +
1.442 +#endif // C_AKNMEMORYSELECTIONDIALOGMULTIDRIVE_H