commonuis/CommonDialogs/src/AknCFDUtility.cpp
changeset 14 3320e4e6e8bb
parent 0 2f259fa3e83a
equal deleted inserted replaced
0:2f259fa3e83a 14:3320e4e6e8bb
    22 #include <AknIconArray.h>
    22 #include <AknIconArray.h>
    23 #include <eikenv.h>
    23 #include <eikenv.h>
    24 #include <AknsUtils.h>
    24 #include <AknsUtils.h>
    25 #include <gulicon.h>
    25 #include <gulicon.h>
    26 #include <fbs.h>
    26 #include <fbs.h>
    27 #include <rsfwmountman.h>
       
    28 #include <driveinfo.h>
    27 #include <driveinfo.h>
    29 #include <StringLoader.h>
    28 #include <StringLoader.h>
    30 #include <commondialogs.rsg>
    29 #include <commondialogs.rsg>
    31 #include "AknCFDUtility.h"
    30 #include "AknCFDUtility.h"
    32 #include <AknUtils.h>
    31 #include <AknUtils.h>
   165     aDriveInfo.iVolumeLabel = volumeInfo.iName;
   164     aDriveInfo.iVolumeLabel = volumeInfo.iName;
   166 
   165 
   167     // If type is remote drive and aConnectionState is required
   166     // If type is remote drive and aConnectionState is required
   168     if( driveInfo.iDriveAtt & KDriveAttRemote )
   167     if( driveInfo.iDriveAtt & KDriveAttRemote )
   169         {
   168         {
   170         TChar driveLetter;
   169 //        TChar driveLetter;
   171         fs.DriveToChar( aDriveNumber, driveLetter );
   170 //        fs.DriveToChar( aDriveNumber, driveLetter );
   172         
   171 //        
   173            // This statement migth cause leave.. to be solved
   172 //           // This statement migth cause leave.. to be solved
   174         CRsfwMountMan* mountMgr = CRsfwMountMan::NewL( 0, NULL );
   173 //        CRsfwMountMan* mountMgr = CRsfwMountMan::NewL( 0, NULL );
   175         TRsfwMountInfo mountInfo;
   174 //        TRsfwMountInfo mountInfo;
   176         error = mountMgr->GetMountInfo( driveLetter, mountInfo );
   175 //        error = mountMgr->GetMountInfo( driveLetter, mountInfo );
   177         delete mountMgr;
   176 //        delete mountMgr;
   178         aDriveInfo.iConnectionState = mountInfo.iMountStatus.iConnectionState;
   177 //        aDriveInfo.iConnectionState = mountInfo.iMountStatus.iConnectionState;
   179         if( error ||
   178 //        if( error ||
   180             mountInfo.iMountStatus.iConnectionState != KMountStronglyConnected )
   179 //            mountInfo.iMountStatus.iConnectionState != KMountStronglyConnected )
   181             {
   180 //            {
   182             aDriveInfo.iDriveStatus = EDriveNotReady;
   181 //            aDriveInfo.iDriveStatus = EDriveNotReady;
   183             return error;
   182 //            return error;
   184             }
   183 //            }
   185         }
   184         }
   186     return error;
   185     return error;
   187     }
   186     }
   188 
   187 
   189 
   188 
   253         }
   252         }
   254 
   253 
   255     // If type is remote drive and aConnectionState is required
   254     // If type is remote drive and aConnectionState is required
   256     if( driveInfo.iDriveAtt & KDriveAttRemote )
   255     if( driveInfo.iDriveAtt & KDriveAttRemote )
   257         {
   256         {
   258         TChar driveLetter;
   257 //        TChar driveLetter;
   259         fs.DriveToChar( aDriveNumber, driveLetter );
   258 //        fs.DriveToChar( aDriveNumber, driveLetter );
   260         // This statement migth cause leave.. to be solved
   259 //        // This statement migth cause leave.. to be solved
   261         CRsfwMountMan* mountMgr = CRsfwMountMan::NewL( 0, NULL );
   260 //        CRsfwMountMan* mountMgr = CRsfwMountMan::NewL( 0, NULL );
   262         TRsfwMountInfo mountInfo;
   261 //        TRsfwMountInfo mountInfo;
   263         error = mountMgr->GetMountInfo( driveLetter, mountInfo );
   262 //        error = mountMgr->GetMountInfo( driveLetter, mountInfo );
   264         delete mountMgr;
   263 //        delete mountMgr;
   265 
   264 //
   266         if( error ||
   265 //        if( error ||
   267             mountInfo.iMountStatus.iConnectionState != KMountStronglyConnected )
   266 //            mountInfo.iMountStatus.iConnectionState != KMountStronglyConnected )
   268             {
   267 //            {
   269             return EDriveNotReady;
   268 //            return EDriveNotReady;
   270             }
   269 //            }
   271         }
   270         }
   272     return EDriveOK;
   271     return EDriveOK;
   273     }
   272     }
   274 
   273 
   275 // ---------------------------------------------------------------------------
   274 // ---------------------------------------------------------------------------
   496 // ---------------------------------------------------------------------------
   495 // ---------------------------------------------------------------------------
   497 //
   496 //
   498 void AknCFDUtility::ReadDynamicDrivesL(
   497 void AknCFDUtility::ReadDynamicDrivesL(
   499     CDesCArrayFlat& aRootPathArray, TInt aIncludedMedias )
   498     CDesCArrayFlat& aRootPathArray, TInt aIncludedMedias )
   500     {
   499     {
   501 #ifdef _DEBUG
   500 //#ifdef _DEBUG
   502     CDesCArray* mediaTypeStrings = new (ELeave) CDesCArrayFlat(10);
   501 //    CDesCArray* mediaTypeStrings = new (ELeave) CDesCArrayFlat(10);
   503     CleanupStack::PushL( mediaTypeStrings );
   502 //    CleanupStack::PushL( mediaTypeStrings );
   504 
   503 //
   505     // TMediaType enumeration as string representation for debugging.
   504 //    // TMediaType enumeration as string representation for debugging.
   506     mediaTypeStrings->AppendL( _L( "EMediaNotPresent" ) );
   505 //    mediaTypeStrings->AppendL( _L( "EMediaNotPresent" ) );
   507     mediaTypeStrings->AppendL( _L( "EMediaUnknown" ) );
   506 //    mediaTypeStrings->AppendL( _L( "EMediaUnknown" ) );
   508     mediaTypeStrings->AppendL( _L( "EMediaFloppy" ) );
   507 //    mediaTypeStrings->AppendL( _L( "EMediaFloppy" ) );
   509     mediaTypeStrings->AppendL( _L( "EMediaHardDisk" ));
   508 //    mediaTypeStrings->AppendL( _L( "EMediaHardDisk" ));
   510     mediaTypeStrings->AppendL( _L( "EMediaCdRom" ));
   509 //    mediaTypeStrings->AppendL( _L( "EMediaCdRom" ));
   511     mediaTypeStrings->AppendL( _L( "EMediaRam" ));
   510 //    mediaTypeStrings->AppendL( _L( "EMediaRam" ));
   512     mediaTypeStrings->AppendL( _L( "EMediaFlash" ));
   511 //    mediaTypeStrings->AppendL( _L( "EMediaFlash" ));
   513     mediaTypeStrings->AppendL( _L( "EMediaRom"  ));
   512 //    mediaTypeStrings->AppendL( _L( "EMediaRom"  ));
   514     mediaTypeStrings->AppendL( _L( "EMediaRemote" ));
   513 //    mediaTypeStrings->AppendL( _L( "EMediaRemote" ));
   515     mediaTypeStrings->AppendL( _L( "EMediaNANDFlash" ));
   514 //    mediaTypeStrings->AppendL( _L( "EMediaNANDFlash" ));
   516     _LOG( "[CFDUtility] Drive info: " );
   515 //    _LOG( "[CFDUtility] Drive info: " );
   517 #endif // _DEBUG
   516 //#endif // _DEBUG
   518 
   517 //
   519     // Get list of drives dynamically (move this to CFDUtility?)
   518 //    // Get list of drives dynamically (move this to CFDUtility?)
   520     RFs& fs = CCoeEnv::Static()->FsSession();
   519 //    RFs& fs = CCoeEnv::Static()->FsSession();
   521     TDriveList driveList;
   520 //    TDriveList driveList;
   522 
   521 //
   523     CRsfwMountMan* mountMgr = CRsfwMountMan::NewL( 0, NULL );
   522 //    CRsfwMountMan* mountMgr = CRsfwMountMan::NewL( 0, NULL );
   524     CleanupStack::PushL( mountMgr );
   523 //    CleanupStack::PushL( mountMgr );
   525     mountMgr->GetRemoteMountListL( driveList );
   524 //    mountMgr->GetRemoteMountListL( driveList );
   526     CleanupStack::PopAndDestroy( mountMgr );
   525 //    CleanupStack::PopAndDestroy( mountMgr );
   527 
   526 //
   528     _LOG1( "[CFDUtility] driveList:%S", &driveList );
   527 //    _LOG1( "[CFDUtility] driveList:%S", &driveList );
   529 
   528 //
   530     TChar driveLetter;
   529 //    TChar driveLetter;
   531     TInt driveNumber = 0;
   530 //    TInt driveNumber = 0;
   532     _LIT( KDrivePath, "%c:\\" );
   531 //    _LIT( KDrivePath, "%c:\\" );
   533     TDriveInfo driveInfo;
   532 //    TDriveInfo driveInfo;
   534 
   533 //
   535     for( TInt i = 0; i < driveList.Length(); i++ )
   534 //    for( TInt i = 0; i < driveList.Length(); i++ )
   536         {
   535 //        {
   537         driveLetter = driveList[ i ];
   536 //        driveLetter = driveList[ i ];
   538         User::LeaveIfError( fs.CharToDrive( driveLetter, driveNumber ) );
   537 //        User::LeaveIfError( fs.CharToDrive( driveLetter, driveNumber ) );
   539         User::LeaveIfError( fs.Drive( driveInfo, driveNumber ) );
   538 //        User::LeaveIfError( fs.Drive( driveInfo, driveNumber ) );
   540 
   539 //
   541 #ifdef _DEBUG
   540 //#ifdef _DEBUG
   542         TPtrC mediaType( mediaTypeStrings->MdcaPoint( driveInfo.iType ) );
   541 //        TPtrC mediaType( mediaTypeStrings->MdcaPoint( driveInfo.iType ) );
   543         _LOG4( "[CFDUtility] %c:, ID:%d, Type:%S (%d)",
   542 //        _LOG4( "[CFDUtility] %c:, ID:%d, Type:%S (%d)",
   544                TUint( driveLetter ),
   543 //               TUint( driveLetter ),
   545                driveNumber,
   544 //               driveNumber,
   546                &mediaType,
   545 //               &mediaType,
   547                driveInfo.iType );
   546 //               driveInfo.iType );
   548 #endif // _DEBUG
   547 //#endif // _DEBUG
   549         // If drive does not already exist and it is required in included
   548 //        // If drive does not already exist and it is required in included
   550         // media types, append drive letter to rootpaths in correct format:
   549 //        // media types, append drive letter to rootpaths in correct format:
   551         if( !DriveAlreadyExists( aRootPathArray, driveLetter ) &&
   550 //        if( !DriveAlreadyExists( aRootPathArray, driveLetter ) &&
   552             IsIncludedMedia( driveInfo, aIncludedMedias ) )
   551 //            IsIncludedMedia( driveInfo, aIncludedMedias ) )
   553             {
   552 //            {
   554             TBuf<5> driveBuf;            
   553 //            TBuf<5> driveBuf;            
   555             TDesC16 drivePath(KDrivePath);
   554 //            TDesC16 drivePath(KDrivePath);
   556             driveBuf.Format( drivePath, &driveLetter );
   555 //            driveBuf.Format( drivePath, &driveLetter );
   557             aRootPathArray.AppendL( driveBuf );
   556 //            aRootPathArray.AppendL( driveBuf );
   558             }
   557 //            }
   559 
   558 //
   560         }
   559 //        }
   561 
   560 //
   562 #ifdef _DEBUG
   561 //#ifdef _DEBUG
   563     CleanupStack::PopAndDestroy( mediaTypeStrings );
   562 //    CleanupStack::PopAndDestroy( mediaTypeStrings );
   564 #endif // _DEBUG
   563 //#endif // _DEBUG
   565     }
   564     }
   566 
   565 
   567 
   566 
   568 // ---------------------------------------------------------------------------
   567 // ---------------------------------------------------------------------------
   569 // AknCFDUtility::DriveAlreadyExists
   568 // AknCFDUtility::DriveAlreadyExists