epoc32/include/mw/caknmemoryselectiondialog.h
author William Roberts <williamr@symbian.org>
Wed, 31 Mar 2010 12:33:34 +0100
branchSymbian3
changeset 4 837f303aceeb
parent 2 2fe1408b6811
permissions -rw-r--r--
Current Symbian^3 public API header files (from PDK 3.0.h)
This is the epoc32/include tree with the "platform" subtrees removed, and
all but a selected few mbg and rsg files removed.
williamr@2
     1
/*
williamr@2
     2
* Copyright (c) 2002-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@4
     5
* under the terms of "Eclipse Public License v1.0"
williamr@2
     6
* which accompanies this distribution, and is available
williamr@4
     7
* at the URL "http://www.eclipse.org/legal/epl-v10.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:  Dialog used to selection target memory.
williamr@2
    15
*
williamr@2
    16
*/
williamr@2
    17
williamr@2
    18
williamr@2
    19
#ifndef C_AKNMEMORYSELECTIONDIALOG_H
williamr@2
    20
#define C_AKNMEMORYSELECTIONDIALOG_H
williamr@2
    21
williamr@2
    22
#include <CAknCommonDialogsBase.h>
williamr@2
    23
#include <badesca.h> // CDesCArray
williamr@2
    24
williamr@2
    25
class CAknMemorySelectionModel;
williamr@2
    26
class CAknMemorySelectionEventHandler;
williamr@2
    27
class MAknMemorySelectionObserver;
williamr@2
    28
class TDriveInfo;
williamr@2
    29
class CAknIconArray;
williamr@2
    30
williamr@2
    31
/**
williamr@2
    32
 *  A class that launches a pop-up dialog for memory selection.
williamr@2
    33
 *
williamr@2
    34
 *  @lib CommonDialogs.lib
williamr@2
    35
 *  @since S60 1.2
williamr@2
    36
 */
williamr@2
    37
NONSHARABLE_CLASS(CAknMemorySelectionDialog) : public CAknCommonDialogsBase
williamr@2
    38
    {
williamr@2
    39
williamr@2
    40
public:
williamr@2
    41
williamr@2
    42
// Enumerations
williamr@2
    43
    /**
williamr@2
    44
     * @Deprecated: This only works with fixed C: and E: drives.
williamr@2
    45
     * Enumerations for memory items in listbox .
williamr@2
    46
     */
williamr@2
    47
    enum TMemory
williamr@2
    48
        {
williamr@2
    49
        EPhoneMemory = 0,   // C:
williamr@2
    50
        EMemoryCard,        // E:
williamr@2
    51
        EMemoryCount        // must remain last one
williamr@2
    52
        };
williamr@2
    53
williamr@2
    54
// Constructors and destructors
williamr@2
    55
williamr@2
    56
    /**
williamr@2
    57
     * Static constructor.
williamr@2
    58
     *
williamr@2
    59
     * @since S60 3.2
williamr@2
    60
     * @param aDialogType Defines the type of the dialog in order to read
williamr@2
    61
     *        correct default settings for title and softkeys from resource.
williamr@2
    62
     * @param aShowUnavailableDrives Defines whether unavailable or corrupted
williamr@2
    63
     *        drives are shown in memory selection list or not.
williamr@2
    64
     * @return Returns a pointer to an instance of itself.
williamr@2
    65
     */
williamr@2
    66
    IMPORT_C static CAknMemorySelectionDialog* NewL(
williamr@2
    67
        TCommonDialogType aDialogType,
williamr@2
    68
        TBool aShowUnavailableDrives );
williamr@2
    69
williamr@2
    70
williamr@2
    71
    /**
williamr@2
    72
     * Static constructor.
williamr@2
    73
     *
williamr@2
    74
     * @since S60 3.2
williamr@2
    75
     * @param aDialogType Defines the type of the dialog in order to read
williamr@2
    76
     *        correct default settings for title and softkeys from resource.
williamr@2
    77
     * @param aResourceId A resource id (MEMORYSELECTIONDIALOG).
williamr@2
    78
     * @param aShowUnavailableDrives Defines whether unavailable or corrupted
williamr@2
    79
     *        drives are shown in memory selection list or not.
williamr@2
    80
     * @return Returns a pointer to an instance of itself.
williamr@2
    81
     */
williamr@2
    82
    IMPORT_C static CAknMemorySelectionDialog* NewL(
williamr@2
    83
        TCommonDialogType aDialogType,
williamr@2
    84
        TInt aResourceId,
williamr@2
    85
        TBool aShowUnavailableDrives );
williamr@2
    86
williamr@2
    87
    /**
williamr@2
    88
     * Static constructor.
williamr@2
    89
     *
williamr@2
    90
     * @since S60 3.2
williamr@2
    91
     * @param aDialogType Defines the type of the dialog in order to read
williamr@2
    92
     *        correct default settings for title and softkeys from resource.
williamr@2
    93
     * @param aResourceId A resource id (MEMORYSELECTIONDIALOG).
williamr@2
    94
     * @param aShowUnavailableDrives Defines whether unavailable or corrupted
williamr@2
    95
     *        drives are shown in memory selection list or not.
williamr@2
    96
     * @param aIncludedMedias bit flag definition of which medias are
williamr@2
    97
     *        included in the dialog. See TMemoryTypes.
williamr@2
    98
     * @return Returns a pointer to an instance of itself.
williamr@2
    99
     */
williamr@2
   100
    IMPORT_C static CAknMemorySelectionDialog* NewL(
williamr@2
   101
        TCommonDialogType aDialogType,
williamr@2
   102
        TInt aResourceId,
williamr@2
   103
        TBool aShowUnavailableDrives,
williamr@2
   104
        TInt aIncludedMedias );
williamr@2
   105
williamr@2
   106
    IMPORT_C virtual ~CAknMemorySelectionDialog();
williamr@2
   107
williamr@2
   108
// New functions
williamr@2
   109
williamr@2
   110
    /**
williamr@2
   111
     * Sets an observer which is asked if the selected item can be selected.
williamr@2
   112
     *
williamr@2
   113
     * @param aObserver A pointer to an observer.
williamr@2
   114
     */
williamr@2
   115
    IMPORT_C void SetObserver( MAknMemorySelectionObserver* aObserver );
williamr@2
   116
williamr@2
   117
    /**
williamr@2
   118
     * Sets title for the dialog.
williamr@2
   119
     *
williamr@2
   120
     * @param aText Title text.
williamr@2
   121
     */
williamr@2
   122
    IMPORT_C void SetTitleL( const TDesC& aText );
williamr@2
   123
williamr@2
   124
    /**
williamr@2
   125
     * Sets the text used for left softkey.
williamr@2
   126
     *
williamr@2
   127
     * @param aText The text used for left softkey.
williamr@2
   128
     */
williamr@2
   129
    IMPORT_C void SetLeftSoftkeyL( const TDesC& aText );
williamr@2
   130
williamr@2
   131
    /**
williamr@2
   132
     * Sets the text used for right softkey.
williamr@2
   133
     *
williamr@2
   134
     * @param aText The text used for right softkey.
williamr@2
   135
     */
williamr@2
   136
    IMPORT_C void SetRightSoftkeyL( const TDesC& aText );
williamr@2
   137
williamr@2
   138
    /**
williamr@2
   139
     * Gets an item from memory selection dialog at specified index.
williamr@2
   140
     *
williamr@2
   141
     * @param aIndex Index to the item in the memory selection list.
williamr@2
   142
     * @param aItem A reference to a descriptor where the item is stored.
williamr@2
   143
     */
williamr@2
   144
    IMPORT_C void GetItem( TInt aIndex, TDes& aItem );
williamr@2
   145
williamr@2
   146
    /**
williamr@2
   147
     * Gets the location paths of a memory.
williamr@2
   148
     *
williamr@2
   149
     * @param aSelectedMemory The memory that was selected.
williamr@2
   150
     * @param aRootPath A pointer to a descriptor where the root path
williamr@2
   151
     *        of the selected memory is stored. Must have KMaxFileName space.
williamr@2
   152
     *        Set to NULL to ignore.
williamr@2
   153
     * @param aDefaultFolder A pointer to a descriptor where the default folder
williamr@2
   154
     *        of the selected memory is stored. Must have KMaxFileName space.
williamr@2
   155
     *        Set to NULL to ignore.
williamr@2
   156
     */
williamr@2
   157
    IMPORT_C void GetMemories( TMemory aSelectedMemory,
williamr@2
   158
                               TDes* aRootPath,
williamr@2
   159
                               TDes* aDefaultFolder );
williamr@2
   160
williamr@2
   161
    /**
williamr@2
   162
     * Executes the memory selection dialog. Virtual to allow derivation.
williamr@2
   163
     *
williamr@2
   164
     * @param aSelectedMemory A reference to a memory (TMemory).
williamr@2
   165
     *        If one of the memories is selected, the selected memory is
williamr@2
   166
     *        stored to the parameter.
williamr@2
   167
     * @return Returns true if user has selected an item and false
williamr@2
   168
     *         if user hits cancel.
williamr@2
   169
     */
williamr@2
   170
    IMPORT_C virtual TReturnKey ExecuteL( TMemory& aSelectedMemory );
williamr@2
   171
williamr@2
   172
    /**
williamr@2
   173
     * Executes the memory selection dialog. Virtual to allow derivation.
williamr@2
   174
     *
williamr@2
   175
     * @param aSelectedMemory A reference to a memory (TMemory).
williamr@2
   176
     *        If one of the memories is selected, the selected memory is
williamr@2
   177
     *        stored to the parameter.
williamr@2
   178
     * @param aRootPath A pointer to a descriptor where the root path
williamr@2
   179
     *        of the selected memory is stored.
williamr@2
   180
     * @param aDefaultFolder A pointer to a descriptor where the default folder
williamr@2
   181
     *        of the selected memory is stored.
williamr@2
   182
     * @return Returns true if user has selected an item and false
williamr@2
   183
     *         if user hits cancel.
williamr@2
   184
     */
williamr@2
   185
    IMPORT_C virtual TReturnKey ExecuteL(
williamr@2
   186
        TMemory& aSelectedMemory,
williamr@2
   187
        TDes* aRootPath, TDes* aDefaultFolder );
williamr@2
   188
williamr@2
   189
    /**
williamr@2
   190
     * A static method that launches a memory selection dialog.
williamr@2
   191
     * @see RunL()
williamr@2
   192
     */
williamr@2
   193
    IMPORT_C static TBool RunDlgLD(
williamr@2
   194
        TMemory& aSelectedMemory,
williamr@2
   195
        MAknMemorySelectionObserver* aObserver = NULL );
williamr@2
   196
williamr@2
   197
    /**
williamr@2
   198
     * A static method that launches a memory selection dialog.
williamr@2
   199
     * @see RunL()
williamr@2
   200
     */
williamr@2
   201
    IMPORT_C static TBool RunDlgLD(
williamr@2
   202
        TMemory& aSelectedMemory,
williamr@2
   203
        const TDesC& aTitle,
williamr@2
   204
        MAknMemorySelectionObserver* aObserver = NULL );
williamr@2
   205
williamr@2
   206
    /**
williamr@2
   207
     * A static method that launches a memory selection dialog.
williamr@2
   208
     * @see RunL()
williamr@2
   209
     */
williamr@2
   210
    IMPORT_C static TBool RunDlgLD(
williamr@2
   211
        TMemory& aSelectedMemory,
williamr@2
   212
        TInt aResourceId,
williamr@2
   213
        TDes* aRootPath = NULL, TDes* aDefaultFolder = NULL,
williamr@2
   214
        MAknMemorySelectionObserver* aObserver = NULL );
williamr@2
   215
williamr@2
   216
    /**
williamr@2
   217
     * Returns the number of items in list box array.
williamr@2
   218
     * Not exported, for CFD internal use only.
williamr@2
   219
     *
williamr@2
   220
     * @return Returns the number of items in list box array.
williamr@2
   221
     */
williamr@2
   222
    TInt NumberOfItems() const;
williamr@2
   223
williamr@2
   224
    /**
williamr@2
   225
     * Maps drive paths according to selected listbox item. This function is
williamr@2
   226
     * valid for dynamic drives. The prerequisite for this function is that
williamr@2
   227
     * iRootPathArray and additionally iDefaultFolderArray indexes map
williamr@2
   228
     * correctly to iModel's listbox items.
williamr@2
   229
     *
williamr@2
   230
     * @since S60 3.2
williamr@2
   231
     * @param aLbxIndex Index to the selected listbox item.
williamr@2
   232
     * @param aRootPath A pointer to a descriptor where the root path of the
williamr@2
   233
     *        selected drive will be stored. Must have KMaxFileName space.
williamr@2
   234
     *        Set to NULL to ignore.
williamr@2
   235
     * @param aDefaultFolder A pointer to a descriptor where the default folder
williamr@2
   236
     *        of the selected drive will be stored. Must have
williamr@2
   237
     *        KMaxFileNamespace.
williamr@2
   238
     *        Set to NULL to ignore.
williamr@2
   239
     * @return Return error code
williamr@2
   240
     *         KErrNone The drive is found in internal drive list
williamr@2
   241
     *         KErrNotFound The drive is not visible to user or does not exist
williamr@2
   242
     */
williamr@2
   243
    TInt GetDrivePaths( TInt aLbxIndex,
williamr@2
   244
                        TDes* aRootPath,
williamr@2
   245
                        TDes* aDefaultFolder );
williamr@2
   246
williamr@2
   247
protected:
williamr@2
   248
williamr@2
   249
// Constructors and destructors
williamr@2
   250
williamr@2
   251
    CAknMemorySelectionDialog( TCommonDialogType aDialogType );
williamr@2
   252
williamr@2
   253
    /**
williamr@2
   254
     * Constructs class from resource
williamr@2
   255
     *
williamr@2
   256
     * @param aResourceId ID of the resource. Can be zero.
williamr@2
   257
     * @param aShowUnavailableDrives Defines whether unavailable or corrupted
williamr@2
   258
     *        drives are shown in memory selection list or not.
williamr@2
   259
     */
williamr@2
   260
    virtual void ConstructFromResourceL(
williamr@2
   261
        TInt aResourceId,
williamr@2
   262
        TBool aShowUnavailableDrives );
williamr@2
   263
williamr@2
   264
    /**
williamr@2
   265
     * Constructs class from resource
williamr@2
   266
     *
williamr@2
   267
     * @param aResourceId ID of the resource. Can be zero.
williamr@2
   268
     * @param aShowUnavailableDrives Defines whether unavailable or corrupted
williamr@2
   269
     *        drives are shown in memory selection list or not.
williamr@2
   270
     * @param aIncludedMedias bit flag definition of which medias are
williamr@2
   271
     *        included in the dialog. See TMemoryTypes.
williamr@2
   272
     */
williamr@2
   273
    virtual void ConstructFromResourceL(
williamr@2
   274
        TInt aResourceId,
williamr@2
   275
        TBool aShowUnavailableDrives,
williamr@2
   276
        TInt aIncludedMedias );
williamr@2
   277
williamr@2
   278
private:
williamr@2
   279
williamr@2
   280
//  New functions
williamr@2
   281
williamr@2
   282
    /**
williamr@2
   283
     * A static method for launching a memory selection dialog.
williamr@2
   284
     * Creates, constructs, runs and deletes a memory selection dialog with
williamr@2
   285
     * different parameters.
williamr@2
   286
     *
williamr@2
   287
     * @param aResourceId An id of a resource.
williamr@2
   288
     * @param aSelectedMemory A reference to a memory described in ExecuteL.
williamr@2
   289
     * @param aRootPath A pointer to a descriptor where the root path
williamr@2
   290
     *        of the selected memory is stored.
williamr@2
   291
     * @param aDefaultFolder A pointer to a descriptor where the default folder
williamr@2
   292
     *        of the selected memory is stored.
williamr@2
   293
     * @param aTitle A title for memory selection dialog.
williamr@2
   294
     * @param aObserver An observer which is asked if the selected item
williamr@2
   295
     *        can be selected. Implemented in application..
williamr@2
   296
     */
williamr@2
   297
    static TBool RunL(
williamr@2
   298
        TInt aResourceId,
williamr@2
   299
        TMemory& aSelectedMemory,
williamr@2
   300
        TDes* aRootPath,
williamr@2
   301
        TDes* aDefaultFolder,
williamr@2
   302
        const TDesC& aTitle,
williamr@2
   303
        MAknMemorySelectionObserver* aObserver );
williamr@2
   304
williamr@2
   305
williamr@2
   306
    /**
williamr@2
   307
     * Sets id to a default CFD resource depending on dialog type.
williamr@2
   308
     */
williamr@2
   309
    void SetResourceId( TInt& aResourceId, TCommonDialogType aDialogType )
williamr@2
   310
        const;
williamr@2
   311
williamr@2
   312
    /**
williamr@2
   313
     * Reads settings from resource.
williamr@2
   314
     *
williamr@2
   315
     * @param aResourceId Resource's ID to be read.
williamr@2
   316
     * @param aResourceDefined If user defines the resource.
williamr@2
   317
     */
williamr@2
   318
    void ReadFromResourceL( TInt aResourceId, TBool aResourceDefined );
williamr@2
   319
williamr@2
   320
    /**
williamr@2
   321
     * Loads icons into the icon-array.
williamr@2
   322
     * @param aIconArray Array of which to append the loaded icons.
williamr@2
   323
     * @param aDoubleStyle Is the dialog doublestyle.
williamr@2
   324
     */
williamr@2
   325
    void LoadIconsL( CAknIconArray* aIconArray, TBool aDoubleStyle );
williamr@2
   326
williamr@2
   327
    /**
williamr@2
   328
     * Loads default root and default paths of phone memory & memory card
williamr@2
   329
     */
williamr@2
   330
    void GetSystemPathsL();
williamr@2
   331
williamr@2
   332
protected: // Data
williamr@2
   333
williamr@2
   334
    // Own: Dialog type
williamr@2
   335
    TCommonDialogType iDialogType;
williamr@2
   336
williamr@2
   337
    // Own: Model
williamr@2
   338
    CAknMemorySelectionModel* iModel;
williamr@2
   339
williamr@2
   340
    // Own: Event handler
williamr@2
   341
    CAknMemorySelectionEventHandler* iEventHandler;
williamr@2
   342
williamr@2
   343
    // Ref: Observer
williamr@2
   344
    MAknMemorySelectionObserver* iObserver;
williamr@2
   345
williamr@2
   346
    // Own: Title
williamr@2
   347
    HBufC* iTitle;
williamr@2
   348
williamr@2
   349
    // Own: Left softkey text
williamr@2
   350
    HBufC* iLeftSoftkey;
williamr@2
   351
williamr@2
   352
    // Own: Right softkey text
williamr@2
   353
    HBufC* iRightSoftkey;
williamr@2
   354
williamr@2
   355
    // Own: Root path array
williamr@2
   356
    // iDynamicDrivesEnabled indicates the content of this array.
williamr@2
   357
    CDesCArrayFlat iRootPathArray;
williamr@2
   358
williamr@2
   359
    // Own: Default folder array
williamr@2
   360
    CDesCArrayFlat iDefaultFolderArray;
williamr@2
   361
williamr@2
   362
    // Own: ETrue if dynamic drive reading is enabled
williamr@2
   363
    //      EFalse if drives are static (C: and E:).
williamr@2
   364
    // This affects iRootPathArray and iDefaultFolderArray content and
williamr@2
   365
    // ordering.
williamr@2
   366
    TBool iDynamicDrivesEnabled;
williamr@2
   367
williamr@2
   368
    TInt iIncludedMedias;
williamr@2
   369
    };
williamr@2
   370
williamr@2
   371
#endif // C_AKNMEMORYSELECTIONDIALOG_H