epoc32/include/mw/caknmemoryselectiondialog.h
branchSymbian2
changeset 2 2fe1408b6811
parent 1 666f914201fb
child 4 837f303aceeb
     1.1 --- a/epoc32/include/mw/caknmemoryselectiondialog.h	Tue Nov 24 13:55:44 2009 +0000
     1.2 +++ b/epoc32/include/mw/caknmemoryselectiondialog.h	Tue Mar 16 16:12:26 2010 +0000
     1.3 @@ -1,1 +1,371 @@
     1.4 -caknmemoryselectiondialog.h
     1.5 +/*
     1.6 +* Copyright (c) 2002-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:  Dialog used to selection target memory.
    1.19 +*
    1.20 +*/
    1.21 +
    1.22 +
    1.23 +#ifndef C_AKNMEMORYSELECTIONDIALOG_H
    1.24 +#define C_AKNMEMORYSELECTIONDIALOG_H
    1.25 +
    1.26 +#include <CAknCommonDialogsBase.h>
    1.27 +#include <badesca.h> // CDesCArray
    1.28 +
    1.29 +class CAknMemorySelectionModel;
    1.30 +class CAknMemorySelectionEventHandler;
    1.31 +class MAknMemorySelectionObserver;
    1.32 +class TDriveInfo;
    1.33 +class CAknIconArray;
    1.34 +
    1.35 +/**
    1.36 + *  A class that launches a pop-up dialog for memory selection.
    1.37 + *
    1.38 + *  @lib CommonDialogs.lib
    1.39 + *  @since S60 1.2
    1.40 + */
    1.41 +NONSHARABLE_CLASS(CAknMemorySelectionDialog) : public CAknCommonDialogsBase
    1.42 +    {
    1.43 +
    1.44 +public:
    1.45 +
    1.46 +// Enumerations
    1.47 +    /**
    1.48 +     * @Deprecated: This only works with fixed C: and E: drives.
    1.49 +     * Enumerations for memory items in listbox .
    1.50 +     */
    1.51 +    enum TMemory
    1.52 +        {
    1.53 +        EPhoneMemory = 0,   // C:
    1.54 +        EMemoryCard,        // E:
    1.55 +        EMemoryCount        // must remain last one
    1.56 +        };
    1.57 +
    1.58 +// Constructors and destructors
    1.59 +
    1.60 +    /**
    1.61 +     * Static constructor.
    1.62 +     *
    1.63 +     * @since S60 3.2
    1.64 +     * @param aDialogType Defines the type of the dialog in order to read
    1.65 +     *        correct default settings for title and softkeys from resource.
    1.66 +     * @param aShowUnavailableDrives Defines whether unavailable or corrupted
    1.67 +     *        drives are shown in memory selection list or not.
    1.68 +     * @return Returns a pointer to an instance of itself.
    1.69 +     */
    1.70 +    IMPORT_C static CAknMemorySelectionDialog* NewL(
    1.71 +        TCommonDialogType aDialogType,
    1.72 +        TBool aShowUnavailableDrives );
    1.73 +
    1.74 +
    1.75 +    /**
    1.76 +     * Static constructor.
    1.77 +     *
    1.78 +     * @since S60 3.2
    1.79 +     * @param aDialogType Defines the type of the dialog in order to read
    1.80 +     *        correct default settings for title and softkeys from resource.
    1.81 +     * @param aResourceId A resource id (MEMORYSELECTIONDIALOG).
    1.82 +     * @param aShowUnavailableDrives Defines whether unavailable or corrupted
    1.83 +     *        drives are shown in memory selection list or not.
    1.84 +     * @return Returns a pointer to an instance of itself.
    1.85 +     */
    1.86 +    IMPORT_C static CAknMemorySelectionDialog* NewL(
    1.87 +        TCommonDialogType aDialogType,
    1.88 +        TInt aResourceId,
    1.89 +        TBool aShowUnavailableDrives );
    1.90 +
    1.91 +    /**
    1.92 +     * Static constructor.
    1.93 +     *
    1.94 +     * @since S60 3.2
    1.95 +     * @param aDialogType Defines the type of the dialog in order to read
    1.96 +     *        correct default settings for title and softkeys from resource.
    1.97 +     * @param aResourceId A resource id (MEMORYSELECTIONDIALOG).
    1.98 +     * @param aShowUnavailableDrives Defines whether unavailable or corrupted
    1.99 +     *        drives are shown in memory selection list or not.
   1.100 +     * @param aIncludedMedias bit flag definition of which medias are
   1.101 +     *        included in the dialog. See TMemoryTypes.
   1.102 +     * @return Returns a pointer to an instance of itself.
   1.103 +     */
   1.104 +    IMPORT_C static CAknMemorySelectionDialog* NewL(
   1.105 +        TCommonDialogType aDialogType,
   1.106 +        TInt aResourceId,
   1.107 +        TBool aShowUnavailableDrives,
   1.108 +        TInt aIncludedMedias );
   1.109 +
   1.110 +    IMPORT_C virtual ~CAknMemorySelectionDialog();
   1.111 +
   1.112 +// New functions
   1.113 +
   1.114 +    /**
   1.115 +     * Sets an observer which is asked if the selected item can be selected.
   1.116 +     *
   1.117 +     * @param aObserver A pointer to an observer.
   1.118 +     */
   1.119 +    IMPORT_C void SetObserver( MAknMemorySelectionObserver* aObserver );
   1.120 +
   1.121 +    /**
   1.122 +     * Sets title for the dialog.
   1.123 +     *
   1.124 +     * @param aText Title text.
   1.125 +     */
   1.126 +    IMPORT_C void SetTitleL( const TDesC& aText );
   1.127 +
   1.128 +    /**
   1.129 +     * Sets the text used for left softkey.
   1.130 +     *
   1.131 +     * @param aText The text used for left softkey.
   1.132 +     */
   1.133 +    IMPORT_C void SetLeftSoftkeyL( const TDesC& aText );
   1.134 +
   1.135 +    /**
   1.136 +     * Sets the text used for right softkey.
   1.137 +     *
   1.138 +     * @param aText The text used for right softkey.
   1.139 +     */
   1.140 +    IMPORT_C void SetRightSoftkeyL( const TDesC& aText );
   1.141 +
   1.142 +    /**
   1.143 +     * Gets an item from memory selection dialog at specified index.
   1.144 +     *
   1.145 +     * @param aIndex Index to the item in the memory selection list.
   1.146 +     * @param aItem A reference to a descriptor where the item is stored.
   1.147 +     */
   1.148 +    IMPORT_C void GetItem( TInt aIndex, TDes& aItem );
   1.149 +
   1.150 +    /**
   1.151 +     * Gets the location paths of a memory.
   1.152 +     *
   1.153 +     * @param aSelectedMemory The memory that was selected.
   1.154 +     * @param aRootPath A pointer to a descriptor where the root path
   1.155 +     *        of the selected memory is stored. Must have KMaxFileName space.
   1.156 +     *        Set to NULL to ignore.
   1.157 +     * @param aDefaultFolder A pointer to a descriptor where the default folder
   1.158 +     *        of the selected memory is stored. Must have KMaxFileName space.
   1.159 +     *        Set to NULL to ignore.
   1.160 +     */
   1.161 +    IMPORT_C void GetMemories( TMemory aSelectedMemory,
   1.162 +                               TDes* aRootPath,
   1.163 +                               TDes* aDefaultFolder );
   1.164 +
   1.165 +    /**
   1.166 +     * Executes the memory selection dialog. Virtual to allow derivation.
   1.167 +     *
   1.168 +     * @param aSelectedMemory A reference to a memory (TMemory).
   1.169 +     *        If one of the memories is selected, the selected memory is
   1.170 +     *        stored to the parameter.
   1.171 +     * @return Returns true if user has selected an item and false
   1.172 +     *         if user hits cancel.
   1.173 +     */
   1.174 +    IMPORT_C virtual TReturnKey ExecuteL( TMemory& aSelectedMemory );
   1.175 +
   1.176 +    /**
   1.177 +     * Executes the memory selection dialog. Virtual to allow derivation.
   1.178 +     *
   1.179 +     * @param aSelectedMemory A reference to a memory (TMemory).
   1.180 +     *        If one of the memories is selected, the selected memory is
   1.181 +     *        stored to the parameter.
   1.182 +     * @param aRootPath A pointer to a descriptor where the root path
   1.183 +     *        of the selected memory is stored.
   1.184 +     * @param aDefaultFolder A pointer to a descriptor where the default folder
   1.185 +     *        of the selected memory is stored.
   1.186 +     * @return Returns true if user has selected an item and false
   1.187 +     *         if user hits cancel.
   1.188 +     */
   1.189 +    IMPORT_C virtual TReturnKey ExecuteL(
   1.190 +        TMemory& aSelectedMemory,
   1.191 +        TDes* aRootPath, TDes* aDefaultFolder );
   1.192 +
   1.193 +    /**
   1.194 +     * A static method that launches a memory selection dialog.
   1.195 +     * @see RunL()
   1.196 +     */
   1.197 +    IMPORT_C static TBool RunDlgLD(
   1.198 +        TMemory& aSelectedMemory,
   1.199 +        MAknMemorySelectionObserver* aObserver = NULL );
   1.200 +
   1.201 +    /**
   1.202 +     * A static method that launches a memory selection dialog.
   1.203 +     * @see RunL()
   1.204 +     */
   1.205 +    IMPORT_C static TBool RunDlgLD(
   1.206 +        TMemory& aSelectedMemory,
   1.207 +        const TDesC& aTitle,
   1.208 +        MAknMemorySelectionObserver* aObserver = NULL );
   1.209 +
   1.210 +    /**
   1.211 +     * A static method that launches a memory selection dialog.
   1.212 +     * @see RunL()
   1.213 +     */
   1.214 +    IMPORT_C static TBool RunDlgLD(
   1.215 +        TMemory& aSelectedMemory,
   1.216 +        TInt aResourceId,
   1.217 +        TDes* aRootPath = NULL, TDes* aDefaultFolder = NULL,
   1.218 +        MAknMemorySelectionObserver* aObserver = NULL );
   1.219 +
   1.220 +    /**
   1.221 +     * Returns the number of items in list box array.
   1.222 +     * Not exported, for CFD internal use only.
   1.223 +     *
   1.224 +     * @return Returns the number of items in list box array.
   1.225 +     */
   1.226 +    TInt NumberOfItems() const;
   1.227 +
   1.228 +    /**
   1.229 +     * Maps drive paths according to selected listbox item. This function is
   1.230 +     * valid for dynamic drives. The prerequisite for this function is that
   1.231 +     * iRootPathArray and additionally iDefaultFolderArray indexes map
   1.232 +     * correctly to iModel's listbox items.
   1.233 +     *
   1.234 +     * @since S60 3.2
   1.235 +     * @param aLbxIndex Index to the selected listbox item.
   1.236 +     * @param aRootPath A pointer to a descriptor where the root path of the
   1.237 +     *        selected drive will be stored. Must have KMaxFileName space.
   1.238 +     *        Set to NULL to ignore.
   1.239 +     * @param aDefaultFolder A pointer to a descriptor where the default folder
   1.240 +     *        of the selected drive will be stored. Must have
   1.241 +     *        KMaxFileNamespace.
   1.242 +     *        Set to NULL to ignore.
   1.243 +     * @return Return error code
   1.244 +     *         KErrNone The drive is found in internal drive list
   1.245 +     *         KErrNotFound The drive is not visible to user or does not exist
   1.246 +     */
   1.247 +    TInt GetDrivePaths( TInt aLbxIndex,
   1.248 +                        TDes* aRootPath,
   1.249 +                        TDes* aDefaultFolder );
   1.250 +
   1.251 +protected:
   1.252 +
   1.253 +// Constructors and destructors
   1.254 +
   1.255 +    CAknMemorySelectionDialog( TCommonDialogType aDialogType );
   1.256 +
   1.257 +    /**
   1.258 +     * Constructs class from resource
   1.259 +     *
   1.260 +     * @param aResourceId ID of the resource. Can be zero.
   1.261 +     * @param aShowUnavailableDrives Defines whether unavailable or corrupted
   1.262 +     *        drives are shown in memory selection list or not.
   1.263 +     */
   1.264 +    virtual void ConstructFromResourceL(
   1.265 +        TInt aResourceId,
   1.266 +        TBool aShowUnavailableDrives );
   1.267 +
   1.268 +    /**
   1.269 +     * Constructs class from resource
   1.270 +     *
   1.271 +     * @param aResourceId ID of the resource. Can be zero.
   1.272 +     * @param aShowUnavailableDrives Defines whether unavailable or corrupted
   1.273 +     *        drives are shown in memory selection list or not.
   1.274 +     * @param aIncludedMedias bit flag definition of which medias are
   1.275 +     *        included in the dialog. See TMemoryTypes.
   1.276 +     */
   1.277 +    virtual void ConstructFromResourceL(
   1.278 +        TInt aResourceId,
   1.279 +        TBool aShowUnavailableDrives,
   1.280 +        TInt aIncludedMedias );
   1.281 +
   1.282 +private:
   1.283 +
   1.284 +//  New functions
   1.285 +
   1.286 +    /**
   1.287 +     * A static method for launching a memory selection dialog.
   1.288 +     * Creates, constructs, runs and deletes a memory selection dialog with
   1.289 +     * different parameters.
   1.290 +     *
   1.291 +     * @param aResourceId An id of a resource.
   1.292 +     * @param aSelectedMemory A reference to a memory described in ExecuteL.
   1.293 +     * @param aRootPath A pointer to a descriptor where the root path
   1.294 +     *        of the selected memory is stored.
   1.295 +     * @param aDefaultFolder A pointer to a descriptor where the default folder
   1.296 +     *        of the selected memory is stored.
   1.297 +     * @param aTitle A title for memory selection dialog.
   1.298 +     * @param aObserver An observer which is asked if the selected item
   1.299 +     *        can be selected. Implemented in application..
   1.300 +     */
   1.301 +    static TBool RunL(
   1.302 +        TInt aResourceId,
   1.303 +        TMemory& aSelectedMemory,
   1.304 +        TDes* aRootPath,
   1.305 +        TDes* aDefaultFolder,
   1.306 +        const TDesC& aTitle,
   1.307 +        MAknMemorySelectionObserver* aObserver );
   1.308 +
   1.309 +
   1.310 +    /**
   1.311 +     * Sets id to a default CFD resource depending on dialog type.
   1.312 +     */
   1.313 +    void SetResourceId( TInt& aResourceId, TCommonDialogType aDialogType )
   1.314 +        const;
   1.315 +
   1.316 +    /**
   1.317 +     * Reads settings from resource.
   1.318 +     *
   1.319 +     * @param aResourceId Resource's ID to be read.
   1.320 +     * @param aResourceDefined If user defines the resource.
   1.321 +     */
   1.322 +    void ReadFromResourceL( TInt aResourceId, TBool aResourceDefined );
   1.323 +
   1.324 +    /**
   1.325 +     * Loads icons into the icon-array.
   1.326 +     * @param aIconArray Array of which to append the loaded icons.
   1.327 +     * @param aDoubleStyle Is the dialog doublestyle.
   1.328 +     */
   1.329 +    void LoadIconsL( CAknIconArray* aIconArray, TBool aDoubleStyle );
   1.330 +
   1.331 +    /**
   1.332 +     * Loads default root and default paths of phone memory & memory card
   1.333 +     */
   1.334 +    void GetSystemPathsL();
   1.335 +
   1.336 +protected: // Data
   1.337 +
   1.338 +    // Own: Dialog type
   1.339 +    TCommonDialogType iDialogType;
   1.340 +
   1.341 +    // Own: Model
   1.342 +    CAknMemorySelectionModel* iModel;
   1.343 +
   1.344 +    // Own: Event handler
   1.345 +    CAknMemorySelectionEventHandler* iEventHandler;
   1.346 +
   1.347 +    // Ref: Observer
   1.348 +    MAknMemorySelectionObserver* iObserver;
   1.349 +
   1.350 +    // Own: Title
   1.351 +    HBufC* iTitle;
   1.352 +
   1.353 +    // Own: Left softkey text
   1.354 +    HBufC* iLeftSoftkey;
   1.355 +
   1.356 +    // Own: Right softkey text
   1.357 +    HBufC* iRightSoftkey;
   1.358 +
   1.359 +    // Own: Root path array
   1.360 +    // iDynamicDrivesEnabled indicates the content of this array.
   1.361 +    CDesCArrayFlat iRootPathArray;
   1.362 +
   1.363 +    // Own: Default folder array
   1.364 +    CDesCArrayFlat iDefaultFolderArray;
   1.365 +
   1.366 +    // Own: ETrue if dynamic drive reading is enabled
   1.367 +    //      EFalse if drives are static (C: and E:).
   1.368 +    // This affects iRootPathArray and iDefaultFolderArray content and
   1.369 +    // ordering.
   1.370 +    TBool iDynamicDrivesEnabled;
   1.371 +
   1.372 +    TInt iIncludedMedias;
   1.373 +    };
   1.374 +
   1.375 +#endif // C_AKNMEMORYSELECTIONDIALOG_H