filebrowser/engine/FBFolderSelector.cpp
changeset 51 b048e15729d6
equal deleted inserted replaced
44:5db69f4c3d06 51:b048e15729d6
       
     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             // this needed because we have an extra item in the listbox
       
   306             index--;
       
   307 
       
   308             // append the new directory
       
   309             if (iFileEntryList->Count() > index)
       
   310                 {
       
   311                 TFileEntry fileEntry = iFileEntryList->At(index);
       
   312                 
       
   313                 if (fileEntry.iEntry.IsDir())
       
   314                     {
       
   315                     iCurrentPath.Append(fileEntry.iEntry.iName);
       
   316                     iCurrentPath.Append(_L("\\"));
       
   317                     }
       
   318                 }
       
   319             }
       
   320                    
       
   321         // update view
       
   322         RefreshViewL();
       
   323         }
       
   324     }
       
   325 
       
   326 // --------------------------------------------------------------------------------------------
       
   327 
       
   328 void CFileBrowserFolderSelector::RefreshViewL()
       
   329     {
       
   330     if (IsDriveListViewActive())
       
   331         {
       
   332         GetDriveListL();
       
   333         }
       
   334     else
       
   335         {
       
   336         GetFileListL();
       
   337         }
       
   338     iFolderSelectorUI->InformFolderSelectionChanged();
       
   339 
       
   340     // TODO
       
   341 //    if (iCurrentPath == KNullDesC)
       
   342 //        iEikonEnv->InfoMsgWithDuration(_L("<- up dir  down dir ->"), TTimeIntervalMicroSeconds32(KMaxTInt));
       
   343 //    else
       
   344 //        iEikonEnv->InfoMsgWithDuration(iCurrentPath, TTimeIntervalMicroSeconds32(KMaxTInt));
       
   345    
       
   346 //    SetItemTextArray(textArray);
       
   347 //    SetOwnershipType(ELbmOwnsItemArray);
       
   348 //    ListBox()->HandleItemAdditionL();
       
   349 //    Layout();
       
   350 //    ListBox()->SetCurrentItemIndex(0);
       
   351 //    DrawDeferred();
       
   352     }
       
   353 
       
   354 // --------------------------------------------------------------------------------------------
       
   355     
       
   356 //TBool CFileBrowserFolderSelector::RunCopyDlgLD()
       
   357 //    {
       
   358 //    iLSKActionText.Copy(_L("Copy"));
       
   359 //    return ExecuteLD(1/*R_COPY_TO_FOLDER_SELECTION_QUERY*/);
       
   360 //    }
       
   361 
       
   362 //// --------------------------------------------------------------------------------------------
       
   363 
       
   364 //TBool CFileBrowserFolderSelector::RunMoveDlgLD()
       
   365 //    {
       
   366 //    iLSKActionText.Copy(_L("Move"));
       
   367 //    return ExecuteLD(1/*R_MOVE_TO_FOLDER_SELECTION_QUERY*/);
       
   368 //    }
       
   369 
       
   370 //// --------------------------------------------------------------------------------------------
       
   371 
       
   372 //TInt CAknQueryDialog::GetLeftCBAShortKeyPress()
       
   373 //    {
       
   374 //    return TInt16(0xffff & TInt16(ButtonGroupContainer().ButtonGroup()->CommandId(0)));
       
   375 //    }
       
   376 
       
   377 //// --------------------------------------------------------------------------------------------
       
   378   
       
   379 //TInt CAknQueryDialog::GetRightCBAShortKeyPress()
       
   380 //    {
       
   381 //    return TInt16(0xffff & TInt16(ButtonGroupContainer().ButtonGroup()->CommandId(2)));
       
   382 //    }
       
   383        
       
   384 // --------------------------------------------------------------------------------------------
       
   385 
       
   386 void CFileBrowserFolderSelector::GetDriveListL()
       
   387     {
       
   388     TDriveList driveList;
       
   389 
       
   390     // get drive listing depending of the support for network drives
       
   391     if (true/*TODO iEngine->Settings().iSupportNetworkDrives*/)
       
   392         {
       
   393         #ifndef __SERIES60_30__
       
   394             #ifndef __SERIES60_31__
       
   395                 User::LeaveIfError(iFs.DriveList(driveList, KDriveAttAll));
       
   396             #endif
       
   397         #else
       
   398             User::LeaveIfError(iFs.DriveList(driveList));
       
   399         #endif
       
   400         }
       
   401     else
       
   402         {
       
   403         User::LeaveIfError(iFs.DriveList(driveList));
       
   404         }
       
   405 
       
   406     iDriveEntryList->Reset();
       
   407 
       
   408     //TDriveEntry driveEntry;
       
   409     for (TInt i=0; i<KMaxDrives; i++)
       
   410         {
       
   411         if (driveList[i])
       
   412             {
       
   413             TDriveEntry driveEntry;
       
   414 
       
   415             // set default icon
       
   416             driveEntry.iIconId = EFixedIconPhoneMemory;
       
   417 
       
   418             // get drive letter and number
       
   419             driveEntry.iLetter = 'A' + i;
       
   420             iFs.CharToDrive(driveEntry.iLetter, driveEntry.iNumber);
       
   421 
       
   422             // get volume info and check errors
       
   423             if (iFs.Volume(driveEntry.iVolumeInfo, driveEntry.iNumber) == KErrNone)
       
   424                 {
       
   425                 // set media type descriptor
       
   426                 TInt mediaType = driveEntry.iVolumeInfo.iDrive.iType;
       
   427                 TBool extMountable( EFalse );
       
   428 
       
   429                 if (mediaType == EMediaNotPresent)
       
   430                     driveEntry.iMediaTypeDesc = _L("Not present");
       
   431                 else if (mediaType ==EMediaUnknown )
       
   432                     driveEntry.iMediaTypeDesc = _L("Unknown");
       
   433                 else if (mediaType ==EMediaFloppy )
       
   434                     driveEntry.iMediaTypeDesc = _L("Floppy");
       
   435                 else if (mediaType == EMediaHardDisk)
       
   436                     driveEntry.iMediaTypeDesc = _L("Mass storage");
       
   437                 else if (mediaType == EMediaCdRom)
       
   438                     driveEntry.iMediaTypeDesc = _L("CD-ROM");
       
   439                 else if (mediaType == EMediaRam)
       
   440                     driveEntry.iMediaTypeDesc = _L("RAM");
       
   441                 else if (mediaType == EMediaFlash)
       
   442                     driveEntry.iMediaTypeDesc = _L("Flash");
       
   443                 else if (mediaType == EMediaRom)
       
   444                     driveEntry.iMediaTypeDesc = _L("ROM");
       
   445                 else if (mediaType == EMediaRemote)
       
   446                     driveEntry.iMediaTypeDesc = _L("Remote");
       
   447                 else if (mediaType == EMediaNANDFlash)
       
   448                     driveEntry.iMediaTypeDesc = _L("NAND flash");
       
   449 
       
   450                 // get real size of the ROM drive
       
   451                 if (mediaType == EMediaRom)
       
   452                     {
       
   453                     TMemoryInfoV1Buf ramMemory;
       
   454                     UserHal::MemoryInfo(ramMemory);
       
   455                     driveEntry.iVolumeInfo.iSize = ramMemory().iTotalRomInBytes;
       
   456                     }
       
   457 
       
   458                 // set attribute descripitions
       
   459                 if (driveEntry.iVolumeInfo.iDrive.iBattery == EBatNotSupported)
       
   460                     driveEntry.iAttributesDesc.Append(_L("Battery not supported"));
       
   461                 else if (driveEntry.iVolumeInfo.iDrive.iBattery == EBatGood)
       
   462                     driveEntry.iAttributesDesc.Append(_L("Battery good"));
       
   463                 else if (driveEntry.iVolumeInfo.iDrive.iBattery == EBatLow)
       
   464                     driveEntry.iAttributesDesc.Append(_L("Battery low"));
       
   465                 else
       
   466                     driveEntry.iAttributesDesc.Append(_L("Battery state unknown"));
       
   467 
       
   468                 if (driveEntry.iVolumeInfo.iDrive.iDriveAtt & KDriveAttLocal)
       
   469                     driveEntry.iAttributesDesc.Append(_L(" + Local"));
       
   470                 if (driveEntry.iVolumeInfo.iDrive.iDriveAtt & KDriveAttRom)
       
   471                     driveEntry.iAttributesDesc.Append(_L(" + ROM"));
       
   472                 if (driveEntry.iVolumeInfo.iDrive.iDriveAtt & KDriveAttRedirected)
       
   473                     driveEntry.iAttributesDesc.Append(_L("+ Redirected"));
       
   474                 if (driveEntry.iVolumeInfo.iDrive.iDriveAtt & KDriveAttSubsted)
       
   475                     driveEntry.iAttributesDesc.Append(_L(" + Substed"));
       
   476                 if (driveEntry.iVolumeInfo.iDrive.iDriveAtt & KDriveAttInternal)
       
   477                     driveEntry.iAttributesDesc.Append(_L(" + Internal"));
       
   478                 if (driveEntry.iVolumeInfo.iDrive.iDriveAtt & KDriveAttRemovable)
       
   479                     {
       
   480                     driveEntry.iAttributesDesc.Append(_L(" + Removable"));
       
   481 #if (!defined __SERIES60_30__ && !defined __SERIES60_31__)
       
   482                     TUint drvStatus( 0 );
       
   483                     if ( !DriveInfo::GetDriveStatus( iFs, driveEntry.iNumber, drvStatus ) &&
       
   484                          drvStatus & DriveInfo::EDriveExternallyMountable &&
       
   485                          drvStatus & DriveInfo::EDriveInternal )
       
   486                         {
       
   487                         extMountable = ETrue;
       
   488                         // iMediaTypeDesc already set as "Mass storage"
       
   489                         }
       
   490                     else
       
   491                         {
       
   492                         driveEntry.iMediaTypeDesc = _L("Memory card");
       
   493                         }
       
   494 #else
       
   495                     driveEntry.iMediaTypeDesc = _L("Memory card");
       
   496 #endif
       
   497                     }
       
   498                 if (driveEntry.iVolumeInfo.iDrive.iDriveAtt & KDriveAttRemote)
       
   499                     driveEntry.iAttributesDesc.Append(_L(" + Remote"));
       
   500                 if (driveEntry.iVolumeInfo.iDrive.iDriveAtt & KDriveAttTransaction)
       
   501                     driveEntry.iAttributesDesc.Append(_L(" + Transaction"));
       
   502 
       
   503                 if (driveEntry.iVolumeInfo.iDrive.iMediaAtt & KMediaAttVariableSize)
       
   504                     driveEntry.iAttributesDesc.Append(_L(" + Variable size"));
       
   505                 if (driveEntry.iVolumeInfo.iDrive.iMediaAtt & KMediaAttDualDensity)
       
   506                     driveEntry.iAttributesDesc.Append(_L(" + Dual density"));
       
   507                 if (driveEntry.iVolumeInfo.iDrive.iMediaAtt & KMediaAttFormattable)
       
   508                     driveEntry.iAttributesDesc.Append(_L(" + Formattable"));
       
   509                 if (driveEntry.iVolumeInfo.iDrive.iMediaAtt & KMediaAttWriteProtected)
       
   510                     driveEntry.iAttributesDesc.Append(_L(" + Write protected"));
       
   511                 if (driveEntry.iVolumeInfo.iDrive.iMediaAtt & KMediaAttLockable)
       
   512                     driveEntry.iAttributesDesc.Append(_L(" + Lockable"));
       
   513                 if (driveEntry.iVolumeInfo.iDrive.iMediaAtt & KMediaAttLocked)
       
   514                     driveEntry.iAttributesDesc.Append(_L(" + Locked"));
       
   515                 if (driveEntry.iVolumeInfo.iDrive.iMediaAtt & KMediaAttHasPassword)
       
   516                     driveEntry.iAttributesDesc.Append(_L(" + Has password"));
       
   517                 if (driveEntry.iVolumeInfo.iDrive.iMediaAtt & KMediaAttReadWhileWrite)
       
   518                     driveEntry.iAttributesDesc.Append(_L(" + Read while write"));
       
   519                 if (driveEntry.iVolumeInfo.iDrive.iMediaAtt & KMediaAttDeleteNotify)
       
   520                     driveEntry.iAttributesDesc.Append(_L(" + Supports DeleteNotify"));
       
   521 
       
   522 
       
   523                 // mark a removable media with memory card icon
       
   524                 if (driveEntry.iVolumeInfo.iDrive.iDriveAtt & KDriveAttRemovable && !extMountable)
       
   525                     {
       
   526                     if (driveEntry.iVolumeInfo.iDrive.iMediaAtt & KMediaAttLocked || driveEntry.iVolumeInfo.iDrive.iDriveAtt & KDriveAbsent)
       
   527                         {
       
   528                         driveEntry.iIconId = EFixedIconMemoryCardDisabled;
       
   529                         }
       
   530                     else
       
   531                         {
       
   532                         driveEntry.iIconId = EFixedIconMemoryCard;
       
   533                         }
       
   534                     }
       
   535                 }
       
   536 
       
   537             // if this fails, likely it's a memory card which is not present
       
   538             else
       
   539                 {
       
   540                 TVolumeInfo volumeInfo;
       
   541                 volumeInfo.iSize = 0;
       
   542                 volumeInfo.iFree = 0;
       
   543                 volumeInfo.iDrive.iDriveAtt = KDriveAttRemovable;
       
   544                 volumeInfo.iDrive.iMediaAtt = KMediaAttWriteProtected;
       
   545                 driveEntry.iVolumeInfo = volumeInfo;
       
   546 
       
   547                 driveEntry.iMediaTypeDesc = _L("Not ready");
       
   548                 driveEntry.iIconId = EFixedIconMemoryCardDisabled;
       
   549                 }
       
   550 // TODO What to do with iPrevFolderName and iPrevFolderIndex
       
   551 //            if ( iPrevFolderName != KNullDesC && iPrevFolderName[0] == driveEntry.iLetter )
       
   552 //                {
       
   553 //                iPrevFolderIndex = iDriveEntryList->Count();
       
   554 //                }
       
   555 
       
   556             if (driveEntry.iVolumeInfo.iDrive.iMediaAtt != KMediaAttWriteProtected
       
   557                 && driveEntry.iVolumeInfo.iDrive.iMediaAtt != KMediaAttLocked
       
   558                 && driveEntry.iVolumeInfo.iDrive.iDriveAtt != KDriveAbsent)
       
   559                 {
       
   560                 iDriveEntryList->AppendL(driveEntry);
       
   561                 }
       
   562             }
       
   563         }
       
   564     }
       
   565 
       
   566 void CFileBrowserFolderSelector::GetFileListL()
       
   567     {
       
   568     iFileEntryList->Reset();
       
   569 
       
   570     CDir* dir = NULL;
       
   571     if (iFs.GetDir(iCurrentPath, KEntryAttDir|KEntryAttMatchMask, ESortByName | EAscending | EDirsFirst, dir) == KErrNone)
       
   572         {
       
   573         CleanupStack::PushL(dir);
       
   574 
       
   575         for (TInt i=0; i<dir->Count(); i++)
       
   576             {
       
   577             TFileEntry fileEntry;
       
   578             fileEntry.iPath = iCurrentPath;
       
   579             fileEntry.iEntry = (*dir)[i];
       
   580             fileEntry.iDirEntries = KErrNotFound;
       
   581             fileEntry.iIconId = EFixedIconEmpty;
       
   582 
       
   583             // check for directory entries
       
   584             if (fileEntry.iEntry.IsDir())
       
   585                 {
       
   586                 fileEntry.iIconId = EFixedIconFolder;
       
   587 
       
   588                 TFileName subPath = fileEntry.iPath;
       
   589                 subPath.Append(fileEntry.iEntry.iName);
       
   590                 subPath.Append(_L("\\"));
       
   591 
       
   592                 // check if any sub directories
       
   593                 CDir* subDir = NULL;
       
   594                 if (iFs.GetDir(subPath, KEntryAttDir|KEntryAttMatchMask, ESortNone | EDirsFirst, subDir) == KErrNone)
       
   595                     {
       
   596                     fileEntry.iDirEntries = subDir->Count();
       
   597 
       
   598                     for (TInt j=0; j<subDir->Count(); j++)
       
   599                         {
       
   600                         TEntry entry = (*subDir)[j];
       
   601 
       
   602                         if (entry.IsDir())
       
   603                             {
       
   604                             fileEntry.iIconId = EFixedIconFolderSub;
       
   605                             break;
       
   606                             }
       
   607                         }
       
   608 
       
   609                     delete subDir;
       
   610                     }
       
   611                     iFileEntryList->AppendL(fileEntry);
       
   612                 }
       
   613             }
       
   614 
       
   615         CleanupStack::PopAndDestroy(); //dir
       
   616         }
       
   617     }
       
   618 
       
   619 // --------------------------------------------------------------------------------------------
       
   620       
       
   621 // End of File
       
   622