mmappcomponents/mmmtpdataprovider/mmmtpdpplugins/mediamtpdataprovider/src/cmediamtpdataprovider.cpp
branchRCL_3
changeset 9 bee149131e4b
parent 0 a2952bb97e68
child 14 05b0d2323768
equal deleted inserted replaced
4:d45095c2f4f3 9:bee149131e4b
    13 *
    13 *
    14 * Description:  media mtp data provider
    14 * Description:  media mtp data provider
    15 *
    15 *
    16 */
    16 */
    17 
    17 
    18 
       
    19 #include <mtp/mmtpconnection.h>
    18 #include <mtp/mmtpconnection.h>
    20 #include <mtp/mmtpdataproviderframework.h>
    19 #include <mtp/mmtpdataproviderframework.h>
    21 #include <mtp/mmtpstoragemgr.h>
    20 #include <mtp/mmtpstoragemgr.h>
    22 #include <mtp/cmtpobjectmetadata.h>
    21 #include <mtp/cmtpobjectmetadata.h>
    23 #include <mtp/mmtpobjectmgr.h>
    22 #include <mtp/mmtpobjectmgr.h>
    34 #include "cmmmtpdpmetadataaccesswrapper.h"
    33 #include "cmmmtpdpmetadataaccesswrapper.h"
    35 #include "mmmtpdputility.h"
    34 #include "mmmtpdputility.h"
    36 #include "crenameobject.h"
    35 #include "crenameobject.h"
    37 #include "mmmtpdpdefs.h"
    36 #include "mmmtpdpdefs.h"
    38 #include "mmmtpdpfiledefs.h"
    37 #include "mmmtpdpfiledefs.h"
       
    38 #include "cmediamtpdataproviderpropertysettingutility.h"
       
    39 #include "cmediamtpdataproviderdescriptionutility.h"
    39 
    40 
    40 // Class constants.
    41 // Class constants.
    41 // Defines the number of MTP Active Processors allowed
    42 // Defines the number of MTP Active Processors allowed
    42 static const TInt KMediaMtpDataProviderSessionGranularity = 3;
    43 static const TInt KMediaMtpDataProviderSessionGranularity = 3;
    43 static const TInt KMediaMtpDpArrayGranularity = 2;
    44 static const TInt KMediaMtpDpArrayGranularity = 2;
    75     iSupportedFormat( KMediaMtpDpArrayGranularity ),
    76     iSupportedFormat( KMediaMtpDpArrayGranularity ),
    76     iSupportedPropAudio( KMediaMtpDpArrayGranularity ),
    77     iSupportedPropAudio( KMediaMtpDpArrayGranularity ),
    77     iSupportedPropVideo( KMediaMtpDpArrayGranularity ),
    78     iSupportedPropVideo( KMediaMtpDpArrayGranularity ),
    78     iSupportedPropAll( KMediaMtpDpArrayGranularity )
    79     iSupportedPropAll( KMediaMtpDpArrayGranularity )
    79     {
    80     {
       
    81     // Do nothing
    80     }
    82     }
    81 
    83 
    82 // -----------------------------------------------------------------------------
    84 // -----------------------------------------------------------------------------
    83 // CMediaMtpDataProvider::~CMediaMtpDataProvider
    85 // CMediaMtpDataProvider::~CMediaMtpDataProvider
    84 // Destructor
    86 // Destructor
    88     {
    90     {
    89     PRINT( _L( "MM MTP => CMediaMtpDataProvider::~CMediaMtpDataProvider" ) );
    91     PRINT( _L( "MM MTP => CMediaMtpDataProvider::~CMediaMtpDataProvider" ) );
    90 
    92 
    91     CMmMtpDpAccessSingleton::Release();
    93     CMmMtpDpAccessSingleton::Release();
    92     delete iMediaEnumerator;
    94     delete iMediaEnumerator;
       
    95     delete iPropSettingUtility;
       
    96     delete iDescriptionUtility;
    93 
    97 
    94     iPendingEnumerations.Close();
    98     iPendingEnumerations.Close();
    95     TInt count = iActiveProcessors.Count();
    99     TInt count = iActiveProcessors.Count();
    96     for ( TInt i = 0; i < count; i++ )
   100     for ( TInt i = 0; i < count; i++ )
    97         {
   101         {
   130 
   134 
   131     GetSupportedFormatL();
   135     GetSupportedFormatL();
   132     GetSupportedPropL();
   136     GetSupportedPropL();
   133     GetAllSupportedPropL();
   137     GetAllSupportedPropL();
   134 
   138 
       
   139     iPropSettingUtility = CMediaMtpDataProviderPropertySettingUtility::NewL();
       
   140     iDescriptionUtility = CMediaMtpDataProviderDescriptionUtility::NewL();
       
   141 
   135     PRINT( _L( "MM MTP <= CMediaMtpDataProvider::ConstructL" ) );
   142     PRINT( _L( "MM MTP <= CMediaMtpDataProvider::ConstructL" ) );
   136     }
   143     }
   137 
   144 
   138 // -----------------------------------------------------------------------------
   145 // -----------------------------------------------------------------------------
   139 // CMediaMtpDataProvider::ProcessEventL
   146 // CMediaMtpDataProvider::ProcessEventL
   160     {
   167     {
   161     switch ( aNotification )
   168     switch ( aNotification )
   162         {
   169         {
   163         case EMTPSessionClosed:
   170         case EMTPSessionClosed:
   164             PRINT( _L( "MM MTP <> CMediaMtpDataProvider::ProcessNotificationL EMTPSessionClosed event recvd" ) );
   171             PRINT( _L( "MM MTP <> CMediaMtpDataProvider::ProcessNotificationL EMTPSessionClosed event recvd" ) );
   165 
       
   166             SessionClosedL( *reinterpret_cast<const TMTPNotificationParamsSessionChange*> ( aParams ) );
   172             SessionClosedL( *reinterpret_cast<const TMTPNotificationParamsSessionChange*> ( aParams ) );
   167             break;
   173             break;
   168 
   174 
   169         case EMTPSessionOpened:
   175         case EMTPSessionOpened:
   170             PRINT( _L( "MM MTP <> CMediaMtpDataProvider::ProcessNotificationL EMTPSessionOpened event recvd" ) );
   176             PRINT( _L( "MM MTP <> CMediaMtpDataProvider::ProcessNotificationL EMTPSessionOpened event recvd" ) );
   171 
       
   172             SessionOpenedL( *reinterpret_cast<const TMTPNotificationParamsSessionChange*> ( aParams ) );
   177             SessionOpenedL( *reinterpret_cast<const TMTPNotificationParamsSessionChange*> ( aParams ) );
   173             break;
   178             break;
   174 
   179 
   175         case EMTPStorageAdded:
   180         case EMTPStorageAdded:
   176             break;
   181             break;
   203 
   208 
   204     __ASSERT_DEBUG( index != KErrNotFound, Panic(EMmMTPDpNoMatchingProcessor) );
   209     __ASSERT_DEBUG( index != KErrNotFound, Panic(EMmMTPDpNoMatchingProcessor) );
   205 
   210 
   206     MMmRequestProcessor* processor = iActiveProcessors[index];
   211     MMmRequestProcessor* processor = iActiveProcessors[index];
   207     iActiveProcessor = index;
   212     iActiveProcessor = index;
   208     // iActiveProcessorRemoved = EFalse;
   213     iActiveProcessorRemoved = EFalse;
   209     TBool result = processor->HandleRequestL( aRequest, aPhase );
   214     TBool result = processor->HandleRequestL( aRequest, aPhase );
   210 
   215 
   211     if( !iIsSessionOpen )
   216     if ( !iIsSessionOpen )
   212         {
   217         {
   213         processor->Release();
   218         processor->Release();
   214         }
   219         }
   215 
   220     // iActiveProcessorRemoved will be set to ETrue in the above function
       
   221     // HandleRequestL(),such as SessionClose()
       
   222     else if ( iActiveProcessorRemoved )
       
   223         {
       
   224         processor->Release(); // destroy the processor
       
   225         }
   216     else if ( result ) // destroy the processor
   226     else if ( result ) // destroy the processor
   217         {
   227         {
   218         processor->Release();
   228         processor->Release();
   219         iActiveProcessors.Remove( index );
   229         iActiveProcessors.Remove( index );
   220         }
   230         }
   244                 == aSession.iConnection.ConnectionId() ) )
   254                 == aSession.iConnection.ConnectionId() ) )
   245             {
   255             {
   246             processor->UsbDisconnect(); // Rollback
   256             processor->UsbDisconnect(); // Rollback
   247 
   257 
   248             iActiveProcessors.Remove( i );
   258             iActiveProcessors.Remove( i );
   249             processor->Release();
   259             if ( i == iActiveProcessor )
       
   260                 {
       
   261                 iActiveProcessorRemoved = ETrue;
       
   262                 }
       
   263             else
       
   264                 {
       
   265                 processor->Release();
       
   266                 }
   250             }
   267             }
   251         }
   268         }
   252 
   269 
   253     // introduce to cleanup DBs at each close session
   270     // introduce to cleanup DBs at each close session
   254     iMediaEnumerator->SessionClosedL();
   271     iMediaEnumerator->SessionClosedL();
   498     return index;
   515     return index;
   499     }
   516     }
   500 
   517 
   501 // -----------------------------------------------------------------------------
   518 // -----------------------------------------------------------------------------
   502 // CMediaMtpDataProvider::GetWrapper
   519 // CMediaMtpDataProvider::GetWrapper
   503 // return the reference of CMmMtpDpMetadataAccessWrapper to enumerator
   520 // return wrapper references
   504 // -----------------------------------------------------------------------------
   521 // -----------------------------------------------------------------------------
   505 //
   522 //
   506 CMmMtpDpMetadataAccessWrapper& CMediaMtpDataProvider::GetWrapperL()
   523 CMmMtpDpMetadataAccessWrapper& CMediaMtpDataProvider::GetWrapperL()
   507     {
   524     {
   508     return CMmMtpDpAccessSingleton::GetAccessWrapperL();
   525     return CMmMtpDpAccessSingleton::GetAccessWrapperL();
       
   526     }
       
   527 
       
   528 // -----------------------------------------------------------------------------
       
   529 // CMediaMtpDataProvider::PropSettingUtility
       
   530 // return The utility to setting properties
       
   531 // -----------------------------------------------------------------------------
       
   532 //
       
   533 CPropertySettingUtility* CMediaMtpDataProvider::PropSettingUtility()
       
   534     {
       
   535     return iPropSettingUtility;
       
   536     }
       
   537 
       
   538 // -----------------------------------------------------------------------------
       
   539 // CMediaMtpDataProvider::DescriptionUtility
       
   540 // return The utiltiy to setting descriptions
       
   541 // -----------------------------------------------------------------------------
       
   542 //
       
   543 CDescriptionUtility* CMediaMtpDataProvider::DescriptionUtility()
       
   544     {
       
   545     return iDescriptionUtility;
   509     }
   546     }
   510 
   547 
   511 // ---------------------------------------------------------------------------
   548 // ---------------------------------------------------------------------------
   512 // CMediaMtpDataProvider::GetSupportedFormat
   549 // CMediaMtpDataProvider::GetSupportedFormat
   513 //
   550 //