epoc32/include/mw/caknmemoryselectiondialogmultidrive.h
author William Roberts <williamr@symbian.org>
Tue, 16 Mar 2010 16:12:26 +0000
branchSymbian2
changeset 2 2fe1408b6811
parent 1 666f914201fb
child 4 837f303aceeb
permissions -rw-r--r--
Final list of Symbian^2 public API header files
williamr@2
     1
/*
williamr@2
     2
* Copyright (c) 2007 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@2
     5
* 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
     6
* which accompanies this distribution, and is available
williamr@2
     7
* at the URL "http://www.symbianfoundation.org/legal/licencesv10.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:  New memory selection dialog to support multiple drives.
williamr@2
    15
*
williamr@2
    16
*/
williamr@2
    17
williamr@2
    18
williamr@2
    19
williamr@2
    20
#ifndef C_AKNMEMORYSELECTIONDIALOGMULTIDRIVE_H
williamr@2
    21
#define C_AKNMEMORYSELECTIONDIALOGMULTIDRIVE_H
williamr@2
    22
williamr@2
    23
#include <CAknCommonDialogsBase.h>
williamr@2
    24
#include <badesca.h> // CDesCArray
williamr@2
    25
#include <f32file.h> // TDriveNumber
williamr@2
    26
williamr@2
    27
class CAknMemorySelectionModelMultiDrive;
williamr@2
    28
class CAknMemorySelectionEventHandler;
williamr@2
    29
class MAknMemorySelectionObserver;
williamr@2
    30
class TDriveInfo;
williamr@2
    31
class CAknIconArray;
williamr@2
    32
williamr@2
    33
/**
williamr@2
    34
 *  A class that launches a pop-up dialog for memory (drive) selection.
williamr@2
    35
 *
williamr@2
    36
 *  It is used to replace CAknMemorySelectionDialog class to support multiple
williamr@2
    37
 *  drives.
williamr@2
    38
 *
williamr@2
    39
 *  @lib CommonDialogs.lib
williamr@2
    40
 *  @since S60 5.0
williamr@2
    41
 */
williamr@2
    42
NONSHARABLE_CLASS( CAknMemorySelectionDialogMultiDrive )
williamr@2
    43
    : public CAknCommonDialogsBase
williamr@2
    44
    {
williamr@2
    45
public:
williamr@2
    46
williamr@2
    47
williamr@2
    48
// Constructors and destructors
williamr@2
    49
williamr@2
    50
    /**
williamr@2
    51
     * Static constructor.
williamr@2
    52
     *
williamr@2
    53
     * @since S60 5.0
williamr@2
    54
     * @param aDialogType Defines the type of the dialog in order to read
williamr@2
    55
     *        correct default settings for title and softkeys from resource.
williamr@2
    56
     * @param aShowUnavailableDrives Defines whether unavailable or corrupted
williamr@2
    57
     *        drives are shown in memory selection list or not.
williamr@2
    58
     * @return Returns a pointer to an instance of itself.
williamr@2
    59
     */
williamr@2
    60
    IMPORT_C static CAknMemorySelectionDialogMultiDrive* NewL(
williamr@2
    61
        TCommonDialogType aDialogType,
williamr@2
    62
        TBool aShowUnavailableDrives );
williamr@2
    63
williamr@2
    64
williamr@2
    65
    /**
williamr@2
    66
     * Static constructor.
williamr@2
    67
     *
williamr@2
    68
     * @since S60 5.0
williamr@2
    69
     * @param aDialogType Defines the type of the dialog in order to read
williamr@2
    70
     *        correct default settings for title and softkeys from resource.
williamr@2
    71
     * @param aResourceId A resource id (MEMORYSELECTIONDIALOG). "Locations"
williamr@2
    72
     *                    part of resource is not used any more.
williamr@2
    73
     * @param aShowUnavailableDrives Defines whether unavailable or corrupted
williamr@2
    74
     *        drives are shown in memory selection list or not.
williamr@2
    75
     * @return Returns a pointer to an instance of itself.
williamr@2
    76
     */
williamr@2
    77
    IMPORT_C static CAknMemorySelectionDialogMultiDrive* NewL(
williamr@2
    78
        TCommonDialogType aDialogType,
williamr@2
    79
        TInt aResourceId,
williamr@2
    80
        TBool aShowUnavailableDrives );
williamr@2
    81
williamr@2
    82
    /**
williamr@2
    83
     * Static constructor.
williamr@2
    84
     *
williamr@2
    85
     * @since S60 5.0
williamr@2
    86
     * @param aDialogType Defines the type of the dialog in order to read
williamr@2
    87
     *        correct default settings for title and softkeys from resource.
williamr@2
    88
     * @param aResourceId A resource id (MEMORYSELECTIONDIALOG). "Locations"
williamr@2
    89
     *                    part of resource is not used any more.
williamr@2
    90
     * @param aShowUnavailableDrives Defines whether unavailable or corrupted
williamr@2
    91
     *        drives are shown in memory selection list or not.
williamr@2
    92
     * @param aIncludedMedias bit flag definition of which medias are
williamr@2
    93
     *        included in the dialog. See TMemoryTypes.
williamr@2
    94
     * @return Returns a pointer to an instance of itself.
williamr@2
    95
     */
williamr@2
    96
    IMPORT_C static CAknMemorySelectionDialogMultiDrive* NewL(
williamr@2
    97
        TCommonDialogType aDialogType,
williamr@2
    98
        TInt aResourceId,
williamr@2
    99
        TBool aShowUnavailableDrives,
williamr@2
   100
        TInt aIncludedMedias );
williamr@2
   101
williamr@2
   102
    IMPORT_C virtual ~CAknMemorySelectionDialogMultiDrive();
williamr@2
   103
williamr@2
   104
// New functions
williamr@2
   105
williamr@2
   106
    /**
williamr@2
   107
     * Sets title for the dialog.
williamr@2
   108
     *
williamr@2
   109
     * @since S60 5.0
williamr@2
   110
     * @param aText Title text.
williamr@2
   111
     */
williamr@2
   112
    IMPORT_C void SetTitleL( const TDesC& aText );
williamr@2
   113
williamr@2
   114
    /**
williamr@2
   115
     * Sets the text used for left softkey.
williamr@2
   116
     *
williamr@2
   117
     * @since S60 5.0
williamr@2
   118
     * @param aText The text used for left softkey.
williamr@2
   119
     */
williamr@2
   120
    IMPORT_C void SetLeftSoftkeyL( const TDesC& aText );
williamr@2
   121
williamr@2
   122
    /**
williamr@2
   123
     * Sets the text used for right softkey.
williamr@2
   124
     *
williamr@2
   125
     * @param aText The text used for right softkey.
williamr@2
   126
     */
williamr@2
   127
    IMPORT_C void SetRightSoftkeyL( const TDesC& aText );
williamr@2
   128
williamr@2
   129
    /**
williamr@2
   130
     * Gets an item from memory selection dialog at specified index.
williamr@2
   131
     *
williamr@2
   132
     * @since S60 5.0
williamr@2
   133
     * @param aIndex Index to the item in the memory selection list.
williamr@2
   134
     * @param aItem A reference to a descriptor where the item is stored.
williamr@2
   135
     */
williamr@2
   136
    IMPORT_C void GetItem( TInt aIndex, TDes& aItem );
williamr@2
   137
williamr@2
   138
williamr@2
   139
    /**
williamr@2
   140
     * Executes the memory selection dialog. Virtual to allow derivation.
williamr@2
   141
     *
williamr@2
   142
     * @since S60 5.0
williamr@2
   143
     * @param aSelectedDrive A reference to a drive.
williamr@2
   144
     *        If one of the drives is selected, the selected drive is
williamr@2
   145
     *        stored to the parameter.
williamr@2
   146
     * @return Returns true if user has selected an item and false
williamr@2
   147
     *         if user hits cancel.
williamr@2
   148
     */
williamr@2
   149
    IMPORT_C virtual TReturnKey ExecuteL( TDriveNumber& aSelectedDrive );
williamr@2
   150
williamr@2
   151
    /**
williamr@2
   152
     * Executes the memory selection dialog. Virtual to allow derivation.
williamr@2
   153
     *
williamr@2
   154
     * @since S60 5.0
williamr@2
   155
     * @param aSelectedDrive A reference to a drive.
williamr@2
   156
     *        If one of the drives is selected, the selected drive is
williamr@2
   157
     *        stored to the parameter.
williamr@2
   158
     * @param aRootPath A pointer to a descriptor where the root path
williamr@2
   159
     *        of the selected memory is stored.
williamr@2
   160
     * @param aDefaultFolder A pointer to a descriptor where the default folder
williamr@2
   161
     *        of the selected memory is stored.
williamr@2
   162
     * @return Returns true if user has selected an item and false
williamr@2
   163
     *         if user hits cancel.
williamr@2
   164
     */
williamr@2
   165
    IMPORT_C virtual TReturnKey ExecuteL(
williamr@2
   166
        TDriveNumber& aSelectedDrive,
williamr@2
   167
        TDes* aRootPath, TDes* aDefaultFolder );
williamr@2
   168
williamr@2
   169
    /**
williamr@2
   170
     * A static method that launches a memory selection dialog.
williamr@2
   171
     *
williamr@2
   172
     * @since S60 5.0
williamr@2
   173
     * @see RunL()
williamr@2
   174
     */
williamr@2
   175
    IMPORT_C static TBool RunDlgLD( TDriveNumber& aSelectedDrive );
williamr@2
   176
williamr@2
   177
    /**
williamr@2
   178
     * New overloaded function to support multiple drives.
williamr@2
   179
     * A static method that launches a memory selection dialog.
williamr@2
   180
     *
williamr@2
   181
     * @since S60 5.0
williamr@2
   182
     * @see RunL()
williamr@2
   183
     */
williamr@2
   184
    IMPORT_C static TBool RunDlgLD(
williamr@2
   185
        TDriveNumber& aSelectedDrive, const TDesC& aTitle );
williamr@2
   186
williamr@2
   187
    /**
williamr@2
   188
     * A static method that launches a memory selection dialog.
williamr@2
   189
     *
williamr@2
   190
     * @since S60 5.0
williamr@2
   191
     * @see RunL()
williamr@2
   192
     */
williamr@2
   193
    IMPORT_C static TBool RunDlgLD(
williamr@2
   194
        TDriveNumber& aSelectedDrive,
williamr@2
   195
        TInt aResourceId,
williamr@2
   196
        TDes* aRootPath = NULL,
williamr@2
   197
        TDes* aDefaultFolder = NULL );
williamr@2
   198
williamr@2
   199
    /**
williamr@2
   200
     * Returns the number of items in list box array.
williamr@2
   201
     * Not exported, for CFD internal use only.
williamr@2
   202
     *
williamr@2
   203
     * @return Returns the number of items in list box array.
williamr@2
   204
     */
williamr@2
   205
    TInt NumberOfItems() const;
williamr@2
   206
williamr@2
   207
    /**
williamr@2
   208
     * Maps drive paths according to drive number. This function is valid
williamr@2
   209
     * for dynamic drives.
williamr@2
   210
     *
williamr@2
   211
     * @since S60 5.0
williamr@2
   212
     * @param aDrive Drive number.
williamr@2
   213
     * @param aRootPath A pointer to a descriptor where the root path of the
williamr@2
   214
     *        selected drive will be stored. Must have KMaxFileName space.
williamr@2
   215
     *        Set to NULL to ignore.
williamr@2
   216
     * @param aDefaultFolder A pointer to a descriptor where the default folder
williamr@2
   217
     *        of the selected drive will be stored. Must have
williamr@2
   218
     *        KMaxFileNamespace.
williamr@2
   219
     *        Set to NULL to ignore.
williamr@2
   220
     * @return Return error code
williamr@2
   221
     *         KErrNone The drive is found in internal drive list
williamr@2
   222
     *         KErrNotFound The drive is not visible to user or does not exist
williamr@2
   223
     */
williamr@2
   224
    TInt GetDrivePaths( TDriveNumber aDrive,
williamr@2
   225
                        TDes* aRootPath,
williamr@2
   226
                        TDes* aDefaultFolder );
williamr@2
   227
williamr@2
   228
    /**
williamr@2
   229
     * Maps drive paths according to selected listbox item. This function is
williamr@2
   230
     * valid for dynamic drives. The prerequisite for this function is that
williamr@2
   231
     * iRootPathArray and additionally iDefaultFolderArray indexes map
williamr@2
   232
     * correctly to iModel's listbox items.
williamr@2
   233
     *
williamr@2
   234
     * @since S60 5.0
williamr@2
   235
     * @param aLbxIndex Index to the selected listbox item.
williamr@2
   236
     * @param aRootPath A pointer to a descriptor where the root path of the
williamr@2
   237
     *        selected drive will be stored. Must have KMaxFileName space.
williamr@2
   238
     *        Set to NULL to ignore.
williamr@2
   239
     * @param aDefaultFolder A pointer to a descriptor where the default folder
williamr@2
   240
     *        of the selected drive will be stored. Must have
williamr@2
   241
     *        KMaxFileNamespace.
williamr@2
   242
     *        Set to NULL to ignore.
williamr@2
   243
     * @return Return error code
williamr@2
   244
     *         KErrNone The drive is found in internal drive list
williamr@2
   245
     *         KErrNotFound The drive is not visible to user or does not exist
williamr@2
   246
     */
williamr@2
   247
    TInt GetDrivePaths( TInt aLbxIndex,
williamr@2
   248
                        TDes* aRootPath,
williamr@2
   249
                        TDes* aDefaultFolder );
williamr@2
   250
williamr@2
   251
    /**
williamr@2
   252
     * Add user defined root path and default folder into memory selection
williamr@2
   253
     * dialog. It is used to replace old user defined resource.
williamr@2
   254
     *
williamr@2
   255
     * @since S60 5.0
williamr@2
   256
     * @param aRootPath A pointer to a descriptor where the root path of the
williamr@2
   257
     *        selected drive will be stored. Must have KMaxFileName space.
williamr@2
   258
     *        Set to NULL to ignore.
williamr@2
   259
     *        The user defined root path will be added after each drive's root
williamr@2
   260
     *        path. For example, if user specifics "Sounds\Digital\" for root
williamr@2
   261
     *        path, then the root paths for all drives will be:
williamr@2
   262
     *        C:\Data\Sounds\Digital\
williamr@2
   263
     *        E:\Sounds\Digital\
williamr@2
   264
     *        F:\Sounds\Digital\
williamr@2
   265
     *        ...
williamr@2
   266
     *
williamr@2
   267
     * @param aDefaultFolder A pointer to a descriptor where the default folder
williamr@2
   268
     *        of the selected drive will be stored. Must have KMaxFileName
williamr@2
   269
     *        space. The user defined root path will be added after each drive's
williamr@2
   270
     *        root path. Set to NULL to ignore. For example, if user specifics
williamr@2
   271
     *        "MyFolder\" for default folder, then the default folders of all
williamr@2
   272
     *        drives will be:
williamr@2
   273
     *        <C drive's root path>\"MyFolder\"
williamr@2
   274
     *        ...
williamr@2
   275
     *        The trailing backslash will be added automatically whether user
williamr@2
   276
     *        add it or not.
williamr@2
   277
     *        
williamr@2
   278
     * @return Return error code
williamr@2
   279
     */
williamr@2
   280
    IMPORT_C TInt AddDrivePathsL( const TDesC& aRootPath,
williamr@2
   281
                                  const TDesC& aDefaultFolder );
williamr@2
   282
    
williamr@2
   283
    /**
williamr@2
   284
     * Gets item index based on given drive number.
williamr@2
   285
     *
williamr@2
   286
     * @since S60 5.0
williamr@2
   287
     * @param aDrive Drive to be searched.
williamr@2
   288
     * @return Return item index if given drive is found in memory selection
williamr@2
   289
     *         dialog's drive list. Othewise return KErrNotFound
williamr@2
   290
     */
williamr@2
   291
    IMPORT_C TInt FindIndexByDrive( const TDriveNumber& aDrive );
williamr@2
   292
    
williamr@2
   293
    /**
williamr@2
   294
     * Get drive number based on item index in the listbox
williamr@2
   295
     *
williamr@2
   296
     * @param aIndex Listbox's item index.
williamr@2
   297
     * @return Return drive number
williamr@2
   298
     */
williamr@2
   299
    TDriveNumber FindDriveByIndex( const TInt aIndex );
williamr@2
   300
    
williamr@2
   301
    /**
williamr@2
   302
     * Check if there is any unavailable MMC (not inserted).
williamr@2
   303
     * 
williamr@2
   304
     * @return ETrue There is at least one MMC unavailble.
williamr@2
   305
     *         EFalse MMC inserted.
williamr@2
   306
     */
williamr@2
   307
    TBool HasUnavailbleMMC();
williamr@2
   308
    
williamr@2
   309
    /**
williamr@2
   310
     * Update model.
williamr@2
   311
     * */
williamr@2
   312
    void UpdateModelL();
williamr@2
   313
    
williamr@2
   314
protected:
williamr@2
   315
williamr@2
   316
// Constructors and destructors
williamr@2
   317
williamr@2
   318
    CAknMemorySelectionDialogMultiDrive( TCommonDialogType aDialogType );
williamr@2
   319
williamr@2
   320
    /**
williamr@2
   321
     * Constructs class from resource
williamr@2
   322
     *
williamr@2
   323
     * @param aResourceId ID of the resource. Can be zero.
williamr@2
   324
     * @param aShowUnavailableDrives Defines whether unavailable or corrupted
williamr@2
   325
     *        drives are shown in memory selection list or not.
williamr@2
   326
     */
williamr@2
   327
    virtual void ConstructFromResourceL(
williamr@2
   328
        TInt aResourceId,
williamr@2
   329
        TBool aShowUnavailableDrives );
williamr@2
   330
williamr@2
   331
    /**
williamr@2
   332
     * Constructs class from resource
williamr@2
   333
     *
williamr@2
   334
     * @param aResourceId ID of the resource. Can be zero.
williamr@2
   335
     * @param aShowUnavailableDrives Defines whether unavailable or corrupted
williamr@2
   336
     *        drives are shown in memory selection list or not.
williamr@2
   337
     * @param aIncludedMedias bit flag definition of which medias are
williamr@2
   338
     *        included in the dialog. See TMemoryTypes.
williamr@2
   339
     */
williamr@2
   340
    virtual void ConstructFromResourceL(
williamr@2
   341
        TInt aResourceId,
williamr@2
   342
        TBool aShowUnavailableDrives,
williamr@2
   343
        TInt aIncludedMedias );
williamr@2
   344
        
williamr@2
   345
private:
williamr@2
   346
williamr@2
   347
//  New functions
williamr@2
   348
williamr@2
   349
    /**
williamr@2
   350
     * New overloaded function to support multiple drives.
williamr@2
   351
     * A static method for launching a memory selection dialog.
williamr@2
   352
     * Creates, constructs, runs and deletes a memory selection dialog with
williamr@2
   353
     * different parameters.
williamr@2
   354
     *
williamr@2
   355
     * @since S60 5.0
williamr@2
   356
     * @param aResourceId An id of a resource.
williamr@2
   357
     * @param aSelectedMemory A reference to a memory described in ExecuteL.
williamr@2
   358
     * @param aRootPath A pointer to a descriptor where the root path
williamr@2
   359
     *        of the selected memory is stored.
williamr@2
   360
     * @param aDefaultFolder A pointer to a descriptor where the default folder
williamr@2
   361
     *        of the selected memory is stored.
williamr@2
   362
     * @param aTitle A title for memory selection dialog.
williamr@2
   363
     */
williamr@2
   364
    static TBool RunL(
williamr@2
   365
        TInt aResourceId,
williamr@2
   366
        TDriveNumber& aSelectedDrive,
williamr@2
   367
        TDes* aRootPath,
williamr@2
   368
        TDes* aDefaultFolder,
williamr@2
   369
        const TDesC& aTitle );
williamr@2
   370
williamr@2
   371
    /**
williamr@2
   372
     * Sets id to a default CFD resource depending on dialog type.
williamr@2
   373
     */
williamr@2
   374
    void SetResourceId( TInt& aResourceId, TCommonDialogType aDialogType )
williamr@2
   375
        const;
williamr@2
   376
williamr@2
   377
    /**
williamr@2
   378
     * Reads settings from resource.
williamr@2
   379
     */
williamr@2
   380
    void ReadFromResourceL( TInt aResourceId );
williamr@2
   381
williamr@2
   382
    /**
williamr@2
   383
     * Loads icons into the icon-array.
williamr@2
   384
     * @param aIconArray Array of which to append the loaded icons.
williamr@2
   385
     * @param aDoubleStyle Is the dialog doublestyle.
williamr@2
   386
     */
williamr@2
   387
    void LoadIconsL( CAknIconArray* aIconArray, TBool aDoubleStyle );
williamr@2
   388
williamr@2
   389
    /**
williamr@2
   390
     * Get all user visible drives with information of their root paths and
williamr@2
   391
     * default folders.
williamr@2
   392
     * Internal usage for memory selection dialog
williamr@2
   393
     * @param aUserDefinedId Is the user defined resource id;
williamr@2
   394
     */
williamr@2
   395
    void GetSystemDrivesL( TInt aUserDefinedId );
williamr@2
   396
williamr@2
   397
protected:
williamr@2
   398
williamr@2
   399
// Data
williamr@2
   400
williamr@2
   401
    // Own: Dialog type
williamr@2
   402
    TCommonDialogType iDialogType;
williamr@2
   403
williamr@2
   404
    // Own: Model
williamr@2
   405
    CAknMemorySelectionModelMultiDrive* iModel;
williamr@2
   406
williamr@2
   407
    // Own: Event handler
williamr@2
   408
    CAknMemorySelectionEventHandler* iEventHandler;
williamr@2
   409
williamr@2
   410
    // Own: Title
williamr@2
   411
    HBufC* iTitle;
williamr@2
   412
williamr@2
   413
    // Own: Left softkey text
williamr@2
   414
    HBufC* iLeftSoftkey;
williamr@2
   415
williamr@2
   416
    // Own: Right softkey text
williamr@2
   417
    HBufC* iRightSoftkey;
williamr@2
   418
williamr@2
   419
    // Own: Root path array
williamr@2
   420
    CDesCArrayFlat iRootPathArray;
williamr@2
   421
williamr@2
   422
    // Own: Default folder array
williamr@2
   423
    CDesCArrayFlat iDefaultFolderArray;
williamr@2
   424
williamr@2
   425
    // Own: ETrue if dynamic drive reading is enabled
williamr@2
   426
    //      EFalse if drives are static (C: and E:).
williamr@2
   427
    // This affects iRootPathArray and iDefaultFolderArray content and
williamr@2
   428
    // ordering.
williamr@2
   429
    TBool iDynamicDrivesEnabled;
williamr@2
   430
williamr@2
   431
    /**
williamr@2
   432
     * Indicate which media types of drives could be visible.
williamr@2
   433
     */
williamr@2
   434
    TInt iIncludedMedias;
williamr@2
   435
    
williamr@2
   436
    };
williamr@2
   437
williamr@2
   438
#endif // C_AKNMEMORYSELECTIONDIALOGMULTIDRIVE_H