mmappcomponents/mmmtpdataprovider/mmmtpdprequestprocessor/src/csetobjectreferences.cpp
branchRCL_3
changeset 17 780c925249c1
parent 14 05b0d2323768
child 23 4740b34b83ce
equal deleted inserted replaced
15:d240f0a77280 17:780c925249c1
    16 */
    16 */
    17 
    17 
    18 
    18 
    19 #include <mtp/cmtptypearray.h>
    19 #include <mtp/cmtptypearray.h>
    20 #include <mtp/mmtpobjectmgr.h>
    20 #include <mtp/mmtpobjectmgr.h>
    21 #include <mtp/mmtpdataproviderframework.h>
       
    22 #include <mtp/mmtpreferencemgr.h>
    21 #include <mtp/mmtpreferencemgr.h>
    23 
    22 
    24 #include "csetobjectreferences.h"
    23 #include "csetobjectreferences.h"
    25 #include "tmmmtpdppanic.h"
    24 #include "tmmmtpdppanic.h"
    26 #include "mmmtpdplogger.h"
    25 #include "mmmtpdplogger.h"
    27 #include "cmmmtpdpmetadataaccesswrapper.h"
    26 #include "cmmmtpdpmetadataaccesswrapper.h"
    28 #include "mmmtpdputility.h"
    27 #include "mmmtpdputility.h"
    29 #include "mmmtpdpconfig.h"
    28 #include "mmmtpdpconfig.h"
       
    29 
       
    30 const TInt KMmMtpRefArrayGranularity = 3;
    30 
    31 
    31 // -----------------------------------------------------------------------------
    32 // -----------------------------------------------------------------------------
    32 // Verification data for the SetReferences request
    33 // Verification data for the SetReferences request
    33 // -----------------------------------------------------------------------------
    34 // -----------------------------------------------------------------------------
    34 //
    35 //
    86 // -----------------------------------------------------------------------------
    87 // -----------------------------------------------------------------------------
    87 // CSetObjectReferences::CSetObjectReferences
    88 // CSetObjectReferences::CSetObjectReferences
    88 // Standard c++ constructor
    89 // Standard c++ constructor
    89 // -----------------------------------------------------------------------------
    90 // -----------------------------------------------------------------------------
    90 //
    91 //
    91 EXPORT_C CSetObjectReferences::CSetObjectReferences(
    92 EXPORT_C CSetObjectReferences::CSetObjectReferences( MMTPDataProviderFramework& aFramework,
    92     MMTPDataProviderFramework& aFramework,
       
    93     MMTPConnection& aConnection,
    93     MMTPConnection& aConnection,
    94     MMmMtpDpConfig& aDpConfig ) :
    94     MMmMtpDpConfig& aDpConfig ) :
    95     CRequestProcessor(
    95         CRequestProcessor( aFramework,
    96         aFramework,
    96             aConnection,
    97         aConnection,
    97             sizeof( KMTPSetObjectReferencesPolicy ) / sizeof( TMTPRequestElementInfo ),
    98         sizeof( KMTPSetObjectReferencesPolicy )/sizeof( TMTPRequestElementInfo ),
    98             KMTPSetObjectReferencesPolicy ),
    99         KMTPSetObjectReferencesPolicy ),
    99         iDpConfig( aDpConfig )
   100     iDpConfig( aDpConfig )
       
   101     {
   100     {
   102     PRINT( _L( "Operation: SetObjectReferences(0x9811)" ) );
   101     PRINT( _L( "Operation: SetObjectReferences(0x9811)" ) );
   103     }
   102     }
   104 
   103 
   105 // -----------------------------------------------------------------------------
   104 // -----------------------------------------------------------------------------
   106 // CSetObjectReferences::DoSetObjectReferencesL
   105 // CSetObjectReferences::DoSetObjectReferencesL
   107 // set references to DB
   106 // set references to DB
   108 // -----------------------------------------------------------------------------
   107 // -----------------------------------------------------------------------------
   109 //
   108 //
   110 EXPORT_C void CSetObjectReferences::DoSetObjectReferencesL( CMmMtpDpMetadataAccessWrapper& /*aWrapper*/,
   109 EXPORT_C void CSetObjectReferences::DoSetObjectReferencesL( const CMTPObjectMetaData& aObject )
   111     TUint16 /*aObjectFormat*/,
   110     {
   112     const TDesC& /*aSrcFileName*/,
   111     TUint formatCode = aObject.Uint( CMTPObjectMetaData::EFormatCode );
   113     CDesCArray& /*aRefFileArray*/ )
   112     TBool hasReference = MmMtpDpUtility::HasReference( formatCode );
   114     {
   113 
   115     // do nothing, do special thing by inheriting
   114     if ( hasReference )
       
   115         {
       
   116         iDpConfig.GetWrapperL().SetReferenceL( aObject, *iReferenceSuids );
       
   117         }
   116     }
   118     }
   117 
   119 
   118 // -----------------------------------------------------------------------------
   120 // -----------------------------------------------------------------------------
   119 // CSetObjectReferences::ServiceL
   121 // CSetObjectReferences::ServiceL
   120 // SetReferences request handler
   122 // SetReferences request handler
   140     {
   142     {
   141     PRINT( _L("MM MTP => CSetObjectReferences::DoHandleResponsePhaseL" ) );
   143     PRINT( _L("MM MTP => CSetObjectReferences::DoHandleResponsePhaseL" ) );
   142 
   144 
   143     delete iReferenceSuids;
   145     delete iReferenceSuids;
   144     iReferenceSuids = NULL;
   146     iReferenceSuids = NULL;
   145     iReferenceSuids = new ( ELeave ) CDesCArrayFlat( 3 );
   147     iReferenceSuids = new ( ELeave ) CDesCArrayFlat( KMmMtpRefArrayGranularity );
   146 
   148 
   147     if ( !VerifyReferenceHandlesL() )
   149     if ( !VerifyReferenceHandlesL() )
   148         {
   150         {
   149         SendResponseL( EMTPRespCodeInvalidObjectReference );
   151         SendResponseL( EMTPRespCodeInvalidObjectReference );
   150         }
   152         }
   157             *iReferences );
   159             *iReferences );
   158 
   160 
   159         CMTPObjectMetaData* object = CMTPObjectMetaData::NewLC(); // + object
   161         CMTPObjectMetaData* object = CMTPObjectMetaData::NewLC(); // + object
   160         iFramework.ObjectMgr().ObjectL( objectHandle, *object );
   162         iFramework.ObjectMgr().ObjectL( objectHandle, *object );
   161         PRINT1( _L( "MM MTP <> object file name is %S" ), &(object->DesC( CMTPObjectMetaData::ESuid ) ) );
   163         PRINT1( _L( "MM MTP <> object file name is %S" ), &(object->DesC( CMTPObjectMetaData::ESuid ) ) );
   162         DoSetObjectReferencesL( iDpConfig.GetWrapperL(),
   164         DoSetObjectReferencesL( *object );
   163             object->Uint( CMTPObjectMetaData::EFormatCode ),
       
   164             object->DesC( CMTPObjectMetaData::ESuid ),
       
   165             *iReferenceSuids );
       
   166 
   165 
   167         CleanupStack::PopAndDestroy( object ); // - object
   166         CleanupStack::PopAndDestroy( object ); // - object
   168 
   167 
   169         SendResponseL( EMTPRespCodeOK );
   168         SendResponseL( EMTPRespCodeOK );
   170         }
   169         }
   194         if ( !objectMgr.ObjectL( handle, *object ) )
   193         if ( !objectMgr.ObjectL( handle, *object ) )
   195             {
   194             {
   196             result = EFalse;
   195             result = EFalse;
   197             break;
   196             break;
   198             }
   197             }
   199 
   198         // Only audio in playlist is supported
   200         iReferenceSuids->AppendL( object->DesC( CMTPObjectMetaData::ESuid ) );
   199         if ( iDpConfig.GetWrapperL().Category( *object ) == EMPXSong )
       
   200             iReferenceSuids->AppendL( object->DesC( CMTPObjectMetaData::ESuid ) );
   201         }
   201         }
   202     CleanupStack::PopAndDestroy( object ); // - object
   202     CleanupStack::PopAndDestroy( object ); // - object
   203     PRINT( _L( "MM MTP <= CSetObjectReferences::VerifyReferenceHandlesL" ) );
   203     PRINT( _L( "MM MTP <= CSetObjectReferences::VerifyReferenceHandlesL" ) );
   204     return result;
   204     return result;
   205     }
   205     }