mmappcomponents/mmmtpdataprovider/mmmtpdprequestprocessor/src/crenameobject.cpp
branchRCL_3
changeset 9 bee149131e4b
parent 0 a2952bb97e68
child 17 780c925249c1
equal deleted inserted replaced
4:d45095c2f4f3 9:bee149131e4b
    32 // CRenameObject::NewL
    32 // CRenameObject::NewL
    33 // Two phase constructor
    33 // Two phase constructor
    34 // -----------------------------------------------------------------------------
    34 // -----------------------------------------------------------------------------
    35 //
    35 //
    36 EXPORT_C CRenameObject* CRenameObject::NewL( MMTPDataProviderFramework& aFramework,
    36 EXPORT_C CRenameObject* CRenameObject::NewL( MMTPDataProviderFramework& aFramework,
    37         CMmMtpDpMetadataAccessWrapper& aWrapper )
    37     CMmMtpDpMetadataAccessWrapper& aWrapper )
    38     {
    38     {
    39     PRINT( _L( "MM MTP => CRenameObject::NewL" ) );
    39     PRINT( _L( "MM MTP => CRenameObject::NewL" ) );
    40 
    40 
    41     CRenameObject* self = new ( ELeave ) CRenameObject( aFramework, aWrapper );
    41     CRenameObject* self = new ( ELeave ) CRenameObject( aFramework, aWrapper );
    42     CleanupStack::PushL( self );
    42     CleanupStack::PushL( self );
    57     CActive( EPriorityStandard ),
    57     CActive( EPriorityStandard ),
    58     iFramework( aFramework ),
    58     iFramework( aFramework ),
    59     iObjectHandles( KMmMtpRArrayGranularity ),
    59     iObjectHandles( KMmMtpRArrayGranularity ),
    60     iWrapper ( aWrapper )
    60     iWrapper ( aWrapper )
    61     {
    61     {
       
    62     // Do nothing
    62     }
    63     }
    63 
    64 
    64 // -----------------------------------------------------------------------------
    65 // -----------------------------------------------------------------------------
    65 // CRenameObject::~CRenameObject
    66 // CRenameObject::~CRenameObject
    66 // destructor
    67 // destructor
   119 // Cancel the rename object process
   120 // Cancel the rename object process
   120 // -----------------------------------------------------------------------------
   121 // -----------------------------------------------------------------------------
   121 //
   122 //
   122 EXPORT_C void CRenameObject::DoCancel()
   123 EXPORT_C void CRenameObject::DoCancel()
   123     {
   124     {
   124 
   125     // Do nothing
   125     }
   126     }
   126 
   127 
   127 // -----------------------------------------------------------------------------
   128 // -----------------------------------------------------------------------------
   128 // CRenameObject::RunL
   129 // CRenameObject::RunL
   129 //
   130 //
   218     RMTPObjectMgrQueryContext context;
   219     RMTPObjectMgrQueryContext context;
   219     RArray<TUint> handles;
   220     RArray<TUint> handles;
   220     CleanupClosePushL( context ); // + context
   221     CleanupClosePushL( context ); // + context
   221     CleanupClosePushL( handles ); // + handles
   222     CleanupClosePushL( handles ); // + handles
   222 
   223 
   223     TMTPObjectMgrQueryParams params( KMTPStorageAll, KMTPFormatsAll,
   224     TMTPObjectMgrQueryParams params( KMTPStorageAll, KMTPFormatsAll, aParentHandle );
   224             aParentHandle );
       
   225     do
   225     do
   226         {
   226         {
   227         iFramework.ObjectMgr().GetObjectHandlesL( params, context, handles );
   227         iFramework.ObjectMgr().GetObjectHandlesL( params, context, handles );
   228 
   228 
   229         TInt numberOfObjects = handles.Count();
   229         TInt numberOfObjects = handles.Count();
   230         for ( TInt i = 0; i < numberOfObjects; i++ )
   230         for ( TInt i = 0; i < numberOfObjects; i++ )
   231             {
   231             {
   232             if ( iFramework.ObjectMgr().ObjectOwnerId( handles[i] ) == iFramework.DataProviderId() )
   232             if ( iFramework.ObjectMgr().ObjectOwnerId( handles[i] ) == iFramework.DataProviderId() )
   233                 {
   233                 {
   234                 iObjectHandles.AppendL( handles[i] );
   234                 iObjectHandles.AppendL( handles[i] );
   235                 continue;
   235                 // NOTE: Fw changed the mechanism of notification, no need to iterate
   236                 }
   236 
   237 
       
   238             // Folder
       
   239             // TODO: need to modify, should not know device dp id
       
   240             if ( iFramework.ObjectMgr().ObjectOwnerId( handles[i] ) == 0 ) // We know that the device dp id is always 0, otherwise the whole MTP won't work.
       
   241                 {
       
   242                 GenerateObjectHandleListL( handles[i] );
       
   243                 }
   237                 }
   244             }
   238             }
   245         }
   239         }
   246     while ( !context.QueryComplete() );
   240     while ( !context.QueryComplete() );
   247 
   241 
   258 //
   252 //
   259 void CRenameObject::GetParentSuidL( TUint32 aHandle,
   253 void CRenameObject::GetParentSuidL( TUint32 aHandle,
   260     const TDesC& aFolderName )
   254     const TDesC& aFolderName )
   261     {
   255     {
   262     PRINT2( _L( "MM MTP => CRenameObject::GetParentSuidL aHandle(0x%x), aFolderName(%S)" ),
   256     PRINT2( _L( "MM MTP => CRenameObject::GetParentSuidL aHandle(0x%x), aFolderName(%S)" ),
   263         aHandle, &aFolderName );
   257         aHandle,
       
   258         &aFolderName );
   264     CMTPObjectMetaData* objectInfo( CMTPObjectMetaData::NewLC() ); // + objectInfo
   259     CMTPObjectMetaData* objectInfo( CMTPObjectMetaData::NewLC() ); // + objectInfo
   265     // get the old folder suid
   260     // get the old folder suid
   266     if ( iFramework .ObjectMgr().ObjectL( aHandle, *objectInfo ) )
   261     if ( iFramework .ObjectMgr().ObjectL( aHandle, *objectInfo ) )
   267         {
   262         {
   268         iNewFolderName.Zero();
   263         iNewFolderName.Zero();
   269         iNewFolderName = objectInfo->DesC( CMTPObjectMetaData::ESuid );
   264         iNewFolderName = objectInfo->DesC( CMTPObjectMetaData::ESuid );
   270         PRINT1( _L( "MM MTP <> CRenameObject::GetParentSuidL new folder full file name(%S)" ), &iNewFolderName );
   265         PRINT1( _L( "MM MTP <> CRenameObject::GetParentSuidL new folder full file name(%S)" ), &iNewFolderName );
   271         const TInt length = iNewFolderName.Length();
       
   272 
       
   273         TParsePtrC parentSuid( iNewFolderName.Left( length - 1 ) );
       
   274 
   266 
   275         iOldFolderFullName.Zero();
   267         iOldFolderFullName.Zero();
   276         iOldFolderFullName.Append( parentSuid.DriveAndPath() );
       
   277         iOldFolderFullName.Append( aFolderName ); // just name not suid
   268         iOldFolderFullName.Append( aFolderName ); // just name not suid
   278         _LIT( KBackSlash, "\\" );
   269 
   279         iOldFolderFullName.Append( KBackSlash );
       
   280         PRINT1( _L( "MM MTP <> CRenameObject::GetParentSuidL = %S" ), &iOldFolderFullName );
   270         PRINT1( _L( "MM MTP <> CRenameObject::GetParentSuidL = %S" ), &iOldFolderFullName );
   281         }
   271         }
   282     else
   272     else
   283         User::Leave( KErrCorrupt );
   273         User::Leave( KErrCorrupt );
   284 
   274