utilityapps/filebrowser/engine/FBFolderSelector.cpp
changeset 55 2d9cac8919d3
equal deleted inserted replaced
53:819e59dfc032 55:2d9cac8919d3
       
     1 /*
       
     2 * Copyright (c) 2009 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:  
       
    15 *
       
    16 */
       
    17 
       
    18 #include "FBFolderSelector.h"
       
    19 #include "FBFileUtils.h"
       
    20 #include "FB.hrh"
       
    21 #include "FBStd.h"
       
    22 
       
    23 #if (!defined __SERIES60_30__ && !defined __SERIES60_31__)
       
    24 #include <driveinfo.h>
       
    25 #endif // !defined __SERIES60_30__ && !defined __SERIES60_31__
       
    26 
       
    27 // ===================================== MEMBER FUNCTIONS =====================================
       
    28 
       
    29 CFileBrowserFolderSelector *CFileBrowserFolderSelector::NewL(
       
    30         TDes& aReturnPath,
       
    31         MFolderSelectorUI *aFolderSelectorUI)
       
    32     {
       
    33     CFileBrowserFolderSelector* self = new(ELeave) CFileBrowserFolderSelector(aReturnPath,
       
    34                                                                               aFolderSelectorUI);
       
    35     CleanupStack::PushL(self);
       
    36     self->ConstructL();
       
    37     CleanupStack::Pop(self);
       
    38     return self;    
       
    39     }
       
    40 
       
    41 // --------------------------------------------------------------------------------------------
       
    42 
       
    43 CFileBrowserFolderSelector::~CFileBrowserFolderSelector()
       
    44     {
       
    45     delete iFileEntryList;
       
    46     delete iDriveEntryList;
       
    47     
       
    48     iFs.Close();
       
    49 
       
    50     //iEikonEnv->InfoMsgCancel();
       
    51     }
       
    52 
       
    53 // --------------------------------------------------------------------------------------------
       
    54 
       
    55 CFileBrowserFolderSelector::CFileBrowserFolderSelector(TDes& aReturnPath, MFolderSelectorUI *aFolderSelectorUI) :
       
    56     iReturnPath(aReturnPath),
       
    57     iFolderSelectorUI(aFolderSelectorUI)
       
    58     {
       
    59     }
       
    60 
       
    61 // --------------------------------------------------------------------------------------------
       
    62 
       
    63 void CFileBrowserFolderSelector::ConstructL()
       
    64     {
       
    65     User::LeaveIfError( iFs.Connect() );
       
    66     iDriveEntryList = new(ELeave) CDriveEntryList(8);
       
    67     iFileEntryList = new(ELeave) CFileEntryList(32);
       
    68     iCurrentPath = KNullDesC;
       
    69     
       
    70     //iIsDragging = EFalse;
       
    71     //EnableDragEvents();
       
    72     
       
    73     // get only writeable drives
       
    74     GetDriveListL();
       
    75     }
       
    76 
       
    77 // --------------------------------------------------------------------------------------------
       
    78 
       
    79 /*
       
    80 void CFileBrowserFolderSelector::HandlePointerEventL(const TPointerEvent &aPointerEvent)
       
    81     {
       
    82     // detect direction of dragging by comparing the start and finish points
       
    83     
       
    84     if (aPointerEvent.iType == TPointerEvent::EButton1Down)
       
    85         {
       
    86         iDragStartPoint = aPointerEvent.iPosition;
       
    87         iIsDragging = EFalse;
       
    88         }
       
    89     else if (aPointerEvent.iType == TPointerEvent::EDrag)
       
    90         {
       
    91         iIsDragging = ETrue;
       
    92         
       
    93         return;
       
    94         }
       
    95     else if (aPointerEvent.iType == TPointerEvent::EButton1Up)
       
    96         {
       
    97         if (iIsDragging)
       
    98             {
       
    99             const TInt KDelta = iDragStartPoint.iX - aPointerEvent.iPosition.iX;
       
   100             const TInt KThreshold = 30;
       
   101             
       
   102             if (KDelta < -KThreshold) // dragging to right
       
   103                 {
       
   104                 // "emulate" right key press
       
   105                 
       
   106                 TKeyEvent keyEvent;
       
   107                 keyEvent.iCode = EKeyRightArrow;
       
   108                 keyEvent.iModifiers = 0;
       
   109                 
       
   110                 TEventCode type = EEventKey;
       
   111         
       
   112                 OfferKeyEventL(keyEvent, type);
       
   113                 
       
   114                 return;
       
   115                 }
       
   116             else if (KDelta > KThreshold) // dragging to left
       
   117                 {
       
   118                 // "emulate" left key press
       
   119                 
       
   120                 TKeyEvent keyEvent;
       
   121                 keyEvent.iCode = EKeyLeftArrow;
       
   122                 keyEvent.iModifiers = 0;
       
   123                 
       
   124                 TEventCode type = EEventKey;
       
   125         
       
   126                 OfferKeyEventL(keyEvent, type);
       
   127                 
       
   128                 return;
       
   129                 }            
       
   130             }
       
   131         iIsDragging = EFalse;
       
   132         }
       
   133     else
       
   134         {
       
   135         iIsDragging = EFalse;        
       
   136         }
       
   137 
       
   138     CAknListQueryDialog::HandlePointerEventL(aPointerEvent);    
       
   139     }
       
   140 */
       
   141        
       
   142 // --------------------------------------------------------------------------------------------
       
   143 
       
   144 TKeyResponse CFileBrowserFolderSelector::OfferKeyEventL(const TKeyEvent& /*aKeyEvent*/, TEventCode /*aType*/)
       
   145     {
       
   146 //    if(aType != EEventKey)
       
   147 //        return EKeyWasNotConsumed;
       
   148     
       
   149 //    if (aKeyEvent.iCode == EKeyLeftArrow && !IsDriveListViewActive())
       
   150 //        {
       
   151 //        MoveUpOneLevelL();
       
   152 //        return EKeyWasConsumed;
       
   153 //        }
       
   154 //    else if (aKeyEvent.iCode == EKeyRightArrow && ((ListBox()->CurrentItemIndex() > 0 && !IsDriveListViewActive()) || IsDriveListViewActive()))
       
   155 //        {
       
   156 //        MoveDownToDirectoryL();
       
   157 //        return EKeyWasConsumed;
       
   158 //        }
       
   159 //    else if (aKeyEvent.iCode == EKeyOK || aKeyEvent.iCode == EKeyEnter)
       
   160 //        {
       
   161 //        if (IsDriveListViewActive())
       
   162 //            {
       
   163 //            MoveDownToDirectoryL();
       
   164 //            return EKeyWasConsumed;
       
   165 //            }
       
   166 //        else if (ListBox()->CurrentItemIndex() == 0)
       
   167 //            {
       
   168 //            TryExitL(EAknSoftkeyOk);
       
   169 //            return EKeyWasConsumed;
       
   170 //            }
       
   171 //        else if (ListBox()->CurrentItemIndex() > 0)
       
   172 //            {
       
   173 //            MoveDownToDirectoryL();
       
   174 //            return EKeyWasConsumed;
       
   175 //            }
       
   176 //        }
       
   177 //
       
   178 //    TKeyResponse result = CAknDialog::OfferKeyEventL(aKeyEvent, aType);
       
   179 //
       
   180 //    // update LSK label
       
   181 //    if (!IsDriveListViewActive())
       
   182 //        {
       
   183 //        if (ListBox()->CurrentItemIndex() == 0)
       
   184 //            {
       
   185 //            ButtonGroupContainer().SetCommandL(0, EAknSoftkeyOk, iLSKActionText);
       
   186 //            ButtonGroupContainer().DrawNow();
       
   187 //            }
       
   188 //        else
       
   189 //            {
       
   190 //            ButtonGroupContainer().SetCommandL(0, EAknSoftkeyOk, _L("Open dir"));
       
   191 //            ButtonGroupContainer().DrawNow();
       
   192 //            }
       
   193 //        }
       
   194 //
       
   195 //    return result;
       
   196     return TKeyResponse();
       
   197     }    
       
   198 
       
   199 // --------------------------------------------------------------------------------------------
       
   200 
       
   201 void CFileBrowserFolderSelector::PreLayoutDynInitL()
       
   202     {
       
   203 //    CAknListQueryDialog::PreLayoutDynInitL();
       
   204 
       
   205 //    static_cast<CEikFormattedCellListBox*>(ListBox())->ItemDrawer()->ColumnData()->EnableMarqueeL(ETrue);
       
   206     }
       
   207 
       
   208 // --------------------------------------------------------------------------------------------
       
   209 
       
   210 void CFileBrowserFolderSelector::PostLayoutDynInitL()
       
   211     {
       
   212 //    CAknListQueryDialog::PostLayoutDynInitL();
       
   213     
       
   214     //w SetIconArrayL(static_cast<CArrayPtr<CGulIcon>*>(iIconArray));
       
   215     
       
   216     RefreshViewL();
       
   217     }
       
   218 
       
   219 // --------------------------------------------------------------------------------------------
       
   220 
       
   221 TBool CFileBrowserFolderSelector::OkToExitL(TInt /*aButtonId*/)
       
   222     {
       
   223 //    if (aButtonId == GetLeftCBAShortKeyPress())
       
   224 //        {
       
   225 //        if (IsDriveListViewActive())
       
   226 //            {
       
   227 //            MoveDownToDirectoryL();
       
   228 //            return EFalse;
       
   229 //            }
       
   230 //        else if (ListBox()->CurrentItemIndex() == 0)
       
   231 //            {
       
   232 //            // close the dialog
       
   233 //            iReturnPath = iCurrentPath;
       
   234 //            return ETrue;
       
   235 //            }
       
   236 //        else if (ListBox()->CurrentItemIndex() > 0)
       
   237 //            {
       
   238 //            MoveDownToDirectoryL();
       
   239 //            return EFalse;
       
   240 //            }
       
   241 //        else
       
   242 //            return EFalse;
       
   243 //        }
       
   244 //    else if (aButtonId == GetRightCBAShortKeyPress())
       
   245 //        {
       
   246 //        return ETrue;
       
   247 //        }
       
   248 //    else
       
   249 //        {
       
   250 //        return EFalse;
       
   251 //        }
       
   252     return ETrue;
       
   253     }
       
   254 
       
   255 // --------------------------------------------------------------------------------------------
       
   256 
       
   257 void CFileBrowserFolderSelector::MoveUpOneLevelL()
       
   258     {
       
   259     if (iCurrentPath.Length() <= 3)
       
   260         {
       
   261         // move to drive list view is the current path is already short enough
       
   262         iCurrentPath = KNullDesC;
       
   263         }
       
   264     else
       
   265         {
       
   266         // move one directory up
       
   267         TInt marker(iCurrentPath.Length());
       
   268         
       
   269         // find second last dir marker
       
   270         for (TInt i=iCurrentPath.Length()-2; i>=0; i--)
       
   271             {
       
   272             if (iCurrentPath[i] == '\\')
       
   273                 {
       
   274                 marker = i;
       
   275                 break;
       
   276                 }
       
   277                 
       
   278             }
       
   279         iCurrentPath = iCurrentPath.LeftTPtr(marker+1);
       
   280         }    
       
   281 
       
   282     // update view
       
   283     RefreshViewL();
       
   284     }
       
   285 
       
   286 // --------------------------------------------------------------------------------------------
       
   287 
       
   288 void CFileBrowserFolderSelector::MoveDownToDirectoryL(TInt index)
       
   289     {
       
   290     if (index >= 0)
       
   291         {
       
   292         if (IsDriveListViewActive())
       
   293             {
       
   294             // currently in a drive list view, move to root of selected drive
       
   295             if (iDriveEntryList->Count() > index)
       
   296                 {
       
   297                 TDriveEntry driveEntry = iDriveEntryList->At(index);
       
   298                 
       
   299                 iCurrentPath.Append(driveEntry.iLetter);    
       
   300                 iCurrentPath.Append(_L(":\\"));
       
   301                 }
       
   302             }
       
   303         else
       
   304             {
       
   305             // append the new directory
       
   306             if (index >= 0 && index < iFileEntryList->Count())
       
   307                 {
       
   308                 TFileEntry fileEntry = iFileEntryList->At(index);
       
   309                 
       
   310                 if (fileEntry.iEntry.IsDir())
       
   311                     {
       
   312                     iCurrentPath.Append(fileEntry.iEntry.iName);
       
   313                     iCurrentPath.Append(_L("\\"));
       
   314                     }
       
   315                 }
       
   316             }
       
   317                    
       
   318         // update view
       
   319         RefreshViewL();
       
   320         }
       
   321     }
       
   322 
       
   323 // --------------------------------------------------------------------------------------------
       
   324 
       
   325 void CFileBrowserFolderSelector::RefreshViewL()
       
   326     {
       
   327     if (IsDriveListViewActive())
       
   328         {
       
   329         GetDriveListL();
       
   330         }
       
   331     else
       
   332         {
       
   333         GetFileListL();
       
   334         }
       
   335     iFolderSelectorUI->InformFolderSelectionChanged();
       
   336 
       
   337     // TODO
       
   338 //    if (iCurrentPath == KNullDesC)
       
   339 //        iEikonEnv->InfoMsgWithDuration(_L("<- up dir  down dir ->"), TTimeIntervalMicroSeconds32(KMaxTInt));
       
   340 //    else
       
   341 //        iEikonEnv->InfoMsgWithDuration(iCurrentPath, TTimeIntervalMicroSeconds32(KMaxTInt));
       
   342    
       
   343 //    SetItemTextArray(textArray);
       
   344 //    SetOwnershipType(ELbmOwnsItemArray);
       
   345 //    ListBox()->HandleItemAdditionL();
       
   346 //    Layout();
       
   347 //    ListBox()->SetCurrentItemIndex(0);
       
   348 //    DrawDeferred();
       
   349     }
       
   350 
       
   351 // --------------------------------------------------------------------------------------------
       
   352     
       
   353 //TBool CFileBrowserFolderSelector::RunCopyDlgLD()
       
   354 //    {
       
   355 //    iLSKActionText.Copy(_L("Copy"));
       
   356 //    return ExecuteLD(1/*R_COPY_TO_FOLDER_SELECTION_QUERY*/);
       
   357 //    }
       
   358 
       
   359 //// --------------------------------------------------------------------------------------------
       
   360 
       
   361 //TBool CFileBrowserFolderSelector::RunMoveDlgLD()
       
   362 //    {
       
   363 //    iLSKActionText.Copy(_L("Move"));
       
   364 //    return ExecuteLD(1/*R_MOVE_TO_FOLDER_SELECTION_QUERY*/);
       
   365 //    }
       
   366 
       
   367 //// --------------------------------------------------------------------------------------------
       
   368 
       
   369 //TInt CAknQueryDialog::GetLeftCBAShortKeyPress()
       
   370 //    {
       
   371 //    return TInt16(0xffff & TInt16(ButtonGroupContainer().ButtonGroup()->CommandId(0)));
       
   372 //    }
       
   373 
       
   374 //// --------------------------------------------------------------------------------------------
       
   375   
       
   376 //TInt CAknQueryDialog::GetRightCBAShortKeyPress()
       
   377 //    {
       
   378 //    return TInt16(0xffff & TInt16(ButtonGroupContainer().ButtonGroup()->CommandId(2)));
       
   379 //    }
       
   380        
       
   381 // --------------------------------------------------------------------------------------------
       
   382 
       
   383 void CFileBrowserFolderSelector::GetDriveListL()
       
   384     {
       
   385     TDriveList driveList;
       
   386 
       
   387     // get drive listing depending of the support for network drives
       
   388     if (true/*TODO iEngine->Settings().iSupportNetworkDrives*/)
       
   389         {
       
   390         #ifndef __SERIES60_30__
       
   391             #ifndef __SERIES60_31__
       
   392                 User::LeaveIfError(iFs.DriveList(driveList, KDriveAttAll));
       
   393             #endif
       
   394         #else
       
   395             User::LeaveIfError(iFs.DriveList(driveList));
       
   396         #endif
       
   397         }
       
   398     else
       
   399         {
       
   400         User::LeaveIfError(iFs.DriveList(driveList));
       
   401         }
       
   402 
       
   403     iDriveEntryList->Reset();
       
   404 
       
   405     //TDriveEntry driveEntry;
       
   406     for (TInt i=0; i<KMaxDrives; i++)
       
   407         {
       
   408         if (driveList[i])
       
   409             {
       
   410             TDriveEntry driveEntry;
       
   411 
       
   412             // set default icon
       
   413             driveEntry.iIconId = EFixedIconPhoneMemory;
       
   414 
       
   415             // get drive letter and number
       
   416             driveEntry.iLetter = 'A' + i;
       
   417             iFs.CharToDrive(driveEntry.iLetter, driveEntry.iNumber);
       
   418 
       
   419             // get volume info and check errors
       
   420             if (iFs.Volume(driveEntry.iVolumeInfo, driveEntry.iNumber) == KErrNone)
       
   421                 {
       
   422                 // set media type descriptor
       
   423                 TInt mediaType = driveEntry.iVolumeInfo.iDrive.iType;
       
   424                 TBool extMountable( EFalse );
       
   425 
       
   426                 if (mediaType == EMediaNotPresent)
       
   427                     driveEntry.iMediaTypeDesc = _L("Not present");
       
   428                 else if (mediaType ==EMediaUnknown )
       
   429                     driveEntry.iMediaTypeDesc = _L("Unknown");
       
   430                 else if (mediaType ==EMediaFloppy )
       
   431                     driveEntry.iMediaTypeDesc = _L("Floppy");
       
   432                 else if (mediaType == EMediaHardDisk)
       
   433                     driveEntry.iMediaTypeDesc = _L("Mass storage");
       
   434                 else if (mediaType == EMediaCdRom)
       
   435                     driveEntry.iMediaTypeDesc = _L("CD-ROM");
       
   436                 else if (mediaType == EMediaRam)
       
   437                     driveEntry.iMediaTypeDesc = _L("RAM");
       
   438                 else if (mediaType == EMediaFlash)
       
   439                     driveEntry.iMediaTypeDesc = _L("Flash");
       
   440                 else if (mediaType == EMediaRom)
       
   441                     driveEntry.iMediaTypeDesc = _L("ROM");
       
   442                 else if (mediaType == EMediaRemote)
       
   443                     driveEntry.iMediaTypeDesc = _L("Remote");
       
   444                 else if (mediaType == EMediaNANDFlash)
       
   445                     driveEntry.iMediaTypeDesc = _L("NAND flash");
       
   446 
       
   447                 // get real size of the ROM drive
       
   448                 if (mediaType == EMediaRom)
       
   449                     {
       
   450                     TMemoryInfoV1Buf ramMemory;
       
   451                     UserHal::MemoryInfo(ramMemory);
       
   452                     driveEntry.iVolumeInfo.iSize = ramMemory().iTotalRomInBytes;
       
   453                     }
       
   454 
       
   455                 // set attribute descripitions
       
   456                 if (driveEntry.iVolumeInfo.iDrive.iBattery == EBatNotSupported)
       
   457                     driveEntry.iAttributesDesc.Append(_L("Battery not supported"));
       
   458                 else if (driveEntry.iVolumeInfo.iDrive.iBattery == EBatGood)
       
   459                     driveEntry.iAttributesDesc.Append(_L("Battery good"));
       
   460                 else if (driveEntry.iVolumeInfo.iDrive.iBattery == EBatLow)
       
   461                     driveEntry.iAttributesDesc.Append(_L("Battery low"));
       
   462                 else
       
   463                     driveEntry.iAttributesDesc.Append(_L("Battery state unknown"));
       
   464 
       
   465                 if (driveEntry.iVolumeInfo.iDrive.iDriveAtt & KDriveAttLocal)
       
   466                     driveEntry.iAttributesDesc.Append(_L(" + Local"));
       
   467                 if (driveEntry.iVolumeInfo.iDrive.iDriveAtt & KDriveAttRom)
       
   468                     driveEntry.iAttributesDesc.Append(_L(" + ROM"));
       
   469                 if (driveEntry.iVolumeInfo.iDrive.iDriveAtt & KDriveAttRedirected)
       
   470                     driveEntry.iAttributesDesc.Append(_L("+ Redirected"));
       
   471                 if (driveEntry.iVolumeInfo.iDrive.iDriveAtt & KDriveAttSubsted)
       
   472                     driveEntry.iAttributesDesc.Append(_L(" + Substed"));
       
   473                 if (driveEntry.iVolumeInfo.iDrive.iDriveAtt & KDriveAttInternal)
       
   474                     driveEntry.iAttributesDesc.Append(_L(" + Internal"));
       
   475                 if (driveEntry.iVolumeInfo.iDrive.iDriveAtt & KDriveAttRemovable)
       
   476                     {
       
   477                     driveEntry.iAttributesDesc.Append(_L(" + Removable"));
       
   478 #if (!defined __SERIES60_30__ && !defined __SERIES60_31__)
       
   479                     TUint drvStatus( 0 );
       
   480                     if ( !DriveInfo::GetDriveStatus( iFs, driveEntry.iNumber, drvStatus ) &&
       
   481                          drvStatus & DriveInfo::EDriveExternallyMountable &&
       
   482                          drvStatus & DriveInfo::EDriveInternal )
       
   483                         {
       
   484                         extMountable = ETrue;
       
   485                         // iMediaTypeDesc already set as "Mass storage"
       
   486                         }
       
   487                     else
       
   488                         {
       
   489                         driveEntry.iMediaTypeDesc = _L("Memory card");
       
   490                         }
       
   491 #else
       
   492                     driveEntry.iMediaTypeDesc = _L("Memory card");
       
   493 #endif
       
   494                     }
       
   495                 if (driveEntry.iVolumeInfo.iDrive.iDriveAtt & KDriveAttRemote)
       
   496                     driveEntry.iAttributesDesc.Append(_L(" + Remote"));
       
   497                 if (driveEntry.iVolumeInfo.iDrive.iDriveAtt & KDriveAttTransaction)
       
   498                     driveEntry.iAttributesDesc.Append(_L(" + Transaction"));
       
   499 
       
   500                 if (driveEntry.iVolumeInfo.iDrive.iMediaAtt & KMediaAttVariableSize)
       
   501                     driveEntry.iAttributesDesc.Append(_L(" + Variable size"));
       
   502                 if (driveEntry.iVolumeInfo.iDrive.iMediaAtt & KMediaAttDualDensity)
       
   503                     driveEntry.iAttributesDesc.Append(_L(" + Dual density"));
       
   504                 if (driveEntry.iVolumeInfo.iDrive.iMediaAtt & KMediaAttFormattable)
       
   505                     driveEntry.iAttributesDesc.Append(_L(" + Formattable"));
       
   506                 if (driveEntry.iVolumeInfo.iDrive.iMediaAtt & KMediaAttWriteProtected)
       
   507                     driveEntry.iAttributesDesc.Append(_L(" + Write protected"));
       
   508                 if (driveEntry.iVolumeInfo.iDrive.iMediaAtt & KMediaAttLockable)
       
   509                     driveEntry.iAttributesDesc.Append(_L(" + Lockable"));
       
   510                 if (driveEntry.iVolumeInfo.iDrive.iMediaAtt & KMediaAttLocked)
       
   511                     driveEntry.iAttributesDesc.Append(_L(" + Locked"));
       
   512                 if (driveEntry.iVolumeInfo.iDrive.iMediaAtt & KMediaAttHasPassword)
       
   513                     driveEntry.iAttributesDesc.Append(_L(" + Has password"));
       
   514                 if (driveEntry.iVolumeInfo.iDrive.iMediaAtt & KMediaAttReadWhileWrite)
       
   515                     driveEntry.iAttributesDesc.Append(_L(" + Read while write"));
       
   516                 if (driveEntry.iVolumeInfo.iDrive.iMediaAtt & KMediaAttDeleteNotify)
       
   517                     driveEntry.iAttributesDesc.Append(_L(" + Supports DeleteNotify"));
       
   518 
       
   519 
       
   520                 // mark a removable media with memory card icon
       
   521                 if (driveEntry.iVolumeInfo.iDrive.iDriveAtt & KDriveAttRemovable && !extMountable)
       
   522                     {
       
   523                     if (driveEntry.iVolumeInfo.iDrive.iMediaAtt & KMediaAttLocked || driveEntry.iVolumeInfo.iDrive.iDriveAtt & KDriveAbsent)
       
   524                         {
       
   525                         driveEntry.iIconId = EFixedIconMemoryCardDisabled;
       
   526                         }
       
   527                     else
       
   528                         {
       
   529                         driveEntry.iIconId = EFixedIconMemoryCard;
       
   530                         }
       
   531                     }
       
   532                 }
       
   533 
       
   534             // if this fails, likely it's a memory card which is not present
       
   535             else
       
   536                 {
       
   537                 TVolumeInfo volumeInfo;
       
   538                 volumeInfo.iSize = 0;
       
   539                 volumeInfo.iFree = 0;
       
   540                 volumeInfo.iDrive.iDriveAtt = KDriveAttRemovable;
       
   541                 volumeInfo.iDrive.iMediaAtt = KMediaAttWriteProtected;
       
   542                 driveEntry.iVolumeInfo = volumeInfo;
       
   543 
       
   544                 driveEntry.iMediaTypeDesc = _L("Not ready");
       
   545                 driveEntry.iIconId = EFixedIconMemoryCardDisabled;
       
   546                 }
       
   547 // TODO What to do with iPrevFolderName and iPrevFolderIndex
       
   548 //            if ( iPrevFolderName != KNullDesC && iPrevFolderName[0] == driveEntry.iLetter )
       
   549 //                {
       
   550 //                iPrevFolderIndex = iDriveEntryList->Count();
       
   551 //                }
       
   552 
       
   553             if (driveEntry.iVolumeInfo.iDrive.iMediaAtt != KMediaAttWriteProtected
       
   554                 && driveEntry.iVolumeInfo.iDrive.iMediaAtt != KMediaAttLocked
       
   555                 && driveEntry.iVolumeInfo.iDrive.iDriveAtt != KDriveAbsent)
       
   556                 {
       
   557                 iDriveEntryList->AppendL(driveEntry);
       
   558                 }
       
   559             }
       
   560         }
       
   561     }
       
   562 
       
   563 void CFileBrowserFolderSelector::GetFileListL()
       
   564     {
       
   565     iFileEntryList->Reset();
       
   566 
       
   567     CDir* dir = NULL;
       
   568     if (iFs.GetDir(iCurrentPath, KEntryAttDir|KEntryAttMatchMask, ESortByName | EAscending | EDirsFirst, dir) == KErrNone)
       
   569         {
       
   570         CleanupStack::PushL(dir);
       
   571 
       
   572         for (TInt i=0; i<dir->Count(); i++)
       
   573             {
       
   574             TFileEntry fileEntry;
       
   575             fileEntry.iPath = iCurrentPath;
       
   576             fileEntry.iEntry = (*dir)[i];
       
   577             fileEntry.iDirEntries = KErrNotFound;
       
   578             fileEntry.iIconId = EFixedIconEmpty;
       
   579 
       
   580             // check for directory entries
       
   581             if (fileEntry.iEntry.IsDir())
       
   582                 {
       
   583                 fileEntry.iIconId = EFixedIconFolder;
       
   584 
       
   585                 TFileName subPath = fileEntry.iPath;
       
   586                 subPath.Append(fileEntry.iEntry.iName);
       
   587                 subPath.Append(_L("\\"));
       
   588 
       
   589                 // check if any sub directories
       
   590                 CDir* subDir = NULL;
       
   591                 if (iFs.GetDir(subPath, KEntryAttDir|KEntryAttMatchMask, ESortNone | EDirsFirst, subDir) == KErrNone)
       
   592                     {
       
   593                     fileEntry.iDirEntries = subDir->Count();
       
   594 
       
   595                     for (TInt j=0; j<subDir->Count(); j++)
       
   596                         {
       
   597                         TEntry entry = (*subDir)[j];
       
   598 
       
   599                         if (entry.IsDir())
       
   600                             {
       
   601                             fileEntry.iIconId = EFixedIconFolderSub;
       
   602                             break;
       
   603                             }
       
   604                         }
       
   605 
       
   606                     delete subDir;
       
   607                     }
       
   608                     iFileEntryList->AppendL(fileEntry);
       
   609                 }
       
   610             }
       
   611 
       
   612         CleanupStack::PopAndDestroy(); //dir
       
   613         }
       
   614     }
       
   615 
       
   616 // --------------------------------------------------------------------------------------------
       
   617       
       
   618 // End of File
       
   619