|         |      1 /* | 
|         |      2 * Copyright (c) 2002-2007 Nokia Corporation and/or its subsidiary(-ies). | 
|         |      3 * All rights reserved. | 
|         |      4 * This component and the accompanying materials are made available | 
|         |      5 * under the terms of "Eclipse Public License v1.0"" | 
|         |      6 * which accompanies this distribution, and is available | 
|         |      7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". | 
|         |      8 * | 
|         |      9 * Initial Contributors: | 
|         |     10 * Nokia Corporation - initial contribution. | 
|         |     11 * | 
|         |     12 * Contributors: | 
|         |     13 * | 
|         |     14 * Description:  Holds item information | 
|         |     15 * | 
|         |     16 */ | 
|         |     17  | 
|         |     18  | 
|         |     19  | 
|         |     20 #ifndef CFILEMANAGERITEMPROPERTIES_H_ | 
|         |     21 #define CFILEMANAGERITEMPROPERTIES_H_ | 
|         |     22  | 
|         |     23 // INCLUDES | 
|         |     24 #include <e32base.h> | 
|         |     25 #include <f32file.h> | 
|         |     26  | 
|         |     27 // FORWARD DECLARATIONS | 
|         |     28 class CFileManagerActiveSize; | 
|         |     29 class CFileManagerUtils; | 
|         |     30 class CFileManagerActiveCount; | 
|         |     31 class CGflmGroupItem; | 
|         |     32 class CFileManagerEngine; | 
|         |     33  | 
|         |     34 /** | 
|         |     35 *  Engine gathers the item information to this object. | 
|         |     36 * | 
|         |     37 *  @lib FileManagerEngine.lib | 
|         |     38 *  @since 2.0 | 
|         |     39 */ | 
|         |     40 NONSHARABLE_CLASS(CFileManagerItemProperties) : public CBase | 
|         |     41     { | 
|         |     42     public: | 
|         |     43         /* Bitmask bits of the item types */ | 
|         |     44         enum TFileManagerFileType  | 
|         |     45             { | 
|         |     46             ENotDefined         = 0x00, | 
|         |     47             EFolder             = 0x01, | 
|         |     48             EDefault            = 0x02, | 
|         |     49             EMedia              = 0x04, | 
|         |     50             EFile               = 0x08, | 
|         |     51             EForwardLocked      = 0x10, | 
|         |     52             EPlaylist           = 0x20, | 
|         |     53             ELink               = 0x40, | 
|         |     54             EOpen               = 0x80, | 
|         |     55             EReadOnly           = 0x100, | 
|         |     56             EDrmProtected       = 0x200, | 
|         |     57             EDrmLocalDataFile   = 0x400 | 
|         |     58             }; | 
|         |     59     public: | 
|         |     60         /** | 
|         |     61         * Two-phased constructor.        | 
|         |     62         */ | 
|         |     63         static CFileManagerItemProperties* NewL(  | 
|         |     64             const TDesC& aFullPath, | 
|         |     65             CFileManagerUtils& aUtils, | 
|         |     66             CFileManagerEngine& aEngine ); | 
|         |     67  | 
|         |     68         /** | 
|         |     69         * Two-phased constructor. | 
|         |     70         */ | 
|         |     71         static CFileManagerItemProperties* NewL( | 
|         |     72             const CGflmGroupItem& aItem, | 
|         |     73             CFileManagerUtils& aUtils, | 
|         |     74             CFileManagerEngine& aEngine ); | 
|         |     75  | 
|         |     76         /** | 
|         |     77         * Destructor. | 
|         |     78         */ | 
|         |     79         IMPORT_C ~CFileManagerItemProperties(); | 
|         |     80  | 
|         |     81     public: | 
|         |     82  | 
|         |     83         /** | 
|         |     84         * Gets the name of the item | 
|         |     85         * @since 2.7 | 
|         |     86         * @return Name of the item, file name without extension  | 
|         |     87         * or directory name | 
|         |     88         */ | 
|         |     89         IMPORT_C TPtrC Name() const; | 
|         |     90  | 
|         |     91         /** | 
|         |     92         * Gets the item modification time (universal time) | 
|         |     93         * @since 2.7 | 
|         |     94         * @return TTime when item was last modified | 
|         |     95         */ | 
|         |     96         IMPORT_C TTime ModifiedDate() const; | 
|         |     97  | 
|         |     98         /** | 
|         |     99         * Size of the item, size of the file or size of the dir | 
|         |    100         * @since 2.7 | 
|         |    101         * @return Item size in bytes | 
|         |    102         */ | 
|         |    103         IMPORT_C TInt64 SizeL(); | 
|         |    104  | 
|         |    105         /** | 
|         |    106         * Count of files in directory, subdirectories not included | 
|         |    107         * @since 2.7 | 
|         |    108         * @return File count in dir, -1 if item is file | 
|         |    109         */ | 
|         |    110         IMPORT_C TInt FilesContainedL(); | 
|         |    111  | 
|         |    112         /** | 
|         |    113         * Count of folders in directory,  | 
|         |    114         * directories in subdirectories are not included | 
|         |    115         * @since 2.7 | 
|         |    116         * @return Folder count in dir, -1 if item is file | 
|         |    117         */ | 
|         |    118         IMPORT_C TInt FoldersContainedL(); | 
|         |    119  | 
|         |    120         /** | 
|         |    121         * Count of open files in directory | 
|         |    122         * @since 2.7 | 
|         |    123         * @return count of open files in directory, -1 if item is file | 
|         |    124         */ | 
|         |    125         IMPORT_C TInt OpenFilesL(); | 
|         |    126  | 
|         |    127         /** | 
|         |    128         * Returns item type information | 
|         |    129         * @since 2.7 | 
|         |    130         * @return TFileManagerFileType information of item | 
|         |    131         */ | 
|         |    132         IMPORT_C TUint32 TypeL(); | 
|         |    133  | 
|         |    134         /** | 
|         |    135         * Item extension | 
|         |    136         * @since 2.7 | 
|         |    137         * @return File extension, empty if item is dir | 
|         |    138         */ | 
|         |    139         IMPORT_C TPtrC Ext() const; | 
|         |    140          | 
|         |    141         /** | 
|         |    142         * Fullpath of item, includes drive, path and name with extension | 
|         |    143         * @since 2.7 | 
|         |    144         * @return fullpath  | 
|         |    145         */ | 
|         |    146         IMPORT_C TPtrC FullPath() const; | 
|         |    147  | 
|         |    148         /** | 
|         |    149         * Gets the name of the item with extension | 
|         |    150         * @since 2.7 | 
|         |    151         * @return Name of the item | 
|         |    152         */ | 
|         |    153         IMPORT_C TPtrC NameAndExt() const; | 
|         |    154  | 
|         |    155         /** | 
|         |    156         * Localized name of item if found, if not Name() is returned | 
|         |    157         * @since 2.7 | 
|         |    158         * @return Localized name | 
|         |    159         */ | 
|         |    160         IMPORT_C TPtrC LocalizedName() const; | 
|         |    161  | 
|         |    162         /** | 
|         |    163         * Gets the item modification time (local time) | 
|         |    164         * @since 3.1 | 
|         |    165         * @param aTime For local time | 
|         |    166         * @return Error code | 
|         |    167         */ | 
|         |    168         IMPORT_C TInt ModifiedLocalDate( TTime& aTime ) const; | 
|         |    169  | 
|         |    170         /** | 
|         |    171         * Checks if item contains any files or folders | 
|         |    172         * @since 3.1 | 
|         |    173         * @return ETrue if contains any items, EFalse if not | 
|         |    174         */ | 
|         |    175         IMPORT_C TBool ContainsAnyFilesOrFolders(); | 
|         |    176  | 
|         |    177         /** | 
|         |    178         * Gets MIME type of file | 
|         |    179         * @since 3.1 | 
|         |    180         * @return MIME type | 
|         |    181         */ | 
|         |    182         IMPORT_C TPtrC MimeTypeL(); | 
|         |    183  | 
|         |    184         /** | 
|         |    185         * Checks if item is a drive item | 
|         |    186         * @since 3.1 | 
|         |    187         * @return ETrue if drive item, otherwise EFalse | 
|         |    188         */ | 
|         |    189         IMPORT_C TBool IsDrive() const; | 
|         |    190  | 
|         |    191         /** | 
|         |    192         * Gets drive name | 
|         |    193         * @since 3.1 | 
|         |    194         * @return drive name | 
|         |    195         */ | 
|         |    196         IMPORT_C TPtrC DriveName() const; | 
|         |    197  | 
|         |    198         /** | 
|         |    199         * Checks if item is on remote drive | 
|         |    200         * @since 3.2 | 
|         |    201         * @return ETrue if item on remote drive, otherwise EFalse | 
|         |    202         */ | 
|         |    203         IMPORT_C TBool IsRemoteDrive() const; | 
|         |    204  | 
|         |    205         /** | 
|         |    206         * Gets drive id | 
|         |    207         * @since 5.0 | 
|         |    208         * @return Drive id | 
|         |    209         */ | 
|         |    210         IMPORT_C TInt DriveId() const; | 
|         |    211  | 
|         |    212     private: | 
|         |    213         /** | 
|         |    214         * C++ default constructor. | 
|         |    215         */ | 
|         |    216         CFileManagerItemProperties(  | 
|         |    217             CFileManagerUtils& aUtils, | 
|         |    218             CFileManagerEngine& aEngine ); | 
|         |    219              | 
|         |    220         /** | 
|         |    221         * By default Symbian 2nd phase constructor is private. | 
|         |    222         */ | 
|         |    223         void ConstructL( const TDesC& aFullPath ); | 
|         |    224  | 
|         |    225         /** | 
|         |    226         * By default Symbian 2nd phase constructor is private. | 
|         |    227         */ | 
|         |    228         void ConstructL( const TDesC& aFullPath, const TEntry& aEntry ); | 
|         |    229  | 
|         |    230         /** | 
|         |    231         * By default Symbian 2nd phase constructor is private. | 
|         |    232         */ | 
|         |    233         void ConstructL( const CGflmGroupItem& aItem ); | 
|         |    234  | 
|         |    235         // Counts file sizes in given folder | 
|         |    236         TInt64 FolderSizeL( const TDesC& aFullPath ); | 
|         |    237  | 
|         |    238         // Counts items in directory, given parameter defines the type of count | 
|         |    239         TInt CountItemsL( | 
|         |    240             const TFileManagerFileType& aType ); | 
|         |    241  | 
|         |    242         void EnsureEntryDataFetched() const; | 
|         |    243  | 
|         |    244         void SetEntryData( const TEntry& aEntry ) const; | 
|         |    245  | 
|         |    246     private: | 
|         |    247  | 
|         |    248         // Own: Location in file system | 
|         |    249         HBufC* iFullPath; | 
|         |    250  | 
|         |    251         // Size of the file in bytes. In case of folder, this is a sum of all items | 
|         |    252         // under the folder including the subfolders. | 
|         |    253         mutable TInt64 iSize; | 
|         |    254  | 
|         |    255         // How many files are inside the folder, subfolders not counted | 
|         |    256         // In case of file this is undefined | 
|         |    257         TInt iFilesContained; | 
|         |    258  | 
|         |    259         // How many folders are inside the folder, subfolders are not counted | 
|         |    260         // In case of file this is undefined | 
|         |    261         TInt iFoldersContained; | 
|         |    262  | 
|         |    263         // How many open files are inside the folder | 
|         |    264         // In case of file this is undefined | 
|         |    265         TInt iOpenFiles; | 
|         |    266  | 
|         |    267         // type of item, TFileManagerFileType bitmask | 
|         |    268         TUint32 iType; | 
|         |    269  | 
|         |    270         // Own: Folder size calculation | 
|         |    271         CFileManagerActiveSize* iActiveSize; | 
|         |    272  | 
|         |    273         // Own: Folder properties  | 
|         |    274         CFileManagerActiveCount* iActiveCount; | 
|         |    275  | 
|         |    276         // Item modification day, copied from items TEntry | 
|         |    277         mutable TTime iModified; | 
|         |    278  | 
|         |    279         // Ref: Contains some useful common services, localizer, RFs... | 
|         |    280         CFileManagerUtils& iUtils; | 
|         |    281  | 
|         |    282         // Ref: Contains some useful common services | 
|         |    283         CFileManagerEngine& iEngine; | 
|         |    284  | 
|         |    285         enum TItemState // Internal state bit definitions | 
|         |    286             { | 
|         |    287             EItemDirectory = 0x1, | 
|         |    288             EItemDrive = 0x2, | 
|         |    289             EItemAction = 0x4, | 
|         |    290             EItemFile = 0x8, | 
|         |    291             EItemHasFilesOrFolders = 0x10, | 
|         |    292             EItemHasNoFilesOrFolders = 0x20, | 
|         |    293             EItemRemoteDrive = 0x40, | 
|         |    294             EItemEntryDataFetched = 0x80, | 
|         |    295             EItemNotFileOrDir = EItemDrive | EItemAction | 
|         |    296             }; | 
|         |    297         // Internal item state bits, see above | 
|         |    298         mutable TUint32 iState; | 
|         |    299  | 
|         |    300         // Own: Item name | 
|         |    301         HBufC* iName; | 
|         |    302  | 
|         |    303     }; | 
|         |    304  | 
|         |    305  | 
|         |    306  | 
|         |    307 #endif // CFILEMANAGERITEMPROPERTIES_H_ |