mmappcomponents/mmmtpdataprovider/mmmtpdpplugins/abstractmediamtpdataprovider/src/cabstractmediamtpdataprovider.cpp
changeset 0 a2952bb97e68
child 9 bee149131e4b
child 25 d881023c13eb
equal deleted inserted replaced
-1:000000000000 0:a2952bb97e68
       
     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:  AbstractMedia data provider
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #include <mtp/mmtpconnection.h>
       
    20 #include <mtp/mtpprotocolconstants.h>
       
    21 #include <mtp/mmtpdataproviderframework.h>
       
    22 #include <mtp/mmtpstoragemgr.h>
       
    23 #include <mtp/tmtptyperequest.h>
       
    24 #include <mtp/cmtpobjectmetadata.h>
       
    25 #include <mtp/mmtpobjectmgr.h>
       
    26 #include <barsc.h>
       
    27 #include <barsread.h>
       
    28 #include <driveinfo.h>
       
    29 
       
    30 #include "cabstractmediamtpdataprovider.h"
       
    31 #include "crequestprocessor.h"
       
    32 #include "abstractmediamtpdataproviderconst.h"
       
    33 #include "tmmmtpdppanic.h"
       
    34 #include "cabstractmediamtpdataproviderenumerator.h"
       
    35 #include "mmmtpdplogger.h"
       
    36 #include "cmmmtpdpaccesssingleton.h"
       
    37 #include "mmmtpdputility.h"
       
    38 #include "cabstractmediamtpdataproviderrenameobject.h"
       
    39 #include "mmmtpdpdefs.h"
       
    40 #include "mmmtpdpfiledefs.h"
       
    41 
       
    42 // Class constants.
       
    43 // Defines the number of MTP Active Processors allowed
       
    44 static const TInt KMTPAbstractMediaDpSessionGranularity = 3;
       
    45 static const TInt KAbstractMediaMtpDpArrayGranularity = 2;
       
    46 
       
    47 static const TInt KActiveEnumeration = 0;
       
    48 
       
    49 // -----------------------------------------------------------------------------
       
    50 // CAbstractMediaMtpDataProvider::NewL
       
    51 // Two Phase Construction
       
    52 // -----------------------------------------------------------------------------
       
    53 //
       
    54 TAny* CAbstractMediaMtpDataProvider::NewL( TAny* aParams )
       
    55     {
       
    56     CAbstractMediaMtpDataProvider* self = new ( ELeave ) CAbstractMediaMtpDataProvider( aParams );
       
    57     CleanupStack::PushL( self );
       
    58     self->ConstructL();
       
    59     CleanupStack::Pop( self );
       
    60 
       
    61     return self;
       
    62     }
       
    63 
       
    64 // -----------------------------------------------------------------------------
       
    65 // CAbstractMediaMtpDataProvider::CAbstractMediaMtpDataProvider
       
    66 // Standard C++ constructor
       
    67 // -----------------------------------------------------------------------------
       
    68 //
       
    69 CAbstractMediaMtpDataProvider::CAbstractMediaMtpDataProvider( TAny* aParams ) :
       
    70     CMTPDataProviderPlugin( aParams ),
       
    71     iActiveProcessors( KMTPAbstractMediaDpSessionGranularity ),
       
    72     iAbstractMediaEnumerator( NULL ),
       
    73     iPendingEnumerations ( KAbstractMediaMtpDpArrayGranularity ),
       
    74     iActiveProcessor( -1 ),
       
    75     iRenameObject( NULL ),
       
    76     iSupportedFormat( KAbstractMediaMtpDpArrayGranularity ),
       
    77     iSupportedProperties( KAbstractMediaMtpDpArrayGranularity )
       
    78     {
       
    79     }
       
    80 
       
    81 // -----------------------------------------------------------------------------
       
    82 // CAbstractMediaMtpDataProvider::~CAbstractMediaMtpDataProvider
       
    83 // Destructor
       
    84 // -----------------------------------------------------------------------------
       
    85 //
       
    86 CAbstractMediaMtpDataProvider::~CAbstractMediaMtpDataProvider()
       
    87     {
       
    88     PRINT( _L( "MM MTP => CAbstractMediaMtpDataProvider::~CAbstractMediaMtpDataProvider" ) );
       
    89 
       
    90     iPendingEnumerations.Close();
       
    91     TInt count = iActiveProcessors.Count();
       
    92     for ( TInt i = 0; i < count; i++ )
       
    93         {
       
    94         iActiveProcessors[i]->Release();
       
    95         }
       
    96     iActiveProcessors.Close();
       
    97 
       
    98     delete iAbstractMediaEnumerator;
       
    99     CMmMtpDpAccessSingleton::Release();
       
   100 
       
   101     if ( iRenameObject )
       
   102         delete iRenameObject;
       
   103 
       
   104     iSupportedFormat.Close();
       
   105     iSupportedProperties.Close();
       
   106 
       
   107     PRINT( _L( "MM MTP => CAbstractMediaMtpDataProvider::~CAbstractMediaMtpDataProvider" ) );
       
   108     }
       
   109 
       
   110 void CAbstractMediaMtpDataProvider::Cancel()
       
   111     {
       
   112     iAbstractMediaEnumerator->Cancel();
       
   113     }
       
   114 
       
   115 // -----------------------------------------------------------------------------
       
   116 // CAbstractMediaMtpDataProvider::ConstructL
       
   117 // Second-phase construction
       
   118 // -----------------------------------------------------------------------------
       
   119 //
       
   120 void CAbstractMediaMtpDataProvider::ConstructL()
       
   121     {
       
   122     PRINT( _L( "MM MTP => CAbstractMediaMtpDataProvider::ConstructL" ) );
       
   123 
       
   124     iAbstractMediaEnumerator = CAbstractMediaMtpDataProviderEnumerator::NewL( Framework(), *this );
       
   125 
       
   126     CMmMtpDpAccessSingleton::CreateL( Framework().Fs(), Framework() );
       
   127 
       
   128     GetSupportedFormatL();
       
   129     GetSupportedPropertiesL();
       
   130 
       
   131     PRINT( _L( "MM MTP <= CAbstractMediaMtpDataProvider::ConstructL" ) );
       
   132     }
       
   133 
       
   134 // -----------------------------------------------------------------------------
       
   135 // CAbstractMediaMtpDataProvider::ProcessEventL
       
   136 // Process event from initiator
       
   137 // -----------------------------------------------------------------------------
       
   138 //
       
   139 void CAbstractMediaMtpDataProvider::ProcessEventL( const TMTPTypeEvent& aEvent,
       
   140     MMTPConnection& aConnection )
       
   141     {
       
   142     TInt index = LocateRequestProcessorL( aEvent, aConnection );
       
   143     if ( index != KErrNotFound )
       
   144         {
       
   145         iActiveProcessors[index]->HandleEventL( aEvent );
       
   146         }
       
   147     }
       
   148 
       
   149 // -----------------------------------------------------------------------------
       
   150 // CAbstractMediaMtpDataProvider::ProcessNotificationL
       
   151 // Process notification from initiator
       
   152 // -----------------------------------------------------------------------------
       
   153 //
       
   154 void CAbstractMediaMtpDataProvider::ProcessNotificationL( TMTPNotification aNotification,
       
   155     const TAny* aParams )
       
   156     {
       
   157     switch ( aNotification )
       
   158         {
       
   159         case EMTPSessionClosed:
       
   160             PRINT( _L( "MM MTP <> CAbstractMediaMtpDataProvider::ProcessNotificationL EMTPSessionClosed event recvd" ) );
       
   161 
       
   162             SessionClosedL( *reinterpret_cast<const TMTPNotificationParamsSessionChange*> ( aParams ) );
       
   163             break;
       
   164 
       
   165         case EMTPSessionOpened:
       
   166             PRINT( _L( "MM MTP <> CAbstractMediaMtpDataProvider::ProcessNotificationL EMTPSessionOpened event recvd" ) );
       
   167 
       
   168             SessionOpenedL( *reinterpret_cast<const TMTPNotificationParamsSessionChange*> ( aParams ) );
       
   169             break;
       
   170 
       
   171         case EMTPStorageAdded:
       
   172             break;
       
   173 
       
   174         case EMTPStorageRemoved:
       
   175             break;
       
   176 
       
   177         case EMTPRenameObject:
       
   178             PRINT( _L( "MM MTP <> CAbstractMediaMtpDataProvider::ProcessNotificationL EMTPRenameObject event recvd" ) );
       
   179             RenameObjectL( *reinterpret_cast<const TMTPNotificationParamsHandle*> ( aParams ) );
       
   180             break;
       
   181 
       
   182         default:
       
   183             PRINT( _L( "MM MTP <> CAbstractMediaMtpDataProvider::ProcessNotificationL Ignore all other notifications" ) );
       
   184             // Ignore all other notifications.
       
   185             break;
       
   186         }
       
   187     }
       
   188 
       
   189 // -----------------------------------------------------------------------------
       
   190 // CAbstractMediaMtpDataProvider::ProcessRequestPhaseL
       
   191 // Process the request from initiator
       
   192 // -----------------------------------------------------------------------------
       
   193 //
       
   194 void CAbstractMediaMtpDataProvider::ProcessRequestPhaseL( TMTPTransactionPhase aPhase,
       
   195     const TMTPTypeRequest& aRequest,
       
   196     MMTPConnection& aConnection )
       
   197     {
       
   198     TInt index = LocateRequestProcessorL( aRequest, aConnection );
       
   199 
       
   200     __ASSERT_DEBUG( index != KErrNotFound, Panic( EMmMTPDpNoMatchingProcessor ) );
       
   201 
       
   202     MMmRequestProcessor* processor = iActiveProcessors[index];
       
   203     iActiveProcessor = index;
       
   204     // iActiveProcessorRemoved = EFalse;
       
   205     TBool result = processor->HandleRequestL( aRequest, aPhase );
       
   206     if( !iIsSessionOpen )
       
   207         {
       
   208         processor->Release();
       
   209         }
       
   210     // iActiveProcessorRemoved will be set to ETrue in the above function
       
   211     // HandleRequestL(),such as SessionClose()
       
   212     // else if ( iActiveProcessorRemoved )
       
   213     //     {
       
   214     //     processor->Release(); // destroy the processor
       
   215     //     }
       
   216     else if ( result ) // destroy the processor
       
   217         {
       
   218         processor->Release();
       
   219         iActiveProcessors.Remove( index );
       
   220         }
       
   221     iActiveProcessor = -1;
       
   222     }
       
   223 
       
   224 // -----------------------------------------------------------------------------
       
   225 // CAbstractMediaMtpDataProvider::SessionClosedL
       
   226 // Notify the data provider that the session has been closed
       
   227 // -----------------------------------------------------------------------------
       
   228 //
       
   229 void CAbstractMediaMtpDataProvider::SessionClosedL( const TMTPNotificationParamsSessionChange& aSession )
       
   230     {
       
   231     iIsSessionOpen = EFalse;
       
   232     TInt count = iActiveProcessors.Count();
       
   233     PRINT1( _L( "MM MTP => CAbstractMediaMtpDataProvider::SessionClosedL, total processor count = %d" ), count );
       
   234     for( TInt i = 0; i < count; i++ )
       
   235         {
       
   236         MMmRequestProcessor* processor = iActiveProcessors[i];
       
   237 
       
   238         // replaced for the Request() is invalid sometimes
       
   239         // TUint32 sessionId( processor->Request().Uint32( TMTPTypeRequest::ERequestSessionID ) );
       
   240         TUint32 sessionId = processor->SessionId();
       
   241 
       
   242         if ( ( sessionId == aSession.iMTPId )
       
   243                 && ( processor->Connection().ConnectionId()
       
   244                 == aSession.iConnection.ConnectionId() ) )
       
   245             {
       
   246             processor->UsbDisconnect(); // Rollback
       
   247 
       
   248             iActiveProcessors.Remove( i );
       
   249             // if ( i == iActiveProcessor )
       
   250             //     {
       
   251             //     iActiveProcessorRemoved = ETrue;
       
   252             //     }
       
   253             //     else
       
   254                 {
       
   255                 processor->Release();
       
   256                 }
       
   257             }
       
   258         }
       
   259 
       
   260     // TODO: Compare to Media Dp, missing enumerator's SessionClose
       
   261     CMmMtpDpAccessSingleton::CloseSessionL();
       
   262     }
       
   263 
       
   264 // -----------------------------------------------------------------------------
       
   265 // CAbstractMediaMtpDataProvider::SessionOpenedL
       
   266 // Open Session operation
       
   267 // -----------------------------------------------------------------------------
       
   268 //
       
   269 void CAbstractMediaMtpDataProvider::SessionOpenedL( const TMTPNotificationParamsSessionChange& /*aSession*/ )
       
   270     {
       
   271     CMmMtpDpAccessSingleton::OpenSessionL();
       
   272     iIsSessionOpen = ETrue;
       
   273     }
       
   274 
       
   275 // -----------------------------------------------------------------------------
       
   276 // CAbstractMediaMtpDataProvider::RenameObjectL
       
   277 // Process the changed folder
       
   278 // -----------------------------------------------------------------------------
       
   279 //
       
   280 void CAbstractMediaMtpDataProvider::RenameObjectL( const TMTPNotificationParamsHandle& aObject )
       
   281     {
       
   282     PRINT( _L( "MM MTP => CAbstractMediaMtpDataProvider::RenameObjectL" ) );
       
   283 
       
   284     if ( !iRenameObject )
       
   285         {
       
   286         iRenameObject = CAbstractMediaMtpDataProviderRenameObject::NewL( Framework(),
       
   287             GetWrapperL() );
       
   288         }
       
   289 
       
   290     iRenameObject->StartL( aObject.iHandleId, aObject.iFileName );
       
   291 
       
   292     PRINT( _L( "MM MTP <= CAbstractMediaMtpDataProvider::RenameObjectL" ) );
       
   293     }
       
   294 
       
   295 // -----------------------------------------------------------------------------
       
   296 // CAbstractMediaMtpDataProvider::StartObjectEnumerationL
       
   297 // Start object enumeration
       
   298 // -----------------------------------------------------------------------------
       
   299 //
       
   300 void CAbstractMediaMtpDataProvider::StartObjectEnumerationL( TUint32 aStorageId )
       
   301     {
       
   302     iPendingEnumerations.AppendL( aStorageId );
       
   303 
       
   304     if ( iPendingEnumerations.Count() > 0 )
       
   305         {
       
   306         iAbstractMediaEnumerator->StartL( iPendingEnumerations[KActiveEnumeration] );
       
   307         }
       
   308     }
       
   309 
       
   310 // -----------------------------------------------------------------------------
       
   311 // CAbstractMediaMtpDataProvider::StartStorageEnumerationL
       
   312 // Start Storage enumeration
       
   313 // -----------------------------------------------------------------------------
       
   314 //
       
   315 void CAbstractMediaMtpDataProvider::StartStorageEnumerationL()
       
   316     {
       
   317     Framework().StorageEnumerationCompleteL();
       
   318     }
       
   319 
       
   320 // -----------------------------------------------------------------------------
       
   321 // CAbstractMediaMtpDataProvider::Supported
       
   322 // Defines the supported operations and formats of the data provider
       
   323 // -----------------------------------------------------------------------------
       
   324 //
       
   325 void CAbstractMediaMtpDataProvider::Supported( TMTPSupportCategory aCategory,
       
   326     RArray<TUint>& aArray ) const
       
   327     {
       
   328     switch ( aCategory )
       
   329         {
       
   330         case EEvents:
       
   331             break;
       
   332 
       
   333         case EObjectCaptureFormats:
       
   334         case EObjectPlaybackFormats:
       
   335             {
       
   336             TInt count = sizeof( KAbstractMediaMtpDataProviderSupportedFormats ) / sizeof( TUint16 );
       
   337             for ( TInt i = 0; i < count; i++ )
       
   338                 {
       
   339                 aArray.Append( KAbstractMediaMtpDataProviderSupportedFormats[i] );
       
   340                 }
       
   341             }
       
   342             break;
       
   343 
       
   344         case EOperations:
       
   345             {
       
   346             TInt count = sizeof( KAbstractMediaMtpDataProviderSupportedOperations ) / sizeof( TUint16 );
       
   347 
       
   348             for ( TInt i = 0; i < count; i++ )
       
   349                 {
       
   350                 aArray.Append( KAbstractMediaMtpDataProviderSupportedOperations[i] );
       
   351                 }
       
   352             }
       
   353             break;
       
   354 
       
   355         case EObjectProperties:
       
   356             {
       
   357             TInt count = iSupportedProperties.Count();
       
   358 
       
   359             for ( TInt i = 0; i < count; i++ )
       
   360                 {
       
   361                 aArray.Append( iSupportedProperties[i] );
       
   362                 }
       
   363             PRINT1( _L( "MM MTP <> CAbstractMediaMtpDataProvider::Supported properties count = %d" ), aArray.Count() );
       
   364             }
       
   365             break;
       
   366 
       
   367         case EStorageSystemTypes:
       
   368             {
       
   369             aArray.Append( CMTPStorageMetaData::ESystemTypeDefaultFileSystem );
       
   370             }
       
   371             break;
       
   372 
       
   373         default:
       
   374             // Unrecognised category, leave aArray unmodified.
       
   375             break;
       
   376         }
       
   377     }
       
   378 
       
   379 // -----------------------------------------------------------------------------
       
   380 // CAbstractMediaMtpDataProvider::SupportedL
       
   381 // Defines the supported operations and formats of the data provider
       
   382 // -----------------------------------------------------------------------------
       
   383 //
       
   384 void CAbstractMediaMtpDataProvider::SupportedL( TMTPSupportCategory aCategory,
       
   385     CDesCArray& aStrings ) const
       
   386     {
       
   387     if( aCategory == EFormatExtensionSets )
       
   388         {
       
   389         //EMTPFormatCodeM3U,
       
   390         aStrings.AppendL(KFormatExtensionM3U);
       
   391         aStrings.AppendL(KFormatExtensionPLA);
       
   392         aStrings.AppendL(KFormatExtensionVIR);
       
   393         }
       
   394     }
       
   395 
       
   396 TAny* CAbstractMediaMtpDataProvider::GetExtendedInterface( TUid /*aInterfaceUid*/ )
       
   397     {
       
   398     return NULL;
       
   399     }
       
   400 
       
   401 // -----------------------------------------------------------------------------
       
   402 // CAbstractMediaMtpDataProvider::NotifyEnumerationCompleteL
       
   403 // enumeration completed
       
   404 // -----------------------------------------------------------------------------
       
   405 //
       
   406 void CAbstractMediaMtpDataProvider::NotifyEnumerationCompleteL( TUint32 /*aStorageId*/,
       
   407     TInt /*aError*/ )
       
   408     {
       
   409     Framework().ObjectEnumerationCompleteL( iPendingEnumerations[KActiveEnumeration] );
       
   410     iPendingEnumerations.Remove( KActiveEnumeration );
       
   411     if ( iPendingEnumerations.Count() )
       
   412         {
       
   413         iAbstractMediaEnumerator->StartL( iPendingEnumerations[KActiveEnumeration] );
       
   414         }
       
   415     }
       
   416 
       
   417 // -----------------------------------------------------------------------------
       
   418 // CAbstractMediaMtpDataProvider::LocateRequestProcessorL
       
   419 // Find or create a request processor that can process the request
       
   420 // -----------------------------------------------------------------------------
       
   421 //
       
   422 TInt CAbstractMediaMtpDataProvider::LocateRequestProcessorL( const TMTPTypeRequest& aRequest,
       
   423     MMTPConnection& aConnection )
       
   424     {
       
   425     TInt index = KErrNotFound;
       
   426     TInt count = iActiveProcessors.Count();
       
   427     for ( TInt i = 0; i < count; i++ )
       
   428         {
       
   429         if ( iActiveProcessors[i]->Match( aRequest, aConnection ) )
       
   430             {
       
   431             index = i;
       
   432             break;
       
   433             }
       
   434         }
       
   435     if ( index == KErrNotFound )
       
   436         {
       
   437         MMmRequestProcessor* processor =
       
   438             AbstractMediaMtpDataProviderProcessor::CreateL( Framework(),
       
   439                 aRequest,
       
   440                 aConnection,
       
   441                 *this );
       
   442 
       
   443         CleanupReleasePushL( *processor );
       
   444         iActiveProcessors.AppendL( processor );
       
   445         CleanupStack::Pop( processor );
       
   446         index = count;
       
   447         }
       
   448 
       
   449     return index;
       
   450     }
       
   451 
       
   452 // -----------------------------------------------------------------------------
       
   453 // CAbstractMediaMtpDataProvider::LocateRequestProcessorL
       
   454 // Find or create a request processor that can process the event
       
   455 // -----------------------------------------------------------------------------
       
   456 //
       
   457 TInt CAbstractMediaMtpDataProvider::LocateRequestProcessorL( const TMTPTypeEvent& aEvent,
       
   458     MMTPConnection& aConnection )
       
   459     {
       
   460     TInt index = KErrNotFound;
       
   461     TInt count = iActiveProcessors.Count();
       
   462     for ( TInt i = 0; i < count; i++ )
       
   463         {
       
   464         if ( iActiveProcessors[i]->Match( aEvent, aConnection ) )
       
   465             {
       
   466             index = i;
       
   467             break;
       
   468             }
       
   469         }
       
   470     return index;
       
   471     }
       
   472 
       
   473 // -----------------------------------------------------------------------------
       
   474 // CAbstractMediaMtpDataProvider::GetWrapper
       
   475 // return the reference of CMmMtpDpMetadataAccessWrapper to enumerator
       
   476 // -----------------------------------------------------------------------------
       
   477 //
       
   478 CMmMtpDpMetadataAccessWrapper& CAbstractMediaMtpDataProvider::GetWrapperL()
       
   479     {
       
   480     return CMmMtpDpAccessSingleton::GetAccessWrapperL();
       
   481     }
       
   482 
       
   483 // ---------------------------------------------------------------------------
       
   484 // CAbstractMediaMtpDataProvider::GetSupportedFormat
       
   485 //
       
   486 // ---------------------------------------------------------------------------
       
   487 //
       
   488 const RArray<TUint>* CAbstractMediaMtpDataProvider::GetSupportedFormat() const
       
   489     {
       
   490     return &iSupportedFormat;
       
   491     }
       
   492 
       
   493 void CAbstractMediaMtpDataProvider::GetSupportedFormatL()
       
   494     {
       
   495     iSupportedFormat.Reset();
       
   496 
       
   497     TInt count = sizeof ( KAbstractMediaMtpDataProviderSupportedFormats ) / sizeof( TUint16 );
       
   498     for ( TInt i = 0; i < count; i++ )
       
   499         {
       
   500         InsertL( iSupportedFormat, KAbstractMediaMtpDataProviderSupportedFormats[i] );
       
   501         }
       
   502     }
       
   503 
       
   504 const RArray<TUint>* CAbstractMediaMtpDataProvider::GetSupportedPropertiesL( TUint32 aFormatCode ) const
       
   505     {
       
   506     return &iSupportedProperties;
       
   507     }
       
   508 
       
   509 // ---------------------------------------------------------------------------
       
   510 // CAbstractMediaMtpDataProvider::GetSupportedPropertiesL
       
   511 //
       
   512 // ---------------------------------------------------------------------------
       
   513 //
       
   514 void CAbstractMediaMtpDataProvider::GetSupportedPropertiesL()
       
   515     {
       
   516     iSupportedProperties.Reset();
       
   517 
       
   518     TInt count = 0, i = 0;
       
   519     count = sizeof( KMmMtpDpSupportedPropMandatoryAll ) / sizeof( TUint16 );
       
   520     for ( i = 0; i < count; i++ )
       
   521         {
       
   522         InsertL( iSupportedProperties, KMmMtpDpSupportedPropMandatoryAll[i] );
       
   523         }
       
   524 
       
   525     count = sizeof( KMmMtpDpSupportedPropAdditionalAll ) / sizeof( TUint16 );
       
   526     for ( i = 0; i < count; i++ )
       
   527         {
       
   528         InsertL( iSupportedProperties, KMmMtpDpSupportedPropAdditionalAll[i] );
       
   529         }
       
   530     }
       
   531 
       
   532 // ---------------------------------------------------------------------------
       
   533 // CAbstractMediaMtpDataProvider::GetAllSupportedProperties
       
   534 //
       
   535 // ---------------------------------------------------------------------------
       
   536 //
       
   537 const RArray<TUint>* CAbstractMediaMtpDataProvider::GetAllSupportedProperties() const
       
   538     {
       
   539     return &iSupportedProperties;
       
   540     }
       
   541 
       
   542 // ---------------------------------------------------------------------------
       
   543 // CMediaMtpDataProvider::GetDefaultStorageIdL
       
   544 //
       
   545 // ---------------------------------------------------------------------------
       
   546 //
       
   547 TUint32 CAbstractMediaMtpDataProvider::GetDefaultStorageIdL() const
       
   548     {
       
   549     TInt driveNum = -1;
       
   550     TInt err = DriveInfo::GetDefaultDrive( DriveInfo::EDefaultMassStorage, driveNum );
       
   551     PRINT2( _L( "MM MTP <> GetDefaultDrive, driveNum = %d, err = %d" ), driveNum, err );
       
   552 
       
   553     TDriveInfo driveInfo;
       
   554     User::LeaveIfError( Framework().Fs().Drive( driveInfo, driveNum ) );
       
   555     if( driveInfo.iType == EMediaNotPresent || driveInfo.iType == EMediaUnknown )
       
   556         {
       
   557         err = DriveInfo::GetDefaultDrive( DriveInfo::EDefaultPhoneMemory, driveNum );
       
   558         PRINT( _L( "MM MTP <> Memory card doesn't exist, set PhoneMemory to default" ) );
       
   559         }
       
   560 
       
   561     return Framework().StorageMgr().FrameworkStorageId( TDriveNumber( driveNum ) );
       
   562     }
       
   563 
       
   564 // ---------------------------------------------------------------------------
       
   565 // CAbstractMediaMtpDataProvider::Insert
       
   566 //
       
   567 // ---------------------------------------------------------------------------
       
   568 //
       
   569 void CAbstractMediaMtpDataProvider::InsertL( RArray<TUint>& aArray, const TUint aProperCode ) const
       
   570     {
       
   571     TInt err = KErrNone;
       
   572     err = aArray.Find( aProperCode );
       
   573     if ( err == KErrNotFound )
       
   574         err = aArray.Append( aProperCode );
       
   575 
       
   576     User::LeaveIfError( err );
       
   577     }
       
   578 
       
   579 // end of file