| 39 |      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 | // INCLUDES
 | 
|  |     20 | #include <e32base.h>
 | 
|  |     21 | #include <f32file.h>
 | 
|  |     22 | #include <tz.h>
 | 
|  |     23 | #include "CFileManagerItemProperties.h"
 | 
|  |     24 | #include "CFileManagerUtils.h"
 | 
|  |     25 | #include "CFilemanagerMimeIconArray.h"
 | 
|  |     26 | #include "Cfilemanagerfolderarray.h"
 | 
|  |     27 | #include "Cfilemanageractivesize.h"
 | 
|  |     28 | #include "CFilemanagerActiveCount.h"
 | 
|  |     29 | #include "CFileManagerEngine.h" 
 | 
|  |     30 | #include "CGflmGroupItem.h"
 | 
|  |     31 | #include "CGflmFileSystemItem.h"
 | 
|  |     32 | #include "CGflmDriveItem.h"
 | 
|  |     33 | #include "CGflmGlobalActionItem.h"
 | 
|  |     34 | 
 | 
|  |     35 | 
 | 
|  |     36 | // ============================ MEMBER FUNCTIONS ===============================
 | 
|  |     37 | // -----------------------------------------------------------------------------
 | 
|  |     38 | // CFileManagerItemProperties::CFileManagerItemProperties
 | 
|  |     39 | // 
 | 
|  |     40 | // -----------------------------------------------------------------------------
 | 
|  |     41 | // 
 | 
|  |     42 | CFileManagerItemProperties::CFileManagerItemProperties( 
 | 
|  |     43 |         CFileManagerUtils& aUtils,
 | 
|  |     44 |         CFileManagerEngine& aEngine ) :
 | 
|  |     45 |             iSize( KErrNotFound ),
 | 
|  |     46 |             iFilesContained( KErrNotFound ),
 | 
|  |     47 |             iFoldersContained( KErrNotFound ),
 | 
|  |     48 |             iOpenFiles( KErrNotFound ),
 | 
|  |     49 |             iUtils( aUtils ),
 | 
|  |     50 |             iEngine( aEngine )
 | 
|  |     51 |     {
 | 
|  |     52 |     }
 | 
|  |     53 | 
 | 
|  |     54 | // -----------------------------------------------------------------------------
 | 
|  |     55 | // CFileManagerItemProperties::NewL
 | 
|  |     56 | // 
 | 
|  |     57 | // -----------------------------------------------------------------------------
 | 
|  |     58 | // 
 | 
|  |     59 | CFileManagerItemProperties* CFileManagerItemProperties::NewL( 
 | 
|  |     60 |         const TDesC& aFullPath,
 | 
|  |     61 |         CFileManagerUtils& aUtils,
 | 
|  |     62 |         CFileManagerEngine& aEngine )
 | 
|  |     63 |     {
 | 
|  |     64 |     CFileManagerItemProperties* self =
 | 
|  |     65 |         new (ELeave) CFileManagerItemProperties( aUtils, aEngine );
 | 
|  |     66 |     CleanupStack::PushL( self );
 | 
|  |     67 |     self->ConstructL( aFullPath );
 | 
|  |     68 |     CleanupStack::Pop( self );
 | 
|  |     69 |     return self;
 | 
|  |     70 |     }
 | 
|  |     71 | 
 | 
|  |     72 | // -----------------------------------------------------------------------------
 | 
|  |     73 | // CFileManagerItemProperties::NewL
 | 
|  |     74 | // 
 | 
|  |     75 | // -----------------------------------------------------------------------------
 | 
|  |     76 | // 
 | 
|  |     77 | CFileManagerItemProperties* CFileManagerItemProperties::NewL(
 | 
|  |     78 |         const CGflmGroupItem& aItem,
 | 
|  |     79 |         CFileManagerUtils& aUtils,
 | 
|  |     80 |         CFileManagerEngine& aEngine )
 | 
|  |     81 |     {
 | 
|  |     82 |     CFileManagerItemProperties* self =
 | 
|  |     83 |         new (ELeave) CFileManagerItemProperties( aUtils, aEngine );
 | 
|  |     84 |     CleanupStack::PushL( self );
 | 
|  |     85 |     self->ConstructL( aItem );
 | 
|  |     86 |     CleanupStack::Pop( self );
 | 
|  |     87 |     return self;
 | 
|  |     88 |     }
 | 
|  |     89 | 
 | 
|  |     90 | // -----------------------------------------------------------------------------
 | 
|  |     91 | // CFileManagerItemProperties::ConstructL
 | 
|  |     92 | // 
 | 
|  |     93 | // -----------------------------------------------------------------------------
 | 
|  |     94 | // 
 | 
|  |     95 | void CFileManagerItemProperties::ConstructL( const TDesC& aFullPath )
 | 
|  |     96 |     {
 | 
|  |     97 |     iFullPath = aFullPath.AllocL();
 | 
|  |     98 | 
 | 
|  |     99 |     // Setup the rest of entry data when needed first time
 | 
|  |    100 |     if ( CFileManagerUtils::HasFinalBackslash( aFullPath ) )
 | 
|  |    101 |         {
 | 
|  |    102 |         iState |= EItemDirectory;
 | 
|  |    103 |         }
 | 
|  |    104 |     else
 | 
|  |    105 |         {
 | 
|  |    106 |         iState |= EItemFile;
 | 
|  |    107 |         }
 | 
|  |    108 |     }
 | 
|  |    109 | 
 | 
|  |    110 | // -----------------------------------------------------------------------------
 | 
|  |    111 | // CFileManagerItemProperties::ConstructL
 | 
|  |    112 | // 
 | 
|  |    113 | // -----------------------------------------------------------------------------
 | 
|  |    114 | // 
 | 
|  |    115 | void CFileManagerItemProperties::ConstructL(
 | 
|  |    116 |         const TDesC& aFullPath, const TEntry& aEntry )
 | 
|  |    117 |     {
 | 
|  |    118 |     iFullPath = aFullPath.AllocL();
 | 
|  |    119 | 
 | 
|  |    120 |     // Setup all entry data now
 | 
|  |    121 |     SetEntryData( aEntry );
 | 
|  |    122 |     }
 | 
|  |    123 | 
 | 
|  |    124 | // -----------------------------------------------------------------------------
 | 
|  |    125 | // CFileManagerItemProperties::ConstructL
 | 
|  |    126 | // 
 | 
|  |    127 | // -----------------------------------------------------------------------------
 | 
|  |    128 | // 
 | 
|  |    129 | void CFileManagerItemProperties::ConstructL( const CGflmGroupItem& aItem )
 | 
|  |    130 |     {
 | 
|  |    131 |     switch ( aItem.Type() )
 | 
|  |    132 |         {
 | 
|  |    133 |         case CGflmGroupItem::EFile:
 | 
|  |    134 |         case CGflmGroupItem::EDirectory:
 | 
|  |    135 |             {
 | 
|  |    136 |             const CGflmFileSystemItem& fsItem =
 | 
|  |    137 |                 static_cast< const CGflmFileSystemItem& >( aItem );
 | 
|  |    138 |             HBufC* fullPath = fsItem.FullPathLC();
 | 
|  |    139 |             ConstructL( *fullPath, fsItem.Entry() );
 | 
|  |    140 |             if ( iUtils.IsRemoteDrive( *fullPath ) )
 | 
|  |    141 |                 {
 | 
|  |    142 |                 iState |= EItemRemoteDrive;
 | 
|  |    143 |                 }
 | 
|  |    144 |             CleanupStack::PopAndDestroy( fullPath );
 | 
|  |    145 |             break;
 | 
|  |    146 |             }
 | 
|  |    147 |         case CGflmGroupItem::EDrive:
 | 
|  |    148 |             {
 | 
|  |    149 |             const CGflmDriveItem& drvItem =
 | 
|  |    150 |                 static_cast< const CGflmDriveItem& >( aItem );
 | 
|  |    151 |             iFullPath = drvItem.RootDirectory().AllocL();
 | 
|  |    152 | #ifdef RD_MULTIPLE_DRIVE
 | 
|  |    153 |             iName = iUtils.GetDriveNameL(
 | 
|  |    154 |                 drvItem.Drive(),
 | 
|  |    155 |                 CFileManagerUtils::EMainLayout );
 | 
|  |    156 | #else // RD_MULTIPLE_DRIVE
 | 
|  |    157 |             iName = drvItem.Name().AllocL();
 | 
|  |    158 | #endif // RD_MULTIPLE_DRIVE
 | 
|  |    159 |             iState |= EItemDrive;
 | 
|  |    160 |             if ( iUtils.IsRemoteDrive( *iFullPath ) )
 | 
|  |    161 |                 {
 | 
|  |    162 |                 iState |= EItemRemoteDrive;
 | 
|  |    163 |                 }
 | 
|  |    164 |             break;
 | 
|  |    165 |             }
 | 
|  |    166 |         case CGflmGroupItem::EGlobalActionItem:
 | 
|  |    167 |             {
 | 
|  |    168 |             const CGflmGlobalActionItem& actItem = 
 | 
|  |    169 |                 static_cast< const CGflmGlobalActionItem& >( aItem );
 | 
|  |    170 |             if ( actItem.Id() == EFileManagerBackupAction )
 | 
|  |    171 |                 {
 | 
|  |    172 |                 // Ignore error
 | 
|  |    173 |                 iEngine.LatestBackupTime( iModified );
 | 
|  |    174 |                 }
 | 
|  |    175 |             iName = aItem.Name().AllocL();
 | 
|  |    176 |             // Action items do not have entry data, so mark it as fetched
 | 
|  |    177 |             iState |= EItemAction | EItemEntryDataFetched;
 | 
|  |    178 |             break;
 | 
|  |    179 |             }
 | 
|  |    180 |         default:
 | 
|  |    181 |             {
 | 
|  |    182 |             User::Leave( KErrNotFound );
 | 
|  |    183 |             break;
 | 
|  |    184 |             }
 | 
|  |    185 |         }
 | 
|  |    186 |     }
 | 
|  |    187 | 
 | 
|  |    188 | // -----------------------------------------------------------------------------
 | 
|  |    189 | // CFileManagerItemProperties::~CFileManagerItemProperties
 | 
|  |    190 | // 
 | 
|  |    191 | // -----------------------------------------------------------------------------
 | 
|  |    192 | // 
 | 
|  |    193 | CFileManagerItemProperties::~CFileManagerItemProperties()
 | 
|  |    194 |     {
 | 
|  |    195 |     delete iFullPath;
 | 
|  |    196 |     delete iActiveSize;
 | 
|  |    197 |     delete iActiveCount;
 | 
|  |    198 |     delete iName;
 | 
|  |    199 |     }
 | 
|  |    200 | 
 | 
|  |    201 | // -----------------------------------------------------------------------------
 | 
|  |    202 | // CFileManagerItemProperties::Name() const
 | 
|  |    203 | //
 | 
|  |    204 | // -----------------------------------------------------------------------------
 | 
|  |    205 | //
 | 
|  |    206 | EXPORT_C TPtrC CFileManagerItemProperties::Name() const
 | 
|  |    207 |     {
 | 
|  |    208 |     if ( iState & EItemNotFileOrDir )
 | 
|  |    209 |         {
 | 
|  |    210 |         return iName->Des();
 | 
|  |    211 |         }
 | 
|  |    212 |     TParsePtrC parse( CFileManagerUtils::StripFinalBackslash( *iFullPath ) );
 | 
|  |    213 |     return parse.Name();
 | 
|  |    214 |     }
 | 
|  |    215 | 
 | 
|  |    216 | // -----------------------------------------------------------------------------
 | 
|  |    217 | // CFileManagerItemProperties::ModifiedDate() const
 | 
|  |    218 | //
 | 
|  |    219 | // -----------------------------------------------------------------------------
 | 
|  |    220 | //
 | 
|  |    221 | EXPORT_C TTime CFileManagerItemProperties::ModifiedDate() const
 | 
|  |    222 |     {
 | 
|  |    223 |     EnsureEntryDataFetched();
 | 
|  |    224 |     return iModified;
 | 
|  |    225 |     }
 | 
|  |    226 | 
 | 
|  |    227 | // -----------------------------------------------------------------------------
 | 
|  |    228 | // CFileManagerItemProperties::SizeL()
 | 
|  |    229 | //
 | 
|  |    230 | // -----------------------------------------------------------------------------
 | 
|  |    231 | //
 | 
|  |    232 | EXPORT_C TInt64 CFileManagerItemProperties::SizeL()
 | 
|  |    233 |     {
 | 
|  |    234 |     if ( iState & EItemNotFileOrDir )
 | 
|  |    235 |         {
 | 
|  |    236 |         return 0;
 | 
|  |    237 |         }
 | 
|  |    238 |     if( iSize == KErrNotFound )
 | 
|  |    239 |         {
 | 
|  |    240 |         if ( iState & EItemFile )
 | 
|  |    241 |             {
 | 
|  |    242 |             EnsureEntryDataFetched();
 | 
|  |    243 |             }
 | 
|  |    244 |         else
 | 
|  |    245 |             {
 | 
|  |    246 |             iSize = FolderSizeL( *iFullPath );
 | 
|  |    247 |             }
 | 
|  |    248 |         }
 | 
|  |    249 |     return iSize;
 | 
|  |    250 |     }
 | 
|  |    251 | 
 | 
|  |    252 | // -----------------------------------------------------------------------------
 | 
|  |    253 | // CFileManagerItemProperties::FilesContainedL()
 | 
|  |    254 | //
 | 
|  |    255 | // -----------------------------------------------------------------------------
 | 
|  |    256 | //
 | 
|  |    257 | EXPORT_C TInt CFileManagerItemProperties::FilesContainedL()
 | 
|  |    258 |     {
 | 
|  |    259 |     if( iFilesContained == KErrNotFound )
 | 
|  |    260 |         {
 | 
|  |    261 |         CountItemsL( CFileManagerItemProperties::EFile );
 | 
|  |    262 |         }
 | 
|  |    263 |     return iFilesContained;
 | 
|  |    264 |     }
 | 
|  |    265 | 
 | 
|  |    266 | // -----------------------------------------------------------------------------
 | 
|  |    267 | // CFileManagerItemProperties::FoldersContainedL()
 | 
|  |    268 | //
 | 
|  |    269 | // -----------------------------------------------------------------------------
 | 
|  |    270 | //
 | 
|  |    271 | EXPORT_C TInt CFileManagerItemProperties::FoldersContainedL()
 | 
|  |    272 |     {
 | 
|  |    273 |     if( iFoldersContained == KErrNotFound )
 | 
|  |    274 |         {
 | 
|  |    275 |         CountItemsL( CFileManagerItemProperties::EFolder );
 | 
|  |    276 |         }
 | 
|  |    277 |     return iFoldersContained;
 | 
|  |    278 |     }
 | 
|  |    279 | 
 | 
|  |    280 | // -----------------------------------------------------------------------------
 | 
|  |    281 | // CFileManagerItemProperties::OpenFilesL()
 | 
|  |    282 | //
 | 
|  |    283 | // -----------------------------------------------------------------------------
 | 
|  |    284 | //
 | 
|  |    285 | EXPORT_C TInt CFileManagerItemProperties::OpenFilesL()
 | 
|  |    286 |     {
 | 
|  |    287 |     if( iOpenFiles == KErrNotFound )
 | 
|  |    288 |         {
 | 
|  |    289 |         CountItemsL( CFileManagerItemProperties::EOpen );
 | 
|  |    290 |         }
 | 
|  |    291 |     return iOpenFiles;
 | 
|  |    292 |     }
 | 
|  |    293 | 
 | 
|  |    294 | // -----------------------------------------------------------------------------
 | 
|  |    295 | // CFileManagerItemProperties::TypeL()
 | 
|  |    296 | //
 | 
|  |    297 | // -----------------------------------------------------------------------------
 | 
|  |    298 | //
 | 
|  |    299 | EXPORT_C TUint32 CFileManagerItemProperties::TypeL()
 | 
|  |    300 |     {
 | 
|  |    301 |     if( iType == CFileManagerItemProperties::ENotDefined )
 | 
|  |    302 |         {
 | 
|  |    303 |         iType = iUtils.FileTypeL( *iFullPath );
 | 
|  |    304 |         }
 | 
|  |    305 |     return iType;
 | 
|  |    306 |     }
 | 
|  |    307 | 
 | 
|  |    308 | // -----------------------------------------------------------------------------
 | 
|  |    309 | // CFileManagerItemProperties::Ext() const
 | 
|  |    310 | //
 | 
|  |    311 | // -----------------------------------------------------------------------------
 | 
|  |    312 | //
 | 
|  |    313 | EXPORT_C TPtrC CFileManagerItemProperties::Ext() const
 | 
|  |    314 |     {
 | 
|  |    315 |     if ( iState & EItemNotFileOrDir )
 | 
|  |    316 |         {
 | 
|  |    317 |         return TPtrC( KNullDesC );
 | 
|  |    318 |         }
 | 
|  |    319 |     TParsePtrC parse( *iFullPath );
 | 
|  |    320 |     TPtrC ext( parse.Ext() );
 | 
|  |    321 |     return ext;
 | 
|  |    322 |     }
 | 
|  |    323 | 
 | 
|  |    324 | // -----------------------------------------------------------------------------
 | 
|  |    325 | // CFileManagerItemProperties::CountItemsL
 | 
|  |    326 | // -----------------------------------------------------------------------------
 | 
|  |    327 | //
 | 
|  |    328 | TInt CFileManagerItemProperties::CountItemsL(
 | 
|  |    329 |         const TFileManagerFileType& aType )
 | 
|  |    330 |     {
 | 
|  |    331 |     if ( !( iState & ( EItemDirectory | EItemDrive ) ) )
 | 
|  |    332 |         {
 | 
|  |    333 |         // It's not a folder
 | 
|  |    334 |         return KErrNotFound;
 | 
|  |    335 |         }
 | 
|  |    336 | 
 | 
|  |    337 |     delete iActiveCount;
 | 
|  |    338 |     iActiveCount = NULL;
 | 
|  |    339 | 
 | 
|  |    340 |     iActiveCount = CFileManagerActiveCount::NewL(
 | 
|  |    341 |         iEngine.Fs(), *iFullPath, aType );
 | 
|  |    342 | 
 | 
|  |    343 |     if ( !iActiveCount->IsProcessDone() )
 | 
|  |    344 |         {
 | 
|  |    345 |         iEngine.ShowWaitDialogL( *iActiveCount );
 | 
|  |    346 |         }
 | 
|  |    347 | 
 | 
|  |    348 |     if ( iFilesContained == KErrNotFound )
 | 
|  |    349 |         {
 | 
|  |    350 |         iFilesContained = iActiveCount->FileCount();
 | 
|  |    351 |         }
 | 
|  |    352 | 
 | 
|  |    353 |     if ( iFoldersContained == KErrNotFound )
 | 
|  |    354 |         {
 | 
|  |    355 |         iFoldersContained = iActiveCount->FolderCount();
 | 
|  |    356 |         }
 | 
|  |    357 | 
 | 
|  |    358 |     if ( iOpenFiles == KErrNotFound )
 | 
|  |    359 |         {
 | 
|  |    360 |         iOpenFiles = iActiveCount->OpenFiles();
 | 
|  |    361 |         }
 | 
|  |    362 | 
 | 
|  |    363 |     return KErrNone;
 | 
|  |    364 |     }
 | 
|  |    365 | 
 | 
|  |    366 | // -----------------------------------------------------------------------------
 | 
|  |    367 | // CFileManagerItemProperties::FolderSizeL
 | 
|  |    368 | // -----------------------------------------------------------------------------
 | 
|  |    369 | //
 | 
|  |    370 | TInt64 CFileManagerItemProperties::FolderSizeL( const TDesC& aFullPath )
 | 
|  |    371 |     {
 | 
|  |    372 |     if ( !( iState & EItemDirectory ) )
 | 
|  |    373 |         {
 | 
|  |    374 |         // It's not a folder
 | 
|  |    375 |         return KErrNotFound;
 | 
|  |    376 |         }
 | 
|  |    377 | 
 | 
|  |    378 |     delete iActiveSize;
 | 
|  |    379 |     iActiveSize = NULL;
 | 
|  |    380 |     iActiveSize = CFileManagerActiveSize::NewL( iEngine.Fs(), aFullPath );
 | 
|  |    381 |     iEngine.ShowWaitDialogL( *iActiveSize );
 | 
|  |    382 |     if ( !iActiveSize->IsProcessDone() )
 | 
|  |    383 |         {
 | 
|  |    384 |         User::Leave( KErrCancel );
 | 
|  |    385 |         }
 | 
|  |    386 |     return iActiveSize->GetFolderSize();
 | 
|  |    387 |     }
 | 
|  |    388 | 
 | 
|  |    389 | // -----------------------------------------------------------------------------
 | 
|  |    390 | // CFileManagerItemProperties::FullPath() const
 | 
|  |    391 | //
 | 
|  |    392 | // -----------------------------------------------------------------------------
 | 
|  |    393 | //
 | 
|  |    394 | EXPORT_C TPtrC CFileManagerItemProperties::FullPath() const
 | 
|  |    395 |     {
 | 
|  |    396 |     if ( iFullPath )
 | 
|  |    397 |         {
 | 
|  |    398 |         return iFullPath->Des();
 | 
|  |    399 |         }
 | 
|  |    400 |     return TPtrC( KNullDesC );
 | 
|  |    401 |     }
 | 
|  |    402 | 
 | 
|  |    403 | // -----------------------------------------------------------------------------
 | 
|  |    404 | // CFileManagerItemProperties::NameAndExt() const
 | 
|  |    405 | //
 | 
|  |    406 | // -----------------------------------------------------------------------------
 | 
|  |    407 | //
 | 
|  |    408 | EXPORT_C TPtrC CFileManagerItemProperties::NameAndExt() const
 | 
|  |    409 |     {
 | 
|  |    410 |     if ( iState & EItemNotFileOrDir )
 | 
|  |    411 |         {
 | 
|  |    412 |         return iName->Des();
 | 
|  |    413 |         }
 | 
|  |    414 |     TParsePtrC parse( CFileManagerUtils::StripFinalBackslash( *iFullPath ) );
 | 
|  |    415 |     return parse.NameAndExt();
 | 
|  |    416 |     }
 | 
|  |    417 | 
 | 
|  |    418 | // -----------------------------------------------------------------------------
 | 
|  |    419 | // CFileManagerItemProperties::LocalizedName() const
 | 
|  |    420 | //
 | 
|  |    421 | // -----------------------------------------------------------------------------
 | 
|  |    422 | //
 | 
|  |    423 | EXPORT_C TPtrC CFileManagerItemProperties::LocalizedName() const
 | 
|  |    424 |     {
 | 
|  |    425 |     if (iState & EItemDirectory )
 | 
|  |    426 |         {
 | 
|  |    427 |         TPtrC ptr( iUtils.LocalizedName( *iFullPath ) );
 | 
|  |    428 |         if ( ptr.Length() )
 | 
|  |    429 |             {
 | 
|  |    430 |             return ptr;
 | 
|  |    431 |             }
 | 
|  |    432 |         }
 | 
|  |    433 |     return NameAndExt();
 | 
|  |    434 |     }
 | 
|  |    435 | 
 | 
|  |    436 | // -----------------------------------------------------------------------------
 | 
|  |    437 | // CFileManagerItemProperties::ModifiedLocalDate() const
 | 
|  |    438 | //
 | 
|  |    439 | // -----------------------------------------------------------------------------
 | 
|  |    440 | //
 | 
|  |    441 | EXPORT_C TInt CFileManagerItemProperties::ModifiedLocalDate(
 | 
|  |    442 |         TTime& aTime ) const
 | 
|  |    443 |     {
 | 
|  |    444 |     aTime = ModifiedDate(); // convert from universal time
 | 
|  |    445 |     RTz tz;
 | 
|  |    446 |     TInt err( tz.Connect() );
 | 
|  |    447 |     if ( err == KErrNone )
 | 
|  |    448 |         {
 | 
|  |    449 |         err = tz.ConvertToLocalTime( aTime );
 | 
|  |    450 |         if ( err != KErrNone )
 | 
|  |    451 |             {
 | 
|  |    452 |             aTime = ModifiedDate(); // use universal time
 | 
|  |    453 |             }
 | 
|  |    454 |         tz.Close();
 | 
|  |    455 |         }
 | 
|  |    456 |     return err;
 | 
|  |    457 |     }
 | 
|  |    458 | 
 | 
|  |    459 | // -----------------------------------------------------------------------------
 | 
|  |    460 | // CFileManagerItemProperties::ContainsAnyFilesOrFolders()
 | 
|  |    461 | //
 | 
|  |    462 | // -----------------------------------------------------------------------------
 | 
|  |    463 | //
 | 
|  |    464 | EXPORT_C TInt CFileManagerItemProperties::ContainsAnyFilesOrFolders()
 | 
|  |    465 |     {
 | 
|  |    466 |     if ( !( iState & EItemDirectory ) ||
 | 
|  |    467 |          ( iState & EItemHasNoFilesOrFolders ) )
 | 
|  |    468 |         {
 | 
|  |    469 |         return EFalse;
 | 
|  |    470 |         }
 | 
|  |    471 |     if ( iState & EItemHasFilesOrFolders )
 | 
|  |    472 |         {
 | 
|  |    473 |         return ETrue;
 | 
|  |    474 |         }
 | 
|  |    475 |     TBool ret( CFileManagerUtils::HasAny(
 | 
|  |    476 |         iEngine.Fs(),
 | 
|  |    477 |         *iFullPath,
 | 
|  |    478 |         KEntryAttNormal | KEntryAttDir | KEntryAttHidden | KEntryAttSystem ) );
 | 
|  |    479 |     if ( ret )
 | 
|  |    480 |         {
 | 
|  |    481 |         iState |= EItemHasFilesOrFolders;
 | 
|  |    482 |         }
 | 
|  |    483 |     else
 | 
|  |    484 |         {
 | 
|  |    485 |         iState |= EItemHasNoFilesOrFolders;
 | 
|  |    486 |         }
 | 
|  |    487 |     return ret;
 | 
|  |    488 |     }
 | 
|  |    489 | 
 | 
|  |    490 | // -----------------------------------------------------------------------------
 | 
|  |    491 | // CFileManagerItemProperties::MimeTypeL()
 | 
|  |    492 | //
 | 
|  |    493 | // -----------------------------------------------------------------------------
 | 
|  |    494 | // 
 | 
|  |    495 | EXPORT_C TPtrC CFileManagerItemProperties::MimeTypeL()
 | 
|  |    496 |     {
 | 
|  |    497 |     if ( iState & EItemNotFileOrDir )
 | 
|  |    498 |         {
 | 
|  |    499 |         return TPtrC( KNullDesC );
 | 
|  |    500 |         }
 | 
|  |    501 |     return iUtils.MimeTypeL( *iFullPath );
 | 
|  |    502 |     }
 | 
|  |    503 | 
 | 
|  |    504 | // -----------------------------------------------------------------------------
 | 
|  |    505 | // CFileManagerItemProperties::IsDrive()
 | 
|  |    506 | //
 | 
|  |    507 | // -----------------------------------------------------------------------------
 | 
|  |    508 | // 
 | 
|  |    509 | EXPORT_C TBool CFileManagerItemProperties::IsDrive() const
 | 
|  |    510 |     {
 | 
|  |    511 |     if ( iState & EItemDrive )
 | 
|  |    512 |         {
 | 
|  |    513 |         return ETrue;
 | 
|  |    514 |         }
 | 
|  |    515 |     return EFalse;
 | 
|  |    516 |     }
 | 
|  |    517 | 
 | 
|  |    518 | // -----------------------------------------------------------------------------
 | 
|  |    519 | // CFileManagerItemProperties::DriveName()
 | 
|  |    520 | //
 | 
|  |    521 | // -----------------------------------------------------------------------------
 | 
|  |    522 | // 
 | 
|  |    523 | EXPORT_C TPtrC CFileManagerItemProperties::DriveName() const
 | 
|  |    524 |     {
 | 
|  |    525 |     if ( iState & EItemDrive )
 | 
|  |    526 |         {
 | 
|  |    527 |         return Name();
 | 
|  |    528 |         }
 | 
|  |    529 |     return iEngine.CurrentDriveName();
 | 
|  |    530 |     }
 | 
|  |    531 | 
 | 
|  |    532 | // -----------------------------------------------------------------------------
 | 
|  |    533 | // CFileManagerItemProperties::IsRemoteDrive()
 | 
|  |    534 | //
 | 
|  |    535 | // -----------------------------------------------------------------------------
 | 
|  |    536 | // 
 | 
|  |    537 | EXPORT_C TBool CFileManagerItemProperties::IsRemoteDrive() const
 | 
|  |    538 |     {
 | 
|  |    539 |     if ( iState & EItemRemoteDrive )
 | 
|  |    540 |         {
 | 
|  |    541 |         return ETrue;
 | 
|  |    542 |         }
 | 
|  |    543 |     return EFalse;
 | 
|  |    544 |     }
 | 
|  |    545 | 
 | 
|  |    546 | // -----------------------------------------------------------------------------
 | 
|  |    547 | // CFileManagerItemProperties::EnsureEntryDataFetched
 | 
|  |    548 | // 
 | 
|  |    549 | // -----------------------------------------------------------------------------
 | 
|  |    550 | // 
 | 
|  |    551 | void CFileManagerItemProperties::EnsureEntryDataFetched() const
 | 
|  |    552 |     {
 | 
|  |    553 |     if ( iState & EItemEntryDataFetched )
 | 
|  |    554 |         {
 | 
|  |    555 |         return;
 | 
|  |    556 |         }
 | 
|  |    557 | 
 | 
|  |    558 |     iState |= EItemEntryDataFetched; // Do not try fetch more than once
 | 
|  |    559 | 
 | 
|  |    560 |     TEntry entry;
 | 
|  |    561 |     if ( iEngine.Fs().Entry( *iFullPath, entry ) != KErrNone )
 | 
|  |    562 |         {
 | 
|  |    563 |         return;
 | 
|  |    564 |         }
 | 
|  |    565 | 
 | 
|  |    566 |     SetEntryData( entry );
 | 
|  |    567 |     }
 | 
|  |    568 | 
 | 
|  |    569 | // -----------------------------------------------------------------------------
 | 
|  |    570 | // CFileManagerItemProperties::SetEntryData
 | 
|  |    571 | // 
 | 
|  |    572 | // -----------------------------------------------------------------------------
 | 
|  |    573 | // 
 | 
|  |    574 | void CFileManagerItemProperties::SetEntryData( const TEntry& aEntry ) const
 | 
|  |    575 |     {
 | 
|  |    576 |     iState |= EItemEntryDataFetched;
 | 
|  |    577 | 
 | 
|  |    578 |     iModified = aEntry.iModified;
 | 
|  |    579 | 
 | 
|  |    580 |     if ( aEntry.IsDir() )
 | 
|  |    581 |         {
 | 
|  |    582 |         iState |= EItemDirectory;
 | 
|  |    583 |         }
 | 
|  |    584 |     else
 | 
|  |    585 |         {
 | 
|  |    586 |         iState |= EItemFile;
 | 
|  |    587 |         iSize = (TUint) aEntry.iSize;
 | 
|  |    588 |         }
 | 
|  |    589 |     }
 | 
|  |    590 | 
 | 
|  |    591 | // -----------------------------------------------------------------------------
 | 
|  |    592 | // CFileManagerItemProperties::DriveId
 | 
|  |    593 | // 
 | 
|  |    594 | // -----------------------------------------------------------------------------
 | 
|  |    595 | // 
 | 
|  |    596 | EXPORT_C TInt CFileManagerItemProperties::DriveId() const
 | 
|  |    597 |     {
 | 
|  |    598 |     TInt ret( KErrNotFound );
 | 
|  |    599 |     if ( iFullPath )
 | 
|  |    600 |         {
 | 
|  |    601 |         ret = TDriveUnit( *iFullPath );
 | 
|  |    602 |         }
 | 
|  |    603 |     return ret;
 | 
|  |    604 |     }
 | 
|  |    605 | 
 | 
|  |    606 | // End of File
 |