commonuis/CommonDialogs/src/AknCFDUtility.cpp
branchRCL_3
changeset 56 d48ab3b357f1
parent 55 aecbbf00d063
child 72 a5e7a4f63858
--- a/commonuis/CommonDialogs/src/AknCFDUtility.cpp	Tue Aug 31 15:28:30 2010 +0300
+++ b/commonuis/CommonDialogs/src/AknCFDUtility.cpp	Wed Sep 01 12:16:19 2010 +0100
@@ -24,6 +24,7 @@
 #include <AknsUtils.h>
 #include <gulicon.h>
 #include <fbs.h>
+#include <rsfwmountman.h>
 #include <driveinfo.h>
 #include <StringLoader.h>
 #include <commondialogs.rsg>
@@ -166,21 +167,21 @@
     // If type is remote drive and aConnectionState is required
     if( driveInfo.iDriveAtt & KDriveAttRemote )
         {
-//        TChar driveLetter;
-//        fs.DriveToChar( aDriveNumber, driveLetter );
-//        
-//           // This statement migth cause leave.. to be solved
-//        CRsfwMountMan* mountMgr = CRsfwMountMan::NewL( 0, NULL );
-//        TRsfwMountInfo mountInfo;
-//        error = mountMgr->GetMountInfo( driveLetter, mountInfo );
-//        delete mountMgr;
-//        aDriveInfo.iConnectionState = mountInfo.iMountStatus.iConnectionState;
-//        if( error ||
-//            mountInfo.iMountStatus.iConnectionState != KMountStronglyConnected )
-//            {
-//            aDriveInfo.iDriveStatus = EDriveNotReady;
-//            return error;
-//            }
+        TChar driveLetter;
+        fs.DriveToChar( aDriveNumber, driveLetter );
+        
+           // This statement migth cause leave.. to be solved
+        CRsfwMountMan* mountMgr = CRsfwMountMan::NewL( 0, NULL );
+        TRsfwMountInfo mountInfo;
+        error = mountMgr->GetMountInfo( driveLetter, mountInfo );
+        delete mountMgr;
+        aDriveInfo.iConnectionState = mountInfo.iMountStatus.iConnectionState;
+        if( error ||
+            mountInfo.iMountStatus.iConnectionState != KMountStronglyConnected )
+            {
+            aDriveInfo.iDriveStatus = EDriveNotReady;
+            return error;
+            }
         }
     return error;
     }
@@ -254,19 +255,19 @@
     // If type is remote drive and aConnectionState is required
     if( driveInfo.iDriveAtt & KDriveAttRemote )
         {
-//        TChar driveLetter;
-//        fs.DriveToChar( aDriveNumber, driveLetter );
-//        // This statement migth cause leave.. to be solved
-//        CRsfwMountMan* mountMgr = CRsfwMountMan::NewL( 0, NULL );
-//        TRsfwMountInfo mountInfo;
-//        error = mountMgr->GetMountInfo( driveLetter, mountInfo );
-//        delete mountMgr;
-//
-//        if( error ||
-//            mountInfo.iMountStatus.iConnectionState != KMountStronglyConnected )
-//            {
-//            return EDriveNotReady;
-//            }
+        TChar driveLetter;
+        fs.DriveToChar( aDriveNumber, driveLetter );
+        // This statement migth cause leave.. to be solved
+        CRsfwMountMan* mountMgr = CRsfwMountMan::NewL( 0, NULL );
+        TRsfwMountInfo mountInfo;
+        error = mountMgr->GetMountInfo( driveLetter, mountInfo );
+        delete mountMgr;
+
+        if( error ||
+            mountInfo.iMountStatus.iConnectionState != KMountStronglyConnected )
+            {
+            return EDriveNotReady;
+            }
         }
     return EDriveOK;
     }
@@ -497,70 +498,70 @@
 void AknCFDUtility::ReadDynamicDrivesL(
     CDesCArrayFlat& aRootPathArray, TInt aIncludedMedias )
     {
-//#ifdef _DEBUG
-//    CDesCArray* mediaTypeStrings = new (ELeave) CDesCArrayFlat(10);
-//    CleanupStack::PushL( mediaTypeStrings );
-//
-//    // TMediaType enumeration as string representation for debugging.
-//    mediaTypeStrings->AppendL( _L( "EMediaNotPresent" ) );
-//    mediaTypeStrings->AppendL( _L( "EMediaUnknown" ) );
-//    mediaTypeStrings->AppendL( _L( "EMediaFloppy" ) );
-//    mediaTypeStrings->AppendL( _L( "EMediaHardDisk" ));
-//    mediaTypeStrings->AppendL( _L( "EMediaCdRom" ));
-//    mediaTypeStrings->AppendL( _L( "EMediaRam" ));
-//    mediaTypeStrings->AppendL( _L( "EMediaFlash" ));
-//    mediaTypeStrings->AppendL( _L( "EMediaRom"  ));
-//    mediaTypeStrings->AppendL( _L( "EMediaRemote" ));
-//    mediaTypeStrings->AppendL( _L( "EMediaNANDFlash" ));
-//    _LOG( "[CFDUtility] Drive info: " );
-//#endif // _DEBUG
-//
-//    // Get list of drives dynamically (move this to CFDUtility?)
-//    RFs& fs = CCoeEnv::Static()->FsSession();
-//    TDriveList driveList;
-//
-//    CRsfwMountMan* mountMgr = CRsfwMountMan::NewL( 0, NULL );
-//    CleanupStack::PushL( mountMgr );
-//    mountMgr->GetRemoteMountListL( driveList );
-//    CleanupStack::PopAndDestroy( mountMgr );
-//
-//    _LOG1( "[CFDUtility] driveList:%S", &driveList );
-//
-//    TChar driveLetter;
-//    TInt driveNumber = 0;
-//    _LIT( KDrivePath, "%c:\\" );
-//    TDriveInfo driveInfo;
-//
-//    for( TInt i = 0; i < driveList.Length(); i++ )
-//        {
-//        driveLetter = driveList[ i ];
-//        User::LeaveIfError( fs.CharToDrive( driveLetter, driveNumber ) );
-//        User::LeaveIfError( fs.Drive( driveInfo, driveNumber ) );
-//
-//#ifdef _DEBUG
-//        TPtrC mediaType( mediaTypeStrings->MdcaPoint( driveInfo.iType ) );
-//        _LOG4( "[CFDUtility] %c:, ID:%d, Type:%S (%d)",
-//               TUint( driveLetter ),
-//               driveNumber,
-//               &mediaType,
-//               driveInfo.iType );
-//#endif // _DEBUG
-//        // If drive does not already exist and it is required in included
-//        // media types, append drive letter to rootpaths in correct format:
-//        if( !DriveAlreadyExists( aRootPathArray, driveLetter ) &&
-//            IsIncludedMedia( driveInfo, aIncludedMedias ) )
-//            {
-//            TBuf<5> driveBuf;            
-//            TDesC16 drivePath(KDrivePath);
-//            driveBuf.Format( drivePath, &driveLetter );
-//            aRootPathArray.AppendL( driveBuf );
-//            }
-//
-//        }
-//
-//#ifdef _DEBUG
-//    CleanupStack::PopAndDestroy( mediaTypeStrings );
-//#endif // _DEBUG
+#ifdef _DEBUG
+    CDesCArray* mediaTypeStrings = new (ELeave) CDesCArrayFlat(10);
+    CleanupStack::PushL( mediaTypeStrings );
+
+    // TMediaType enumeration as string representation for debugging.
+    mediaTypeStrings->AppendL( _L( "EMediaNotPresent" ) );
+    mediaTypeStrings->AppendL( _L( "EMediaUnknown" ) );
+    mediaTypeStrings->AppendL( _L( "EMediaFloppy" ) );
+    mediaTypeStrings->AppendL( _L( "EMediaHardDisk" ));
+    mediaTypeStrings->AppendL( _L( "EMediaCdRom" ));
+    mediaTypeStrings->AppendL( _L( "EMediaRam" ));
+    mediaTypeStrings->AppendL( _L( "EMediaFlash" ));
+    mediaTypeStrings->AppendL( _L( "EMediaRom"  ));
+    mediaTypeStrings->AppendL( _L( "EMediaRemote" ));
+    mediaTypeStrings->AppendL( _L( "EMediaNANDFlash" ));
+    _LOG( "[CFDUtility] Drive info: " );
+#endif // _DEBUG
+
+    // Get list of drives dynamically (move this to CFDUtility?)
+    RFs& fs = CCoeEnv::Static()->FsSession();
+    TDriveList driveList;
+
+    CRsfwMountMan* mountMgr = CRsfwMountMan::NewL( 0, NULL );
+    CleanupStack::PushL( mountMgr );
+    mountMgr->GetRemoteMountListL( driveList );
+    CleanupStack::PopAndDestroy( mountMgr );
+
+    _LOG1( "[CFDUtility] driveList:%S", &driveList );
+
+    TChar driveLetter;
+    TInt driveNumber = 0;
+    _LIT( KDrivePath, "%c:\\" );
+    TDriveInfo driveInfo;
+
+    for( TInt i = 0; i < driveList.Length(); i++ )
+        {
+        driveLetter = driveList[ i ];
+        User::LeaveIfError( fs.CharToDrive( driveLetter, driveNumber ) );
+        User::LeaveIfError( fs.Drive( driveInfo, driveNumber ) );
+
+#ifdef _DEBUG
+        TPtrC mediaType( mediaTypeStrings->MdcaPoint( driveInfo.iType ) );
+        _LOG4( "[CFDUtility] %c:, ID:%d, Type:%S (%d)",
+               TUint( driveLetter ),
+               driveNumber,
+               &mediaType,
+               driveInfo.iType );
+#endif // _DEBUG
+        // If drive does not already exist and it is required in included
+        // media types, append drive letter to rootpaths in correct format:
+        if( !DriveAlreadyExists( aRootPathArray, driveLetter ) &&
+            IsIncludedMedia( driveInfo, aIncludedMedias ) )
+            {
+            TBuf<5> driveBuf;            
+            TDesC16 drivePath(KDrivePath);
+            driveBuf.Format( drivePath, &driveLetter );
+            aRootPathArray.AppendL( driveBuf );
+            }
+
+        }
+
+#ifdef _DEBUG
+    CleanupStack::PopAndDestroy( mediaTypeStrings );
+#endif // _DEBUG
     }
 
 
@@ -794,24 +795,21 @@
                         
         if (( aFreeSpace >= KHundredNum ) && ( aFreeSpace < KMegaNum ))
             {
-            tempNum /= KThousandNum; // Divide to kilobytes
-            tempNum = TReal32( TInt( tempNum * 10 ) ) / 10;
+            tempNum /= TReal64( KThousandNum ); // Divide to kilobytes
             unitBuf = StringLoader::LoadLC(
                                     R_CFD_QTN_MEMC_UNITS_KILOBYTE,
                                     CCoeEnv::Static());                              
             }
         else if (( aFreeSpace >= KMegaNum ) && ( aFreeSpace < KGigaNum ))
             {                             
-            tempNum /= KMegaNum; // Divide to Megabytes
-            tempNum = TReal32( TInt( tempNum * 10 ) ) / 10;
+            tempNum /= TReal64( KMegaNum ); // Divide to Megabytes
             unitBuf = StringLoader::LoadLC(
                                     R_CFD_QTN_MEMC_UNITS_MEGABYTE,
                                     CCoeEnv::Static());            
             }
         else if (aFreeSpace >= KGigaNum )   
             {
-            tempNum /= KGigaNum; // Divide to Gigabytes
-            tempNum = TReal32( TInt( tempNum * 10 ) ) / 10;
+            tempNum /= TReal64( KGigaNum ); // Divide to Gigabytes
             unitBuf = StringLoader::LoadLC(
                                     R_CFD_QTN_MEMC_UNITS_GIGABYTE,
                                     CCoeEnv::Static());