mmappcomponents/mmmtpdataprovider/mmmtpdpplugins/abstractmediamtpdataprovider/src/cabstractmediamtpdataprovider.cpp
branchRCL_3
changeset 9 bee149131e4b
parent 0 a2952bb97e68
child 14 05b0d2323768
--- a/mmappcomponents/mmmtpdataprovider/mmmtpdpplugins/abstractmediamtpdataprovider/src/cabstractmediamtpdataprovider.cpp	Tue Feb 02 00:27:58 2010 +0200
+++ b/mmappcomponents/mmmtpdataprovider/mmmtpdpplugins/abstractmediamtpdataprovider/src/cabstractmediamtpdataprovider.cpp	Fri Feb 19 23:18:32 2010 +0200
@@ -38,6 +38,8 @@
 #include "cabstractmediamtpdataproviderrenameobject.h"
 #include "mmmtpdpdefs.h"
 #include "mmmtpdpfiledefs.h"
+#include "cabstractmediamtpdataproviderpropertysettingutility.h"
+#include "cabstractmediamtpdataproviderdescriptionutility.h"
 
 // Class constants.
 // Defines the number of MTP Active Processors allowed
@@ -76,6 +78,7 @@
     iSupportedFormat( KAbstractMediaMtpDpArrayGranularity ),
     iSupportedProperties( KAbstractMediaMtpDpArrayGranularity )
     {
+    // Do nothing
     }
 
 // -----------------------------------------------------------------------------
@@ -87,6 +90,9 @@
     {
     PRINT( _L( "MM MTP => CAbstractMediaMtpDataProvider::~CAbstractMediaMtpDataProvider" ) );
 
+    delete iPropSettingUtility;
+    delete iDescriptionUtility;
+
     iPendingEnumerations.Close();
     TInt count = iActiveProcessors.Count();
     for ( TInt i = 0; i < count; i++ )
@@ -128,6 +134,9 @@
     GetSupportedFormatL();
     GetSupportedPropertiesL();
 
+    iPropSettingUtility = CAbstractMediaMtpDataProviderPropertySettingUtility::NewL();
+    iDescriptionUtility = CAbstractMediaMtpDataProviderDescriptionUtility::NewL();
+
     PRINT( _L( "MM MTP <= CAbstractMediaMtpDataProvider::ConstructL" ) );
     }
 
@@ -158,13 +167,11 @@
         {
         case EMTPSessionClosed:
             PRINT( _L( "MM MTP <> CAbstractMediaMtpDataProvider::ProcessNotificationL EMTPSessionClosed event recvd" ) );
-
             SessionClosedL( *reinterpret_cast<const TMTPNotificationParamsSessionChange*> ( aParams ) );
             break;
 
         case EMTPSessionOpened:
             PRINT( _L( "MM MTP <> CAbstractMediaMtpDataProvider::ProcessNotificationL EMTPSessionOpened event recvd" ) );
-
             SessionOpenedL( *reinterpret_cast<const TMTPNotificationParamsSessionChange*> ( aParams ) );
             break;
 
@@ -201,18 +208,18 @@
 
     MMmRequestProcessor* processor = iActiveProcessors[index];
     iActiveProcessor = index;
-    // iActiveProcessorRemoved = EFalse;
+    iActiveProcessorRemoved = EFalse;
     TBool result = processor->HandleRequestL( aRequest, aPhase );
-    if( !iIsSessionOpen )
+    if ( !iIsSessionOpen )
         {
         processor->Release();
         }
     // iActiveProcessorRemoved will be set to ETrue in the above function
-    // HandleRequestL(),such as SessionClose()
-    // else if ( iActiveProcessorRemoved )
-    //     {
-    //     processor->Release(); // destroy the processor
-    //     }
+    // HandleRequestL(), such as SessionClose()
+    else if ( iActiveProcessorRemoved )
+        {
+        processor->Release(); // destroy the processor
+        }
     else if ( result ) // destroy the processor
         {
         processor->Release();
@@ -231,7 +238,7 @@
     iIsSessionOpen = EFalse;
     TInt count = iActiveProcessors.Count();
     PRINT1( _L( "MM MTP => CAbstractMediaMtpDataProvider::SessionClosedL, total processor count = %d" ), count );
-    for( TInt i = 0; i < count; i++ )
+    for ( TInt i = 0; i < count; i++ )
         {
         MMmRequestProcessor* processor = iActiveProcessors[i];
 
@@ -240,17 +247,17 @@
         TUint32 sessionId = processor->SessionId();
 
         if ( ( sessionId == aSession.iMTPId )
-                && ( processor->Connection().ConnectionId()
-                == aSession.iConnection.ConnectionId() ) )
+            && ( processor->Connection().ConnectionId() 
+			== aSession.iConnection.ConnectionId() ) )
             {
             processor->UsbDisconnect(); // Rollback
 
             iActiveProcessors.Remove( i );
-            // if ( i == iActiveProcessor )
-            //     {
-            //     iActiveProcessorRemoved = ETrue;
-            //     }
-            //     else
+            if ( i == iActiveProcessor )
+                {
+                iActiveProcessorRemoved = ETrue;
+                }
+            else
                 {
                 processor->Release();
                 }
@@ -472,7 +479,7 @@
 
 // -----------------------------------------------------------------------------
 // CAbstractMediaMtpDataProvider::GetWrapper
-// return the reference of CMmMtpDpMetadataAccessWrapper to enumerator
+// return wrapper references
 // -----------------------------------------------------------------------------
 //
 CMmMtpDpMetadataAccessWrapper& CAbstractMediaMtpDataProvider::GetWrapperL()
@@ -480,6 +487,26 @@
     return CMmMtpDpAccessSingleton::GetAccessWrapperL();
     }
 
+// -----------------------------------------------------------------------------
+// CAbstractMediaMtpDataProvider::PropSettingUtility
+// return The utility to setting properties
+// -----------------------------------------------------------------------------
+//
+CPropertySettingUtility* CAbstractMediaMtpDataProvider::PropSettingUtility()
+    {
+    return iPropSettingUtility;
+    }
+
+// -----------------------------------------------------------------------------
+// CAbstractMediaMtpDataProvider::DescriptionUtility
+// return The utiltiy to setting descriptions
+// -----------------------------------------------------------------------------
+//
+CDescriptionUtility* CAbstractMediaMtpDataProvider::DescriptionUtility()
+    {
+    return iDescriptionUtility;
+    }
+
 // ---------------------------------------------------------------------------
 // CAbstractMediaMtpDataProvider::GetSupportedFormat
 //
@@ -501,8 +528,9 @@
         }
     }
 
-const RArray<TUint>* CAbstractMediaMtpDataProvider::GetSupportedPropertiesL( TUint32 aFormatCode ) const
+const RArray<TUint>* CAbstractMediaMtpDataProvider::GetSupportedPropertiesL( TUint32 /*aFormatCode*/ ) const
     {
+    // May need add more implementation here for further extension.
     return &iSupportedProperties;
     }
 
@@ -552,10 +580,19 @@
 
     TDriveInfo driveInfo;
     User::LeaveIfError( Framework().Fs().Drive( driveInfo, driveNum ) );
+    PRINT3( _L( "driveInfo.iType = 0x%x, driveInfo.iDriveAtt = 0x%x, driveInfo.iMediaAtt = 0x%x" ),
+        driveInfo.iType,
+        driveInfo.iDriveAtt,
+        driveInfo.iMediaAtt );
     if( driveInfo.iType == EMediaNotPresent || driveInfo.iType == EMediaUnknown )
         {
-        err = DriveInfo::GetDefaultDrive( DriveInfo::EDefaultPhoneMemory, driveNum );
-        PRINT( _L( "MM MTP <> Memory card doesn't exist, set PhoneMemory to default" ) );
+        err = DriveInfo::GetDefaultDrive( DriveInfo::EDefaultRemovableMassStorage, driveNum );
+        User::LeaveIfError( Framework().Fs().Drive( driveInfo, driveNum ) );
+        if( driveInfo.iType == EMediaNotPresent || driveInfo.iType == EMediaUnknown )
+            {
+            err = DriveInfo::GetDefaultDrive( DriveInfo::EDefaultPhoneMemory, driveNum );
+            PRINT( _L( "MM MTP <> Memory card doesn't exist, set PhoneMemory to default" ) );
+            }
         }
 
     return Framework().StorageMgr().FrameworkStorageId( TDriveNumber( driveNum ) );