mtpfws/mtpfw/dataproviders/proxydp/src/cmtpmoveobject.cpp
changeset 47 63cf70d3ecd8
parent 33 883e91c086aa
equal deleted inserted replaced
44:a5deb6b96675 47:63cf70d3ecd8
    24 #include "cmtpparserrouter.h"
    24 #include "cmtpparserrouter.h"
    25 #include "cmtpstoragemgr.h"
    25 #include "cmtpstoragemgr.h"
    26 #include "mtpproxydppanic.h"
    26 #include "mtpproxydppanic.h"
    27 #include "cmtpobjectbrowser.h"
    27 #include "cmtpobjectbrowser.h"
    28 #include "mtpdppanic.h"
    28 #include "mtpdppanic.h"
    29 
    29 #include "mtpdebug.h"
    30 __FLOG_STMT(_LIT8(KComponent,"PrxyMoveObj");)
    30 #include "OstTraceDefinitions.h"
       
    31 #ifdef OST_TRACE_COMPILER_IN_USE
       
    32 #include "cmtpmoveobjectTraces.h"
       
    33 #endif
       
    34 
       
    35 
    31 const TUint KInvalidDpId = 0xFF;
    36 const TUint KInvalidDpId = 0xFF;
    32 /**
    37 /**
    33 Verification data for the MoveObject request
    38 Verification data for the MoveObject request
    34 */    
    39 */    
    35 const TMTPRequestElementInfo KMTPMoveObjectPolicy[] = 
    40 const TMTPRequestElementInfo KMTPMoveObjectPolicy[] = 
    57 /**
    62 /**
    58 Destructor
    63 Destructor
    59 */    
    64 */    
    60 CMTPMoveObject::~CMTPMoveObject()
    65 CMTPMoveObject::~CMTPMoveObject()
    61     {
    66     {
       
    67     OstTraceFunctionEntry0( CMTPMOVEOBJECT_CMTPMOVEOBJECT_ENTRY );
    62     iSingletons.Close();
    68     iSingletons.Close();
    63     iNewParent.Close();
    69     iNewParent.Close();
    64 	delete iPathToCreate;
    70 	delete iPathToCreate;
    65 	
    71 	
    66     delete iFileMan;
    72     delete iFileMan;
    69     iNewHandleParentStack.Close();
    75     iNewHandleParentStack.Close();
    70     iHandleDepths.Close();
    76     iHandleDepths.Close();
    71     iHandles.Close();
    77     iHandles.Close();
    72     delete iObjBrowser;
    78     delete iObjBrowser;
    73     iTargetDps.Close();
    79     iTargetDps.Close();
    74     __FLOG(_L8("+/-Dtor"));
    80     OstTraceFunctionExit0( CMTPMOVEOBJECT_CMTPMOVEOBJECT_EXIT );
    75     __FLOG_CLOSE;
       
    76     }
    81     }
    77 
    82 
    78 /**
    83 /**
    79 Constructor
    84 Constructor
    80 */    
    85 */    
    81 CMTPMoveObject::CMTPMoveObject(MMTPDataProviderFramework& aFramework, MMTPConnection& aConnection) :
    86 CMTPMoveObject::CMTPMoveObject(MMTPDataProviderFramework& aFramework, MMTPConnection& aConnection) :
    82     CMTPRequestProcessor(aFramework, aConnection, sizeof(KMTPMoveObjectPolicy)/sizeof(TMTPRequestElementInfo), KMTPMoveObjectPolicy)
    87     CMTPRequestProcessor(aFramework, aConnection, sizeof(KMTPMoveObjectPolicy)/sizeof(TMTPRequestElementInfo), KMTPMoveObjectPolicy)
    83     {
    88     {
    84     __FLOG_OPEN( KMTPSubsystem, KComponent );
       
    85     __FLOG( _L8("+/-Ctor") );
       
    86     }
    89     }
    87     
    90     
    88 /**
    91 /**
    89 Second phase constructor.
    92 Second phase constructor.
    90 */
    93 */
    91 void CMTPMoveObject::ConstructL()
    94 void CMTPMoveObject::ConstructL()
    92     {
    95     {
    93     __FLOG( _L8("+ConstructL") );
    96     OstTraceFunctionEntry0( CMTPMOVEOBJECT_CONSTRUCTL_ENTRY );
    94     iNewParent.CreateL(KMaxFileName);
    97     iNewParent.CreateL(KMaxFileName);
    95     iSingletons.OpenL();
    98     iSingletons.OpenL();
    96     iFolderToRemove.CreateL( KMaxFileName );
    99     iFolderToRemove.CreateL( KMaxFileName );
    97     iOwnerDp = KInvalidDpId;
   100     iOwnerDp = KInvalidDpId;
    98     __FLOG( _L8("-ConstructL") );
   101     OstTraceFunctionExit0( CMTPMOVEOBJECT_CONSTRUCTL_EXIT );
    99     }
   102     }
   100     
   103     
   101 /**
   104 /**
   102 MoveObject request handler
   105 MoveObject request handler
   103 */ 
   106 */ 
   104 void CMTPMoveObject::ServiceL()
   107 void CMTPMoveObject::ServiceL()
   105     {
   108     {
   106     __FLOG( _L8("+ServiceL") );
   109     OstTraceFunctionEntry0( CMTPMOVEOBJECT_SERVICEL_ENTRY );
   107     iTargetDps.Reset();
   110     iTargetDps.Reset();
   108     CMTPParserRouter& router(iSingletons.Router());
   111     CMTPParserRouter& router(iSingletons.Router());
   109     CMTPParserRouter::TRoutingParameters params(Request(), iConnection);
   112     CMTPParserRouter::TRoutingParameters params(Request(), iConnection);
   110     router.ParseOperationRequestL(params);
   113     router.ParseOperationRequestL(params);
   111     router.RouteOperationRequestL(params, iTargetDps);
   114     router.RouteOperationRequestL(params, iTargetDps);
   112     
   115     
   113     BrowseHandlesL();
   116     BrowseHandlesL();
   114     __FLOG( _L8("-ServiceL") );
   117     OstTraceFunctionExit0( CMTPMOVEOBJECT_SERVICEL_EXIT );
   115     }
   118     }
   116 
   119 
   117 void CMTPMoveObject::ProxyReceiveDataL(MMTPType& /*aData*/, const TMTPTypeRequest& /*aRequest*/, MMTPConnection& /*aConnection*/, TRequestStatus& /*aStatus*/)
   120 void CMTPMoveObject::ProxyReceiveDataL(MMTPType& /*aData*/, const TMTPTypeRequest& /*aRequest*/, MMTPConnection& /*aConnection*/, TRequestStatus& /*aStatus*/)
   118     {
   121     {
   119     Panic(EMTPWrongRequestPhase);    
   122     Panic(EMTPWrongRequestPhase);    
   128 void CMTPMoveObject::ProxySendResponseL(const TMTPTypeResponse& aResponse, const TMTPTypeRequest& aRequest, MMTPConnection& aConnection, TRequestStatus& aStatus)
   131 void CMTPMoveObject::ProxySendResponseL(const TMTPTypeResponse& aResponse, const TMTPTypeRequest& aRequest, MMTPConnection& aConnection, TRequestStatus& aStatus)
   129 #else
   132 #else
   130 void CMTPMoveObject::ProxySendResponseL(const TMTPTypeResponse& aResponse, const TMTPTypeRequest& /*aRequest*/, MMTPConnection& /*aConnection*/, TRequestStatus& aStatus)
   133 void CMTPMoveObject::ProxySendResponseL(const TMTPTypeResponse& aResponse, const TMTPTypeRequest& /*aRequest*/, MMTPConnection& /*aConnection*/, TRequestStatus& aStatus)
   131 #endif
   134 #endif
   132     {
   135     {
   133     __FLOG( _L8("+ProxySendResponseL") );
   136     OstTraceFunctionEntry0( CMTPMOVEOBJECT_PROXYSENDRESPONSEL_ENTRY );
   134     __ASSERT_DEBUG(((&iCurrentRequest == &aRequest) && (&iConnection == &aConnection)), Panic(EMTPNotSameRequestProxy));
   137     __ASSERT_DEBUG(((&iCurrentRequest == &aRequest) && (&iConnection == &aConnection)), Panic(EMTPNotSameRequestProxy));
   135     MMTPType::CopyL(aResponse, iResponse);
   138     MMTPType::CopyL(aResponse, iResponse);
   136 	TRequestStatus* status = &aStatus;
   139 	TRequestStatus* status = &aStatus;
   137 	User::RequestComplete(status, KErrNone);
   140 	User::RequestComplete(status, KErrNone);
   138     __FLOG( _L8("-ProxySendResponseL") );
   141 	OstTraceFunctionExit0( CMTPMOVEOBJECT_PROXYSENDRESPONSEL_EXIT );
   139     }
   142     }
   140 
   143 
   141 #ifdef _DEBUG    
   144 #ifdef _DEBUG    
   142 void CMTPMoveObject::ProxyTransactionCompleteL(const TMTPTypeRequest& aRequest, MMTPConnection& aConnection)
   145 void CMTPMoveObject::ProxyTransactionCompleteL(const TMTPTypeRequest& aRequest, MMTPConnection& aConnection)
   143 #else
   146 #else
   144 void CMTPMoveObject::ProxyTransactionCompleteL(const TMTPTypeRequest& /*aRequest*/, MMTPConnection& /*aConnection*/)
   147 void CMTPMoveObject::ProxyTransactionCompleteL(const TMTPTypeRequest& /*aRequest*/, MMTPConnection& /*aConnection*/)
   145 #endif
   148 #endif
   146     {
   149     {
   147     __FLOG( _L8("+ProxyTransactionCompleteL") );
   150     OstTraceFunctionEntry0( CMTPMOVEOBJECT_PROXYTRANSACTIONCOMPLETEL_ENTRY );
   148     __ASSERT_DEBUG(((&iCurrentRequest == &aRequest) && (&iConnection == &aConnection)), Panic(EMTPNotSameRequestProxy));
   151     __ASSERT_DEBUG(((&iCurrentRequest == &aRequest) && (&iConnection == &aConnection)), Panic(EMTPNotSameRequestProxy));
   149     TInt err((iResponse.Uint16(TMTPTypeResponse::EResponseCode) == EMTPRespCodeOK) ? KErrNone : KErrGeneral);    
   152     TInt err((iResponse.Uint16(TMTPTypeResponse::EResponseCode) == EMTPRespCodeOK) ? KErrNone : KErrGeneral);    
   150     if (err == KErrNone)
   153     if (err == KErrNone)
   151         {
   154         {
   152         iCurrentHandle--;
   155         iCurrentHandle--;
   155     else
   158     else
   156         {
   159         {
   157         SendResponseL( iResponse.Uint16( TMTPTypeResponse::EResponseCode ) ); 
   160         SendResponseL( iResponse.Uint16( TMTPTypeResponse::EResponseCode ) ); 
   158         }
   161         }
   159 
   162 
   160     __FLOG( _L8("-ProxyTransactionCompleteL") );
   163     OstTraceFunctionExit0( CMTPMOVEOBJECT_PROXYTRANSACTIONCOMPLETEL_EXIT );
   161     }
   164     }
   162 
   165 
   163 /**
   166 /**
   164 Retrive the parameters of the request
   167 Retrive the parameters of the request
   165 */	
   168 */	
   166 void CMTPMoveObject::GetParametersL()
   169 void CMTPMoveObject::GetParametersL()
   167     {
   170     {
   168     __FLOG( _L8("+GetParametersL") );
   171     OstTraceFunctionEntry0( CMTPMOVEOBJECT_GETPARAMETERSL_ENTRY );
   169     
   172     
   170     TUint32 objectHandle  = iCurrentRequest.Uint32( TMTPTypeRequest::ERequestParameter1 );
   173     TUint32 objectHandle  = iCurrentRequest.Uint32( TMTPTypeRequest::ERequestParameter1 );
   171     TUint32 newParentHandle  = iCurrentRequest.Uint32( TMTPTypeRequest::ERequestParameter3 );
   174     TUint32 newParentHandle  = iCurrentRequest.Uint32( TMTPTypeRequest::ERequestParameter3 );
   172     
   175     
   173     if(newParentHandle == 0)
   176     if(newParentHandle == 0)
   179         iFramework.ObjectMgr().ObjectL( TMTPTypeUint32( newParentHandle ), *iObjInfoCache );
   182         iFramework.ObjectMgr().ObjectL( TMTPTypeUint32( newParentHandle ), *iObjInfoCache );
   180         iNewParent = iObjInfoCache->DesC(CMTPObjectMetaData::ESuid);
   183         iNewParent = iObjInfoCache->DesC(CMTPObjectMetaData::ESuid);
   181         }
   184         }
   182     
   185     
   183     iFramework.ObjectMgr().ObjectL( TMTPTypeUint32( objectHandle ), *iObjInfoCache );
   186     iFramework.ObjectMgr().ObjectL( TMTPTypeUint32( objectHandle ), *iObjInfoCache );
   184     __FLOG( _L8("-GetParametersL") );	
   187     OstTraceFunctionExit0( CMTPMOVEOBJECT_GETPARAMETERSL_EXIT );
   185     }
   188     }
   186 
   189 
   187 /**
   190 /**
   188 Get a default parent object, when the current request does not specify a parent object
   191 Get a default parent object, when the current request does not specify a parent object
   189 */
   192 */
   190 void CMTPMoveObject::GetDefaultParentObjectL( TDes& aObjectName )
   193 void CMTPMoveObject::GetDefaultParentObjectL( TDes& aObjectName )
   191     {
   194     {
   192     __FLOG( _L8("+GetDefaultParentObjectL") );
   195     OstTraceFunctionEntry0( CMTPMOVEOBJECT_GETDEFAULTPARENTOBJECTL_ENTRY );
   193     const CMTPStorageMetaData& storageMetaData( iFramework.StorageMgr().StorageL(iStorageId) );
   196     const CMTPStorageMetaData& storageMetaData( iFramework.StorageMgr().StorageL(iStorageId) );
   194     aObjectName = storageMetaData.DesC(CMTPStorageMetaData::EStorageSuid);
   197     aObjectName = storageMetaData.DesC(CMTPStorageMetaData::EStorageSuid);
   195     __FLOG( _L8("-GetDefaultParentObjectL") );
   198 
   196 
   199     OstTraceFunctionExit0( CMTPMOVEOBJECT_GETDEFAULTPARENTOBJECTL_EXIT );
   197     }
   200     }
   198 
   201 
   199 /**
   202 /**
   200 Check if we can move the file to the new location
   203 Check if we can move the file to the new location
   201 */
   204 */
   202 TMTPResponseCode CMTPMoveObject::CanMoveObjectL(const TDesC& aOldName, const TDesC& aNewName) const
   205 TMTPResponseCode CMTPMoveObject::CanMoveObjectL(const TDesC& aOldName, const TDesC& aNewName) const
   203 	{
   206 	{
   204 	__FLOG(_L8("+CanMoveObjectL"));
   207 	OstTraceFunctionEntry0( CMTPMOVEOBJECT_CANMOVEOBJECTL_ENTRY );
   205 	TMTPResponseCode result = EMTPRespCodeOK;
   208 	TMTPResponseCode result = EMTPRespCodeOK;
   206 
   209 
   207 	TEntry fileEntry;
   210 	TEntry fileEntry;
   208 	User::LeaveIfError(iFramework.Fs().Entry(aOldName, fileEntry));
   211 	LEAVEIFERROR(iFramework.Fs().Entry(aOldName, fileEntry),
       
   212 	        OstTraceExt1( TRACE_ERROR, DUP1_CMTPMOVEOBJECT_CANMOVEOBJECTL, "get entry for %S error!", aOldName));
       
   213 	        
   209 	TInt drive(iFramework.StorageMgr().DriveNumber(iStorageId));
   214 	TInt drive(iFramework.StorageMgr().DriveNumber(iStorageId));
   210 	User::LeaveIfError(drive);
   215 	LEAVEIFERROR(drive,
       
   216 	        OstTrace1( TRACE_ERROR, DUP2_CMTPMOVEOBJECT_CANMOVEOBJECTL, "can't identify drive number for storageId %d", iStorageId ));
   211 	TVolumeInfo volumeInfo;
   217 	TVolumeInfo volumeInfo;
   212 	User::LeaveIfError(iFramework.Fs().Volume(volumeInfo, drive));
   218 	LEAVEIFERROR(iFramework.Fs().Volume(volumeInfo, drive),
       
   219 	        OstTrace1( TRACE_ERROR, DUP3_CMTPMOVEOBJECT_CANMOVEOBJECTL, "can't get volume info for drive %d", drive));
   213 	
   220 	
   214 	if (BaflUtils::FileExists(iFramework.Fs(), aNewName))			
   221 	if (BaflUtils::FileExists(iFramework.Fs(), aNewName))			
   215 		{
   222 		{
   216 		result = EMTPRespCodeInvalidParentObject;
   223 		result = EMTPRespCodeInvalidParentObject;
   217 		}
   224 		}
   218 	__FLOG_VA((_L8("-CanMoveObjectL (Exit with response code 0x%04X)"), result));
   225     OstTrace1( TRACE_NORMAL, CMTPMOVEOBJECT_CANMOVEOBJECTL, "Exit with response code 0x%04X", result ); 	
       
   226 	OstTraceFunctionExit0( CMTPMOVEOBJECT_CANMOVEOBJECTL_EXIT );
       
   227 	
   219 	return result;	
   228 	return result;	
   220 	}
   229 	}
   221 	
   230 	
   222 void CMTPMoveObject::GetSuidFromHandleL(TUint aHandle, TDes& aSuid) const
   231 void CMTPMoveObject::GetSuidFromHandleL(TUint aHandle, TDes& aSuid) const
   223 	{
   232 	{
   228 	CleanupStack::PopAndDestroy(meta);
   237 	CleanupStack::PopAndDestroy(meta);
   229 	}
   238 	}
   230 		
   239 		
   231 void CMTPMoveObject::RunL()
   240 void CMTPMoveObject::RunL()
   232     {
   241     {
   233     __FLOG( _L8("+RunL") );
   242     OstTraceFunctionEntry0( CMTPMOVEOBJECT_RUNL_ENTRY );
   234     if ( iStatus==KErrNone )
   243     if ( iStatus==KErrNone )
   235         {
   244         {
   236         switch ( iState )
   245         switch ( iState )
   237             {
   246             {
   238             case ERemoveSourceFolderTree:
   247             case ERemoveSourceFolderTree:
   251     else
   260     else
   252         {
   261         {
   253         SendResponseL( iResponse.Uint16( TMTPTypeResponse::EResponseCode ) );
   262         SendResponseL( iResponse.Uint16( TMTPTypeResponse::EResponseCode ) );
   254         }
   263         }
   255 
   264 
   256     __FLOG( _L8("-RunL") );
   265     OstTraceFunctionExit0( CMTPMOVEOBJECT_RUNL_EXIT );
   257     }
   266     }
   258     	
   267     	
   259 TInt CMTPMoveObject::RunError(TInt /*aError*/)
   268 TInt CMTPMoveObject::RunError(TInt /*aError*/)
   260 	{
   269 	{
   261 	TRAP_IGNORE(SendResponseL(EMTPRespCodeGeneralError));
   270 	TRAP_IGNORE(SendResponseL(EMTPRespCodeGeneralError));
   287     iFramework.SendResponseL(iResponse, req, Connection());
   296     iFramework.SendResponseL(iResponse, req, Connection());
   288     }
   297     }
   289 
   298 
   290 TMTPResponseCode CMTPMoveObject::CreateFolderL()
   299 TMTPResponseCode CMTPMoveObject::CreateFolderL()
   291     {
   300     {
   292     __FLOG( _L8("+CreateFolderL") );
   301     OstTraceFunctionEntry0( CMTPMOVEOBJECT_CREATEFOLDERL_ENTRY );
   293     TMTPResponseCode ret = EMTPRespCodeOK;
   302     TMTPResponseCode ret = EMTPRespCodeOK;
   294     
   303     
   295     GetParametersL();
   304     GetParametersL();
   296     __FLOG_1( _L("New folder parent: %S"), &iNewParent );
   305     OstTraceExt1( TRACE_NORMAL, CMTPMOVEOBJECT_CREATEFOLDERL, "New folder parent: %S", iNewParent );
       
   306     
   297     const TDesC& oldPath = iObjInfoCache->DesC( CMTPObjectMetaData::ESuid );
   307     const TDesC& oldPath = iObjInfoCache->DesC( CMTPObjectMetaData::ESuid );
   298     if ( iFolderToRemove.Length() == 0 )
   308     if ( iFolderToRemove.Length() == 0 )
   299         {
   309         {
   300         iFolderToRemove = oldPath;
   310         iFolderToRemove = oldPath;
   301         }
   311         }
   302     
   312     
   303     TFileName fileNamePart;
   313     TFileName fileNamePart;
   304     User::LeaveIfError( BaflUtils::MostSignificantPartOfFullName( oldPath, fileNamePart ) );
   314     LEAVEIFERROR( BaflUtils::MostSignificantPartOfFullName( oldPath, fileNamePart ),
   305     __FLOG_1( _L("Folder name: %S"), &fileNamePart );
   315             OstTraceExt1( TRACE_ERROR, DUP1_CMTPMOVEOBJECT_CREATEFOLDERL, "can't get Folder or file name for %S", oldPath));
       
   316 
       
   317     OstTraceExt1( TRACE_NORMAL, DUP2_CMTPMOVEOBJECT_CREATEFOLDERL, "Folder name: %S", fileNamePart );
   306     
   318     
   307     if ( ( iNewParent.Length() + fileNamePart.Length() + 1 ) <= iNewParent.MaxLength() )
   319     if ( ( iNewParent.Length() + fileNamePart.Length() + 1 ) <= iNewParent.MaxLength() )
   308         {
   320         {
   309         iNewParent.Append( fileNamePart );
   321         iNewParent.Append( fileNamePart );
   310         iNewParent.Append( KPathDelimiter );
   322         iNewParent.Append( KPathDelimiter );
   313         {
   325         {
   314         ret = EMTPRespCodeInvalidParentObject;
   326         ret = EMTPRespCodeInvalidParentObject;
   315         }
   327         }
   316     if ( EMTPRespCodeOK == ret )
   328     if ( EMTPRespCodeOK == ret )
   317         {
   329         {
   318         __FLOG_VA( ( _L("Try to move %S to %S"), &oldPath, &iNewParent ) );
   330         OstTraceExt2( TRACE_NORMAL, DUP3_CMTPMOVEOBJECT_CREATEFOLDERL, 
       
   331                 "Try to move %S to %S", oldPath, iNewParent );
   319         ret = CanMoveObjectL( oldPath, iNewParent );
   332         ret = CanMoveObjectL( oldPath, iNewParent );
   320         
   333         
   321         if ( EMTPRespCodeOK == ret )
   334         if ( EMTPRespCodeOK == ret )
   322             {
   335             {
   323             TInt err = iFramework.Fs().MkDir( iNewParent );
   336             TInt err = iFramework.Fs().MkDir( iNewParent );
   324             User::LeaveIfError( err );
   337             LEAVEIFERROR( err, 
       
   338                     OstTraceExt2( TRACE_ERROR, DUP4_CMTPMOVEOBJECT_CREATEFOLDERL, "make directory %S error! error code %d", iNewParent, err));
   325             iNewHandleParentStack.AppendL( iObjInfoCache->Uint( CMTPObjectMetaData::EHandle ) );
   339             iNewHandleParentStack.AppendL( iObjInfoCache->Uint( CMTPObjectMetaData::EHandle ) );
   326             }
   340             }
   327         }
   341         }
   328     
   342     
   329     __FLOG( _L8("-CreateFolderL") );
   343     OstTraceFunctionExit0( CMTPMOVEOBJECT_CREATEFOLDERL_EXIT );
   330     return ret;
   344     return ret;
   331     }
   345     }
   332 
   346 
   333 void CMTPMoveObject::RemoveSourceFolderTreeL()
   347 void CMTPMoveObject::RemoveSourceFolderTreeL()
   334     {
   348     {
   335     __FLOG( _L8("+RemoveSourceFolderTreeL") );
   349     OstTraceFunctionEntry0( CMTPMOVEOBJECT_REMOVESOURCEFOLDERTREEL_ENTRY );
   336     
   350     
   337     if ( iFolderToRemove.Length() > 0 )
   351     if ( iFolderToRemove.Length() > 0 )
   338         {
   352         {
   339         __FLOG_1( _L("Removing %S"), &iFolderToRemove );
   353         OstTraceExt1(TRACE_NORMAL, CMTPMOVEOBJECT_REMOVESOURCEFOLDERTREEL, "Removing %S", iFolderToRemove);
   340         delete iFileMan;
   354         delete iFileMan;
   341         iFileMan = NULL;
   355         iFileMan = NULL;
   342         iFileMan = CFileMan::NewL( iFramework.Fs() );
   356         iFileMan = CFileMan::NewL( iFramework.Fs() );
   343         
   357         
   344         iState = ERemoveSourceFolderTree;
   358         iState = ERemoveSourceFolderTree;
   345         User::LeaveIfError( iFileMan->RmDir( iFolderToRemove, iStatus ) );
   359         LEAVEIFERROR( iFileMan->RmDir( iFolderToRemove, iStatus ),
       
   360                 OstTraceExt1( TRACE_ERROR, DUP1_CMTPMOVEOBJECT_REMOVESOURCEFOLDERTREEL, "delete directory %S error", iFolderToRemove));
       
   361                 
   346         SetActive();
   362         SetActive();
   347         }
   363         }
   348     else
   364     else
   349         {
   365         {
   350         SendResponseL( iResponse.Uint16( TMTPTypeResponse::EResponseCode ) );
   366         SendResponseL( iResponse.Uint16( TMTPTypeResponse::EResponseCode ) );
   351         }
   367         }
   352     
   368     
   353     __FLOG( _L8("-RemoveSourceFolderTreeL") );
   369     OstTraceFunctionExit0( CMTPMOVEOBJECT_REMOVESOURCEFOLDERTREEL_EXIT );
   354     }
   370     }
   355 
   371 
   356 void CMTPMoveObject::BrowseHandlesL()
   372 void CMTPMoveObject::BrowseHandlesL()
   357     {
   373     {
   358     __FLOG( _L8("+BrowseHandlesL") );
   374     OstTraceFunctionEntry0( CMTPMOVEOBJECT_BROWSEHANDLESL_ENTRY );
   359     
   375     
   360     iFolderToRemove.SetLength( 0 );
   376     iFolderToRemove.SetLength( 0 );
   361     iState = EInit;
   377     iState = EInit;
   362     
   378     
   363     delete iObjBrowser;
   379     delete iObjBrowser;
   379     CMTPObjectBrowser::TBrowseCallback callback = { CMTPMoveObject::OnBrowseObjectL, this };
   395     CMTPObjectBrowser::TBrowseCallback callback = { CMTPMoveObject::OnBrowseObjectL, this };
   380     TUint32 handle = Request().Uint32( TMTPTypeRequest::ERequestParameter1 );
   396     TUint32 handle = Request().Uint32( TMTPTypeRequest::ERequestParameter1 );
   381     TUint32 newHandleParent = Request().Uint32( TMTPTypeRequest::ERequestParameter3 );
   397     TUint32 newHandleParent = Request().Uint32( TMTPTypeRequest::ERequestParameter3 );
   382     iNewHandleParentStack.AppendL( newHandleParent );
   398     iNewHandleParentStack.AppendL( newHandleParent );
   383     iObjBrowser->GoL( KMTPFormatsAll, handle, KMaxTUint32, callback );
   399     iObjBrowser->GoL( KMTPFormatsAll, handle, KMaxTUint32, callback );
   384     __FLOG_1( _L8("iHandles.Count() = %d"), iHandles.Count() );
   400     OstTrace1( TRACE_NORMAL, CMTPMOVEOBJECT_BROWSEHANDLESL, "iHandles.Count() = %d",  iHandles.Count());
       
   401     
   385     
   402     
   386     if ( iHandles.Count() > 0 )
   403     if ( iHandles.Count() > 0 )
   387         {
   404         {
   388         iCurrentHandle = iHandles.Count() - 1;
   405         iCurrentHandle = iHandles.Count() - 1;
   389         Schedule( KErrNone );
   406         Schedule( KErrNone );
   391     else
   408     else
   392         {
   409         {
   393         SendResponseL( EMTPRespCodeInvalidObjectHandle );
   410         SendResponseL( EMTPRespCodeInvalidObjectHandle );
   394         }
   411         }
   395     
   412     
   396     __FLOG( _L8("-BrowseHandlesL") );
   413     OstTraceFunctionExit0( CMTPMOVEOBJECT_BROWSEHANDLESL_EXIT );
   397     }
   414     }
   398 
   415 
   399 void CMTPMoveObject::NextObjectHandleL()
   416 void CMTPMoveObject::NextObjectHandleL()
   400     {
   417     {
   401     __FLOG( _L8("+NextObjectHandleL") );
   418     OstTraceFunctionEntry0( CMTPMOVEOBJECT_NEXTOBJECTHANDLEL_ENTRY );
   402     __ASSERT_DEBUG( ( iNewHandleParentStack.Count() > 0 ), User::Invariant() );
   419     __ASSERT_DEBUG( ( iNewHandleParentStack.Count() > 0 ), User::Invariant() );
   403     iOwnerDp = KInvalidDpId;
   420     iOwnerDp = KInvalidDpId;
   404     if ( iCurrentHandle >=0 )
   421     if ( iCurrentHandle >=0 )
   405         {
   422         {
   406         __FLOG_1( _L8("iCurrentHandle = %d"), iCurrentHandle );
   423         OstTrace1( TRACE_NORMAL, CMTPMOVEOBJECT_NEXTOBJECTHANDLEL, "iCurrentHandle = %d", iCurrentHandle );
       
   424         
   407         TUint32 handle = iHandles[iCurrentHandle];
   425         TUint32 handle = iHandles[iCurrentHandle];
   408         TUint32 depth = iHandleDepths[iCurrentHandle];
   426         TUint32 depth = iHandleDepths[iCurrentHandle];
   409         __FLOG_1( _L8("depth = %d"), depth );
   427         OstTrace1( TRACE_NORMAL, DUP1_CMTPMOVEOBJECT_NEXTOBJECTHANDLEL, "depth = %d", depth );
   410         if ( iCurrentHandle !=  ( iHandles.Count() - 1 ) )
   428         if ( iCurrentHandle !=  ( iHandles.Count() - 1 ) )
   411             {
   429             {
   412             TUint32 previousDepth = iHandleDepths[iCurrentHandle + 1];
   430             TUint32 previousDepth = iHandleDepths[iCurrentHandle + 1];
   413             __FLOG_1( _L8("previousDepth = %d"), previousDepth );
   431             OstTrace1( TRACE_NORMAL, DUP2_CMTPMOVEOBJECT_NEXTOBJECTHANDLEL, "previousDepth = %d", previousDepth );
   414             if ( depth < previousDepth )
   432             if ( depth < previousDepth )
   415                 {
   433                 {
   416                 // Completed copying folder and all its sub-folder and files, pop all copied folders' handle which are not shallower than the current one.
   434                 // Completed copying folder and all its sub-folder and files, pop all copied folders' handle which are not shallower than the current one.
   417                 
   435                 
   418                 // Step 1: pop the previous handle itself if it is am empty folder
   436                 // Step 1: pop the previous handle itself if it is am empty folder
   458     else
   476     else
   459         {
   477         {
   460         RemoveSourceFolderTreeL();
   478         RemoveSourceFolderTreeL();
   461         }
   479         }
   462     
   480     
   463     __FLOG( _L8("-NextObjectHandleL") );
   481     OstTraceFunctionExit0( CMTPMOVEOBJECT_NEXTOBJECTHANDLEL_EXIT );
   464     }
   482     }
   465 
   483 
   466 void CMTPMoveObject::OnBrowseObjectL( TAny* aSelf, TUint aHandle, TUint32 aCurDepth )
   484 void CMTPMoveObject::OnBrowseObjectL( TAny* aSelf, TUint aHandle, TUint32 aCurDepth )
   467     {
   485     {
   468     CMTPMoveObject* self = reinterpret_cast< CMTPMoveObject* >( aSelf );
   486     CMTPMoveObject* self = reinterpret_cast< CMTPMoveObject* >( aSelf );